From e875693d8cb4c5fb8ab1dc014bedfed2a4c13c3e Mon Sep 17 00:00:00 2001
From: songwenxuan <1924103812@qq.com>
Date: Tue, 30 Sep 2025 12:00:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=B1=B1=E8=A5=BF=E6=AD=A3=E5=BC=8F=E9=85=8D?=
=?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 10 +--
.../controller/AppPosiDeviceController.java | 74 ++++++++++++++-----
.../dataDocking/MesDataScheduled.java | 15 ++--
.../resources/application-local.properties | 6 +-
.../datasource/tbIron/TbIronPlcMapper.xml | 3 +-
5 files changed, 73 insertions(+), 35 deletions(-)
diff --git a/pom.xml b/pom.xml
index 098f844..ddca550 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,12 @@
4.0.0
com.zcloud
- integrated_yjb_scheduled
+ sx_yjb_scheduled
0.0.1-SNAPSHOT
war
- integrated_yjb_scheduled
- integrated_yjb_scheduled for Spring Boot
+ sx_yjb_scheduled
+ sx_yjb_scheduled for Spring Boot
org.springframework.boot
@@ -451,7 +451,7 @@
-
- integrated_yjb_scheduled
+ sx_yjb_scheduled
org.springframework.boot
diff --git a/src/main/java/com/zcloud/controller/AppPosiDeviceController.java b/src/main/java/com/zcloud/controller/AppPosiDeviceController.java
index 5ca226c..05c2c19 100644
--- a/src/main/java/com/zcloud/controller/AppPosiDeviceController.java
+++ b/src/main/java/com/zcloud/controller/AppPosiDeviceController.java
@@ -1,20 +1,17 @@
package com.zcloud.controller;
+import com.alibaba.fastjson.JSONObject;
import com.xxl.job.core.context.XxlJobHelper;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.tbIron.TbIronPlcMapper;
import com.zcloud.mapper.dsno2.target.MesDeviceMonitoringMapper;
-import com.zcloud.util.DateUtil;
-import com.zcloud.util.R;
-import com.zcloud.util.Tools;
-import com.zcloud.util.UuidUtil;
+import com.zcloud.util.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
-import javax.tools.Tool;
import java.util.*;
import java.util.stream.Collectors;
@@ -28,8 +25,29 @@ public class AppPosiDeviceController {
@Resource
private MesDeviceMonitoringMapper mesDeviceMonitoringMapper;
+ @Resource
+ private RedisUtil redisUtil;
+
@PostMapping("/test1")
public R test1(@RequestBody HashMap parma) throws Exception {
+ System.out.println("测试接口,请更换正式接口!");
+ // 打印接收的数据 排序分类显示
+ printReceiveData(parma);
+ // 批量存储数据
+ batchInsert(parma);
+ return R.ok();
+ }
+
+ @PostMapping("/receiver")
+ public R receiver(@RequestBody HashMap parma) throws Exception {
+ // 打印接收的数据 排序分类显示
+ printReceiveData(parma);
+ // 批量存储数据
+ batchInsert(parma);
+ return R.ok();
+ }
+
+ void printReceiveData(HashMap parma) {
System.out.println("———————————————————————————————————————————————————————————————————————————————————————————————————————————");
// 1. 初始化分组Map,确保键唯一(使用LinkedHashMap保持插入顺序,可选)
Map>> groupMap = new LinkedHashMap<>();
@@ -72,7 +90,6 @@ public class AppPosiDeviceController {
System.out.println("【" + prefix + "组】:" + groupContent);
});
System.out.println("———————————————————————————————————————————————————————————————————————————————————————————————————————————");
- return R.ok();
}
/**
@@ -130,9 +147,7 @@ public class AppPosiDeviceController {
}
}
- @PostMapping("/receiver")
- public R receiver(@RequestBody HashMap parma) throws Exception {
- System.out.println("parma数据:" +parma);
+ void batchInsert(HashMap parma) {
// 定义处理批次数据 ID
String processingBatchId = UuidUtil.get32UUID();
// 批处理时间
@@ -153,19 +168,35 @@ public class AppPosiDeviceController {
} else if (parma.containsKey("t2td1")) {
dataList.add(saveData(parma.get("t2td1"), "cf0c414e21e0413aac3ac53e53c33058", targetAllList, processingBatchId, processingTime));
}
- } else if (location.equals("2#高炉控制室")) {
- System.out.println("2#高炉控制室");
- } else if (location.equals("3#高炉控制室")) {
- System.out.println("3#高炉控制室");
- } else if (location.equals("型钢加热炉")) {
- System.out.println("型钢加热炉");
- } else if (location.equals("15万高炉煤气柜")) {
- System.out.println("15万高炉煤气柜");
+ } else if (location.equals("2#高炉中控室")) {
+ if (parma.containsKey("t2td1")) {
+ dataList.add(saveData(parma.get("t2td1"), "90313d5f6a22cefcd2ea44c871481723", targetAllList, processingBatchId, processingTime));
+ }
+ } else if (location.equals("3#高炉中控室")) {
+ if (parma.containsKey("t2td1")) {
+ dataList.add(saveData(parma.get("t2td1"), "8cf0093ec99a1d09cac2e8bc207c0d8b", targetAllList, processingBatchId, processingTime));
+ }
+ } else if (location.equals("型钢中控室")) {
+ if (parma.containsKey("td1")) {
+ dataList.add(saveData(parma.get("td1"), "da04c8ae4e7b2bacaafae391a3baa0aa", targetAllList, processingBatchId, processingTime));
+ } else 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));
XxlJobHelper.log("成功保存{}条物联网模块数据到本地数据库", dataList.size());
- return R.ok();
}
// 定义一个通用的保存数据的方法
@@ -176,13 +207,14 @@ public class AppPosiDeviceController {
HashMap data = new HashMap<>();
data.put("MONITORING_ID", UuidUtil.get32UUID());
data.put("CURRENT_VALUE", CURRENT_VALUE);
- data.put("PROCESSING_TIME", processingBatchId);
- data.put("PROCESSING_BATCH_ID", processingTime);
+ data.put("PROCESSING_TIME", processingTime);
+ data.put("PROCESSING_BATCH_ID", processingBatchId);
data.put("INSERT_TIME", DateUtil.date2Str(new Date()));
data.put("WARNING", 0); // 是否告警 要完善相关告警逻辑进行判断
data.put("GATHER_TIME", 5);
data.put("PLC_NAME", "");
data.put("OVERVIEW_OF_ALERTS", "");
+ data.put("EQUIPMENT_ID", EQUIPMENT_ID);
// 每个设备只有一个监测数据阈值,也就是一氧化碳浓度
if (collect.size() > 0) {
PageData pageData = collect.get(0);
@@ -204,6 +236,7 @@ public class AppPosiDeviceController {
data.put("ALARM_VALUE", pageData.getString("ALARM_VALUE"));
data.put("TARGET_STATUS", pageData.getString("TARGET_STATUS"));
data.put("CORPINFO_ID", pageData.getString("CORPINFO_ID"));
+ data.put("REPORT_ID", pageData.getString("REPORT_ID"));
} else {
data.put("IPCDEVICE_ID", "");
data.put("PLC_ID", "");
@@ -222,6 +255,7 @@ public class AppPosiDeviceController {
data.put("ALARM_VALUE", "");
data.put("TARGET_STATUS", "");
data.put("CORPINFO_ID", "");
+ data.put("REPORT_ID", "");
}
return data;
}
diff --git a/src/main/java/com/zcloud/scheduled/dataDocking/MesDataScheduled.java b/src/main/java/com/zcloud/scheduled/dataDocking/MesDataScheduled.java
index f2aec8a..2cd2ad3 100644
--- a/src/main/java/com/zcloud/scheduled/dataDocking/MesDataScheduled.java
+++ b/src/main/java/com/zcloud/scheduled/dataDocking/MesDataScheduled.java
@@ -73,6 +73,7 @@ public class MesDataScheduled extends IJobHandler {
}
@Scheduled(cron ="*/5 * * * * ?")
+// @Scheduled(cron ="0 0/5 * * * ?")
public void scheduled() throws Exception {
this.execute();
}
@@ -145,8 +146,8 @@ public class MesDataScheduled extends IJobHandler {
mesData.put("MONITORING_ID", UuidUtil.get32UUID());
mesData.put("TARGET_NAME", key);
mesData.put("CURRENT_VALUE", map.get(key));
- mesData.put("PROCESSING_TIME", processingBatchId);
- mesData.put("PROCESSING_BATCH_ID", processingTime);
+ mesData.put("PROCESSING_TIME", processingTime);
+ mesData.put("PROCESSING_BATCH_ID", processingBatchId);
mesData.put("INSERT_TIME", DateUtil.date2Str(new Date()));
mesData.put("WARNING", 0); // 是否告警 要完善相关告警逻辑进行判断
mesData.put("GATHER_TIME", 5);
@@ -171,16 +172,16 @@ public class MesDataScheduled extends IJobHandler {
} else if (suffix.equals("A2") || suffix.equals("B2")) {
mesData.put("EQUIPMENT_ID", "2c83b99df54e80a674be5657b11db55c");
collect = zl2TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
- } else if (key.equals("TAG325") || key.equals("TAG326") || key.equals("TAG317") || key.equals("TAG318")) {
+ } else if (key.contains("1#")) {
mesData.put("EQUIPMENT_ID", "c6825a6e1c959c3e5c800433516b2e8d");
collect = gl1TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
- } else if (key.equals("TAG327") || key.equals("TAG328") || key.equals("TAG319") || key.equals("TAG320")) {
+ } else if (key.contains("2#")) {
mesData.put("EQUIPMENT_ID", "7face71b8cb7b47872cbe94f9b16831d");
collect = gl2TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
- } else if (key.equals("TAG329") || key.equals("TAG330") || key.equals("TAG321") || key.equals("TAG322")) {
+ } else if (key.contains("3#")) {
mesData.put("EQUIPMENT_ID", "2cb052450581597064b510118c076e2a");
collect = gl3TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
- } else if (key.equals("TAG331") || key.equals("TAG332") || key.equals("TAG333") || key.equals("TAG334") || key.equals("TAG323") || key.equals("TAG324")) {
+ } else if (key.contains("4#")) {
mesData.put("EQUIPMENT_ID", "67c2e8315ca57d68201762e4ce9db351");
collect = gl4TargetList.stream().filter(item -> item.getString("TARGET_NAME").equals(key)).collect(Collectors.toList());
}
@@ -203,6 +204,7 @@ public class MesDataScheduled extends IJobHandler {
mesData.put("ALARM_VALUE", pageData.getString("ALARM_VALUE"));
mesData.put("TARGET_STATUS", pageData.getString("TARGET_STATUS"));
mesData.put("CORPINFO_ID", pageData.getString("CORPINFO_ID"));
+ mesData.put("REPORT_ID", pageData.getString("REPORT_ID"));
} else {
mesData.put("IPCDEVICE_ID", "");
mesData.put("PLC_ID", "");
@@ -221,6 +223,7 @@ public class MesDataScheduled extends IJobHandler {
mesData.put("ALARM_VALUE", "");
mesData.put("TARGET_STATUS", "");
mesData.put("CORPINFO_ID", "");
+ mesData.put("REPORT_ID", "");
}
mesSaveList.add(mesData);
}
diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties
index 3b304d0..c7e49a1 100644
--- a/src/main/resources/application-local.properties
+++ b/src/main/resources/application-local.properties
@@ -1,10 +1,10 @@
datasource.no1.driver-class-name: com.mysql.cj.jdbc.Driver
-datasource.no1.url=jdbc:mysql://172.16.112.250:33080/sx_yjb?allowPublicKeyRetrieval=true&serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8
+datasource.no1.url=jdbc:mysql://172.16.70.228:33080/sx_yjb?allowPublicKeyRetrieval=true&serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8
datasource.no1.username=root
datasource.no1.password=Mysql@zcloud33080
#
datasource.no2.driver-class-name:org.postgresql.Driver
-datasource.no2.url=jdbc:postgresql://172.16.112.250:15431/postgres?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=UTC
+datasource.no2.url=jdbc:postgresql://172.16.70.228:15431/postgres?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=UTC
datasource.no2.username=postgres
datasource.no2.password=Mysql@zcloud15431
#MES系统数据库配置
@@ -17,7 +17,7 @@ datasource.mes2.url=jdbc:oracle:thin:@172.16.90.227:1521/emsdb
datasource.mes2.username=drzf
datasource.mes2.password=drzf
#redis
-spring.redis.host=172.16.112.251
+spring.redis.host=172.16.70.226
spring.redis.password=Zcloud@redis16379
spring.redis.database=10
spring.redis.port=16379
diff --git a/src/main/resources/mybatis/datasource/tbIron/TbIronPlcMapper.xml b/src/main/resources/mybatis/datasource/tbIron/TbIronPlcMapper.xml
index 0d9c641..e9ec525 100644
--- a/src/main/resources/mybatis/datasource/tbIron/TbIronPlcMapper.xml
+++ b/src/main/resources/mybatis/datasource/tbIron/TbIronPlcMapper.xml
@@ -60,7 +60,8 @@
p.CREATTIME,
p.OPERATOR,
p.OPERATTIME,
- p.ISDELETE
+ p.ISDELETE,
+ p.REPORT_ID
from
tb_iron_monitoring_target p
left join tb_iron_plc plc ON p.PLC_ID = plc.PLC_ID