| | |
| | | @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 |