From 2ec09cbf6b4b96794d2bc388e742519958cd6b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Wed, 19 Mar 2025 13:52:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=B8=B8=E9=87=8F=E5=80=BC=E5=8F=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/app/device/spray/SprayTaskExecutor.java | 9 ++- .../front/cmd/business/MatrixSprayChangeParam.java | 8 ++- .../app/front/cmd/business/MatrixSprayStart.java | 25 +++++--- .../front/cmd/business/NozzlePipelinePreFill.java | 18 ++++-- .../app/front/cmd/business/NozzlePipelineWash.java | 18 ++++-- .../front/cmd/business/SyringePipelineWash.java | 18 ++++-- .../com/qyft/ms/app/model/entity/Position.java | 4 ++ .../qyft/ms/app/service/ISysSettingsService.java | 26 -------- .../qyft/ms/app/service/SysSettingsService.java | 26 ++++++++ .../app/service/impl/ISysSettingsServiceImpl.java | 71 ---------------------- .../app/service/impl/SysSettingsServiceImpl.java | 70 +++++++++++++++++++++ src/main/resources/sql/init.sql | 4 +- 12 files changed, 174 insertions(+), 123 deletions(-) delete mode 100644 src/main/java/com/qyft/ms/app/service/ISysSettingsService.java create mode 100644 src/main/java/com/qyft/ms/app/service/SysSettingsService.java delete mode 100644 src/main/java/com/qyft/ms/app/service/impl/ISysSettingsServiceImpl.java create mode 100644 src/main/java/com/qyft/ms/app/service/impl/SysSettingsServiceImpl.java diff --git a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java index a81a8e9..851b4d8 100644 --- a/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java +++ b/src/main/java/com/qyft/ms/app/device/spray/SprayTaskExecutor.java @@ -1,9 +1,12 @@ package com.qyft.ms.app.device.spray; import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.qyft.ms.app.common.constant.WebSocketMessageType; import com.qyft.ms.app.device.status.SprayTask; import com.qyft.ms.app.model.bo.Point2D; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.SysSettingsService; import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.model.bo.DeviceCommand; @@ -25,6 +28,7 @@ public class SprayTaskExecutor { private final WebSocketService webSocketService; private final DeviceCommandService deviceCommandService; private final SprayTaskPointCollector sprayTaskPointCollector; + private final SysSettingsService sysSettingsService; private Thread taskThread; @@ -49,8 +53,9 @@ public class SprayTaskExecutor { CommandFuture motorYPositionSetCommandFuture = deviceCommandService.sendCommand(motorYPositionSetCommand); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand); commandWait(motorXPositionSetCommandFuture, motorYPositionSetCommandFuture, motorZPositionSetCommandFuture); - - Double height = 101.2 - sprayTask.getSprayParams().getMotorZHeight();//TODO 101.2是玻片高度,这个应该从数据库中获取 + SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); + Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); + Double height = slideHeight - sprayTask.getSprayParams().getMotorZHeight(); DeviceCommand motorZPositionSetAboveSlideCommand = DeviceCommandGenerator.motorZPositionSet(height); CommandFuture motorZPositionSetAboveSlideCommandFuture = deviceCommandService.sendCommand(motorZPositionSetAboveSlideCommand); commandWait(motorZPositionSetAboveSlideCommandFuture); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java index 791ecf6..1513a1f 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayChangeParam.java @@ -1,6 +1,9 @@ package com.qyft.ms.app.front.cmd.business; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.qyft.ms.app.device.status.SprayTask; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.SysSettingsService; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; @@ -25,6 +28,7 @@ import java.util.concurrent.CompletableFuture; public class MatrixSprayChangeParam extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final SysSettingsService sysSettingsService; @Override public CompletableFuture handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { @@ -51,7 +55,9 @@ public class MatrixSprayChangeParam extends BaseCommandHandler { CommandFuture syringePumpVolumeSetCommandFuture = deviceCommandService.sendCommand(syringePumpVolumeSetCommand, form, emitter); commandWait(syringePumpVolumeSetCommandFuture); //3.z轴高度 - Double height = 101.2 - motorZHeight;//TODO 101.2是玻片高度,这个应该从数据库中获取 + SysSettings slideHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "slide_height")); + Double slideHeight = Double.parseDouble(slideHeightSysSettings.getValue()); + Double height = slideHeight - motorZHeight; DeviceCommand smotorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(height);//移动z轴到指定位置 CommandFuture smotorZPositionSetCommandFuture = deviceCommandService.sendCommand(smotorZPositionSetCommand, form, emitter); commandWait(smotorZPositionSetCommandFuture); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java index 78b51e8..ce3cc53 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayStart.java @@ -1,11 +1,13 @@ package com.qyft.ms.app.front.cmd.business; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.qyft.ms.app.common.generator.PathGenerator; import com.qyft.ms.app.device.spray.SprayTaskExecutor; import com.qyft.ms.app.device.status.SprayTask; +import com.qyft.ms.app.model.entity.Position; +import com.qyft.ms.app.service.PositionService; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.constant.CommandStatus; -import com.qyft.ms.system.common.device.command.CommandFuture; import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.device.command.FrontCommand; import com.qyft.ms.system.common.utils.CheckedRunnable; @@ -13,14 +15,12 @@ import com.qyft.ms.system.common.utils.LambdaUtil; import com.qyft.ms.system.core.handler.BaseCommandHandler; import com.qyft.ms.system.model.bo.DeviceCommand; import com.qyft.ms.system.model.form.FrontCmdControlForm; -import com.qyft.ms.system.service.device.DeviceCommandService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; -import java.awt.*; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -41,7 +41,8 @@ public class MatrixSprayStart extends BaseCommandHandler { private static final ExecutorService singleExecutor = Executors.newSingleThreadExecutor(); private final SprayTaskExecutor sprayTaskExecutor; - private final DeviceCommandService deviceCommandService; + private final PositionService positionService; + private static boolean nonNullCheck(ResponseBodyEmitter emitter, String cmdId, String cmdCode, String matrixPathType, @@ -132,13 +133,17 @@ public class MatrixSprayStart extends BaseCommandHandler { sprayTask.setSprayParam(matrixPathType, motorZHeight, gasPressure, volume, highVoltage, highVoltageValue, spacing, movingSpeed, times, positionList); // 7.循环喷涂区域 - Double[][] slideArr = { //TODO 每个玻片的位置,应当从数据库获取 - {18.08, 0.0}, - {45.08, 0.0}, - {72.08, 0.0}, - {99.08, 0.0} - }; + Position slidePosition1 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position1")); + Position slidePosition2 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position2")); + Position slidePosition3 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position3")); + Position slidePosition4 = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "slide_position4")); + Double[][] slideArr = { + {slidePosition1.getX(), slidePosition1.getY()}, + {slidePosition2.getX(), slidePosition2.getY()}, + {slidePosition3.getX(), slidePosition3.getY()}, + {slidePosition4.getX(), slidePosition4.getY()} + }; for (Map position : positionList) { int index = (int) position.get("index"); //index 第几个玻片 Double[] upperLeft = {((Number) position.get("x1")).doubleValue(), ((Number) position.get("y1")).doubleValue()}; //范围左上角 x1,y1 diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java index 2c8d8b9..6626e2e 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFill.java @@ -1,6 +1,11 @@ package com.qyft.ms.app.front.cmd.business; import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.qyft.ms.app.model.entity.Position; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.PositionService; +import com.qyft.ms.app.service.SysSettingsService; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.device.command.CommandFuture; @@ -28,6 +33,8 @@ import java.util.concurrent.CompletableFuture; public class NozzlePipelinePreFill extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final SysSettingsService sysSettingsService; + private final PositionService positionService; @Override public CompletableFuture handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { @@ -47,17 +54,20 @@ public class NozzlePipelinePreFill extends BaseCommandHandler { emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "获得电机XYZ相对原点坐标失败", motorXyzPositionGetCommandDeviceResult), MediaType.APPLICATION_JSON); return; } - if (zAxisPosition > 80) { //z轴超出安全距离,抬升z轴 //TODO安全距离应该可配置 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(80.0, speed); + SysSettings safeZHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "safe_z_height")); + double safeZHeight = Double.parseDouble(safeZHeightSysSettings.getValue()); + if (zAxisPosition > safeZHeight) { //z轴超出安全距离,抬升z轴 + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(safeZHeight, speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); } + Position wasteLiquor = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "waste_liquor")); //3.x轴移动到废液位置 - DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(173.08, speed); + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(wasteLiquor.getX(), speed); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter); commandWait(motorXPositionSetCommandFuture); //4.下降z轴高度,防止飞溅 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(70.0, speed); + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ(), speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); //5.打开三通阀注射器管路 diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java index 48971f8..386136c 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelineWash.java @@ -1,6 +1,11 @@ package com.qyft.ms.app.front.cmd.business; import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.qyft.ms.app.model.entity.Position; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.PositionService; +import com.qyft.ms.app.service.SysSettingsService; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.device.command.CommandFuture; @@ -28,6 +33,8 @@ import java.util.concurrent.CompletableFuture; public class NozzlePipelineWash extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final SysSettingsService sysSettingsService; + private final PositionService positionService; @Override public CompletableFuture handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { @@ -42,17 +49,20 @@ public class NozzlePipelineWash extends BaseCommandHandler { emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "获得电机XYZ相对原点坐标失败", motorXyzPositionGetCommandDeviceResult), MediaType.APPLICATION_JSON); return; } - if (zAxisPosition > 80) { //z轴超出安全距离,抬升z轴 //TODO安全距离应该可配置 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(80.0); + SysSettings safeZHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "safe_z_height")); + double safeZHeight = Double.parseDouble(safeZHeightSysSettings.getValue()); + if (zAxisPosition > safeZHeight) { //z轴超出安全距离,抬升z轴 + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(safeZHeight); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); } + Position wasteLiquor = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "waste_liquor")); //2.轴移动到废液位置 - DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(173.08); + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(wasteLiquor.getX()); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter); commandWait(motorXPositionSetCommandFuture); //3.下降z轴高度,防止飞溅 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(70.0); + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ()); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); //4.开启三通阀到喷嘴管路 diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java index 288b197..3a4015b 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWash.java @@ -1,6 +1,11 @@ package com.qyft.ms.app.front.cmd.business; import cn.hutool.json.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.qyft.ms.app.model.entity.Position; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.PositionService; +import com.qyft.ms.app.service.SysSettingsService; import com.qyft.ms.system.common.annotation.CommandMapping; import com.qyft.ms.system.common.constant.CommandStatus; import com.qyft.ms.system.common.device.command.CommandFuture; @@ -28,6 +33,8 @@ import java.util.concurrent.CompletableFuture; public class SyringePipelineWash extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final SysSettingsService sysSettingsService; + private final PositionService positionService; @Override public CompletableFuture handle(FrontCmdControlForm form, ResponseBodyEmitter emitter) { @@ -47,17 +54,20 @@ public class SyringePipelineWash extends BaseCommandHandler { emitter.send(FrontCommand.backstage(form.getCmdId(), form.getCmdCode(), CommandStatus.ERROR, "获得电机XYZ相对原点坐标失败", motorXyzPositionGetCommandDeviceResult), MediaType.APPLICATION_JSON); return; } - if (zAxisPosition > 80) { //z轴超出安全距离,抬升z轴 //TODO安全距离应该可配置 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(80.0, speed); + SysSettings safeZHeightSysSettings = sysSettingsService.getOne(new LambdaQueryWrapper().eq(SysSettings::getCode, "safe_z_height")); + double safeZHeight = Double.parseDouble(safeZHeightSysSettings.getValue()); + if (zAxisPosition > safeZHeight) { //z轴超出安全距离,抬升z轴 + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(safeZHeight, speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); } + Position wasteLiquor = positionService.getOne(new LambdaQueryWrapper().eq(Position::getPointCode, "waste_liquor")); //3.x轴移动到废液位置 - DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(173.08, speed); + DeviceCommand motorXPositionSetCommand = DeviceCommandGenerator.motorXPositionSet(wasteLiquor.getX(), speed); CommandFuture motorXPositionSetCommandFuture = deviceCommandService.sendCommand(motorXPositionSetCommand, form, emitter); commandWait(motorXPositionSetCommandFuture); //4.下降z轴高度,防止飞溅 - DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(70.0, speed); + DeviceCommand motorZPositionSetCommand = DeviceCommandGenerator.motorZPositionSet(wasteLiquor.getZ(), speed); CommandFuture motorZPositionSetCommandFuture = deviceCommandService.sendCommand(motorZPositionSetCommand, form, emitter); commandWait(motorZPositionSetCommandFuture); //5.打开三通阀注射器管路 diff --git a/src/main/java/com/qyft/ms/app/model/entity/Position.java b/src/main/java/com/qyft/ms/app/model/entity/Position.java index 17a927c..63aad8f 100644 --- a/src/main/java/com/qyft/ms/app/model/entity/Position.java +++ b/src/main/java/com/qyft/ms/app/model/entity/Position.java @@ -17,6 +17,10 @@ public class Position extends BaseEntity { private String pointName; @NotBlank + @Schema(description = "code") + private String pointCode; + + @NotBlank @Schema(description = "x") private Double x; diff --git a/src/main/java/com/qyft/ms/app/service/ISysSettingsService.java b/src/main/java/com/qyft/ms/app/service/ISysSettingsService.java deleted file mode 100644 index 87496fa..0000000 --- a/src/main/java/com/qyft/ms/app/service/ISysSettingsService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.qyft.ms.app.service; - - -import com.baomidou.mybatisplus.extension.service.IService; -import com.qyft.ms.app.model.entity.SysSettings; - -import java.util.List; -import java.util.Map; - -/** - * 系统配置接口层 - */ -public interface ISysSettingsService extends IService { - - List getSlidePositionList(); - - void updateWorkStatus(String washing); - - String getWorkStatus(); - - Double getTargetHumidity(); - - void updateTargetHumidity(Double humidity); - - Map getWasteLiquorPosition(); -} diff --git a/src/main/java/com/qyft/ms/app/service/SysSettingsService.java b/src/main/java/com/qyft/ms/app/service/SysSettingsService.java new file mode 100644 index 0000000..1fd0c65 --- /dev/null +++ b/src/main/java/com/qyft/ms/app/service/SysSettingsService.java @@ -0,0 +1,26 @@ +package com.qyft.ms.app.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.qyft.ms.app.model.entity.SysSettings; + +import java.util.List; +import java.util.Map; + +/** + * 系统配置接口层 + */ +public interface SysSettingsService extends IService { + + List getSlidePositionList(); + + void updateWorkStatus(String washing); + + String getWorkStatus(); + + Double getTargetHumidity(); + + void updateTargetHumidity(Double humidity); + + Map getWasteLiquorPosition(); +} diff --git a/src/main/java/com/qyft/ms/app/service/impl/ISysSettingsServiceImpl.java b/src/main/java/com/qyft/ms/app/service/impl/ISysSettingsServiceImpl.java deleted file mode 100644 index c8f43f3..0000000 --- a/src/main/java/com/qyft/ms/app/service/impl/ISysSettingsServiceImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.qyft.ms.app.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.qyft.ms.app.mapper.SysSettingsMapper; -import com.qyft.ms.app.model.entity.SysSettings; -import com.qyft.ms.app.service.ISysSettingsService; -import jakarta.annotation.PostConstruct; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Map; - -/** - * 系统配置实现类 - */ -@Service -@RequiredArgsConstructor -public class ISysSettingsServiceImpl extends ServiceImpl implements ISysSettingsService { - private final SysSettingsMapper sysSettingsMapper; - // 玻片位置 - @Getter - List slidePositionList; - // 电机速度 - @Getter - List motorSpeedList; - - @Getter - Map wasteLiquorPosition; - - // 自检状态 - @Getter - boolean selfCheckStatus = false; - - // 设备状态 - @Getter - String workStatus = "idle"; - - // 目标湿度 - @Getter - Double targetHumidity = 0.0; - -// @PostConstruct - public void init() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.in("code", "slide_position"); - Long parentId = sysSettingsMapper.selectOne(queryWrapper).getId(); - slidePositionList = sysSettingsMapper.selectList(new QueryWrapper().eq("parent_id", parentId)); - motorSpeedList = sysSettingsMapper.selectList(new QueryWrapper().eq("parent_id", new QueryWrapper().eq("code", "speed"))); - String position = sysSettingsMapper.selectOne(new QueryWrapper().eq("code", "waste_liquor")).getValue(); - String [] positionList = position.split(","); - wasteLiquorPosition = Map.of( - "x", Double.parseDouble(positionList[0]), - "y", Double.parseDouble(positionList[1]), - "z", Double.parseDouble(positionList[2]) - ); - - } - - public void updateWorkStatus(String status) { - workStatus = status; - } - public void updateTargetHumidity(Double humidity) { - targetHumidity = humidity; - } - public void updateSelfCheckStatus(boolean status) { - selfCheckStatus = status; - } -} diff --git a/src/main/java/com/qyft/ms/app/service/impl/SysSettingsServiceImpl.java b/src/main/java/com/qyft/ms/app/service/impl/SysSettingsServiceImpl.java new file mode 100644 index 0000000..5a95fb9 --- /dev/null +++ b/src/main/java/com/qyft/ms/app/service/impl/SysSettingsServiceImpl.java @@ -0,0 +1,70 @@ +package com.qyft.ms.app.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.qyft.ms.app.mapper.SysSettingsMapper; +import com.qyft.ms.app.model.entity.SysSettings; +import com.qyft.ms.app.service.SysSettingsService; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * 系统配置实现类 + */ +@Service +@RequiredArgsConstructor +public class SysSettingsServiceImpl extends ServiceImpl implements SysSettingsService { + private final SysSettingsMapper sysSettingsMapper; + // 玻片位置 + @Getter + List slidePositionList; + // 电机速度 + @Getter + List motorSpeedList; + + @Getter + Map wasteLiquorPosition; + + // 自检状态 + @Getter + boolean selfCheckStatus = false; + + // 设备状态 + @Getter + String workStatus = "idle"; + + // 目标湿度 + @Getter + Double targetHumidity = 0.0; + +// @PostConstruct + public void init() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("code", "slide_position"); + Long parentId = sysSettingsMapper.selectOne(queryWrapper).getId(); + slidePositionList = sysSettingsMapper.selectList(new QueryWrapper().eq("parent_id", parentId)); + motorSpeedList = sysSettingsMapper.selectList(new QueryWrapper().eq("parent_id", new QueryWrapper().eq("code", "speed"))); + String position = sysSettingsMapper.selectOne(new QueryWrapper().eq("code", "waste_liquor")).getValue(); + String [] positionList = position.split(","); + wasteLiquorPosition = Map.of( + "x", Double.parseDouble(positionList[0]), + "y", Double.parseDouble(positionList[1]), + "z", Double.parseDouble(positionList[2]) + ); + + } + + public void updateWorkStatus(String status) { + workStatus = status; + } + public void updateTargetHumidity(Double humidity) { + targetHumidity = humidity; + } + public void updateSelfCheckStatus(boolean status) { + selfCheckStatus = status; + } +} diff --git a/src/main/resources/sql/init.sql b/src/main/resources/sql/init.sql index 81b633d..365734e 100644 --- a/src/main/resources/sql/init.sql +++ b/src/main/resources/sql/init.sql @@ -64,7 +64,9 @@ VALUES (1, NULL, '电机电流', 'current', NULL), (5, NULL, '电机运行速度', 'speed', NULL), (6, 5, 'x轴速度', 'x_speed', 10), (7, 5, 'y轴速度', 'y_speed', 10), - (8, 5, 'z轴速度', 'z_speed', 10); + (8, 5, 'z轴速度', 'z_speed', 10), + (9, NULL, '玻片高度', 'slide_height', 101.2), + (10, NULL, 'z轴安全高度', 'safe_z_height', 80);