Commit 7ee19c73 authored by litengwei's avatar litengwei

任务 14551

parent e4c605f2
...@@ -57,11 +57,17 @@ public enum PressurePumpEnum { ...@@ -57,11 +57,17 @@ public enum PressurePumpEnum {
this.tips = tips; this.tips = tips;
} }
public static List<PressurePumpEnum> getEnumListByCode(String code) { public static List<PressurePumpEnum> getEnumListByCode(String value) {
List<PressurePumpEnum> list = new ArrayList<>(); List<PressurePumpEnum> list = new ArrayList<>();
for(PressurePumpEnum e : PressurePumpEnum.values()) { for(PressurePumpEnum e : PressurePumpEnum.values()) {
if (e.getCode().startsWith(code)) { if (value.equals("true")) {
list.add(e); if (e.getCode().startsWith("FHS_PressurePump_Stop")) {
list.add(e);
}
} else {
if (e.getCode().startsWith("FHS_PressurePump_Start")) {
list.add(e);
}
} }
} }
return list; return list;
......
...@@ -48,7 +48,7 @@ public interface IotFeign { ...@@ -48,7 +48,7 @@ public interface IotFeign {
@RequestParam(value = "top") String top, @RequestParam(value = "top") String top,
@RequestParam(value = "productKey") String productKey, @RequestParam(value = "productKey") String productKey,
@RequestParam(value = "deviceName") String deviceName, @RequestParam(value = "deviceName") String deviceName,
@RequestParam("FHS_FirePump_RunStatus") String key, @RequestParam("FHS_PressurePump_Start") String key,
@RequestParam(required = false, value = "fieldKey") String fieldKey); @RequestParam(required = false, value = "fieldKey") String fieldKey);
......
...@@ -19,6 +19,7 @@ import com.yeejoin.equipmanage.common.utils.DateUtils; ...@@ -19,6 +19,7 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.utils.UUIDUtils; import com.yeejoin.equipmanage.common.utils.UUIDUtils;
import com.yeejoin.equipmanage.common.vo.*; import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.fegin.SystemctlFeign; import com.yeejoin.equipmanage.fegin.SystemctlFeign;
import com.yeejoin.equipmanage.mapper.*; import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.quartz.PumpSendMessage; import com.yeejoin.equipmanage.quartz.PumpSendMessage;
...@@ -41,7 +42,10 @@ import org.springframework.util.CollectionUtils; ...@@ -41,7 +42,10 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -101,6 +105,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -101,6 +105,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
EquipmentSpecificIndexMapper equipmentSpecificIndexMapper; EquipmentSpecificIndexMapper equipmentSpecificIndexMapper;
@Autowired @Autowired
private IotFeign iotFeign;
@Autowired
MarqueeDataMapper marqueeDataMapper; MarqueeDataMapper marqueeDataMapper;
//消防泵 //消防泵
@Value("${equipment.plan.pump}") @Value("${equipment.plan.pump}")
...@@ -364,9 +371,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -364,9 +371,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
iotDataListToCacheMap(iotDatalist); iotDataListToCacheMap(iotDatalist);
iotDatalist.forEach(iotDataVO -> { iotDatalist.forEach(iotDataVO -> {
String indexKey = iotDataVO.getKey(); String indexKey = iotDataVO.getKey();
String indexValue = iotDataVO.getValue().toString();
// 稳压泵启停信号处理 // 稳压泵启停信号处理
if (indexKey.equals(pressurePumpStart) || indexKey.equals(pressurePumpStop)) { if (indexKey.equals(pressurePumpStart)) {
pressurePump(indexKey, iotDatalist, topicEntity); pressurePump(indexKey,indexValue, iotDatalist, topicEntity);
} }
for (EquipmentSpecificIndex equipmentSpecificIndex : indexList) { for (EquipmentSpecificIndex equipmentSpecificIndex : indexList) {
if (!ObjectUtils.isEmpty(equipmentSpecificIndex.getNameKey()) if (!ObjectUtils.isEmpty(equipmentSpecificIndex.getNameKey())
...@@ -1489,13 +1497,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1489,13 +1497,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
} }
private void pressurePump(String indexKey, List<IotDataVO> iotDatalist, TopicEntityVo topicEntity) { private void pressurePump(String indexKey, String indexValue, List<IotDataVO> iotDatalist, TopicEntityVo topicEntity) {
List<String> listIndex = new ArrayList<>(); List<String> listIndex = new ArrayList<>();
listIndex.add(pressurePumpStart); listIndex.add(pressurePumpStart);
listIndex.add(pressurePumpStop);
// 获取全部启停泵信号 // 获取全部启停泵信号
List<EquipmentSpecificIndex> equipmentSpeIndexList = equipmentSpecificIndexService.getEquipmentSpeIndexByIndex(listIndex); List<EquipmentSpecificIndex> equipmentSpeIndexList = equipmentSpecificIndexService.getEquipmentSpeIndexByIndex(listIndex);
List<PressurePumpEnum> enumListByCode = PressurePumpEnum.getEnumListByCode(indexKey); List<PressurePumpEnum> enumListByCode = PressurePumpEnum.getEnumListByCode(indexValue);
if (!CollectionUtils.isEmpty(enumListByCode)) { if (!CollectionUtils.isEmpty(enumListByCode)) {
enumListByCode.forEach(pressurePumpEnum -> { enumListByCode.forEach(pressurePumpEnum -> {
...@@ -1516,15 +1523,23 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1516,15 +1523,23 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private EquipmentSpecificIndex getPressurePumpDateByType(String indexKey, PressurePumpValueEnum valueEnum, TopicEntityVo topicEntity, List<EquipmentSpecificIndex> equipmentSpeIndexList, PressurePumpEnum pressurePumpEnum) { private EquipmentSpecificIndex getPressurePumpDateByType(String indexKey, PressurePumpValueEnum valueEnum, TopicEntityVo topicEntity, List<EquipmentSpecificIndex> equipmentSpeIndexList, PressurePumpEnum pressurePumpEnum) {
String iotCode = topicEntity.getIotCode(); String iotCode = topicEntity.getIotCode();
EquipmentSpecificIndex equipmentSpecificIndex = null; EquipmentSpecificIndex equipmentSpecificIndex = null;
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码错误,请确认!");
}
String jobName = topicEntity.getIotCode()+"_"+indexKey; String jobName = topicEntity.getIotCode()+"_"+indexKey;
String triggerName = PUMP_TRIGGER_NAME+"-"+topicEntity.getIotCode(); String triggerName = PUMP_TRIGGER_NAME+"-"+topicEntity.getIotCode();
switch (valueEnum) { switch (valueEnum) {
case LAST_STOP: case LAST_STOP:
List<EquipmentSpecificIndex> lastStop = equipmentSpeIndexList.stream().filter(e -> List<EquipmentSpecificIndex> lastStop = equipmentSpeIndexList.stream().filter(e ->
StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStop.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(lastStop)) { if (!CollectionUtils.isEmpty(lastStop)) {
equipmentSpecificIndex = lastStop.get(0); getIotDate(equipmentSpecificIndex, lastStop, prefix, suffix , "false");
} }
break; break;
case LAST_START: case LAST_START:
...@@ -1538,15 +1553,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1538,15 +1553,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && e.getIotCode().equals(iotCode) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(lastStart)) { if (!CollectionUtils.isEmpty(lastStart)) {
equipmentSpecificIndex = lastStart.get(0); getIotDate(equipmentSpecificIndex, lastStart, prefix, suffix, "true");
} }
break; break;
case LATELY_STOP: case LATELY_STOP:
List<EquipmentSpecificIndex> latelyStop = equipmentSpeIndexList.stream().filter(e -> List<EquipmentSpecificIndex> latelyStop = equipmentSpeIndexList.stream().filter(e ->
StringUtil.isNotEmpty(e.getValue()) && pressurePumpStop.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(latelyStop)) { if (!CollectionUtils.isEmpty(latelyStop)) {
equipmentSpecificIndex = latelyStop.get(0); getIotDate(equipmentSpecificIndex, latelyStop, prefix, null, "false");
} }
break; break;
case LATELY_START: case LATELY_START:
...@@ -1554,7 +1569,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1554,7 +1569,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed()) StringUtil.isNotEmpty(e.getValue()) && pressurePumpStart.equals(e.getEquipmentIndexKey())).sorted(Comparator.comparing(EquipmentSpecificIndex::getUpdateDate).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!CollectionUtils.isEmpty(latelyStart)) { if (!CollectionUtils.isEmpty(latelyStart)) {
equipmentSpecificIndex = latelyStart.get(0); getIotDate(equipmentSpecificIndex, latelyStart, prefix, null, "true");
} }
break; break;
case PUMP_START_TIME: case PUMP_START_TIME:
...@@ -1566,6 +1581,21 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1566,6 +1581,21 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return equipmentSpecificIndex; return equipmentSpecificIndex;
} }
private void getIotDate(EquipmentSpecificIndex equipmentSpecificIndex, List<EquipmentSpecificIndex> listData, String prefix, String suffix, String flag) {
ResponseModel start = iotFeign.selectOne(remoteSecurityService.getServerToken().getAppKey(), remoteSecurityService.getServerToken().getProduct(), remoteSecurityService.getServerToken().getToke(), "1", prefix, suffix, flag, pressurePumpStart);
if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult());
List<Map<String, String>> listObject1 = (List<Map<String, String>>) JSONArray.parse(json1);
List<Map<String, String>> collect = listObject1.stream().filter(t -> (t.containsKey("time"))).collect(Collectors.toList());
String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
listData.get(0).setUpdateDate(startDate);
equipmentSpecificIndex = listData.get(0);
}
}
private void checkValueByDate(EquipmentSpecificIndex data, Date newDate, PressurePumpEnum pressurePumpEnum) { private void checkValueByDate(EquipmentSpecificIndex data, Date newDate, PressurePumpEnum pressurePumpEnum) {
String operator = pressurePumpEnum.getOperator(); String operator = pressurePumpEnum.getOperator();
PressurePumpCheckEnum pumpCheckEnum = PressurePumpCheckEnum.getByCode(operator); PressurePumpCheckEnum pumpCheckEnum = PressurePumpCheckEnum.getByCode(operator);
...@@ -1695,8 +1725,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1695,8 +1725,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
cron = pressurePumpEnum.getLeftValue(); cron = pressurePumpEnum.getLeftValue();
} }
EquipmentSpecific equipmentSpecific = null; EquipmentSpecific equipmentSpecific = null;
try { try {
LambdaQueryWrapper<EquipmentSpecific> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EquipmentSpecific> wrapper = new LambdaQueryWrapper<>();
......
...@@ -115,7 +115,7 @@ equipment.scrap.day=30 ...@@ -115,7 +115,7 @@ equipment.scrap.day=30
equipment.scrap.cron=0 0 9 * * ? equipment.scrap.cron=0 0 9 * * ?
# 稳压泵启动信号 # 稳压泵启动信号
equipment.pressurepump.start=FHS_FirePump_RunStatus equipment.pressurepump.start=FHS_PressurePump_Start
# 稳压泵停止信号 # 稳压泵停止信号
equipment.pressurepump.stop=FHS_PressurePump_Stop equipment.pressurepump.stop=FHS_PressurePump_Stop
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment