diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5d8db9a..fd4943d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,9 +5,14 @@
-
-
+
+
+
+
+
+
+
@@ -31,8 +36,7 @@
@@ -86,8 +90,9 @@
"RunOnceActivity.git.unshallow": "true",
"Spring Boot.WebServerApplication.executor": "Debug",
"git-widget-placeholder": "master",
+ "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/andy/ideaWorker/station-control/web-server/src/main/resources/mapper",
+ "last_opened_file_path": "E:/andy/ideaWorker/station-control",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@@ -96,7 +101,7 @@
"project.structure.last.edited": "Project",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.2",
- "settings.editor.selected.configurable": "fileTemplates",
+ "settings.editor.selected.configurable": "MavenSettings",
"vue.rearranger.settings.migration": "true"
}
}
@@ -216,9 +221,9 @@
-
+
@@ -380,7 +385,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -390,11 +418,24 @@
-
+
file://$PROJECT_DIR$/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java
- 1480
+ 73
+
+
+
+
+
+ file://$PROJECT_DIR$/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java
+ 491
+
+
+
+
+
+
diff --git a/commoms/core/src/main/resources/application-core.yml b/commoms/core/src/main/resources/application-core.yml
index e0f2b41..e7cdd00 100644
--- a/commoms/core/src/main/resources/application-core.yml
+++ b/commoms/core/src/main/resources/application-core.yml
@@ -2,4 +2,4 @@
ythd:
cloud-private-key: MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALEbx7j2XmAo3NiviJIk8/Mo1RF4yT/MYmZdZRnB9iSh4koIiu/KKCGSwvViFGfmP/q8TNLWsvpTVo3MxWBFJkWaALuo/iPu5RJ+tU1l0YXA35zZNxMuiDbmnI7wODRePUY1g5fa1ZNy5oDUQumfrXhDCoFC2AMUBn9KiMr+QQ97AgMBAAECgYAk/lF8X/Gckkx28ktLg251Nu0yZhFbQxy2lwF8HNiGFE5I+nnS1l4FjTstuBvdC+oHPHerfm8J/IhSvBfqIOd6PulJyuh5s31cdc+2SDWUzh8sBm48YHlDfjltZG2ijgM7h/+uvw1gHwXH8JQGF7ZjWguD3TJfqZ/jPFsuxoLKOQJBAOsp+f7kS5VXg6ziKzCMlWOAEfrsAO5ZhLJNMtoirbMQZYUfYxUc3KFWQMT9i9O2M752NXoeUed8a1DjmfyxaX8CQQDAzPs5EPNfpfuGsvJ79lGsH8mZcw7VdjDzmwNVVLLnSOaJxQIPTusjEJ2YmBs+ifCF30VIDpkRd/DGaj4yNgAFAkEAorh1B+6objoUHviQshNU+3iO+HV9X3AJ5eaNHWuJjbH2zVqekOlbsTehsa1Pp7sXqt7YuhtoySjKiTo0PynzuQJBAJsvovsBANQ5VubJ/NH4py6je3LPIN6Cvs4mNJ2nikUN8bps38aQoEVeJ2ve6vcAsqAe4bYpQd3ErAIZHCzwOD0CQF8hDwEGx1S4nJQpB9rmSQhoNzaEJuJKXgpAxNCQ9g4kLRZE+hpZk1kPw+VjGalyyZkY5ilXkWnqsvrprn+wW7Y=
cloud-public-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCxG8e49l5gKNzYr4iSJPPzKNUReMk/zGJmXWUZwfYkoeJKCIrvyighksL1YhRn5j/6vEzS1rL6U1aNzMVgRSZFmgC7qP4j7uUSfrVNZdGFwN+c2TcTLog25pyO8Dg0Xj1GNYOX2tWTcuaA1ELpn614QwqBQtgDFAZ/SojK/kEPewIDAQAB
- static-public-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC32MZ8u1bK66Uj+Uh3eTfDLcGy4TosSLfksYvJBavX6fckS6vdV8VeYj9gQvTrB6b3VKIdsqf/uP4AjgiKlP34GVMfDr0bEPEccurEhs23QWSHGrVSJG5HPG0B1PBbRMMUwUkmQJxo65Ml6SSPyS/4ebdZ0qeY2/cWaK8laYj7sQIDAQAB
\ No newline at end of file
+ static-public-key: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDdc3YXAeVRGUCDjKLlc62i5tojX42DoIENqvfCX8Z2lFkalfgh0I01Qx+WeaxWxqnovv4gy32RN2bPxjKXNhK2krZ4Or9uXcbkC66rowBACesrYs/MNcFvmVZH7tLVIXTkBkE2XS20FNYeoyc0dCZ3/kgXlfxty6ztIwCmRGQpAQIDAQAB
\ No newline at end of file
diff --git a/commoms/mongodb/src/main/resources/application-mongoDev.yml b/commoms/mongodb/src/main/resources/application-mongoDev.yml
index 33ae722..7578069 100644
--- a/commoms/mongodb/src/main/resources/application-mongoDev.yml
+++ b/commoms/mongodb/src/main/resources/application-mongoDev.yml
@@ -1,6 +1,6 @@
yt:
base_properties:
- host: 192.168.5.112
+ host: 192.168.5.232
port: 27017
#用于账号密码验证的库
authentication-database: admin
diff --git a/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java b/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java
index b454146..16405fb 100644
--- a/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java
+++ b/web-server/src/main/java/com/evotech/hd/webserver/controller/TestController.java
@@ -206,11 +206,17 @@ public class TestController {
Boolean result = false;
do{
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
+ errorCenCheck(rgvNo, category, 0);
+ if (checkJt(rgvNo, category, 0)) {
+ return;
+ }
if(result = InstructionReadUtils.getCenRbDoorOpenStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("%s 开合门已打开", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
}
}while (!result);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgvNo, category, "打开开合门出现异常=="+e.getMessage());
throw new RuntimeException("打开开合门出现异常:",e);
}
}
@@ -276,33 +282,6 @@ public class TestController {
return;
}
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s], 电池仓位[%s]>>>>>存入操作完成", (runNun+1), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo, targetPositionNo))));
-// InstructionWriteUtils.rgvResetToZero(rgvNo);
-// openResult = false;
-// do{
-// errorCheck(rgvNo, category, runNun);
-// if(checkJt(rgvNo, category, runNun)){
-// return;
-// }
-// Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
-// //跳开查询
-// if(openResult = executionBatterySwapService.executionOpenResult(rgvNo)){
-// WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s]>>>>>执行归位操作", (runNun+1), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()),rgvNo))));
-// endResult = false;
-// do{
-// errorCheck(rgvNo, category, runNun);
-// if(checkJt(rgvNo, category, runNun)){
-// return;
-// }
-// Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
-// //执行结束查询
-// if(endResult = executionBatterySwapService.executionResult(rgvNo)){
-// //输出
-// WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s]>>>>>归位操作完成",(runNun+1), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo))));
-// errorCheck(rgvNo, category, runNun);
-// }
-// }while(!endResult);
-// }
-// }while (!openResult);
}
}while(!endResult);
}
@@ -319,8 +298,12 @@ public class TestController {
message = JSONObject.toJSONString(error);
}
closeRunMap.put(rgvNo, new AtomicBoolean(true));
+ e.printStackTrace();
+ stopRgv(rgvNo, category, "执行取存电池出现异常=="+e.getMessage());
throw new RuntimeException(String.format(" 执行时间:[%s]; RRG:[%s] 出现异常; 机构区间为:{%s}; 执行类型为:{%s}; 执行次数为:{%s}; 异常信息为:{%s}",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo, category, "取存", (runNun+1), message), e);
} catch (InstructionException ex) {
+ ex.printStackTrace();
+ stopRgv(rgvNo, category, "执行取存电池出现异常=="+ex.getMessage());
throw new RuntimeException(ex);
}
}
@@ -375,32 +358,6 @@ public class TestController {
return;
}
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data", String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s]>>>>>执行装电池操作完成", (runNun+1),new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo))));
-// InstructionWriteUtils.rgvResetToZero(rgvNo);
-// openResult = false;
-// do {
-// errorCheck(rgvNo, category, runNun);
-// if(checkJt(rgvNo, category, runNun)){
-// return;
-// }
-// Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
-// //跳开查询
-// if (openResult = executionBatterySwapService.executionOpenResult(rgvNo)) {
-// WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data", String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s]>>>>>执行归位操作", (runNun+1),new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo))));
-// result = false;
-// do{
-// errorCheck(rgvNo, category, runNun);
-// if(checkJt(rgvNo, category, runNun)){
-// return;
-// }
-// Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
-// if(result = executionBatterySwapService.executionResult(rgvNo)){
-// //输出
-// WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("第[%s]次执行: 执行时间:[%s]; RRG:[%s]>>>>>归位操作完成",(runNun+1), new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo))));
-// errorCheck(rgvNo, category, runNun);
-// }
-// }while (!result);
-// }
-// }while (!openResult);
}
}while(!result);
}
@@ -416,9 +373,13 @@ public class TestController {
if(Collections.isNotEmpty(error)){
message = JSONObject.toJSONString(error);
}
+ e.printStackTrace();
+ stopRgv(rgvNo, category, "执行拆装电池操作=="+e.getMessage());
closeRunMap.put(rgvNo, new AtomicBoolean(true));
throw new RuntimeException(String.format(" 执行时间:[%s]; RRG:[%s] 出现异常; 机构区间为:{%s}; 执行类型为:{%s}; 执行次数为:{%s}; 异常信息为:{%s}",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()), rgvNo, category, "拆装", (runNun+1), message), e);
} catch (InstructionException ex) {
+ ex.printStackTrace();
+ stopRgv(rgvNo, category, "执行拆装电池操作=="+ex.getMessage());
throw new RuntimeException(ex);
}
}
@@ -434,12 +395,18 @@ public class TestController {
InstructionWriteUtils.closeCenDoor();
Boolean result = false;
do{
+ errorCenCheck(rgvNo, category, 0);
+ if (checkJt(rgvNo, category, 0)) {
+ return;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if(result = InstructionReadUtils.getCenRbDoorCloseStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("%s 开合门已关闭", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
}
}while (!result);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgvNo, category, "关闭开合门出现异常=="+e.getMessage());
throw new RuntimeException("关闭开合门出现异常:", e);
}
}
@@ -506,6 +473,16 @@ public class TestController {
}
+ public void errorCenCheck(final String rgvNo, final String category, final Integer runNun) throws Exception {
+ Map error = executionBatterySwapService.checkCenErrorInfo();
+ if(Collections.isNotEmpty(error)){
+ String message = JSONObject.toJSONString(error);
+ stopRgv(rgvNo, rgvNo, String.valueOf(error.get("errorMsg")));
+ throw new RuntimeException(String.format("RRG:[%s] 出现异常; 机构区间为:{%s}; 执行类型为:{%s}; 执行次数为:{%s}; 异常信息为:{%s}",rgvNo, category, "取存", (runNun+1), message));
+ }
+
+ }
+
@@ -514,13 +491,14 @@ public class TestController {
@ApiLog(value = "结束", type = LogTypeEnum.OPERATION)
public Result stop(@PathVariable("category") final String category, @RequestParam("rgvNo") final String rgvNo) throws Exception {
//检查RGV是否运作
- if(executionBatterySwapService.executionResult(rgvNo) && taskRgvMap.containsKey(rgvNo)){
- //睡了1秒再次检查, 防止空闲冲突
- Thread.sleep(1000);
- if(executionBatterySwapService.executionResult(rgvNo)){
- taskRgvMap.remove(rgvNo);
- }
- }else{
+// if(executionBatterySwapService.executionResult(rgvNo) && taskRgvMap.containsKey(rgvNo)){
+// //睡了1秒再次检查, 防止空闲冲突
+// Thread.sleep(1000);
+// if(executionBatterySwapService.executionResult(rgvNo)){
+// taskRgvMap.remove(rgvNo);
+// }
+// }else{
+ //不管rgv是否运作, 直接停止
CompletableFuture future = taskRgvMap.get(rgvNo);
future.cancel(true);
closeRunMap.put(rgvNo, new AtomicBoolean(true));
@@ -617,7 +595,7 @@ public class TestController {
taskRgvMap.remove(rgvNo);
}
});
- }
+// }
return Result.getInstance().success();
}
@@ -733,13 +711,25 @@ public class TestController {
InstructionWriteUtils.startCorrectInstitution();
Boolean openResult = false;
do {
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
//检查是否存在异常
if (openResult = executionBatterySwapService.checkCenOpenExecutionResult()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构正在执行", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
Boolean result = false;
do {
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
if(result = executionBatterySwapService.checkCenExecutionResult()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构已锁定", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
// 推送云端, 并查询是否存在异常 没有异常, 开始启动换电
return true;
}
@@ -748,6 +738,8 @@ public class TestController {
}
}while (!openResult);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, finalSplitStorageRgv, "启动对中机构出现异常=="+e.getMessage());
throw new RuntimeException("启动对中机构出现异常:",e);
}
return false;
@@ -764,13 +756,23 @@ public class TestController {
InstructionWriteUtils.openCenDoor();
Boolean result = false;
do{
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if(result = InstructionReadUtils.getCenRbDoorOpenStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 开合门已打开", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
return true;
}
}while (!result);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, finalSplitStorageRgv, "打开开合门出现异常=="+e.getMessage());
throw new RuntimeException("打开开合门出现异常:",e);
}
}
@@ -1048,14 +1050,24 @@ public class TestController {
InstructionWriteUtils.closeCenDoor();
Boolean result = false;
do{
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if(result = InstructionReadUtils.getCenRbDoorCloseStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("%s 开合门已关闭", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
return true;
}
}while (!result);
//开门完成
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, finalLoadingRgv, "关闭开合门出现异常=="+e.getMessage());
throw new RuntimeException("关闭开合门出现异常:", e);
}
}
@@ -1073,14 +1085,26 @@ public class TestController {
InstructionWriteUtils.closeCorrectInstitution();
Boolean openResult = false;
do {
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
//检查是否存在异常
if (openResult = executionBatterySwapService.checkCenOpenExecutionResult()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构正在执行", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
Boolean result = false;
do {
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
if(result = executionBatterySwapService.checkCenExecutionResult()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构已释放", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
// 推送云端, 并查询是否存在异常 没有异常, 开始启动换电
+ errorCenCheck(rgv, category, finalRunNun);
+ if (checkJt(rgv, category, finalRunNun)) {
+ return false;
+ }
return true;
}
}while (!result);
@@ -1088,6 +1112,8 @@ public class TestController {
}
}while (!openResult);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, finalLoadingRgv, e.getMessage());
throw new RuntimeException("释放对中机构出现异常:",e);
}
}
@@ -1159,13 +1185,14 @@ public class TestController {
String rgv = splitStorageRgvNo+"_"+takePackRgvNo;
//检查RGV是否运作
- if(executionBatterySwapService.executionResult(splitStorageRgvNo) && executionBatterySwapService.executionResult(takePackRgvNo) && taskRgvMap.containsKey(rgv)){
- //睡了1秒再次检查, 防止空闲冲突
- Thread.sleep(1000);
- if(executionBatterySwapService.executionResult(splitStorageRgvNo) && executionBatterySwapService.executionResult(takePackRgvNo)){
- taskRgvMap.remove(rgv);
- }
- }else{
+// if(executionBatterySwapService.executionResult(splitStorageRgvNo) && executionBatterySwapService.executionResult(takePackRgvNo) && taskRgvMap.containsKey(rgv)){
+// //睡了1秒再次检查, 防止空闲冲突
+// Thread.sleep(1000);
+// if(executionBatterySwapService.executionResult(splitStorageRgvNo) && executionBatterySwapService.executionResult(takePackRgvNo)){
+// taskRgvMap.remove(rgv);
+// }
+// }else{
+ //无论rgv是否运作, 直接定制
CompletableFuture future = taskRgvMap.get(rgv);
if(future == null){
return Result.getInstance().success("当前任务已停止");
@@ -1277,7 +1304,7 @@ public class TestController {
taskRgvMap.remove(rgv);
}
});
- }
+// }
return Result.getInstance().success();
}
@@ -1304,19 +1331,30 @@ public class TestController {
return;
}
//执行开门
+ int finalRunNun = runNun;
CompletableFuture openFuture = CompletableFuture.supplyAsync(() -> {
try {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method", "testRgv" + category, "data", String.format(" 执行时间:[%s]; 下发打开开合门命令", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
InstructionWriteUtils.openCenDoor();
Boolean result = false;
do {
+ errorCheck("door", category, finalRunNun);
+ if(checkJt("door", category, finalRunNun)){
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if (result = InstructionReadUtils.getCenRbDoorOpenStatus()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method", "testRgv" + category, "data", String.format(" 执行时间:[%s]; 开合门已打开", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCheck("door", category, finalRunNun);
+ if(checkJt("door", category, finalRunNun)){
+ return false;
+ }
return true;
}
} while (!result);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv("door", category, "打开开合门出现异常=="+e.getMessage());
throw new RuntimeException("打开开合门出现异常:", e);
}
return false;
@@ -1331,14 +1369,24 @@ public class TestController {
InstructionWriteUtils.closeCenDoor();
Boolean result = false;
do {
+ errorCheck("door", category, finalRunNun);
+ if(checkJt("door", category, finalRunNun)){
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if (result = InstructionReadUtils.getCenRbDoorCloseStatus()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method", "testRgv" + category, "data", String.format("%s 开合门已关闭", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCheck("door", category, finalRunNun);
+ if(checkJt("door", category, finalRunNun)){
+ return false;
+ }
return true;
}
} while (!result);
//开门完成
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv("door", category, "关闭开合门出现异常=="+e.getMessage());
throw new RuntimeException("关闭开合门出现异常:", e);
}
return false;
@@ -1458,13 +1506,25 @@ public class TestController {
InstructionWriteUtils.startCorrectInstitution();
Boolean openResult = false;
do {
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
//检查是否存在异常
if (openResult = executionBatterySwapService.checkCenOpenExecutionResult()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构正在执行", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
Boolean result = false;
do {
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
if(result = executionBatterySwapService.checkCenExecutionResult()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构已锁定", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
// 推送云端, 并查询是否存在异常 没有异常, 开始启动换电
return true;
}
@@ -1473,6 +1533,8 @@ public class TestController {
}
}while (!openResult);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, category, "启动对中机构出现异常=="+e.getMessage());
throw new RuntimeException("启动对中机构出现异常:",e);
}
return false;
@@ -1489,13 +1551,23 @@ public class TestController {
InstructionWriteUtils.openCenDoor();
Boolean result = false;
do{
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if(result = InstructionReadUtils.getCenRbDoorOpenStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 开合门已打开", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
return true;
}
}while (!result);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, category, "打开开合门出现异常=="+e.getMessage());
throw new RuntimeException("打开开合门出现异常:",e);
}
}
@@ -1723,14 +1795,24 @@ public class TestController {
InstructionWriteUtils.closeCenDoor();
Boolean result = false;
do{
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
Thread.sleep(ParamUtils.getInstructionIntervalRequestMilliseconds());
if(result = InstructionReadUtils.getCenRbDoorCloseStatus()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format("%s 开合门已关闭", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
return true;
}
}while (!result);
//开门完成
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, category, "关闭开合门出现异常=="+e.getMessage());
throw new RuntimeException("关闭开合门出现异常:", e);
}
}
@@ -1748,11 +1830,19 @@ public class TestController {
InstructionWriteUtils.closeCorrectInstitution();
Boolean openResult = false;
do {
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
//检查是否存在异常
if (openResult = executionBatterySwapService.checkCenOpenExecutionResult()) {
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构正在执行", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
Boolean result = false;
do {
+ errorCenCheck(rgv, category, 0);
+ if (checkJt(rgv, category, 0)) {
+ return false;
+ }
if(result = executionBatterySwapService.checkCenExecutionResult()){
WebSocketUtils.broadCastMessage(JSONObject.toJSONString(Collections.asMap("method","testRgv"+category,"data",String.format(" 执行时间:[%s]; 对中机构已释放", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())))));
// 推送云端, 并查询是否存在异常 没有异常, 开始启动换电
@@ -1763,6 +1853,8 @@ public class TestController {
}
}while (!openResult);
} catch (Exception e) {
+ e.printStackTrace();
+ stopRgv(rgv, category, "释放对中机构出现异常=="+e.getMessage());
throw new RuntimeException("释放对中机构出现异常:",e);
}
}
@@ -1830,21 +1922,22 @@ public class TestController {
String rgv = splitStorageRgvNo;
//检查RGV是否运作
- if(executionBatterySwapService.executionResult(splitStorageRgvNo) && taskRgvMap.containsKey(rgv)){
- //睡了1秒再次检查, 防止空闲冲突
- Thread.sleep(1000);
- if(executionBatterySwapService.executionResult(splitStorageRgvNo)){
- CompletableFuture future = taskRgvMap.get(rgv);
- if(future == null){
- return Result.getInstance().success("当前任务已停止");
- }
- future.cancel(true);
- closeRunMap.put(rgv, new AtomicBoolean(true));
- InstructionWriteUtils.rgvStopMove(splitStorageRgvNo);
- checkJt(rgv, category, 0);
- taskRgvMap.remove(rgv);
- }
- }else{
+// if(executionBatterySwapService.executionResult(splitStorageRgvNo) && taskRgvMap.containsKey(rgv)){
+// //睡了1秒再次检查, 防止空闲冲突
+// Thread.sleep(1000);
+// if(executionBatterySwapService.executionResult(splitStorageRgvNo)){
+// CompletableFuture future = taskRgvMap.get(rgv);
+// if(future == null){
+// return Result.getInstance().success("当前任务已停止");
+// }
+// future.cancel(true);
+// closeRunMap.put(rgv, new AtomicBoolean(true));
+// InstructionWriteUtils.rgvStopMove(splitStorageRgvNo);
+// checkJt(rgv, category, 0);
+// taskRgvMap.remove(rgv);
+// }
+// }else{
+ //无论rgv是否运作, 直接停止
CompletableFuture future = taskRgvMap.get(rgv);
if(future == null){
return Result.getInstance().success("当前任务已停止");
@@ -1944,7 +2037,7 @@ public class TestController {
taskRgvMap.remove(rgv);
}
});
- }
+// }
return Result.getInstance().success();
}
diff --git a/web-server/src/main/java/com/evotech/hd/webserver/job/service/ExecutionBatterySwapService.java b/web-server/src/main/java/com/evotech/hd/webserver/job/service/ExecutionBatterySwapService.java
index 1b798a8..8868acb 100644
--- a/web-server/src/main/java/com/evotech/hd/webserver/job/service/ExecutionBatterySwapService.java
+++ b/web-server/src/main/java/com/evotech/hd/webserver/job/service/ExecutionBatterySwapService.java
@@ -693,6 +693,11 @@ public class ExecutionBatterySwapService {
//如果为0, 则执行结束
return Collections.isNotEmpty(executionResult(ParamUtils.getCenErrorCode()));
}
+
+ public Map checkCenErrorInfo() throws InstructionException {
+ //如果为0, 则执行结束
+ return executionResult(ParamUtils.getCenErrorCode());
+ }
//对中机构异常查询
public Boolean checkCenError(SwapBatteryStepEnum swapBatteryStep) throws InstructionException {
//如果为0, 则执行结束
diff --git a/web-server/src/main/java/com/evotech/hd/webserver/service/impl/BatteryCompartmentServiceImpl.java b/web-server/src/main/java/com/evotech/hd/webserver/service/impl/BatteryCompartmentServiceImpl.java
index f56fe19..029c672 100644
--- a/web-server/src/main/java/com/evotech/hd/webserver/service/impl/BatteryCompartmentServiceImpl.java
+++ b/web-server/src/main/java/com/evotech/hd/webserver/service/impl/BatteryCompartmentServiceImpl.java
@@ -1,5 +1,6 @@
package com.evotech.hd.webserver.service.impl;
+import cn.hutool.json.JSONException;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -19,12 +20,15 @@ import com.evotech.hd.core.entity.business.OrderCharging;
import com.evotech.hd.core.enums.ChargerStatusEnums;
import com.evotech.hd.exception.InstructionException;
import com.evotech.hd.utils.Collections;
+import com.evotech.hd.utils.DateUtils;
import com.evotech.hd.webserver.mapper.BatteryCompartmentMapper;
+import com.evotech.hd.webserver.mqtt.MqttPublishUtils;
import com.evotech.hd.webserver.service.BatteryCompartmentService;
import com.evotech.hd.webserver.service.BatteryService;
import com.evotech.hd.webserver.service.BatteryStrategyService;
import com.evotech.hd.webserver.service.OrderChargingService;
import com.evotech.hd.webserver.utils.AccessStrategyUtil;
+import com.evotech.hd.webserver.utils.ParamUtils;
import com.evotech.hd.webserver.utils.instruction.InstructionReadUtils;
import com.evotech.hd.webserver.utils.instruction.InstructionWriteUtils;
import org.apache.commons.lang3.ObjectUtils;
@@ -56,10 +60,44 @@ public class BatteryCompartmentServiceImpl extends ServiceImpl init(Integer maxNo) {
+ String stationCode = ParamUtils.findStationCode();
+ cn.hutool.json.JSONObject bc = new cn.hutool.json.JSONObject();
+ bc.put("stationCode", stationCode);
+ cn.hutool.json.JSONObject b = new cn.hutool.json.JSONObject();
+ b.put("sourceFrom", 1); //默认来源为站
+ b.put("sourceCode", stationCode); //默认编码为换电站编号
+ b.put("pointType", 1); //默认轨迹点类型为电站
+ b.put("pointCode", stationCode); //默认轨迹点编码为换电站编号
for (int i=1; i <= maxNo; i++){
try {
- if(buildCompartmentResult(i)){
- batteryService.buildBattery(i);
+ BatteryCompartment batteryCompartment = buildCompartment(i);
+ if(ObjectUtils.isNotEmpty(batteryCompartment)){
+ try {
+ //电池仓推送云端
+ bc.put("dccNo", batteryCompartment.getBatteryCompartmentNo());
+ bc.put("status", batteryCompartment.getStatus());
+ MqttPublishUtils.sendState("batteryCompartment",bc);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ log.error("电池仓推送云端出现异常>>>>>>>>>", e.getCause());
+ }
+ //初始化电池
+ Battery battery = batteryService.buildBattery(i);
+ //如果仓存存在电池, 推送电池数据
+ if(battery != null){
+// b.put("typeCode", ); //电池型号编码
+// b.put("typeName",); //电池型号名称
+ b.put("batCode", battery.getBatteryCode()); //电池编码
+// b.put("productionDate",); //生产日期
+ b.put("registrationDate", DateUtils.parseDateToStr("yyyyMMdd",battery.getCreateTime())); //注册时间
+ b.put("status", getStatus(battery.getBatteryMode())); //状态
+// b.put("pointName",); //轨迹点名称
+ b.put("soc", battery.getSoc()); //当前电量
+ b.put("dccNo", i); //电池仓位号
+ MqttPublishUtils.sendState("battery",b);
+ }
+
+ //电池推送云端
}else{
break;
}
@@ -71,6 +109,24 @@ public class BatteryCompartmentServiceImpl extends ServiceImpl findPageList(Page page, QueryWrapper queryWrapper) {
queryWrapper.orderByAsc("a.id");// 根据预约日期和预约时间段倒序排序
diff --git a/web-server/src/main/java/com/evotech/hd/webserver/utils/ParamUtils.java b/web-server/src/main/java/com/evotech/hd/webserver/utils/ParamUtils.java
index 70f856d..d088458 100644
--- a/web-server/src/main/java/com/evotech/hd/webserver/utils/ParamUtils.java
+++ b/web-server/src/main/java/com/evotech/hd/webserver/utils/ParamUtils.java
@@ -1,7 +1,9 @@
package com.evotech.hd.webserver.utils;
+import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONObject;
import com.evotech.hd.core.dtos.system.ParamsDTO;
+import com.evotech.hd.webserver.service.BatteryCompartmentService;
import com.evotech.hd.webserver.service.ParamsService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -377,6 +379,7 @@ public class ParamUtils {
return paramService.getParamsDTOByCode(code);
}
+
public static void encryptKeyReq(cn.hutool.json.JSONObject jsonObject){
try {
String encryptVector = jsonObject.getStr("encryptVector");
@@ -387,6 +390,9 @@ public class ParamUtils {
if(StringUtils.isNotEmpty(encryptKey)){
paramService.getOrUpdateParamsDTO("站点AES公钥", ParamsConstant.STATION_AES_PUBLIC_KEY,encryptKey,"软件初始安装时, 直接初始化");
}
+ //每次跟换站控编码, 检测是否存在电池仓数据信息, 如果不存在,需要初始化电池仓信息, 并且同步通知到云端
+ //默认100个电池仓
+ SpringUtil.getBean(BatteryCompartmentService.class).init(jsonObject.getInt("dccNum"));
} catch (Exception e) {
e.printStackTrace();
log.error("更新站控的AES秘钥出现异常", e.getMessage());
diff --git a/web-server/src/main/java/com/evotech/hd/webserver/utils/sendCloud/CloudSendInfoUtils.java b/web-server/src/main/java/com/evotech/hd/webserver/utils/sendCloud/CloudSendInfoUtils.java
index a184002..f095a30 100644
--- a/web-server/src/main/java/com/evotech/hd/webserver/utils/sendCloud/CloudSendInfoUtils.java
+++ b/web-server/src/main/java/com/evotech/hd/webserver/utils/sendCloud/CloudSendInfoUtils.java
@@ -1,5 +1,6 @@
package com.evotech.hd.webserver.utils.sendCloud;
+import cn.hutool.crypto.symmetric.SymmetricCrypto;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
@@ -9,7 +10,9 @@ import com.evotech.hd.utils.Collections;
import com.evotech.hd.webserver.logging.AsyncLogService;
import com.evotech.hd.webserver.logging.LogUtils;
import com.evotech.hd.webserver.mqtt.MessageTopic;
+import com.evotech.hd.webserver.mqtt.MessageUtilService;
import com.evotech.hd.webserver.mqtt.MqttPublishUtils;
+import com.evotech.hd.webserver.mqtt.MyMqttMessage;
import com.evotech.hd.webserver.service.MessageMqttService;
import com.evotech.hd.webserver.utils.ParamUtils;
import lombok.extern.slf4j.Slf4j;
@@ -44,9 +47,12 @@ public class CloudSendInfoUtils {
private static MessageMqttService messageMqttService;
- public CloudSendInfoUtils(AsyncLogService asyncLogService, MessageMqttService messageMqttService) {
+ private static MessageUtilService messageUtilService;
+
+ public CloudSendInfoUtils(AsyncLogService asyncLogService, MessageMqttService messageMqttService, MessageUtilService messageUtilService) {
this.asyncLogService = asyncLogService;
this.messageMqttService = messageMqttService;
+ this.messageUtilService =messageUtilService;
}
@@ -175,18 +181,11 @@ public class CloudSendInfoUtils {
json.put("stationCode", stationCode);
json.put("stationName", stationName);
json.put("timestamp", timestamp);
- String sign = null;
- try {
- sign = RsaEcbPkcsFullUtil.sign(json.toString());
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
Map map = Collections.emptyMap();
map.put("stationCode", stationCode);
map.put("stationName", stationName);
- map.put("sign", sign);
- map.put("data", json.toString());
+ SymmetricCrypto aes = messageUtilService.getAes(stationCode);
+ map.put("data", aes.encryptBase64(json.toString()));
JSONObject result = doPost(ParamUtils.getCloudRequestUrl(), map, Collections.asMap("Content-Type", "application/json","Accept-Language", "zh-CN"));
messageMqttService.update(null,new MessageTopic(json.getString("method"), "HTTP"), "-1", 1, JSONUtil.parseObj(map));
asyncLogService.saveLog(LogUtils.getSendCloudLog(functionName, (System.currentTimeMillis()-startTime), json, (result == null ? "" : result.toString()), null));
diff --git a/web-server/src/main/resources/application-dev.yml b/web-server/src/main/resources/application-dev.yml
index 6b28ab8..0905c2c 100644
--- a/web-server/src/main/resources/application-dev.yml
+++ b/web-server/src/main/resources/application-dev.yml
@@ -1,6 +1,6 @@
spring:
redis:
- host: 192.168.5.112
+ host: 192.168.5.232
port: 6379
database: 13
password: hbyt2025
@@ -17,7 +17,7 @@ spring:
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
mqtt:
- broker: tcp://192.168.5.112:1883 # MQTT服务器地址(如Mosquitto默认端口1883)
+ broker: tcp://192.168.5.232:1883 # MQTT服务器地址(如Mosquitto默认端口1883)
client-id: springboot-mqtt-${random.value} # 客户端ID(添加随机数确保唯一)
username: admin # 可选,MQTT服务器认证用户名
password: hbyt12345 # 可选,MQTT服务器认证密码