| | |
| | | private final IrrigatePlanSv irrigatePlanSv; |
| | | private final CommandSv commandSv; |
| | | |
| | | /** |
| | | * 创建灌溉计划 |
| | | * 1. 添加灌溉计划 |
| | | * 2. 添加灌溉次序 |
| | | * 3. 添加灌溉计划操作记录 |
| | | * @param planAndSchedule |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> createPlan(@RequestBody @Valid IrrigatePlan planAndSchedule, BindingResult bindingResult){ |
| | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 删除灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "deletePlan") |
| | | public BaseResponse<Boolean> deletePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult) { |
| | | if(bindingResult != null && bindingResult.hasErrors()){ |
| | |
| | | return BaseResponseUtils.buildSuccess() ; |
| | | } |
| | | |
| | | /** |
| | | * 发布灌溉计划 |
| | | * 1. 修改灌溉计划状态为发布状态 |
| | | * 2. 添加灌溉计划操作记录 |
| | | * 3. 生成开阀计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "publishPlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> publishPlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | |
| | | //return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划最新状态 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getPlanLatestState") |
| | | public BaseResponse<Integer> getPlanLatestState(@RequestParam Long planId) { |
| | | if(planId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 终止灌溉计划 |
| | | * @param planSimple |
| | | * @param bindingResult |
| | | * @return |
| | | */ |
| | | @PostMapping(path = "terminatePlan", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | //@Transactional(rollbackFor = Exception.class) |
| | | public BaseResponse<Boolean> terminatePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){ |
| | |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | String terminateStartTimeStr = LocalDate.now().getYear() + "-01-01 00:00:00"; |
| | | Date terminateStartTime = Date.from(LocalDateTime.parse(terminateStartTimeStr, formatter).atZone(ZoneId.systemDefault()).toInstant()); |
| | | Integer terminateDuration = 9999; |
| | | Integer terminateDuration = 0; |
| | | |
| | | // 判断该计划是否可执行终止操作:未删除、未终止、已发布、当前时间小于计划结束时间 |
| | | Date planStartTime = irrigatePlanSv.getToTerminatePlan(planId); |
| | |
| | | return BaseResponseUtils.buildSuccess(); |
| | | } |
| | | |
| | | /** |
| | | * 获取未完成的计划列表,小程序计划列表页使用 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getNotCompletePlans") |
| | | public BaseResponse<List<VoPlans>> getNotCompletePlans() { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取已完成的计划列表,小程序计划列表页使用 |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getCompletedPlans") |
| | | public BaseResponse<QueryResultVo<List<VoPlans>>> getCompletedPlans(QueryConditionVo qo) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划发布结果 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getPublishResults") |
| | | public BaseResponse<VoPlanDetails> getPublishResults(@RequestParam Long planId) { |
| | | if(planId == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据计划ID获取计划终止操作结果 |
| | | * @param planId |
| | | * @return |
| | | */ |
| | | @GetMapping(path = "/getTerminateResults") |
| | | public BaseResponse<VoPlanDetails> getTerminateResults(@RequestParam Long planId) { |
| | | if(planId == null) { |