|
@@ -6,7 +6,9 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.zd.airbottle.domain.AlarmRecord;
|
|
import com.zd.airbottle.domain.AlarmRecord;
|
|
|
|
|
+import com.zd.airbottle.domain.DbStock;
|
|
|
import com.zd.airbottle.domain.QpAirBottle;
|
|
import com.zd.airbottle.domain.QpAirBottle;
|
|
|
import com.zd.airbottle.domain.QpUseRecord;
|
|
import com.zd.airbottle.domain.QpUseRecord;
|
|
|
import com.zd.airbottle.domain.vo.*;
|
|
import com.zd.airbottle.domain.vo.*;
|
|
@@ -109,6 +111,9 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private RedisTemplate<String, HardwareRfid> redisTemplate;
|
|
private RedisTemplate<String, HardwareRfid> redisTemplate;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DbStockService dbStockService;
|
|
|
|
|
+
|
|
|
private static final String RFID_CODE = "RFID:";
|
|
private static final String RFID_CODE = "RFID:";
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -438,6 +443,131 @@ public class AlarmRecordServiceImpl implements IAlarmRecordService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public Integer beaconAdd(Map <String, String> tagMap) {
|
|
|
|
|
+ //根据信标查询库存信息
|
|
|
|
|
+ String beaconTag = tagMap.get("beaconTag");
|
|
|
|
|
+ LambdaQueryWrapper<DbStock> queryWrapper = new LambdaQueryWrapper();
|
|
|
|
|
+ queryWrapper.eq(DbStock::getBeaconTag, beaconTag);
|
|
|
|
|
+ DbStock dbStock = dbStockService.getOne(queryWrapper);
|
|
|
|
|
+ // 查询配置
|
|
|
|
|
+ ResultData<WarningConfigDto> byType = laboratoryService.getByType(3);
|
|
|
|
|
+ if (HttpStatus.SUCCESS != byType.getCode()) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ //违规带离(1系统通知 2短信通知 3声光报警)
|
|
|
|
|
+ WarningConfigDto warningConfigDto = byType.getData();
|
|
|
|
|
+ String illegalRemoval = warningConfigDto.getIllegalRemoval();
|
|
|
|
|
+
|
|
|
|
|
+ WarningNoticeLogDto warningNoticeLogDto = new WarningNoticeLogDto();
|
|
|
|
|
+ warningNoticeLogDto.setKeyId(dbStock.getId());
|
|
|
|
|
+ warningNoticeLogDto.setName(dbStock.getGasName());
|
|
|
|
|
+ warningNoticeLogDto.setWarningType(3);
|
|
|
|
|
+ warningNoticeLogDto.setWarningSubType(1);
|
|
|
|
|
+ warningNoticeLogDto.setWarningContent("气瓶违规带离");
|
|
|
|
|
+ warningNoticeLogDto.setWarningTime(LocalDateTime.now());
|
|
|
|
|
+ warningNoticeLogDto.setWarningWay(illegalRemoval);
|
|
|
|
|
+// warningNoticeLogDto.setHolder(storageRVo.getOwner());
|
|
|
|
|
+// warningNoticeLogDto.setDeposit(storageRVo.getLocation());
|
|
|
|
|
+ warningNoticeLogDto.setMargin(new BigDecimal(dbStock.getGasPressure()));
|
|
|
|
|
+ warningNoticeLogDto.setSpecification(dbStock.getSize()+"");
|
|
|
|
|
+ warningNoticeLogDto.setEntryTime(LocalDateTimeUtil.of(dbStock.getCreateTime()));
|
|
|
|
|
+
|
|
|
|
|
+ //查询到实验室负责人id 安全责任人id
|
|
|
|
|
+ ResultData<List<CheckSubjectDto>> subjectInfoList = laboratoryService.findSubjectInfoList(String.valueOf(dbStock.getSubjectId()));
|
|
|
|
|
+ StringBuffer userIds = 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());
|
|
|
|
|
+ userIds.append(i.getSafeUserId()).append(",").append(i.getAdminId());
|
|
|
|
|
+ phones.append(i.getAdminPhone()).append(",").append(i.getSafeUserPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ ResultData resultData = laboratoryService.addWarningNoticeLog(warningNoticeLogDto);
|
|
|
|
|
+ if (HttpStatus.SUCCESS != resultData.getCode()) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long logId = (Long) resultData.getData();
|
|
|
|
|
+
|
|
|
|
|
+ //rfid门禁机报警
|
|
|
|
|
+// R<Boolean> alarm = remoteRfidService.alarm(hardwareRfidDto);
|
|
|
|
|
+// log.info("==================>{},{}",alarm.getCode(),alarm.getMsg());
|
|
|
|
|
+
|
|
|
|
|
+ //摄像头录像
|
|
|
|
|
+// ResultData<LabHardwareDto> cameraHardware = remoteLabHardwareService.findHardwareByType(storageRVo.getSubjectId(), 4, null, "2");
|
|
|
|
|
+// if (HttpStatus.SUCCESS == cameraHardware.getCode()) {
|
|
|
|
|
+// String ip = String.valueOf(cameraHardware.getData().getIpAddress());
|
|
|
|
|
+// startVideo(ip);
|
|
|
|
|
+// scheduledExecutorService.schedule(new TimerTask() {
|
|
|
|
|
+// @Override
|
|
|
|
|
+// public void run() {
|
|
|
|
|
+// stopVideo(ip, logId);
|
|
|
|
|
+// }
|
|
|
|
|
+// }, 30, TimeUnit.SECONDS);
|
|
|
|
|
+// }
|
|
|
|
|
+ //按照配置预警
|
|
|
|
|
+ if (illegalRemoval != null) {
|
|
|
|
|
+ String text = "【实验室安全系统】"+warningNoticeLogDto.getSubName()+"-实验人员违规携带"+warningNoticeLogDto.getName()+"气瓶离开房间,发生时间:" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss") + ",请尽快确认。";
|
|
|
|
|
+
|
|
|
|
|
+ //系统通知
|
|
|
|
|
+ if (illegalRemoval.contains("1")) {
|
|
|
|
|
+ LabMessageContent labMessageContent = new LabMessageContent();
|
|
|
|
|
+ labMessageContent.setSendMode(2);
|
|
|
|
|
+ labMessageContent.setSendRange(3);
|
|
|
|
|
+ labMessageContent.setMessClass(1);
|
|
|
|
|
+ labMessageContent.setMessType(13);
|
|
|
|
|
+ labMessageContent.setSubIds(String.valueOf(dbStock.getSubjectId()));
|
|
|
|
|
+ labMessageContent.setUserIds(userIds.toString());
|
|
|
|
|
+ labMessageContent.setContent(text);
|
|
|
|
|
+ remoteMessageContentService.sendMessage(labMessageContent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //短信通知
|
|
|
|
|
+ if (illegalRemoval.contains("2")) {
|
|
|
|
|
+ String[] strings = Stream.of(phones.toString().split(",")).filter(a -> StrUtil.isNotBlank(a)).collect(Collectors.joining(",")).split(",");
|
|
|
|
|
+ if (strings != null) {
|
|
|
|
|
+ //获取人员电话信息
|
|
|
|
|
+ ResultData<List<UserPhoneInfo>> listResultData = laboratoryService.selectAdminAndSafeAdminById(warningNoticeLogDto.getSubId());
|
|
|
|
|
+ if(HttpStatus.SUCCESS != listResultData.getCode()){
|
|
|
|
|
+ log.info("获取实验室管理员和安全员信息失败!{}",JSON.toJSONString(listResultData));
|
|
|
|
|
+ }
|
|
|
|
|
+ List<UserPhoneInfo> userPhoneInfoList = listResultData.getData();
|
|
|
|
|
+ AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, SendTypes.SMS.toString(), text);
|
|
|
|
|
+ alarmEntrty.setLogId(logId);
|
|
|
|
|
+ alarmEntrty.setUserPhoneInfo(userPhoneInfoList);
|
|
|
|
|
+ remoteAlarmService.send(alarmEntrty);
|
|
|
|
|
+ log.info("气瓶发送短信打电话消息推送完成!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //声光报警
|
|
|
|
|
+ if (illegalRemoval.contains("3")) {
|
|
|
|
|
+ ResultData<LabHardwareDto> hardwareByType = remoteLabHardwareService.findHardwareByType(dbStock.getSubjectId(), 8, null, null);
|
|
|
|
|
+ if (HttpStatus.SUCCESS == hardwareByType.getCode()) {
|
|
|
|
|
+ warningNoticeLogDto.setId(logId);
|
|
|
|
|
+ warningNoticeLogDto.setVoiceBroadcast(1);
|
|
|
|
|
+ laboratoryService.updateWarningNoticeLog(warningNoticeLogDto);
|
|
|
|
|
+ Long id = hardwareByType.getData().getId();
|
|
|
|
|
+ laboratoryService.controlDevice(id, 1);
|
|
|
|
|
+ scheduledExecutorService.schedule(new TimerTask() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ laboratoryService.controlDevice(id, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public List<BottleStorageInfoVo> setMasterIds(AlarmRecord alarmRecord) {
|
|
public List<BottleStorageInfoVo> setMasterIds(AlarmRecord alarmRecord) {
|
|
|
if (!StringUtils.isEmpty(alarmRecord.getSearchValue())) {
|
|
if (!StringUtils.isEmpty(alarmRecord.getSearchValue())) {
|
|
|
BottleStorageInfoVo storageInfoVo = new BottleStorageInfoVo();
|
|
BottleStorageInfoVo storageInfoVo = new BottleStorageInfoVo();
|