Преглед на файлове

博海数据同步发送测试

lloyd преди 2 месеца
родител
ревизия
2f1403b1a7

+ 3 - 1
.gitignore

@@ -12,4 +12,6 @@ target
12 12
 
13 13
 logs
14 14
 !**/nacos/target
15
-data/gtcvr.db
15
+data/gtcvr.db
16
+/data/dump/
17
+/data/

BIN
release/gtcvr.db


+ 0 - 2
src/main/java/com/gct/edge/entity/BhRtuData.java

@@ -19,8 +19,6 @@ import lombok.experimental.Accessors;
19 19
 @Accessors(chain = true)
20 20
 public class BhRtuData extends Model<BhRtuData> {
21 21
 
22
-    private static final long serialVersionUID=1L;
23
-    
24 22
     private String wellId;
25 23
     
26 24
     private String prodDate;

+ 1 - 0
src/main/java/com/gct/edge/service/excutor/DataSendService.java

@@ -3,6 +3,7 @@ package com.gct.edge.service.excutor;
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 5
 import com.baomidou.mybatisplus.extension.service.IService;
6
+import com.gct.edge.entity.BhRtuData;
6 7
 import com.gct.edge.entity.DumpRecord;
7 8
 import com.gct.edge.service.abst.DumpRecordService;
8 9
 import com.gct.edge.service.abst.AoidProdStateService;

+ 13 - 10
src/main/java/com/gct/edge/service/excutor/ModbusReadService.java

@@ -67,7 +67,15 @@ public class ModbusReadService {
67 67
                 List<List<Double>> sgt = readBody.card;
68 68
                 Double s = readBody.s;
69 69
                 Double n = readBody.n;
70
-                String prodTime = readBody.prodTime;
70
+                String prodTime = LocalDateTime.now().format(df);
71
+                String checkTime = readBody.prodTime;
72
+                //bh  data read save
73
+                BHModbusDataBody bhModbusDataBody = ModbusRTUReader.readBHBody();
74
+                BhRtuData data = JSONObject.toJavaObject((JSON) JSONObject.toJSON(bhModbusDataBody), BhRtuData.class);
75
+                data.setWellId(aoidConfigData.getJh());
76
+                data.setProdDate(prodTime);
77
+                bhRtuDataService.save(data);
78
+
71 79
                 if (Objects.isNull(sgt) || Objects.isNull(s) || Objects.isNull(n) ||Objects.isNull(prodTime) || s < 1e-6 || n < 1e-6) {
72 80
                     log.error("read Rtu modbus failed, sgt: {},s: {},n: {},prodTime: {}", sgt, s, n, prodTime);
73 81
                     continue;
@@ -78,12 +86,12 @@ public class ModbusReadService {
78 86
                 if (Objects.isNull(lastDumpRecord)){
79 87
                     lastDumpRecord = new DumpRecord();
80 88
                     lastDumpRecord.setTableName(aoidConfigData.getJh());
81
-                    lastDumpRecord.setDumpTime(prodTime);
89
+                    lastDumpRecord.setDumpTime(checkTime);
82 90
                     dumpRecordService.save(lastDumpRecord);
83 91
                 }else {
84
-                    if (lastDumpRecord.getDumpTime().equals(prodTime))continue;
92
+                    if (lastDumpRecord.getDumpTime().equals(checkTime))continue;
85 93
                     else {
86
-                        lastDumpRecord.setDumpTime(prodTime);
94
+                        lastDumpRecord.setDumpTime(checkTime);
87 95
                         dumpRecordService.update(lastDumpRecord,new QueryWrapper<DumpRecord>().eq("table_name", aoidConfigData.getJh()));
88 96
                     }
89 97
                 }
@@ -97,12 +105,7 @@ public class ModbusReadService {
97 105
                 executor.submit(new CalculateInputData(aoidConfigData.getJh(), LocalDateTime.parse(prodTime, df), s, n, sgtDouble));
98 106
 
99 107
 
100
-                //bh  data read save
101
-                BHModbusDataBody bhModbusDataBody = ModbusRTUReader.readBHBody();
102
-                BhRtuData data = JSONObject.toJavaObject((JSON) JSONObject.toJSON(bhModbusDataBody), BhRtuData.class);
103
-                data.setWellId(aoidConfigData.getJh());
104
-                data.setProdDate(prodTime);
105
-                bhRtuDataService.save(data);
108
+
106 109
             } catch (Exception e) {
107 110
                 log.error("readDataAndSubmitTask error, detail: {}, cause: {}", e.getMessage(),e.getCause());
108 111
             }

+ 4 - 2
src/main/java/com/gct/etl/ModbusRTUReader.java

@@ -186,6 +186,8 @@ public class ModbusRTUReader {
186 186
     }
187 187
 
188 188
     private static void connect() {
189
+        regConfig.serial.serialName = "COM3";
190
+        regConfig.serial.baudRate = 115200;//232口使用115200,485口注释此行
189 191
         System.out.printf("serial: %s, baudRate: %d, is485mode: %s%n", regConfig.serial.serialName, regConfig.serial.baudRate, regConfig.serial.isRs485);
190 192
         ModbusSerialMaster master = masterCache.get(regConfig.serial);
191 193
         if (Objects.nonNull(master) && master.isConnected()) return;
@@ -283,8 +285,8 @@ public class ModbusRTUReader {
283 285
                 String setMethodName = "set" + filedName;
284 286
                 ModbusReadConfig.Section regConfig = (ModbusReadConfig.Section) BHModbusReadConfig.class.getMethod(getMethodName).invoke(readConfig);
285 287
                 if (Objects.isNull(regConfig)) continue;
286
-                if (element.getType().equals(Double.class)) {
287
-                    BHModbusDataBody.class.getMethod(setMethodName,Double.class).invoke(body, readFloatSingle(regConfig, new ByteToFloat()));
288
+                if (element.getType().equals(Float.class)) {
289
+                    BHModbusDataBody.class.getMethod(setMethodName,Float.class).invoke(body, readFloatSingle(regConfig, new ByteToFloat()));
288 290
                 } else if (element.getType().equals(Integer.class)) {
289 291
                     BHModbusDataBody.class.getMethod(setMethodName,Integer.class).invoke(body, readIntegerSingle(regConfig, new DefaultParser()));
290 292
                 }