地质所 沉降监测网建设项目
zmk
2024-05-15 9e3afc6d0fa514f986d3fea40fa23124e6fb5070
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package com.javaweb.third.baidu.bean;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
/**
 * userDefine  用户自定义审核接口结果
 * @author wujiyue
 */
public class ImageVerifyResult{
    /**
     *结果json字符串
     */
    private String json;
    /**
     *true 合规  false 不合规
     */
    private boolean result;
    /**
     *1.合规,2.疑似,3.不合规
     */
    private int resultType;
    /**
     *描述
     */
    private String description;
    private List<ErrorMsgBean> data;
 
    public List<ErrorMsgBean> getData() {
        return data;
    }
 
    public void setData(List<ErrorMsgBean> data) {
        this.data = data;
    }
    public static ImageVerifyResult create(String jsonStr) {
        return new ImageVerifyResult(jsonStr);
    }
 
    @Override
    public String toString() {
        return "ImageVerifyResult{" +
                "result=" + result +
                ", resultType=" + resultType +
                ", description='" + description + '\'' +
                ", data=" + data +
                '}';
    }
 
    public boolean isResult() {
        return result;
    }
 
    public void setResult(boolean result) {
        this.result = result;
    }
 
    public int getResultType() {
        return resultType;
    }
 
    public void setResultType(int resultType) {
        this.resultType = resultType;
    }
 
    public String getDescription() {
        return description;
    }
 
    public void setDescription(String description) {
        this.description = description;
    }
 
    public class ErrorMsgBean{
        /**
         * 违规信息
         */
        private String msg;//
        /**
         * 违规类型代码
         */
        private String type;//
        /**
         * 概率
         */
        private Double probability;//
        /**
         * type=11 存在公众人物  会把人物识别名称和概率列出来   Map内的key有name、probability
         */
        private List<Map> stars;
 
        @Override
        public String toString() {
            return "ErrorMsgBean{" +
                    "stars=" + stars +
                    ", msg='" + msg + '\'' +
                    ", type='" + type + '\'' +
                    ", probability=" + probability +
                    '}';
        }
 
        public String getMsg() {
            return msg;
        }
 
        public void setMsg(String msg) {
            this.msg = msg;
        }
 
        public String getType() {
            return type;
        }
 
        public void setType(String type) {
            this.type = type;
        }
 
        public double getProbability() {
            return probability;
        }
 
        public void setProbability(Double probability) {
            this.probability = probability;
        }
 
        public List<Map> getStars() {
            return stars;
        }
 
        public void setStars(List<Map> stars) {
            this.stars = stars;
        }
 
 
    }
    public ImageVerifyResult(String json){
        //result:     {"conclusion":"不合规","log_id":152894126780709,"data":[{"msg":"存在水印码内容","probability":0.9978612,"type":5},{"msg":"存在公众人物","stars":[{"probability":0.65225273,"name":"血纯茗雅"}],"type":11}],"conclusionType":2}
        //result:     {"conclusion":"合规","log_id":152894144516161,"conclusionType":1}
        this.json = json;
        try{
            JSONObject o= JSON.parseObject(json);
            String conclusionType= String.valueOf(o.get("conclusionType"));
            String conclusion= String.valueOf(o.get("conclusion"));
            if("1".equals(conclusionType)){
                resultType=1;
                result=true;
                description=conclusion;
            }else if("2".equals(conclusionType)){
                resultType=2;
                result=false;
                description=conclusion;
            }else{
                resultType=3;
                result=false;
                description=conclusion;
            }
            if(!result){
                //不合格,就去获得不合格详细原因
                List<Map> list= JSONArray.parseArray(o.get("data").toString(), Map.class);
                if(list!=null&&list.size()>0){
                    List<ErrorMsgBean> errorMsgBeans=new ArrayList<ErrorMsgBean>();
                    ErrorMsgBean tempBean=null;
                    for(Map tmap:list){
                        tempBean=new ErrorMsgBean();
                        tempBean.setMsg(String.valueOf(tmap.get("msg")));
                        tempBean.setType(String.valueOf(tmap.get("type")));
                        if(tmap.get("probability")!=null){
                            tempBean.setProbability(Double.valueOf(String.valueOf(tmap.get("probability"))));
                        }else{
                            tempBean.setProbability(null);
                        }
                        if(tmap.get("stars")!=null){
                            List<Map> starsList= JSONArray.parseArray(tmap.get("stars").toString(), Map.class);
                            if(starsList!=null&&starsList.size()>0){
                                tempBean.setStars(starsList);
                            }
                        }
                        errorMsgBeans.add(tempBean);
                    }
                    this.data=errorMsgBeans;
                }
            }
 
        }catch (Exception ex){
            ex.printStackTrace();
            resultType=-1;
            result=false;
            description="结果解析异常!";
        }
 
    }
}