Administrator
2024-01-05 8ffdb9e3170e5ca530b652cb4600046bfb08a925
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/intakeController/IntakeControllerCtrl.java
@@ -7,6 +7,8 @@
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoBa.BaClient;
import com.dy.pipIrrGlobal.pojoPr.PrIntakeController;
import com.dy.pipIrrProject.controller.ControllerSv;
import com.dy.pipIrrProject.intake.IntakeSv;
import com.dy.pipIrrProject.result.ProjectResultCode;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
@@ -38,12 +40,13 @@
@RequiredArgsConstructor
public class IntakeControllerCtrl {
    private final IntakeControllerSv intakeControllerSv;
    private final IntakeSv intakeSv;
    private final ControllerSv controllerSv;
    /**
     * 添加取水口/控制器捆绑记录
     * 1. 判断取水口是否存在
     * 2. 判断控制器是否存在
     * 3. 判断取水口、控制器绑定关系是否已存在
     *      若取水口或控制器不存在需提示用户
     *      若取水口已经与控制器绑定需提示用户
     */
    @Operation(summary = "添加绑定记录", description = "添加绑定记录")
    @ApiResponses(value = {
@@ -60,6 +63,12 @@
    public BaseResponse<Boolean> bind(@RequestBody @Valid DtoIntakeController po, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        // 根据编号分别获取取水口、控制器未删除记录数
        Integer recIntke = Optional.ofNullable(intakeSv.getRecordCountOfIntake(po.getIntakeId())).orElse(0);
        Integer recController = Optional.ofNullable(controllerSv.getRecordCountOfController(po.getControllerId())).orElse(0);
        if(recIntke == 0 || recController == 0) {
            return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_OR_CONTROLLER_NO_EXIST.getMessage());
        }
        Integer recordCount = Optional.ofNullable(intakeControllerSv.getBindRecordCount(po.getIntakeId(), po.getControllerId(), (byte)1)).orElse(0);
@@ -102,6 +111,13 @@
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        // 根据编号分别获取取水口、控制器未删除记录数
        Integer recIntke = Optional.ofNullable(intakeSv.getRecordCountOfIntake(po.getIntakeId())).orElse(0);
        Integer recController = Optional.ofNullable(controllerSv.getRecordCountOfController(po.getControllerId())).orElse(0);
        if(recIntke == 0 || recController == 0) {
            return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_OR_CONTROLLER_NO_EXIST.getMessage());
        }
        Integer recordCount = Optional.ofNullable(intakeControllerSv.getBindRecordCount(po.getIntakeId(), po.getControllerId(), (byte)2)).orElse(0);
        if(recordCount > 0) {
            return BaseResponseUtils.buildFail(ProjectResultCode.INTAKE_CONTROLLER_HAS_UNBOUND.getMessage());