From 9104e047e7ef7c4504bd548711b8fdeda3abd621 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 28 十月 2026 10:50:56 +0800
Subject: [PATCH] 【丽水】collectUser 修正

---
 smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java                        |    5 +++++
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java |    7 ++++++-
 smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml                         |   16 ++++++++++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
index fc3499a..0651dd0 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
@@ -817,7 +817,12 @@
         log.info("selectDeptList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysDepts.size());
         // count = sysDept2Mapper.batchDept(sysDepts);
         for (SysDept row : sysDepts) {
-            SysDept sysDeptTemp = sysDept2Mapper.selectDeptByCode(row.getDeptCode(), null);
+            // 绉戝鍜岀梾鍖哄彲鑳藉叡鐢ㄥ悓涓�涓� dept_code锛屽繀椤绘寜 dept_type + orgid 绮剧‘瀹氫綅锛屽惁鍒� selectOne 浼氳繑鍥炲鏉�
+            if (StringUtils.isEmpty(row.getDeptCode())) {
+                log.warn("selectDeptList璺宠繃deptCode涓虹┖鐨勮褰曪細{}", row);
+                continue;
+            }
+            SysDept sysDeptTemp = sysDept2Mapper.selectDeptByCodeAndType(row.getDeptCode(), row.getOrgid(), row.getDeptType());
             if (sysDeptTemp != null && sysDeptTemp.getDeptName() != null) {
                 row.setDeptId(sysDeptTemp.getDeptId());
                 count += sysDept2Mapper.updateDept(row);
diff --git a/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java b/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
index ae80c8e..1ea2c2a 100644
--- a/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/SysDept2Mapper.java
@@ -40,6 +40,11 @@
 
     public SysDept selectDeptByCode(@Param("deptCode")String deptCode,@Param("orgid")String orgid);
 
+    /**
+     * 鎸夌瀹ょ紪鐮併�佹満鏋勩�佺瀹ょ被鍨嬫煡璇紙绉戝鍜岀梾鍖哄彲鑳戒娇鐢ㄧ浉鍚岀紪鐮侊紝蹇呴』甯� deptType 绮剧‘瀹氫綅锛�
+     */
+    public SysDept selectDeptByCodeAndType(@Param("deptCode")String deptCode,@Param("orgid")String orgid,@Param("deptType")String deptType);
+
     public SysDept selectDeptByCodeAndCampus(@Param("deptCode")String deptCode,@Param("orgid")String orgid,@Param("campusid")String campusid);
 
     /**
diff --git a/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml b/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
index 66be32b..a0327a6 100644
--- a/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/SysDeptMapper.xml
@@ -152,6 +152,22 @@
         <if test="orgid != null and orgid != ''">
             AND orgid = #{orgid}
         </if>
+        order by d.dept_id
+        limit 1
+    </select>
+
+    <select id="selectDeptByCodeAndType" resultMap="SysDeptResult">
+        <include refid="selectDeptVo"/>
+        where d.del_flag = '0'
+        and d.dept_code = #{deptCode}
+        <if test="orgid != null and orgid != ''">
+            AND d.orgid = #{orgid}
+        </if>
+        <if test="deptType != null and deptType != ''">
+            AND d.dept_type = #{deptType}
+        </if>
+        order by d.dept_id
+        limit 1
     </select>
 
     <select id="selectDeptByCodeAndCampus" parameterType="string" resultMap="SysDeptResult">

--
Gitblit v1.9.3