Переглянути джерело

Merge branch 'dev' into ocr

lzm 3 роки тому
батько
коміт
30c4308667

+ 2 - 1
business-system/filing-system/src/main/java/com/pj/api/WxController.java

@@ -168,10 +168,11 @@ public class WxController {
     public AjaxJson loginByOpenid() {
         SoMap soMap = SoMap.getRequestSoMap();
         String openid = soMap.getString("openid");
+        Integer type = soMap.getInt("type");
         if (StrUtil.isEmpty(openid)) {
             return AjaxJson.getError("参数异常");
         }
-        return tbMiniUserService.loginByOpenid(openid);
+        return tbMiniUserService.loginByOpenid(openid,type);
     }
 
     @RequestMapping("solve")

+ 31 - 6
sp-core/src/main/java/com/pj/current/netty/command/config/CommandNettyServerHandler.java

@@ -2,16 +2,20 @@ package com.pj.current.netty.command.config;
 
 import cn.hutool.cache.CacheUtil;
 import cn.hutool.cache.impl.TimedCache;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.pj.current.config.MyConfig;
+import com.pj.current.netty.command.constants.CommandType;
 import com.pj.current.netty.command.factory.CommandFactory;
 import com.pj.current.netty.dto.RequestPackageDTO;
+import com.pj.current.task.TaskService;
 import com.pj.project.tb_command_log.TbCommandLog;
 import com.pj.project.tb_command_log.TbCommandLogService;
 import com.pj.project.tb_terminal.TbTerminalService;
+import com.pj.project.tb_terminal.task.FinishCommandTask;
 import com.pj.utils.cache.RedisUtil;
 import io.netty.channel.*;
 import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
@@ -87,17 +91,38 @@ public class CommandNettyServerHandler extends ChannelInboundHandlerAdapter {
         JSONObject reqObj = JSONUtil.parseObj(str);
         Integer code = reqObj.getInt("code");
         if (code != null) {//设备端回复服务器的消息,无需再回复设备
-            String msgId = RedisUtil.get(channelId);
+            String msgId = RedisUtil.rPorp(channelId);
+            log.info("下发命令回复:{},{},{}", channelId,msgId, msg);
             TbCommandLogService tbCommandLogService = SpringUtil.getBean(TbCommandLogService.class);
             TbCommandLog tbCommandLog = tbCommandLogService.findByMsgId(msgId);
-            tbCommandLog.setResponseCode(code)
-                    .setResponseContent(str)
-                    .setResponseTime(new Date());
-            tbCommandLogService.updateById(tbCommandLog);
-            RedisUtil.del(channelId);
+            if (tbCommandLog!=null){
+                tbCommandLog.setResponseCode(code)
+                        .setResponseContent(str)
+                        .setResponseTime(new Date());
+                tbCommandLogService.updateById(tbCommandLog);
+            }
+            //查下还有没有新的命令
+            String sn = RedisUtil.get("sn:" + channelId);
+            MyConfig myConfig = SpringUtil.getBean(MyConfig.class);
+            String key = myConfig.getCommandPrefix() + sn;
+            String command = RedisUtil.rPorp(key);
+            if (StrUtil.isNotEmpty(command)) {
+                RequestPackageDTO requestPackageDTO = JSONUtil.toBean(command, RequestPackageDTO.class);
+                String newMsgId = requestPackageDTO.getMsgId();
+                RedisUtil.lPush(channelId, newMsgId);
+                ctx.write(command);
+                ctx.flush();
+            }else {
+                //命令下发完成
+                TaskService taskService=SpringUtil.getBean(TaskService.class);
+                taskService.addTask(new FinishCommandTask(RandomUtil.randomNumbers(10), 300, ctx));
+            }
             return;
         }
         RequestPackageDTO packageDTO = JSONUtil.toBean(str, RequestPackageDTO.class);
+        Object params = packageDTO.getPayload().getParams();
+        String sn = JSONUtil.parseObj(params).getStr("sn");
+        RedisUtil.setBySecond("sn:"+channelId, sn,180);
         String funcId = packageDTO.getFuncId();
         CommandFactory commandFactory = SpringUtil.getBean(CommandFactory.class);
         commandFactory.handler(funcId).handler(ctx, packageDTO);

+ 2 - 0
sp-core/src/main/java/com/pj/current/netty/command/handler/dto/WhitelistDTO.java

@@ -10,6 +10,7 @@ import java.io.Serializable;
 public class WhitelistDTO implements Serializable {
 
     /**
+     * address : 身份证住址
      * identity_number : 350623xxxxxxxxxxx
      * name : xxxxxxx
      * nation : xxxxxxx
@@ -21,6 +22,7 @@ public class WhitelistDTO implements Serializable {
      * check_num : -1
      */
 
+    private String address;
     private String pin;
     private String identity_number;
     private String name;

+ 9 - 6
sp-core/src/main/java/com/pj/current/netty/command/handler/impl/HealthlogHandler.java

@@ -25,6 +25,7 @@ import com.pj.project.tb_manager.TbManagerService;
 import com.pj.project.tb_person_filing.TbPersonFiling;
 import com.pj.project.tb_person_filing.TbPersonFilingService;
 import com.pj.project.tb_person_filing.task.Base64ToImage;
+import com.pj.project.tb_person_filing.task.DelayIsuued;
 import com.pj.project.tb_person_visit_record.TbPersonVisitRecord;
 import com.pj.project.tb_person_visit_record.TbPersonVisitRecordService;
 import com.pj.project.tb_person_visit_record.task.ConvertBase64ToImage;
@@ -90,11 +91,11 @@ public class HealthlogHandler implements IHandler {
         String str = params.getStr("log");
         HealthlogDTO dto = JSONUtil.toBean(str, HealthlogDTO.class);
         String idCard = dto.getIdentity_number();
+        String sn = params.getStr("sn");
         TbPersonFiling tbPersonFiling = tbPersonFilingService.findByIdCard(idCard);
-
         if (tbPersonFiling == null) {
             if (!SpCfgUtil.termianlFilling()) {
-                log.error("系统不允许设备端进行备案============>删除设备端自动备份的信息,:{}",idCard);
+                log.error("系统不允许设备端进行备案============>删除设备端自动备份的信息,:{}", idCard);
                 tbPersonFilingService.deleteTerminalWhilte(idCard);
                 ctx.write(OKMsg.ok());
                 ctx.flush();
@@ -112,11 +113,13 @@ public class HealthlogHandler implements IHandler {
                     .setJudgeBy("设备上传").setJudgeTime(needJudge ? null : now);
             tbPersonFilingService.save(tbPersonFiling);
             taskService.addTask(new Base64ToImage(RandomUtil.randomNumbers(10), 50, tbPersonFiling.getId(), dto.getPicture()));
-            return;
+            //分发人员信息到其他终端
+            if (!needJudge){
+                taskService.addTask(new DelayIsuued(RandomUtil.randomNumbers(11), 4000, tbPersonFiling.getId(), sn));
+            }
         }
         Long deptId = tbPersonFiling.getDeptId();
         TbDept tbDept = tbDeptService.getById(deptId);
-        String sn = params.getStr("sn");
         TbTerminal tbTerminal = tbTerminalService.findBySN(sn);
         Long venuesId = tbTerminal.getChannelId();
         TbVenues tbVenues = tbVenuesService.getById(venuesId);
@@ -173,7 +176,7 @@ public class HealthlogHandler implements IHandler {
         double minTemperature = SpCfgUtil.getMinTemperature();
         String healthStatus = dto.getHealth_status();
         String now = DateUtil.now();
-        if (minTemperature < Double.valueOf(dto.getTemperature())) {
+        if (StrUtil.isNotEmpty(dto.getTemperature()) && minTemperature < Double.valueOf(dto.getTemperature())) {
             log.info("发送体温异常提醒============");
             MsgDataBO msgDataBO = new MsgDataBO("您收到一条人员体温异常提醒", dto.getName(), dto.getTemperature(), now, "请及时处理");
             //todo 触发体温预警
@@ -182,7 +185,7 @@ public class HealthlogHandler implements IHandler {
                 wxService.sendTemplateMsg(wxConfig.getTemperatureErrorTemplate(), tbManager.getOpenid(), msgDataBO, detailUrl);
             });
         }
-        if (!healthStatus.equals(TbPersonVisitRecord.HealthEnum.GREEN.getStatus())) {
+        if (StrUtil.isNotEmpty(healthStatus) && !healthStatus.equals(TbPersonVisitRecord.HealthEnum.GREEN.getStatus())) {
             log.info("发送健康码异常提醒============");
             // todo 黄码,红码预警
             MsgDataBO msgDataBO = new MsgDataBO("您收到一条人员健康码异常提醒", dto.getName(), now, tbTerminal.getName(), healthStatus, tbVenues.getName(), "请及时处理");

+ 7 - 2
sp-core/src/main/java/com/pj/current/netty/command/handler/impl/TerminalOptionHandler.java

@@ -1,7 +1,9 @@
 package com.pj.current.netty.command.handler.impl;
 
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.XmlUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.pj.current.config.MyConfig;
@@ -9,8 +11,10 @@ import com.pj.current.netty.command.constants.CommandType;
 import com.pj.current.netty.command.handler.IHandler;
 import com.pj.current.netty.dto.OKMsg;
 import com.pj.current.netty.dto.RequestPackageDTO;
+import com.pj.current.task.TaskService;
 import com.pj.project.tb_terminal.TbTerminal;
 import com.pj.project.tb_terminal.TbTerminalService;
+import com.pj.project.tb_terminal.task.FinishCommandTask;
 import io.netty.channel.ChannelHandlerContext;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -28,6 +32,8 @@ public class TerminalOptionHandler implements IHandler {
     private TbTerminalService tbTerminalService;
     @Resource
     private MyConfig myConfig;
+    @Resource
+    TaskService taskService;
 
     @Override
     public CommandType commandType() {
@@ -47,7 +53,6 @@ public class TerminalOptionHandler implements IHandler {
         if (myConfig.getLimitUserCount()<=userCount) {
 
         }
-        ctx.write(OKMsg.ok());
-        ctx.flush();
+        taskService.addTask(new FinishCommandTask(RandomUtil.randomNumbers(10), 300, ctx));
     }
 }

+ 12 - 15
sp-core/src/main/java/com/pj/current/netty/command/handler/impl/UploadCommandHandler.java

@@ -27,8 +27,7 @@ import java.util.List;
 public class UploadCommandHandler implements IHandler {
     @Resource
     private MyConfig myConfig;
-    @Resource
-    private TaskService taskService;
+
 
     @Override
     public CommandType commandType() {
@@ -37,20 +36,18 @@ public class UploadCommandHandler implements IHandler {
 
     @Override
     public void handler(ChannelHandlerContext ctx, RequestPackageDTO packageDTO) {
-        log.info("进入请求命令处理========================");
+        log.info("进入下发命令处理========================");
         String sn = JSONUtil.parseObj(packageDTO.getPayload().getParams()).getStr("sn");
         String key = myConfig.getCommandPrefix() + sn;
-        String commandListStr = RedisUtil.get(key);
-        List<String> list = JSONUtil.toList(commandListStr, String.class);
-        long delay = Long.parseLong(RandomUtil.randomNumbers(3));
-        for (String command : list) {
-            RequestPackageDTO requestPackageDTO = JSONUtil.toBean(command, RequestPackageDTO.class);
-            String taskId = RandomUtil.randomNumbers(16);
-            String msgId = requestPackageDTO.getMsgId();
-            taskService.addTask(new CommandDelayTask(taskId, delay, ctx, command, msgId));
-            delay = delay + 1000;
-        }
-        taskService.addTask(new FinishCommandTask(RandomUtil.randomNumbers(10), delay + 300, ctx));
-        RedisUtil.del(key);
+        String command = RedisUtil.rPorp(key);
+        log.info("下发命令:{},{}", ctx.channel().id().asShortText(), command);
+        RequestPackageDTO requestPackageDTO = JSONUtil.toBean(command, RequestPackageDTO.class);
+        String msgId = requestPackageDTO.getMsgId();
+        String channelId = ctx.channel().id().asShortText();
+        RedisUtil.lPush(channelId, msgId);
+
+        ctx.write(command);
+        ctx.flush();
+
     }
 }

+ 7 - 40
sp-core/src/main/java/com/pj/current/netty/command/handler/impl/UploadUserHandler.java

@@ -53,50 +53,17 @@ public class UploadUserHandler implements IHandler {
     @Override
     public void handler(ChannelHandlerContext ctx, RequestPackageDTO packageDTO) {
         log.info("设备上传人员信息:{}", JSONUtil.toJsonStr(packageDTO));
-        JSONObject params = JSONUtil.parseObj(packageDTO.getPayload().getParams());
-        String sn = params.getStr("sn");
-        TbTerminal tbTerminal = tbTerminalService.findBySN(sn);
-        if (tbTerminal == null) {
-            log.error("========设备不存在=========:{}", sn);
-            return;
-        }
-        tbTerminal.setLastOnLine(DateUtil.now());
-        tbTerminalService.updateById(tbTerminal);
         ctx.write(OKMsg.ok());
         ctx.flush();
-        boolean terminalFilling = SpCfgUtil.termianlFilling();
-        if (!terminalFilling) {
-            log.error("系统不允许设备端进行备案================");
-            return;
-        }
+        JSONObject params = JSONUtil.parseObj(packageDTO.getPayload().getParams());
+        String sn = params.getStr("sn");
         WhitelistDTO uploadUserDTO = JSONUtil.toBean(params.getStr("users"), WhitelistDTO.class);
-        String idCarNo=uploadUserDTO.getIdentity_number();
+        String idCarNo = uploadUserDTO.getIdentity_number();
         TbPersonFiling personFiling = tbPersonFilingService.findByIdCard(idCarNo);
-        //是否允许设备端备案
-        if (personFiling == null) {
-            TbPersonFiling tbPersonFiling = new TbPersonFiling();
-            TbDept dept = tbDeptService.findTheDept(TbDept.AdminTypeEnum.TEMP_TYPE.getType());
-            Date now = new Date();
-            boolean needJudge = TbDept.NeedJudgeEnum.MAN_JUDGE.getType().equals(dept.getNeedJudge());
-            tbPersonFiling.setCreateTime(now)
-                    .setUpdateTime(now)
-                    .setPin(uploadUserDTO.getPin())
-                    .setCreateBy("设备上传").setDeptId(dept.getId()).setDeptName(dept.getName())
-                    .setPin(idCarNo)
-                    .setIdCard(idCarNo)
-                    .setJudgeState(needJudge?0:1).setJudgeTime(needJudge?null:now).setJudgeBy(needJudge?"":"终端备案上传")
-                    .setName(uploadUserDTO.getName());
-            tbPersonFilingService.save(tbPersonFiling);
-            //转换图片
-            taskService.addTask(new Base64ToImage(RandomUtil.randomNumbers(10), 50, tbPersonFiling.getId(), uploadUserDTO.getPhoto()));
-            //分发人员信息到其他终端
-            taskService.addTask(new DelayIsuued(RandomUtil.randomNumbers(11), 4000, tbPersonFiling.getId(), sn));
-        } else {
-            if (!StrUtil.equals(personFiling.getPin(), uploadUserDTO.getPin())) {//更新pin
-                personFiling.setPin(uploadUserDTO.getPin());
-                tbPersonFilingService.updateById(personFiling);
-                taskService.addTask(new DelayIsuued(RandomUtil.randomNumbers(10), 4000, personFiling.getId(), sn));
-            }
+        if (personFiling!=null&&!StrUtil.equals(personFiling.getPin(), uploadUserDTO.getPin())) {//更新pin
+            personFiling.setPin(uploadUserDTO.getPin());
+            tbPersonFilingService.updateById(personFiling);
+            taskService.addTask(new DelayIsuued(RandomUtil.randomNumbers(10), 4000, personFiling.getId(), sn));
         }
     }
 }

+ 29 - 14
sp-core/src/main/java/com/pj/project/sp_admin/SpAdminService.java

@@ -95,9 +95,28 @@ public class SpAdminService {
         spAdmin.setDeptName(tbDept.getName()).setSuperAdmin(superAdmin);
     }
 
-
+    /**
+     * 绑定用户
+     *
+     * @param openid
+     * @param key
+     * @param password
+     * @param type
+     * @param name
+     * @return
+     */
     public AjaxJson bindUser(String openid, String key, String password, Integer type, String name) {
         TbMiniUser tbMiniUser = tbMiniUserService.findByUsername(key);
+        if (tbMiniUser != null) {//直接登录
+            if (tbMiniUser.getType().equals(type)) {
+                tbMiniUser.setOpenid(openid).setLastLoginTime(new Date());
+                tbMiniUserService.updateById(tbMiniUser);
+                return AjaxJson.getSuccessData(tbMiniUserService.buildToken(tbMiniUser));
+            } else {
+                return AjaxJson.getError("请更换入口");
+            }
+        }
+        //绑定操作
         if (TbMiniUser.TypeEnum.INTERIOR_TYPE.getType().equals(type)) {
             SpAdmin spAdmin = spAdminMapper.getByName(key);
             if (spAdmin == null) {
@@ -111,14 +130,9 @@ public class SpAdminService {
             if (spAdmin.getStatus() == 2) {
                 return AjaxJson.getError("此账号已被禁用");
             }
-            if (tbMiniUser==null){
-                tbMiniUser = buildMiniUser(spAdmin, openid);
-                tbMiniUser.setPassword(md5Password).setPhone(key).setUsername(key);
-                tbMiniUserService.save(tbMiniUser);
-            }else {
-                tbMiniUser.setOpenid(openid);
-                tbMiniUserService.updateById(tbMiniUser);
-            }
+            tbMiniUser = buildMiniUser(spAdmin, openid);
+            tbMiniUser.setPassword(md5Password).setPhone(key).setUsername(key);
+            tbMiniUserService.save(tbMiniUser);
             if (PhoneUtil.isPhone(key)) {
                 List<TbManager> managers = tbManagerService.findByPhone(key);
                 managers.forEach(tbManager -> tbManager.setOpenid(openid));
@@ -126,13 +140,14 @@ public class SpAdminService {
             }
             return AjaxJson.getSuccessData(tbMiniUserService.buildToken(tbMiniUser));
         } else {
-            if (tbMiniUser==null){
-                 tbMiniUser = createMiniUser(key, openid, name);
+            if (tbMiniUser == null) {
+                tbMiniUser = createMiniUser(key, openid, name);
                 String md5Password = SystemObject.getPasswordMd5(tbMiniUser.getSpAdminId(), password);
-                tbMiniUser.setPassword(md5Password).setUsername(key);
-            }else {
+                tbMiniUser.setPassword(md5Password);
+            } else {
                 tbMiniUser.setOpenid(openid);
             }
+            tbMiniUser.setLastLoginTime(new Date());
             tbMiniUserService.updateById(tbMiniUser);
             return AjaxJson.getSuccessData(tbMiniUserService.buildToken(tbMiniUser));
         }
@@ -145,7 +160,7 @@ public class SpAdminService {
         tbMiniUser.setCreateTime(new Date()).setSpAdminId(RandomUtil.randomLong(100000, 999999))
                 .setOpenid(openid).setDeptId(dept.getId() + "").setSuperAdmin(0)
                 .setPhone(key).setType(TbMiniUser.TypeEnum.TEMPORARY_TYPE.getType())
-                .setName(name);
+                .setName(name).setUsername(key);
         tbMiniUserService.save(tbMiniUser);
         return tbMiniUser;
     }

+ 12 - 5
sp-core/src/main/java/com/pj/project/tb_mini_user/TbMiniUserService.java

@@ -69,10 +69,17 @@ public class TbMiniUserService extends ServiceImpl<TbMiniUserMapper, TbMiniUser>
         return tbMiniUserMapper.getList(so);
     }
 
-
-    public TbMiniUser findByOpenid(String openid) {
+    /**
+     * 根据open和type查找
+     * @param openid
+     * @param type
+     * @return
+     */
+    public TbMiniUser findByOpenid(String openid,Integer type) {
         QueryWrapper<TbMiniUser> ew = new QueryWrapper<>();
-        ew.lambda().eq(TbMiniUser::getOpenid, openid).orderByDesc(TbMiniUser::getLastLoginTime);
+        ew.lambda().eq(TbMiniUser::getOpenid, openid)
+                .eq(TbMiniUser::getType,type)
+                .orderByDesc(TbMiniUser::getLastLoginTime);
         List<TbMiniUser> list = list(ew);
         return list.isEmpty() ? null : list.get(0);
     }
@@ -84,8 +91,8 @@ public class TbMiniUserService extends ServiceImpl<TbMiniUserMapper, TbMiniUser>
         this.remove(ew);
     }
 
-    public AjaxJson loginByOpenid(String openid) {
-        TbMiniUser tbMiniUser = this.findByOpenid(openid);
+    public AjaxJson loginByOpenid(String openid,Integer type) {
+        TbMiniUser tbMiniUser = this.findByOpenid(openid,type);
         if (tbMiniUser == null) {
             return AjaxJson.getError("用户不存在");
         }

+ 2 - 1
sp-core/src/main/java/com/pj/project/tb_person_filing/TbPersonFilingMapper.xml

@@ -37,8 +37,9 @@
         <where>
             <if test=' this.has("id") '>and id = #{id}</if>
             <if test=' this.has("deptId") '>and dept_id = #{deptId}</if>
+            <if test=' this.has("judgeState") '>and judge_state = #{judgeState}</if>
 
-            <if test=' this.has("name") '>and name = #{name}</if>
+            <if test=' this.has("name") '>and name like concat('%',#{name},'%')</if>
             <if test=' this.has("type") '>and type = #{type}</if>
             <if test=' this.has("idCard") '>and id_card = #{idCard}</if>
             <if test=' this.has("visitReason") '>and visit_reason = #{visitReason}</if>

+ 1 - 1
sp-core/src/main/java/com/pj/project/tb_person_filing/TbPersonFilingService.java

@@ -187,7 +187,7 @@ public class TbPersonFilingService extends ServiceImpl<TbPersonFilingMapper, TbP
             return;
         }
         List<TbTerminal> tbTerminalList = tbTerminalService.list();
-
+        log.info("排除设备下发人脸信息:{},{}",sn,JSONUtil.toJsonStr(filing));
         JSONObject params = builderParams(filing);
         tbTerminalList.stream().filter(t -> !StrUtil.equals(t.getSn(), sn)).forEach(tbTerminal -> {
             tbTerminalService.setCommand(CommandType.ISSUED_USER_COMMAND.getFuncId(), params, tbTerminal);

+ 13 - 13
sp-core/src/main/java/com/pj/project/tb_terminal/TbTerminalService.java

@@ -182,22 +182,23 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
         String sn = tbTerminal.getSn();
         String msgId = RandomUtil.randomNumbers(8);
         String key = myConfig.getCommandPrefix() + sn;
-        String commandStr = RedisUtil.get(key);
-        List<RequestPackageDTO> commandList = JSONUtil.toList(commandStr, RequestPackageDTO.class);
+        //   String commandStr = RedisUtil.get(key);
+        // List<RequestPackageDTO> commandList = JSONUtil.toList(commandStr, RequestPackageDTO.class);
         RequestPackageDTO commandDTO = new RequestPackageDTO();
         RequestPackageDTO.PayloadBean payloadBean = new RequestPackageDTO.PayloadBean();
 
         payloadBean.setParams(params);
         commandDTO.setFuncId(funcId).setPayload(payloadBean)
                 .setMsgId(msgId);
-        commandList.add(commandDTO);
+        // commandList.add(commandDTO);
         TbCommandLog tbCommandLog = new TbCommandLog();
         tbCommandLog.setChannelName(tbTerminal.getChannelName()).setCommand(JSONUtil.toJsonStr(commandDTO))
                 .setMsgId(msgId).setSn(sn)
                 .setTerminalName(tbTerminal.getName()).setCreateTime(new Date()).setCreateBy(StpUserUtil.getAdminName());
         //日志记录
         tbCommandLogService.save(tbCommandLog);
-        RedisUtil.set(key, JSONUtil.toJsonStr(commandList));
+        RedisUtil.lPush(key, JSONUtil.toJsonStr(commandDTO));
+        //  RedisUtil.set(key, JSONUtil.toJsonStr(commandList));
     }
 
     /**
@@ -209,13 +210,10 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
     public void checkOptions(String funcId, String sn) {
         String msgId = RandomUtil.randomNumbers(8);
         String key = myConfig.getCommandPrefix() + sn;
-        String commandStr = RedisUtil.get(key);
-        List<RequestPackageDTO> commandList = JSONUtil.toList(commandStr, RequestPackageDTO.class);
         RequestPackageDTO commandDTO = new RequestPackageDTO();
         commandDTO.setFuncId(funcId)
                 .setMsgId(msgId);
-        commandList.add(commandDTO);
-        RedisUtil.set(myConfig.getCommandPrefix() + sn, JSONUtil.toJsonStr(commandList));
+        RedisUtil.lPush(key, JSONUtil.toJsonStr(commandDTO));
     }
 
     /**
@@ -345,6 +343,9 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
         TbPersonFiling tbPersonFiling = tbPersonFilingService.findByIdCard(idCard);
         if (tbPersonFiling == null) {
             if (SpCfgUtil.termianlFilling()) {
+                TbDept dept = tbDeptService.findTheDept(TbDept.AdminTypeEnum.TEMP_TYPE.getType());
+                boolean needJudge = TbDept.NeedJudgeEnum.MAN_JUDGE.getType().equals(dept.getNeedJudge());
+                checkDataDTO.setIs_pass(needJudge ? 0 :1);
                 log.info("返回信息:{},{}", "首次备案", JSONUtil.toJsonStr(checkDataDTO));
                 return AjaxJson.getSuccess(checkBO.getName() + "首次备案", checkDataDTO);
             } else {
@@ -367,13 +368,13 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
         //健康码是否绿码
         if (!StrUtil.equals(TbPersonVisitRecord.HealthEnum.GREEN.getStatus(), checkBO.getHealth_status())) {
             log.info("返回信息健康码异常:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
-            return AjaxJson.getSuccess(msg, checkDataDTO);
+            return AjaxJson.getSuccess(msg + checkBO.getHealth_status(), checkDataDTO);
         }
         //黑名单用户
         TbPersonBlack black = tbPersonBlackService.findByIdCardAndTime(idCard, now);
         if (black != null) {
             log.info("返回信息黑名单:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
-            return AjaxJson.getSuccess(msg, checkDataDTO);
+            return AjaxJson.getSuccess(msg + "黑名单用户", checkDataDTO);
         }
         //通道是否开放
         TbTerminal tbTerminal = this.findBySN(checkBO.getSn());
@@ -387,8 +388,10 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
             return AjaxJson.getSuccess(msg, checkDataDTO);
         }
         checkDataDTO.setIs_pass(1);
+        log.info("返回信息=放行:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
         return AjaxJson.getSuccess(msg, checkDataDTO);
     }
+
     public void down(Long id) {
         TbTerminal tbTerminal = this.getById(id);
         if (TbTerminal.StateType.OFFLINE.getState().equals(tbTerminal.getState())) {
@@ -396,9 +399,6 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
         }
         tbPersonFilingService.issued(tbTerminal);
         tbPersonBlackService.issued(tbTerminal);
-        String sn = tbTerminal.getSn();
-        String key = myConfig.getCommandPrefix() + sn;
-        log.info("list:{}",RedisUtil.get(key));
         this.startHeartCommand(tbTerminal.getSn());
     }
 }

+ 2 - 1
sp-core/src/main/java/com/pj/project/tb_terminal/task/CommandDelayTask.java

@@ -33,7 +33,8 @@ public class CommandDelayTask extends Task {
     public void run() {
         log.info("延迟发送命令:{}",command);
         String channelId = cx.channel().id().asShortText();
-        RedisUtil.setBySecond(channelId, msgId, 20);
+        RedisUtil.lPush(channelId,msgId);
+       // RedisUtil.setBySecond(channelId, msgId, 20);
         cx.write(command);
         cx.flush();
     }

+ 119 - 104
sp-core/src/main/java/com/pj/utils/cache/RedisUtil.java

@@ -3,6 +3,8 @@ package com.pj.utils.cache;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.StringRedisTemplate;
@@ -12,114 +14,127 @@ import org.springframework.stereotype.Component;
 
 /**
  * Redis工具类
- * @author kongyongshun
  *
+ * @author kongyongshun
  */
 @Component
 public class RedisUtil {
 
-	public static long ttl = 24* 7;	//默认超时时间,单位周,此为一周
-
-	/**
-	 * 对象专用
-	 */
-	public static RedisTemplate<String, Object> redisTemplate;
-	@Autowired
-	@SuppressWarnings({ "rawtypes", "unchecked" })
-	public void setRedisTemplate(RedisTemplate redisTemplate) {
-		// 配置 key 序列化为 json序列化格式 
-		StringRedisSerializer keySerializer = new StringRedisSerializer();
-		redisTemplate.setKeySerializer(keySerializer);
-		redisTemplate.setHashKeySerializer(keySerializer);
-		// 配置 value 序列化为 json序列化格式 
-		GenericJackson2JsonRedisSerializer valueSerializer = new GenericJackson2JsonRedisSerializer();
-		redisTemplate.setValueSerializer(valueSerializer);
-		redisTemplate.setHashValueSerializer(valueSerializer);
-		// 
-		RedisUtil.redisTemplate = redisTemplate;
-	}
-
-	/**
-	 * string专用
-	 */
-	static StringRedisTemplate stringRedisTemplate;
-	@Autowired
-	public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplates) {
-		RedisUtil.stringRedisTemplate = stringRedisTemplates;
-	}
-
-
-	/* * * * * * * * * * * * * * * * String操作 * * * * * * * * * * * * * * * * * * * * * * * * */
-
-
-	// 默认7*24小时
-	public static void set(String key, String value) {
-		stringRedisTemplate.opsForValue().set(key, value, ttl, TimeUnit.HOURS);
-	}
-
-	// 写入,并设置时长,单位 Hours
-	public static void setByHour(String key, String value, int timeout) {
-		stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.HOURS);
-	}
-	
-	// 写入,并设置时长,单位 分钟 MINUTES
-	public static void setByMINUTES(String key, String value, int timeout) {
-		stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.MINUTES);
-	}
-	// 写入,并设置时长,单位 秒
-	public static void setBySecond(String key, String value, int timeout) {
-		stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
-	}
-
-	// 写入,永久有效 
-	public static void setByForever(String key, String value) {
-		stringRedisTemplate.opsForValue().set(key, value);
-	}
-
-	// 读取
-	public static String get(String key) {
-		return stringRedisTemplate.opsForValue().get(key);
-	}
-
-
-	// 删除
-	public static void del(String key) {
-		stringRedisTemplate.delete(key);
-	}
-
-
-	/* * * * * * * * * * * * * * * * Object值操作 * * * * * * * * * * * * * * * * * * * * * * * * */
-
-	// 写入值
-	public static void forValueSet(String key, Object value){
-		redisTemplate.opsForValue().set(key, value, ttl, TimeUnit.HOURS);
-	}
-
-	// 读取值
-	@SuppressWarnings("unchecked")
-	public static <T>T forValueGet(String key, Class<T> cs){
-		return (T) redisTemplate.opsForValue().get(key);
-	}
-
-
-	/* * * * * * * * * * * * * * * * List集合操作 * * * * * * * * * * * * * * * * * * * * * * * * */
-
-	// 查询
-	public static List<Object> forListGet(String key){
-		return redisTemplate.opsForList().range(key, 0, -1);
-	}
-
-	// 追加键值
-	public static void forListAdd(String key, Object... args){
-		redisTemplate.opsForList().rightPushAll(key,  args);
-	}
-
-	// 移除所有键值
-	public static void forListRemove(String key){
-		List<Object> list = forListGet(key);
-		for (int i = 0; i < list.size(); i++) {
-			redisTemplate.opsForList().remove(key, -1,list.get(i));
-		}
-	}
+    public static long ttl = 24 * 7;    //默认超时时间,单位周,此为一周
 
+    /**
+     * 对象专用
+     */
+    public static RedisTemplate<String, Object> redisTemplate;
+
+    @Autowired
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public void setRedisTemplate(RedisTemplate redisTemplate) {
+        // 配置 key 序列化为 json序列化格式
+        StringRedisSerializer keySerializer = new StringRedisSerializer();
+        redisTemplate.setKeySerializer(keySerializer);
+        redisTemplate.setHashKeySerializer(keySerializer);
+        // 配置 value 序列化为 json序列化格式
+        GenericJackson2JsonRedisSerializer valueSerializer = new GenericJackson2JsonRedisSerializer();
+        redisTemplate.setValueSerializer(valueSerializer);
+        redisTemplate.setHashValueSerializer(valueSerializer);
+        //
+        RedisUtil.redisTemplate = redisTemplate;
+    }
+
+    /**
+     * string专用
+     */
+    static StringRedisTemplate stringRedisTemplate;
+
+    @Autowired
+    public void setStringRedisTemplate(StringRedisTemplate stringRedisTemplates) {
+        RedisUtil.stringRedisTemplate = stringRedisTemplates;
+    }
+
+
+    /* * * * * * * * * * * * * * * * String操作 * * * * * * * * * * * * * * * * * * * * * * * * */
+
+
+    // 默认7*24小时
+    public static void set(String key, String value) {
+        stringRedisTemplate.opsForValue().set(key, value, ttl, TimeUnit.HOURS);
+    }
+
+    // 写入,并设置时长,单位 Hours
+    public static void setByHour(String key, String value, int timeout) {
+        stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.HOURS);
+    }
+
+    // 写入,并设置时长,单位 分钟 MINUTES
+    public static void setByMINUTES(String key, String value, int timeout) {
+        stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.MINUTES);
+    }
+
+    // 写入,并设置时长,单位 秒
+    public static void setBySecond(String key, String value, int timeout) {
+        stringRedisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
+    }
+
+    // 写入,永久有效
+    public static void setByForever(String key, String value) {
+        stringRedisTemplate.opsForValue().set(key, value);
+    }
+
+    // 读取
+    public static String get(String key) {
+        return stringRedisTemplate.opsForValue().get(key);
+    }
+
+
+    // 删除
+    public static void del(String key) {
+        stringRedisTemplate.delete(key);
+    }
+
+
+    /* * * * * * * * * * * * * * * * Object值操作 * * * * * * * * * * * * * * * * * * * * * * * * */
+
+    // 写入值
+    public static void forValueSet(String key, Object value) {
+        redisTemplate.opsForValue().set(key, value, ttl, TimeUnit.HOURS);
+    }
+
+    // 读取值
+    @SuppressWarnings("unchecked")
+    public static <T> T forValueGet(String key, Class<T> cs) {
+        return (T) redisTemplate.opsForValue().get(key);
+    }
+
+
+    /* * * * * * * * * * * * * * * * List集合操作 * * * * * * * * * * * * * * * * * * * * * * * * */
+
+    // 查询
+    public static List<Object> forListGet(String key) {
+        return redisTemplate.opsForList().range(key, 0, -1);
+    }
+
+    // 追加键值
+    public static void forListAdd(String key, Object... args) {
+        redisTemplate.opsForList().rightPushAll(key, args);
+    }
+
+    // 移除所有键值
+    public static void forListRemove(String key) {
+        List<Object> list = forListGet(key);
+        for (int i = 0; i < list.size(); i++) {
+            redisTemplate.opsForList().remove(key, -1, list.get(i));
+        }
+    }
+
+
+    public static void lPush(String key, String value) {
+        redisTemplate.opsForList().leftPush(key, value);
+        redisTemplate.expire(key, 80, TimeUnit.SECONDS);
+    }
+
+    public static String rPorp(String key) {
+        Object v = redisTemplate.opsForList().rightPop(key);
+        return v == null ? "" : v.toString();
+    }
 }

+ 3 - 3
sp-start/src/main/resources/application-dev.yml

@@ -13,12 +13,12 @@ spring:
         # 是否打开sql监控台  (生产环境请务必关闭此选项) 
         druid: 
             stat-view-servlet:
-                enabled: true
+                enabled: false
             web-stat-filter: 
-                enabled: true
+                enabled: false
             filter:
                 config:
-                    enabled: true
+                    enabled: false
 
     # redis配置 
     redis: