czh 2 лет назад
Родитель
Сommit
c2e88cf855

+ 9 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dao/KwsEnterpriseDao.java

@@ -115,6 +115,15 @@ public interface KwsEnterpriseDao {
      */
     FindManagePojo findManageInfoByEntId(Long entId);
 
+    /**
+     * @param entId 企业id
+     * @return FindManagePojo
+     * @desc: 查企业的管理员
+     * @author: czh
+     * @date: 2023/6/29
+     */
+    List<FindManagePojo> findManageInfoByEntIds(@Param(value = "list") List<Long> entId);
+
     /**
      * @param entId 企业id
      * @return FindManagePojo

+ 2 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/model/pojo/FindManagePojo.java

@@ -22,4 +22,6 @@ public class FindManagePojo implements Serializable {
 
     private Long roleId;
 
+    private Long entId;
+
 }

+ 14 - 7
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -910,13 +911,16 @@ public class KwsEnterpriseService {
             collect = kwsEntTypeList.stream().collect(Collectors.groupingBy(KwsEntType::getEntId));
         }
 
-        List<Long> managers = kwsEnterprises.stream().map(KwsEnterprise::getManager).toList();
+        List<FindManagePojo> manageInfoByEntIds = kwsEnterpriseDao.findManageInfoByEntIds(kwsEnterprises.stream().map(KwsEnterprise::getId).toList());
         Map<Long, KwsUser> userCollect = new HashMap<>(Global.NUMERICAL_SIXTEEN);
-        if (CollectionUtils.isNotEmpty(managers)) {
-            List<KwsUser> kwsUsers = kwsUserService.selectByKeys(managers);
+        Map<Long, FindManagePojo> manageInfoCollect = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        if (CollectionUtils.isNotEmpty(manageInfoByEntIds)) {
+            List<KwsUser> kwsUsers = kwsUserService.selectByKeys(manageInfoByEntIds.stream().map(FindManagePojo::getUserId).toList());
             if (CollectionUtils.isNotEmpty(kwsUsers)) {
                 userCollect = kwsUsers.stream().collect(Collectors.toMap(KwsUser::getId, e -> e, (n, o) -> n));
             }
+
+            manageInfoCollect = manageInfoByEntIds.stream().collect(Collectors.toMap(FindManagePojo::getEntId, Function.identity()));
         }
 
 
@@ -925,14 +929,17 @@ public class KwsEnterpriseService {
             QueryCurrentOrganizationResVo queryCurrentOrganizationResVo = new QueryCurrentOrganizationResVo();
             List<KwsEntType> kwsEntTypeList1 = collect.get(kwsEnterprise.getId());
             queryCurrentOrganizationResVo.setEntTypes(CollectionUtils.isEmpty(kwsEntTypeList1) ? null : String.join(Global.COMMA, kwsEntTypeList1.stream().map(KwsEntType::getType).map(String::valueOf).toList()));
-            Long manager = kwsEnterprise.getManager();
-            if (Objects.nonNull(manager)) {
-                queryCurrentOrganizationResVo.setContactsId(manager);
-                KwsUser kwsUser = userCollect.get(manager);
+            FindManagePojo findManagePojo = manageInfoCollect.get(kwsEnterprise.getId());
+            if (Objects.nonNull(findManagePojo)) {
+                queryCurrentOrganizationResVo.setContactsId(findManagePojo.getUserId());
+                KwsUser kwsUser = userCollect.get(findManagePojo.getUserId());
                 if (Objects.nonNull(kwsUser)) {
                     queryCurrentOrganizationResVo.setContacts(kwsUser.getName());
                     queryCurrentOrganizationResVo.setPhone(kwsUser.getPhone());
                 }
+            } else {
+                queryCurrentOrganizationResVo.setContacts(kwsEnterprise.getContacts());
+                queryCurrentOrganizationResVo.setPhone(kwsEnterprise.getPhone());
             }
             queryCurrentOrganizationResVo.setCityName(kwsEnterprise.getCityName());
             queryCurrentOrganizationResVo.setBusiness(kwsEnterprise.getBusiness());

+ 28 - 2
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -236,7 +236,8 @@
   <select id="findManageInfoByEntId" resultType="com.sckw.system.model.pojo.FindManagePojo">
     select distinct d.id userId,
            b.id deptId,
-           f.id roleId
+           f.id roleId,
+           a.id entId
       from kws_enterprise a
       left join kws_dept b on a.id = b.ent_id
       left join kws_user_dept c on b.id = c.dept_id
@@ -326,7 +327,32 @@
                     )
     </select>
 
-    <insert id="insert" parameterType="com.sckw.system.model.KwsEnterprise">
+  <select id="findManageInfoByEntIds" resultType="com.sckw.system.model.pojo.FindManagePojo">
+    select distinct d.id userId,
+                    b.id deptId,
+                    f.id roleId,
+                    a.id entId
+      from kws_enterprise a
+             left join kws_dept b on a.id = b.ent_id
+             left join kws_user_dept c on b.id = c.dept_id
+             left join kws_user d on c.user_id = d.id
+             left join kws_user_role e on d.id = e.user_id
+             left join kws_role f on e.role_id = f.id
+      where a.del_flag = 0
+        and b.del_flag = 0
+        and c.del_flag = 0
+        and d.del_flag = 0
+        and e.del_flag = 0
+        and f.del_flag = 0
+        and d.is_main = 1
+        and d.system_type = 2
+        and a.id in
+      <foreach collection="list" separator="," open="(" close=")" item="item">
+        #{item}
+      </foreach>
+  </select>
+
+  <insert id="insert" parameterType="com.sckw.system.model.KwsEnterprise">
     insert into kws_enterprise
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">