From d2d8db6a6f66f3b646e395a7a2a4822ce68d5b47 Mon Sep 17 00:00:00 2001
From: zhanghl <253316343@qq.com>
Date: 星期二, 22 四月 2025 15:08:25 +0800
Subject: [PATCH] 角色-部门表增加 部门组织编码

---
 aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java b/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
index 30ab94f..9eab4bf 100644
--- a/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
+++ b/aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
@@ -1,10 +1,9 @@
 package com.aps.system.service.impl;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
+
+import com.aps.system.api.domain.SysDept;
+import com.aps.system.mapper.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -19,10 +18,6 @@
 import com.aps.system.domain.SysRoleDept;
 import com.aps.system.domain.SysRoleMenu;
 import com.aps.system.domain.SysUserRole;
-import com.aps.system.mapper.SysRoleDeptMapper;
-import com.aps.system.mapper.SysRoleMapper;
-import com.aps.system.mapper.SysRoleMenuMapper;
-import com.aps.system.mapper.SysUserRoleMapper;
 import com.aps.system.service.ISysRoleService;
 
 /**
@@ -45,6 +40,8 @@
     @Autowired
     private SysRoleDeptMapper roleDeptMapper;
 
+    @Autowired
+    private SysDeptMapper deptMapper;
     /**
      * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁
      * 
@@ -320,12 +317,21 @@
         int rows = 1;
         // 鏂板瑙掕壊涓庨儴闂紙鏁版嵁鏉冮檺锛夌鐞�
         List<SysRoleDept> list = new ArrayList<SysRoleDept>();
-        for (Long deptId : role.getDeptIds())
+        Long[] deptIds = role.getDeptIds();
+        List<SysDept> sysDepts = deptMapper.selectDeptListByIdList(Arrays.asList(deptIds));
+
+        for (Long deptId : deptIds)
         {
-            SysRoleDept rd = new SysRoleDept();
-            rd.setRoleId(role.getRoleId());
-            rd.setDeptId(deptId);
-            list.add(rd);
+            Optional<SysDept> first = sysDepts.stream().filter(sysDept -> sysDept.getDeptId().equals(deptId)).findFirst();
+            if(first.isPresent()){
+                SysDept sysDept = first.get();
+                SysRoleDept rd = new SysRoleDept();
+                rd.setRoleId(role.getRoleId());
+                rd.setDeptId(deptId);
+                rd.setDeptOrgCode(sysDept.getOrgCode());
+                list.add(rd);
+            }
+
         }
         if (list.size() > 0)
         {

--
Gitblit v1.9.3