liurunyu
4 天以前 e8937f27fce194d015ce6c27d286e7fc89f5e580
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
package com.dy.pipIrrIrrigate.irrigateGroup;
 
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.pojoIr.IrGroupClient;
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;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
 
/**
 * @author :WuZeYu
 * @Date :2024/5/21  16:19
 * @LastEditTime :2024/5/21  16:19
 * @Description
 */
@Slf4j
@Tag(name = "轮灌组", description = "轮灌组")
@RestController
@RequestMapping(path = "group")
@RequiredArgsConstructor
public class IrrigateGroupCtrl {
    @Autowired
    private IrrigateGroupSv irrigateGroupSv;
 
    /**
     * 创建轮灌组
     *
     * @param po            轮灌组实体对象
     * @param bindingResult
     * @return 添加是否成功
     */
    @Operation(summary = "创建轮灌组记录", description = "创建轮灌组记录")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "add", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> add(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        try {
            Integer rec = Optional.ofNullable(irrigateGroupSv.addIrrigateGroup(po)).orElse(0);
            if (rec == 0) {
                return BaseResponseUtils.buildFail(IrrigateResultCode.ADD_GROUP_FAIL.getMessage());
            }
        } catch (Exception e) {
            log.error("创建轮灌组异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 逻辑删除灌溉单元
     *
     * @param
     * @return
     */
    @Operation(summary = "逻辑删除轮灌组", description = "逻辑删除轮灌组")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "delete")
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> delete(@RequestBody Map map) {
        if (map == null || map.size() <= 0) {
            BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_GROUP_ID.getMessage());
        }
        Long groupId = Long.parseLong(map.get("id").toString());
        try {
            Integer rows = irrigateGroupSv.deleteIrrigateGroup(groupId);
            if (rows == 0) {
                return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_GROUP_FAIL.getMessage());
            }
        } catch (Exception e) {
            log.error("删除轮灌组异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 批量删除
     *
     * @param groupIds
     * @return
     */
    @PostMapping(path = "delete_batch", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> delete_batch(@RequestBody Map<String, List> groupIds) {
        if (groupIds == null || groupIds.size() <= 0) {
            BaseResponseUtils.buildFail(IrrigateResultCode.PLEASE_INPUT_PROJECT_ID.getMessage());
        }
        List ids = groupIds.get("groupIds");
        for (int i = 0; i < ids.size(); i++) {
            long groupId = Long.parseLong(ids.get(i).toString());
            try {
                Integer rows = irrigateGroupSv.deleteIrrigateGroup(groupId);
                if (rows == 0) {
                    return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_GROUP_FAIL.getMessage());
                }
            } catch (Exception e) {
                log.error("删除轮灌组异常", e);
                return BaseResponseUtils.buildException(e.getMessage());
            }
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 修改灌溉单元
     *
     * @param po
     * @param bindingResult
     * @return
     */
    @Operation(summary = "修改轮灌组", description = "修改轮灌组")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> update(@RequestBody @Valid IrIrrigateGroup po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        try {
            Integer rec = Optional.ofNullable(irrigateGroupSv.updateIrrigateGroup(po)).orElse(0);
            if (rec == 0) {
                return BaseResponseUtils.buildFail(IrrigateResultCode.UPDATE_GROUP_FAIL.getMessage());
            }
        } catch (Exception e) {
            log.error("修改轮灌组异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 获取一个轮灌组
     *
     * @return 获取一个轮灌组
     */
    @Operation(summary = "获取一个轮灌组", description = "获取一个轮灌组")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "获取一个轮灌组(BaseResponse.content:{})",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = IrIrrigateGroup.class))}
            )
    })
    @GetMapping(path = "one")
    @SsoAop()
    public BaseResponse<VoGroupOne> one(@RequestParam Long id) {
        VoGroupOne irIrrigateGroup = this.irrigateGroupSv.selectById(id);
 
        return BaseResponseUtils.buildSuccess(irIrrigateGroup);
 
    }
 
    /**
     * 分页查询
     *
     * @param vo
     * @return
     */
    @Operation(summary = "获得一页轮灌组记录", description = "获得一页轮灌组记录")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "获得一页灌溉单元记录(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoActiveCard.class))}
            )
    })
    @GetMapping(path = "some")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoGroup>>> getIrrigateGroups(QueryVo vo) {
        try {
            QueryResultVo<List<VoGroup>> res = irrigateGroupSv.getIrrigateGroups(vo);
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("获取轮灌组记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
    /**
     * 轮灌组添加灌溉单元
     *
     * @param po            轮灌组灌溉单元中间表
     * @param bindingResult
     * @return 添加是否成功
     */
    @Operation(summary = "轮灌组添加灌溉单元", description = "轮灌组添加灌溉单元")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @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) {
        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 {
            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.GROUP_ADD_UNIT_FAIL.getMessage());
                }
            }
        } catch (Exception e) {
            log.error("轮灌组添加灌溉单元异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 轮灌组移除灌溉单元
     *
     * @param
     * @return
     */
    @Operation(summary = "轮灌组移除灌溉单元", description = "轮灌组移除灌溉单元")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "remove_unit")
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    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());
        }
        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 {
            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.deleteGroupUnit(irGroupUnit)).orElse(0);
                if (rec == 0) {
                    return BaseResponseUtils.buildFail(IrrigateResultCode.DELETE_PROJECT_FAIL.getMessage());
                }
            }
 
        } catch (Exception e) {
            log.error("轮灌组移除灌溉单元异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    @GetMapping(path = "bind_units")
    @SsoAop()
    public BaseResponse<List<String>> getGroupBindUnits(Long id) {
        try {
            List<Long> res = irrigateGroupSv.getGroupBindUnits(id);
            ArrayList<Object> list = new ArrayList<>();
            for (int i = 0; i < res.size(); i++) {
                String aLong = res.get(i).toString();
                list.add(aLong);
            }
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("获取一个轮灌组绑定灌溉单元记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
    @GetMapping(path = "notBind_units")
    @SsoAop()
    public BaseResponse<List<String>> getNotBindUnits() {
        try {
            List<Long> res = irrigateGroupSv.getNotBindUnits();
            ArrayList<Object> list = new ArrayList<>();
            for (int i = 0; i < res.size(); i++) {
                String aLong = res.get(i).toString();
                list.add(aLong);
            }
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("获取未绑定轮灌组的灌溉单元id记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
 
    /**
     * 修改轮灌组绑定的灌溉单元
     *
     * @param po            轮灌组灌溉单元中间表
     * @param bindingResult
     * @return 添加是否成功
     */
    @Operation(summary = "修改轮灌组绑定的灌溉单元", description = "修改轮灌组绑定的灌溉单元")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @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) {
        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<String> newUnitIds = (List<String>) 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);
                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 = Long.parseLong(newUnitIds.get(i));
                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) {
            log.error("修改轮灌组绑定的灌溉单元异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 轮灌组关联农户
     * @param po
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "add_group_client", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> addGroupClient(@RequestBody @Valid GroupClient po, BindingResult bindingResult) {
        if (bindingResult != null && bindingResult.hasErrors()) {
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        IrGroupClient irGroupClient = new IrGroupClient();
        irGroupClient.setGroupId(po.getGroupId());
        irGroupClient.setClientId(po.getClientId());
        irGroupClient.setOperator(po.getOperator());
        irGroupClient.setOperateTime(new Date());
 
        try {
            Long rec = Optional.ofNullable(irrigateGroupSv.addGroupClient(irGroupClient)).orElse(0L);
            if (rec == 0) {
                return BaseResponseUtils.buildErrorMsg(IrrigateResultCode.GRPUP_ASSOCIATE_CLIENT_FAIL.getMessage());
            }
        } catch (Exception e) {
            return BaseResponseUtils.buildException(e.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true);
    }
 
    /**
     * 新增轮灌组,新代码
     * @param po
     * @param bindingResult
     * @return
     */
    @PostMapping(path = "addIrrigateGroup", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> addIrrigateGroup(@RequestBody @Valid IrrigateGroup po, BindingResult bindingResult) {
        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.buildErrorMsg(map_result.get("msg").toString());
        }
        return BaseResponseUtils.buildSuccess() ;
    }
 
    /**
     * 删除轮灌组,新代码
     * @param groupId
     * @return
     */
    @PostMapping(path = "deleteIrrigateGroup")
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> deleteIrrigateGroup(@RequestParam(required = false) Long groupId) {
        if(groupId == null) {
            return BaseResponseUtils.buildErrorMsg("轮灌组ID不能为空");
        }
 
        Map map_result = irrigateGroupSv.deleteGroup(groupId);
        if(map_result.get("success").equals(false)) {
            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
        }
        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());
        }
    }
 
    /**
     * 获取全部轮灌组,新代码
     * @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")) ;
    }
}