张晓波
2023-10-20 406346ddc25e58717772fe70258d3f7a72b0e557
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
package com.thhy.staff.modules.biz.platuser.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.api.utils.StringUtils;
import com.thhy.general.common.BasicMessage;
import com.thhy.general.common.BasicStatus;
import com.thhy.general.config.SysUserInfo;
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.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 org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CopyOnWriteArraySet;
 
/**
 *  服务实现类
 * @author zhang_xiao_bo
 * @since 2023-03-30 12:49:45
 */
@Service
public class PlatUserServiceImpl implements PlatUserService {
 
    private Logger logger = LoggerFactory.getLogger(PlatUserServiceImpl.class);
 
    @Autowired
    private PlatUserMapper platUserMapper;
 
    @Autowired
    private UserApplyHistoryMapper historyMapper;
 
    @Autowired
    private ScreenMqUtils screenMqUtils;
 
    @Autowired
    private FaceDeviceMapper faceDeviceMapper;
 
    @Autowired
    private EmqxConfig emqxConfig;
 
    @Autowired
    private FaceConfig faceConfig;
 
    public PlatUser get(Serializable id){
        return platUserMapper.queryById(id);
    }
 
    @Override
    public List<PlatUserPullDown> queryForPullDown(PlatUserDto platUserDto) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo();
        if(platUserDto==null)platUserDto = new PlatUserDto();
        platUserDto.setCompanyId(userInfo.getCompanyId());
        return platUserMapper.queryForPullDown(platUserDto);
    }
 
    @Override
    public List<PlatUserPullDown> queryForPullDownDorm(PlatUserDto platUserDto) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo();
        if(platUserDto==null)platUserDto = new PlatUserDto();
        platUserDto.setCompanyId(userInfo.getCompanyId());
        return platUserMapper.queryForPullDownDorm(platUserDto);
    }
 
    public List<PlatUserListVo> findList(PlatUserDto platUserDto){
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        platUserDto.setCompanyId(sysUserInfo.getCompanyId());
        return platUserMapper.findList(platUserDto);
    }
 
    @Override
    public List<PlatUserListVo> findListForExport(PlatUserDto platUserDto, String token) {
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo(token);
        platUserDto.setCompanyId(sysUserInfo.getCompanyId());
        return platUserMapper.findList(platUserDto);
    }
 
    /**
     * 增加和修改
     * @param platUserDto
     */
    @Transactional
    public void addPlatUser(PlatUserDto platUserDto){
        SysUserInfo sysUserInfo = UserInfoUtils.getInstance().getUserInfo();
        String syncSysFlag = "false";
        //String syncJobNum = "";
        if(platUserDto.getUserId() == null){
            //增加操作
            String userId = platUserMapper.queryIdByPhone(platUserDto.getPhone());
            if(!StringUtils.isEmpty(userId)){
                throw new BasicException(BasicStatus.PHONE_IS_EXIST);
            }
 
            String sysUserId = platUserMapper.querySysUserIdByPhone(platUserDto.getPhone());
 
            if(!StringUtils.isEmpty(sysUserId)){
                throw new BasicException(BasicStatus.PHONE_IS_EXIST_SYSUSER);
            }
 
            String userIdno = platUserMapper.queryIdByIdno(platUserDto.getIdNo());
            if(!StringUtils.isEmpty(userIdno)){
                throw new BasicException(BasicStatus.IDNO_IS_EXIST);
            }
 
 
 
            int maxno = platUserMapper.queryMaxJobNum(platUserDto.getUserType());
            String newJobNum = StaffNoUtils.create(platUserDto.getUserType(),maxno);
            platUserDto.setJobNum(newJobNum);
            platUserDto.setCreateUser(sysUserInfo.getUserId());
            platUserDto.setFromPlat(1); //PC
            platUserMapper.insert(platUserDto);
            if(platUserDto.getIsLogin()==1) syncSysFlag="first";
        }else{
            //修改操作
            String userId = platUserMapper.queryIdByPhone(platUserDto.getPhone());
            String userIdno = platUserMapper.queryIdByIdno(platUserDto.getIdNo());
            if (!StringUtils.isEmpty(userId)) {
                if(!platUserDto.getUserId().equals(userId)){
                    throw new BasicException(BasicStatus.PHONE_IS_EXIST);
                }
            }
            if (!StringUtils.isEmpty(userIdno)) {
                if(!platUserDto.getUserId().equals(userIdno)){
                    throw new BasicException(BasicStatus.IDNO_IS_EXIST);
                }
            }
            PlatUser plat = platUserMapper.queryById(platUserDto.getUserId());
            platUserDto.setUpdateUser(sysUserInfo.getUserId());
            platUserDto.setUpdateTime(new Date());
            if(platUserDto.getIsLogin()==plat.getIsLogin()){
                syncSysFlag="false";
            }else{
                if(platUserDto.getIsLogin()==1)syncSysFlag="updatesync";
                if(platUserDto.getIsLogin()==2)syncSysFlag="updatedel";
 
                platUserDto.setJobNum(plat.getJobNum());
            }
            platUserMapper.update(platUserDto);
 
        }
        if("first".equals(syncSysFlag)){
            //同步用户表
            SysUsers sysUsers = StaffNoUtils.PlatoSys(platUserDto);
            platUserMapper.insertSysUser(sysUsers);
            //BasicResult basicResult = sysUserService.insertSysUser(JSON.toJSONString(sysUsers));
            //CheckResult.check(basicResult);
        }else if(!"false".equals(syncSysFlag)){
            if("updatesync".equals(syncSysFlag)){
                SysUsers sysUsers = StaffNoUtils.PlatoSys(platUserDto);
                platUserMapper.insertSysUser(sysUsers);
            }else{
                platUserMapper.syncDelete(platUserDto.getJobNum());
            }
        }
        String posId = platUserDto.getPosId();
        String departId = platUserDto.getDepartId();
        String groups = platUserDto.getGroups();
        platUserMapper.deleteDepartUserByUser(platUserDto.getUserId());
        platUserMapper.insertDepartUser(new OtherUser(departId, platUserDto.getUserId()));
        platUserMapper.deletePositionUserByUser(platUserDto.getUserId());
        platUserMapper.insertPositionUser(new OtherUser(posId, platUserDto.getUserId()));
 
 
        platUserMapper.deleteGroupUserByUser(platUserDto.getUserId());
        if (!StringUtils.isEmpty(platUserDto.getGroups())) {
            String[] groupArray = new String[]{groups};
            if(groups.contains(",")){
                groupArray = groups.split(",");
            }
            for(String groupId : groupArray){
                platUserMapper.insertGroupUser(new GroupUser(groupId, platUserDto.getUserId()));
            }
        }
    }
 
    /**
     * 删除
     * @param userId
     */
    @Transactional
    public void delete(Serializable userId){
        PlatUser platUser = platUserMapper.queryPhoneAndIsLogin(userId);
 
        if (platUser.getIsLogin()==1) {
            platUserMapper.deleteSysUserByPlat(platUser.getUserId());
        }
        platUserMapper.deleteDepartUserByUser(platUser.getUserId());
        platUserMapper.deletePositionUserByUser(platUser.getUserId());
        platUserMapper.deleteGroupUserByUser(platUser.getUserId());
        platUserMapper.deletelogic(userId);
    }
 
 
    @Override
    @Transactional
    public void register(PlatUserDto platUserDto) {
        if(StringUtils.isEmpty(platUserDto.getOpenId())){
            throw new BasicException(BasicStatus.OPEN_ID_IS_MISS);
        }
        MpRegisterInfoVo reginfo = platUserMapper.queryByOpenId(platUserDto.getOpenId());
        if(reginfo==null){
            String phone = platUserMapper.queryIdByPhone(platUserDto.getPhone());
            if(!StringUtils.isEmpty(phone)){
                throw new BasicException(BasicStatus.PHONE_IS_EXIST);
            }
 
            String userIdno = platUserMapper.queryIdByIdno(platUserDto.getIdNo());
            if(!StringUtils.isEmpty(userIdno)){
                throw new BasicException(BasicStatus.IDNO_IS_EXIST);
            }
            int maxno = platUserMapper.queryMaxJobNum(2);
            String newJobNum = StaffNoUtils.create(2,maxno);
            platUserDto.setJobNum(newJobNum);
            platUserDto.setUserType(2);//劳务人员
            platUserDto.setApplyFlag(0);
            platUserDto.setIsLogin(1);
            platUserMapper.insert(platUserDto);
            platUserMapper.deletePositionUserByUser(platUserDto.getUserId());
            platUserMapper.insertPositionUser(new OtherUser(platUserDto.getPosId(), platUserDto.getUserId()));
        }else {
            if(!reginfo.getCompanyId().equals(platUserDto.getCompanyId())){
                throw new BasicException(BasicStatus.USER_ALREADY_HAS_COMPANY);
            }
            if(reginfo.getApplyFlag()==1){
                throw new BasicException(BasicStatus.REGISTER_IS_PASS); //不要重复注册
            }
            String userId = platUserMapper.queryIdByPhone(platUserDto.getPhone());
            String userIdno = platUserMapper.queryIdByIdno(platUserDto.getIdNo());
            if (!StringUtils.isEmpty(userId)) {
                if(!reginfo.getUserId().equals(userId)){
                    throw new BasicException(BasicStatus.PHONE_IS_EXIST);
                }
            }
            if (!StringUtils.isEmpty(userIdno)) {
                if(!reginfo.getUserId().equals(userIdno)){
                    throw new BasicException(BasicStatus.IDNO_IS_EXIST);
                }
            }
            platUserDto.setUserId(reginfo.getUserId());
            platUserDto.setApplyFlag(0);
            platUserMapper.update(platUserDto);
            if(!reginfo.getPosId().equals(platUserDto.getPosId())){
                platUserMapper.deletePositionUserByUser(platUserDto.getUserId());
                platUserMapper.insertPositionUser(new OtherUser(platUserDto.getPosId(), platUserDto.getUserId()));
            }
        }
 
        UserApplyHistory userApplyHistory = new UserApplyHistory();
        userApplyHistory.setPlatUserId(platUserDto.getUserId());
        userApplyHistory.setProcessFlag(ProcessFlag.REG.getValue());
        userApplyHistory.setApplyResult(1);
        userApplyHistory.setCreateUser(platUserDto.getUserId());
        historyMapper.insert(userApplyHistory);
 
        //SysUsers sysUsers = StaffNoUtils.PlatoSys(platUserDto);
        //platUserMapper.insertSysUser(sysUsers);
    }
 
    @Override
    public Map<String,Object> checkuser(PlatUserDto platUserDto) {
        Map<String,Object> map = new HashMap<>();
        //根据openId获取platUser信息
        MpRegisterInfoVo mpRegisterInfoVo = platUserMapper.queryByOpenId(platUserDto.getOpenId());
        //判断是否审批完成
        if(mpRegisterInfoVo==null){
            map.put("regstatus",0); //新用户需要注册
            return map;
        }
 
        if(mpRegisterInfoVo.getApplyFlag()==1){
            map.put("regstatus",1); //已经审批完成
            return map;
        }
 
        if(mpRegisterInfoVo.getApplyFlag()==0){
            map.put("regstatus",2); //等待审核
            return map;
        }
 
        if(mpRegisterInfoVo.getApplyFlag()==2){
            map.put("regstatus",3); //审核未通过
            map.put("reginfo",mpRegisterInfoVo);
            List<ApplyHistory> applyHistories = platUserMapper.queryHistoryByUserId(mpRegisterInfoVo.getUserId());
            map.put("applyRecord",applyHistories);
            return map;
        }
        return map;
    }
 
    @Override
    public Map<String, Object> applyDetail(PlatUserDto platUserDto) {
        Map<String,Object> map = new HashMap<>();
        MpRegisterInfoVo mpRegisterInfoVo = platUserMapper.queryByUserId(platUserDto.getUserId());
        map.put("reginfo",mpRegisterInfoVo);
        List<ApplyHistory> applyHistories = platUserMapper.queryHistoryByUserId(mpRegisterInfoVo.getUserId());
        map.put("applyRecord",applyHistories);
        return map;
    }
 
    @Override
    public List<ApplyListVo> applyList(PlatUserDto platUserDto) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo();
        if(platUserDto==null) platUserDto = new PlatUserDto();
        platUserDto.setCompanyId(userInfo.getCompanyId());
        return platUserMapper.queryApplyList(platUserDto);
    }
 
    @Override
    @Transactional
    public void apply(UserApplyHistory userApplyHistory) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo();
        userApplyHistory.setCreateUser(userInfo.getUserId());
        if(userApplyHistory.getApplyResult()==1){
            userApplyHistory.setProcessFlag(ProcessFlag.APPLY_PASS.getValue());
        }else {
            userApplyHistory.setProcessFlag(ProcessFlag.APPLY_NOPASS.getValue());
        }
        historyMapper.insert(userApplyHistory);
        platUserMapper.updateApplyStatus(userApplyHistory.getUserId(), userApplyHistory.getApplyResult());
        if(userApplyHistory.getApplyResult()==1){
            PlatUserDto platUserDto = platUserMapper.queryForDtoByUserId(userApplyHistory.getUserId());
            SysUsers sysUsers = StaffNoUtils.PlatoSys(platUserDto);
            platUserMapper.insertSysUser(sysUsers);
            platUserMapper.deleteDepartUserByUser(userApplyHistory.getUserId());
            platUserMapper.insertDepartUser(new OtherUser(userApplyHistory.getDepartId(), platUserDto.getUserId()));
        }
    }
 
    @Override
    public void testFace(FaceDto faceDto) {
        CopyOnWriteArraySet<ChannelHandlerContext> CTXS= NettyServerHandler.CTXS;
        logger.info("netty链接个数"+CTXS.size());
        faceDto.setOp(1);
        /*CopyOnWriteArraySet<Session> SESSIONS = FaceServer.SESSIONS;
        SESSIONS.forEach(session ->{
            try {
                if (session.isOpen()) {
                    session.getBasicRemote().sendText(JSON.toJSONString(faceDto));
                    logger.info("成功推送消息到局域网段"+session.getId()+"___"+session.getRequestURI().getHost());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });*/
        CTXS.forEach(ctx ->{
            if (!ctx.isRemoved()&&ctx.channel().isOpen()) {
                ctx.write(JSON.toJSONString(faceDto));
                ctx.flush();
                //logger.info("成功推送消息到局域网段"+session.getId()+"___"+session.getRequestURI().getHost());
            }
        });
        /*Map<String,Object> map = AcsMain.addFace(faceDto.getJobNum(),filePrefix+"/"+faceDto.getPhoto());
        if(map.containsKey("code")){
            if(Integer.parseInt(map.get("code").toString())!=0){
                throw new BasicException(new BasicMessage(map.get("code").toString(),map.get("message").toString()));
            }
        }*/
    }
 
    @Override
    public void addFace(FaceDto faceDto) {
        faceDto.setOp(1);
        FaceDto fd = platUserMapper.queryJobNumByUserId(faceDto.getUserId());
        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){
                    throw new BasicException(new BasicMessage(map.get("code").toString(),map.get("message").toString()));
                }
            }*/
            /*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","与门禁一体机失去链接"));
            }
            if(CTXS.size()>1){
                logger.info("多个客户端"+CTXS.size());
            }
            CTXS.forEach(ctx ->{
                if (!ctx.isRemoved()&&ctx.channel().isOpen()) {
                    logger.info("即将推送消息到局域网段");
                    faceDto.setJobNum(fd.getJobNum());
                    faceDto.setRealName(fd.getRealName());
                    ctx.write(JSON.toJSONString(faceDto));
                    ctx.flush();
                    logger.info("成功推送消息到局域网段");
                }
            });*/
        }
    }
 
    @Override
    @Transactional
    public void delFace(FaceDto faceDto) {
        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(",");
        }
        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
    public void doorhis(String eventLog) {
 
        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);
            }
            screenMqUtils.sendFace("update");
        }else{
            String subEventType = control.getString("subEventType");
            if("1038".equals(subEventType)){
                //联动事件报警
 
            }
        }
        platUserMapper.insertDoorLis(doorLis);
    }
 
    @Override
    public Map<String, Object> faceRecord(String token) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
        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);
        List<DoorUserVo> list = platUserMapper.queryDoorUser();
        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;
    }
 
    @Override
    public Map<String, Object> todayWorkUser(String token) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
        int totalUserCount = platUserMapper.queryPlatUser(userInfo.getCompanyId());
        int workUserCount = platUserMapper.countInDoorUserToday();
 
        Map<String,Object> map = new HashMap<>();
        map.put("mod","todayAttendance");
        map.put("totalUserCount",totalUserCount);
        map.put("workUserCount",workUserCount);
        BigDecimal rate = new BigDecimal(0);
        if(totalUserCount!=0&&workUserCount!=0){
            rate = new BigDecimal(workUserCount).divide(new BigDecimal(totalUserCount),2, RoundingMode.HALF_UP);
        }
        map.put("rate",rate);
        return map;
    }
 
    @Override
    public Map<String, Object> groupUserWork(String token) {
        SysUserInfo userInfo = UserInfoUtils.getInstance().getUserInfo(token);
        List<GroupWorking> groupWorkingList = platUserMapper.groupUserWorking(userInfo.getCompanyId());
        groupWorkingList.forEach(gl -> {
            int count = platUserMapper.countFaceRecordByGroup(gl.getGroupId());
            gl.setGroupWorkCount(count);
        });
        Map<String,Object> map = new HashMap<>();
        map.put("mod","groupWork");
        map.put("groupWork",groupWorkingList);
        return map;
    }
 
    @Override
    public void doorlisWithPic(DoorLisPic doorLisPic) {
 
        if("5".equals(doorLisPic.getFirstType())){
            if("4b".equals(doorLisPic.getSecType())){
                doorLisPic.setVerify(1);
            }else if("4c".equals(doorLisPic.getSecType())){
                doorLisPic.setVerify(2);
            }else if("15".equals(doorLisPic.getSecType())){
                doorLisPic.setLockOp(1);
            }else if("16".equals(doorLisPic.getSecType())){
                doorLisPic.setLockOp(2);
            }
        }else if("3".equals(doorLisPic.getFirstType())){
 
        }
        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());
    }
}