refactor(device):重构物联网设备数据处理逻辑
- 修改设备数据查询方法,使用listMQTarget替代listTargetByEquId - 优化数据处理流程,通过循环遍历设备配置替代硬编码条件判断- 增加空值检查,确保数据列表不为空时才执行保存操作- 移除冗余的批量插入和更新方法 - 添加设备类型过滤条件,精确匹配一氧化碳设备数据 - 简化代码结构,提高可维护性和扩展性dev
parent
4912547478
commit
7a0c4a8082
|
|
@ -152,74 +152,38 @@ public class AppPosiDeviceController {
|
||||||
String processingBatchId = UuidUtil.get32UUID();
|
String processingBatchId = UuidUtil.get32UUID();
|
||||||
// 批处理时间
|
// 批处理时间
|
||||||
String processingTime = DateUtil.date2Str(new Date());
|
String processingTime = DateUtil.date2Str(new Date());
|
||||||
// td1 和 t2td1 的值是一氧化碳浓度 每次数据至多两条(安装在一起的设备)
|
|
||||||
String location = parma.get("location");
|
String location = parma.get("location");
|
||||||
// 根据设备的地点和td1或者是t2td1判断出设备对应系统中的哪个
|
|
||||||
// 查出所有一氧化碳设备的阈值配置
|
// 查出所有一氧化碳设备的配置
|
||||||
List<PageData> targetAllList = tbIronPlcMapper.listTargetByEquId();
|
List<PageData> targetAllList = tbIronPlcMapper.listMQTarget();
|
||||||
// 定义一个存储集合用于存储要入库的数据
|
// 定义一个存储集合用于存储要入库的数据
|
||||||
List<Map<String, Object>> dataList = new ArrayList<>();
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
||||||
// TODO: 这里要读表作对比然后存入数据库
|
|
||||||
if (location.equals("1#高炉中控室")) {
|
// 循环遍历所有设备配置
|
||||||
// 如果是1#高炉中控室,td1的值为1#高炉中控室(上)的CO浓度,t2td1的值为1#高炉中控室(下)的CO浓度。
|
for (PageData target : targetAllList) {
|
||||||
if (parma.containsKey("td1")) {
|
String displayArea = target.getString("DISPLAY_AREA");
|
||||||
// 如果包含td1,证明1#高炉中控室(上)的CO浓度有值 将一氧化碳的浓度值、所属设备编码(EQUIPMENT_ID)、预警阈值传入方法
|
String bitNo = target.getString("BIT_NO");
|
||||||
dataList.add(saveData(parma.get("td1"), "8eab7aff5585192b028e9592e2a6c6e9", targetAllList, processingBatchId, processingTime));
|
String equipmentId = target.getString("EQUIPMENT_ID");
|
||||||
}
|
|
||||||
if (parma.containsKey("t2td1")) {
|
// 检查DISPLAY_AREA是否匹配传入的location
|
||||||
dataList.add(saveData(parma.get("t2td1"), "cf0c414e21e0413aac3ac53e53c33058", targetAllList, processingBatchId, processingTime));
|
if (location != null && location.equals(displayArea) && bitNo != null) {
|
||||||
}
|
// 直接使用BIT_NO作为参数key查找对应的值
|
||||||
} else if (location.equals("2#高炉中控室")) {
|
if (parma.containsKey(bitNo)) {
|
||||||
if (parma.containsKey("td1")) {
|
String currentValue = parma.get(bitNo);
|
||||||
dataList.add(saveData(String.valueOf(Double.parseDouble(parma.get("td1")) / 10), "5787b69539465c1221c4eb2b9bf00168", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
// 添加到数据列表
|
||||||
if (parma.containsKey("t2td1")) {
|
dataList.add(saveData(currentValue, equipmentId, targetAllList, processingBatchId, processingTime));
|
||||||
dataList.add(saveData(parma.get("t2td1"), "90313d5f6a22cefcd2ea44c871481723", targetAllList, processingBatchId, processingTime));
|
}
|
||||||
}
|
|
||||||
} else if (location.equals("3#高炉中控室")) {
|
|
||||||
if (parma.containsKey("td24")) {
|
|
||||||
dataList.add(saveData(parma.get("td24"), "bdd20ccfe7c356a350d4bbc1d0390f97", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
if (parma.containsKey("t2td1")) {
|
|
||||||
dataList.add(saveData(parma.get("t2td1"), "8cf0093ec99a1d09cac2e8bc207c0d8b", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
} else if (location.equals("4#高炉中控室")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "49a8b00f779007f09c0fbd5afeccb75a", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
if (parma.containsKey("t2td1")) {
|
|
||||||
dataList.add(saveData(parma.get("t2td1"), "3737a215ef2f5a774703cd69f2952d3c", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
} else if (location.equals("一烧中控室")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "7c7ab19b8b862e6febac8e72e2bcecaa", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
}else if (location.equals("二烧中控室")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "8e3854150d46d7fa9769cf6d5dc0cfa8", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
} else if (location.equals("型钢中控室")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "da04c8ae4e7b2bacaafae391a3baa0aa", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
if (parma.containsKey("t2td1")) {
|
|
||||||
dataList.add(saveData(parma.get("t2td1"), "60ef896d9f6af5705430cf6aa8d52174", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
} else if (location.equals("15万高炉煤气柜中控室")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "07d5be0f912ae11418772b39d447665b", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
|
||||||
} else if (location.equals("新跨大包热修")) {
|
|
||||||
if (parma.containsKey("td1")) {
|
|
||||||
dataList.add(saveData(parma.get("td1"), "188624b575d36e4bc2cffd57c78b3314", targetAllList, processingBatchId, processingTime));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 存储集合中处理好的数据
|
|
||||||
mesDeviceMonitoringMapper.saveBatchFromMes(dataList);
|
|
||||||
|
|
||||||
// 将物联网数据存入Redis缓存
|
// 存储集合中处理好的数据
|
||||||
redisUtil.set("WMK_DATA_LIST", JSONObject.toJSONString(dataList));
|
if (!dataList.isEmpty()) {
|
||||||
XxlJobHelper.log("成功保存{}条物联网模块数据到本地数据库", dataList.size());
|
mesDeviceMonitoringMapper.saveBatchFromMes(dataList);
|
||||||
|
// 将物联网数据存入Redis缓存
|
||||||
|
redisUtil.set("WMK_DATA_LIST", JSONObject.toJSONString(dataList));
|
||||||
|
XxlJobHelper.log("成功保存{}条物联网模块数据到本地数据库", dataList.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定义一个通用的保存数据的方法
|
// 定义一个通用的保存数据的方法
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ public interface TbIronPlcMapper {
|
||||||
|
|
||||||
ArrayList<HashMap<String,String>> listAll ();
|
ArrayList<HashMap<String,String>> listAll ();
|
||||||
|
|
||||||
|
List<PageData> listMQTarget();
|
||||||
|
|
||||||
List<PageData> listTargetByEquId();
|
List<PageData> listTargetByEquId();
|
||||||
|
|
||||||
List<PageData> listDustDeviceAll();
|
List<PageData> listDustDeviceAll();
|
||||||
|
|
@ -23,23 +25,11 @@ public interface TbIronPlcMapper {
|
||||||
*/
|
*/
|
||||||
List<PageData> listRealtimeDataByEquipmentId(String equipmentId);
|
List<PageData> listRealtimeDataByEquipmentId(String equipmentId);
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量插入数据到实时表
|
|
||||||
* @param dataList 数据列表
|
|
||||||
*/
|
|
||||||
void insertBatchToRealtime(List<Map<String, Object>> dataList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单条插入数据到实时表
|
* 单条插入数据到实时表
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
*/
|
*/
|
||||||
void insertToRealtime(Map<String, Object> data);
|
void insertToRealtime(Map<String, Object> data);
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量更新从MES获取的数据
|
|
||||||
* @param dataList 数据列表
|
|
||||||
*/
|
|
||||||
void updateBatchToRealtime(List<Map<String, Object>> dataList);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单条更新从MES获取的数据
|
* 单条更新从MES获取的数据
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,38 @@
|
||||||
p.CORPINFO_ID = '499d43c24fab49f59391ce49fb401837' and p.ISDELETE = 0 and mt.ISDELETE = 0
|
p.CORPINFO_ID = '499d43c24fab49f59391ce49fb401837' and p.ISDELETE = 0 and mt.ISDELETE = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="listMQTarget" resultType="com.zcloud.entity.PageData">
|
||||||
|
SELECT
|
||||||
|
p.PLC_ID,
|
||||||
|
p.PLC_NAME,
|
||||||
|
p.IPCDEVICE_ID,
|
||||||
|
p.EQUIPMENT_ID,
|
||||||
|
e.DEVICE_TYPE,
|
||||||
|
mt.TARGET_NAME,
|
||||||
|
mt.TARGET_TYPE,
|
||||||
|
mt.TARGET_PLACE,
|
||||||
|
mt.TARGET_UNIT,
|
||||||
|
mt.THRESHOLD_UP_LIMIT,
|
||||||
|
mt.THRESHOLD_UP_UP_LIMIT,
|
||||||
|
mt.THRESHOLD_DOWN_LIMIT,
|
||||||
|
mt.THRESHOLD_DOWN_DOWN_LIMIT,
|
||||||
|
mt.RANGE_UP,
|
||||||
|
mt.RANGE_DOWN,
|
||||||
|
mt.TARGET_DESCRIPTION,
|
||||||
|
mt.BIT_NO,
|
||||||
|
mt.SIGNAL_TYPE,
|
||||||
|
mt.ALARM_VALUE,
|
||||||
|
mt.TARGET_STATUS,
|
||||||
|
p.CORPINFO_ID,
|
||||||
|
mt.REPORT_ID
|
||||||
|
FROM
|
||||||
|
tb_iron_plc p
|
||||||
|
LEFT JOIN tb_iron_equipment_info e on p.EQUIPMENT_ID = e.EQUIPMENT_ID
|
||||||
|
LEFT JOIN tb_iron_monitoring_target mt on mt.PLC_ID = p.PLC_ID
|
||||||
|
WHERE
|
||||||
|
p.CORPINFO_ID = '499d43c24fab49f59391ce49fb401837' and p.ISDELETE = 0 and mt.ISDELETE = 0 and e.DEVICE_TYPE = 'gdsyyhtbjq01'
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="listDustDeviceAll" resultType="com.zcloud.entity.PageData">
|
<select id="listDustDeviceAll" resultType="com.zcloud.entity.PageData">
|
||||||
SELECT
|
SELECT
|
||||||
dds.DEVICE_SENSOR_ID as PLC_ID,
|
dds.DEVICE_SENSOR_ID as PLC_ID,
|
||||||
|
|
@ -64,7 +96,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 查询填报的数据上下限高低值范围 -->
|
<!-- 查询全部设备填报的数据上下限高低值范围 -->
|
||||||
<select id="listTargetByEquId" resultType="com.zcloud.entity.PageData">
|
<select id="listTargetByEquId" resultType="com.zcloud.entity.PageData">
|
||||||
SELECT
|
SELECT
|
||||||
p.PLC_ID,
|
p.PLC_ID,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue