Browse Source

fix:调整工艺配置试管格式

master
白凤吉 1 week ago
parent
commit
d43fdde84c
  1. 5
      src/main/java/com/iflytop/colortitration/app/controller/CraftsController.java
  2. 12
      src/main/java/com/iflytop/colortitration/app/model/dto/SetCraftsDTO.java
  3. 30
      src/main/java/com/iflytop/colortitration/common/service/CraftsService.java

5
src/main/java/com/iflytop/colortitration/app/controller/CraftsController.java

@ -19,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
@Tag(name = "\uD83E\uDD16工艺管理")
@RestController
@ -74,8 +75,8 @@ public class CraftsController {
@Operation(summary = "配置试管工艺")
@PostMapping("/set-crafts")
public Result<?> setCrafts(@Valid @RequestBody SetCraftsDTO startCraftsDTO) {
craftsService.setCrafts(startCraftsDTO);
public Result<?> setCrafts(@Valid @RequestBody List<SetCraftsDTO> startCraftsDTOList) {
craftsService.setCrafts(startCraftsDTOList);
return Result.success();
}

12
src/main/java/com/iflytop/colortitration/app/model/dto/SetCraftsDTO.java

@ -2,7 +2,6 @@ package com.iflytop.colortitration.app.model.dto;
import com.iflytop.colortitration.app.common.enums.MultipleModuleCode;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
@ -10,13 +9,12 @@ import java.util.List;
@Schema(description = "设置试管工艺")
@Data
public class SetCraftsDTO {
@NotNull
@Schema(description = "工艺id")
private Long craftId;
@Schema(description = "配置的工艺id")
private Long craftsId;
@Schema(description = "可以使用的滴定模块")
private List<MultipleModuleCode> moduleCodes;
private List<MultipleModuleCode> titrationModuleCodes;
@Schema(description = "试管编号")
private List<Integer> tubeNums;
@Schema(description = "试管编号")
private Integer tubeNum;
}

30
src/main/java/com/iflytop/colortitration/common/service/CraftsService.java

@ -2,7 +2,6 @@ package com.iflytop.colortitration.common.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.colortitration.app.common.enums.TitrationStatus;
import com.iflytop.colortitration.app.core.crafts.CraftsContext;
import com.iflytop.colortitration.app.core.crafts.CraftsDispatcher;
import com.iflytop.colortitration.app.core.state.DeviceState;
@ -14,6 +13,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 工艺接口服务
*/
@ -31,21 +32,18 @@ public class CraftsService extends ServiceImpl<CraftsMapper, Crafts> {
/**
* 设置试管的工艺
*/
public void setCrafts(SetCraftsDTO startCraftsDTO) {
Crafts crafts = this.getById(startCraftsDTO.getCraftId());
for (Integer tubeNum : startCraftsDTO.getTubeNums()) {
TubeState tubeState = deviceState.getTrayTubeStateMap().get(tubeNum);
if (tubeState != null && tubeState.getTitrationStatus() == TitrationStatus.NOT_STARTED) {
tubeState.setCraftsId(crafts.getId());
tubeState.setCraftsName(crafts.getName());
tubeState.setTitrationModuleCodes(startCraftsDTO.getModuleCodes());
CraftsContext job = new CraftsContext();
job.setTubeNum(tubeNum);
job.setCrafts(crafts);
job.setSelectedModules(startCraftsDTO.getModuleCodes());
craftsDispatcher.addCraftsJob(job);
}
public void setCrafts(List<SetCraftsDTO> startCraftsDTOList) {
for (SetCraftsDTO startCraftsDTO : startCraftsDTOList) {
TubeState tubeState = deviceState.getTrayTubeStateMap().get(startCraftsDTO.getTubeNum());
Crafts crafts = this.getById(startCraftsDTO.getCraftsId());
tubeState.setCraftsId(crafts.getId());
tubeState.setCraftsName(crafts.getName());
tubeState.setTitrationModuleCodes(startCraftsDTO.getTitrationModuleCodes());
CraftsContext job = new CraftsContext();
job.setTubeNum(startCraftsDTO.getTubeNum());
job.setCrafts(crafts);
job.setSelectedModules(startCraftsDTO.getTitrationModuleCodes());
craftsDispatcher.addCraftsJob(job);
}
}

Loading…
Cancel
Save