23 changed files with 265 additions and 124 deletions
-
18src/main/java/com/iflytop/handacid/app/command/control/PumpRotateStartCommand.java
-
6src/main/java/com/iflytop/handacid/app/controller/AuditRecordController.java
-
28src/main/java/com/iflytop/handacid/app/controller/FormulationController.java
-
22src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java
-
22src/main/java/com/iflytop/handacid/app/controller/TestController.java
-
28src/main/java/com/iflytop/handacid/app/core/command/DeviceCommandGenerator.java
-
14src/main/java/com/iflytop/handacid/app/core/event/StateChangeEvent.java
-
18src/main/java/com/iflytop/handacid/app/core/listener/CommandFeedbackListener.java
-
6src/main/java/com/iflytop/handacid/app/core/state/ChannelState.java
-
18src/main/java/com/iflytop/handacid/app/model/dto/FormulationListDTO.java
-
24src/main/java/com/iflytop/handacid/app/model/vo/FormulationListVO.java
-
25src/main/java/com/iflytop/handacid/app/service/ChannelCtrlService.java
-
8src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java
-
38src/main/java/com/iflytop/handacid/app/websocket/server/WebSocketMessageType.java
-
16src/main/java/com/iflytop/handacid/app/websocket/server/WebSocketSender.java
-
4src/main/java/com/iflytop/handacid/common/model/entity/AuditRecord.java
-
6src/main/java/com/iflytop/handacid/common/model/entity/Channel.java
-
2src/main/java/com/iflytop/handacid/common/model/entity/Formulation.java
-
5src/main/java/com/iflytop/handacid/common/model/entity/ReceiveRecord.java
-
2src/main/java/com/iflytop/handacid/common/model/vo/FormulationVO.java
-
25src/main/java/com/iflytop/handacid/common/service/FormulationService.java
-
34src/main/java/com/iflytop/handacid/common/service/ReceiveRecordService.java
-
20src/main/resources/sql/init.sql
@ -1,14 +0,0 @@ |
|||||
package com.iflytop.handacid.app.core.event; |
|
||||
import lombok.AllArgsConstructor; |
|
||||
import lombok.Data; |
|
||||
|
|
||||
/** |
|
||||
* 状态变更事件 |
|
||||
*/ |
|
||||
@Data |
|
||||
@AllArgsConstructor |
|
||||
public class StateChangeEvent { |
|
||||
private String fieldPath; |
|
||||
private Object oldValue; |
|
||||
private Object newValue; |
|
||||
} |
|
@ -0,0 +1,18 @@ |
|||||
|
package com.iflytop.handacid.app.core.listener; |
||||
|
|
||||
|
import com.iflytop.handacid.app.core.event.CommandFeedbackEvent; |
||||
|
import com.iflytop.handacid.app.service.DeviceCommandService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.context.event.EventListener; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
@Component |
||||
|
@RequiredArgsConstructor |
||||
|
public class CommandFeedbackListener { |
||||
|
private final DeviceCommandService deviceCommandService; |
||||
|
|
||||
|
@EventListener |
||||
|
public void handleCommandFeedbackEvent(CommandFeedbackEvent event) { |
||||
|
deviceCommandService.completeCommandResponse(event.getJsonResponse()); |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.iflytop.handacid.app.model.dto; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class FormulationListDTO { |
||||
|
|
||||
|
@NotNull |
||||
|
@Schema(description = "溶液id") |
||||
|
private Long solutionId; |
||||
|
|
||||
|
@NotNull |
||||
|
@Schema(description = "浓度") |
||||
|
private Double concentration; |
||||
|
|
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.iflytop.handacid.app.model.vo; |
||||
|
|
||||
|
import io.swagger.v3.oas.annotations.media.Schema; |
||||
|
import jakarta.validation.constraints.NotNull; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class FormulationListVO { |
||||
|
|
||||
|
private Long id; |
||||
|
|
||||
|
@Schema(description = "加液量(mL)") |
||||
|
private Double volume; |
||||
|
|
||||
|
@Schema(description = "溶液ID") |
||||
|
private Long solutionId; |
||||
|
|
||||
|
@Schema(description = "溶液名称") |
||||
|
private String solutionName; |
||||
|
|
||||
|
@Schema(description = "溶液浓度") |
||||
|
private Double concentration; |
||||
|
|
||||
|
} |
@ -1,14 +1,48 @@ |
|||||
package com.iflytop.handacid.common.service; |
package com.iflytop.handacid.common.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.iflytop.handacid.app.core.state.ChannelState; |
||||
|
import com.iflytop.handacid.app.core.state.DeviceState; |
||||
import com.iflytop.handacid.common.mapper.ReceiveRecordMapper; |
import com.iflytop.handacid.common.mapper.ReceiveRecordMapper; |
||||
|
import com.iflytop.handacid.common.model.entity.Channel; |
||||
import com.iflytop.handacid.common.model.entity.ReceiveRecord; |
import com.iflytop.handacid.common.model.entity.ReceiveRecord; |
||||
|
import com.iflytop.handacid.common.model.entity.Solution; |
||||
|
import com.iflytop.handacid.common.model.entity.User; |
||||
import lombok.RequiredArgsConstructor; |
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
|
||||
/** |
/** |
||||
* 领取记录接口服务 |
* 领取记录接口服务 |
||||
*/ |
*/ |
||||
@Service |
@Service |
||||
@RequiredArgsConstructor |
@RequiredArgsConstructor |
||||
public class ReceiveRecordService extends ServiceImpl<ReceiveRecordMapper, ReceiveRecord> { |
public class ReceiveRecordService extends ServiceImpl<ReceiveRecordMapper, ReceiveRecord> { |
||||
|
private final UserService userService; |
||||
|
private final SolutionService solutionService; |
||||
|
private final ChannelService channelService; |
||||
|
private final DeviceState deviceState; |
||||
|
|
||||
|
public boolean receive(ReceiveRecord receiveRecord) { |
||||
|
User issuer = userService.getById(receiveRecord.getIssuerId()); |
||||
|
receiveRecord.setIssuerNickname(issuer.getNickname()); |
||||
|
User receiver = userService.getById(receiveRecord.getReceiverId()); |
||||
|
receiveRecord.setReceiverNickname(receiver.getNickname()); |
||||
|
Solution solution = solutionService.getById(receiveRecord.getSolutionId()); |
||||
|
receiveRecord.setSolutionName(solution.getName()); |
||||
|
this.save(receiveRecord); |
||||
|
|
||||
|
Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, receiveRecord.getChannelCode())); |
||||
|
channel.setCurrentVolume(receiveRecord.getReceivedVolume()); |
||||
|
channel.setReceivedVolume(receiveRecord.getReceivedVolume()); |
||||
|
channel.setConcentration(receiveRecord.getConcentration()); |
||||
|
channelService.updateById(channel); |
||||
|
|
||||
|
ChannelState channelState = deviceState.getChannelStateMap().get(receiveRecord.getChannelCode()); |
||||
|
channelState.setCurrentVolume(receiveRecord.getReceivedVolume()); |
||||
|
channelState.setReceivedVolume(receiveRecord.getReceivedVolume()); |
||||
|
channelState.setConcentration(receiveRecord.getConcentration()); |
||||
|
|
||||
|
return true; |
||||
|
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue