|
|
@@ -44,7 +44,6 @@ import com.zd.model.domain.per.PerPrefix;
|
|
|
import com.zd.model.entity.HardwareRfidDto;
|
|
|
import com.zd.model.entity.InventoryTag;
|
|
|
import com.zd.system.api.entity.SysDictData;
|
|
|
-import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -59,7 +58,6 @@ import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -381,15 +379,14 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
logger.info("RFID 检测到违规触发报警: " + JSONUtil.toJsonStr(hxpStock));
|
|
|
//触发RFID警报
|
|
|
HardwareRfidDto hardwareRfidDto = tag.getHardwareRfidDto();
|
|
|
- boolean isAlarm = false;
|
|
|
- // 查询配置
|
|
|
- ResultData<WarningConfigDto> byType = remoteLaboratoryService.getByType(2);
|
|
|
- if (HttpStatus.SUCCESS != byType.getCode()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- //违规带离(1系统通知 2短信通知 3声光报警)
|
|
|
- WarningConfigDto warningConfigDto = byType.getData();
|
|
|
- String illegalRemoval = warningConfigDto.getIllegalRemoval();
|
|
|
+ // 查询配置
|
|
|
+ ResultData<WarningConfigDto> byType = remoteLaboratoryService.getByType(2);
|
|
|
+ if (HttpStatus.SUCCESS != byType.getCode()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //违规带离(1系统通知 2短信通知 3声光报警)
|
|
|
+ WarningConfigDto warningConfigDto = byType.getData();
|
|
|
+ String illegalRemoval = warningConfigDto.getIllegalRemoval();
|
|
|
|
|
|
WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
warningNoticeLogDto.setKeyId(hxpStock.getId());
|
|
|
@@ -489,130 +486,131 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // 如果非领用状态,做报警台账
|
|
|
- // 0.检测实验室声光报警器是否使用- 使用则直接调用触发- 否则跳过
|
|
|
- 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"));
|
|
|
- }
|
|
|
-
|
|
|
- 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 {
|
|
|
- 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");
|
|
|
- isAlarm = true;
|
|
|
-
|
|
|
-
|
|
|
- // 默认一个实验室只触发一个报警器
|
|
|
- hxpAlarmRecord = new HxpAlarmRecord();
|
|
|
- hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【" + subName + "】," + "化学品(" + hxpStock.getChemicalName() + "), 请尽快确认!");
|
|
|
- hxpAlarmRecord.setAlarmType(2);
|
|
|
- hxpAlarmRecord.setHasValid(1);
|
|
|
- hxpAlarmRecord.setAlarmMode(2);
|
|
|
- hxpAlarmRecord.setAlarmTime(DateUtils.getNowDate());
|
|
|
- hxpAlarmRecord.setSubId(hxpStock.getSubId());
|
|
|
- hxpAlarmRecord.setTerminalNum(terminalNum == null ? tag.getSerialNumber() : terminalNum);
|
|
|
- hxpAlarmRecord.setHandlingStatus(1);
|
|
|
- // TODO 请在此处新增图片路径字段并使用 fileR 中的返回值url作为图片路径以供前端调用,具体实现方式可参考 com.zd.bottle.service.impl.AlarmRecordServiceImpl.remoteAdd#155 行代码,默认配置为空,具体配置可参考zd-bottle-dev.yml#113行到115行
|
|
|
-
|
|
|
- hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
|
|
|
-
|
|
|
- Long recordId = hxpAlarmRecord.getId();
|
|
|
- // 控制响铃时长
|
|
|
- if (smartTerminal.get("ringTime") != null) {
|
|
|
- ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
|
|
- executorService.schedule(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 自动处理声光报警状态
|
|
|
- HxpAlarmRecord hxpAlarmRecord1 = new HxpAlarmRecord();
|
|
|
- hxpAlarmRecord1.setId(recordId);
|
|
|
- hxpAlarmRecord1.setHandlingStatus(2);
|
|
|
- hxpAlarmRecord1.setHandlingTime(DateUtils.getNowDate());
|
|
|
- hxpAlarmRecord1.setHandlingUserId(-2L);
|
|
|
- hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord1);
|
|
|
-
|
|
|
- remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id") + ""), "00");
|
|
|
- }
|
|
|
- }, Long.parseLong(smartTerminal.get("ringTime") + ""), TimeUnit.SECONDS);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 报警通知演示临时通知给实验室管理员 phones
|
|
|
- Long recordId = sendPhoneAlarm(hxpStock.getId(), hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
|
|
|
-
|
|
|
- cacheMap.put(rfidCode, DateUtils.getNowDate());
|
|
|
-
|
|
|
- // 系统通知 未领用即携带化学品离开实验室-实验室安全责任人
|
|
|
- Map<String, Object> msgData = new HashMap<>();
|
|
|
- msgData.put("sendRange", 3);
|
|
|
- msgData.put("messClass", -1);
|
|
|
- msgData.put("content", "系统检测到:化学品【" + hxpStock.getChemicalName() + "】,未领用被带离实验室【" + subName + "】,请您确认!");
|
|
|
-
|
|
|
- List<Map<String, Object>> userMsgList = new ArrayList<>();
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(safeUserId)) {
|
|
|
- String[] userIds = safeUserId.split(",");
|
|
|
- Map<String, Object> userMsg;
|
|
|
- for (String userId : userIds) {
|
|
|
- userMsg = new HashMap<>();
|
|
|
- userMsg.put("joinUserId", userId);
|
|
|
- userMsg.put("isRead", false);
|
|
|
- userMsgList.add(userMsg);
|
|
|
- }
|
|
|
- msgData.put("messageUserList", userMsgList);
|
|
|
-
|
|
|
- remoteMessageContentService.addDynamicMessage(msgData);
|
|
|
- }
|
|
|
-
|
|
|
- // 需求变动内容:未领用即携带化学品离开房间报警时,如实验室安全责任人通过化学品终端或PC管理后台操作处理,状态更改为已处理,报警流程终止
|
|
|
- // 保证逻辑严谨,数据必须进行强关联
|
|
|
- if (recordId != null) {
|
|
|
- // 1.查询标签所属实验室院系报警配置流程处理
|
|
|
- List<HxpAlarmConfig> hxpAlarmConfigList = hxpAlarmConfigMapper.selectBySubId(3, hxpStock.getSubId());
|
|
|
- // 2.最多五个步骤分别执行
|
|
|
- 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.setAlarmType(2);
|
|
|
- hxpAlarmRecord.setAlarmMode(3);
|
|
|
- hxpAlarmRecord.setHasValid(0);
|
|
|
- hxpAlarmRecord.setAlarmTime(date);
|
|
|
- hxpAlarmRecord.setSubId(hxpStock.getSubId());
|
|
|
- hxpAlarmRecord.setStockId(hxpStock.getId());
|
|
|
- hxpAlarmRecord.setParentId(recordId);
|
|
|
- //hxpAlarmRecord.setTerminalNum();
|
|
|
- hxpAlarmRecord.setHandlingStatus(1);
|
|
|
- hxpAlarmRecord.setLiableUserIds(hxpAlarmConfig.getAlarmPhone());
|
|
|
-
|
|
|
- //执行时间 - 报警时间计算
|
|
|
- date = DateUtil.offsetMinute(date, Optional.ofNullable(hxpAlarmConfig.getTimeInterval()).orElse(1));
|
|
|
- // TODO 短信阶梯通知触发流程控制
|
|
|
- hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- logger.error("通知升级功能异常");
|
|
|
- }
|
|
|
-
|
|
|
return true;
|
|
|
+// // 如果非领用状态,做报警台账
|
|
|
+// // 0.检测实验室声光报警器是否使用- 使用则直接调用触发- 否则跳过
|
|
|
+// 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"));
|
|
|
+// }
|
|
|
+//
|
|
|
+// 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 {
|
|
|
+// 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");
|
|
|
+// isAlarm = true;
|
|
|
+//
|
|
|
+//
|
|
|
+// // 默认一个实验室只触发一个报警器
|
|
|
+// hxpAlarmRecord = new HxpAlarmRecord();
|
|
|
+// hxpAlarmRecord.setAlarmContent("未领用即携带化学品离开实验室【" + subName + "】," + "化学品(" + hxpStock.getChemicalName() + "), 请尽快确认!");
|
|
|
+// hxpAlarmRecord.setAlarmType(2);
|
|
|
+// hxpAlarmRecord.setHasValid(1);
|
|
|
+// hxpAlarmRecord.setAlarmMode(2);
|
|
|
+// hxpAlarmRecord.setAlarmTime(DateUtils.getNowDate());
|
|
|
+// hxpAlarmRecord.setSubId(hxpStock.getSubId());
|
|
|
+// hxpAlarmRecord.setTerminalNum(terminalNum == null ? tag.getSerialNumber() : terminalNum);
|
|
|
+// hxpAlarmRecord.setHandlingStatus(1);
|
|
|
+// // TODO 请在此处新增图片路径字段并使用 fileR 中的返回值url作为图片路径以供前端调用,具体实现方式可参考 com.zd.bottle.service.impl.AlarmRecordServiceImpl.remoteAdd#155 行代码,默认配置为空,具体配置可参考zd-bottle-dev.yml#113行到115行
|
|
|
+//
|
|
|
+// hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
|
|
|
+//
|
|
|
+// Long recordId = hxpAlarmRecord.getId();
|
|
|
+// // 控制响铃时长
|
|
|
+// if (smartTerminal.get("ringTime") != null) {
|
|
|
+// ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
|
|
|
+// executorService.schedule(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// // 自动处理声光报警状态
|
|
|
+// HxpAlarmRecord hxpAlarmRecord1 = new HxpAlarmRecord();
|
|
|
+// hxpAlarmRecord1.setId(recordId);
|
|
|
+// hxpAlarmRecord1.setHandlingStatus(2);
|
|
|
+// hxpAlarmRecord1.setHandlingTime(DateUtils.getNowDate());
|
|
|
+// hxpAlarmRecord1.setHandlingUserId(-2L);
|
|
|
+// hxpAlarmRecordMapper.updateHxpAlarmRecord(hxpAlarmRecord1);
|
|
|
+//
|
|
|
+// remoteLaboratoryService.controlByInside(Long.parseLong(smartTerminal.get("id") + ""), "00");
|
|
|
+// }
|
|
|
+// }, Long.parseLong(smartTerminal.get("ringTime") + ""), TimeUnit.SECONDS);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// // 报警通知演示临时通知给实验室管理员 phones
|
|
|
+// Long recordId = sendPhoneAlarm(hxpStock.getId(), hxpStock.getSubId(), subName, hxpStock.getChemicalName(), subInfo.get("phones") + "");
|
|
|
+//
|
|
|
+// cacheMap.put(rfidCode, DateUtils.getNowDate());
|
|
|
+//
|
|
|
+// // 系统通知 未领用即携带化学品离开实验室-实验室安全责任人
|
|
|
+// Map<String, Object> msgData = new HashMap<>();
|
|
|
+// msgData.put("sendRange", 3);
|
|
|
+// msgData.put("messClass", -1);
|
|
|
+// msgData.put("content", "系统检测到:化学品【" + hxpStock.getChemicalName() + "】,未领用被带离实验室【" + subName + "】,请您确认!");
|
|
|
+//
|
|
|
+// List<Map<String, Object>> userMsgList = new ArrayList<>();
|
|
|
+//
|
|
|
+// if (StringUtils.isNotBlank(safeUserId)) {
|
|
|
+// String[] userIds = safeUserId.split(",");
|
|
|
+// Map<String, Object> userMsg;
|
|
|
+// for (String userId : userIds) {
|
|
|
+// userMsg = new HashMap<>();
|
|
|
+// userMsg.put("joinUserId", userId);
|
|
|
+// userMsg.put("isRead", false);
|
|
|
+// userMsgList.add(userMsg);
|
|
|
+// }
|
|
|
+// msgData.put("messageUserList", userMsgList);
|
|
|
+//
|
|
|
+// remoteMessageContentService.addDynamicMessage(msgData);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 需求变动内容:未领用即携带化学品离开房间报警时,如实验室安全责任人通过化学品终端或PC管理后台操作处理,状态更改为已处理,报警流程终止
|
|
|
+// // 保证逻辑严谨,数据必须进行强关联
|
|
|
+// if (recordId != null) {
|
|
|
+// // 1.查询标签所属实验室院系报警配置流程处理
|
|
|
+// List<HxpAlarmConfig> hxpAlarmConfigList = hxpAlarmConfigMapper.selectBySubId(3, hxpStock.getSubId());
|
|
|
+// // 2.最多五个步骤分别执行
|
|
|
+// 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.setAlarmType(2);
|
|
|
+// hxpAlarmRecord.setAlarmMode(3);
|
|
|
+// hxpAlarmRecord.setHasValid(0);
|
|
|
+// hxpAlarmRecord.setAlarmTime(date);
|
|
|
+// hxpAlarmRecord.setSubId(hxpStock.getSubId());
|
|
|
+// hxpAlarmRecord.setStockId(hxpStock.getId());
|
|
|
+// hxpAlarmRecord.setParentId(recordId);
|
|
|
+// //hxpAlarmRecord.setTerminalNum();
|
|
|
+// hxpAlarmRecord.setHandlingStatus(1);
|
|
|
+// hxpAlarmRecord.setLiableUserIds(hxpAlarmConfig.getAlarmPhone());
|
|
|
+//
|
|
|
+// //执行时间 - 报警时间计算
|
|
|
+// date = DateUtil.offsetMinute(date, Optional.ofNullable(hxpAlarmConfig.getTimeInterval()).orElse(1));
|
|
|
+// // TODO 短信阶梯通知触发流程控制
|
|
|
+// hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// logger.error("通知升级功能异常");
|
|
|
+// }
|
|
|
+
|
|
|
+// return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -929,8 +927,17 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
}
|
|
|
//违规带离(1系统通知 2短信通知 3声光报警)
|
|
|
WarningConfigDto warningConfigDto = byType.getData();
|
|
|
+ //即将过期提醒天数
|
|
|
+ Integer unexpiredWarnDays = warningConfigDto.getUnexpiredWarnDays();
|
|
|
+ // 化学品即将过期
|
|
|
+ List<HxpStockVO> unexpiredStock = hxpStockMapper.selectUnexpiredStock(unexpiredWarnDays);
|
|
|
+ // 已过期
|
|
|
+ List<HxpStockVO> expiredStock = hxpStockMapper.selectExpiredStock();
|
|
|
+ unexpired(unexpiredStock,warningConfigDto);
|
|
|
+ expired(expiredStock,warningConfigDto);
|
|
|
+
|
|
|
//化学品已过期 化学品即将过期
|
|
|
- List<HxpStock> hxpStocks = hxpStockMapper.selectHxpStockList(new HxpStock());
|
|
|
+ /*List<HxpStock> hxpStocks = hxpStockMapper.selectHxpStockList(new HxpStock());
|
|
|
Optional.ofNullable(hxpStocks).orElseGet(Collections::emptyList).forEach(hxpStock -> {
|
|
|
HxpChemicalJoinCabinet hxpChemicalJoinCabinet = hxpChemicalJoinCabinetMapper.selectHxpChemicalJoinCabinetById(hxpStock.getJoinId());
|
|
|
//过期时间
|
|
|
@@ -1056,8 +1063,151 @@ public class HxpStockServiceImpl implements IHxpStockService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ });*/
|
|
|
+ }
|
|
|
+
|
|
|
+ private void unexpired(List<HxpStockVO> unexpiredStock, WarningConfigDto warningConfigDto) {
|
|
|
+ Optional.ofNullable(unexpiredStock).orElseGet(Collections::emptyList).stream().forEach(hxpStock -> {
|
|
|
+ HxpChemicalJoinCabinet hxpChemicalJoinCabinet = hxpChemicalJoinCabinetMapper.selectHxpChemicalJoinCabinetById(hxpStock.getJoinId());
|
|
|
+ //过期时间在提醒天数内 并且在一天之内
|
|
|
+ WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
+ warningNoticeLogDto.setKeyId(hxpStock.getId());
|
|
|
+ warningNoticeLogDto.setName(hxpStock.getChemicalName());
|
|
|
+ warningNoticeLogDto.setWarningType(2);
|
|
|
+ warningNoticeLogDto.setWarningTime(LocalDateTime.now());
|
|
|
+ warningNoticeLogDto.setExpirationTime(LocalDateTimeUtil.of(hxpStock.getExpirationTime()));
|
|
|
+ warningNoticeLogDto.setMargin(hxpStock.getOutUsages());
|
|
|
+ warningNoticeLogDto.setDeposit(hxpStock.getCabinetName());
|
|
|
+ warningNoticeLogDto.setSpecification(hxpChemicalJoinCabinet.getChemicalAmount() + hxpChemicalJoinCabinet.getChemicalAmountUnit());
|
|
|
+ warningNoticeLogDto.setWarningContent("化学品即将过期");
|
|
|
+ warningNoticeLogDto.setWarningSubType(3);
|
|
|
+ warningNoticeLogDto.setWarningWay(warningConfigDto.getUnexpired());
|
|
|
+ //查询到实验室负责人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 result = remoteLaboratoryService.addWarningNoticeLog(warningNoticeLogDto);
|
|
|
+ if (HttpStatus.SUCCESS == result.getCode()) {
|
|
|
+ logger.info("即将过期保存日志成功!");
|
|
|
+ }
|
|
|
+ ResultData urlScheme = remoteMessageService.getUrlScheme(Long.valueOf(String.valueOf(result.getData())));
|
|
|
+ if (urlScheme.getCode() != HttpStatus.SUCCESS) {
|
|
|
+ logger.error("获取urlScheme失败!");
|
|
|
+ }
|
|
|
+ String systemText = "【实验室安全系统】" + warningNoticeLogDto.getSubName() + "-" + warningNoticeLogDto.getName() + "即将过期,发生时间:" + LocalDateTime.now() + ",请尽快确认。";
|
|
|
+ String text = "【实验室安全系统】" + warningNoticeLogDto.getSubName() + "-" + warningNoticeLogDto.getName() + "即将过期,发生时间:" + LocalDateTime.now() + ",请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id=" + result.getData() + "&urlScheme=" + urlScheme.getData();
|
|
|
+ //发送通知
|
|
|
+ sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getUnexpired(), systemText, text);
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ private void expired(List<HxpStockVO> expiredStock,WarningConfigDto warningConfigDto) {
|
|
|
+ Optional.ofNullable(expiredStock).orElseGet(Collections::emptyList).stream().forEach(hxpStock -> {
|
|
|
+ HxpChemicalJoinCabinet hxpChemicalJoinCabinet = hxpChemicalJoinCabinetMapper.selectHxpChemicalJoinCabinetById(hxpStock.getJoinId());
|
|
|
+ ResultData resultData = remoteLaboratoryService.getRemindData(hxpStock.getId());
|
|
|
+ if (HttpStatus.SUCCESS != resultData.getCode()) {
|
|
|
+ logger.error("获取提醒日志数据失败!");
|
|
|
+ }
|
|
|
+ List<WarningNoticeLogDto> warningNoticeLogDtos = JSON.parseArray(JSON.toJSONString(resultData.getData()), WarningNoticeLogDto.class);
|
|
|
+ //过期提醒数据
|
|
|
+ List<WarningNoticeLogDto> logDtoList = Optional.ofNullable(warningNoticeLogDtos).orElseGet(Collections::emptyList).stream().filter(i -> i.getWarningType() == 2 && i.getWarningSubType() == 4).collect(Collectors.toList());
|
|
|
+ // 过滤已过期提醒次数超过限制的化学品
|
|
|
+ if(logDtoList.size() > warningConfigDto.getExpiredWarnCount()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //过期时间在提醒天数内 并且在一天之内
|
|
|
+ WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
+ warningNoticeLogDto.setKeyId(hxpStock.getId());
|
|
|
+ warningNoticeLogDto.setName(hxpStock.getChemicalName());
|
|
|
+ warningNoticeLogDto.setWarningType(2);
|
|
|
+ warningNoticeLogDto.setWarningTime(LocalDateTime.now());
|
|
|
+ warningNoticeLogDto.setExpirationTime(LocalDateTimeUtil.of(hxpStock.getExpirationTime()));
|
|
|
+ warningNoticeLogDto.setMargin(hxpStock.getOutUsages());
|
|
|
+ warningNoticeLogDto.setDeposit(hxpStock.getCabinetName());
|
|
|
+ warningNoticeLogDto.setSpecification(hxpChemicalJoinCabinet.getChemicalAmount() + hxpChemicalJoinCabinet.getChemicalAmountUnit());
|
|
|
+ warningNoticeLogDto.setWarningContent("化学品已过期");
|
|
|
+ warningNoticeLogDto.setWarningSubType(4);
|
|
|
+ warningNoticeLogDto.setWarningWay(warningConfigDto.getExpired());
|
|
|
+ //查询到实验室负责人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 result = remoteLaboratoryService.addWarningNoticeLog(warningNoticeLogDto);
|
|
|
+ if (HttpStatus.SUCCESS == result.getCode()) {
|
|
|
+ logger.info("已过期保存日志成功!");
|
|
|
+ }
|
|
|
+ ResultData urlScheme = remoteMessageService.getUrlScheme(Long.valueOf(String.valueOf(result.getData())));
|
|
|
+ if(urlScheme.getCode() != HttpStatus.SUCCESS){
|
|
|
+ logger.error("获取urlScheme失败!");
|
|
|
+ }
|
|
|
+ String systemText = "【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getName()+"已过期,请尽快确认。";
|
|
|
+ String text = "【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-"+warningNoticeLogDto.getName()+"已过期,请尽快确认。点击查看:https://lab.zjznai.com/labAppTest/earlyWarning/index.html?id="+result.getData()+"&urlScheme="+urlScheme.getData();
|
|
|
+ //发送通知
|
|
|
+ sendNotice(hxpStock, userIdStr, phones, warningConfigDto.getExpired(), systemText, text);
|
|
|
+ });
|
|
|
+
|
|
|
+ List<Long> stockIds = expiredStock.stream().filter(i -> 1 == i.getStatus()).map(HxpStockVO::getId).collect(Collectors.toList());
|
|
|
+ List<Long> joinIds = expiredStock.stream().filter(i-> 1 == i.getStatus()).map(HxpStockVO::getJoinId).collect(Collectors.toList());
|
|
|
+ if(stockIds.size() > 0){
|
|
|
+ hxpStockMapper.updateExpiredByIds(stockIds);
|
|
|
+ }
|
|
|
+ if(joinIds.size() > 0){
|
|
|
+ hxpChemicalJoinCabinetMapper.updateExpiredByIds(joinIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendNotice(HxpStockVO hxpStock, StringBuffer userIdStr, StringBuffer phones, String expired, String systemText, String text) {
|
|
|
+ if (expired.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(systemText);
|
|
|
+ remoteMessageContentService.sendMessage(labMessageContent);
|
|
|
+ }
|
|
|
+ if (expired.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("化学品已过期发送短信打电话消息推送完成!");
|
|
|
+ logger.info("化学品已过期发送短信内容:{}", text);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 化学品超时未归还
|
|
|
* @Param []
|