|
@@ -2,34 +2,40 @@ package com.pj.project.tb_terminal;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.Update;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.pj.current.config.MyConfig;
|
|
|
import com.pj.current.global.BusinessException;
|
|
|
import com.pj.current.netty.command.constants.CommandType;
|
|
|
-import com.pj.current.netty.dto.ParamsDTO;
|
|
|
import com.pj.current.netty.dto.RequestPackageDTO;
|
|
|
-import com.pj.current.netty.dto.ResponsePackageDTO;
|
|
|
import com.pj.current.netty.heart.HeartBeatHandler;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.project.tb_command_log.TbCommandLog;
|
|
|
import com.pj.project.tb_command_log.TbCommandLogService;
|
|
|
+import com.pj.project.tb_dept.TbDept;
|
|
|
+import com.pj.project.tb_dept.TbDeptService;
|
|
|
+import com.pj.project.tb_person_black.TbPersonBlack;
|
|
|
import com.pj.project.tb_person_black.TbPersonBlackService;
|
|
|
+import com.pj.project.tb_person_filing.TbPersonFiling;
|
|
|
import com.pj.project.tb_person_filing.TbPersonFilingService;
|
|
|
+import com.pj.project.tb_person_visit_record.TbPersonVisitRecord;
|
|
|
+import com.pj.project.tb_terminal.bo.CheckBO;
|
|
|
+import com.pj.project.tb_terminal.bo.CheckDataDTO;
|
|
|
+import com.pj.project.tb_terminal.bo.MonitorDTO;
|
|
|
import com.pj.project.tb_venues.TbVenues;
|
|
|
import com.pj.project.tb_venues.TbVenuesService;
|
|
|
+import com.pj.project4sp.spcfg.SpCfgUtil;
|
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
-import io.netty.channel.ChannelHandlerContext;
|
|
|
+import com.pj.utils.sg.AjaxJson;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -67,6 +73,8 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
|
|
|
@Resource
|
|
|
private TbPersonBlackService tbPersonBlackService;
|
|
|
+ @Resource
|
|
|
+ private TbDeptService tbDeptService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -123,6 +131,9 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
tbTerminal.setIpAddress(clientIp).setState(TbTerminal.StateType.ONLINE.getState())
|
|
|
.setSn(sn).setCreateTime(new Date());
|
|
|
this.save(tbTerminal);
|
|
|
+ tbPersonFilingService.issued(tbTerminal);
|
|
|
+ tbPersonBlackService.issued(tbTerminal);
|
|
|
+ this.startHeartCommand(tbTerminal.getSn());
|
|
|
return;
|
|
|
}
|
|
|
if (!StrUtil.equals(tbTerminal.getState(), TbTerminal.StateType.ONLINE.getState())) {
|
|
@@ -190,6 +201,7 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
|
|
|
/**
|
|
|
* 查看设备属性,不记录日志
|
|
|
+ *
|
|
|
* @param funcId
|
|
|
* @param sn
|
|
|
*/
|
|
@@ -223,7 +235,7 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
*/
|
|
|
public void unbind(Long id) {
|
|
|
TbTerminal tbTerminal = this.getById(id);
|
|
|
- if (StrUtil.equals(tbTerminal.getState(),TbTerminal.StateType.OFFLINE.getState())){
|
|
|
+ if (StrUtil.equals(tbTerminal.getState(), TbTerminal.StateType.OFFLINE.getState())) {
|
|
|
throw new BusinessException("设备已离线");
|
|
|
}
|
|
|
tbTerminalMapper.unbind(id);
|
|
@@ -236,7 +248,7 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
*/
|
|
|
public void clearData(Long id) {
|
|
|
TbTerminal tbTerminal = this.getById(id);
|
|
|
- if (StrUtil.equals(tbTerminal.getState(),TbTerminal.StateType.OFFLINE.getState())){
|
|
|
+ if (StrUtil.equals(tbTerminal.getState(), TbTerminal.StateType.OFFLINE.getState())) {
|
|
|
throw new BusinessException("设备已离线");
|
|
|
}
|
|
|
this.clearData(tbTerminal);
|
|
@@ -255,7 +267,6 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 清空所有数据
|
|
|
*
|
|
@@ -268,12 +279,13 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
|
|
|
/**
|
|
|
* 远程开门
|
|
|
+ *
|
|
|
* @param id
|
|
|
*/
|
|
|
public void open(Long id) {
|
|
|
log.info("==========远程开闸============");
|
|
|
TbTerminal tbTerminal = this.getById(id);
|
|
|
- if (StrUtil.equals(tbTerminal.getState(),TbTerminal.StateType.OFFLINE.getState())){
|
|
|
+ if (StrUtil.equals(tbTerminal.getState(), TbTerminal.StateType.OFFLINE.getState())) {
|
|
|
throw new BusinessException("设备已离线");
|
|
|
}
|
|
|
setCommand(CommandType.ISSUED_NORMALOPEN_COMMAND.getFuncId(), null, tbTerminal);
|
|
@@ -282,15 +294,16 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
|
|
|
/**
|
|
|
* 同步时间
|
|
|
+ *
|
|
|
* @param id
|
|
|
*/
|
|
|
- public void asyncTime(Long id){
|
|
|
+ public void asyncTime(Long id) {
|
|
|
TbTerminal tbTerminal = this.getById(id);
|
|
|
- if (StrUtil.equals(tbTerminal.getState(),TbTerminal.StateType.OFFLINE.getState())){
|
|
|
+ if (StrUtil.equals(tbTerminal.getState(), TbTerminal.StateType.OFFLINE.getState())) {
|
|
|
throw new BusinessException("设备已离线");
|
|
|
}
|
|
|
- JSONObject params=new JSONObject();
|
|
|
- params.set("time",System.currentTimeMillis()/1000);
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.set("time", System.currentTimeMillis() / 1000);
|
|
|
setCommand(CommandType.SYNC_TIME_COMMAND.getFuncId(), params, tbTerminal);
|
|
|
startHeartCommand(tbTerminal.getSn());
|
|
|
|
|
@@ -301,4 +314,64 @@ public class TbTerminalService extends ServiceImpl<TbTerminalMapper, TbTerminal>
|
|
|
ew.eq("channel_id", channelId);
|
|
|
return list(ew);
|
|
|
}
|
|
|
+
|
|
|
+ public List<MonitorDTO> getMonitor() {
|
|
|
+ return tbTerminalMapper.getMonitor();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 终端请求是否放行
|
|
|
+ *
|
|
|
+ * @param checkBO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public AjaxJson check(CheckBO checkBO) {
|
|
|
+ log.info("设备请求放行接口:{}", JSONUtil.toJsonStr(checkBO));
|
|
|
+ int acidLimit = SpCfgUtil.getAcidLimit();
|
|
|
+ int tourLimit = SpCfgUtil.getTourLimit();
|
|
|
+ String now = DateUtil.now();
|
|
|
+ String idCard = checkBO.getIdentity_number();
|
|
|
+ CheckDataDTO checkDataDTO = new CheckDataDTO();
|
|
|
+ checkDataDTO.setNucleic_restrict(acidLimit)
|
|
|
+ .setTrip_restrict(tourLimit).setIs_pass(0);
|
|
|
+ //是否备案、备案是否通过审核
|
|
|
+ TbPersonFiling tbPersonFiling = tbPersonFilingService.findByIdCard(idCard);
|
|
|
+ if (tbPersonFiling == null || tbPersonFiling.getJudgeState() == 0) {
|
|
|
+ log.info("返回信息:{},{}", "人员未备案", JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess("人员未备案", checkDataDTO);
|
|
|
+ }
|
|
|
+ TbDept tbDept = tbDeptService.getById(tbPersonFiling.getDeptId());
|
|
|
+ String msg = tbDept.getName() + tbPersonFiling.getName();
|
|
|
+ //体温是否异常
|
|
|
+ double minTemperature = SpCfgUtil.getMinTemperature();
|
|
|
+ if (minTemperature < checkBO.getTemperature()) {
|
|
|
+ log.info("返回信息体温过高:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess(msg, checkDataDTO);
|
|
|
+ }
|
|
|
+ //健康码是否绿码
|
|
|
+ if (!StrUtil.equals(TbPersonVisitRecord.HealthEnum.GREEN.getStatus(), checkBO.getHealth_status())) {
|
|
|
+ log.info("返回信息健康码异常:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess(msg, checkDataDTO);
|
|
|
+ }
|
|
|
+ //黑名单用户
|
|
|
+ TbPersonBlack black = tbPersonBlackService.findByIdCardAndTime(idCard, now);
|
|
|
+ if (black != null) {
|
|
|
+ log.info("返回信息黑名单:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess(msg, checkDataDTO);
|
|
|
+ }
|
|
|
+ //通道是否开放
|
|
|
+ TbTerminal tbTerminal = this.findBySN(checkBO.getSn());
|
|
|
+ if (tbTerminal==null){
|
|
|
+ log.info("返回信息非法设备:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess("非法设备", checkDataDTO);
|
|
|
+ }
|
|
|
+ TbVenues tbVenues = tbVenuesService.getById(tbTerminal.getChannelId());
|
|
|
+ if (tbVenues.getStatus()==0){
|
|
|
+ log.info("返回信息通道关闭放行:{},{}", msg, JSONUtil.toJsonStr(checkDataDTO));
|
|
|
+ return AjaxJson.getSuccess(msg, checkDataDTO);
|
|
|
+ }
|
|
|
+ checkDataDTO.setIs_pass(1);
|
|
|
+ return AjaxJson.getSuccess(msg, checkDataDTO);
|
|
|
+ }
|
|
|
+
|
|
|
}
|