| | |
| | | @PostMapping(path = "add_unit", consumes = MediaType.APPLICATION_JSON_VALUE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @SsoAop() |
| | | public BaseResponse<Boolean> addGroupUnit(@RequestBody @Valid IrGroupUnit 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()); |
| | | } |
| | | Long groupId = Long.parseLong(po.get("groupId").toString()); |
| | | Long operator = Long.parseLong(po.get("operator").toString()); |
| | | List<Long> unitIds = (List<Long>) po.get("unitIds"); |
| | | try { |
| | | Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(po)).orElse(0); |
| | | if (rec == 0) { |
| | | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); |
| | | for (int i = 0; i < unitIds.size(); i++) { |
| | | Long unitId = unitIds.get(i); |
| | | IrGroupUnit irGroupUnit = new IrGroupUnit(); |
| | | irGroupUnit.setGroupId(groupId); |
| | | irGroupUnit.setUnitId(unitId); |
| | | irGroupUnit.setOperator(operator); |
| | | Integer rec = Optional.ofNullable(irrigateGroupSv.addGroupUnit(irGroupUnit)).orElse(0); |
| | | if (rec == 0) { |
| | | return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_PROJECT_FAIL.getMessage()); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("轮灌组添加灌溉单元异常", e); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 逻辑删除 轮灌组移除灌溉单元 |
| | | * 轮灌组移除灌溉单元 |
| | | * @param |
| | | * @return |
| | | */ |