9 changed files with 198 additions and 12 deletions
-
19src/main/java/com/iflytop/colortitration/app/common/enums/TitrationStatus.java
-
37src/main/java/com/iflytop/colortitration/app/controller/TraytController.java
-
32src/main/java/com/iflytop/colortitration/app/controller/TubeController.java
-
10src/main/java/com/iflytop/colortitration/app/core/state/DeviceState.java
-
11src/main/java/com/iflytop/colortitration/app/core/state/TubeState.java
-
19src/main/java/com/iflytop/colortitration/app/model/dto/TrayTubeSetExistDTO.java
-
6src/main/java/com/iflytop/colortitration/app/service/DeviceInitService.java
-
51src/main/java/com/iflytop/colortitration/app/service/TrayService.java
-
25src/main/java/com/iflytop/colortitration/app/service/TubeService.java
@ -0,0 +1,19 @@ |
|||
package com.iflytop.colortitration.app.common.enums; |
|||
|
|||
/** |
|||
* 滴定状态 |
|||
*/ |
|||
public enum TitrationStatus { |
|||
/** |
|||
* 滴定未开始 |
|||
*/ |
|||
NOT_STARTED, |
|||
/** |
|||
* 滴定进行中 |
|||
*/ |
|||
IN_PROGRESS, |
|||
/** |
|||
* 滴定完毕 |
|||
*/ |
|||
COMPLETED; |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.iflytop.colortitration.app.controller; |
|||
|
|||
import com.iflytop.colortitration.app.common.enums.MultipleModuleCode; |
|||
import com.iflytop.colortitration.app.service.TrayService; |
|||
import com.iflytop.colortitration.common.result.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@Tag(name = "试管") |
|||
@RestController |
|||
@RequestMapping("/api/tray") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class TraytController { |
|||
private final TrayService trayService; |
|||
|
|||
@Operation(summary = "放入一个托盘") |
|||
@PostMapping("/tray-in") |
|||
public Result<?> trayIn(MultipleModuleCode moduleCode) { |
|||
trayService.trayIn(moduleCode); |
|||
return Result.success(); |
|||
} |
|||
|
|||
@Operation(summary = "拿走一个托盘") |
|||
@PostMapping("/tray-out") |
|||
public Result<?> trayOut(MultipleModuleCode moduleCode) { |
|||
trayService.trayOut(moduleCode); |
|||
return Result.success(); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.iflytop.colortitration.app.controller; |
|||
|
|||
import com.iflytop.colortitration.app.model.dto.TrayTubeSetExistDTO; |
|||
import com.iflytop.colortitration.app.service.TubeService; |
|||
import com.iflytop.colortitration.common.result.Result; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.PutMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Tag(name = "试管") |
|||
@RestController |
|||
@RequestMapping("/api/tube") |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class TubeController { |
|||
private final TubeService tubeService; |
|||
|
|||
@Operation(summary = "修改托盘是否存在试管") |
|||
@PutMapping("/set-tube-exist") |
|||
public Result<?> setTubeExist(@RequestBody List<TrayTubeSetExistDTO> trayTubeSetExistDTOList) { |
|||
tubeService.setTubeExist(trayTubeSetExistDTOList); |
|||
return Result.success(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.iflytop.colortitration.app.model.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import jakarta.validation.constraints.NotNull; |
|||
import lombok.Data; |
|||
|
|||
@Schema(description = "是否存在试管") |
|||
@Data |
|||
public class TrayTubeSetExistDTO { |
|||
|
|||
@NotNull |
|||
@Schema(description = "试管编号") |
|||
private Integer tubeNum; |
|||
|
|||
@NotNull |
|||
@Schema(description = "是否存在试管 true存在 false不存在") |
|||
private Boolean bubeExist; |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.iflytop.colortitration.app.service; |
|||
|
|||
import com.iflytop.colortitration.app.common.enums.MultipleModuleCode; |
|||
import com.iflytop.colortitration.app.core.state.DeviceState; |
|||
import com.iflytop.colortitration.app.core.state.TubeState; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.ObjectProvider; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class TrayService { |
|||
private final DeviceState deviceState; |
|||
private final ObjectProvider<TubeState> tubeStateObjectProvider; |
|||
|
|||
/** |
|||
* 放入了一个新托盘 |
|||
*/ |
|||
public synchronized void trayIn(MultipleModuleCode moduleCode) { |
|||
if (MultipleModuleCode.MODULE_1.equals(moduleCode)) { |
|||
for (int i = 1; i < 17; i++) { |
|||
deviceState.getTrayTubeStateMap().put(i, tubeStateObjectProvider.getObject(i)); |
|||
} |
|||
deviceState.setTrayExist1(true); |
|||
} else if (MultipleModuleCode.MODULE_2.equals(moduleCode)) { |
|||
for (int i = 17; i < 33; i++) { |
|||
deviceState.getTrayTubeStateMap().put(i, tubeStateObjectProvider.getObject(i)); |
|||
} |
|||
deviceState.setTrayExist2(true); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 拿走了托盘 |
|||
*/ |
|||
public synchronized void trayOut(MultipleModuleCode moduleCode) { |
|||
if (MultipleModuleCode.MODULE_1.equals(moduleCode)) { |
|||
for (int i = 1; i < 17; i++) { |
|||
deviceState.getTrayTubeStateMap().remove(i); |
|||
} |
|||
deviceState.setTrayExist1(false); |
|||
} else if (MultipleModuleCode.MODULE_2.equals(moduleCode)) { |
|||
for (int i = 17; i < 33; i++) { |
|||
deviceState.getTrayTubeStateMap().remove(i); |
|||
} |
|||
deviceState.setTrayExist2(false); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.iflytop.colortitration.app.service; |
|||
|
|||
import com.iflytop.colortitration.app.core.state.DeviceState; |
|||
import com.iflytop.colortitration.app.model.dto.TrayTubeSetExistDTO; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class TubeService { |
|||
private final DeviceState deviceState; |
|||
/** |
|||
* 修改托盘中试管是否存在 |
|||
*/ |
|||
public void setTubeExist(List<TrayTubeSetExistDTO> trayTubeSetExistDTOList) { |
|||
for (TrayTubeSetExistDTO trayTubeSetExistDTO : trayTubeSetExistDTOList) { |
|||
deviceState.getTrayTubeStateMap().get(trayTubeSetExistDTO.getTubeNum()).setBubeExist(trayTubeSetExistDTO.getBubeExist()); |
|||
} |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue