瀏覽代碼

修复 海康推送

魏熙美 6 年之前
父節點
當前提交
0c0e103735

+ 7
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/FaceServicelimpl.java 查看文件

@@ -407,6 +407,13 @@ public class FaceServicelimpl implements FaceServiceI {
407 407
 
408 408
         // 海康数据
409 409
         TaUserHk taUserHk = taUserHkMapper.selectByUserVerifyIdAndCommunityId(userVerify.getId(), userVerify.getCommunityId());
410
+        if (null == taUserHk) {
411
+            /**
412
+             * 如果没有海康数据,就进行推送
413
+             */
414
+            ihkService.pushPerson(taUser.getId() + "", userVerify.getId());
415
+            taUserHk = taUserHkMapper.selectByUserVerifyIdAndCommunityId(userVerify.getId(), userVerify.getCommunityId());
416
+        }
410 417
 
411 418
         // 海康权限信息
412 419
         TpUnitHkSetting tpUnitHkSetting = getUnitHkSetting(userVerify.getCommunityId(), userVerify.getUnitId());

+ 14
- 6
CODE/smart-community/hardware-server/src/main/java/com/community/huiju/service/impl/HkHardwareServiceImpl.java 查看文件

@@ -142,18 +142,26 @@ public class HkHardwareServiceImpl implements HkHardwareServiceI {
142 142
             downloadEntranceGuardPermissions(entranceGuardPermissions.toJSONString());
143 143
         }
144 144
 
145
-        // 下发门禁人脸权限
146
-        JSONObject entranceGuardFace = jsonObject.getJSONObject("entranceGuardFace");
147
-        if (null != entranceGuardFace) {
148
-            downloadEntranceGuardFace(entranceGuardFace.toJSONString());
149
-        }
150
-
151 145
         // 下发门口机(可视对讲)卡权限
152 146
         JSONObject doorPermissions = jsonObject.getJSONObject("doorPermissions");
153 147
         if (null != doorPermissions) {
154 148
             downloadDoorPermissions(doorPermissions.toJSONString());
155 149
         }
156 150
 
151
+
152
+        try {
153
+            // 睡眠 3 秒
154
+            Thread.sleep(3000);
155
+        } catch (InterruptedException e) {
156
+            e.printStackTrace();
157
+        }
158
+
159
+        // 下发门禁人脸权限
160
+        JSONObject entranceGuardFace = jsonObject.getJSONObject("entranceGuardFace");
161
+        if (null != entranceGuardFace) {
162
+            downloadEntranceGuardFace(entranceGuardFace.toJSONString());
163
+        }
164
+
157 165
         // 下发门口机(可视对讲)人脸权限
158 166
         JSONObject doorFace = jsonObject.getJSONObject("doorFace");
159 167
         if (null != doorFace) {

+ 7
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/PropertyApplication.java 查看文件

@@ -3,6 +3,7 @@ package com.community.huiju;
3 3
 import com.alibaba.fastjson.serializer.SerializerFeature;
4 4
 import com.alibaba.fastjson.support.config.FastJsonConfig;
5 5
 import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
6
+import feign.Logger;
6 7
 import org.mybatis.spring.annotation.MapperScan;
7 8
 import org.springframework.boot.SpringApplication;
8 9
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -45,4 +46,10 @@ public class PropertyApplication {
45 46
 		factory.setLocation("/tmp/smart-community");
46 47
 		return factory.createMultipartConfig();
47 48
 	}
49
+
50
+	@Bean
51
+	public Logger.Level feignLoggerLevel() {
52
+		//这里记录所有,根据实际情况选择合适的日志level
53
+		return Logger.Level.FULL;
54
+	}
48 55
 }

+ 3
- 3
CODE/smart-community/property-api/src/main/java/com/community/huiju/feign/TaUserFeignService.java 查看文件

@@ -17,7 +17,7 @@ public interface TaUserFeignService {
17 17
      * @return
18 18
      */
19 19
     @RequestMapping(value = "/user/register",method = RequestMethod.POST)
20
-    ResponseBean register(@RequestBody String parameter);
20
+    String register(@RequestBody String parameter);
21 21
 
22 22
     /**
23 23
      * 推送海康人员添加
@@ -25,14 +25,14 @@ public interface TaUserFeignService {
25 25
      * @return
26 26
      */
27 27
     @RequestMapping(value = "/pushHKPerson/{appUserId}", method = RequestMethod.POST)
28
-    ResponseBean pushHKPerson(@PathVariable("appUserId") Integer appUserId, @RequestParam("userVerifyId") Integer userVerifyId);
28
+    String pushHKPerson(@PathVariable("appUserId") Integer appUserId, @RequestParam("userVerifyId") Integer userVerifyId);
29 29
 
30 30
     /**
31 31
      * 异动下载门禁权限
32 32
      * @return
33 33
      */
34 34
     @RequestMapping(value = "/downloadAuthorityByDeviceUuids", method = RequestMethod.POST)
35
-    ResponseBean downloadAuthorityByDeviceUuids();
35
+    String downloadAuthorityByDeviceUuids();
36 36
 
37 37
 
38 38
 

+ 6
- 5
CODE/smart-community/property-api/src/main/java/com/community/huiju/feign/impl/TaUserFeignFallBack.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.community.huiju.feign.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.community.commom.mode.ResponseBean;
4 5
 import com.community.huiju.feign.TaUserFeignService;
5 6
 import lombok.extern.slf4j.Slf4j;
@@ -8,24 +9,24 @@ import lombok.extern.slf4j.Slf4j;
8 9
 public class TaUserFeignFallBack implements TaUserFeignService {
9 10
 
10 11
     @Override
11
-    public ResponseBean register(String parameter) {
12
+    public String register(String parameter) {
12 13
         return back();
13 14
     }
14 15
 
15 16
     @Override
16
-    public ResponseBean pushHKPerson(Integer appUserId,Integer userVerifyId) {
17
+    public String pushHKPerson(Integer appUserId,Integer userVerifyId) {
17 18
         return back();
18 19
     }
19 20
 
20 21
     @Override
21
-    public ResponseBean downloadAuthorityByDeviceUuids() {
22
+    public String downloadAuthorityByDeviceUuids() {
22 23
         return back();
23 24
     }
24 25
 
25
-    private ResponseBean back() {
26
+    private String back() {
26 27
         log.error("app-api 远端服务请求失败!");
27 28
         ResponseBean responseBean = new ResponseBean();
28 29
         responseBean.addError("app-api 远端服务请求失败!");
29
-        return responseBean;
30
+        return JSONObject.toJSONString(responseBean);
30 31
     }
31 32
 }

+ 28
- 7
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BuildingOwnerInfoServiceImpl.java 查看文件

@@ -192,11 +192,23 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
192 192
             tpBuildingOwnerInfo.setTaUserVerifyId(userVerify.getId());
193 193
             tpBuildingOwnerInfoMapper.updateById(tpBuildingOwnerInfo);
194 194
 
195
-            // 推送海康
196
-            ResponseBean pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
197
-            if (!"0".equals(pushHKPerson.getCode())) {
195
+            /**
196
+             * 这里有特殊情况需要外面包裹一层异常捕获
197
+             */
198
+            try {
199
+
200
+                // 推送海康
201
+                String pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
202
+                JSONObject pushHKPersonJsonObject = JSONObject.parseObject(pushHKPerson);
203
+                if (!"0".equals(pushHKPersonJsonObject.getString("code"))) {
204
+                    throw new WisdomException("设备推送失败!");
205
+                }
206
+
207
+            }catch (Exception e) {
208
+                log.info("设备推送失败!,人员id:{}", userVerify.getUserId());
198 209
                 throw new WisdomException("设备推送失败!");
199 210
             }
211
+
200 212
         }
201 213
 
202 214
 
@@ -205,7 +217,7 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
205 217
     }
206 218
 
207 219
     @Override
208
-    @Transactional(rollbackFor = Exception.class)
220
+    //@Transactional(rollbackFor = Exception.class)
209 221
     public ResponseBean add(String parameter, UserElement userElement) {
210 222
         ResponseBean responseBean = new ResponseBean();
211 223
 
@@ -333,13 +345,22 @@ public class BuildingOwnerInfoServiceImpl extends ServiceImpl<TpBuildingOwnerInf
333 345
             messageMapper.insert(message);
334 346
         }
335 347
 
336
-
348
+        /**
349
+         * 这里有特殊情况需要外面包裹一层异常捕获
350
+         */
351
+        try {
337 352
             // 推送海康
338
-            ResponseBean pushHKPerson = taUserFeignService.pushHKPerson(appUser.getId(), taUserVerify.getId());
339
-            if (!"0".equals(pushHKPerson.getCode())) {
353
+            String pushHKPerson = taUserFeignService.pushHKPerson(appUser.getId(), taUserVerify.getId());
354
+            JSONObject pushHKPersonJsonObject = JSONObject.parseObject(pushHKPerson);
355
+            if (!"0".equals(pushHKPersonJsonObject.getString("code"))) {
340 356
                 log.info("设备推送失败!,人员id:{}", userVerify.getUserId());
341 357
                 throw new WisdomException("设备推送失败!");
342 358
             }
359
+        } catch (Exception e) {
360
+            log.info("设备推送失败!,人员id:{}", userVerify.getUserId());
361
+            throw new WisdomException("设备推送失败!");
362
+        }
363
+
343 364
 
344 365
 
345 366
         if (row <= 0) {

+ 7
- 4
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/TaUserVerifyServiceImpl.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package com.community.huiju.service.impl;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -124,8 +125,9 @@ public class TaUserVerifyServiceImpl extends ServiceImpl<TaUserVerifyMapper, TaU
124 125
 
125 126
         try {
126 127
             // 推送海康
127
-            ResponseBean pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
128
-            if (!"0".equals(pushHKPerson.getCode())) {
128
+            String pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
129
+            JSONObject pushHKPersonJsonObject = JSONObject.parseObject(pushHKPerson);
130
+            if (!"0".equals(pushHKPersonJsonObject.getString("code"))) {
129 131
                 throw new WisdomException("设备推送失败!");
130 132
             }
131 133
         } catch (Exception e) {
@@ -269,8 +271,9 @@ public class TaUserVerifyServiceImpl extends ServiceImpl<TaUserVerifyMapper, TaU
269 271
 
270 272
             try {
271 273
                 // 推送海康
272
-                ResponseBean pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
273
-                if (!"0".equals(pushHKPerson.getCode())) {
274
+                String pushHKPerson = taUserFeignService.pushHKPerson(userVerify.getUserId(), userVerifyId);
275
+                JSONObject pushHKPersonJsonObject = JSONObject.parseObject(pushHKPerson);
276
+                if (!"0".equals(pushHKPersonJsonObject.getString("code"))) {
274 277
                     throw new WisdomException("设备推送失败!");
275 278
                 }
276 279
             } catch (Exception e) {

+ 6
- 0
CODE/smart-community/property-api/src/main/resources/application.yml 查看文件

@@ -11,3 +11,9 @@ mybatis-plus:
11 11
   configuration:
12 12
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #打印sql语句,调试用
13 13
   mapper-locations: classpath:mapper/*.xml
14
+
15
+
16
+logging:
17
+  level:
18
+    com.community.huiju.dao: debug
19
+    com.community.huiju.feign: DEBUG