|
|
@@ -29,6 +29,7 @@ import com.zd.common.core.utils.DictUtils;
|
|
|
import com.zd.common.core.utils.SaveUtil;
|
|
|
import com.zd.common.core.utils.SecurityUtils;
|
|
|
import com.zd.laboratory.api.dto.CheckSubjectDto;
|
|
|
+import com.zd.laboratory.api.dto.LabHardwareDto;
|
|
|
import com.zd.laboratory.api.dto.WarningConfigDto;
|
|
|
import com.zd.laboratory.api.dto.WarningNoticeLogDto;
|
|
|
import com.zd.laboratory.api.entity.LabMessageContent;
|
|
|
@@ -355,18 +356,17 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
@Override
|
|
|
public synchronized boolean RFIDCheck(InventoryTag tag) {
|
|
|
String rfidCode = tag.getEpc();
|
|
|
- if(StringUtils.isBlank(rfidCode)){
|
|
|
+ if (StringUtils.isBlank(rfidCode)) {
|
|
|
return false;
|
|
|
}
|
|
|
Date d = cacheMap.get(rfidCode);
|
|
|
- if(d != null && DateUtil.compare(DateUtil.offsetSecond(d, interval), DateUtils.getNowDate()) > 0){
|
|
|
+ if (d != null && DateUtil.compare(DateUtil.offsetSecond(d, interval), DateUtils.getNowDate()) > 0) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
logger.info("RFID 实时检测 RFIDCheck(标签编号): " + rfidCode);
|
|
|
HxpStock hxpStock = hxpStockMapper.selectByRfidCode(rfidCode);
|
|
|
- if(hxpStock == null){
|
|
|
+ if (hxpStock == null) {
|
|
|
logger.info("RFID 实时检测 (标签未绑定化学品): " + rfidCode);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -374,10 +374,10 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
|
|
|
// 查询该库存数据是否处于领用状态
|
|
|
HxpUserecord hxpUserecord = hxpUserecordMapper.selectByStockId(hxpStock.getId());
|
|
|
- if(hxpUserecord != null){
|
|
|
+ if (hxpUserecord != null) {
|
|
|
logger.info("RFID 化学品正常使用中: " + JSONUtil.toJsonStr(hxpUserecord));
|
|
|
return false;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
logger.info("RFID 检测到违规触发报警: " + JSONUtil.toJsonStr(hxpStock));
|
|
|
//触发RFID警报
|
|
|
HardwareRfidDto hardwareRfidDto = tag.getHardwareRfidDto();
|
|
|
@@ -391,116 +391,129 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
WarningConfigDto warningConfigDto = byType.getData();
|
|
|
String illegalRemoval = warningConfigDto.getIllegalRemoval();
|
|
|
|
|
|
- WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
- warningNoticeLogDto.setKeyId(hxpStock.getId());
|
|
|
- warningNoticeLogDto.setName(hxpStock.getChemicalName());
|
|
|
- warningNoticeLogDto.setWarningType(2);
|
|
|
- warningNoticeLogDto.setWarningSubType(1);
|
|
|
- warningNoticeLogDto.setWarningContent("化学品违规带离");
|
|
|
- warningNoticeLogDto.setWarningTime(LocalDateTime.now());
|
|
|
- warningNoticeLogDto.setWarningWay(illegalRemoval);
|
|
|
- warningNoticeLogDto.setMargin(hxpStock.getOutUsages());
|
|
|
- warningNoticeLogDto.setDeposit(hxpStock.getCabinetName());
|
|
|
- warningNoticeLogDto.setSpecification(hxpChemicalJoinCabinet.getChemicalAmount() + hxpChemicalJoinCabinet.getChemicalAmountUnit());
|
|
|
+ WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
+ warningNoticeLogDto.setKeyId(hxpStock.getId());
|
|
|
+ warningNoticeLogDto.setName(hxpStock.getChemicalName());
|
|
|
+ warningNoticeLogDto.setWarningType(2);
|
|
|
+ warningNoticeLogDto.setWarningSubType(1);
|
|
|
+ warningNoticeLogDto.setWarningContent("化学品违规带离");
|
|
|
+ warningNoticeLogDto.setWarningTime(LocalDateTime.now());
|
|
|
+ warningNoticeLogDto.setWarningWay(illegalRemoval);
|
|
|
+ warningNoticeLogDto.setMargin(hxpStock.getOutUsages());
|
|
|
+ warningNoticeLogDto.setDeposit(hxpStock.getCabinetName());
|
|
|
+ warningNoticeLogDto.setSpecification(hxpChemicalJoinCabinet.getChemicalAmount() + hxpChemicalJoinCabinet.getChemicalAmountUnit());
|
|
|
|
|
|
- //查询到实验室负责人id 安全责任人id
|
|
|
- ResultData<List<CheckSubjectDto>> subjectInfoList = remoteLaboratoryService.findSubjectInfoList(String.valueOf(hxpStock.getSubId()));
|
|
|
- StringBuffer userIdStr = new StringBuffer();
|
|
|
- StringBuffer phones = new StringBuffer();
|
|
|
- if (HttpStatus.SUCCESS == subjectInfoList.getCode()) {
|
|
|
- List<CheckSubjectDto> data = subjectInfoList.getData();
|
|
|
- CheckSubjectDto i = data.get(0);
|
|
|
- warningNoticeLogDto.setSubId(i.getSubId());
|
|
|
- warningNoticeLogDto.setSubName(i.getSubjectName());
|
|
|
- warningNoticeLogDto.setBuildName(i.getBuildName());
|
|
|
- warningNoticeLogDto.setFloorId(i.getFloorId());
|
|
|
- warningNoticeLogDto.setFloorName(i.getFloorName());
|
|
|
- warningNoticeLogDto.setRoomNum(i.getRoomNumber());
|
|
|
- userIdStr.append(i.getSafeUserId()).append(",").append(i.getAdminId());
|
|
|
- phones.append(i.getAdminPhone()).append(",").append(i.getSafeUserPhone());
|
|
|
- }
|
|
|
- ResultData resultData = remoteLaboratoryService.addWarningNoticeLog(warningNoticeLogDto);
|
|
|
- if (HttpStatus.SUCCESS != resultData.getCode()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- Long logId = (Long)resultData.getData();
|
|
|
- if(illegalRemoval != null){
|
|
|
- ResultData urlScheme = remoteMessageService.getUrlScheme(logId);
|
|
|
- if(urlScheme.getCode() != HttpStatus.SUCCESS){
|
|
|
- logger.error("获取urlScheme失败!");
|
|
|
+ //查询到实验室负责人id 安全责任人id
|
|
|
+ ResultData<List<CheckSubjectDto>> subjectInfoList = remoteLaboratoryService.findSubjectInfoList(String.valueOf(hxpStock.getSubId()));
|
|
|
+ StringBuffer userIdStr = new StringBuffer();
|
|
|
+ StringBuffer phones = new StringBuffer();
|
|
|
+ if (HttpStatus.SUCCESS == subjectInfoList.getCode()) {
|
|
|
+ List<CheckSubjectDto> data = subjectInfoList.getData();
|
|
|
+ CheckSubjectDto i = data.get(0);
|
|
|
+ warningNoticeLogDto.setSubId(i.getSubId());
|
|
|
+ warningNoticeLogDto.setSubName(i.getSubjectName());
|
|
|
+ warningNoticeLogDto.setBuildName(i.getBuildName());
|
|
|
+ warningNoticeLogDto.setFloorId(i.getFloorId());
|
|
|
+ warningNoticeLogDto.setFloorName(i.getFloorName());
|
|
|
+ warningNoticeLogDto.setRoomNum(i.getRoomNumber());
|
|
|
+ userIdStr.append(i.getSafeUserId()).append(",").append(i.getAdminId());
|
|
|
+ phones.append(i.getAdminPhone()).append(",").append(i.getSafeUserPhone());
|
|
|
+ }
|
|
|
+ ResultData resultData = remoteLaboratoryService.addWarningNoticeLog(warningNoticeLogDto);
|
|
|
+ if (HttpStatus.SUCCESS != resultData.getCode()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Long logId = (Long) resultData.getData();
|
|
|
+ //rfid报警通知
|
|
|
+ R<Boolean> alarm = remoteRfidService.alarm(hardwareRfidDto);
|
|
|
+ logger.info("==================>{},{}", alarm.getCode(), alarm.getMsg());
|
|
|
+ //视频录制
|
|
|
+ ResultData<LabHardwareDto> cameraHardware = remoteLabHardwareService.findHardwareByType(hxpStock.getSubId(), 4, null, "2");
|
|
|
+ if (HttpStatus.SUCCESS == cameraHardware.getCode()) {
|
|
|
+ String ip = cameraHardware.getData().getIpAddress();
|
|
|
+ startVideo(ip);
|
|
|
+ scheduledExecutorService.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ stopVideo(ip, logId);
|
|
|
}
|
|
|
- String text = "【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-实验人员违规携带"+warningNoticeLogDto.getName()+"离开房间,发生时间:"+LocalDateTimeUtil.format(LocalDateTime.now(),"yyyy-MM-dd HH:mm:ss")+",请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id="+logId +"&urlScheme="+urlScheme.getData();
|
|
|
- if (illegalRemoval.contains("1")) {
|
|
|
- //系统通知
|
|
|
- LabMessageContent labMessageContent = new LabMessageContent();
|
|
|
- labMessageContent.setSendMode(2);
|
|
|
- labMessageContent.setSendRange(3);
|
|
|
- labMessageContent.setMessClass(1);
|
|
|
- labMessageContent.setMessType(13);
|
|
|
- labMessageContent.setSubIds(String.valueOf(hxpStock.getSubId()));
|
|
|
- labMessageContent.setUserIds(userIdStr.toString());
|
|
|
- labMessageContent.setContent(text);
|
|
|
- remoteMessageContentService.sendMessage(labMessageContent);
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- if (illegalRemoval.contains("2")) {
|
|
|
- //短信通知
|
|
|
- String[] strings = Stream.of(phones.toString().split(","))
|
|
|
- .filter(a -> StrUtil.isNotBlank(a))
|
|
|
- .collect(Collectors.joining(","))
|
|
|
- .split(",");
|
|
|
+ //按照配置预警
|
|
|
+ if (illegalRemoval != null) {
|
|
|
+ ResultData urlScheme = remoteMessageService.getUrlScheme(logId);
|
|
|
+ if (urlScheme.getCode() != HttpStatus.SUCCESS) {
|
|
|
+ logger.error("获取urlScheme失败!");
|
|
|
+ }
|
|
|
+ String text = "【实验室安全系统】" + warningNoticeLogDto.getSubName() + "-实验人员违规携带" + warningNoticeLogDto.getName() + "离开房间,发生时间:" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") + ",请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id=" + logId + "&urlScheme=" + urlScheme.getData();
|
|
|
+ //系统通知
|
|
|
+ if (illegalRemoval.contains("1")) {
|
|
|
+ LabMessageContent labMessageContent = new LabMessageContent();
|
|
|
+ labMessageContent.setSendMode(2);
|
|
|
+ labMessageContent.setSendRange(3);
|
|
|
+ labMessageContent.setMessClass(1);
|
|
|
+ labMessageContent.setMessType(13);
|
|
|
+ labMessageContent.setSubIds(String.valueOf(hxpStock.getSubId()));
|
|
|
+ labMessageContent.setUserIds(userIdStr.toString());
|
|
|
+ labMessageContent.setContent(text);
|
|
|
+ remoteMessageContentService.sendMessage(labMessageContent);
|
|
|
|
|
|
- if (strings != null) {
|
|
|
- AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(),text);
|
|
|
- remoteAlarmService.send(alarmEntrty);
|
|
|
- logger.info("化学品违规带离发送短信打电话消息推送完成!");
|
|
|
- }
|
|
|
- }
|
|
|
- if (hardwareRfidDto!=null && illegalRemoval.contains("3")) {
|
|
|
- //声光报警
|
|
|
- R<Boolean> alarm = remoteRfidService.alarm(hardwareRfidDto);
|
|
|
- logger.info("==================>{},{}",alarm.getCode(),alarm.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ //短信通知
|
|
|
+ if (illegalRemoval.contains("2")) {
|
|
|
+ String[] strings = Stream.of(phones.toString().split(",")).filter(a -> StrUtil.isNotBlank(a)).collect(Collectors.joining(",")).split(",");
|
|
|
+ if (strings != null) {
|
|
|
+ AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
|
|
|
+ remoteAlarmService.send(alarmEntrty);
|
|
|
+ logger.info("化学品违规带离发送短信打电话消息推送完成!");
|
|
|
}
|
|
|
- ResultData result = remoteLabHardwareService.findCameraByType(hxpStock.getSubId(), 4, "2");
|
|
|
- if (HttpStatus.SUCCESS == result.getCode()) {
|
|
|
- String ip = String.valueOf(result.getData());
|
|
|
- startVideo(ip);
|
|
|
+ }
|
|
|
+ if (hardwareRfidDto != null && illegalRemoval.contains("3")) {
|
|
|
+ ResultData<LabHardwareDto> hardwareByType = remoteLabHardwareService.findHardwareByType(hxpStock.getSubId(), 8, null, null);
|
|
|
+ if (HttpStatus.SUCCESS == hardwareByType.getCode()) {
|
|
|
+ warningNoticeLogDto.setVoiceBroadcast(1);
|
|
|
+ Long id = hardwareByType.getData().getId();
|
|
|
+ remoteLaboratoryService.controlDevice(id, 1);
|
|
|
scheduledExecutorService.schedule(new TimerTask() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- stopVideo(ip,logId);
|
|
|
+ remoteLaboratoryService.controlDevice(id, 0);
|
|
|
}
|
|
|
}, 30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
}
|
|
|
+ remoteLaboratoryService.updateWarningNoticeLog(warningNoticeLogDto);
|
|
|
+ }
|
|
|
// 如果非领用状态,做报警台账
|
|
|
// 0.检测实验室声光报警器是否使用- 使用则直接调用触发- 否则跳过
|
|
|
- Map<String,Object> subInfo = hxpUserecordMapper.selectSubInfoById(hxpStock.getSubId());
|
|
|
+ Map<String, Object> subInfo = hxpUserecordMapper.selectSubInfoById(hxpStock.getSubId());
|
|
|
String subName = "";
|
|
|
String safeUserId = "";
|
|
|
- if(subInfo != null){
|
|
|
- subName = subInfo.get("name")==null?"":String.valueOf(subInfo.get("name"));
|
|
|
- safeUserId = subInfo.get("safeUserId")==null?"":String.valueOf(subInfo.get("safeUserId"));
|
|
|
+ if (subInfo != null) {
|
|
|
+ subName = subInfo.get("name") == null ? "" : String.valueOf(subInfo.get("name"));
|
|
|
+ safeUserId = subInfo.get("safeUserId") == null ? "" : String.valueOf(subInfo.get("safeUserId"));
|
|
|
}
|
|
|
|
|
|
String terminalNum;
|
|
|
HxpAlarmRecord hxpAlarmRecord;
|
|
|
Integer dealTime = 0;
|
|
|
List<Map<String, Object>> terminalList = hxpSmartTerminalMapper.selectTerminalBySubId(8, hxpStock.getSubId());
|
|
|
- if(CollectionUtils.isEmpty(terminalList)){
|
|
|
- logger.info("实验室【"+subName+"】ID" + hxpStock.getSubId() +"未设置或启用声光报警器!");
|
|
|
- }else {
|
|
|
+ if (CollectionUtils.isEmpty(terminalList)) {
|
|
|
+ logger.info("实验室【" + subName + "】ID" + hxpStock.getSubId() + "未设置或启用声光报警器!");
|
|
|
+ } else {
|
|
|
Map<String, Object> smartTerminal = terminalList.get(0);
|
|
|
terminalNum = String.valueOf(smartTerminal.get("hardwareNum"));
|
|
|
dealTime = (Integer) smartTerminal.get("dealTime");
|
|
|
// 执行声光报警器动作触发
|
|
|
- remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id")+"") , "01");
|
|
|
+ remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id") + ""), "01");
|
|
|
isAlarm = true;
|
|
|
|
|
|
|
|
|
// 默认一个实验室只触发一个报警器
|
|
|
hxpAlarmRecord = new HxpAlarmRecord();
|
|
|
- hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+hxpStock.getChemicalName()+"), 请尽快确认!");
|
|
|
+ hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【" + subName + "】," + "化学品(" + hxpStock.getChemicalName() + "), 请尽快确认!");
|
|
|
hxpAlarmRecord.setAlarmType(2);
|
|
|
hxpAlarmRecord.setHasValid(1);
|
|
|
hxpAlarmRecord.setAlarmMode(2);
|
|
|
@@ -514,7 +527,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
|
|
|
Long recordId = hxpAlarmRecord.getId();
|
|
|
// 控制响铃时长
|
|
|
- if(smartTerminal.get("ringTime") != null){
|
|
|
+ if (smartTerminal.get("ringTime") != null) {
|
|
|
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
|
|
executorService.schedule(new Runnable() {
|
|
|
@Override
|
|
|
@@ -527,7 +540,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
hxpAlarmRecord1.setHandlingUserId(-2L);
|
|
|
hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord1);
|
|
|
|
|
|
- remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id")+"") , "00");
|
|
|
+ remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id") + ""), "00");
|
|
|
}
|
|
|
}, Long.parseLong(smartTerminal.get("ringTime") + ""), TimeUnit.SECONDS);
|
|
|
}
|
|
|
@@ -535,7 +548,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
|
|
|
|
|
|
// 报警通知演示临时通知给实验室管理员 phones
|
|
|
- Long recordId = sendPhoneAlarm(hxpStock.getId(),hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
|
|
|
+ Long recordId = sendPhoneAlarm(hxpStock.getId(), hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
|
|
|
|
|
|
cacheMap.put(rfidCode, DateUtils.getNowDate());
|
|
|
|
|
|
@@ -543,11 +556,11 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
Map<String, Object> msgData = new HashMap<>();
|
|
|
msgData.put("sendRange", 3);
|
|
|
msgData.put("messClass", -1);
|
|
|
- msgData.put("content", "系统检测到:化学品【" + hxpStock.getChemicalName() + "】,未领用被带离实验室【"+subName+"】,请您确认!");
|
|
|
+ msgData.put("content", "系统检测到:化学品【" + hxpStock.getChemicalName() + "】,未领用被带离实验室【" + subName + "】,请您确认!");
|
|
|
|
|
|
List<Map<String, Object>> userMsgList = new ArrayList<>();
|
|
|
|
|
|
- if(StringUtils.isNotBlank(safeUserId)){
|
|
|
+ if (StringUtils.isNotBlank(safeUserId)) {
|
|
|
String[] userIds = safeUserId.split(",");
|
|
|
Map<String, Object> userMsg;
|
|
|
for (String userId : userIds) {
|
|
|
@@ -563,18 +576,18 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
|
|
|
// 需求变动内容:未领用即携带化学品离开房间报警时,如实验室安全责任人通过化学品终端或PC管理后台操作处理,状态更改为已处理,报警流程终止
|
|
|
// 保证逻辑严谨,数据必须进行强关联
|
|
|
- if(recordId != null){
|
|
|
+ if (recordId != null) {
|
|
|
// 1.查询标签所属实验室院系报警配置流程处理
|
|
|
List<HxpAlarmConfig> hxpAlarmConfigList = hxpAlarmConfigMapper.selectBySubId(3, hxpStock.getSubId());
|
|
|
// 2.最多五个步骤分别执行
|
|
|
- if(CollectionUtils.isNotEmpty(hxpAlarmConfigList)){
|
|
|
- logger.info("实验室【"+subName+"】ID" + hxpStock.getSubId() +"执行用户短信通知!");
|
|
|
+ if (CollectionUtils.isNotEmpty(hxpAlarmConfigList)) {
|
|
|
+ logger.info("实验室【" + subName + "】ID" + hxpStock.getSubId() + "执行用户短信通知!");
|
|
|
|
|
|
Date date = DateUtil.offsetMinute(DateUtils.getNowDate(), Optional.ofNullable(dealTime).orElse(1));
|
|
|
|
|
|
for (HxpAlarmConfig hxpAlarmConfig : hxpAlarmConfigList) {
|
|
|
hxpAlarmRecord = new HxpAlarmRecord();
|
|
|
- hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【"+subName+"】," + "化学品("+hxpStock.getChemicalName()+"),请尽快确认!");
|
|
|
+ hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【" + subName + "】," + "化学品(" + hxpStock.getChemicalName() + "),请尽快确认!");
|
|
|
hxpAlarmRecord.setAlarmType(2);
|
|
|
hxpAlarmRecord.setAlarmMode(3);
|
|
|
hxpAlarmRecord.setHasValid(0);
|
|
|
@@ -592,7 +605,7 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
logger.error("通知升级功能异常");
|
|
|
}
|
|
|
|