| New file |
| | |
| | | package com.dy.pipIrrIrrigate.irrigatePlan; |
| | | |
| | | import com.dy.common.aop.SsoAop; |
| | | import com.dy.common.webUtil.BaseResponse; |
| | | import com.dy.common.webUtil.BaseResponseUtils; |
| | | import com.dy.pipIrrIrrigate.irrigatePlan.dto.IrrigatePlan; |
| | | import com.dy.pipIrrIrrigate.irrigatePlan.dto.PlanSimple; |
| | | import jakarta.validation.Valid; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @author ZhuBaoMin |
| | | * @date 2025-06-30 14:58 |
| | | * @LastEditTime 2025-06-30 14:58 |
| | | * @Description |
| | | */ |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping(path = "plan") |
| | | @RequiredArgsConstructor |
| | | public class IrrigatePlanCtrl { |
| | | private final IrrigatePlanSv irrigatePlanSv; |
| | | |
| | | /** |
| | | * 创建灌溉计划 |
| | | * @param planAndSchedule |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> createPlan(@RequestBody @Valid IrrigatePlan planAndSchedule, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = irrigatePlanSv.createPlan(planAndSchedule); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 删除灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "deletePlan") |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> deletePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = irrigatePlanSv.deletePlan(planSimple); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 发布灌溉计划 |
| | | * 1. 修改灌溉计划状态为发布状态 |
| | | * 2. 添加灌溉计划操作记录 |
| | | * 3. 生成开阀计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "publishPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> publishPlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = irrigatePlanSv.publishPlan(planSimple); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 终止灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "terminatePlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> terminatePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | | return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); |
| | | } |
| | | |
| | | Map map_result = irrigatePlanSv.terminatePlan(planSimple); |
| | | if(map_result.get("success").equals(false)) { |
| | | return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); |
| | | } |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | } |