| | |
| | | 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; |
| | |
| | | @SsoAop() |
| | | public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){ |
| | | try { |
| | | QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo); |
| | | if(res.itemTotal != null && res.itemTotal > 0) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }else { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage()); |
| | | } |
| | | //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()) ; |
| | |
| | | }) |
| | | @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); |
| | | if(res != null) { |
| | | return BaseResponseUtils.buildSuccess(res); |
| | | }else { |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage()); |
| | | } |
| | | //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()) ; |
| | |
| | | @SsoAop() |
| | | 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(); |
| | |
| | | */ |
| | | Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); |
| | | if(map_districts.size() <= 0) { |
| | | return BaseResponseUtils.buildFail("区划信息有误"); |
| | | return BaseResponseUtils.buildErrorMsg("区划信息有误"); |
| | | } |
| | | Long countryId = Long.parseLong(map_districts.get("countryId").toString()); |
| | | Long townId = Long.parseLong(map_districts.get("townId").toString()); |
| | |
| | | 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) ; |
| | | } |
| | |
| | | try { |
| | | Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0); |
| | | if(res == 0) |
| | | return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage()); |
| | | return BaseResponseUtils.buildErrorMsg(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage()); |
| | | |
| | | return BaseResponseUtils.buildSuccess(true); |
| | | } catch (Exception e) { |
| | |
| | | @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(); |
| | | |
| | | PrDivide prDivide = DtoToDividePojo.INSTANCT.po2vo(po); |
| | | |
| | | if (villageId!=null){ |
| | | /** |
| | |
| | | */ |
| | | Map map_districts = Optional.ofNullable(divideSv.getDistrictsByVillageId(villageId)).orElse(new HashMap()); |
| | | if(map_districts.size() <= 0) { |
| | | return BaseResponseUtils.buildFail("区划信息有误"); |
| | | return BaseResponseUtils.buildErrorMsg("区划信息有误"); |
| | | } |
| | | Long countryId = Long.parseLong(map_districts.get("countryId").toString()); |
| | | Long townId = Long.parseLong(map_districts.get("townId").toString()); |
| | | po.setCountyid(countryId); |
| | | po.setTownid(townId); |
| | | prDivide.setCountyid(countryId); |
| | | prDivide.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) ; |
| | | } |