|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 逻辑删除灌溉单元 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 批量删除 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param groupIds | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改灌溉单元 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param po | 
|---|
|  |  |  | * @param bindingResult | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE) | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult){ | 
|---|
|  |  |  | public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 分页查询 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param vo | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(path = "add_unit", consumes = MediaType.APPLICATION_JSON_VALUE) | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid Map<String,Object> po, BindingResult bindingResult) { | 
|---|
|  |  |  | public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid Map<String, Object> po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | *  轮灌组移除灌溉单元 | 
|---|
|  |  |  | * 轮灌组移除灌溉单元 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(path = "remove_unit") | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> deleteGroupUnit(@RequestBody @Valid Map<String,Object> po, BindingResult bindingResult) { | 
|---|
|  |  |  | public BaseResponse<Boolean> deleteGroupUnit(@RequestBody @Valid Map<String, Object> po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 修改轮灌组绑定的灌溉单元 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping(path = "updateBindUnits", consumes = MediaType.APPLICATION_JSON_VALUE) | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | @SsoAop() | 
|---|
|  |  |  | public BaseResponse<Boolean> updateBindUnits(@RequestBody @Valid Map<String,Object> po, BindingResult bindingResult){ | 
|---|
|  |  |  | public BaseResponse<Boolean> updateBindUnits(@RequestBody @Valid Map<String, Object> po, BindingResult bindingResult) { | 
|---|
|  |  |  | if (bindingResult != null && bindingResult.hasErrors()) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Long groupId = Long.parseLong(po.get("groupId").toString()); | 
|---|
|  |  |  | Long operator = Long.parseLong(po.get("operator").toString()); | 
|---|
|  |  |  | List<Long> newUnitIds = (List<Long>) po.get("unitIds"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Long> oldUnitIds = irrigateGroupSv.getGroupBindUnits(groupId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | IrGroupUnit irGroupUnit = new IrGroupUnit(); | 
|---|
|  |  |  | irGroupUnit.setGroupId(groupId); | 
|---|
|  |  |  | irGroupUnit.setOperator(operator); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | for (int j = 0; j < oldUnitIds.size(); j++) { | 
|---|
|  |  |  | Long oldUnitId = oldUnitIds.get(j); | 
|---|
|  |  |  | IrGroupUnit irGroupUnit1 = new IrGroupUnit(); | 
|---|
|  |  |  | irGroupUnit1.setGroupId(groupId); | 
|---|
|  |  |  | irGroupUnit1.setUnitId(oldUnitId); | 
|---|
|  |  |  | irGroupUnit1.setOperator(operator); | 
|---|
|  |  |  | Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit1)).orElse(0); | 
|---|
|  |  |  | if (rec == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); | 
|---|
|  |  |  | if (!newUnitIds.toString().contains(oldUnitId.toString())) { | 
|---|
|  |  |  | irGroupUnit.setUnitId(oldUnitId); | 
|---|
|  |  |  | Integer rec = Optional.ofNullable(irrigateGroupSv.deleteGroupUnit(irGroupUnit)).orElse(0); | 
|---|
|  |  |  | if (rec == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (int i = 0; i < newUnitIds.size(); i++) { | 
|---|
|  |  |  | Long newUnitId = newUnitIds.get(i); | 
|---|
|  |  |  | IrGroupUnit irGroupUnit2 = new IrGroupUnit(); | 
|---|
|  |  |  | irGroupUnit2.setGroupId(groupId); | 
|---|
|  |  |  | irGroupUnit2.setUnitId(newUnitId); | 
|---|
|  |  |  | irGroupUnit2.setOperator(operator); | 
|---|
|  |  |  | Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit2)).orElse(0); | 
|---|
|  |  |  | if (rec == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); | 
|---|
|  |  |  | if (!oldUnitIds.toString().contains(newUnitId.toString())) { | 
|---|
|  |  |  | irGroupUnit.setUnitId(newUnitId); | 
|---|
|  |  |  | Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit)).orElse(0); | 
|---|
|  |  |  | if (rec == 0) { | 
|---|
|  |  |  | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|