From 930d29f39d115fe76c305af4320c2acbcb30c445 Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期四, 12 六月 2025 10:37:37 +0800
Subject: [PATCH] 优化SQL
---
igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv2/msg/AnalysisService.java | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv2/msg/AnalysisService.java b/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv2/msg/AnalysisService.java
index 3a46bff..49c51b5 100644
--- a/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv2/msg/AnalysisService.java
+++ b/igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv2/msg/AnalysisService.java
@@ -81,6 +81,7 @@
ser.setPort(message.getPort());
ser.setStatus(Constant.YN_Y);
coreSerService.updateByData(ser);
+ log.info("涓绘満------->>骞冲彴锛氭敞鍐屾垚鍔燂紝鍒嗘満淇℃伅={}", ser);
}
return;
}
@@ -164,7 +165,7 @@
//濡傛灉褰撳墠鍖呯殑鏁版嵁涓暟澶т簬绛変簬褰撳墠浠撳簱鐨勯厤缃偣浣嶅垯琛ㄧず鍗曞寘杩斿洖
if (curPoint >= sumPoint) {
-
+ log.info("鍒嗘満------>>>骞冲彴锛氱伯鎯呮暟鎹崟鍖�=" + grainHex);
//杩斿洖绮儏鎺ユ敹淇℃伅
replayGrain(message);
@@ -188,11 +189,12 @@
if (grainHex.length() >= sumPoint * 4) {
//杩斿洖绮儏鎺ユ敹淇℃伅
replayGrain(message);
-
+ log.info("鍒嗘満------>>>骞冲彴锛氱伯鎯呮暟鎹鍖咃紝瀹屾暣鏁版嵁=" + grainHex);
analysisGrain2(ser, message, exeRequest, depotConf, sysConf, batchId, grainHex);
return;
} else {
+ log.info("鍒嗘満------>>>骞冲彴锛氬皢绗竴鍖呮暟鎹瓨鍏ュ唴瀛�=" + grainHex);
contextMapGrain.put(key, grainHex);
replayGrain(message);
}
@@ -207,7 +209,8 @@
*
* @param message
*/
- private void replayGrain(IoMessage message) {
+ private void replayGrain(IoMessage message) throws InterruptedException {
+ Thread.sleep(50);
String hexStr = CommandBuild.getMsgGrainReply(message.getAddr());
log.info("骞冲彴--------->>>涓绘満锛岃繑鍥炵伯鎯呮姤鏂囨敹鍒颁俊鎭紝鎶ユ枃={}", hexStr);
serverEngine.push(message.getIp(),message.getPort(),BytesUtil.hexStrToBytes(hexStr));
@@ -431,27 +434,41 @@
try {
THDto th = new THDto();
th.setCompanyId(ContextUtil.getDefaultCompanyId());
+
String data = message.getContent();
- String houseNo = data.substring(0, 2);
+ String houseNo = data.substring(0, 4);
+ int depotId = BytesUtil.hexToInt(BytesUtil.tran_LH(houseNo));
String t = data.substring(4, 8);
String h = data.substring(8, 12);
- double temp, humy;
+ double humy;
+ String temp;
+ int symbol = 0; //绗﹀彿浣�
+ double tempValue;
if (ReMessageBuilder.ERROR_TAG.equals(t)) {
- temp = 0.0;
+ temp = "0000";
} else {
- temp = (double) BytesUtil.hexToBigInt(BytesUtil.tran_LH(t)) / 10;
+ temp = BytesUtil.tran_LH(t);
}
+ temp = BytesUtil.hexString2binaryString(temp, 16);
+
+ //绗﹀彿浣�
+ symbol = Integer.valueOf(temp.substring(0, 1));
+ //鑾峰彇娓╁害鍊�
+ tempValue = BytesUtil.biannary2Decimal(temp.substring(6))/10;
+ //鑻ヤ负璐燂紝鍒欒ˉ鐮侊細鍙栧弽鍔�1
+ if (symbol == 1) {
+ tempValue = 0.0 - BytesUtil.twoToString(temp)/10;
+ }
+ th.setTempIn(tempValue);
if (ReMessageBuilder.ERROR_TAG.equals(h)) {
humy = 0.0;
} else {
humy = (double) BytesUtil.hexToBigInt(BytesUtil.tran_LH(h)) / 10;
}
-
- th.setTempIn(temp);
th.setHumidityIn(humy);
- log.info("涓绘満--------->>>骞冲彴锛岃В鏋愪粨娓╀粨婀夸俊鎭紝浠撳簱={},缁撴灉={}", houseNo, th.toString());
+ log.info("涓绘満--------->>>骞冲彴锛岃В鏋愪粨娓╀粨婀夸俊鎭紝浠撳簱={},缁撴灉={}", depotId, th.toString());
- String key = "TH_" + houseNo;
+ String key = "TH_" + depotId;
contextMapTH.put(key, th);
} catch (Exception e) {
@@ -466,8 +483,8 @@
private THDto getTH(IoMessage message) {
String data = message.getContent();
String houseNo = data.substring(0, 2);
-
- String key = "TH_" + houseNo;
+ Integer depotId = BytesUtil.hexToInt(houseNo);
+ String key = "TH_" + depotId;
return contextMapTH.get(key);
}
--
Gitblit v1.9.3