Browse Source

增加审计记录

master
王梦远 3 days ago
parent
commit
8d22601f52
  1. 10
      src/main/java/com/iflytop/handacid/app/core/listener/BleGamepadEventListener.java
  2. 12
      src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java
  3. 10
      src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java

10
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.core.state.DeviceState;
import com.iflytop.handacid.app.service.ChannelCtrlService; 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.service.AppEventBusService;
import com.iflytop.handacid.hardware.type.A8kPacket; import com.iflytop.handacid.hardware.type.A8kPacket;
import com.iflytop.handacid.hardware.type.CmdId; import com.iflytop.handacid.hardware.type.CmdId;
@ -14,7 +15,6 @@ import org.springframework.stereotype.Component;
/** /**
* 蓝牙手柄按钮事件监听 * 蓝牙手柄按钮事件监听
*
*/ */
@Component @Component
@ -42,16 +42,16 @@ public class BleGamepadEventListener {
if (CmdId.event_ble_gamepad_liquid_acid.equals(cmdId)) { if (CmdId.event_ble_gamepad_liquid_acid.equals(cmdId)) {
//判断当前的设备状态 //判断当前的设备状态
log.info("蓝牙手柄 加酸按钮 按下"); log.info("蓝牙手柄 加酸按钮 按下");
if(deviceState.isSolutionAdding()){
if (deviceState.isSolutionAdding()) {
channelCtrlService.solutionAddStop(); channelCtrlService.solutionAddStop();
}else{
} else {
channelCtrlService.solutionAddStart(); channelCtrlService.solutionAddStart();
} }
} else if (CmdId.event_ble_gamepad_liquid_acid_prefilling.equals(cmdId)) { } else if (CmdId.event_ble_gamepad_liquid_acid_prefilling.equals(cmdId)) {
log.info("蓝牙手柄 预充按钮 按下"); log.info("蓝牙手柄 预充按钮 按下");
if(deviceState.isSolutionPreFillStart()){
if (deviceState.isSolutionPreFillStart()) {
channelCtrlService.solutionPreFillStart(); channelCtrlService.solutionPreFillStart();
}else{
} else {
channelCtrlService.solutionPreFillStop(); channelCtrlService.solutionPreFillStop();
} }
} else if (CmdId.event_ble_gamepad_connected.equals(cmdId)) { } else if (CmdId.event_ble_gamepad_connected.equals(cmdId)) {

12
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.command.DeviceCommandGenerator;
import com.iflytop.handacid.app.core.state.ChannelState; import com.iflytop.handacid.app.core.state.ChannelState;
import com.iflytop.handacid.app.core.state.DeviceState; 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.model.entity.Formulation;
import com.iflytop.handacid.common.service.AuditRecordService;
import com.iflytop.handacid.common.service.FormulationService; import com.iflytop.handacid.common.service.FormulationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -30,6 +32,7 @@ public class ChannelCtrlService {
private final FormulationService formulationService; private final FormulationService formulationService;
private final DeviceCommandService deviceCommandService; private final DeviceCommandService deviceCommandService;
private final DeviceState deviceState; private final DeviceState deviceState;
private final AuditRecordService auditRecordService;
/** /**
* 开始加液 * 开始加液
@ -48,6 +51,9 @@ public class ChannelCtrlService {
Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId())); Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId()));
DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions()); DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions());
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); 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); CommandUtil.wait(commandFutureList);
Thread.sleep(deviceState.getDelay() * 1000L); Thread.sleep(deviceState.getDelay() * 1000L);
@ -58,6 +64,9 @@ public class ChannelCtrlService {
Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId())); Formulation formulation = formulationService.getOne(new LambdaQueryWrapper<Formulation>().eq(Formulation::getSolutionId, channelState.getSolutionId()));
DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions()); DeviceCommand deviceCommand = getPumpMoveByCommandByChannel(channelState.getChannelCode(), formulation.getRevolutions());
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); 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); CommandUtil.wait(commandFutureList);
} }
@ -108,6 +117,9 @@ public class ChannelCtrlService {
for (ChannelState channelState : channelStateList) { for (ChannelState channelState : channelStateList) {
DeviceCommand deviceCommand = getPumpForwardRotateCommandByChannel(channelState.getChannelCode()); DeviceCommand deviceCommand = getPumpForwardRotateCommandByChannel(channelState.getChannelCode());
commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); 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); CommandUtil.wait(commandFutureList);
} catch (Exception e) { } catch (Exception e) {

10
src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java

@ -33,4 +33,14 @@ public class AuditRecord extends BaseEntity {
@Schema(description = "使用溶液量") @Schema(description = "使用溶液量")
private Double usedVolume; 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;
}
} }
Loading…
Cancel
Save