|
@@ -6,6 +6,8 @@ import java.net.Socket;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.cache.CacheUtil;
|
|
@@ -105,8 +107,7 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
String sn = getSn(ip);
|
|
|
//通道
|
|
|
TbVenues channel = tbVenuesService.getById(channelId);
|
|
|
- t.setSn(sn)
|
|
|
- .setDepartmentId(channel.getDepartmentId());
|
|
|
+ t.setSn(sn);
|
|
|
//场地
|
|
|
t.setVenuesId(channel.getPId());
|
|
|
this.save(t);
|
|
@@ -154,7 +155,7 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
t.setSn(sn);
|
|
|
}
|
|
|
TbVenues channel = tbVenuesService.getById(t.getChannelId());
|
|
|
- t.setDepartmentId(channel.getDepartmentId()).setVenuesId(channel.getPId());
|
|
|
+ t.setVenuesId(channel.getPId());
|
|
|
this.updateById(t);
|
|
|
}
|
|
|
|
|
@@ -315,11 +316,12 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
TbVenues pVenues = tbVenuesService.getById(channel.getPId());
|
|
|
TbCarVisitRecord tbCarVisitRecord = new TbCarVisitRecord();
|
|
|
tbCarVisitRecord.setCarNo(carNo).setAllowPass(allowPass)
|
|
|
- .setChannelId(tbGateTerminal.getVenuesId()).setDepartmentId(pVenues.getDepartmentId())
|
|
|
+ .setChannelId(tbGateTerminal.getVenuesId())
|
|
|
.setChannel(channel.getName()).setDirection(direction).setVenuesId(pVenues.getId())
|
|
|
.setVisitTime(now).setUpdateTime(now).setCreateTime(now).setRecordType(2);
|
|
|
- TbCarFiling carFiling = tbCarFilingService.findByCarNo(carNo);
|
|
|
- if (carFiling != null) {
|
|
|
+ List<TbCarFiling> carFilingList = tbCarFilingService.findByCarNo(carNo);
|
|
|
+ if (carFilingList.size() == 1) {
|
|
|
+ TbCarFiling carFiling = carFilingList.get(0);
|
|
|
TbDept tbDept = tbDeptService.getById(carFiling.getDeptId());
|
|
|
tbCarVisitRecord.setDriverName(carFiling.getDriverName()).setDeptId(carFiling.getDeptId()).setDeptName(tbDept.getName())
|
|
|
.setDriverIdCard(carFiling.getDriverIdCard()).setType(carFiling.getType())
|
|
@@ -340,12 +342,16 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
*/
|
|
|
private void cacheResult(String carNo, String now, TbGateTerminal tbGateTerminal, Long recordId) {
|
|
|
Long channelId = tbGateTerminal.getChannelId();
|
|
|
+ Long venuesId = tbGateTerminal.getVenuesId();
|
|
|
TbCarBlack tbCarBlack = tbCarBlackService.findByCarNo(carNo, now);
|
|
|
String key = "result:" + channelId;
|
|
|
//是否在黑名单上
|
|
|
Long terminalId = tbGateTerminal.getId();
|
|
|
ResultDTO dto = new ResultDTO(recordId, terminalId, 0);
|
|
|
- if (tbCarBlack != null) {
|
|
|
+ long nowTime = new Date().getTime();
|
|
|
+ if (tbCarBlack != null
|
|
|
+ &&nowTime<=tbCarBlack.getEndTime().getTime()
|
|
|
+ &&nowTime>=tbCarBlack.getStartTime().getTime()) {
|
|
|
RedisUtil.set(key, JSONUtil.toJsonStr(dto));
|
|
|
log.error("黑名单车辆:{}", carNo);
|
|
|
return;
|
|
@@ -356,34 +362,40 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
log.error("防疫策略不开放:{}", carNo);
|
|
|
return;
|
|
|
}
|
|
|
- //入口场所
|
|
|
- TbVenues tbVenues = tbVenuesService.getById(channel.getPId());
|
|
|
- TbCarFiling tbCarFiling = tbCarFilingService.findByCarNo(carNo);
|
|
|
+
|
|
|
+ List<TbCarFiling> carFilingList = tbCarFilingService.findByCarNo(carNo);
|
|
|
//是否备案
|
|
|
- if (tbCarFiling == null) {
|
|
|
+ if (carFilingList.isEmpty()) {
|
|
|
RedisUtil.set(key, JSONUtil.toJsonStr(dto));
|
|
|
log.error("车辆未备案:{}", carNo);
|
|
|
return;
|
|
|
}
|
|
|
+ //设备所在场所
|
|
|
+ TbVenues terminalVenues = tbVenuesService.getById(venuesId);
|
|
|
+ //找出备案等级比之高的场所
|
|
|
+ List<Long> venuesIdList = carFilingList.stream().map(TbCarFiling::getVenuesId).collect(Collectors.toList());
|
|
|
//备案的场所
|
|
|
- TbVenues filingTbVenues=tbVenuesService.getById(tbCarFiling.getVenuesId());
|
|
|
+ List<TbVenues> venuesList = tbVenuesService.listByIds(venuesIdList);
|
|
|
+ Optional<TbVenues> optionalTbVenues = venuesList.stream().filter(venues -> venues.getLevel() <= terminalVenues.getLevel()).findAny();
|
|
|
//备案场所的等级低于入场的场所===>不给通行
|
|
|
- if (filingTbVenues.getLevel()>tbVenues.getLevel()){
|
|
|
+ if (!optionalTbVenues.isPresent()) {
|
|
|
RedisUtil.set(key, JSONUtil.toJsonStr(dto));
|
|
|
log.error("备案场所等级不足,无法进入:{}", carNo);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- //备案车,如果属于的组织只需要满足一个条件的直接放行
|
|
|
- Long deptId = tbCarFiling.getDeptId();
|
|
|
- TbDept tbDept = tbDeptService.getById(deptId);
|
|
|
- if (TbDept.PassTypeEnum.ONE.getType().equals(tbDept.getPassType())) {
|
|
|
- log.error("组织满足条件二,直接放行:{}", carNo);
|
|
|
- try {
|
|
|
- open(terminalId);
|
|
|
- tbCarVisitRecordService.updatePass(recordId);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("开闸失败:{}", e.getMessage());
|
|
|
+ for (TbCarFiling tbCarFiling : carFilingList) {//备案车,如果属于的组织只需要满足一个条件的直接放行
|
|
|
+ Long deptId = tbCarFiling.getDeptId();
|
|
|
+ TbDept tbDept = tbDeptService.getById(deptId);
|
|
|
+ if (TbDept.PassTypeEnum.ONE.getType().equals(tbDept.getPassType())) {
|
|
|
+ log.error("组织满足条件二,直接放行:{}", carNo);
|
|
|
+ try {
|
|
|
+ open(terminalId);
|
|
|
+ tbCarVisitRecordService.updatePass(recordId);
|
|
|
+ //停止循环下发命令
|
|
|
+ break;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("开闸失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
dto = new ResultDTO(recordId, terminalId, 1);
|
|
@@ -392,12 +404,13 @@ public class TbGateTerminalService extends ServiceImpl<TbGateTerminalMapper, TbG
|
|
|
|
|
|
/**
|
|
|
* 通道的道闸
|
|
|
+ *
|
|
|
* @param channelId
|
|
|
* @return
|
|
|
*/
|
|
|
public List<TbGateTerminal> findByChannelId(Long channelId) {
|
|
|
QueryWrapper<TbGateTerminal> ew = new QueryWrapper<>();
|
|
|
- ew.lambda().eq(TbGateTerminal::getChannelId,channelId);
|
|
|
+ ew.lambda().eq(TbGateTerminal::getChannelId, channelId);
|
|
|
return list(ew);
|
|
|
}
|
|
|
}
|