|  |  |  | 
|---|
|  |  |  | 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)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取项目下轮灌组 | 
|---|
|  |  |  | * @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 | 
|---|
|  |  |  | */ | 
|---|