Browse Source

Merge branch 'release_1.1.3' into dev_1.1.3
merge

wangliang 5 tháng trước cách đây
mục cha
commit
690a9c00aa

+ 9 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesMapper.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.sop.business.bean.dto.UserArchivesImportDto;
 import com.qmth.sop.business.bean.result.ArchivesSourceResult;
-import com.qmth.sop.business.bean.result.UserArchivesInfoResult;
 import com.qmth.sop.business.bean.result.UserArchivesResult;
 import com.qmth.sop.business.entity.TBUserArchives;
 import com.qmth.sop.common.enums.RoleTypeEnum;
@@ -47,6 +46,15 @@ public interface TBUserArchivesMapper extends BaseMapper<TBUserArchives> {
      */
     List<UserArchivesResult> findUserArchivesById(@Param("archivesId") Long archivesId, @Param("userId") Long userId);
 
+    /**
+     * 根据用户id或档案id查询档案详情
+     *
+     * @param archivesIdList 档案id
+     * @param userId     用户id
+     * @return 档案详情
+     */
+    List<UserArchivesResult> findUserArchivesByIdList(@Param("archivesIdList") List<Long> archivesIdList, @Param("userId") Long userId);
+
     /**
      * 根据角色类型查询该角色的档案资源
      *

+ 2 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesService.java

@@ -106,6 +106,8 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
      */
     UserArchivesResult findUserArchivesByArchivesIdORUserId(Long archivesId, Long userId);
 
+    List<UserArchivesResult> findUserArchivesByArchivesIdORUserIdList(List<Long> archivesIdList, Long userId);
+
     /**
      * 查询空闲的工程师档案资源
      *

+ 42 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -546,26 +546,51 @@ public class TBUserArchivesAllocationServiceImpl
         }
         List<Long> effectArchivesIdList = datasource.stream().distinct().collect(Collectors.toList());
         List<UserArchivesDto> result = new ArrayList<>();
-        for (Long effectArchivesId : effectArchivesIdList) {
-            UserArchivesResult tbUserArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(
-                    effectArchivesId, null);
-            if (tbUserArchivesResult.getAuthenticationStatus()) {
-                UserArchivesDto cell = new UserArchivesDto();
-                cell.setUserId(tbUserArchivesResult.getUserId());
-                cell.setUserArchivesId(tbUserArchivesResult.getUserArchivesId());
-                cell.setName(tbUserArchivesResult.getName());
-                cell.setProvince(tbUserArchivesResult.getProvince());
-                cell.setCity(tbUserArchivesResult.getCity());
-                cell.setSupplierName(tbUserArchivesResult.getSupplierName());
-                cell.setMobileNumber(tbUserArchivesResult.getMobileNumber());
-                List<RoleResult> roleInfoList = tbUserArchivesResult.getRoleInfoList();
-                if (CollectionUtils.isNotEmpty(roleInfoList)) {
-                    cell.setArchivesRoleName(
-                            roleInfoList.stream().map(RoleResult::getRoleName).collect(Collectors.joining(",")));
+        if (!CollectionUtils.isEmpty(effectArchivesIdList)) {
+            List<UserArchivesResult> tbUserArchivesResultList = tbUserArchivesService.findUserArchivesByArchivesIdORUserIdList(
+                    effectArchivesIdList, null);
+            if (!CollectionUtils.isEmpty(tbUserArchivesResultList)) {
+                for (UserArchivesResult tbUserArchivesResult : tbUserArchivesResultList) {
+                    if (tbUserArchivesResult.getAuthenticationStatus()) {
+                        UserArchivesDto cell = new UserArchivesDto();
+                        cell.setUserId(tbUserArchivesResult.getUserId());
+                        cell.setUserArchivesId(tbUserArchivesResult.getUserArchivesId());
+                        cell.setName(tbUserArchivesResult.getName());
+                        cell.setProvince(tbUserArchivesResult.getProvince());
+                        cell.setCity(tbUserArchivesResult.getCity());
+                        cell.setSupplierName(tbUserArchivesResult.getSupplierName());
+                        cell.setMobileNumber(tbUserArchivesResult.getMobileNumber());
+                        List<RoleResult> roleInfoList = tbUserArchivesResult.getRoleInfoList();
+                        if (CollectionUtils.isNotEmpty(roleInfoList)) {
+                            cell.setArchivesRoleName(roleInfoList.stream().map(RoleResult::getRoleName)
+                                    .collect(Collectors.joining(",")));
+                        }
+                        result.add(cell);
+                    }
                 }
-                result.add(cell);
             }
         }
+
+        //        for (Long effectArchivesId : effectArchivesIdList) {
+        //            UserArchivesResult tbUserArchivesResult = tbUserArchivesService.findUserArchivesByArchivesIdORUserId(
+        //                    effectArchivesId, null);
+        //            if (tbUserArchivesResult.getAuthenticationStatus()) {
+        //                UserArchivesDto cell = new UserArchivesDto();
+        //                cell.setUserId(tbUserArchivesResult.getUserId());
+        //                cell.setUserArchivesId(tbUserArchivesResult.getUserArchivesId());
+        //                cell.setName(tbUserArchivesResult.getName());
+        //                cell.setProvince(tbUserArchivesResult.getProvince());
+        //                cell.setCity(tbUserArchivesResult.getCity());
+        //                cell.setSupplierName(tbUserArchivesResult.getSupplierName());
+        //                cell.setMobileNumber(tbUserArchivesResult.getMobileNumber());
+        //                List<RoleResult> roleInfoList = tbUserArchivesResult.getRoleInfoList();
+        //                if (CollectionUtils.isNotEmpty(roleInfoList)) {
+        //                    cell.setArchivesRoleName(
+        //                            roleInfoList.stream().map(RoleResult::getRoleName).collect(Collectors.joining(",")));
+        //                }
+        //                result.add(cell);
+        //            }
+        //        }
         return result;
     }
 

+ 33 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -538,6 +538,39 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
         return result;
     }
 
+    @Override
+    public List<UserArchivesResult> findUserArchivesByArchivesIdORUserIdList(List<Long> archivesIdList, Long userId) {
+        List<UserArchivesResult> userArchivesResultList = this.baseMapper.findUserArchivesByIdList(archivesIdList,
+                userId);
+        if (CollectionUtils.isNotEmpty(userArchivesResultList)) {
+//            if (userArchivesResultList.size() > 1) {
+//                throw ExceptionResultEnum.ERROR.exception("档案数据异常");
+//            }
+            for (UserArchivesResult result : userArchivesResultList) {
+                List<RoleResult> roleResultList = new ArrayList<>();
+
+                // 认证的角色枚举
+                List<RoleTypeEnum> authRole = new ArrayList<>();
+                authRole.add(RoleTypeEnum.EFFECT_ENGINEER);
+                authRole.add(RoleTypeEnum.REGION_COORDINATOR);
+                authRole.add(RoleTypeEnum.ASSISTANT_ENGINEER);
+                if (userId != null && userId > 0) {
+                    for (RoleTypeEnum roleTypeEnum : authRole) {
+                        // TODO: 2023/8/14 可优化查询
+                        if (sysUserRoleService.userContainsRoles(userId, roleTypeEnum)) {
+                            RoleResult roleResult = sysRoleService.findRoleInfoByArchivesType(roleTypeEnum);
+                            if (Objects.nonNull(roleResult)) {
+                                roleResultList.add(roleResult);
+                            }
+                        }
+                    }
+                }
+                result.setRoleInfoList(roleResultList);
+            }
+        }
+        return userArchivesResultList;
+    }
+
     @Override
     public List<ArchivesSourceResult> findFreeEngineerSourceByType(RoleTypeEnum roleType, String crmNo) {
         List<ArchivesSourceResult> result = new ArrayList<>();

+ 46 - 0
sop-business/src/main/resources/mapper/TBUserArchivesMapper.xml

@@ -179,6 +179,7 @@
         </where>
         ORDER BY tbua.update_time DESC,tbua.code DESC
     </select>
+
     <select id="findUserArchivesById" resultType="com.qmth.sop.business.bean.result.UserArchivesResult">
         SELECT
             tbua.id AS userArchivesId,
@@ -221,6 +222,51 @@
         </where>
     </select>
 
+    <select id="findUserArchivesByIdList" resultType="com.qmth.sop.business.bean.result.UserArchivesResult">
+        SELECT
+        tbua.id AS userArchivesId,
+        tbua.code,
+        tbua.name,
+        tbua.province,
+        tbua.city,
+        tbua.area,
+        tbua.identity,
+        tbua.gender,
+        education,
+        tbua.mobile_number AS mobileNumber,
+        tbua.email,
+        base_photo_path AS basePhotoPath,
+        tbuas.supplier_id AS supplierId,
+        ss.name AS supplierName,
+        tbuas.archives_time AS archivesTime,
+        tbuas.authentication_score AS authenticationScore,
+        tbuas.authentication_valid_time AS authenticationValidTime,
+        IF(REPLACE(UNIX_TIMESTAMP(NOW(3)), '.', '') &lt;= tbuas.authentication_valid_time,TRUE,FALSE) AS authenticationStatus,
+        tbuas.remark,
+        su.id AS userId,
+        tbua.status AS status,
+        tbua.enable as enable
+        FROM
+        t_b_user_archives tbua
+        LEFT JOIN
+        t_b_user_archives_supplier tbuas ON tbua.id = tbuas.user_archives_id
+        LEFT JOIN
+        sys_supplier ss ON ss.id = tbuas.supplier_id
+        LEFT JOIN
+        sys_user su ON su.mobile_number = tbua.mobile_number
+        <where>
+            <if test="userId != null">
+                AND su.id = #{userId}
+            </if>
+            <if test="archivesIdList != null and archivesIdList != ''">
+                AND tbua.id in
+                <foreach collection="archivesIdList" item="archivesId" open="(" separator="," close=")">
+                    #{archivesId}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
     <select id="findArchivesSourceByType" resultType="com.qmth.sop.business.bean.result.ArchivesSourceResult">
         SELECT
             tbua.id AS archivesId,