张晓波
2023-12-12 453e36702a81f459295d30841bab00010f9a6ae6
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/service/impl/PlatUserServiceImpl.java
@@ -25,6 +25,7 @@
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;
@@ -34,6 +35,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
@@ -452,52 +454,28 @@
    @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
@@ -554,13 +532,19 @@
        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;
    }
@@ -616,6 +600,26 @@
        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";