From 8d22601f521efcde5796442e4e3fe384234dba54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 31 Jul 2025 19:24:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=A1=E8=AE=A1=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handacid/app/core/listener/BleGamepadEventListener.java | 10 +++++----- .../com/iflytop/handacid/app/service/ChannelCtrlService.java | 12 ++++++++++++ .../iflytop/handacid/common/model/entity/AuditRecord.java | 10 ++++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iflytop/handacid/app/core/listener/BleGamepadEventListener.java b/src/main/java/com/iflytop/handacid/app/core/listener/BleGamepadEventListener.java index e6c2632..c8659eb 100644 --- a/src/main/java/com/iflytop/handacid/app/core/listener/BleGamepadEventListener.java +++ b/src/main/java/com/iflytop/handacid/app/core/listener/BleGamepadEventListener.java @@ -2,6 +2,7 @@ package com.iflytop.handacid.app.core.listener; import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.app.service.ChannelCtrlService; +import com.iflytop.handacid.common.service.AuditRecordService; import com.iflytop.handacid.hardware.service.AppEventBusService; import com.iflytop.handacid.hardware.type.A8kPacket; import com.iflytop.handacid.hardware.type.CmdId; @@ -14,7 +15,6 @@ import org.springframework.stereotype.Component; /** * 蓝牙手柄按钮事件监听 - * */ @Component @@ -42,16 +42,16 @@ public class BleGamepadEventListener { if (CmdId.event_ble_gamepad_liquid_acid.equals(cmdId)) { //判断当前的设备状态 log.info("蓝牙手柄 加酸按钮 按下"); - if(deviceState.isSolutionAdding()){ + if (deviceState.isSolutionAdding()) { channelCtrlService.solutionAddStop(); - }else{ + } else { channelCtrlService.solutionAddStart(); } } else if (CmdId.event_ble_gamepad_liquid_acid_prefilling.equals(cmdId)) { log.info("蓝牙手柄 预充按钮 按下"); - if(deviceState.isSolutionPreFillStart()){ + if (deviceState.isSolutionPreFillStart()) { channelCtrlService.solutionPreFillStart(); - }else{ + } else { channelCtrlService.solutionPreFillStop(); } } else if (CmdId.event_ble_gamepad_connected.equals(cmdId)) { diff --git a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java index ecfe275..fa05f2a 100644 --- a/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java +++ b/src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java @@ -10,7 +10,9 @@ import com.iflytop.handacid.app.core.command.DeviceCommand; import com.iflytop.handacid.app.core.command.DeviceCommandGenerator; import com.iflytop.handacid.app.core.state.ChannelState; import com.iflytop.handacid.app.core.state.DeviceState; +import com.iflytop.handacid.common.model.entity.AuditRecord; import com.iflytop.handacid.common.model.entity.Formulation; +import com.iflytop.handacid.common.service.AuditRecordService; import com.iflytop.handacid.common.service.FormulationService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -30,6 +32,7 @@ public class ChannelCtrlService { private final FormulationService formulationService; private final DeviceCommandService deviceCommandService; private final DeviceState deviceState; + private final AuditRecordService auditRecordService; /** * 开始加液 @@ -48,6 +51,9 @@ public class ChannelCtrlService { Formulation formulation = formulationService.getOne(new LambdaQueryWrapper().eq(Formulation::getSolutionId, channelState.getSolutionId())); DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions()); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + AuditRecord auditRecord = new AuditRecord(deviceState.getCurrentUser().getId(), deviceState.getCurrentUser().getNickname(), channelState.getSolutionId(), + channelState.getSolutionName(), formulation.getConcentration(), channelState.getChannelCode().name(), formulation.getVolume()); + auditRecordService.saveOrUpdate(auditRecord); } CommandUtil.wait(commandFutureList); Thread.sleep(deviceState.getDelay() * 1000L); @@ -58,6 +64,9 @@ public class ChannelCtrlService { Formulation formulation = formulationService.getOne(new LambdaQueryWrapper().eq(Formulation::getSolutionId, channelState.getSolutionId())); DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions()); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + AuditRecord auditRecord = new AuditRecord(deviceState.getCurrentUser().getId(), deviceState.getCurrentUser().getNickname(), channelState.getSolutionId(), + channelState.getSolutionName(), formulation.getConcentration(), channelState.getChannelCode().name(), formulation.getVolume()); + auditRecordService.saveOrUpdate(auditRecord); } CommandUtil.wait(commandFutureList); } @@ -108,6 +117,9 @@ public class ChannelCtrlService { for (ChannelState channelState : channelStateList) { DeviceCommand deviceCommand = getPumpForwardRotateCommandByChannel(channelState.getChannelCode()); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); + AuditRecord auditRecord = new AuditRecord(deviceState.getCurrentUser().getId(), deviceState.getCurrentUser().getNickname(), channelState.getSolutionId(), + channelState.getSolutionName(), channelState.getConcentration(), channelState.getChannelCode().name(), channelState.getTargetVolume()); + auditRecordService.saveOrUpdate(auditRecord); } CommandUtil.wait(commandFutureList); } catch (Exception e) { diff --git a/src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java b/src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java index 85747b8..cfc99f4 100644 --- a/src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java +++ b/src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java @@ -33,4 +33,14 @@ public class AuditRecord extends BaseEntity { @Schema(description = "使用溶液量") private Double usedVolume; + public AuditRecord(Long userId, String userNickname, Long solutionId, String solutionName, Double concentration, String channelCode, Double usedVolume) { + this.userId = userId; + this.userNickname = userNickname; + this.solutionId = solutionId; + this.solutionName = solutionName; + this.concentration = concentration; + this.channelCode = channelCode; + this.usedVolume = usedVolume; + } + }