From 4513ef24bf9b188c2a77d6ce94f1a6b7e9ebf0e6 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期日, 27 四月 2025 20:40:19 +0800 Subject: [PATCH] fix(irrigatePlan): 修正灌溉计划开始时间逻辑 --- pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java | 120 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 71 insertions(+), 49 deletions(-) diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java index 9f07908..830de5b 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java @@ -10,6 +10,7 @@ import com.dy.pipIrrGlobal.pojoBa.BaClient; import com.dy.pipIrrGlobal.pojoPr.PrDivide; import com.dy.pipIrrGlobal.voPr.VoDivide; +import com.dy.pipIrrGlobal.voPr.VoDivideDetails; import com.dy.pipIrrGlobal.voSe.VoActiveCard; import com.dy.pipIrrProject.result.ProjectResultCode; import io.swagger.v3.oas.annotations.Operation; @@ -67,8 +68,13 @@ @SsoAop() public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){ try { - QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo); - return BaseResponseUtils.buildSuccess(res); + //QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo); + //if(res.itemTotal != null && res.itemTotal > 0) { + // return BaseResponseUtils.buildSuccess(res); + //}else { + // return BaseResponseUtils.buildSuccess(ProjectResultCode.NO_DIVIDES.getMessage()); + //} + return BaseResponseUtils.buildSuccess(divideSv.getDivides(vo)); } catch (Exception e) { log.error("鑾峰彇寮�鍗¤褰曞紓甯�", e); return BaseResponseUtils.buildException(e.getMessage()) ; @@ -91,10 +97,16 @@ }) @GetMapping(path = "/getone/{id}") @SsoAop() - public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){ + //public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){ + public BaseResponse<VoDivideDetails> getOneDivide(@PathVariable("id") Long id){ try { - PrDivide res = divideSv.getOneDivide(id); - return BaseResponseUtils.buildSuccess(res); + //PrDivide res = divideSv.getOneDivide(id); + //if(res != null) { + // return BaseResponseUtils.buildSuccess(res); + //}else { + // return BaseResponseUtils.buildErrorMsg(ProjectResultCode.NO_DIVIDES.getMessage()); + //} + return BaseResponseUtils.buildSuccess(divideSv.getDivideDetails(id)); } catch (Exception e) { log.error("鏌ヨ鍐滄埛寮傚父", e); return BaseResponseUtils.buildException(e.getMessage()) ; @@ -119,39 +131,42 @@ @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> add(@RequestBody @Valid PrDivide po, BindingResult bindingResult){ + public BaseResponse<Boolean> add(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛� - Long villageId = po.getVillageid(); + Long villageId = po.getVillageId(); - /** - * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭� - */ - Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); - if(map_districts.size() <= 0) { - return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎"); + PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po); + + if (villageId!=null){ + /** + * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭� + */ + Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); + if(map_districts.size() <= 0) { + return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎"); + } + Long countryId = Long.parseLong(map_districts.get("countryId").toString()); + Long townId = Long.parseLong(map_districts.get("townId").toString()); + prDivide.setCountyid(countryId); + prDivide.setTownid(townId); } - Long countryId = Long.parseLong(map_districts.get("countryId").toString()); - Long townId = Long.parseLong(map_districts.get("townId").toString()); - po.setCountyid(countryId); - po.setTownid(townId); - Date operateTime = new Date(); - po.setOperatedt(operateTime); - po.setDeleted((byte)0); - Integer rec = Optional.ofNullable(divideSv.addDivide(po)).orElse(0); + prDivide.setOperatedt(operateTime); + prDivide.setDeleted((byte)0); + Integer rec = Optional.ofNullable(divideSv.addDivide(prDivide)).orElse(0); if(rec == 0) { - return BaseResponseUtils.buildFail(ProjectResultCode.DIVIDE_FAIL.getMessage()); + return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DIVIDE_FAIL.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; } /** * 鏍规嵁鍒嗘按鎴縄D閫昏緫鍒犻櫎鍒嗘按鎴� - * @param id + * @param map * @return */ @Operation(summary = "鍒犻櫎涓�涓垎姘存埧", description = "鍒犻櫎涓�涓垎姘存埧鏁版嵁") @@ -164,14 +179,19 @@ ) }) - @GetMapping(path = "/delone/{id}") + //@GetMapping(path = "/delone/{id}") + @PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE) @SsoAop() - public BaseResponse<Boolean> deleteDivideById(@PathVariable("id") Long id){ + public BaseResponse<Boolean> deleteDivideById(@RequestBody Map map){ + Long id = Optional.ofNullable(Long.parseLong(map.get("id").toString())).orElse(0L); + if(id == 0) + return BaseResponseUtils.buildException(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage()); + try { Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0); - if(res == 0) { - return BaseResponseUtils.buildFail("鍒嗘按鎴垮垹闄ゅけ璐�"); - } + if(res == 0) + return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage()); + return BaseResponseUtils.buildSuccess(true); } catch (Exception e) { log.error("鍒犻櫎鍒嗘按鎴垮紓甯�", e); @@ -197,34 +217,36 @@ @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) @Transactional(rollbackFor = Exception.class) @SsoAop() - public BaseResponse<Boolean> update(@RequestBody @Valid PrDivide po, BindingResult bindingResult){ + public BaseResponse<Boolean> update(@RequestBody @Valid DtoDivide po, BindingResult bindingResult){ if(bindingResult != null && bindingResult.hasErrors()){ - return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } // 鎺ユ敹鏉戠紪鍙凤紙涓婚敭锛� - Long villageId = po.getVillageid(); + Long villageId = po.getVillageId(); - /** - * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭� - */ - Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); - if(map_districts.size() <= 0) { - return BaseResponseUtils.buildFail("鍖哄垝淇℃伅鏈夎"); + PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po); + + if (villageId!=null){ + /** + * 鑾峰彇5绾ц鏀垮尯鍒掍俊鎭� + */ + Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); + if(map_districts.size() <= 0) { + return BaseResponseUtils.buildErrorMsg("鍖哄垝淇℃伅鏈夎"); + } + Long countryId = Long.parseLong(map_districts.get("countryId").toString()); + Long townId = Long.parseLong(map_districts.get("townId").toString()); + prDivide.setCountyid(countryId); + prDivide.setTownid(townId); } - Long countryId = Long.parseLong(map_districts.get("countryId").toString()); - Long townId = Long.parseLong(map_districts.get("townId").toString()); - - po.setCountyid(countryId); - po.setTownid(townId); - Date operateTime = new Date(); - po.setOperatedt(operateTime); + prDivide.setOperatedt(operateTime); - Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(po)).orElse(0); + Integer rec = Optional.ofNullable(divideSv.updateByPrimaryKey(prDivide)).orElse(0); if(rec == 0) { - return BaseResponseUtils.buildFail("鍒嗘按鎴夸慨鏀瑰け璐�"); + return BaseResponseUtils.buildErrorMsg("鍒嗘按鎴夸慨鏀瑰け璐�"); } return BaseResponseUtils.buildSuccess(true) ; } @@ -235,8 +257,8 @@ * @param vo */ @SneakyThrows(IOException.class) - @RequestMapping(value = "/exportDivides", method = RequestMethod.GET) - public void exportDivides(HttpServletResponse response, QueryVo vo) { + @RequestMapping(value = "/export", method = RequestMethod.GET) + public void export(HttpServletResponse response, QueryVo vo) { setExcelRespProp(response, "鍒嗘按鎴垮垪琛�"); //List<VoDivide> memberList = LocalJsonUtil.getListFromJson("json/members.json", VoDivide.class); List<VoDivide> memberList = divideSv.exportDivides(vo); -- Gitblit v1.8.0