From e8937f27fce194d015ce6c27d286e7fc89f5e580 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 23 四月 2025 17:29:47 +0800
Subject: [PATCH] 查询开关阀记录相关修改

---
 pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java |  576 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 576 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java
new file mode 100644
index 0000000..77706f0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupCtrl.java
@@ -0,0 +1,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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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 = "鑾峰彇涓�涓疆鐏岀粍锛圔aseResponse.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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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 = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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("鑾峰彇鏈粦瀹氳疆鐏岀粍鐨勭亴婧夊崟鍏僫d璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+
+    /**
+     * 淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓
+     *
+     * @param po            杞亴缁勭亴婧夊崟鍏冧腑闂磋〃
+     * @param bindingResult
+     * @return 娣诲姞鏄惁鎴愬姛
+     */
+    @Operation(summary = "淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓", description = "淇敼杞亴缁勭粦瀹氱殑鐏屾簤鍗曞厓")
+    @ApiResponses(value = {
+            @ApiResponse(
+                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+                    description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝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("杞亴缁処D涓嶈兘涓虹┖");
+        }
+
+        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("杞亴缁処D涓嶈兘涓虹┖");
+        }
+        
+        // 鍏堝垽鏂〃鍐呮槸鍚﹀瓨鍦ㄧ浉鍚岀殑 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("杞亴缁処D涓嶈兘涓虹┖");
+        }
+
+        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")) ;
+    }
+}

--
Gitblit v1.8.0