From 406346ddc25e58717772fe70258d3f7a72b0e557 Mon Sep 17 00:00:00 2001 From: 张晓波 <bingbo1993@126.com> Date: 星期五, 20 十月 2023 10:33:19 +0800 Subject: [PATCH] 苏州配置文件简 化 --- hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java | 204 ++++++++++++++++++--------------------------------- 1 files changed, 72 insertions(+), 132 deletions(-) diff --git a/hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java b/hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java index d5117c7..c9fbf76 100644 --- a/hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java +++ b/hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java @@ -9,30 +9,28 @@ import com.thhy.general.exception.BasicException; import com.thhy.general.utils.ScreenMqUtils; import com.thhy.general.utils.UserInfoUtils; +import com.thhy.staff.config.EmqxConfig; +import com.thhy.staff.config.FaceConfig; import com.thhy.staff.modules.biz.applyhistory.entity.UserApplyHistory; import com.thhy.staff.modules.biz.applyhistory.mapper.UserApplyHistoryMapper; import com.thhy.staff.modules.biz.depart.entity.OtherUser; +import com.thhy.staff.modules.biz.face.entity.MqContent; +import com.thhy.staff.modules.biz.face.mapper.FaceDeviceMapper; import com.thhy.staff.modules.biz.group.entity.GroupUser; import com.thhy.staff.modules.biz.netty.NettyServerHandler; -import com.thhy.staff.modules.biz.platuser.controller.FaceServer; import com.thhy.staff.modules.biz.platuser.entity.*; import com.thhy.staff.modules.biz.platuser.mapper.PlatUserMapper; import com.thhy.staff.modules.biz.platuser.service.PlatUserService; -import com.thhy.staff.modules.biz.platuser.service.SysUserService; -import com.thhy.staff.modules.biz.position.mapper.PositionMapper; +import com.thhy.staff.utils.MqUtils; import com.thhy.staff.utils.ProcessFlag; import com.thhy.staff.utils.StaffNoUtils; import io.netty.channel.ChannelHandlerContext; +import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - -import javax.servlet.http.HttpServletRequest; -import javax.websocket.Session; -import java.io.IOException; import java.io.Serializable; import java.math.BigDecimal; import java.math.RoundingMode; @@ -53,16 +51,19 @@ private PlatUserMapper platUserMapper; @Autowired - private SysUserService sysUserService; - - @Autowired private UserApplyHistoryMapper historyMapper; @Autowired - private PositionMapper positionMapper; + private ScreenMqUtils screenMqUtils; @Autowired - private ScreenMqUtils screenMqUtils; + private FaceDeviceMapper faceDeviceMapper; + + @Autowired + private EmqxConfig emqxConfig; + + @Autowired + private FaceConfig faceConfig; public PlatUser get(Serializable id){ return platUserMapper.queryById(id); @@ -387,6 +388,25 @@ platUserMapper.updateFace(faceDto); if(faceDto.getSyncToDevice()==1){ //下发 + List<String> sns = faceDeviceMapper.queryDevSn(); + + MqContent mqContent = new MqContent("sync_person", faceConfig.getUrlPrefix()+faceConfig.getNotify()); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("path",faceConfig.getUrlPrefix()+faceConfig.getSinglePer()); + JSONObject pathParamJson = new JSONObject(); + pathParamJson.put("dev_sno",""); + pathParamJson.put("limit",10); + pathParamJson.put("offset",0); + pathParamJson.put("total",1); + List<String> userIds = new ArrayList<>(); + userIds.add(faceDto.getUserId()); + pathParamJson.put("person_list",userIds); + pathParamJson.put("person_type","4"); + jsonObject.put("path_params",pathParamJson); + mqContent.setData(jsonObject); + logger.info("下发人脸参数:"+JSON.toJSONString(mqContent)); + MqUtils.createClient(emqxConfig,sns,JSON.toJSONString(mqContent)); /*Map<String,Object> map = AcsMain.addFace(fd.getJobNum(),filePrefix+"/"+fd.getPhoto()); if(map.containsKey("code")){ if(Integer.parseInt(map.get("code").toString())!=0){ @@ -409,7 +429,7 @@ } });*/ - CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS; + /*CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS; if(CTXS.size()<1){ throw new BasicException(new BasicMessage("99991","与门禁一体机失去链接")); } @@ -425,59 +445,35 @@ ctx.flush(); logger.info("成功推送消息到局域网段"); } - }); + });*/ } } @Override @Transactional public void delFace(FaceDto faceDto) { - faceDto.setOp(2); String userIds = faceDto.getUserIds(); + if(StringUtils.isEmpty(userIds)){ + throw new BasicException(BasicStatus.ERROR); + } + List<String> sns = faceDeviceMapper.queryDevSn(); String[] userIdArray = new String[]{userIds}; if(userIds.contains(",")){ userIdArray = userIds.split(","); } - for(String userId : userIdArray){ - faceDto.setUserId(userId); - faceDto.setSyncToDevice(2); - platUserMapper.updateDelFace(faceDto); - - - FaceDto fd = platUserMapper.queryJobNumByUserId(faceDto.getUserId()); - //删除下发 - /*FaceDto fd = platUserMapper.queryJobNumByUserId(userId); - AcsMain.deleteFace(fd.getJobNum());*/ - /*CopyOnWriteArraySet<Session> SESSIONS = FaceServer.SESSIONS; - if(SESSIONS.size()<1){ - throw new BasicException(new BasicMessage("99991","与门禁一体机失去链接")); - } - SESSIONS.forEach(session ->{ - try { - if (session.isOpen()) { - faceDto.setPhoto(filePrefix+faceDto.getPhoto()); - session.getBasicRemote().sendText(JSON.toJSONString(faceDto)); - logger.info("成功推送消息到局域网段"+session.getId()+"___"+session.getRequestURI().getHost()); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - });*/ - - CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS; - if(CTXS.size()<1){ - throw new BasicException(new BasicMessage("99991","与门禁一体机失去链接")); - } - CTXS.forEach(ctx ->{ - if (!ctx.isRemoved()&&ctx.channel().isOpen()) { - faceDto.setJobNum(fd.getJobNum()); - faceDto.setPhoto("https://pipe.thhy-tj.com/"+faceDto.getPhoto()); - ctx.write(JSON.toJSONString(faceDto)); - ctx.flush(); - logger.info("删除人脸成功推送消息到局域网段"); - } - }); - } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("method","delete_person"); + jsonObject.put("notify",faceConfig.getUrlPrefix()+"deleteNotify"); + JSONObject userIdJSON = new JSONObject(); + userIdJSON.put("userIds",userIdArray); + jsonObject.put("params",userIdJSON); + JSONObject dataJson = new JSONObject(); + dataJson.put("person_list",userIdArray); + dataJson.put("person_type","4"); + jsonObject.put("data",dataJson); + String content = jsonObject.toJSONString(); + logger.info("删除指令打印"+content); + MqUtils.createClient(emqxConfig,sns,content); } @Override @@ -528,82 +524,6 @@ platUserMapper.insertDoorLis(doorLis); } - - public static void main(String[] args) { - String eventLog = "{\n" + - "\t\"ipAddress\":\t\"192.168.1.12\",\n" + - "\t\"ipv6Address\":\t\"240e:345:129e:cf00:e2ca:3cff:fef0:d933\",\n" + - "\t\"portNo\":\t443,\n" + - "\t\"protocol\":\t\"HTTPS\",\n" + - "\t\"macAddress\":\t\"e0:ca:3c:f0:d9:33\",\n" + - "\t\"channelID\":\t1,\n" + - "\t\"dateTime\":\t\"2023-09-05T15:44:04+08:00\",\n" + - "\t\"activePostCount\":\t1,\n" + - "\t\"eventType\":\t\"AccessControllerEvent\",\n" + - "\t\"eventState\":\t\"active\",\n" + - "\t\"eventDescription\":\t\"Access Controller Event\",\n" + - "\t\"AccessControllerEvent\":\t{\n" + - "\t\t\"deviceName\":\t\"Access Controller\",\n" + - "\t\t\"majorEventType\":\t5,\n" + - "\t\t\"subEventType\":\t76,\n" + - "\t\t\"cardReaderKind\":\t1,\n" + - "\t\t\"cardReaderNo\":\t1,\n" + - "\t\t\"verifyNo\":\t233,\n" + - "\t\t\"serialNo\":\t437,\n" + - "\t\t\"currentVerifyMode\":\t\"cardOrFace\",\n" + - "\t\t\"frontSerialNo\":\t436,\n" + - "\t\t\"attendanceStatus\":\t\"undefined\",\n" + - "\t\t\"statusValue\":\t0,\n" + - "\t\t\"mask\":\t\"no\",\n" + - "\t\t\"helmet\":\t\"unknown\",\n" + - "\t\t\"picturesNumber\":\t1,\n" + - "\t\t\"purePwdVerifyEnable\":\ttrue,\n" + - "\t\t\"FaceRect\":\t{\n" + - "\t\t\t\"height\":\t0.116000,\n" + - "\t\t\t\"width\":\t0.065000,\n" + - "\t\t\t\"x\":\t0.546000,\n" + - "\t\t\t\"y\":\t0.634000\n" + - "\t\t}\n" + - "\t}\n" + - "}"; - JSONObject jsonObject = JSONObject.parseObject(eventLog); - - if(!jsonObject.containsKey("eventType")){ - //platUserMapper.addDoorHis(eventLog); - return; - } - String eventType = jsonObject.getString("eventType"); - if(!"AccessControllerEvent".equals(eventType)){ - //platUserMapper.addDoorHis(eventLog); - return; - } - - JSONObject control = jsonObject.getJSONObject("AccessControllerEvent"); - - String majorEventType = control.getString("majorEventType"); - if(!"1".equals(majorEventType)&&!"5".equals(majorEventType)){ - //platUserMapper.addDoorHis(eventLog); - return; - } - - DoorLis doorLis = new DoorLis(); - //doorLis.setOriStr(eventLog); - doorLis.setIpAddress(jsonObject.getString("ipAddress")); - doorLis.setMacAddress(jsonObject.getString("macAddress")); - doorLis.setNoticeType(Integer.parseInt(majorEventType)); - if("5".equals(majorEventType)){ - String subEventType = control.getString("subEventType"); - if("75".equals(subEventType)){ - doorLis.setVerify(1); - doorLis.setName(control.getString("name")); - doorLis.setEmployeeNoString(control.getString("employeeNoString")); - }else if("76".equals(subEventType)){ - doorLis.setVerify(2); - } - } - - } - @Override public Map<String, Object> faceRecord(String token) { SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token); @@ -617,6 +537,7 @@ map.put("doorUserList",list); PlatUserFace platUserFace = platUserMapper.queryFaceUserByJobNum(list.get(0).getJobNum()); platUserFace.setPassTime(list.get(0).getCreateTime()); + platUserFace.setRecordId(list.get(0).getId()); map.put("firstUserInfo",platUserFace); return map; } @@ -671,4 +592,23 @@ } platUserMapper.insertDoorListener(doorLisPic); } + + public static void main(String[] args) { + MqContent mqContent = new MqContent("sync_person", "notify"); + String uu = "02d32ee86bec2b11e4b23eb6"; + JSONObject jsonObject = new JSONObject(); + jsonObject.put("path","/path"); + JSONObject pathParamJson = new JSONObject(); + + pathParamJson.put("dev_sno",""); + pathParamJson.put("limit",10); + pathParamJson.put("offset",0); + pathParamJson.put("total",1); + pathParamJson.put("person_list","[\""+uu+"\"]"); + pathParamJson.put("person_type","4"); + jsonObject.put("path_params",pathParamJson); + mqContent.setData(jsonObject); + + System.out.println(pathParamJson.toJSONString()); + } } -- Gitblit v1.9.3