a
554325746@qq.com
2019-05-29 1bef2d413cd9eae19fa7aff0524f73aa3f94b113
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package com.basic.security.utils;
 
import android.os.SystemClock;
import android.text.TextUtils;
 
import com.basic.security.activity.MainActivity;
import com.basic.security.base.BaseApplication;
import com.basic.security.manager.AlarmManager;
import com.basic.security.manager.SettingManager;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
 
import org.json.JSONArray;
 
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class SocketClient extends Thread {
    Socket socket;
    private String ip;
    private int port;
 
    public SocketClient(String ip, int port) {
        this.ip = ip;
        this.port = port;
    }
 
    public static boolean needRestart = false;
 
    public Comparator<Map<String, String>> mapComparator = new Comparator<Map<String, String>>() {
        public int compare(Map<String, String> m1, Map<String, String> m2) {
            try {
                double score1 = Double.parseDouble(m1.get("likePer"));
                double score2 = Double.parseDouble(m2.get("likePer"));
                return (int)(score1 - score2);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }
    };
 
    public void parseJson(String msg) {
 
        JsonParser parser = new JsonParser();
        boolean isJSON = true;
        JsonElement element = null;
        try {
            element = parser.parse(msg);
        } catch (JsonParseException e) {
            System.out.println("exception: "+ msg + " " + e);
            isJSON = false;
        }
        newRemoteAlarmList = new ArrayList<>();
        if (isJSON && element != null) {
            Object obj = element.getAsJsonObject();
            JsonArray dataList = (JsonArray) ((JsonObject) obj).get("datalist");
            for (int i = 0; i < dataList.size(); i++) {
                JsonObject je = (JsonObject)dataList.get(i);
                Map<String, String> newRemoteAlarm = new HashMap<>();
                for(Map.Entry<String, JsonElement> entry : je.entrySet()) {
                    Object value = entry.getValue();
                    String key = entry.getKey();
                    if (value != null) {
                        if ("baseInfo".equals(key)) {
                            List<Map<String, String>> matchPersonMapList = new ArrayList<>();
                            List<String> matchPersonStrList = new ArrayList<>();
                            String matchPersonListStr = "";
                            if (value instanceof JsonArray) {
                                JsonArray matchPersonList = (JsonArray)value;
                                for (int ii = 0; ii < matchPersonList.size(); ii++ ) {
                                    JsonObject matchPerson = (JsonObject)matchPersonList.get(ii);
                                    Map<String, String> matchPersonMap = new HashMap<>();
 
                                    for(Map.Entry<String, JsonElement> matchPersonEntry : matchPerson.entrySet()) {
                                        String matchPersonKey = matchPersonEntry.getKey();
                                        Object matchPersonValue = matchPersonEntry.getValue();
                                        if (matchPersonValue != null) {
                                            String matchPersonValueStr = matchPersonValue.toString();
                                            if (matchPersonValueStr.startsWith("\"")) {
                                                matchPersonValueStr = matchPersonValueStr.substring(1);
                                            }
                                            if (matchPersonValueStr.endsWith("\"")) {
                                                matchPersonValueStr = matchPersonValueStr.substring(0, matchPersonValueStr.length() - 1);
                                            }
                                            matchPersonMap.put(matchPersonKey, matchPersonValueStr);
                                        } else {
                                            matchPersonMap.put(matchPersonKey, "");
                                        }
                                    }
                                    matchPersonMap.put("mathPersonStr",  matchPersonMap.get("tableName")+ " " +  matchPersonMap.get("personName"));
                                    matchPersonMapList.add(matchPersonMap);
                                }
                                Collections.sort(matchPersonMapList, mapComparator);
                                for (Map<String, String> matchPersonMap : matchPersonMapList) {
                                    matchPersonStrList.add(matchPersonMap.get("mathPersonStr"));
                                }
                                matchPersonListStr = TextUtils.join("`", matchPersonStrList);
                            }
                            newRemoteAlarm.put("matchPersonListStr", matchPersonListStr);
                        } else {
                            newRemoteAlarm.put(entry.getKey(), value.toString());
                        }
                    }
                }
                newRemoteAlarmList.add(newRemoteAlarm);
            }
//
            if (newRemoteAlarmList != null && newRemoteAlarmList.size() > 0) {
//                                        System.out.println("receive");
//                                        if (1==1) {
//                                            return;
//                                        }
                AlarmManager.renameKeys(newRemoteAlarmList);
                if (AlarmManager.saveRemoteAlarmListToSqlite(newRemoteAlarmList) > 0) {
                    ((MainActivity)BaseApplication.getApplication().activity).fragment_home.refreshGridView();
                }
            } else {
                if (((MainActivity)BaseApplication.getApplication().activity).currentFragment ==
                        ((MainActivity)BaseApplication.getApplication().activity).fragment_home) {
                    ToastUtil.show("获取报警数据失败");
                }
            }
        }
    }
 
    List<Map<String, String>> newRemoteAlarmList = null;
    @Override
    public void run() {
        super.run();
        BufferedInputStream inputStream = null;
        BufferedOutputStream outputStream = null;
        Socket socket = null;
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        String msg = null;
        try {
            while (true) {
                try {
                    if (1!=1) {
                        msg = "{ \t\"datalist\": [ \t\t{ \t\t\t\"content\": \"\", \t\t\t\"id\": \"8a769d1c-886c-487c-a934-e92b09d8f189\", \t\t\t\"personIsHub\": \"1\", \t\t\t\"picAddress\": \"学校南围墙西段中向东     周界\", \t\t\t\"picDate\": \"2019-05-17 12:19:26\", \t\t\t\"picMaxUrl\": \"http://58.118.225.79:44280/group4/M00/07/4E/rBEy8VzbdN2AVqJIABGqRF1VFR0033.jpg\", \t\t\t\"picSmUrl\": \"http://58.118.225.79:44280/group3/M00/05/18/rBEy81yy6n2AFGElABQIY3pylXU412.jpg\", \t\t\t\"sdkType\": \"入侵\", \t\t\t\"taskName\": \"taskName刘欣\", \t\t\t\"videoIp\": \"学校南围墙西段中向东     周界\", \t\t\t\"videoNum\": \"http://58.118.225.79:44480/videosource/210235C23NF187000168/201905/15/2019051510/210235C23NF187000168$2019-05-15-10-09-37_454639_454888.mp4\", \t\t\t\"videoReqNum\": \"cid3\" \t\t}, \t\t{ \t\t\t\"ID\": \"68a6fe5c-1cb1-4e3c-bc4a-22d678f76e8d\", \t\t\t\"IDCard\": [ \t\t\t\t\"54319001230310455431\", \t\t\t\t\"54319001102134569375\", \t\t\t\t\"54319001310104514563\", \t\t\t\t\"54319001100121231977\", \t\t\t\t\"54319001202319872643\", \t\t\t\t\"54319001230310455431\", \t\t\t\t\"54319001102134569375\" \t\t\t], \t\t\t\"ageDescription\": \"青年\", \t\t\t\"baseInfo\": [ \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001230310455431\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"43\", \t\t\t\t\t\"monitorLevel\": \"2\", \t\t\t\t\t\"personId\": \"70171c10-d8ba-4b7c-a7ec-94d4f89a8d7d\", \t\t\t\t\t\"personName\": \"石破天\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfb968957dfa\", \t\t\t\t\t\"phoneNum\": \"11093456217\", \t\t\t\t\t\"tableId\": \"80a5935d-c6b4-4678-9c76-a6b01c07725b\", \t\t\t\t\t\"tableName\": \"底库124\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001102134569375\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"41\", \t\t\t\t\t\"monitorLevel\": \"3\", \t\t\t\t\t\"personId\": \"68d89b3e-e4db-42eb-ac75-aa8c1082a087\", \t\t\t\t\t\"personName\": \"孙悟空\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfbaa2516ad2\", \t\t\t\t\t\"phoneNum\": \"11031248765\", \t\t\t\t\t\"tableId\": \"5a544e15-2c40-4e54-a12b-f6a0f71f3fbd\", \t\t\t\t\t\"tableName\": \"底库123\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001310104514563\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"78\", \t\t\t\t\t\"monitorLevel\": \"1\", \t\t\t\t\t\"personId\": \"83a42f98-ad21-466f-97aa-24bff1b0340f\", \t\t\t\t\t\"personName\": \"黄飞鸿\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfbb19faece3\", \t\t\t\t\t\"phoneNum\": \"11067854653\", \t\t\t\t\t\"tableId\": \"0cb7f275-9fb3-434e-9122-e59f551443ea\", \t\t\t\t\t\"tableName\": \"底库123412\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001100121231977\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"20\", \t\t\t\t\t\"monitorLevel\": \"2\", \t\t\t\t\t\"personId\": \"fed7b71c-d5eb-4feb-86d9-0522d7034412\", \t\t\t\t\t\"personName\": \"李逍遥\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9601/11,06dfb71c698169\", \t\t\t\t\t\"phoneNum\": \"11012344321\", \t\t\t\t\t\"tableId\": \"f008bf89-9406-490d-868b-6dd679cae954\", \t\t\t\t\t\"tableName\": \"同步库2\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001202319872643\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"40\", \t\t\t\t\t\"monitorLevel\": \"3\", \t\t\t\t\t\"personId\": \"f290bb54-4de8-496b-8612-a8c563ab45e1\", \t\t\t\t\t\"personName\": \"令狐冲\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9601/8,06dfb8facdaf8a\", \t\t\t\t\t\"phoneNum\": \"11039876431\", \t\t\t\t\t\"tableId\": \"ce228150-448b-4e70-9b08-374ed7c5bc3e\", \t\t\t\t\t\"tableName\": \"123\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001230310455431\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"86\", \t\t\t\t\t\"monitorLevel\": \"1\", \t\t\t\t\t\"personId\": \"70171c10-d8ba-4b7c-a7ec-94d4f89a8d7d\", \t\t\t\t\t\"personName\": \"石破天\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfb968957dfa\", \t\t\t\t\t\"phoneNum\": \"11093456217\", \t\t\t\t\t\"tableId\": \"af6dd3b3-dc94-42ee-8347-f12214c2562f\", \t\t\t\t\t\"tableName\": \"同步库3\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001102134569375\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"66\", \t\t\t\t\t\"monitorLevel\": \"2\", \t\t\t\t\t\"personId\": \"68d89b3e-e4db-42eb-ac75-aa8c1082a087\", \t\t\t\t\t\"personName\": \"孙悟空\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfbaa2516ad2\", \t\t\t\t\t\"phoneNum\": \"11031248765\", \t\t\t\t\t\"tableId\": \"2e0640d0-33e5-45e6-b024-3fe165c6f9e9\", \t\t\t\t\t\"tableName\": \"测试底库名称超长字数测试\" \t\t\t\t} \t\t\t], \t\t\t\"content\": \"\", \t\t\t\"gender\": \"男\", \t\t\t\"id\": \"68a6fe5c-1cb1-4e3c-bc4a-22d678f76e8d\", \t\t\t\"indeviceName\": \"视频分析设备244\", \t\t\t\"personIsHub\": \"1\", \t\t\t\"picAddress\": \"测试地址\", \t\t\t\"picDate\": \"2019-05-17 12:19:21\", \t\t\t\"picMaxUrl\": \"http://58.118.225.79:44280/group4/M00/07/6A/rBEy8VzbhTaABvYpAAgn7hKYC2g311.jpg\", \t\t\t\"picSmUrl\": \"http://58.118.225.79:44280/group2/M00/00/B4/rBEy9Fx1Bn2ASQ6FAABDPo9CwFw073.jpg\", \t\t\t\"race\": \"黄人\", \t\t\t\"sdkType\": \"人脸\", \t\t\t\"taskName\": \"run\", \t\t\t\"videoIp\": \"172.17.50.244\", \t\t\t\"videoNum\": \"http://192.168.1.203:9600/12,017dae9d21ac08\", \t\t\t\"videoReqNum\": \"cid3\" \t\t}, \t\t{ \t\t\t\"content\": \"\", \t\t\t\"id\": \"fea3e88f-a2c4-4a07-a19d-89c336f446ee\", \t\t\t\"personIsHub\": \"1\", \t\t\t\"picAddress\": \"学校南围墙西段东向西     周界\", \t\t\t\"picDate\": \"2019-05-17 12:19:21\", \t\t\t\"picMaxUrl\": \"http://58.118.225.79:44280/group4/M00/07/4E/rBEy8VzbdN2AVqJIABGqRF1VFR0033.jpg\", \t\t\t\"picSmUrl\": \"http://58.118.225.79:44280/group3/M00/05/18/rBEy81yy6Y-AORXtABZqoERSp9I640.jpg\", \t\t\t\"sdkType\": \"入侵\", \t\t\t\"taskName\": \"taskName刘欣\", \t\t\t\"videoIp\": \"学校南围墙西段东向西     周界\", \t\t\t\"videoNum\": \"http://58.118.225.79:44480/videosource/210235C23NF187000168/201905/15/2019051510/210235C23NF187000168$2019-05-15-10-09-37_454639_454888.mp4\", \t\t\t\"videoReqNum\": \"cid2\" \t\t}, \t\t{ \t\t\t\"content\": \"\", \t\t\t\"id\": \"5fa82d38-b725-45dc-907e-a7ee0ad3e803\", \t\t\t\"personIsHub\": \"1\", \t\t\t\"picAddress\": \"学校南围墙西段东向西     周界\", \t\t\t\"picDate\": \"2019-05-17 12:19:16\", \t\t\t\"picMaxUrl\": \"http://58.118.225.79:44280/group4/M00/07/4E/rBEy8VzbdN2AVqJIABGqRF1VFR0033.jpg\", \t\t\t\"picSmUrl\": \"http://58.118.225.79:44280/group3/M00/05/18/rBEy81yy6Y2AHleCABVr-OZBNps388.jpg\", \t\t\t\"sdkType\": \"入侵\", \t\t\t\"taskName\": \"taskName刘欣\", \t\t\t\"videoIp\": \"学校南围墙西段东向西     周界\", \t\t\t\"videoNum\": \"http://58.118.225.79:44480/videosource/210235C23NF187000168/201905/15/2019051510/210235C23NF187000168$2019-05-15-10-09-37_454639_454888.mp4\", \t\t\t\"videoReqNum\": \"cid1\" \t\t}, \t\t{ \t\t\t\"ID\": \"3bce3eef-2062-456e-b5cb-d1a4cc63c158\", \t\t\t\"IDCard\": [ \t\t\t\t\"54319001202319872643\", \t\t\t\t\"54319001230310455431\", \t\t\t\t\"54319001102134569375\", \t\t\t\t\"54319001310104514563\", \t\t\t\t\"54319001100121231977\", \t\t\t\t\"54319001202319872643\" \t\t\t], \t\t\t\"ageDescription\": \"青年\", \t\t\t\"baseInfo\": [ \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001202319872643\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"3\", \t\t\t\t\t\"monitorLevel\": \"1\", \t\t\t\t\t\"personId\": \"f290bb54-4de8-496b-8612-a8c563ab45e1\", \t\t\t\t\t\"personName\": \"令狐冲\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9601/8,06dfb8facdaf8a\", \t\t\t\t\t\"phoneNum\": \"11039876431\", \t\t\t\t\t\"tableId\": \"2e0640d0-33e5-45e6-b024-3fe165c6f9e9\", \t\t\t\t\t\"tableName\": \"测试底库名称超长字数测试\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001230310455431\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"31\", \t\t\t\t\t\"monitorLevel\": \"2\", \t\t\t\t\t\"personId\": \"70171c10-d8ba-4b7c-a7ec-94d4f89a8d7d\", \t\t\t\t\t\"personName\": \"石破天\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfb968957dfa\", \t\t\t\t\t\"phoneNum\": \"11093456217\", \t\t\t\t\t\"tableId\": \"80a5935d-c6b4-4678-9c76-a6b01c07725b\", \t\t\t\t\t\"tableName\": \"底库124\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001102134569375\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"1\", \t\t\t\t\t\"monitorLevel\": \"3\", \t\t\t\t\t\"personId\": \"68d89b3e-e4db-42eb-ac75-aa8c1082a087\", \t\t\t\t\t\"personName\": \"孙悟空\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfbaa2516ad2\", \t\t\t\t\t\"phoneNum\": \"11031248765\", \t\t\t\t\t\"tableId\": \"5a544e15-2c40-4e54-a12b-f6a0f71f3fbd\", \t\t\t\t\t\"tableName\": \"底库123\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001310104514563\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"1\", \t\t\t\t\t\"monitorLevel\": \"1\", \t\t\t\t\t\"personId\": \"83a42f98-ad21-466f-97aa-24bff1b0340f\", \t\t\t\t\t\"personName\": \"黄飞鸿\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9600/12,06dfbb19faece3\", \t\t\t\t\t\"phoneNum\": \"11067854653\", \t\t\t\t\t\"tableId\": \"0cb7f275-9fb3-434e-9122-e59f551443ea\", \t\t\t\t\t\"tableName\": \"底库123412\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001100121231977\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"男\", \t\t\t\t\t\"likePer\": \"48\", \t\t\t\t\t\"monitorLevel\": \"2\", \t\t\t\t\t\"personId\": \"fed7b71c-d5eb-4feb-86d9-0522d7034412\", \t\t\t\t\t\"personName\": \"李逍遥\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9601/11,06dfb71c698169\", \t\t\t\t\t\"phoneNum\": \"11012344321\", \t\t\t\t\t\"tableId\": \"f008bf89-9406-490d-868b-6dd679cae954\", \t\t\t\t\t\"tableName\": \"同步库2\" \t\t\t\t}, \t\t\t\t{ \t\t\t\t\t\"IDCard\": \"54319001202319872643\", \t\t\t\t\t\"content\": \"\", \t\t\t\t\t\"gender\": \"女\", \t\t\t\t\t\"likePer\": \"97\", \t\t\t\t\t\"monitorLevel\": \"3\", \t\t\t\t\t\"personId\": \"f290bb54-4de8-496b-8612-a8c563ab45e1\", \t\t\t\t\t\"personName\": \"令狐冲\", \t\t\t\t\t\"personPicUrl\": \"http://192.168.1.203:9601/8,06dfb8facdaf8a\", \t\t\t\t\t\"phoneNum\": \"11039876431\", \t\t\t\t\t\"tableId\": \"ce228150-448b-4e70-9b08-374ed7c5bc3e\", \t\t\t\t\t\"tableName\": \"123\" \t\t\t\t} \t\t\t], \t\t\t\"content\": \"\", \t\t\t\"gender\": \"男\", \t\t\t\"id\": \"3bce3eef-2062-456e-b5cb-d1a4cc63c158\", \t\t\t\"indeviceName\": \"视频分析设备244\", \t\t\t\"personIsHub\": \"1\", \t\t\t\"picAddress\": \"测试地址\", \t\t\t\"picDate\": \"2019-05-17 12:19:16\", \t\t\t\"picMaxUrl\": \"http://58.118.225.79:44280/group4/M00/07/6A/rBEy8VzbhTaABvYpAAgn7hKYC2g311.jpg\", \t\t\t\"picSmUrl\": \"http://58.118.225.79:44280/group2/M00/00/B4/rBEy9Fx1Bn-AS7idAAAgkMt8drY443.jpg\", \t\t\t\"race\": \"黑人\", \t\t\t\"sdkType\": \"人脸\", \t\t\t\"taskName\": \"face\", \t\t\t\"videoIp\": \"172.17.50.244\", \t\t\t\"videoNum\": \"http://192.168.1.203:9600/12,017dae9d21ac08\", \t\t\t\"videoReqNum\": \"cid2\" \t\t} \t], \t\"total\": 5 }";
                        parseJson(msg);
                        SystemClock.sleep(2000);
                        continue;
                    }
                    ip = SettingManager.getIpStr();
                    port = SettingManager.getPort();
                    socket = new Socket();
                    socket.connect(new InetSocketAddress(ip, port), 3000);
//                    socket.connect(new InetSocketAddress(ip, 7000), 3000);
                    inputStream = new BufferedInputStream(socket.getInputStream());
                    outputStream = new BufferedOutputStream(socket.getOutputStream());
 
                    byte[] buff = new byte[10*1024*1024];
                    int len = 0;
                    while ((len = inputStream.read(buff)) != -1) {
                        for (int i1 = 0; i1 <len; i1++) {
                            if (buff[i1] == '\0') {
                                byte[] msgBuf = byteArrayOutputStream.toByteArray();
                                msg = new String(msgBuf, 0, msgBuf.length);
                                msg = msg.substring(0, msg.lastIndexOf("}") + 1);
                                byteArrayOutputStream.reset();
                                System.out.println("msg="+msg);
                                parseJson(msg);
                            } else {
                                byteArrayOutputStream.write(buff[i1]);
                            }
                        }
                        if (needRestart) {
                            needRestart = false;
                            break;
                        }
                    }
                } catch (Exception e) {
                    System.out.println("SocketClient:110, " + e.getMessage());
                } finally {
                    if (socket != null) {
                        try {
                            socket.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    SystemClock.sleep(2000);
                }
            }
 
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (outputStream != null) {
                    outputStream.close();
                }
 
                if (inputStream != null) {
                    inputStream.close();
                }
 
                if (socket != null) {
                    socket.close();
                }
 
            } catch (IOException e) {
                e.printStackTrace();
            }
 
        }
 
    }
 
}