|
|
@@ -8,6 +8,7 @@ import com.zd.bottle.domain.BottleStorage;
|
|
|
import com.zd.bottle.domain.RfidTag;
|
|
|
import com.zd.bottle.domain.UsegasApply;
|
|
|
import com.zd.bottle.mapper.AlarmRecordMapper;
|
|
|
+import com.zd.bottle.properties.AlarmProperties;
|
|
|
import com.zd.bottle.service.AlarmRecordService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zd.bottle.service.BottleStorageService;
|
|
|
@@ -25,6 +26,8 @@ import com.zd.system.api.alarm.domain.AlarmEntrty;
|
|
|
import com.zd.system.api.alarm.domain.Routes;
|
|
|
import com.zd.system.api.alarm.domain.SendTypes;
|
|
|
import com.zd.system.api.domain.InventoryTag;
|
|
|
+import com.zd.system.api.domain.SysFile;
|
|
|
+import com.zd.system.api.forward.RemoteForwardService;
|
|
|
import com.zd.system.api.laboratory.RemoteLaboratoryService;
|
|
|
import com.zd.system.api.laboratory.RemoteSubQueryService;
|
|
|
import com.zd.system.api.laboratory.domain.LabSubject;
|
|
|
@@ -34,6 +37,7 @@ import com.zd.system.api.netty.RemoteNettyService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
|
|
|
import org.apache.poi.util.StringUtil;
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -80,6 +84,12 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
|
|
@Resource
|
|
|
private UsegasApplyService applyService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RemoteForwardService remoteForwardService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AlarmProperties alarmProperties;
|
|
|
+
|
|
|
private static final String MSG_MATCH = "==================>{},{}";
|
|
|
|
|
|
@Override
|
|
|
@@ -127,18 +137,12 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
|
|
if (bottleStorage != null) {
|
|
|
String airName = bottleStorage.getAirName();
|
|
|
LambdaQueryWrapper<UsegasApply> lambdaQuery = Wrappers.lambdaQuery(UsegasApply.class);
|
|
|
- lambdaQuery.eq(UsegasApply::getUseGasName,airName)
|
|
|
- .ge(UsegasApply::getEndTime, DateUtil.formatDate(Calendar.getInstance().getTime())).eq(UsegasApply::getLeadAuditStaus,1);
|
|
|
+ lambdaQuery.eq(UsegasApply::getUseGasName, airName)
|
|
|
+ .ge(UsegasApply::getEndTime, DateUtil.formatDate(Calendar.getInstance().getTime())).eq(UsegasApply::getLeadAuditStaus, 1);
|
|
|
List<UsegasApply> applies = applyService.list(lambdaQuery);
|
|
|
- if (applies.isEmpty()){
|
|
|
+ if (applies.isEmpty()) {
|
|
|
Long id = bottleStorage.getId();
|
|
|
- //触发RFID警报
|
|
|
- if (hardware!=null){
|
|
|
- R<Boolean> alarm = remoteNettyService.alarm(hardware);//RFID设备报警
|
|
|
- log.info(MSG_MATCH,alarm.getCode(),alarm.getMsg());
|
|
|
- }else {
|
|
|
- log.info("==================> rfid 参数有误!"+ tag);
|
|
|
- }
|
|
|
+ R<SysFile> fileR = getFileR(tag, hardware);
|
|
|
String key = FRID_CODE + electronicTag + id;
|
|
|
String frid = redisService.getCacheObject(key);
|
|
|
if (frid != null) {
|
|
|
@@ -148,6 +152,10 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
|
|
sendAlarm(bottleStorage);
|
|
|
redisService.setCacheObject(key, electronicTag, 300L, TimeUnit.SECONDS);
|
|
|
AlarmRecord alarmRecord = new AlarmRecord();
|
|
|
+ if (fileR != null && fileR.getCode() == HttpStatus.SUCCESS && fileR.getData() != null) {
|
|
|
+ SysFile data = fileR.getData();
|
|
|
+ alarmRecord.setAttachmentUrl(data.getUrl());
|
|
|
+ }
|
|
|
alarmRecord.setElectronicTag(electronicTag)
|
|
|
.setAlarmTime(Calendar.getInstance().getTime())
|
|
|
.setMasterId(id)
|
|
|
@@ -164,6 +172,24 @@ public class AlarmRecordServiceImpl extends ServiceImpl<AlarmRecordMapper, Alarm
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ @Nullable
|
|
|
+ private R<SysFile> getFileR(InventoryTag tag, RemoteLabHardware hardware) {
|
|
|
+ //触发RFID警报
|
|
|
+ if (hardware != null) {
|
|
|
+ R<Boolean> alarm = remoteNettyService.alarm(hardware);//RFID设备报警
|
|
|
+ log.info(MSG_MATCH, alarm.getCode(), alarm.getMsg());
|
|
|
+ } else {
|
|
|
+ log.info("==================> rfid 参数有误!" + tag);
|
|
|
+ }
|
|
|
+ String streamUrl = alarmProperties.getStreamUrl();
|
|
|
+ if (StringUtils.hasLength(streamUrl)) {
|
|
|
+ R<SysFile> fileR = remoteForwardService.photograph(alarmProperties.getStreamUrl());
|
|
|
+ log.info("文件上传状态:{},接口返回消息:{},文件上传路径:{}", fileR.getCode(), fileR.getMsg(), fileR.getData());
|
|
|
+ return fileR;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
private void sendAlarm(BottleStorage storage) {
|
|
|
Long subjectId = storage.getSubjectId();
|
|
|
R<List<LabSubject>> resultList = remoteSubQueryService.listByIds(Collections.singletonList(subjectId));
|