| | |
| | | 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.utils.MqUtils; |
| | | import com.thhy.staff.utils.ProcessFlag; |
| | | import com.thhy.staff.utils.StaffNoUtils; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import net.bytebuddy.build.Plugin; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.CopyOnWriteArraySet; |
| | | |
| | |
| | | pathParamJson.put("limit",10); |
| | | pathParamJson.put("offset",0); |
| | | pathParamJson.put("total",1); |
| | | pathParamJson.put("person_list","[\""+faceDto.getUserId()+"\"]"); |
| | | 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){ |
| | |
| | | } |
| | | });*/ |
| | | |
| | | CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS; |
| | | /*CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS; |
| | | if(CTXS.size()<1){ |
| | | throw new BasicException(new BasicMessage("99991","与门禁一体机失去链接")); |
| | | } |
| | |
| | | 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 |
| | |
| | | int userCount = platUserMapper.queryPlatUser(userInfo.getCompanyId()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("mod","facerecord"); |
| | | map.put("totalUserCount",userCount); |
| | | map.put("watchUserCount",0); |
| | | map.put("dangerUserCount",0); |
| | | //map.put("totalUserCount",userCount); |
| | | //map.put("watchUserCount",0); |
| | | //map.put("dangerUserCount",0); |
| | | |
| | | List<String> faceAreas = platUserMapper.faceArea(); |
| | | map.put("faceAreas",faceAreas); |
| | | |
| | | List<DoorUserVo> list = platUserMapper.queryDoorUser(); |
| | | map.put("doorUserList",list); |
| | | PlatUserFace platUserFace = platUserMapper.queryFaceUserByJobNum(list.get(0).getJobNum()); |
| | | platUserFace.setPassTime(list.get(0).getCreateTime()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | platUserFace.setPassTime(sdf.format(list.get(0).getCreateTime())); |
| | | platUserFace.setRecordId(list.get(0).getId()); |
| | | map.put("firstUserInfo",platUserFace); |
| | | return map; |
| | | } |
| | |
| | | platUserMapper.insertDoorListener(doorLisPic); |
| | | } |
| | | |
| | | @Override |
| | | public List<HashMap<String, Object>> queryGroups() { |
| | | return platUserMapper.queryGroups(); |
| | | } |
| | | |
| | | @Override |
| | | public List<HashMap<String, Object>> queryHelmetWarn() { |
| | | return platUserMapper.queryHelmetWarn(); |
| | | } |
| | | |
| | | @Override |
| | | public List<AreaAdmin> areaAdminInfo() { |
| | | List<AreaAdmin> areaAdminList = platUserMapper.queryAreaInfo(); |
| | | for(AreaAdmin areaAdmin : areaAdminList){ |
| | | List<NamePhoneDepart> namePhoneDepartList = platUserMapper.queryAdminByArea(areaAdmin.getAreaId()); |
| | | areaAdmin.setNpdList(namePhoneDepartList); |
| | | } |
| | | return areaAdminList; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | MqContent mqContent = new MqContent("sync_person", "notify"); |
| | | String uu = "02d32ee86bec2b11e4b23eb6"; |