From f44135f835bf62319f9bb8a32e4592a707e5e8c1 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期日, 27 四月 2025 11:09:55 +0800
Subject: [PATCH] SSO登录逻辑再修改

---
 pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java |   75 +++++++++++++++++++++++++++++--------
 1 files changed, 59 insertions(+), 16 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
index 1419aa1..da54d34 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
@@ -172,6 +172,31 @@
     }
 
     /**
+     * 鏍规嵁杞亴缁勫悕绉版煡璇㈡槸鍚﹀瓨鍦紙娣诲姞杞亴缁勬椂浣跨敤锛�
+     * @param groupCode 杞亴缁勫悕绉�
+     * @return 鏄惁瀛樺湪
+     */
+    public boolean existsByGroupCode(String groupCode) {
+        if (groupCode == null || "".equals(groupCode.trim())) {
+            return false;
+        }
+        return irIrrigateGroupMapper.countByGroupCode(groupCode) > 0;
+    }
+
+    /**
+     * 鏍规嵁杞亴缁勫悕绉版煡璇㈡槸鍚﹀瓨鍦紙淇敼杞亴缁勬椂浣跨敤锛屾帓闄ゅ綋鍓岻D锛�
+     * @param groupCode 杞亴缁勫悕绉�
+     * @param excludeId 闇�瑕佹帓闄ょ殑ID
+     * @return 鏄惁瀛樺湪
+     */
+    public boolean existsByGroupCodeExcludeId(String groupCode, Long excludeId) {
+        if (groupCode == null || "".equals(groupCode.trim())) {
+            return false;
+        }
+        return irIrrigateGroupMapper.countByGroupCodeExcludeId(groupCode, excludeId) > 0;
+    }
+
+    /**
      * 鍒犻櫎杞亴缁勪笌鍐滄埛绠$悊
      * @param id
      * @return
@@ -260,25 +285,43 @@
      * @return
      */
     public Map updateIrrigateGroup(IrrigateGroup po) {
+        // 淇敼杞亴缁�
+        IrIrrigateGroup irrigateGroup = new IrIrrigateGroup();
+        irrigateGroup.setId(po.getGroupId());
+        irrigateGroup.setGroupCode(po.getGroupCode());
+        irrigateGroup.setDefaultDuration(po.getDefaultDuration());
+        irrigateGroup.setOperator(po.getOperator());
+        irrigateGroup.setOperateTime(new Date());
+        irrigateGroup.setDeleted((byte) 0);
+        irIrrigateGroupMapper.updateByPrimaryKeySelective(irrigateGroup);
+
+        // 鍒犻櫎杞亴缁勪笌鍙栨按鍙e叧鑱�
         Long groupId = po.getGroupId();
-        Map map_deleteGroup = deleteGroup(groupId);
-        if(map_deleteGroup.get("success").equals(false)) {
-            Map map = new HashMap<>();
-            map.put("success", false);
-            map.put("msg", map_deleteGroup.get("msg").toString());
-            map.put("content", null);
-            return map;
-        }
+        irGroupIntakeMapper.deleteByGroupId(groupId);
 
-        Map map_addGroup = addIrrigateGroup(po);
-        if(map_addGroup.get("success").equals(false)) {
-            Map map = new HashMap<>();
-            map.put("success", false);
-            map.put("msg", map_addGroup.get("msg").toString());
-            map.put("content", null);
-            return map;
-        }
+        // 娣诲姞杞亴缁勪笌鍙栨按鍙e叧鑱�
+        String[] intakeArr = po.getIntakes().split(",");
+        Integer sort = 1;
+        for(String intekeId : intakeArr) {
+            String trimmed = intekeId.trim();
+            if(trimmed.isEmpty()) {
+                continue;
+            }
+            try {
+                Long intakeIdLong = Long.parseLong(trimmed);
+                IrGroupIntake irGroupIntake = new IrGroupIntake();
+                irGroupIntake.setGroupId(groupId);
+                irGroupIntake.setIntakeId(intakeIdLong);
+                irGroupIntakeMapper.insert(irGroupIntake);
+            } catch (NumberFormatException  e) {
+                Map map = new HashMap<>();
+                map.put("success", false);
+                map.put("msg", "鍙栨按鍙D鏍煎紡閿欒");
+                map.put("content", null);
+                return map;
+            }
 
+        }
         Map map = new HashMap<>();
         map.put("success", true);
         map.put("msg", "淇敼杞亴缁勬垚鍔�");

--
Gitblit v1.8.0