Commit 47f280da authored by 刘林's avatar 刘林

Merge branch 'develop_dl_jiangxi' into develop_dl

parents c8a7ee45 967d2149
......@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.component.influxdb.InfluxDbConnection;
import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import com.yeejoin.equipmanage.common.datasync.entity.FireEquipmentDefectAlarm;
......@@ -29,9 +28,7 @@ import com.yeejoin.equipmanage.quartz.QuartzManager;
import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.utils.BeanUtil;
import javafx.scene.control.Tab;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -52,7 +49,6 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -384,22 +380,22 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
JSONObject jsonObject = JSONObject.parseObject(message);
String dataType = jsonObject.getString("datatype");
String indexAddress,value,timeStamp,quality = null;
String indexAddress, value, timeStamp, quality = null;
//如果消息是遥信类型,进行指标转换
if(dataType != null && dataType.equals("state")){
if (dataType != null && dataType.equals("state")) {
indexAddress = jsonObject.getString("scadaid");
value = jsonObject.getInteger("value") ==1 ? "true":"false";
value = jsonObject.getInteger("value") == 1 ? "true" : "false";
timeStamp = jsonObject.getString("timestamp");
}else{
} else {
indexAddress = jsonObject.getString("key");
value = jsonObject.getString("value");
timeStamp = jsonObject.getString("time_stamp");
quality = jsonObject.getString("quality");
}
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,null);
if (equipmentSpeIndex == null){
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, null);
if (equipmentSpeIndex == null) {
return;
}
equipmentSpeIndex.setValue(value);
......@@ -636,7 +632,6 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//influxdb
Map<String, String> tagsMap = new HashMap<>();
Map<String, Object> fieldsMap = new HashMap<>();
Map<String, Object> fieldsStrMap = new HashMap<>();
log.info("接收到iot消息: {}", message);
TopicEntityVo topicEntity = new TopicEntityVo();
......@@ -652,11 +647,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
String traceId = jsonObject.getString("traceId");
String deviceCode = jsonObject.getString("deviceCode");
String gatewayId = jsonObject.getString("gatewayId");
String value=jsonObject.getString("value");
String value = jsonObject.getString("value");
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress,gatewayId);
if (equipmentSpeIndex == null){
EquipmentSpecificIndex equipmentSpeIndex = equipmentSpecificIndexService.getEquipmentSpeIndexByIndexAddress(indexAddress, gatewayId);
if (equipmentSpeIndex == null) {
return;
}
......@@ -671,21 +666,25 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
//更新装备性能指标
//equipmentSpecificIndexService.updateById(equipmentSpeIndex);
tagsMap.put("key", indexAddress+"_"+gatewayId);
tagsMap.put("key", indexAddress + "_" + gatewayId);
String valueLabel = valueTranslate(value, equipmentSpeIndex.getValueEnum());
fieldsMap.put("traceId", traceId);
fieldsMap.put("address", indexAddress);
fieldsMap.put("value", value);
fieldsMap.put("valueLabel", valueLabel.equals("") ? value : valueLabel);
fieldsMap.put("gatewayId", gatewayId);
fieldsMap.put("dataType", dataType);
fieldsMap.put("equipmentId", equipmentSpeIndex.getEquipmentId());
fieldsMap.put("equipmentIndexName", equipmentSpeIndex.getEquipmentIndexName());
fieldsMap.put("equipmentIndexKey", equipmentSpeIndex.getEquipmentIndexKey());
fieldsMap.put("isAlarm", equipmentSpeIndex.getIsAlarm().toString());
fieldsMap.put("unit", equipmentSpeIndex.getIndexUnitName());
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
fieldsMap.put("createdTime", simpleDateFormat.format(new Date()));
fieldsMap.put("equipmentIndex", JSON.toJSONString(equipmentSpeIndex));
//保存influxDB库
influxDbConnection.insert("iot_data", tagsMap, fieldsMap);
QueryWrapper<EquipmentSpecific> queryWrapper = new QueryWrapper<>();
......@@ -951,8 +950,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} else {
//恢复后修改 wl_equip_qrcode_record中对应记录
LambdaQueryWrapper<EquipQrcodeRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipQrcodeRecord::getEquipid,action.getEquipmentSpecificId());
wrapper.eq(EquipQrcodeRecord::getSourceId,action.getId());
wrapper.eq(EquipQrcodeRecord::getEquipid, action.getEquipmentSpecificId());
wrapper.eq(EquipQrcodeRecord::getSourceId, action.getId());
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecordMapper.selectOne(wrapper);
equipQrcodeRecord.setCleanTime(new Date());
equipQrcodeRecordMapper.updateById(equipQrcodeRecord);
......@@ -965,12 +964,12 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
bool = Boolean.TRUE;
LambdaQueryWrapper<EquipQrcodeRecord> query = new LambdaQueryWrapper<>();
query.eq(EquipQrcodeRecord::getEquipid,action.getEquipmentSpecificId());
query.eq(EquipQrcodeRecord::getEquipid, action.getEquipmentSpecificId());
query.isNull(EquipQrcodeRecord::getCleanTime);
List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query);
if (equipQrcodeRecords.size() > 0){ //如果记录表中还存在未消除的巡检故障 则先修改为黄码
if (equipQrcodeRecords.size() > 0) { //如果记录表中还存在未消除的巡检故障 则先修改为黄码
iEquipmentSpecificSerivce.updateEquipSpecificStatus(equipQrcodeRecords.get(0).getStatus(), String.valueOf(specific.getId()));
}else {
} else {
iEquipmentSpecificSerivce.updateEquipSpecificStatus(specific.getEquipStatus(), String.valueOf(specific.getId()));
}
......@@ -987,7 +986,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 触发风险---> 站端发送消息到Message服务
publishDataToMessage(equipmentSpecificIndexList, isAlarm);
if("zd".equals(system)){
if ("zd".equals(system)) {
System.out.println("站端系统----------------");
// 向预控系统发送消息
......@@ -1008,47 +1007,47 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
// 向画布推送
publishDataToCanvas(equipmentSpecificIndexList);
// 向其他系统推送报警
equipmentAlarmLogsToOtherSystems(alarmLogs);
if(vo.getEcode()!=null){
String ecode= vo.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(vo.getId());
if(lit!=null&& lit.size()>0){
topicEntity.setType("xfsy");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
}
}
}
// 向其他系统推送报警
equipmentAlarmLogsToOtherSystems(alarmLogs);
if (vo.getEcode() != null) {
String ecode = vo.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(vo.getId());
if (lit != null && lit.size() > 0) {
topicEntity.setType("xfsy");
mqttSendGateway.sendToMqtt(emergencyDisposalIndicators, JSONObject.toJSONString(topicEntity));
}
}
}
}
}
});
......
......@@ -131,18 +131,17 @@
<select id="getEquipmentSpeIndexDataByIotCode"
resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT wesi.id AS id,
wei.name_key AS nameKey,
IFNULL(si.value_label, si.`value`) AS 'value',
wesi.equipment_specific_id AS equipmentSpecificId,
wesi.equipment_index_id AS equipmentIndexId,
wes.org_code AS code,
wes.iot_code AS iotCode,
wes.org_code AS orgCode,
wei.type_code AS typeCode,
wei.name AS indexName,
wei.unit AS indexUnitName,
wei.value_enum AS valueEnum
SELECT wesi.id AS id,
wei.name_key AS nameKey,
IFNULL(si.value_label, si.`value`) AS 'value', wesi.equipment_specific_id AS equipmentSpecificId,
wesi.equipment_index_id AS equipmentIndexId,
wes.org_code AS code,
wes.iot_code AS iotCode,
wes.org_code AS orgCode,
wei.type_code AS typeCode,
wei.name AS indexName,
wei.unit AS indexUnitName,
wei.value_enum AS valueEnum
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_index AS wei ON wei.id = wesi.equipment_index_id
......@@ -175,31 +174,29 @@
WHERE wlves.equipment_specific_id = #{id}
</select>
<select id="getEquipmentDetailBySecificId" resultMap="EquipmentDetail">
SELECT wled.NAME equipment_name,
wle.id equip_id,
wled.id equip_detail_id,
SELECT wled.NAME equipment_name,
wle.id equip_id,
wled.id equip_detail_id,
wles.qr_code,
wles.CODE,
(
select GROUP_CONCAT(fs.name)
from f_fire_fighting_system fs
where FIND_IN_SET(fs.id, wles.system_id)
) as System_name,
wlec.NAME category_name,
wlws.full_name warehouse_name,
(select GROUP_CONCAT(fs.name)
from f_fire_fighting_system fs
where FIND_IN_SET(fs.id, wles.system_id)) as System_name,
wlec.NAME category_name,
wlws.full_name warehouse_name,
wled.standard,
sd.`name` country,
sd.`name` country,
wled.remark,
wled.maintenance_cycle,
wled.is_import,
wled.brand,
wlun.`name` unit_name,
wlmi.`name` manufacturer_name,
wlun.`name` unit_name,
wlmi.`name` manufacturer_name,
wlmi.service_tel,
wlmi.sales_tel,
wlmi.address,
wlmi.img,
wleias.`value` STATUS
wleias.`value` STATUS
FROM wl_equipment_specific wles
LEFT JOIN wl_equipment_detail wled ON wles.equipment_detail_id = wled.id
LEFT JOIN wl_system_dic sd ON sd.id = wled.country
......@@ -209,13 +206,11 @@
LEFT JOIN wl_warehouse_structure wlws ON wlsd.warehouse_structure_id = wlws.id
LEFT JOIN wl_unit wlun ON wle.unit_id = wlun.id
LEFT JOIN wl_manufacturer_info wlmi ON wlmi.id = wled.manufacturer_id
LEFT JOIN (
SELECT wlei.equipment_id,
wlesi.`value`
FROM wl_equipment_index wlei
LEFT JOIN wl_equipment_specific_index wlesi ON wlei.id = wlesi.equipment_index_id
WHERE wlei.name_key = 'runState'
) wleias ON wle.id = wleias.equipment_id
LEFT JOIN (SELECT wlei.equipment_id,
wlesi.`value`
FROM wl_equipment_index wlei
LEFT JOIN wl_equipment_specific_index wlesi ON wlei.id = wlesi.equipment_index_id
WHERE wlei.name_key = 'runState') wleias ON wle.id = wleias.equipment_id
WHERE wles.id = #{id}
</select>
<select id="selectEquProperty" resultType="java.util.HashMap">
......@@ -428,10 +423,10 @@
esi.equipment_index_name AS equipmentSpecificIndexName,
IF(
esi.value_label = ''
esi.value_label = ''
OR esi.value_label IS NULL,
esi.`value`,
esi.value_label
esi.`value`,
esi.value_label
) AS valueLabel,
es.position AS location,
esi.update_date AS createDate
......@@ -475,21 +470,21 @@
</select>
<select id="getEquipSpecificScrap" resultType="java.util.Map">
select wes.id,
str.name as sname,
wlsd.status,
wes.position,
wes.name,
we.expiry_date as weExpiry,
<!-- wed.expiry_date as wesExpiry,-->
wed.area as area,
wed.production_date as product
str.name as sname,
wlsd.status,
wes.position,
wes.name,
we.expiry_date as weExpiry,
<!-- wed.expiry_date as wesExpiry,-->
wed.area as area,
wed.production_date as product
from wl_equipment_specific wes
left join wl_equipment_detail wed on wes.equipment_detail_id = wed.id
left join wl_equipment we on wed.equipment_id = we.id
left join wl_warehouse_structure str on str.id = wes.warehouse_structure_id
left join wl_stock_detail wlsd on wes.id = wlsd.equipment_specific_id
left join wl_equipment_detail wed on wes.equipment_detail_id = wed.id
left join wl_equipment we on wed.equipment_id = we.id
left join wl_warehouse_structure str on str.id = wes.warehouse_structure_id
left join wl_stock_detail wlsd on wes.id = wlsd.equipment_specific_id
where wed.production_date is not null
and wlsd.status != 7
and wlsd.status != 7
</select>
<select id="getEquipIndexInIndex" resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT
......@@ -508,7 +503,7 @@
LEFT JOIN wl_equipment_detail wled ON es.equipment_detail_id = wled.id
<where>
<if test="list != null and list.size > 0 and type = 'id'">
si.equipment_index_key IN
si.equipment_index_key IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
......@@ -521,45 +516,45 @@
<!-- 根据信号索引查询装备性能指标 -->
<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
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,
wesi.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}
wesi.index_address = #{indexAddress}
<if test="gatewayId != null">
AND wesi.gateway_id = #{gatewayId}
</if>
......
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