Commit b646432f authored by 刘林's avatar 刘林

fix(equip):解析交换站下发数据,更新指标状态

parent e3b525d3
...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.entity.publics.BaseEntity; ...@@ -6,6 +6,7 @@ import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
...@@ -15,6 +16,7 @@ import java.util.Date; ...@@ -15,6 +16,7 @@ import java.util.Date;
* @since v2.0 * @since v2.0
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true)
@TableName("wl_equipment_specific_index") @TableName("wl_equipment_specific_index")
@ApiModel(value = "EquipmentSpecificIndex对象", description = "性能指标参数") @ApiModel(value = "EquipmentSpecificIndex对象", description = "性能指标参数")
public class EquipmentSpecificIndex extends BaseEntity { public class EquipmentSpecificIndex extends BaseEntity {
...@@ -126,9 +128,6 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -126,9 +128,6 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String alamReason; private String alamReason;
@TableField(exist = false)
private String valueEnum;
@ApiModelProperty(value = "设备CODE") @ApiModelProperty(value = "设备CODE")
@TableField(exist = false) @TableField(exist = false)
private String equipmentSpecificCode; private String equipmentSpecificCode;
...@@ -182,4 +181,26 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -182,4 +181,26 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(value = "unit") @TableField(value = "unit")
private String unit; private String unit;
@ApiModelProperty(value = "信号的索引键key,用于唯一索引信号")
@TableField(value = "index_address")
private String indexAddress;
@ApiModelProperty(value = "品质,0为有效,1为无效")
@TableField(value = "quality")
private String quality;
@ApiModelProperty(value = "测点类型,analog/state")
@TableField(value = "data_type")
private String dataType;
@ApiModelProperty(value = "时间")
@TableField(value = "time_stamp")
private String timeStamp;
/**
* 指标值枚举
*/
@ApiModelProperty(value = "指标值枚举")
@TableField("value_enum")
private String valueEnum;
} }
...@@ -124,6 +124,7 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -124,6 +124,7 @@ public class EquipmentIotMqttReceiveConfig {
list.addAll(ConfigPageTopicEnum.getEnumTopicList()); //大屏数据推送接口订阅 list.addAll(ConfigPageTopicEnum.getEnumTopicList()); //大屏数据推送接口订阅
list.add("+/+/property"); // 添加iot車輛裝備數據上報事件监听 list.add("+/+/property"); // 添加iot車輛裝備數據上報事件监听
list.add("+/+/event"); // 添加iot事件监听 list.add("+/+/event"); // 添加iot事件监听
list.add("+/+/transmit"); // 添加交换站事件监听
String[] arr = list.toArray(new String[list.size()]); String[] arr = list.toArray(new String[list.size()]);
adapter = new MqttPahoMessageDrivenChannelAdapter(clientId + "_inbound", mqttPahoClientFactory(), arr); adapter = new MqttPahoMessageDrivenChannelAdapter(clientId + "_inbound", mqttPahoClientFactory(), arr);
adapter.setCompletionTimeout(completionTimeout); adapter.setCompletionTimeout(completionTimeout);
...@@ -147,6 +148,8 @@ public class EquipmentIotMqttReceiveConfig { ...@@ -147,6 +148,8 @@ public class EquipmentIotMqttReceiveConfig {
mqttReceiveService.handlerMqttIncrementMessage(topic, msg); mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
} else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) { } else if (dataType.equals("event") && StringUtil.isNotEmpty(msg)) {
mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg); mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg);
}else if (dataType.equals("transmit") && StringUtil.isNotEmpty(msg)){
mqttReceiveService.handlerMqttRomaMessage(topic,msg);
} }
} }
}; };
......
...@@ -199,6 +199,7 @@ public class EquipmentIndexController { ...@@ -199,6 +199,7 @@ public class EquipmentIndexController {
for (EquipmentSpecificIndex y : indexList) { for (EquipmentSpecificIndex y : indexList) {
y.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId()); y.setEquipmentIndexKey(equipmentIndex.getPerfQuotaDefinitionId());
y.setEquipmentIndexName(equipmentIndex.getPerfQuotaName()); y.setEquipmentIndexName(equipmentIndex.getPerfQuotaName());
y.setValueEnum(equipmentIndex.getValueEnum());
if (bool.get() && !ObjectUtils.isEmpty(signalClassify)) { if (bool.get() && !ObjectUtils.isEmpty(signalClassify)) {
y.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor()); y.setEmergencyLevelColor(signalClassify.getEmergencyLevelColor());
y.setIsAlarm(signalClassify.getIsAlarm()); y.setIsAlarm(signalClassify.getIsAlarm());
......
...@@ -113,4 +113,6 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif ...@@ -113,4 +113,6 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
List<Map<String, Object>> getEquipSpecificScrap(); List<Map<String, Object>> getEquipSpecificScrap();
List<EquipmentSpecificIndex> getEquipIndexInIndex(@Param("list") List<String> listIndex); List<EquipmentSpecificIndex> getEquipIndexInIndex(@Param("list") List<String> listIndex);
EquipmentSpecificIndex getEquipmentSpeIndexByIndexAddress(String indexAddress);
} }
...@@ -34,4 +34,11 @@ public interface IEquipmentSpecificIndexService extends IService<EquipmentSpecif ...@@ -34,4 +34,11 @@ public interface IEquipmentSpecificIndexService extends IService<EquipmentSpecif
* @return 列表 * @return 列表
*/ */
List<EquipmentSpecificIndex> getEquipmentSpeIndexByIndex(List<String> listIndex); List<EquipmentSpecificIndex> getEquipmentSpeIndexByIndex(List<String> listIndex);
/**
* 根据信号索引查询装备性能指标
* @param indexAddress indexAddress
* @return EquipmentSpecificIndex
*/
EquipmentSpecificIndex getEquipmentSpeIndexByIndexAddress(String indexAddress);
} }
...@@ -17,4 +17,11 @@ public interface MqttReceiveService { ...@@ -17,4 +17,11 @@ public interface MqttReceiveService {
* @param message 消息内容 * @param message 消息内容
*/ */
void handlerMqttIncrementMessage(String topic, String message); void handlerMqttIncrementMessage(String topic, String message);
/**
* 处理交换站消息数据
* @param topic 主题
* @param message 消息内容
*/
void handlerMqttRomaMessage(String topic, String message);
} }
...@@ -28,4 +28,9 @@ public class EquipmentSpecificIndexServiceImpl extends ServiceImpl<EquipmentSpec ...@@ -28,4 +28,9 @@ public class EquipmentSpecificIndexServiceImpl extends ServiceImpl<EquipmentSpec
public List<EquipmentSpecificIndex> getEquipmentSpeIndexByIndex(List<String> listIndex) { public List<EquipmentSpecificIndex> getEquipmentSpeIndexByIndex(List<String> listIndex) {
return this.baseMapper.getEquipIndexInIndex(listIndex); return this.baseMapper.getEquipIndexInIndex(listIndex);
} }
@Override
public EquipmentSpecificIndex getEquipmentSpeIndexByIndexAddress(String indexAddress) {
return this.baseMapper.getEquipmentSpeIndexByIndexAddress(indexAddress);
}
} }
...@@ -1598,6 +1598,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1598,6 +1598,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
equipmentSpecificIndex.setEmergencyLevel(index.getEmergencyLevel()); equipmentSpecificIndex.setEmergencyLevel(index.getEmergencyLevel());
equipmentSpecificIndex.setEmergencyLevelDescribe(index.getEmergencyLevelDescribe()); equipmentSpecificIndex.setEmergencyLevelDescribe(index.getEmergencyLevelDescribe());
equipmentSpecificIndex.setUnit(index.getUnit()); equipmentSpecificIndex.setUnit(index.getUnit());
equipmentSpecificIndex.setValueEnum(index.getValueEnum());
equipmentSpecificIndices.add(equipmentSpecificIndex); equipmentSpecificIndices.add(equipmentSpecificIndex);
}); });
} }
......
...@@ -72,8 +72,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -72,8 +72,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private static Map<String, TemperatureAlarmDto> temperatureMap = new HashMap<>(); private static Map<String, TemperatureAlarmDto> temperatureMap = new HashMap<>();
static IEquipmentSpecificIndexService equipmentSpecificIndexService; static IEquipmentSpecificIndexService equipmentSpecificIndexService;
@Autowired @Autowired
public void setEquipmentSpecificIndexService(IEquipmentSpecificIndexService equipmentSpecificIndexService){ public void setEquipmentSpecificIndexService(IEquipmentSpecificIndexService equipmentSpecificIndexService) {
MqttReceiveServiceImpl.equipmentSpecificIndexService = equipmentSpecificIndexService; MqttReceiveServiceImpl.equipmentSpecificIndexService = equipmentSpecificIndexService;
} }
...@@ -136,8 +137,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -136,8 +137,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
static EquipmentSpecificMapper equipmentSpecificMapper; static EquipmentSpecificMapper equipmentSpecificMapper;
@Autowired @Autowired
public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper){ public void setEquipmentSpecificMapper(EquipmentSpecificMapper equipmentSpecificMapper) {
MqttReceiveServiceImpl.equipmentSpecificMapper = equipmentSpecificMapper; MqttReceiveServiceImpl.equipmentSpecificMapper = equipmentSpecificMapper;
} }
...@@ -145,15 +147,17 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -145,15 +147,17 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
FireFightingSystemMapper FireFightingSystemMapper; FireFightingSystemMapper FireFightingSystemMapper;
static IFireFightingSystemService fireFightingSystemService; static IFireFightingSystemService fireFightingSystemService;
@Autowired @Autowired
public void setFireFightingSystemService(IFireFightingSystemService fireFightingSystemService){ public void setFireFightingSystemService(IFireFightingSystemService fireFightingSystemService) {
MqttReceiveServiceImpl.fireFightingSystemService = fireFightingSystemService; MqttReceiveServiceImpl.fireFightingSystemService = fireFightingSystemService;
} }
static MqttSendGateway mqttSendGateway; static MqttSendGateway mqttSendGateway;
@Autowired @Autowired
public void setMqttSendGateway(MqttSendGateway mqttSendGateway){ public void setMqttSendGateway(MqttSendGateway mqttSendGateway) {
MqttReceiveServiceImpl.mqttSendGateway = mqttSendGateway; MqttReceiveServiceImpl.mqttSendGateway = mqttSendGateway;
} }
...@@ -182,8 +186,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -182,8 +186,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private SystemctlFeign systemctlFeign; private SystemctlFeign systemctlFeign;
private static RemoteSecurityService remoteSecurityService; private static RemoteSecurityService remoteSecurityService;
@Autowired @Autowired
public void setRemoteSecurityService(RemoteSecurityService remoteSecurityService){ public void setRemoteSecurityService(RemoteSecurityService remoteSecurityService) {
MqttReceiveServiceImpl.remoteSecurityService = remoteSecurityService; MqttReceiveServiceImpl.remoteSecurityService = remoteSecurityService;
} }
...@@ -214,8 +219,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -214,8 +219,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private String carTopic; private String carTopic;
private static String canvasTopic; private static String canvasTopic;
@Value("${equip.point.equipmentdata.topic}") @Value("${equip.point.equipmentdata.topic}")
public void setCanvasTopic(String canvasTopic){ public void setCanvasTopic(String canvasTopic) {
MqttReceiveServiceImpl.canvasTopic = canvasTopic; MqttReceiveServiceImpl.canvasTopic = canvasTopic;
} }
...@@ -241,8 +247,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -241,8 +247,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private Boolean isOpenTelemetering; private Boolean isOpenTelemetering;
private static Boolean jcsSwitch; private static Boolean jcsSwitch;
@Value("${systemctl.jcs.switch}") @Value("${systemctl.jcs.switch}")
public void setJcsSwitch(Boolean jcsSwitch){ public void setJcsSwitch(Boolean jcsSwitch) {
MqttReceiveServiceImpl.jcsSwitch = jcsSwitch; MqttReceiveServiceImpl.jcsSwitch = jcsSwitch;
} }
...@@ -310,10 +317,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -310,10 +317,10 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 发送emq消息转kafka // 发送emq消息转kafka
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("topic", topic); jsonObject.put("topic", topic);
jsonObject.put("data",message); jsonObject.put("data", message);
try { try {
emqKeeper.getMqttClient().publish("emq.iot.created",jsonObject.toString().getBytes(),1,false); emqKeeper.getMqttClient().publish("emq.iot.created", jsonObject.toString().getBytes(), 1, false);
} catch (MqttException e) { } catch (MqttException e) {
log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage())); log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage()));
} }
...@@ -326,8 +333,259 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -326,8 +333,259 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
realTimeDateProcessing(topicEntity, collect, vo); realTimeDateProcessing(topicEntity, collect, vo);
} else { } else {
realTimeDateProcessing(topicEntity, iotDatalist,vo); realTimeDateProcessing(topicEntity, iotDatalist, vo);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void handlerMqttRomaMessage(String topic, String message) {
TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity.setTopic(topic);
topicEntity.setMessage(message);
List<IotDataVO> iotDatalist = new ArrayList<>();
List<EquipmentSpecificIndex> equipmentSpecificIndexList = new ArrayList<>();
List<EquipmentSpecificAlarm> equipmentSpecificAlarms = new ArrayList<>();
List<IndexStateVo> indexStateList = new ArrayList<>();
JSONObject jsonObject = JSONObject.parseObject(message);
String dataType = jsonObject.getString("datatype");
String indexAddress = dataType != null ? jsonObject.getString("key") : jsonObject.getString("scadaid");
String quality = jsonObject.getString("quality");
String value = jsonObject.getInteger("value") ==1 ? "true":"false";
String timeStamp = dataType != null ? jsonObject.getString("time_stamp") : jsonObject.getString("timestamp");
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress);
if (equipmentSpeIndex == null){
return;
}
equipmentSpeIndex.setValue(value);
equipmentSpeIndex.setValueLabel(valueTranslate(value, equipmentSpeIndex.getValueEnum()));
equipmentSpeIndex.setEquipmentType(topicEntity.getType());
equipmentSpeIndex.setUpdateDate(new Date());
equipmentSpeIndex.setQuality(quality);
equipmentSpeIndex.setDataType(dataType);
equipmentSpeIndex.setTimeStamp(timeStamp);
equipmentSpeIndex.setUUID(UUIDUtils.getUUID());
IotDataVO iotDataVO = new IotDataVO();
iotDataVO.setKey(equipmentSpeIndex.getNameKey());
iotDataVO.setValue(value);
iotDatalist.add(iotDataVO);
// iEquipmentSpecificSerivce.getEquipSpecificDetailsByEquipmentId(equipmentSpeIndex.getEquipmentSpecificId());
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", equipmentSpeIndex.getEquipmentSpecificId());
EquipmentSpecific equipmentSpecific = iEquipmentSpecificSerivce.getOne(queryWrapper);
if (equipmentSpecific == null) {
return;
}
String iotCode = equipmentSpecific.getIotCode();
List<EquipmentSpecificVo> eqIotCodeList = iEquipmentSpecificSerivce.getEquipAndCarIotcodeByIotcode(iotCode);
if (eqIotCodeList.isEmpty()) {
log.info("该数据{}不存在!", iotCode);
return;
}
if (eqIotCodeList.size() > 1) {
log.info("有重复的{}数据!", iotCode);
}
EquipmentSpecificVo equipmentSpecificVo = eqIotCodeList.get(0);
topicEntity.setType(equipmentSpecificVo.getType());
topicEntity.setCode(equipmentSpecificVo.getCode());
//es存储数据
eSeqService.saveESEquiplistSpecificBySystemESVO(equipmentSpeIndex, String.valueOf(equipmentSpecificVo.getSystemId()), equipmentSpecificVo.getSystemName());
//更新装备性能指标
equipmentSpecificIndexService.updateById(equipmentSpeIndex);
// 更新设备表指标状态
iEquipmentSpecificSerivce.updateEquipmentSpecIndexRealtimeData(equipmentSpeIndex);
equipmentSpecificIndexList.add(equipmentSpeIndex);
indexStateList.add(createIndexStateVo(equipmentSpeIndex));
// 添加指标报告
saveEquipmentAlarmReportDay(equipmentSpeIndex);
// 火眼数据构造告警指标逻辑
equipmentSpeIndex = handleTemperatureAlarm(equipmentSpeIndex, iotDatalist);
boolean alarmFlag = false;
Map<String, String> messageBodyMap = new HashMap<>();
//管网压力、泡沫罐信息、水箱液位告警处理
if (iotDataVO.getKey().toLowerCase().equals(CAFS_FoamTank_FoamTankLevel.toLowerCase()) ||
FHS_PipePressureDetector_PipePressure.toLowerCase().equals(iotDataVO.getKey().toLowerCase()) ||
iotDataVO.getKey().toLowerCase().equals(CAFS_WaterTank_WaterTankLevel.toLowerCase())) {
alarmFlag = doFoamTankLevel(iotDataVO, equipmentSpeIndex, messageBodyMap);
}
//消防水池液位处理
if (iotDataVO.getKey().toLowerCase().equals(FHS_FirePoolDevice_WaterLevel.toLowerCase()) ||
iotDataVO.getKey().toLowerCase().equals(FHS_WirelessliquidDetector_WaterLevel.toLowerCase())) {
alarmFlag = doWaterPoolLevel(iotDataVO, equipmentSpeIndex, messageBodyMap);
}
// 遥测数据生成告警事件、日志处理
if (iotDataVO.getKey().toLowerCase().equals(CAFS_FoamTank_FoamTankLevel.toLowerCase()) ||
FHS_PipePressureDetector_PipePressure.toLowerCase().equals(iotDataVO.getKey().toLowerCase()) ||
iotDataVO.getKey().toLowerCase().equals(CAFS_WaterTank_WaterTankLevel.toLowerCase()) ||
iotDataVO.getKey().toLowerCase().equals(FHS_FirePoolDevice_WaterLevel.toLowerCase()) ||
iotDataVO.getKey().toLowerCase().equals(FHS_WirelessliquidDetector_WaterLevel.toLowerCase())) {
handlingAlarms(equipmentSpeIndex, alarmFlag);
}
// 指标告警处理
if (equipmentSpeIndex.getIsAlarm() != null && 1 == equipmentSpeIndex.getIsAlarm()) {
equipmentSpecificAlarms.addAll(createIndexAlarmRecord(equipmentSpeIndex, messageBodyMap));
}
// 遥测遥信数据推送云端kafka
JSONObject jsonObjectXf = new JSONObject();
jsonObjectXf.put("data_class", "realdata");
if (equipmentSpeIndex.getIsTrend() == 1) {
jsonObjectXf.put("data_type", "analog");
} else {
jsonObjectXf.put("data_type", "state");
} }
String date = DateUtils.date2LongStr(new Date());
jsonObjectXf.put("op_type", "subscribe_emergency");
JSONObject jsonObjectCondition = new JSONObject();
jsonObjectCondition.put("station_psr_id", stationCode);
jsonObjectCondition.put("station_name", stationName);
jsonObjectCondition.put("data_upload_time", date);
jsonObjectXf.put("condition", jsonObjectCondition);
JSONObject jsonObjectData = new JSONObject();
jsonObjectData.put("psrId", stationCode);
jsonObjectData.put("astId", equipmentSpeIndex.getSpecificCode());
jsonObjectData.put("equipType", equipmentSpeIndex.getEquipmentCode());
jsonObjectData.put("name", equipmentSpeIndex.getEquipmentSpecificName() + "-" + equipmentSpeIndex.getEquipmentSpecificIndexName());
if (value.equals("true")) {
jsonObjectData.put("value", "1");
} else if (value.equals("false")) {
jsonObjectData.put("value", "0");
} else {
jsonObjectData.put("value", value);
}
jsonObjectData.put("measurementType", null == equipmentSpeIndex.getEquipmentIndexKey() ? "" : equipmentSpeIndex.getEquipmentIndexKey());
jsonObjectData.put("dateTime", date);
jsonObjectData.put("quality", "0"); // 量测质量码:0 有效,1 无效
List<JSONObject> jsonObjects = Arrays.asList(jsonObjectData);
jsonObjectXf.put("data", jsonObjects);
// 遥测
if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) {
} else {
try {
emqKeeper.getMqttClient().publish("emq.xf.created", jsonObjectXf.toString().getBytes(), 1, false);
log.info("遥测遥信数据推送云端kafka成功");
} catch (MqttException e) {
log.error("遥测遥信数据推送云端kafka失败=====>" + e.getMessage());
e.printStackTrace();
}
}
// 报警数据保存
List<EquipmentSpecificAlarmLog> alarmLogs = new ArrayList<>();
if (!ObjectUtils.isEmpty(equipmentSpecificAlarms)) {
equipmentSpecificAlarmService.saveOrUpdateBatch(equipmentSpecificAlarms);
}
// 需要在事务提交之后,否则事务隔离查询不出数据
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
equipmentSpecificAlarms.forEach(action -> {
if (AlarmStatusEnum.BJ.getCode() == action.getStatus()) {
alarmLogs.add(addEquipAlarmLogRecord(action));
if (ValidationUtil.isEmpty(action.getAlamContent())) {
action.setAlamContent(action.getEquipmentSpecificName() + action.getEquipmentSpecificIndexName());
}
mqttSendGateway.sendToMqtt(TopicEnum.EQDQR.getTopic(), JSONArray.toJSON(action).toString());
} else {
alarmLogs.addAll(upAlarmLogStatus(action.getIotCode(), action.getEquipmentSpecificIndexKey(), action.getTraceId(),
equipmentSpecificAlarmLogService, false));
mqttSendGateway.sendToMqtt(TopicEnum.EQYQR.getTopic(), JSONArray.toJSON(action).toString());
bool = Boolean.TRUE;
}
});
// 直流中心消息推送刷新
publishDataToDCCenterPage(equipmentSpecificIndexList);
// 四横八纵遥测信号信息列表刷新
publishNormalIndexValueToPage(equipmentSpecificIndexList);
if ("zd".equals(system)) {
System.out.println("站端系统----------------");
// 向预控系统发送消息
sendEquipSpecIndexToAutosysTopic(equipmentSpecificIndexList);
// 首页性能指标数据订阅
mqttSendGateway.sendToMqtt(indexTopic, JSON.toJSONString(indexStateList));
// 组态大屏消息推送,设备表实时指标修改
intePageSysDataRefresh(equipmentSpecificIndexList, topicEntity);
// 数字换流站同步指标修改
syncSpecificIndexsToGS(equipmentSpecificIndexList);
// 则更新拓扑节点数据及告警状态
updateNodeDateByEquipId(equipmentSpecificIndexList);
// 向画布推送
publishDataToCanvas(equipmentSpecificIndexList);
// 向其他系统推送报警
equipmentAlarmLogsToOtherSystems(alarmLogs);
if (equipmentSpecificVo.getEcode() != null) {
String ecode = equipmentSpecificVo.getEcode();
boolean flag = false;
//消防泵
String[] strings = pumpCodes.split(",");
for (String string : strings) {
if (ecode.startsWith(string)) {
//通知>消防应急预案
topicEntity.setType("xfb");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
flag = true;
break;
}
}
// 消防炮
String[] stringxfp = monitorCodes.split(",");
if (!flag) {
for (String string1 : stringxfp) {
if (ecode.startsWith(string1)) {
//通知>消防应急预案
topicEntity.setType("xfp");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
flag = true;
break;
}
}
}
//消防水源
if (!flag) {
List<Map> lit = iEquipmentSpecificSerivce.getWater(equipmentSpecificVo.getId());
if (lit != null && lit.size() > 0) {
topicEntity.setType("xfsy");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
}
}
}
}
}
});
} }
/** /**
...@@ -336,7 +594,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -336,7 +594,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
* @param topicEntity * @param topicEntity
* @param iotDatalist * @param iotDatalist
*/ */
public void realTimeDateProcessing(TopicEntityVo topicEntity, List<IotDataVO> iotDatalist,EquipmentSpecificVo vo) { public void realTimeDateProcessing(TopicEntityVo topicEntity, List<IotDataVO> iotDatalist, EquipmentSpecificVo vo) {
String iotCode = topicEntity.getIotCode(); String iotCode = topicEntity.getIotCode();
if (EquipAndCarEnum.equip.type.equals(topicEntity.getType())) { if (EquipAndCarEnum.equip.type.equals(topicEntity.getType())) {
List<EquipmentSpecificIndex> indexList = equipmentSpecificIndexService List<EquipmentSpecificIndex> indexList = equipmentSpecificIndexService
...@@ -344,7 +602,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -344,7 +602,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
if (ObjectUtils.isEmpty(indexList)) { if (ObjectUtils.isEmpty(indexList)) {
return; return;
} }
equipRealTimeDate(iotDatalist, indexList, topicEntity,vo); equipRealTimeDate(iotDatalist, indexList, topicEntity, vo);
String bizOrgCode = indexList.get(0).getBizOrgCode(); String bizOrgCode = indexList.get(0).getBizOrgCode();
// redis缓存指定指标、指定时长物联数据 // redis缓存指定指标、指定时长物联数据
pressurePumpService.saveDataToRedis(iotDatalist, iotCode, bizOrgCode); pressurePumpService.saveDataToRedis(iotDatalist, iotCode, bizOrgCode);
...@@ -353,7 +611,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -353,7 +611,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
if (ObjectUtils.isEmpty(carProperties)) { if (ObjectUtils.isEmpty(carProperties)) {
return; return;
} }
carRealTimeDate(iotDatalist, carProperties,topicEntity); carRealTimeDate(iotDatalist, carProperties, topicEntity);
} }
} }
...@@ -365,7 +623,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -365,7 +623,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
* @param topicEntity * @param topicEntity
*/ */
public void equipRealTimeDate(List<IotDataVO> iotDatalist, List<EquipmentSpecificIndex> indexList, public void equipRealTimeDate(List<IotDataVO> iotDatalist, List<EquipmentSpecificIndex> indexList,
TopicEntityVo topicEntity,EquipmentSpecificVo vo) { TopicEntityVo topicEntity, EquipmentSpecificVo vo) {
List<EquipmentSpecificIndex> equipmentSpecificIndexList = new ArrayList<>(); List<EquipmentSpecificIndex> equipmentSpecificIndexList = new ArrayList<>();
List<EquipmentSpecificAlarm> equipmentSpecificAlarms = new ArrayList<>(); List<EquipmentSpecificAlarm> equipmentSpecificAlarms = new ArrayList<>();
List<IndexStateVo> indexStateList = new ArrayList<>(); List<IndexStateVo> indexStateList = new ArrayList<>();
...@@ -377,7 +635,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -377,7 +635,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String indexValue = iotDataVO.getValue().toString(); String indexValue = iotDataVO.getValue().toString();
// 稳压泵启停信号处理 // 稳压泵启停信号处理
if (indexKey.equals(pressurePumpStart)) { if (indexKey.equals(pressurePumpStart)) {
pressurePump(indexKey,indexValue, 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())
...@@ -394,8 +652,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -394,8 +652,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpeIndex.setUUID(UUIDUtils.getUUID()); equipmentSpeIndex.setUUID(UUIDUtils.getUUID());
//es存储数据 //es存储数据
eSeqService.saveESEquiplistSpecificBySystemESVO(equipmentSpeIndex,String.valueOf(vo.getSystemId()),vo.getSystemName()); eSeqService.saveESEquiplistSpecificBySystemESVO(equipmentSpeIndex, String.valueOf(vo.getSystemId()), vo.getSystemName());
equipmentSpecificIndexService.updateById(equipmentSpeIndex); equipmentSpecificIndexService.updateById(equipmentSpeIndex);
...@@ -441,7 +698,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -441,7 +698,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObjectXf = new JSONObject(); JSONObject jsonObjectXf = new JSONObject();
jsonObjectXf.put("data_class", "realdata"); jsonObjectXf.put("data_class", "realdata");
if(equipmentSpeIndex.getIsTrend() == 1) { if (equipmentSpeIndex.getIsTrend() == 1) {
jsonObjectXf.put("data_type", "analog"); jsonObjectXf.put("data_type", "analog");
} else { } else {
jsonObjectXf.put("data_type", "state"); jsonObjectXf.put("data_type", "state");
...@@ -452,36 +709,37 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -452,36 +709,37 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObjectCondition = new JSONObject(); JSONObject jsonObjectCondition = new JSONObject();
jsonObjectCondition.put("station_psr_id", stationCode); jsonObjectCondition.put("station_psr_id", stationCode);
jsonObjectCondition.put("station_name", stationName); jsonObjectCondition.put("station_name", stationName);
jsonObjectCondition.put("data_upload_time", date ); jsonObjectCondition.put("data_upload_time", date);
jsonObjectXf.put("condition",jsonObjectCondition); jsonObjectXf.put("condition", jsonObjectCondition);
JSONObject jsonObjectData = new JSONObject(); JSONObject jsonObjectData = new JSONObject();
jsonObjectData.put("psrId", stationCode); jsonObjectData.put("psrId", stationCode);
jsonObjectData.put("astId", equipmentSpecificIndex.getSpecificCode()); jsonObjectData.put("astId", equipmentSpecificIndex.getSpecificCode());
jsonObjectData.put("equipType", equipmentSpecificIndex.getEquipmentCode()); jsonObjectData.put("equipType", equipmentSpecificIndex.getEquipmentCode());
jsonObjectData.put("name", equipmentSpecificIndex.getEquipmentSpecificName()+"-"+equipmentSpecificIndex.getEquipmentSpecificIndexName()); jsonObjectData.put("name", equipmentSpecificIndex.getEquipmentSpecificName() + "-" + equipmentSpecificIndex.getEquipmentSpecificIndexName());
if(value.equals("true")) { if (value.equals("true")) {
jsonObjectData.put("value","1"); jsonObjectData.put("value", "1");
} else if (value.equals("false")) { } else if (value.equals("false")) {
jsonObjectData.put("value","0"); jsonObjectData.put("value", "0");
} else { } else {
jsonObjectData.put("value", value); jsonObjectData.put("value", value);
} }
jsonObjectData.put("measurementType", null == equipmentSpecificIndex.getEquipmentIndexKey() ? "" :equipmentSpecificIndex.getEquipmentIndexKey()); jsonObjectData.put("measurementType", null == equipmentSpecificIndex.getEquipmentIndexKey() ? "" : equipmentSpecificIndex.getEquipmentIndexKey());
jsonObjectData.put("dateTime",date); jsonObjectData.put("dateTime", date);
jsonObjectData.put("quality","0"); // 量测质量码:0 有效,1 无效 jsonObjectData.put("quality", "0"); // 量测质量码:0 有效,1 无效
List<JSONObject> jsonObjects = Arrays.asList(jsonObjectData); List<JSONObject> jsonObjects = Arrays.asList(jsonObjectData);
jsonObjectXf.put("data", jsonObjects); jsonObjectXf.put("data", jsonObjects);
// 遥测 // 遥测
if(!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) { if (!isOpenTelemetering && equipmentSpeIndex.getIsTrend() == 1) {
} else { } else {
try { try {
emqKeeper.getMqttClient().publish("emq.xf.created",jsonObjectXf.toString().getBytes(),1,false); emqKeeper.getMqttClient().publish("emq.xf.created", jsonObjectXf.toString().getBytes(), 1, false);
log.info("遥测遥信数据推送云端kafka成功"); log.info("遥测遥信数据推送云端kafka成功");
} catch (MqttException e) { } catch (MqttException e) {
log.error("遥测遥信数据推送云端kafka失败=====>" + e.getMessage()); log.error("遥测遥信数据推送云端kafka失败=====>" + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -491,8 +749,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -491,8 +749,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 报警数据保存 // 报警数据保存
List<EquipmentSpecificAlarmLog> alarmLogs = new ArrayList<>(); List<EquipmentSpecificAlarmLog> alarmLogs = new ArrayList<>();
if(!ObjectUtils.isEmpty(equipmentSpecificAlarms)){ if (!ObjectUtils.isEmpty(equipmentSpecificAlarms)) {
equipmentSpecificAlarmService.saveOrUpdateBatch(equipmentSpecificAlarms); equipmentSpecificAlarmService.saveOrUpdateBatch(equipmentSpecificAlarms);
} }
// 需要在事务提交之后,否则事务隔离查询不出数据 // 需要在事务提交之后,否则事务隔离查询不出数据
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
...@@ -518,7 +776,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -518,7 +776,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 四横八纵遥测信号信息列表刷新 // 四横八纵遥测信号信息列表刷新
publishNormalIndexValueToPage(equipmentSpecificIndexList); publishNormalIndexValueToPage(equipmentSpecificIndexList);
if("zd".equals(system)){ if ("zd".equals(system)) {
System.out.println("站端系统----------------"); System.out.println("站端系统----------------");
// 向预控系统发送消息 // 向预控系统发送消息
...@@ -539,54 +797,54 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -539,54 +797,54 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 向画布推送 // 向画布推送
publishDataToCanvas(equipmentSpecificIndexList); publishDataToCanvas(equipmentSpecificIndexList);
// 向其他系统推送报警 // 向其他系统推送报警
equipmentAlarmLogsToOtherSystems(alarmLogs); equipmentAlarmLogsToOtherSystems(alarmLogs);
if(vo.getEcode()!=null){ if (vo.getEcode() != null) {
String ecode= vo.getEcode(); String ecode = vo.getEcode();
boolean flag=false; boolean flag = false;
//消防泵 //消防泵
String[] strings = pumpCodes.split(","); String[] strings = pumpCodes.split(",");
for (String string : strings) { for (String string : strings) {
if(ecode.startsWith(string)){ if (ecode.startsWith(string)) {
//通知>消防应急预案 //通知>消防应急预案
topicEntity.setType("xfb"); topicEntity.setType("xfb");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity)); mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
flag=true; flag = true;
break; break;
} }
} }
// 消防炮 // 消防炮
String[] stringxfp = monitorCodes.split(","); String[] stringxfp = monitorCodes.split(",");
if(!flag){ if (!flag) {
for (String string1 : stringxfp) { for (String string1 : stringxfp) {
if(ecode.startsWith(string1)){ if (ecode.startsWith(string1)) {
//通知>消防应急预案 //通知>消防应急预案
topicEntity.setType("xfp"); topicEntity.setType("xfp");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity)); mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
flag=true; flag = true;
break; break;
} }
} }
} }
//消防水源 //消防水源
if(!flag){ if (!flag) {
List<Map> lit= iEquipmentSpecificSerivce.getWater(vo.getId()); List<Map> lit = iEquipmentSpecificSerivce.getWater(vo.getId());
if(lit!=null&& lit.size()>0){ if (lit != null && lit.size() > 0) {
topicEntity.setType("xfsy"); topicEntity.setType("xfsy");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity)); mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
} }
} }
} }
} }
} }
}); });
} }
private void handlingAlarms(EquipmentSpecificIndex equipmentSpecificIndex, boolean alarmFlag){ private void handlingAlarms(EquipmentSpecificIndex equipmentSpecificIndex, boolean alarmFlag) {
equipmentSpecificIndex.setIsAlarm(1); equipmentSpecificIndex.setIsAlarm(1);
equipmentSpecificIndex.setValue(String.valueOf(alarmFlag)); equipmentSpecificIndex.setValue(String.valueOf(alarmFlag));
} }
...@@ -594,8 +852,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -594,8 +852,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
/** /**
* 泡沫罐 或 者管网压力 消息发送 * 泡沫罐 或 者管网压力 消息发送
* @param iotDataVO iotDataVO *
* @param equipmentSpecificIndex equipmentSpecificIndex * @param iotDataVO iotDataVO
* @param equipmentSpecificIndex equipmentSpecificIndex
*/ */
private boolean doFoamTankLevel(IotDataVO iotDataVO, EquipmentSpecificIndex equipmentSpecificIndex, Map<String, String> messageBody) { private boolean doFoamTankLevel(IotDataVO iotDataVO, EquipmentSpecificIndex equipmentSpecificIndex, Map<String, String> messageBody) {
boolean alarmFlag = false; boolean alarmFlag = false;
...@@ -609,9 +868,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -609,9 +868,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
BigDecimal minValue = getBigDecimal(map.get("minValues")); BigDecimal minValue = getBigDecimal(map.get("minValues"));
BigDecimal maxValue = getBigDecimal(map.get("maxValues")); BigDecimal maxValue = getBigDecimal(map.get("maxValues"));
BigDecimal nowValue = getBigDecimal(iotDataVO.getValue()); BigDecimal nowValue = getBigDecimal(iotDataVO.getValue());
BigDecimal checkValue = checkUnit(equipmentSpecificIndex.getEquipmentSpecificId(),iotDataVO.getKey().toLowerCase() , nowValue); BigDecimal checkValue = checkUnit(equipmentSpecificIndex.getEquipmentSpecificId(), iotDataVO.getKey().toLowerCase(), nowValue);
if (!ObjectUtils.isEmpty(checkValue)){ if (!ObjectUtils.isEmpty(checkValue)) {
nowValue =checkValue; nowValue = checkValue;
} }
if (nowValue.compareTo(minValue) < 0 || nowValue.compareTo(maxValue) > 0) { if (nowValue.compareTo(minValue) < 0 || nowValue.compareTo(maxValue) > 0) {
String body = ""; String body = "";
...@@ -625,7 +884,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -625,7 +884,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpecificIndex.getEquipmentSpecificName() + "-" + equipmentSpecificIndex.getLocation(), equipmentSpecificIndex.getEquipmentSpecificName() + "-" + equipmentSpecificIndex.getLocation(),
nowValue, nowValue,
nowValue.compareTo(minValue) < 0 ? "低于最低报警阈值" + minValue : "超过最高报警阈值" + maxValue nowValue.compareTo(minValue) < 0 ? "低于最低报警阈值" + minValue : "超过最高报警阈值" + maxValue
); );
model.setTitle("模拟量提醒"); model.setTitle("模拟量提醒");
model.setBody(bodyMain); model.setBody(bodyMain);
model.setMsgType("FoamTankOrPipeNetwork"); model.setMsgType("FoamTankOrPipeNetwork");
...@@ -651,7 +910,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -651,7 +910,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// log.info(String.format("调用平台消息服务成功:%s", JSON.toJSONString(model))); // log.info(String.format("调用平台消息服务成功:%s", JSON.toJSONString(model)));
alarmFlag = true; alarmFlag = true;
} }
return alarmFlag; return alarmFlag;
} }
/** /**
...@@ -682,9 +941,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -682,9 +941,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
nowValue = add.divide(new BigDecimal(i), 2, RoundingMode.HALF_UP); nowValue = add.divide(new BigDecimal(i), 2, RoundingMode.HALF_UP);
} }
BigDecimal checkValue = checkUnit(equipmentSpecificIndex.getEquipmentSpecificId(),iotDataVO.getKey().toLowerCase() , nowValue); BigDecimal checkValue = checkUnit(equipmentSpecificIndex.getEquipmentSpecificId(), iotDataVO.getKey().toLowerCase(), nowValue);
if (!ObjectUtils.isEmpty(checkValue)){ if (!ObjectUtils.isEmpty(checkValue)) {
nowValue =checkValue; nowValue = checkValue;
} }
if (nowValue.compareTo(minValue) < 0 || nowValue.compareTo(maxValue) > 0) { if (nowValue.compareTo(minValue) < 0 || nowValue.compareTo(maxValue) > 0) {
String body = ""; String body = "";
...@@ -724,42 +983,43 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -724,42 +983,43 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return alarmFlag; return alarmFlag;
} }
private BigDecimal checkUnit(Long equipmentSpecificId, String indexKey,BigDecimal nowValue){ private BigDecimal checkUnit(Long equipmentSpecificId, String indexKey, BigDecimal nowValue) {
LambdaQueryWrapper<EquipmentSpecificIndex> lambda = new QueryWrapper<EquipmentSpecificIndex>().lambda(); LambdaQueryWrapper<EquipmentSpecificIndex> lambda = new QueryWrapper<EquipmentSpecificIndex>().lambda();
lambda.eq(EquipmentSpecificIndex :: getEquipmentSpecificId, equipmentSpecificId); lambda.eq(EquipmentSpecificIndex::getEquipmentSpecificId, equipmentSpecificId);
lambda.eq(EquipmentSpecificIndex :: getEquipmentIndexKey, indexKey); lambda.eq(EquipmentSpecificIndex::getEquipmentIndexKey, indexKey);
EquipmentSpecificIndex equipmentSpecificIndex = equipmentSpecificIndexMapper.selectOne(lambda); EquipmentSpecificIndex equipmentSpecificIndex = equipmentSpecificIndexMapper.selectOne(lambda);
if (!ObjectUtils.isEmpty(equipmentSpecificIndex) || !ObjectUtils.isEmpty(equipmentSpecificIndex.getUnit())){ if (!ObjectUtils.isEmpty(equipmentSpecificIndex) || !ObjectUtils.isEmpty(equipmentSpecificIndex.getUnit())) {
if (UnitEnum.MM.getKey().equalsIgnoreCase(equipmentSpecificIndex.getUnit()) || UnitEnum.MM.getName().equals(equipmentSpecificIndex.getUnit())){ if (UnitEnum.MM.getKey().equalsIgnoreCase(equipmentSpecificIndex.getUnit()) || UnitEnum.MM.getName().equals(equipmentSpecificIndex.getUnit())) {
BigDecimal divide = new BigDecimal(1000); BigDecimal divide = new BigDecimal(1000);
nowValue = nowValue.divide(divide,2,BigDecimal.ROUND_HALF_UP); nowValue = nowValue.divide(divide, 2, BigDecimal.ROUND_HALF_UP);
}else if (UnitEnum.CM.getKey().equalsIgnoreCase(equipmentSpecificIndex.getUnit()) || UnitEnum.CM.getName().equals(equipmentSpecificIndex.getUnit())){ } else if (UnitEnum.CM.getKey().equalsIgnoreCase(equipmentSpecificIndex.getUnit()) || UnitEnum.CM.getName().equals(equipmentSpecificIndex.getUnit())) {
BigDecimal divide = new BigDecimal(100); BigDecimal divide = new BigDecimal(100);
nowValue = nowValue.divide(divide,2,BigDecimal.ROUND_HALF_UP); nowValue = nowValue.divide(divide, 2, BigDecimal.ROUND_HALF_UP);
} }
} }
return nowValue; return nowValue;
} }
private BigDecimal getBigDecimal( Object value ) {
private BigDecimal getBigDecimal(Object value) {
BigDecimal val = null; BigDecimal val = null;
if( value != null ) { if (value != null) {
if( value instanceof BigDecimal ) { if (value instanceof BigDecimal) {
val = (BigDecimal) value; val = (BigDecimal) value;
} else if( value instanceof String ) { } else if (value instanceof String) {
val = new BigDecimal( (String) value ); val = new BigDecimal((String) value);
} else if( value instanceof BigInteger) { } else if (value instanceof BigInteger) {
val = new BigDecimal( (BigInteger) value ); val = new BigDecimal((BigInteger) value);
} else if( value instanceof Number ) { } else if (value instanceof Number) {
val = new BigDecimal(String.valueOf(value)); val = new BigDecimal(String.valueOf(value));
} else { } else {
throw new ClassCastException("Not possible to coerce ["+value+"] from class "+value.getClass()+" into a BigDecimal."); throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() + " into a BigDecimal.");
} }
} }
return val; return val;
} }
public void carRealTimeDate(List<IotDataVO> iotDatalist, List<CarProperty> carProperties,TopicEntityVo topicEntity) { public void carRealTimeDate(List<IotDataVO> iotDatalist, List<CarProperty> carProperties, TopicEntityVo topicEntity) {
List<CarProperty> carIndexsList = new ArrayList<>(); List<CarProperty> carIndexsList = new ArrayList<>();
iotDatalist.forEach(iotDataVO -> { iotDatalist.forEach(iotDataVO -> {
// 对指标key为labels的数据处理 // 对指标key为labels的数据处理
...@@ -819,7 +1079,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -819,7 +1079,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
queryWrapper.eq(EquipmentSpecificAlarmLog::getEquipmentSpecificIndexKey, equipmentSpecificIndexKey); queryWrapper.eq(EquipmentSpecificAlarmLog::getEquipmentSpecificIndexKey, equipmentSpecificIndexKey);
queryWrapper.ne(EquipmentSpecificAlarmLog::getStatus, AlarmStatusEnum.HF.getCode()); queryWrapper.ne(EquipmentSpecificAlarmLog::getStatus, AlarmStatusEnum.HF.getCode());
List<EquipmentSpecificAlarmLog> logs = equipmentSpecificAlarmLogService.getBaseMapper().selectList(queryWrapper); List<EquipmentSpecificAlarmLog> logs = equipmentSpecificAlarmLogService.getBaseMapper().selectList(queryWrapper);
if(!logs.isEmpty()){ if (!logs.isEmpty()) {
EquipmentSpecificAlarmLog log = logs.get(0); EquipmentSpecificAlarmLog log = logs.get(0);
EquipmentSpecific specific = equipmentSpecificMapper.selectById(log.getEquipmentSpecificId()); EquipmentSpecific specific = equipmentSpecificMapper.selectById(log.getEquipmentSpecificId());
Date date = new Date(); Date date = new Date();
...@@ -990,8 +1250,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -990,8 +1250,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpecificAlarmLog.setEquipmentSpecificIndexName(StringUtil.isNotEmpty(equipmentSpecificAlarm.getMessageBody()) ? equipmentSpecificAlarm.getMessageBody() : equipmentSpecificAlarm.getEquipmentSpecificIndexName()); equipmentSpecificAlarmLog.setEquipmentSpecificIndexName(StringUtil.isNotEmpty(equipmentSpecificAlarm.getMessageBody()) ? equipmentSpecificAlarm.getMessageBody() : equipmentSpecificAlarm.getEquipmentSpecificIndexName());
//调整为按照设备归属(可归属公司或者部门) //调整为按照设备归属(可归属公司或者部门)
Map<String,Object> mapd= iEquipmentSpecificSerivce.getStationCode(equipmentSpecificAlarm.getEquipmentSpecificId()); Map<String, Object> mapd = iEquipmentSpecificSerivce.getStationCode(equipmentSpecificAlarm.getEquipmentSpecificId());
if(mapd!=null){ if (mapd != null) {
equipmentSpecificAlarmLog.setStationCode(mapd.get("station_code").toString()); equipmentSpecificAlarmLog.setStationCode(mapd.get("station_code").toString());
equipmentSpecificAlarmLog.setStationName(mapd.get("station_name").toString()); equipmentSpecificAlarmLog.setStationName(mapd.get("station_name").toString());
} }
...@@ -1043,8 +1303,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1043,8 +1303,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpecificAlarm.setMessageBody(!ObjectUtils.isEmpty(messageBody) ? messageBody.get("messageBody") : ""); equipmentSpecificAlarm.setMessageBody(!ObjectUtils.isEmpty(messageBody) ? messageBody.get("messageBody") : "");
//调整为按照设备归属(可归属公司或者部门 //调整为按照设备归属(可归属公司或者部门
Map<String,Object> mapd= iEquipmentSpecificSerivce.getStationCode(equipmentSpecificIndex.getEquipmentSpecificId()); Map<String, Object> mapd = iEquipmentSpecificSerivce.getStationCode(equipmentSpecificIndex.getEquipmentSpecificId());
if(mapd!=null){ if (mapd != null) {
equipmentSpecificAlarm.setStationCode(mapd.get("station_code").toString()); equipmentSpecificAlarm.setStationCode(mapd.get("station_code").toString());
equipmentSpecificAlarm.setStationName(mapd.get("station_name").toString()); equipmentSpecificAlarm.setStationName(mapd.get("station_name").toString());
} }
...@@ -1054,7 +1314,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1054,7 +1314,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// equipmentSpecificAlarm.setStationName(stationName); // equipmentSpecificAlarm.setStationName(stationName);
equipmentSpecificAlarms.add(equipmentSpecificAlarm); equipmentSpecificAlarms.add(equipmentSpecificAlarm);
return equipmentSpecificAlarms; return equipmentSpecificAlarms;
} }
...@@ -1131,6 +1390,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1131,6 +1390,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
|| "temperature".equals(x.getKey()) || "ruleTemperature".equals(x.getKey()) || "temperature".equals(x.getKey()) || "ruleTemperature".equals(x.getKey())
|| "thermometryUnit".equals(x.getKey()) || "alarmRule".equals(x.getKey())) || "thermometryUnit".equals(x.getKey()) || "alarmRule".equals(x.getKey()))
.collect(Collectors.toList()); .collect(Collectors.toList());
// List<IotDataVO> iotDataVOS = iotDatalist.stream()
// .filter(x -> Stream.of("alarmLevel", "temperature", "thermometryUnit", "ruleTemperature", "alarmType", "alarmRule")
// .anyMatch(s -> s.equals(x.getKey()))).collect(Collectors.toList());
if (iotDataVOs.size() > 0) { if (iotDataVOs.size() > 0) {
Map<String, Object> map = iotDatalist.stream() Map<String, Object> map = iotDatalist.stream()
.collect(Collectors.toMap(IotDataVO::getKey, IotDataVO::getValue)); .collect(Collectors.toMap(IotDataVO::getKey, IotDataVO::getValue));
...@@ -1575,15 +1839,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1575,15 +1839,15 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 1. 获取需要校验的值 // 1. 获取需要校验的值
PressurePumpValueEnum valueEnum = PressurePumpValueEnum.getByCode(pressurePumpEnum.getCompareValue()); PressurePumpValueEnum valueEnum = PressurePumpValueEnum.getByCode(pressurePumpEnum.getCompareValue());
assert valueEnum != null; assert valueEnum != null;
EquipmentSpecificIndex data = getPressurePumpDateByType(indexKey,valueEnum, topicEntity, equipmentSpeIndexList, pressurePumpEnum); EquipmentSpecificIndex data = getPressurePumpDateByType(indexKey, valueEnum, topicEntity, equipmentSpeIndexList, pressurePumpEnum);
Date newDate = new Date(); Date newDate = new Date();
// 2. 校验 // 2. 校验
if (!ObjectUtils.isEmpty(data.getUpdateDate())) { if (!ObjectUtils.isEmpty(data.getUpdateDate())) {
checkValueByDate(data, newDate, pressurePumpEnum); checkValueByDate(data, newDate, pressurePumpEnum);
}else { } else {
// 稳压泵漏水告警恢复 // 稳压泵漏水告警恢复
List<EquipmentSpecificIndex> collect = equipmentSpeIndexList.stream().filter(item -> !ObjectUtils.isEmpty(item.getIotCode()) && item.getIotCode().equals(topicEntity.getIotCode())).collect(Collectors.toList()); List<EquipmentSpecificIndex> collect = equipmentSpeIndexList.stream().filter(item -> !ObjectUtils.isEmpty(item.getIotCode()) && item.getIotCode().equals(topicEntity.getIotCode())).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect) && !ObjectUtils.isEmpty(collect.get(0)) && !ObjectUtils.isEmpty(collect.get(0).getEquipmentId())){ if (!ObjectUtils.isEmpty(collect) && !ObjectUtils.isEmpty(collect.get(0)) && !ObjectUtils.isEmpty(collect.get(0).getEquipmentId())) {
equipmentSpecificAlarmLogService.pressurePumpRestore(collect.get(0).getEquipmentId()); equipmentSpecificAlarmLogService.pressurePumpRestore(collect.get(0).getEquipmentId());
} }
} }
...@@ -1603,12 +1867,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1603,12 +1867,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} else { } else {
throw new BadRequest("装备物联编码错误,请确认!"); 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) && 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(lastStop)) { if (!CollectionUtils.isEmpty(lastStop)) {
EquipmentSpecificIndex aFalse = getIotDate(equipmentSpecificIndex, lastStop, prefix, suffix, "false"); EquipmentSpecificIndex aFalse = getIotDate(equipmentSpecificIndex, lastStop, prefix, suffix, "false");
...@@ -1618,12 +1882,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1618,12 +1882,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
case LAST_START: case LAST_START:
boolean b = QuartzManager.checkExists(jobName, PUMP_JOB_GROUP_NAME); boolean b = QuartzManager.checkExists(jobName, PUMP_JOB_GROUP_NAME);
// 删除这个稳压泵的监听任务 // 删除这个稳压泵的监听任务
if(b) { if (b) {
QuartzManager.removeJob(jobName,PUMP_JOB_GROUP_NAME,triggerName,PUMP_TRIGGER_GROUP_NAME); QuartzManager.removeJob(jobName, PUMP_JOB_GROUP_NAME, triggerName, PUMP_TRIGGER_GROUP_NAME);
} }
List<EquipmentSpecificIndex> lastStart = equipmentSpeIndexList.stream().filter(e -> List<EquipmentSpecificIndex> lastStart = equipmentSpeIndexList.stream().filter(e ->
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 aTrue = getIotDate(equipmentSpecificIndex, lastStart, prefix, suffix, "true"); EquipmentSpecificIndex aTrue = getIotDate(equipmentSpecificIndex, lastStart, prefix, suffix, "true");
...@@ -1633,7 +1897,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1633,7 +1897,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
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()) && 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(latelyStop)) { if (!CollectionUtils.isEmpty(latelyStop)) {
EquipmentSpecificIndex aFalse = getIotDate(equipmentSpecificIndex, latelyStop, prefix, null, "false"); EquipmentSpecificIndex aFalse = getIotDate(equipmentSpecificIndex, latelyStop, prefix, null, "false");
...@@ -1643,7 +1907,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1643,7 +1907,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
break; break;
case LATELY_START: case LATELY_START:
List<EquipmentSpecificIndex> latelyStart = equipmentSpeIndexList.stream().filter(e -> List<EquipmentSpecificIndex> latelyStart = equipmentSpeIndexList.stream().filter(e ->
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 aTrue = getIotDate(equipmentSpecificIndex, latelyStart, prefix, null, "true"); EquipmentSpecificIndex aTrue = getIotDate(equipmentSpecificIndex, latelyStart, prefix, null, "true");
...@@ -1661,7 +1925,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1661,7 +1925,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
private EquipmentSpecificIndex getIotDate(EquipmentSpecificIndex equipmentSpecificIndex, List<EquipmentSpecificIndex> listData, String prefix, String suffix, String flag) { private EquipmentSpecificIndex 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); 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())) { if (200 == start.getStatus() && !ObjectUtils.isEmpty(start.getResult())) {
String json1 = JSON.toJSONString(start.getResult()); String json1 = JSON.toJSONString(start.getResult());
...@@ -1671,7 +1935,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1671,7 +1935,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " "); String startTime = collect.get(0).get("time").substring(0, 19).replace("T", " ");
Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8); Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTime), +8);
listData.get(0).setUpdateDate(startDate); listData.get(0).setUpdateDate(startDate);
BeanUtils.copyProperties(listData.get(0),equipmentSpecificIndex); BeanUtils.copyProperties(listData.get(0), equipmentSpecificIndex);
} }
return equipmentSpecificIndex; return equipmentSpecificIndex;
} }
...@@ -1684,7 +1948,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1684,7 +1948,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
try { try {
long d1 = df.parse(df.format(data.getUpdateDate())).getTime(); long d1 = df.parse(df.format(data.getUpdateDate())).getTime();
long d2 = df.parse(df.format(newDate)).getTime(); long d2 = df.parse(df.format(newDate)).getTime();
diff = (d2-d1)/1000/60; diff = (d2 - d1) / 1000 / 60;
} catch (Exception e) { } catch (Exception e) {
log.error("时间转换失败" + e.getMessage()); log.error("时间转换失败" + e.getMessage());
return; return;
...@@ -1791,19 +2055,19 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1791,19 +2055,19 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
private void startTimeCompute(String indexKey, TopicEntityVo topicEntity, PressurePumpEnum pressurePumpEnum) { private void startTimeCompute(String indexKey, TopicEntityVo topicEntity, PressurePumpEnum pressurePumpEnum) {
String jobName = topicEntity.getIotCode()+"_"+indexKey; String jobName = topicEntity.getIotCode() + "_" + indexKey;
String cron =""; String cron = "";
String triggerName = PUMP_TRIGGER_NAME+"-"+topicEntity.getIotCode(); String triggerName = PUMP_TRIGGER_NAME + "-" + topicEntity.getIotCode();
if("FHS_PressurePump_Start_ALONE_START_YXSC".equals(pressurePumpEnum.getCode())){ if ("FHS_PressurePump_Start_ALONE_START_YXSC".equals(pressurePumpEnum.getCode())) {
Calendar time= Calendar.getInstance(); Calendar time = Calendar.getInstance();
time.add(Calendar.MINUTE,5); time.add(Calendar.MINUTE, 5);
cron = time.get(Calendar.SECOND) + " " + time.get(Calendar.MINUTE) + "/5 * * * ?"; cron = time.get(Calendar.SECOND) + " " + time.get(Calendar.MINUTE) + "/5 * * * ?";
}else{ } else {
cron = pressurePumpEnum.getLeftValue(); cron = pressurePumpEnum.getLeftValue();
} }
...@@ -1812,22 +2076,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1812,22 +2076,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
LambdaQueryWrapper<EquipmentSpecific> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EquipmentSpecific> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentSpecific::getIotCode, topicEntity.getIotCode()); wrapper.eq(EquipmentSpecific::getIotCode, topicEntity.getIotCode());
equipmentSpecific = equipmentSpecificMapper.selectOne(wrapper); equipmentSpecific = equipmentSpecificMapper.selectOne(wrapper);
}catch (Exception e) { } catch (Exception e) {
log.error("根据iotCod查询失败" + topicEntity.getIotCode()); log.error("根据iotCod查询失败" + topicEntity.getIotCode());
} }
boolean b = QuartzManager.checkExists(jobName, PUMP_JOB_GROUP_NAME); boolean b = QuartzManager.checkExists(jobName, PUMP_JOB_GROUP_NAME);
if (indexKey.equals(pressurePumpStart)) { if (indexKey.equals(pressurePumpStart)) {
if (b) { if (b) {
// 任务存在 更新时间 // 任务存在 更新时间
QuartzManager.modifyJobTime(triggerName,PUMP_TRIGGER_GROUP_NAME,cron); QuartzManager.modifyJobTime(triggerName, PUMP_TRIGGER_GROUP_NAME, cron);
} else { } else {
QuartzManager.removeJob(jobName,PUMP_JOB_GROUP_NAME,triggerName,PUMP_TRIGGER_GROUP_NAME); QuartzManager.removeJob(jobName, PUMP_JOB_GROUP_NAME, triggerName, PUMP_TRIGGER_GROUP_NAME);
// 任务不存在,新增 // 任务不存在,新增
// 传参 // 传参
if (ObjectUtils.isEmpty(equipmentSpecific)) { if (ObjectUtils.isEmpty(equipmentSpecific)) {
return; return;
} }
Map<String,Object> parameter = new HashMap<>(6); Map<String, Object> parameter = new HashMap<>(6);
parameter.put("jobName", jobName); parameter.put("jobName", jobName);
parameter.put("triggerName", triggerName); parameter.put("triggerName", triggerName);
parameter.put("triggerGroupName", PUMP_TRIGGER_GROUP_NAME); parameter.put("triggerGroupName", PUMP_TRIGGER_GROUP_NAME);
...@@ -1838,7 +2102,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1838,7 +2102,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
parameter.put("systemctlFeign", systemctlFeign); parameter.put("systemctlFeign", systemctlFeign);
parameter.put("marqueeDataMapper", marqueeDataMapper); parameter.put("marqueeDataMapper", marqueeDataMapper);
parameter.put("equipmentSpecificAlarmLogService", equipmentSpecificAlarmLogService); parameter.put("equipmentSpecificAlarmLogService", equipmentSpecificAlarmLogService);
QuartzManager.addJob(jobName,PUMP_JOB_GROUP_NAME,triggerName,PUMP_TRIGGER_GROUP_NAME, PumpSendMessage.class,cron,parameter); QuartzManager.addJob(jobName, PUMP_JOB_GROUP_NAME, triggerName, PUMP_TRIGGER_GROUP_NAME, PumpSendMessage.class, cron, parameter);
} }
} }
} }
......
...@@ -843,4 +843,65 @@ ...@@ -843,4 +843,65 @@
esi.emergency_level_describe = ( SELECT emergency_level_describe FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id ); esi.emergency_level_describe = ( SELECT emergency_level_describe FROM wl_equipment_index wei WHERE esi.equipment_index_id = wei.id );
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="LiuLin" id="1686212667">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_index" columnName="index_address"/>
</not>
</preConditions>
<comment>新增属性字段 index_address</comment>
<sql>
alter table `wl_equipment_specific_index` add column `index_address` varchar(50) COMMENT '信号的索引键key,用于唯一索引信号';
</sql>
</changeSet>
<changeSet author="LiuLin" id="1686212667-1">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_index" columnName="quality"/>
</not>
</preConditions>
<comment>新增属性字段 quality</comment>
<sql>
alter table `wl_equipment_specific_index` add column `quality` tinyint(4) DEFAULT NULL COMMENT '品质,0为有效,1为无效';
</sql>
</changeSet>
<changeSet author="LiuLin" id="1686212667-2">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_index" columnName="data_type"/>
</not>
</preConditions>
<comment>新增属性字段 data_type</comment>
<sql>
alter table `wl_equipment_specific_index` add column `data_type` varchar(10) DEFAULT NULL COMMENT '测点类型,analog/state';
</sql>
</changeSet>
<changeSet author="LiuLin" id="1686212667-3">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_index" columnName="time_stamp"/>
</not>
</preConditions>
<comment>新增属性字段 time_stamp</comment>
<sql>
alter table `wl_equipment_specific_index` add column `time_stamp` varchar(32) COMMENT '时间';
</sql>
</changeSet>
<changeSet author="LiuLin" id="1686564561">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="wl_equipment_specific_index" columnName="value_enum"/>
</not>
</preConditions>
<comment>wl_equipment_specific_index add `value_enum`</comment>
<sql>
ALTER TABLE `wl_equipment_specific_index` ADD COLUMN `value_enum` text NULL COMMENT '指标值枚举' AFTER `value_label`;
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
\ No newline at end of file
...@@ -515,4 +515,49 @@ ...@@ -515,4 +515,49 @@
</if> </if>
</where> </where>
</select> </select>
<!-- 根据信号索引查询装备性能指标 -->
<select id="getEquipmentSpeIndexByIndexAddress"
resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT wesi.id AS id,
wei.name_key AS nameKey,
wesi.value AS value,
wesi.equipment_specific_id AS equipmentSpecificId,
wesi.equipment_index_id AS equipmentIndexId,
wesi.equipment_index_name AS equipmentIndexName,
wesi.equipment_index_key AS equipmentIndexKey,
wesi.value_label AS valueLabel,
wei.type_code AS typeCode,
wei.type_name AS typeName,
wei.name AS indexName,
wei.unit AS indexUnitName,
wes.org_code AS orgCode,
ed.`name` AS equipmentSpecificName,
ed.equipment_name AS equipmentName,
wes.iot_code AS iotCode,
wes.code AS specificCode,
wei.`name` AS equipmentSpecificIndexName,
wei.`value_enum` AS valueEnum,
wei.is_trend AS isTrend,
wes.qr_code AS qrCode,
wesi.update_date AS updateDate,
ed.code AS equipmentCode,
ed.equipment_id AS equipmentId,
ed.id AS equipmentDetailId,
wes.code as equipmentSpecificCode,
wes.system_id as systemId,
wesi.is_alarm as isAlarm,
wesi.emergency_level_color as emergencyLevelColor,
wesi.emergency_level as emergencyLevel,
wesi.emergency_level_describe as emergencyLevelDescribe,
wes.biz_org_name AS bizOrgName,
wes.biz_org_code AS bizOrgCode
FROM wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes ON wes.id = wesi.equipment_specific_id
LEFT JOIN wl_equipment_detail ed ON ed.id = wes.equipment_detail_id
LEFT JOIN wl_equipment_index AS wei ON wei.id = wesi.equipment_index_id
WHERE
wesi.index_address = #{indexAddress}
AND wei.is_iot = true
</select>
</mapper> </mapper>
\ No newline at end of file
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