|  |  | 
 |  |  | import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit; | 
 |  |  | import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup; | 
 |  |  | import com.dy.pipIrrGlobal.voIr.VoGroup; | 
 |  |  | import com.dy.pipIrrGlobal.voIr.VoGroupDetail; | 
 |  |  | import com.dy.pipIrrGlobal.voIr.VoGroupOne; | 
 |  |  | import com.dy.pipIrrGlobal.voIr.VoGroupSimple; | 
 |  |  | import com.dy.pipIrrGlobal.voSe.VoActiveCard; | 
 |  |  | import com.dy.pipIrrIrrigate.irrigateGroup.dto.GroupClient; | 
 |  |  | import com.dy.pipIrrIrrigate.irrigateGroup.dto.IrrigateGroup; | 
 |  |  | import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup; | 
 |  |  | import com.dy.pipIrrIrrigate.result.IrrigateResultCode; | 
 |  |  | import io.swagger.v3.oas.annotations.Operation; | 
 |  |  | import io.swagger.v3.oas.annotations.media.Content; | 
 |  |  | 
 |  |  |         if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  |          | 
 |  |  |         // 先判断表内是否存在相同的 groupCode | 
 |  |  |         if (irrigateGroupSv.existsByGroupCode(po.getGroupCode())) { | 
 |  |  |             return BaseResponseUtils.buildFail(IrrigateResultCode.GROUP_CODE_ALREADY_EXISTS.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Map map_result = irrigateGroupSv.addIrrigateGroup(po); | 
 |  |  |         if(map_result.get("success").equals(false)) { | 
 |  |  | 
 |  |  |         return BaseResponseUtils.buildSuccess() ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 修改轮灌组,新代码 | 
 |  |  |      * @param po | 
 |  |  |      * @param bindingResult | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @PostMapping(path = "updateIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE) | 
 |  |  |     @Transactional(rollbackFor = Exception.class) | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<Boolean> updateIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult){ | 
 |  |  |         if (bindingResult != null && bindingResult.hasErrors()) { | 
 |  |  |             return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if(po.getGroupId() == null) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空"); | 
 |  |  |         } | 
 |  |  |          | 
 |  |  |         // 先判断表内是否存在相同的 groupCode(排除当前正在修改的记录) | 
 |  |  |         if (irrigateGroupSv.existsByGroupCodeExcludeId(po.getGroupCode(), po.getGroupId())) { | 
 |  |  |             return BaseResponseUtils.buildFail(IrrigateResultCode.GROUP_CODE_ALREADY_EXISTS.getMessage()); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Map map_result = irrigateGroupSv.updateIrrigateGroup(po); | 
 |  |  |         if(map_result.get("success").equals(false)) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
 |  |  |         } | 
 |  |  |         return BaseResponseUtils.buildSuccess() ; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取轮灌组列表,新代码 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path = "/getSimpleGroups") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<QueryResultVo<List<VoGroupSimple>>> getSimpleGroups(QoGroup qo) { | 
 |  |  |         try { | 
 |  |  |             QueryResultVo<List<VoGroupSimple>> res = irrigateGroupSv.getSimpleGroups(qo); | 
 |  |  |             return BaseResponseUtils.buildSuccess(res); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("获取项目记录异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取项目下轮灌组 | 
 |  |  |      * @param qo | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path = "/getGroupsByProjectId") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<List<VoGroupSimple>> getGroupsByProjectId(QoGroup qo) { | 
 |  |  |         if(qo.getProjectId() == null) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("请选择项目"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         try { | 
 |  |  |             return BaseResponseUtils.buildSuccess(irrigateGroupSv.getGroupsByProjectId(qo)); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("获取轮灌组记录异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取全部轮灌组,新代码 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path = "/getAllGroups") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<List<VoGroupSimple>> getAllGroups() { | 
 |  |  |         try { | 
 |  |  |             return BaseResponseUtils.buildSuccess(irrigateGroupSv.getAllGroups()); | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             log.error("获取项目记录异常", e); | 
 |  |  |             return BaseResponseUtils.buildException(e.getMessage()); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取轮灌组详情,新代码 | 
 |  |  |      * @param groupId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @GetMapping(path = "getGroupDetail") | 
 |  |  |     @SsoAop() | 
 |  |  |     public BaseResponse<VoGroupDetail> getGroupDetail(@RequestParam Long groupId) { | 
 |  |  |         if(groupId == null) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         Map map_result = irrigateGroupSv.getGroupDetail(groupId); | 
 |  |  |         if(map_result.get("success").equals(false)) { | 
 |  |  |             return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString()); | 
 |  |  |         } | 
 |  |  |         return BaseResponseUtils.buildSuccess(map_result.get("content")) ; | 
 |  |  |     } | 
 |  |  | } |