dingxin hace 6 años
padre
commit
5e926f9a20

BIN
CODE/smart-community/[B@5e730dac Ver fichero


BIN
CODE/smart-community/[B@6fdba475 Ver fichero


+ 13
- 0
CODE/smart-community/app-api/pom.xml Ver fichero

@@ -167,6 +167,19 @@
167 167
 			<version>3.1</version>
168 168
 		</dependency>
169 169
 
170
+		<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
171
+		<dependency>
172
+			<groupId>commons-io</groupId>
173
+			<artifactId>commons-io</artifactId>
174
+			<version>1.4</version>
175
+		</dependency>
176
+
177
+		<dependency>
178
+			<groupId>net.coobird</groupId>
179
+			<artifactId>thumbnailator</artifactId>
180
+			<version>0.4.2</version>
181
+		</dependency>
182
+
170 183
 
171 184
 	</dependencies>
172 185
 

+ 5
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/HKConstant.java Ver fichero

@@ -37,7 +37,6 @@ public class HKConstant {
37 37
      * <p>操作用户UUID,即用户UUID,首次使用操作用户UUID可以通过接口 [获取默认用户UUID]来获取</p>
38 38
      * <p>也可以通过接口[分页获取用户]来获取</p>
39 39
      */
40
-    public static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
41 40
 
42 41
     /**
43 42
      * 获取默认用户UUID的接口地址,此地址可以从《海康威视iVMS-8700平台SDKV2.*.* HTTP-OpenAPI使用说明书.chm》中具体的接口说明上获取
@@ -57,8 +56,12 @@ public class HKConstant {
57 56
     /**--主要是推送图片到海康
58 57
      * 通过此接口将人员名单添加到指定的人员分组当中,此接口适合一次添加一个人员,如果需要批量添加可以使用平台上自带的图片压缩包的方式批量添加。
59 58
      */
60
-    public  static  final  String OP_IMG="openapi/service/fas/personInfo/addPersonInfoIntoGroup";
59
+    public  static  final  String OP_IMG="/openapi/service/fas/personInfo/addPersonInfoIntoGroup";
61 60
 
62 61
     public static final String ITF_MONITORY_POINT = "/openapi/service/vss/res/getCamerasEx";
63 62
 
63
+    /**--推送图片时需要获取人员分组下的,人员分组ID
64
+     * --personGroupId--
65
+     */
66
+    public static final  String OP_PERSON_ID="/openapi/service/fas/personGroup/getPersonGroup";
64 67
 }

+ 104
- 10
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/HKOpenApi.java Ver fichero

@@ -1,18 +1,16 @@
1 1
 package com.community.huiju.common.hk;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4
+import com.community.huiju.common.hk.test.PicUtils;
4 5
 import com.google.common.collect.Maps;
5 6
 import com.hikvision.cms.api.common.util.Digests;
6 7
 import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
7 8
 import lombok.extern.slf4j.Slf4j;
8
-
9
-import javax.imageio.ImageIO;
10
-import java.awt.image.BufferedImage;
11
-import java.io.ByteArrayOutputStream;
12
-import java.io.File;
13
-import java.io.IOException;
14
-import java.net.MalformedURLException;
15
-import java.util.Base64;
9
+import net.coobird.thumbnailator.Thumbnails;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.web.multipart.MultipartFile;
13
+import java.io.*;
16 14
 import java.util.Map;
17 15
 
18 16
 /**
@@ -21,6 +19,7 @@ import java.util.Map;
21 19
  */
22 20
 @Slf4j
23 21
 public class HKOpenApi {
22
+    private static Logger logger = LoggerFactory.getLogger(PicUtils.class);
24 23
 
25 24
     public static String getMonitoryPoint(){
26 25
         Map<String,Object> parMap = Maps.newHashMap();
@@ -53,7 +52,7 @@ public class HKOpenApi {
53 52
      * @param imageFile
54 53
      * @return 加密之后的字符串
55 54
      */
56
-    public static String encodeImgageToBase64(String imageFile) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
55
+    /*public static String encodeImgageToBase64(String imageFile) {// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
57 56
         String img=getPicSuffix(String.valueOf(imageFile));
58 57
         ByteArrayOutputStream outputStream = null;
59 58
         try {
@@ -69,7 +68,7 @@ public class HKOpenApi {
69 68
         Base64.Encoder encoder = Base64.getEncoder();
70 69
 
71 70
         return encoder.encodeToString(outputStream.toByteArray());// 返回Base64编码过的字节数组字符串
72
-    }
71
+    }*/
73 72
 
74 73
     /**
75 74
      *
@@ -83,4 +82,99 @@ public class HKOpenApi {
83 82
         return img_path.substring(img_path.lastIndexOf(".") + 1).
84 83
                 trim().toLowerCase();
85 84
     }
85
+
86
+/*    //将本地图片进行Base64位编码
87
+    public static String getImgStr(String imgFile){
88
+        //将图片文件转化为字节数组字符串,并对其进行Base64编码处理
89
+        InputStream in = null;
90
+        byte[] data = null;
91
+        //读取图片字节数组
92
+        try
93
+        {
94
+            in = new FileInputStream(imgFile);
95
+            data = new byte[in.available()];
96
+            in.read(data);
97
+            in.close();
98
+        }
99
+        catch (IOException e)
100
+        {
101
+            e.printStackTrace();
102
+        }
103
+        return new String(org.apache.commons.codec.binary.Base64.encodeBase64(data));
104
+    }*/
105
+
106
+    //将本地图片进行Base64位编码
107
+    public static String getImgStr(MultipartFile imgFile){
108
+        //将图片文件转化为字节数组字符串,并对其进行Base64编码处理
109
+        byte[] data = null;
110
+        //读取图片字节数组
111
+        try
112
+        {
113
+            data = imgFile.getBytes();
114
+        }
115
+        catch (IOException e)
116
+        {
117
+            e.printStackTrace();
118
+        }
119
+        return new String(org.apache.commons.codec.binary.Base64.encodeBase64(data));
120
+    }
121
+
122
+    //将本地图片进行Base64位编码
123
+    public static String getImgStr(byte [] fileBytes){
124
+        return new String(org.apache.commons.codec.binary.Base64.encodeBase64(fileBytes));
125
+    }
126
+
127
+
128
+    /**
129
+     * 根据指定大小压缩图片
130
+     *
131
+     * @param imageBytes  源图片字节数组
132
+     * @param desFileSize 指定图片大小,单位kb
133
+     * @param imageId     影像编号
134
+     * @return 压缩质量后的图片字节数组
135
+     */
136
+    public static byte[] compressPicForScale(byte[] imageBytes, long desFileSize, String imageId) {
137
+        if (imageBytes == null || imageBytes.length <= 0 || imageBytes.length < desFileSize * 1024) {
138
+            return imageBytes;
139
+        }
140
+        long srcSize = imageBytes.length;
141
+        double accuracy = getAccuracy(srcSize / 1024);
142
+        try {
143
+            while (imageBytes.length > desFileSize * 1024) {
144
+                ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes);
145
+                ByteArrayOutputStream outputStream = new ByteArrayOutputStream(imageBytes.length);
146
+                Thumbnails.of(inputStream)
147
+                        .scale(accuracy)
148
+                        .outputQuality(accuracy)
149
+                        .toOutputStream(outputStream);
150
+                imageBytes = outputStream.toByteArray();
151
+            }
152
+            logger.info("【图片压缩】imageId={} | 图片原大小={}kb | 压缩后大小={}kb",
153
+                    imageId, srcSize / 1024, imageBytes.length / 1024);
154
+        } catch (Exception e) {
155
+            logger.error("【图片压缩】msg=图片压缩失败!", e);
156
+        }
157
+        return imageBytes;
158
+    }
159
+
160
+    /**
161
+     * 自动调节精度(经验数值)
162
+     *
163
+     * @param size 源图片大小
164
+     * @return 图片压缩质量比
165
+     */
166
+    private static double getAccuracy(long size) {
167
+        double accuracy;
168
+        if (size < 900) {
169
+            accuracy = 0.85;
170
+        } else if (size < 2047) {
171
+            accuracy = 0.6;
172
+        } else if (size < 3275) {
173
+            accuracy = 0.44;
174
+        } else {
175
+            accuracy = 0.4;
176
+        }
177
+        return accuracy;
178
+    }
179
+
86 180
 }

+ 1
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/test/OpenapiUtil.java Ver fichero

@@ -45,8 +45,7 @@ public class OpenapiUtil {
45 45
 	
46 46
 	/** 
47 47
      * 将本地图片进行Base64位编码 
48
-     *  
49
-     * @param imgUrl 
48
+     *
50 49
      *            图片的url路径,如http://.....xx.jpg 
51 50
      * @param extensioName 图片的扩展名
52 51
      * @return 加密之后的字符串

+ 84
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/test/PicUtils.java Ver fichero

@@ -0,0 +1,84 @@
1
+package com.community.huiju.common.hk.test;
2
+
3
+import net.coobird.thumbnailator.Thumbnails;
4
+import org.apache.commons.io.FileUtils;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+
8
+import java.io.ByteArrayInputStream;
9
+import java.io.ByteArrayOutputStream;
10
+import java.io.File;
11
+import java.io.IOException;
12
+
13
+/**
14
+ * 图片压缩Utils
15
+ *
16
+ * @author worstEzreal
17
+ * @version V1.1.0
18
+ * @date 2018/3/12
19
+ */
20
+public class PicUtils {
21
+
22
+    private static Logger logger = LoggerFactory.getLogger(PicUtils.class);
23
+
24
+   public static void main(String[] args) throws IOException {
25
+        byte[] bytes = FileUtils.readFileToByteArray(new File("C:\\Users\\DELL\\Pictures\\timg.jpg"));
26
+      long l = System.currentTimeMillis();
27
+       bytes = PicUtils.compressPicForScale(bytes, 20, "x");// 图片小于300kb
28
+        System.out.println(System.currentTimeMillis() - l);
29
+        FileUtils.writeByteArrayToFile(new File("C:\\Users\\DELL\\Pictures\\timg.jpg"), bytes);
30
+   }
31
+
32
+    /**
33
+     * 根据指定大小压缩图片
34
+     *
35
+     * @param imageBytes  源图片字节数组
36
+     * @param desFileSize 指定图片大小,单位kb
37
+     * @param imageId     影像编号
38
+     * @return 压缩质量后的图片字节数组
39
+     */
40
+    public static byte[] compressPicForScale(byte[] imageBytes, long desFileSize, String imageId) {
41
+        if (imageBytes == null || imageBytes.length <= 0 || imageBytes.length < desFileSize * 1024) {
42
+            return imageBytes;
43
+        }
44
+        long srcSize = imageBytes.length;
45
+        double accuracy = getAccuracy(srcSize / 1024);
46
+        try {
47
+            while (imageBytes.length > desFileSize * 1024) {
48
+                ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes);
49
+                ByteArrayOutputStream outputStream = new ByteArrayOutputStream(imageBytes.length);
50
+                Thumbnails.of(inputStream)
51
+                        .scale(accuracy)
52
+                        .outputQuality(accuracy)
53
+                        .toOutputStream(outputStream);
54
+                imageBytes = outputStream.toByteArray();
55
+            }
56
+            logger.info("【图片压缩】imageId={} | 图片原大小={}kb | 压缩后大小={}kb",
57
+                    imageId, srcSize / 1024, imageBytes.length / 1024);
58
+        } catch (Exception e) {
59
+            logger.error("【图片压缩】msg=图片压缩失败!", e);
60
+        }
61
+        return imageBytes;
62
+    }
63
+
64
+    /**
65
+     * 自动调节精度(经验数值)
66
+     *
67
+     * @param size 源图片大小
68
+     * @return 图片压缩质量比
69
+     */
70
+    private static double getAccuracy(long size) {
71
+        double accuracy;
72
+        if (size < 900) {
73
+            accuracy = 0.85;
74
+        } else if (size < 2047) {
75
+            accuracy = 0.6;
76
+        } else if (size < 3275) {
77
+            accuracy = 0.44;
78
+        } else {
79
+            accuracy = 0.4;
80
+        }
81
+        return accuracy;
82
+    }
83
+
84
+}

+ 49
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/hk/test/img.java Ver fichero

@@ -0,0 +1,49 @@
1
+package com.community.huiju.common.hk.test;
2
+
3
+import org.apache.commons.codec.binary.Base64;
4
+
5
+import java.io.FileInputStream;
6
+import java.io.IOException;
7
+import java.io.InputStream;
8
+
9
+/**
10
+ * version V1.0
11
+ * class_name: $METHOD_NAME$
12
+ * param: $METHOD_PARAM$
13
+ * describe: TODO
14
+ * creat_user:fannaixi
15
+ * creat_time: 2018/11/6
16
+ **/
17
+public class img{
18
+    public static void main(String[] args) {
19
+        String imgFile = "E:\\1.jpg";//待处理的图片
20
+        String imgbese=getImgStr(imgFile);
21
+        System.out.println(imgbese.length());
22
+        System.out.println(imgbese);
23
+
24
+    }
25
+
26
+    /**
27
+     * 将图片转换成Base64编码
28
+     * @param imgFile 待处理图片
29
+     * @return
30
+     */
31
+    public static String getImgStr(String imgFile){
32
+        //将图片文件转化为字节数组字符串,并对其进行Base64编码处理
33
+        InputStream in = null;
34
+        byte[] data = null;
35
+        //读取图片字节数组
36
+        try
37
+        {
38
+            in = new FileInputStream(imgFile);
39
+            data = new byte[in.available()];
40
+            in.read(data);
41
+            in.close();
42
+        }
43
+        catch (IOException e)
44
+        {
45
+            e.printStackTrace();
46
+        }
47
+        return new String(Base64.encodeBase64(data));
48
+    }
49
+}

+ 87
- 24
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/FaceServicelimpl.java Ver fichero

@@ -7,6 +7,7 @@ import com.community.commom.constant.Constant;
7 7
 import com.community.commom.mode.ResponseBean;
8 8
 import com.community.huiju.common.hk.HKConstant;
9 9
 import com.community.huiju.common.hk.HKOpenApi;
10
+import com.community.huiju.common.hk.test.PicUtils;
10 11
 import com.community.huiju.controller.ImageController;
11 12
 import com.community.huiju.dao.TaFaceMapper;
12 13
 import com.community.huiju.dao.TaSysRoleMapper;
@@ -18,11 +19,16 @@ import com.community.huiju.service.ImageServiceI;
18 19
 import com.community.huiju.service.FaceServicel;
19 20
 import com.hikvision.cms.api.common.util.Digests;
20 21
 import com.hikvision.cms.api.common.util.HttpClientSSLUtils;
22
+import org.apache.commons.io.FileUtils;
21 23
 import org.springframework.beans.factory.annotation.Autowired;
22 24
 import org.springframework.stereotype.Service;
25
+import org.springframework.transaction.annotation.Transactional;
23 26
 import org.springframework.web.multipart.MultipartFile;
24 27
 
28
+import java.io.File;
29
+import java.io.FileInputStream;
25 30
 import java.io.IOException;
31
+import java.io.InputStream;
26 32
 import java.util.Date;
27 33
 import java.util.HashMap;
28 34
 import java.util.Map;
@@ -44,6 +50,7 @@ public class FaceServicelimpl implements FaceServicel {
44 50
     private ImageServiceI imageServiceI;
45 51
 
46 52
     @Override
53
+    @Transactional
47 54
     public ResponseBean addFace(Integer userid,MultipartFile uploadFile) {
48 55
         String faceImg = null;
49 56
         try {
@@ -87,35 +94,41 @@ public class FaceServicelimpl implements FaceServicel {
87 94
             boolean isA=true;
88 95
             if (Constant.OWNER.equals(sysRole.getRoleName()) && "1".equals(taUser.getVerifyStatus())) {
89 96
                 ResponseBean responseBean = new ResponseBean();
90
-                boolean resps=checKout(faceImg,taFace,isA,null);
91
-                if (resps==true) {
92
-                    //校验通过后
93
-                    imgPush(user.getUserName(),faceImg);
97
+                Object resps=checKout(faceImg,taFace,isA,null,user.getUserName(),uploadFile);
98
+                if (null!=resps && "true".equals(resps)) {
94 99
                     responseBean.addSuccess("图片录入成功");
95 100
                 }else {
96
-                    responseBean.addError("7771","请录入正确的图片");
101
+                    if ("1".equals(resps)) {
102
+                        responseBean.addError("7772", "推送海康服务器失败");
103
+                    }else {
104
+                        responseBean.addError("7771","请录入正确的图片");
105
+                    }
97 106
                 }
98 107
                 return responseBean;
99 108
             }
100
-            //家属或者租客
109
+            //家属或者租客,已认证
101 110
             if (Constant.RELATION.equals(sysRole.getRoleName()) || Constant.TENANT.equals(sysRole.getDescription()) && "1".equals(taUser.getVerifyStatus())) {
102 111
                 ResponseBean responseBeans = new ResponseBean();
103
-                boolean resps=checKout(faceImg,taFace,isA,null);
104
-                if (resps==true) {
105
-                    imgPush(user.getUserName(),faceImg);
112
+                Object resps=checKout(faceImg,taFace,isA,null,user.getUserName(),uploadFile);
113
+                if (null!=resps && "true".equals(resps)) {
114
+                    imgPush(user.getUserName(), uploadFile);
106 115
                     responseBeans.addSuccess("图片录入成功");
107 116
                 }else {
108
-                    responseBeans.addError("7771","请录入正确的图片");
117
+                        if ("1".equals(resps)) {
118
+                            responseBeans.addError("7772", "推送海康服务器失败");
119
+                        }else {
120
+                            responseBeans.addError("7771","请录入正确的图片");
121
+                        }
109 122
                 }
110 123
                 return responseBeans;
111 124
             }
112 125
         } else {
113
-            //为业主,已认证
126
+            //为业主,未认证情况下
114 127
             if (Constant.OWNER.equals(sysRole.getRoleName()) && "1".equals(taUser.getVerifyStatus())) {
115 128
                 response.addError("8885", "您的信息已存在");
116 129
                 return response;
117 130
             }
118
-            //家属或者租客
131
+            //家属或者租客,未认证情况下
119 132
             if (Constant.RELATION.equals(sysRole.getRoleName()) || Constant.TENANT.equals(sysRole.getDescription()) && "1".equals(taUser.getVerifyStatus())) {
120 133
                 response.addError("8885", "您的信息已存在");
121 134
                 return response;
@@ -123,11 +136,10 @@ public class FaceServicelimpl implements FaceServicel {
123 136
         }
124 137
         response.addError("9995", "无法确认您的身份,请联系物业");
125 138
         return response;
126
-
127
-
128 139
     }
129 140
 
130 141
     @Override
142
+    @Transactional
131 143
     public ResponseBean upDateFace(Integer userId,MultipartFile uploadFile) {
132 144
         boolean isA=false;
133 145
         String faceImg = null;
@@ -143,8 +155,8 @@ public class FaceServicelimpl implements FaceServicel {
143 155
         taFace.setTaUserId(userId);
144 156
         taFace.setUpdateUser(userId);
145 157
         taFace.setUpdateDate(new Date());
146
-        boolean ck=checKout(faceImg,taFace,isA,userId);
147
-        if (ck == true) {
158
+        Object resps=checKout(faceImg,taFace,isA,userId,user.getUserName(),uploadFile);
159
+        if (null!=resps && "true".equals(resps)) {
148 160
             responseBean.addSuccess("修改成功");
149 161
         }else {
150 162
             responseBean.addError("7771","请录入正确图片");
@@ -153,7 +165,8 @@ public class FaceServicelimpl implements FaceServicel {
153 165
     }
154 166
 
155 167
     //人脸录入验证
156
-    public boolean checKout(String faceImg, TaFace taFace, boolean isA,Integer user) {
168
+    @Transactional
169
+    public Object checKout(String faceImg, TaFace taFace, boolean isA,Integer user,String name,MultipartFile uploadFile) {
157 170
         AESDecode aesd = new AESDecode();
158 171
                 String body = "{\"type\": \"0\", \"image_url\":\"" + faceImg + "\"}";
159 172
         try {
@@ -162,9 +175,18 @@ public class FaceServicelimpl implements FaceServicel {
162 175
             Integer type = (Integer) jsonObject.get("errno");
163 176
             Integer faceNum= (Integer) jsonObject.get("face_num");
164 177
             if (0==type && null!=faceNum && 1==faceNum && isA==true) {
165
-                taFace.setFaceImg(faceImg);
166
-                taFaceMapper.insertSelective(taFace);
167
-                return true;
178
+                //校验通过后
179
+                String errorCode= (String) imgPush(name, uploadFile);
180
+                JSONObject Code = JSONObject.parseObject(errorCode);
181
+                Integer personGroupId = (Integer) Code.get("personGroupId");
182
+                if (null!=personGroupId && personGroupId == 1) {
183
+                    taFace.setFaceImg(faceImg);
184
+                    taFaceMapper.insertSelective(taFace);
185
+                    return true;
186
+                }else{
187
+                    String code="1";
188
+                    return code;
189
+                }
168 190
             }else if (0==type && null!=faceNum && 1==faceNum && isA==false){
169 191
                 taFace.setFaceImg(faceImg);
170 192
                 taFaceMapper.updateByPrimaryKeySelective(taFace);
@@ -177,16 +199,35 @@ public class FaceServicelimpl implements FaceServicel {
177 199
         return false;
178 200
     }
179 201
     //在图片验证通过的情况下,推送到海康
180
-    public Object imgPush(String name,String img){
202
+    public Object imgPush(String name,MultipartFile uploadFile){
181 203
         HKOpenApi hkOpenApi=new HKOpenApi();
182
-        name = hkOpenApi.encodeImgageToBase64(img);
204
+        //把图片压缩成100K以下
205
+        // 压缩后的图片字节数组
206
+        byte [] picByte = null;
207
+        try {
208
+            long l = System.currentTimeMillis();
209
+            byte[] bytes  = uploadFile.getBytes();
210
+            // 拿到转换后的图片字节
211
+            picByte= PicUtils.compressPicForScale(bytes,99L,"x");
212
+        } catch (IOException e) {
213
+            e.printStackTrace();
214
+        }
215
+        // String imgs = hkOpenApi.getImgStr(uploadFile);
216
+        String imgs = hkOpenApi.getImgStr(picByte);
217
+        String pgId= (String) HKpersonGroupId();
218
+        JSONObject jsonObject = JSONObject.parseObject(pgId);
219
+        Integer personGroupId = (Integer) jsonObject.get("personGroupId");
220
+        System.out.println(personGroupId);
183 221
         String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.OP_IMG;
184 222
         Map<String, Object> map = new HashMap<String, Object>();
185 223
         map.put("appkey", HKConstant.APPKEY);//设置APPKEY
186 224
         map.put("time", System.currentTimeMillis());//设置时间参数
187
-        map.put("facePhotos", System.currentTimeMillis());//设置时间参数 //bs64转码
225
+        map.put("token", HKConstant.SECRET);//认证token
226
+        map.put("opUserUuid",HKConstant.OP_USER_UUID);//操作用户UUID
227
+        map.put("facePhotos", imgs); //bs64转码
188 228
         map.put("personName",name);//名字
189
-        map.put("personName",System.currentTimeMillis());//时间取毫秒
229
+        map.put("personGroupId",personGroupId);//分组用户ID
230
+        map.put("birthday",System.currentTimeMillis());//时间取毫秒
190 231
         String params =  JSON.toJSONString(map);
191 232
         System.out.println(" ====== testGetDefaultUserUUID 请求参数:【" + params + "】");
192 233
         String data = null;
@@ -199,5 +240,27 @@ public class FaceServicelimpl implements FaceServicel {
199 240
         return data;
200 241
     }
201 242
 
243
+    //把图片推送海康,需要获得海康人员分组下的
244
+    // **personGroupId**
245
+    @Transactional
246
+    public Object HKpersonGroupId(){
247
+        String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.OP_PERSON_ID;
248
+        Map<String, Object> map = new HashMap<String, Object>();
249
+        map.put("appkey", HKConstant.APPKEY);//设置APPKEY
250
+        map.put("time", System.currentTimeMillis());//设置时间参数
251
+        map.put("token", HKConstant.SECRET);//认证token
252
+        map.put("opUserUuid",HKConstant.OP_USER_UUID);//操作用户UUID
253
+        map.put("pageNo",1);//当前页码
254
+        map.put("pageSize",100);//每页数据记录数
255
+        map.put("birthday",System.currentTimeMillis());//时间取毫秒
256
+        String params =  JSON.toJSONString(map);
257
+        String data = null;
258
+        try {
259
+            data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, params, HKConstant.SECRET), params);
260
+        } catch (Exception e) {
261
+            e.printStackTrace();
262
+        }
263
+        return data;
264
+    }
202 265
 
203 266
 }

+ 7
- 20
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/MonitoringServiceImpl.java Ver fichero

@@ -3,6 +3,7 @@ package com.community.huiju.service.impl;
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.community.commom.mode.ResponseBean;
5 5
 import com.community.huiju.common.hk.HKConstant;
6
+import com.community.huiju.common.hk.HKOpenApi;
6 7
 import com.community.huiju.service.IMonitoringService;
7 8
 import com.google.common.collect.Maps;
8 9
 import com.hikvision.cms.api.common.util.Digests;
@@ -24,30 +25,16 @@ public class MonitoringServiceImpl implements IMonitoringService {
24 25
     @Override
25 26
     public ResponseBean getByCommunityId(Integer communityId) {
26 27
 
27
-        // TODO 数据是假数据, 后期在更改
28
+        // TODO 数据是假数据, 后期在更改. 需要根据小区查询 组织中心编号
28 29
 
29 30
         ResponseBean response = new ResponseBean();
30 31
         Map<String,Object> parMap = Maps.newHashMap();
31
-        String url = HKConstant.OPENAPI_IP_PORT_HTTP + HKConstant.ITF_ADDRESS_GET_CAMERAS;
32
-        //设置APPKEY
33
-        parMap.put("appkey", HKConstant.APPKEY);
34
-        //设置时间参数
35
-        parMap.put("time", System.currentTimeMillis());
36
-        parMap.put("pageNo","");
37
-        parMap.put("pageSize","");
32
+        parMap.put("pageNo",1);
33
+        parMap.put("pageSize",100);
38 34
         parMap.put("opUserUuid",HKConstant.OP_USER_UUID);
39
-        String params =  JSON.toJSONString(parMap);
40
-        log.info("获取 监控列表 请求参数:{}", params);
41
-        String data = null;
42
-        try {
43
-            data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, params, HKConstant.SECRET), params);
44
-            log.info("获取 监控列表 请求返回结果:{}",data);
45
-        } catch (Exception e) {
46
-            e.printStackTrace();
47
-            log.error("获取监控列表失败!",e);
48
-        }
49
-
50
-
35
+        parMap.put("unitUuids","1048576");
36
+/*        String result = HKOpenApi.getMonitoryPoint(parMap);
37
+        response.addSuccess(result);*/
51 38
         return response;
52 39
     }
53 40
 }