From ecdcf63280e0cffa74d49abf20a8f10a09026467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B?= <1063331231@qq.com> Date: Sat, 14 Jun 2025 18:11:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E8=89=BA=E7=9B=91=E6=8E=A7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BF=9D=E5=AD=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iflytop/sgs/app/core/CraftsContext.java | 2 +- .../sgs/app/service/crafts/CraftsStepService.java | 76 +++++++++------------- .../sgs/common/enums/CraftsMonitorResultCode.java | 18 +++++ 3 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 src/main/java/com/iflytop/sgs/common/enums/CraftsMonitorResultCode.java diff --git a/src/main/java/com/iflytop/sgs/app/core/CraftsContext.java b/src/main/java/com/iflytop/sgs/app/core/CraftsContext.java index bb5336b..cde1edf 100644 --- a/src/main/java/com/iflytop/sgs/app/core/CraftsContext.java +++ b/src/main/java/com/iflytop/sgs/app/core/CraftsContext.java @@ -91,7 +91,7 @@ public class CraftsContext implements Runnable { CraftsStep step = craftsStepList.get(currentIndex); craftMonitor.setCurrentStepId(currentIndex); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitorService.saveMonitor(craftMonitor); boolean ok = executeStep(step, craftMonitor); if (!ok) { Message errMsg = MessageBuilder.withPayload(CraftEvents.ERROR_OCCUR).build(); diff --git a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java index 3352f26..a0cb9d1 100644 --- a/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/sgs/app/service/crafts/CraftsStepService.java @@ -31,6 +31,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -100,11 +101,9 @@ public class CraftsStepService { log.info("工艺{},-------------------------------------加稀硝酸-------------------------------------", heatModuleCode); /*工艺监控*/ log.info("工艺{},工艺监控", heatModuleCode); - JSONObject result = new JSONObject(); List finishColumns = new ArrayList<>(); - result.set(ResultCode.SUCCESS.getCode(), finishColumns); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.add_liquid_column.getDescription() + Arrays.toString(finishColumns.toArray())); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控结束*/ /*获取配置信息*/ @@ -213,10 +212,9 @@ public class CraftsStepService { solutionModuleService.solutionMotorMoveZero();//加液机械臂上升 /*工艺监控开始*/ finishColumns.add(i); - result.set("columns", finishColumns);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.add_liquid_column.getDescription() + Arrays.toString(finishColumns.toArray())); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控结束*/ } solutionModuleService.liquidPumpMove(-backFlowDistance);//预充 @@ -256,11 +254,9 @@ public class CraftsStepService { log.info("工艺{},------------------------------加浓硝酸---------------------------", heatModuleCode); /*工艺监控*/ log.info("工艺{},工艺监控", heatModuleCode); - JSONObject result = new JSONObject(); List finishColumns = new ArrayList<>(); - result.set(ResultCode.SUCCESS.getCode(), finishColumns); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.add_liquid_column.getDescription() + Arrays.toString(finishColumns.toArray())); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控结束*/ /*获取配置信息*/ @@ -411,10 +407,9 @@ public class CraftsStepService { solutionModuleService.solutionMotorMoveZero();//加液机械臂上升 /*工艺监控开始*/ finishColumns.add(i); - result.set("columns", finishColumns);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.add_liquid_column.getDescription() + Arrays.toString(finishColumns.toArray())); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控结束*/ } solutionModuleService.liquidPumpMove(-backFlowDistance);//预充 @@ -453,9 +448,9 @@ public class CraftsStepService { * */ public boolean heat(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { /*工艺监控清理上步的记录*/ - JSONObject result = new JSONObject(); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":0"); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控清理上步的记录*/ Double temperature = params.getDouble("temperature");//温度 Integer time = params.getInt("time");//秒 @@ -485,10 +480,9 @@ public class CraftsStepService { cycle--; clock = clock + 60; /*保存到工艺监控*/ - result.set("time", clock);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":" + clock / 60); + craftMonitorService.saveMonitor(craftMonitor); /*保存到工艺监控*/ } delay(seconds); @@ -497,9 +491,6 @@ public class CraftsStepService { deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(null);//加热器目标加热时间 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.finish); //加热完成 log.info("工艺{},加热结束", heatModuleCode); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "加热结束,持续时间", time)); return true; } @@ -511,9 +502,9 @@ public class CraftsStepService { try { log.info("工艺{},----------------------------------清洗---------------------------------------------", heatModuleCode); /*保存到监控开始*/ - JSONObject result = new JSONObject(); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 + craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.clean_cycle.getDescription() + ":0"); + craftMonitorService.saveMonitor(craftMonitor); /*保存到监控结束*/ /*获取参数开始*/ @@ -651,10 +642,9 @@ public class CraftsStepService { log.info("工艺{},加液模块上升至最高,移出试管", heatModuleCode); solutionModuleService.solutionMotorMoveZero();//加液模块上升至最高,移出试管 } - result.set("cycle", i + 1);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.clean_cycle.getDescription() + ":" + (i + 1)); + craftMonitorService.saveMonitor(craftMonitor); } /*清洗结束*/ @@ -685,9 +675,9 @@ public class CraftsStepService { * */ public boolean dry(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { /*工艺监控清理上步的记录*/ - JSONObject result = new JSONObject(); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":0"); + craftMonitorService.saveMonitor(craftMonitor); /*工艺监控清理上步的记录*/ @@ -707,19 +697,15 @@ public class CraftsStepService { deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setStartHeatTime(LocalDateTime.now());//开始加热时间 deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTargetTime(time);//加热器目标加热时间 int clock = 0; - result.set("time", clock);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 int cycle = time / 60; int seconds = time % 60; while (cycle > 0) { delay(60); cycle--; clock = clock + 60; - result.set("time", clock);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":" + clock / 60); + craftMonitorService.saveMonitor(craftMonitor); } log.info("工艺{},恒温中", heatModuleCode); delay(seconds); @@ -739,9 +725,9 @@ public class CraftsStepService { * */ public synchronized boolean anneal(HeatModuleCode heatModuleCode, JSONObject params, CraftMonitor craftMonitor) throws Exception { try { - JSONObject result = new JSONObject(); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor); + craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":0"); + craftMonitorService.saveMonitor(craftMonitor); Double temperature = params.getDouble("temperature");//退火温度 Integer time = params.getInt("time");//秒 boolean heatModuleTrayExist = deviceSensorService.getTrayStateByHeatModuleCode(heatModuleCode); @@ -796,19 +782,15 @@ public class CraftsStepService { deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setStartHeatTime(LocalDateTime.now());//开始加热时间 deviceStateService.getDeviceState().getHeatModuleByCode(HeatModuleCode.heat_module_04).setTargetTime(time);//加热器目标加热时间 int clock = 0; - result.set("time", clock);//添加到结果 - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 int cycle = time / 60; int seconds = time % 60; while (cycle > 0) { delay(60); cycle--; clock = clock + 60; - result.set("time", clock);//添加到结果 craftMonitor.setDeviceState(JSONUtil.toJsonStr(deviceStateService.getDeviceState())); - craftMonitor.setCurrentStepResult(String.valueOf(result)); - craftMonitorService.saveOrUpdate(craftMonitor);//保存到监控 + craftMonitor.setCurrentStepResult(CraftsMonitorResultCode.heat_time.getDescription() + ":" + clock / 60); + craftMonitorService.saveMonitor(craftMonitor); } log.info("工艺{},恒温中", HeatModuleCode.heat_module_04); delay(seconds); diff --git a/src/main/java/com/iflytop/sgs/common/enums/CraftsMonitorResultCode.java b/src/main/java/com/iflytop/sgs/common/enums/CraftsMonitorResultCode.java new file mode 100644 index 0000000..ae9b27f --- /dev/null +++ b/src/main/java/com/iflytop/sgs/common/enums/CraftsMonitorResultCode.java @@ -0,0 +1,18 @@ +package com.iflytop.sgs.common.enums; + +import lombok.Getter; + +/** + * 容器 + */ +@Getter +public enum CraftsMonitorResultCode { + add_liquid_column("已加液列数"), + heat_time("已加热分钟"), + clean_cycle("已清洗次数"); + private final String description; + + CraftsMonitorResultCode(String description) { + this.description = description; + } +}