地质所 沉降监测网建设项目
zmk
2024-05-17 8722d2bb39c6c0697647e77a879d14b28d3ef0f5
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
package com.javaweb.third.baidu.bean.imgClassify;
 
 
import com.alibaba.fastjson.JSONObject;
import com.javaweb.third.baidu.bean.BaseResult;
 
import java.util.Map;
 
/**
 * 主体对象检测
 * @author wujiyue
 */
public class ObjectDetectResult extends BaseResult {
 
    private Map location;
    private Integer width;
    private Integer height;
    private Integer left;
    private Integer top;
 
    public ObjectDetectResult(String json){
        this.setJson(json);
        try{
            JSONObject jsonObject= JSONObject.parseObject(json);
            this.setLog_id(jsonObject.getString("log_id"));
            String e_code=String.valueOf(jsonObject.get("error_code"));
            if(notNull(e_code)){
                this.setError_code(e_code);
                String e_msg=String.valueOf(jsonObject.get("error_msg"));
                this.setError_msg(e_msg);
                this.setRequestOk(false);
            }else {
                this.location = JSONObject.parseObject(jsonObject.get("result").toString(), Map.class);
                if(this.location!=null) {
                    this.setRequestOk(true);
                    this.width=Integer.valueOf(String.valueOf(location.get("width")));
                    this.height=Integer.valueOf(String.valueOf(location.get("height")));
                    this.left=Integer.valueOf(String.valueOf(location.get("left")));
                    this.top=Integer.valueOf(String.valueOf(location.get("top")));
                }
            }
        }catch (Exception ex){
            ex.printStackTrace();
            this.setRequestOk(false);
            this.setError_msg("解析json字符串出现异常!");
        }
    }
    public static ObjectDetectResult create(String jsonStr) {
        return new ObjectDetectResult(jsonStr);
    }
 
    public Map getLocation() {
        return location;
    }
 
    public void setLocation(Map location) {
        this.location = location;
    }
 
    public Integer getWidth() {
        return width;
    }
 
    public void setWidth(Integer width) {
        this.width = width;
    }
 
    public Integer getHeight() {
        return height;
    }
 
    public void setHeight(Integer height) {
        this.height = height;
    }
 
    public Integer getLeft() {
        return left;
    }
 
    public void setLeft(Integer left) {
        this.left = left;
    }
 
    public Integer getTop() {
        return top;
    }
 
    public void setTop(Integer top) {
        this.top = top;
    }
 
    @Override
    public String toString() {
        if(isRequestOk()){
            return "ObjectDetectResult{" +
                    "location=" + location +
                    ", width=" + width +
                    ", height=" + height +
                    ", left=" + left +
                    ", top=" + top +
                    '}';
        }else{
            return getError_msg()+";错误代码["+getError_code()+"]"+";log_id["+getLog_id()+"]";
        }
 
    }
}