Pārlūkot izejas kodu

人员配置选人修改

wangliang 10 mēneši atpakaļ
vecāks
revīzija
b0a7c25379

+ 42 - 26
sop-api/src/main/java/com/qmth/sop/server/api/TBUserArchivesAllocationController.java

@@ -3,10 +3,8 @@ package com.qmth.sop.server.api;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.params.AutoAllocationParam;
 import com.qmth.sop.business.bean.params.UserArchivesAllocationParam;
-import com.qmth.sop.business.bean.result.ArchivesSourceResult;
-import com.qmth.sop.business.bean.result.CrmArchivesAllocationResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
+import com.qmth.sop.business.bean.result.*;
+import com.qmth.sop.business.service.TBCrmService;
 import com.qmth.sop.business.service.TBUserArchivesAllocationService;
 import com.qmth.sop.business.service.TBUserArchivesService;
 import com.qmth.sop.common.annotation.OperationLog;
@@ -45,32 +43,45 @@ public class TBUserArchivesAllocationController {
     @Resource
     private TBUserArchivesService tbUserArchivesService;
 
+    @Resource
+    private TBCrmService tbCrmService;
+
     @ApiOperation(value = "人员调配管理-分页查询")
     @RequestMapping(value = "/page", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = UserArchivesAllocationResult.class) })
     @Deprecated
-    public Result findUserArchivesAllocationPage(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
-            @ApiParam(value = "省") @RequestParam(required = false) String province, @ApiParam(value = "市") @RequestParam(required = false) String city,
-            @ApiParam(value = "县") @RequestParam(required = false) String area, @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
-            @ApiParam(value = "分配差额") @RequestParam(required = false) Integer gap, @ApiParam(value = "大区id") @RequestParam(required = false) Long regionId,
+    public Result findUserArchivesAllocationPage(
+            @ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
+            @ApiParam(value = "省") @RequestParam(required = false) String province,
+            @ApiParam(value = "市") @RequestParam(required = false) String city,
+            @ApiParam(value = "县") @RequestParam(required = false) String area,
+            @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
+            @ApiParam(value = "分配差额") @RequestParam(required = false) Integer gap,
+            @ApiParam(value = "大区id") @RequestParam(required = false) Long regionId,
             @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
             @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
 
-        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmAllocationPage(SystemConstant.convertIdToLong(serviceUnitId),
-                province, city, area, customName, gap, regionId, pageNumber, pageSize));
+        return ResultUtil.ok(
+                tbUserArchivesAllocationService.findCrmAllocationPage(SystemConstant.convertIdToLong(serviceUnitId),
+                        province, city, area, customName, gap, regionId, pageNumber, pageSize));
     }
 
     @ApiOperation(value = "人员调配管理-小计查询")
     @RequestMapping(value = "/sub_total", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = UserArchivesAllocationSubTotalResult.class) })
     @Deprecated
-    public Result findUserArchivesAllocationSubTotal(@ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
-            @ApiParam(value = "省") @RequestParam(required = false) String province, @ApiParam(value = "市") @RequestParam(required = false) String city,
-            @ApiParam(value = "县") @RequestParam(required = false) String area, @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
-            @ApiParam(value = "分配差额") @RequestParam(required = false) Integer gap, @ApiParam(value = "大区id") @RequestParam(required = false) Long regionId) {
-
-        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmAllocationSubTotal(SystemConstant.convertIdToLong(serviceUnitId),
-                province, city, area, customName, gap, regionId));
+    public Result findUserArchivesAllocationSubTotal(
+            @ApiParam(value = "服务单元id") @RequestParam(required = false) String serviceUnitId,
+            @ApiParam(value = "省") @RequestParam(required = false) String province,
+            @ApiParam(value = "市") @RequestParam(required = false) String city,
+            @ApiParam(value = "县") @RequestParam(required = false) String area,
+            @ApiParam(value = "客户名称") @RequestParam(required = false) String customName,
+            @ApiParam(value = "分配差额") @RequestParam(required = false) Integer gap,
+            @ApiParam(value = "大区id") @RequestParam(required = false) Long regionId) {
+
+        return ResultUtil.ok(
+                tbUserArchivesAllocationService.findCrmAllocationSubTotal(SystemConstant.convertIdToLong(serviceUnitId),
+                        province, city, area, customName, gap, regionId));
     }
 
     @ApiOperation(value = "人员调配管理-根据派单号查询派单分配信息")
@@ -84,8 +95,8 @@ public class TBUserArchivesAllocationController {
     @RequestMapping(value = "/edit", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "更新成功", response = Result.class) })
     @OperationLog(logType = LogTypeEnum.EDIT)
-    public Result edit(@Valid @RequestBody UserArchivesAllocationParam userArchivesAllocationParam, BindingResult bindingResult)
-            throws InterruptedException {
+    public Result edit(@Valid @RequestBody UserArchivesAllocationParam userArchivesAllocationParam,
+            BindingResult bindingResult) throws InterruptedException {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
@@ -127,7 +138,8 @@ public class TBUserArchivesAllocationController {
     @RequestMapping(value = "/free_engineer", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = ArchivesSourceResult.class) })
     @Deprecated
-    public Result findFreeEngineer(@ApiParam(value = "工程师类型", required = true) @RequestParam RoleTypeEnum roleType, @ApiParam(value = "派单号") @RequestParam(required = false) String crmNo) {
+    public Result findFreeEngineer(@ApiParam(value = "工程师类型", required = true) @RequestParam RoleTypeEnum roleType,
+            @ApiParam(value = "派单号") @RequestParam(required = false) String crmNo) {
         return ResultUtil.ok(tbUserArchivesService.findFreeEngineerSourceByType(roleType, crmNo));
     }
 
@@ -135,16 +147,19 @@ public class TBUserArchivesAllocationController {
     @RequestMapping(value = "/free_coordinator", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = ArchivesSourceResult.class) })
     @Deprecated
-    public Result findFreeCoordinator(@ApiParam(value = "服务单元id", required = true) @RequestParam String serviceUnitId, @ApiParam(value = "派单号") @RequestParam(required = false) String crmNo) {
-        return ResultUtil.ok(tbUserArchivesService.findFreeCoordinatorByServiceId(SystemConstant.convertIdToLong(serviceUnitId),
-                crmNo, false));
+    public Result findFreeCoordinator(@ApiParam(value = "服务单元id", required = true) @RequestParam String serviceUnitId,
+            @ApiParam(value = "派单号") @RequestParam(required = false) String crmNo) {
+        return ResultUtil.ok(
+                tbUserArchivesService.findFreeCoordinatorByServiceId(SystemConstant.convertIdToLong(serviceUnitId),
+                        crmNo, false));
     }
 
     @ApiOperation(value = "人员调配管理-查询调配信息")
     @RequestMapping(value = "/info", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = ArchivesSourceResult.class) })
     public Result findAllocationInfo(@ApiParam(value = "派单详情id", required = true) @RequestParam String crmDetailId) {
-        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmDetailAllocationInfo(SystemConstant.convertIdToLong(crmDetailId)));
+        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmDetailAllocationInfo(
+                SystemConstant.convertIdToLong(crmDetailId)));
     }
 
     @ApiOperation(value = "人员调配管理-查询可分配的人员")
@@ -152,7 +167,8 @@ public class TBUserArchivesAllocationController {
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = ArchivesSourceResult.class) })
     public Result findCanChoose(@ApiParam(value = "派单详情id", required = true) @RequestParam String crmDetailId,
             @ApiParam(value = "sop角色身份", required = true) @RequestParam SopRoleTypeCompositeEnum sopRoleType) {
-        return ResultUtil.ok(tbUserArchivesAllocationService.findCanChooseArchives(SystemConstant.convertIdToLong(crmDetailId),
-                sopRoleType));
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null, Long.parseLong(crmDetailId), null);
+        return ResultUtil.ok(tbUserArchivesAllocationService.findCanChooseArchives(crmProjectResult.getCustomType(),
+                SystemConstant.convertIdToLong(crmDetailId), sopRoleType));
     }
 }

+ 19 - 12
sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesMapper.java

@@ -12,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -23,14 +24,18 @@ import java.util.Map;
  */
 public interface TBUserArchivesMapper extends BaseMapper<TBUserArchives> {
 
-    IPage<UserArchivesResult> findUserArchivesPage(@Param("iPage") Page<UserArchivesResult> iPage, @Param("city") String city,
-            @Param("supplierId") Long supplierId, @Param("archivesName") String archivesName, @Param("roleType") RoleTypeEnum roleType,
-            @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart, @Param("archivesTimeEnd") Long archivesTimeEnd,
-            @Param("remainValidTime") Long remainValidTime, @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
+    IPage<UserArchivesResult> findUserArchivesPage(@Param("iPage") Page<UserArchivesResult> iPage,
+            @Param("city") String city, @Param("supplierId") Long supplierId,
+            @Param("archivesName") String archivesName, @Param("roleType") RoleTypeEnum roleType,
+            @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart,
+            @Param("archivesTimeEnd") Long archivesTimeEnd, @Param("remainValidTime") Long remainValidTime,
+            @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
 
-    List<UserArchivesImportDto> findExportData(@Param("city") String city, @Param("supplierId") Long supplierId, @Param("archivesName") String archivesName,
-            @Param("roleType") RoleTypeEnum roleType, @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart,
-            @Param("archivesTimeEnd") Long archivesTimeEnd, @Param("remainValidTime") Long remainValidTime, @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
+    List<UserArchivesImportDto> findExportData(@Param("city") String city, @Param("supplierId") Long supplierId,
+            @Param("archivesName") String archivesName, @Param("roleType") RoleTypeEnum roleType,
+            @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart,
+            @Param("archivesTimeEnd") Long archivesTimeEnd, @Param("remainValidTime") Long remainValidTime,
+            @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
 
     /**
      * 根据用户id或档案id查询档案详情
@@ -44,10 +49,10 @@ public interface TBUserArchivesMapper extends BaseMapper<TBUserArchives> {
     /**
      * 根据角色类型查询该角色的档案资源
      *
-     * @param roleType 角色类型
+     * @param roleTypes 角色类型
      * @return 档案资源
      */
-    List<ArchivesSourceResult> findArchivesSourceByType(@Param("roleType") RoleTypeEnum roleType);
+    List<ArchivesSourceResult> findArchivesSourceByType(@Param("roleTypes") Set<RoleTypeEnum> roleTypes);
 
     /**
      * 查询已用档案
@@ -58,9 +63,11 @@ public interface TBUserArchivesMapper extends BaseMapper<TBUserArchives> {
      */
     List<ArchivesSourceResult> findArchivesUsed(@Param("roleType") RoleTypeEnum roleType, @Param("crmNo") String crmNo);
 
-    List<UserArchivesResult> findUserArchivesList(@Param("city") String city, @Param("supplierId") Long supplierId, @Param("archivesName") String archivesName,
-            @Param("roleType") RoleTypeEnum roleType, @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart,
-            @Param("archivesTimeEnd") Long archivesTimeEnd, @Param("remainValidTime") Long remainValidTime, @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
+    List<UserArchivesResult> findUserArchivesList(@Param("city") String city, @Param("supplierId") Long supplierId,
+            @Param("archivesName") String archivesName, @Param("roleType") RoleTypeEnum roleType,
+            @Param("status") Boolean status, @Param("archivesTimeStart") Long archivesTimeStart,
+            @Param("archivesTimeEnd") Long archivesTimeEnd, @Param("remainValidTime") Long remainValidTime,
+            @Param("currentTime") Long currentTime, @Param("unUploadPic") Boolean unUploadPic);
 
     /**
      * 档案小计

+ 7 - 2
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesAllocationService.java

@@ -10,6 +10,7 @@ import com.qmth.sop.business.bean.result.CrmDetailAllocationResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
 import com.qmth.sop.business.entity.TBUserArchivesAllocation;
+import com.qmth.sop.common.enums.ProductTypeEnum;
 import com.qmth.sop.common.enums.SopRoleTypeCompositeEnum;
 import com.qmth.sop.common.enums.SopRoleTypeEnum;
 
@@ -108,20 +109,24 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
     /**
      * 查询派单详情中可以分配的人员
      *
+     * @param productTypeEnum
      * @param crmDetailId     派单详情id
      * @param sopRoleTypeEnum 角色身份
      * @return 可选择人员集合
      */
-    List<UserArchivesDto> findCanChooseArchives(Long crmDetailId, SopRoleTypeEnum sopRoleTypeEnum);
+    List<UserArchivesDto> findCanChooseArchives(ProductTypeEnum productTypeEnum, Long crmDetailId,
+            SopRoleTypeEnum sopRoleTypeEnum);
 
     /**
      * 查询派单详情中可以分配的人员(复合角色)
      *
+     * @param productTypeEnum
      * @param crmDetailId
      * @param sopRoleTypeCompositeEnum
      * @return
      */
-    List<UserArchivesDto> findCanChooseArchives(Long crmDetailId, SopRoleTypeCompositeEnum sopRoleTypeCompositeEnum);
+    List<UserArchivesDto> findCanChooseArchives(ProductTypeEnum productTypeEnum, Long crmDetailId,
+            SopRoleTypeCompositeEnum sopRoleTypeCompositeEnum);
 
     /**
      * 根据派单明细id查询派单分配信息

+ 11 - 7
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesService.java

@@ -13,6 +13,7 @@ import com.qmth.sop.common.enums.RoleTypeEnum;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -40,8 +41,9 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
      * @param pageSize             分页容量
      * @return 结果
      */
-    IPage<UserArchivesResult> findUserArchivesPage(String city, Long supplierId, String archivesName, RoleTypeEnum roleType,
-            Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay, Boolean unUploadPic, Integer pageNumber, Integer pageSize) throws Exception;
+    IPage<UserArchivesResult> findUserArchivesPage(String city, Long supplierId, String archivesName,
+            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
+            Integer remainValidDay, Boolean unUploadPic, Integer pageNumber, Integer pageSize) throws Exception;
 
     /**
      * 编辑用户档案
@@ -57,8 +59,9 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
      *
      * @return 档案小计情况
      */
-    UserArchivesSubTotalResult findUserArchivesSubTotal(String city, Long supplierId, String archivesName, RoleTypeEnum roleType,
-            Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay, Boolean unUploadPic);
+    UserArchivesSubTotalResult findUserArchivesSubTotal(String city, Long supplierId, String archivesName,
+            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
+            Integer remainValidDay, Boolean unUploadPic);
 
     /**
      * 人员档案管理分页查询
@@ -75,7 +78,8 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
      * @return 结果
      */
     List<UserArchivesImportDto> findExportData(String city, Long supplierId, String archivesName, RoleTypeEnum roleType,
-            Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay, Boolean unUploadPic);
+            Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay,
+            Boolean unUploadPic);
 
     /**
      * 作废人员档案
@@ -125,10 +129,10 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
     /**
      * 根据档案角色类型查询可用的档案
      *
-     * @param roleType 档案角色类型
+     * @param roleTypes 档案角色类型
      * @return 档案
      */
-    List<ArchivesSourceResult> findArchivesSourceByType(RoleTypeEnum roleType);
+    List<ArchivesSourceResult> findArchivesSourceByType(Set<RoleTypeEnum> roleTypes);
 
     List<Map<String, Object>> findTempEmp();
 }

+ 28 - 14
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -21,9 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -529,16 +527,29 @@ public class TBUserArchivesAllocationServiceImpl
     }
 
     @Override
-    public List<UserArchivesDto> findCanChooseArchives(Long crmDetailId, SopRoleTypeEnum sopRoleTypeEnum) {
+    public List<UserArchivesDto> findCanChooseArchives(ProductTypeEnum productTypeEnum, Long crmDetailId,
+            SopRoleTypeEnum sopRoleTypeEnum) {
         List<Long> datasource = new ArrayList<>();
         switch (sopRoleTypeEnum) {
         case ENGINEER:
         case PROJECT_MANAGER:
-            datasource = tbUserArchivesService.list().stream().map(TBUserArchives::getId).distinct()
-                    .collect(Collectors.toList());
+            switch (productTypeEnum) {
+            case OFFICE:
+                datasource = tbUserArchivesService.list().stream().map(TBUserArchives::getId).distinct()
+                        .collect(Collectors.toList());
+                break;
+            case CLOUD_MARK:
+                datasource = tbUserArchivesService.findArchivesSourceByType(
+                                new HashSet<>(Arrays.asList(RoleTypeEnum.EFFECT_ENGINEER, RoleTypeEnum.ASSISTANT_ENGINEER)))
+                        .stream().map(ArchivesSourceResult::getArchivesId).distinct().collect(Collectors.toList());
+                break;
+            default:
+                break;
+            }
             break;
         case REGION_COORDINATOR:
-            datasource = tbUserArchivesService.findArchivesSourceByType(RoleTypeEnum.REGION_COORDINATOR).stream()
+            datasource = tbUserArchivesService.findArchivesSourceByType(
+                            new HashSet<>(Arrays.asList(RoleTypeEnum.REGION_COORDINATOR))).stream()
                     .map(ArchivesSourceResult::getArchivesId).distinct().collect(Collectors.toList());
             break;
         }
@@ -570,12 +581,13 @@ public class TBUserArchivesAllocationServiceImpl
     /**
      * 查询派单详情中可以分配的人员(复合角色)
      *
+     * @param productTypeEnum
      * @param crmDetailId
      * @param sopRoleTypeCompositeEnum
      * @return
      */
     @Override
-    public List<UserArchivesDto> findCanChooseArchives(Long crmDetailId,
+    public List<UserArchivesDto> findCanChooseArchives(ProductTypeEnum productTypeEnum, Long crmDetailId,
             SopRoleTypeCompositeEnum sopRoleTypeCompositeEnum) {
         List<UserArchivesDto> result = new ArrayList<>();
         if (sopRoleTypeCompositeEnum == SopRoleTypeCompositeEnum.REGION_COORDINATOR
@@ -589,7 +601,8 @@ public class TBUserArchivesAllocationServiceImpl
                         .collect(Collectors.toList());
                 break;
             case REGION_COORDINATOR:
-                datasource = tbUserArchivesService.findArchivesSourceByType(RoleTypeEnum.REGION_COORDINATOR).stream()
+                datasource = tbUserArchivesService.findArchivesSourceByType(
+                                new HashSet<>(Arrays.asList(RoleTypeEnum.REGION_COORDINATOR))).stream()
                         .map(ArchivesSourceResult::getArchivesId).distinct().collect(Collectors.toList());
                 break;
             }
@@ -634,11 +647,12 @@ public class TBUserArchivesAllocationServiceImpl
         List<UserArchivesDto> enHistoricalList = tbUserArchivesAllocationLogService.findUserArchivesAllocationHistory(
                 crmDetailId, SopRoleTypeEnum.ENGINEER);
 
-        List<UserArchivesDto> rcCanChooseList = this.findCanChooseArchives(crmDetailId,
-                SopRoleTypeEnum.REGION_COORDINATOR);
-        List<UserArchivesDto> pmCanChooseList = this.findCanChooseArchives(crmDetailId,
-                SopRoleTypeEnum.PROJECT_MANAGER);
-        List<UserArchivesDto> enCanChooseList = this.findCanChooseArchives(crmDetailId, SopRoleTypeEnum.ENGINEER);
+        List<UserArchivesDto> rcCanChooseList = this.findCanChooseArchives(crmProjectResult.getCustomType(),
+                crmDetailId, SopRoleTypeEnum.REGION_COORDINATOR);
+        List<UserArchivesDto> pmCanChooseList = this.findCanChooseArchives(crmProjectResult.getCustomType(),
+                crmDetailId, SopRoleTypeEnum.PROJECT_MANAGER);
+        List<UserArchivesDto> enCanChooseList = this.findCanChooseArchives(crmProjectResult.getCustomType(),
+                crmDetailId, SopRoleTypeEnum.ENGINEER);
 
         CrmDetailAllocationResult result = new CrmDetailAllocationResult();
         result.setServiceUnitName(crmProjectResult.getServiceUnitName());

+ 52 - 30
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -34,7 +34,8 @@ import java.util.stream.Collectors;
  * @since 2023-08-01
  */
 @Service
-public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper, TBUserArchives> implements TBUserArchivesService {
+public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper, TBUserArchives>
+        implements TBUserArchivesService {
 
     @Resource
     private SysUserRoleService sysUserRoleService;
@@ -71,8 +72,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
 
     @Override
     public IPage<UserArchivesResult> findUserArchivesPage(String city, Long supplierId, String archivesName,
-            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay,
-            Boolean unUploadPic, Integer pageNumber, Integer pageSize) throws Exception {
+            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
+            Integer remainValidDay, Boolean unUploadPic, Integer pageNumber, Integer pageSize) throws Exception {
         if (city != null && city.length() > 0) {
             city = SystemConstant.translateSpecificSign(city);
         }
@@ -109,7 +110,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
             }
             record.setRoleInfoList(roleResultList);
             record.setAge(this.getAgeByIdentity(record.getIdentity()));
-            record.setAuthenticationStatus(record.getAuthenticationValidTime() != null && record.getAuthenticationValidTime() > currentTime);
+            record.setAuthenticationStatus(
+                    record.getAuthenticationValidTime() != null && record.getAuthenticationValidTime() > currentTime);
             String basePhotoPath = record.getBasePhotoPath();
             if (basePhotoPath != null && basePhotoPath.length() > 0) {
                 record.setBasePhotoPreviewPath(basicAttachmentService.filePreviewPath(basePhotoPath));
@@ -275,9 +277,9 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
             roleTypeList.add(RoleTypeEnum.ASSISTANT_ENGINEER);
             roleTypeList.add(RoleTypeEnum.REGION_COORDINATOR);
 
-            List<Long> sysRoleIds = sysRoleService.listRolesByUserId(userId).stream().filter(e -> !roleTypeList.contains(e.getType())).map(
-                    RoleDto::getId).distinct().collect(
-                    Collectors.toList());
+            List<Long> sysRoleIds = sysRoleService.listRolesByUserId(userId).stream()
+                    .filter(e -> !roleTypeList.contains(e.getType())).map(RoleDto::getId).distinct()
+                    .collect(Collectors.toList());
             roleIds.addAll(sysRoleIds);
         }
         sysUser.setLoginName(mobileNumber);
@@ -292,7 +294,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
 
     @Override
     public UserArchivesSubTotalResult findUserArchivesSubTotal(String city, Long supplierId, String archivesName,
-            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd, Integer remainValidDay, Boolean unUploadPic) {
+            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
+            Integer remainValidDay, Boolean unUploadPic) {
         UserArchivesSubTotalResult result = new UserArchivesSubTotalResult();
         if (city != null && city.length() > 0) {
             city = SystemConstant.translateSpecificSign(city);
@@ -321,27 +324,34 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
             result.setValidCount(validCount);
             result.setInvalidCount(inValidCount);
 
-            List<Long> userIdList = validList.stream().map(UserArchivesResult::getUserId).distinct().collect(Collectors.toList());
-            List<SysUserBriefResult> effectEngineer = sysUserService.findUserListByRoleType(RoleTypeEnum.EFFECT_ENGINEER);
+            List<Long> userIdList = validList.stream().map(UserArchivesResult::getUserId).distinct()
+                    .collect(Collectors.toList());
+            List<SysUserBriefResult> effectEngineer = sysUserService.findUserListByRoleType(
+                    RoleTypeEnum.EFFECT_ENGINEER);
             int effectEngineerCount = 0;
             if (CollectionUtils.isNotEmpty(effectEngineer)) {
-                List<Long> effectEngineerIdList = effectEngineer.stream().map(SysUserBriefResult::getId).distinct().collect(Collectors.toList());
+                List<Long> effectEngineerIdList = effectEngineer.stream().map(SysUserBriefResult::getId).distinct()
+                        .collect(Collectors.toList());
                 effectEngineerCount = (int) userIdList.stream().filter(effectEngineerIdList::contains).count();
             }
             result.setEffectEngineerCount(effectEngineerCount);
 
-            List<SysUserBriefResult> regionCoordinator = sysUserService.findUserListByRoleType(RoleTypeEnum.REGION_COORDINATOR);
+            List<SysUserBriefResult> regionCoordinator = sysUserService.findUserListByRoleType(
+                    RoleTypeEnum.REGION_COORDINATOR);
             int regionCoordinatorCount = 0;
             if (CollectionUtils.isNotEmpty(regionCoordinator)) {
-                List<Long> regionCoordinatorIdList = regionCoordinator.stream().map(SysUserBriefResult::getId).distinct().collect(Collectors.toList());
+                List<Long> regionCoordinatorIdList = regionCoordinator.stream().map(SysUserBriefResult::getId)
+                        .distinct().collect(Collectors.toList());
                 regionCoordinatorCount = (int) userIdList.stream().filter(regionCoordinatorIdList::contains).count();
             }
             result.setRegionCoordinatorCount(regionCoordinatorCount);
 
-            List<SysUserBriefResult> assistantEngineer = sysUserService.findUserListByRoleType(RoleTypeEnum.ASSISTANT_ENGINEER);
+            List<SysUserBriefResult> assistantEngineer = sysUserService.findUserListByRoleType(
+                    RoleTypeEnum.ASSISTANT_ENGINEER);
             int assistantEngineerCount = 0;
             if (CollectionUtils.isNotEmpty(assistantEngineer)) {
-                List<Long> assistantEngineerIdList = assistantEngineer.stream().map(SysUserBriefResult::getId).distinct().collect(Collectors.toList());
+                List<Long> assistantEngineerIdList = assistantEngineer.stream().map(SysUserBriefResult::getId)
+                        .distinct().collect(Collectors.toList());
                 assistantEngineerCount = (int) userIdList.stream().filter(assistantEngineerIdList::contains).count();
             }
             result.setAssistantEngineerCount(assistantEngineerCount);
@@ -350,7 +360,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
     }
 
     @Override
-    public List<UserArchivesImportDto> findExportData(String city, Long supplierId, String archivesName, RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
+    public List<UserArchivesImportDto> findExportData(String city, Long supplierId, String archivesName,
+            RoleTypeEnum roleType, Boolean authenticationStatus, Long archivesTimeStart, Long archivesTimeEnd,
             Integer remainValidDay, Boolean unUploadPic) {
         if (city != null && city.length() > 0) {
             city = SystemConstant.translateSpecificSign(city);
@@ -421,7 +432,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
                 Long validTime = userArchivesResult.getAuthenticationValidTime();
                 // 作废校验1 - 认证状态失效
                 if (validTime != null && currentTime < validTime) {
-                    throw ExceptionResultEnum.ERROR.exception(String.format("[%s]的认证状态为有效,不能作废", userArchivesResult.getName()));
+                    throw ExceptionResultEnum.ERROR.exception(
+                            String.format("[%s]的认证状态为有效,不能作废", userArchivesResult.getName()));
                 }
                 // 作废校验2 - 没有进行中的SOP
                 List<SopInfoResult> sopInfoResultList = tbSopInfoService.findFlowByServiceId(null);
@@ -436,13 +448,15 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
                 if (!isCoordinator) {
                     // 不是区域协调人直接判断非空闲即可作废
                     if (UserArchivesStatusEnum.OCCUPIED.equals(status)) {
-                        throw ExceptionResultEnum.ERROR.exception(String.format("[%s]为非空闲,不能作废", userArchivesResult.getName()));
+                        throw ExceptionResultEnum.ERROR.exception(
+                                String.format("[%s]为非空闲,不能作废", userArchivesResult.getName()));
                     }
                 } else {
                     // 包含区域协调人判断该区域协调人涉及的所有派单均完成
                     if (tbCrmService.list(new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getRegionCoordinatorId, userId)
                             .ne(TBCrm::getStatus, CrmStatusEnum.FINISH)).size() > 0) {
-                        throw ExceptionResultEnum.ERROR.exception(String.format("区域协调人[%s]有未完成的派单,不能作废", userArchivesResult.getName()));
+                        throw ExceptionResultEnum.ERROR.exception(
+                                String.format("区域协调人[%s]有未完成的派单,不能作废", userArchivesResult.getName()));
                     }
                 }
             }
@@ -461,7 +475,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
         String mobileNumber = sysUser.getMobileNumber();
 
         List<TBUserArchives> tbUserArchivesList = this.list(
-                new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getMobileNumber, mobileNumber).eq(TBUserArchives::getEnable, true));
+                new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getMobileNumber, mobileNumber)
+                        .eq(TBUserArchives::getEnable, true));
         if (CollectionUtils.isEmpty(tbUserArchivesList)) {
             throw ExceptionResultEnum.ERROR.exception("不存在档案");
         }
@@ -511,7 +526,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
             throw ExceptionResultEnum.ERROR.exception("该方法只支持查询实施工程师和助理工程师");
         }
 
-        List<ArchivesSourceResult> list = new ArrayList<>(this.findArchivesSourceByType(roleType));
+        List<ArchivesSourceResult> list = new ArrayList<>(
+                this.findArchivesSourceByType(new HashSet<>(Arrays.asList(roleType))));
         if (CollectionUtils.isNotEmpty(list)) {
             Long currentTime = System.currentTimeMillis();
             list = list.stream()
@@ -532,7 +548,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
     }
 
     @Override
-    public List<ArchivesSourceResult> findFreeCoordinatorByServiceId(Long serviceUnitId, String crmNo, boolean verifyRate) {
+    public List<ArchivesSourceResult> findFreeCoordinatorByServiceId(Long serviceUnitId, String crmNo,
+            boolean verifyRate) {
         List<ArchivesSourceResult> result = new ArrayList<>();
         TBService tbService = tbServiceService.getById(serviceUnitId);
         if (Objects.isNull(tbService)) {
@@ -543,9 +560,11 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
                 new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getServiceId, serviceUnitId));
 
         Long currentTime = System.currentTimeMillis();
-        List<ArchivesSourceResult> list = this.findArchivesSourceByType(RoleTypeEnum.REGION_COORDINATOR);
+        List<ArchivesSourceResult> list = this.findArchivesSourceByType(
+                new HashSet<>(Arrays.asList(RoleTypeEnum.REGION_COORDINATOR)));
         if (CollectionUtils.isNotEmpty(list)) {
-            list = list.stream().filter(e -> e.getAuthenticationValidTime() != null && e.getAuthenticationValidTime() >= currentTime).peek(e -> {
+            list = list.stream().filter(e -> e.getAuthenticationValidTime() != null
+                    && e.getAuthenticationValidTime() >= currentTime).peek(e -> {
                 Long userId = e.getUserId();
                 int count = Math.toIntExact(
                         tbCrmList.stream().filter(c -> userId.equals(c.getRegionCoordinatorId())).count());
@@ -559,16 +578,19 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
 
             // 调配选人列表查询的特殊处理
             if (crmNo != null && crmNo.length() > 0) {
-                List<TBCrm> temp = tbCrmList.stream().filter(e -> e.getCrmNo().equals(crmNo)).collect(Collectors.toList());
+                List<TBCrm> temp = tbCrmList.stream().filter(e -> e.getCrmNo().equals(crmNo))
+                        .collect(Collectors.toList());
                 if (CollectionUtils.isEmpty(temp)) {
-                    throw ExceptionResultEnum.ERROR.exception(String.format("派单号[%s]不存在在服务单元[%s]下", crmNo, tbService.getName()));
+                    throw ExceptionResultEnum.ERROR.exception(
+                            String.format("派单号[%s]不存在在服务单元[%s]下", crmNo, tbService.getName()));
                 }
                 TBCrm chooseCrm = temp.get(0);
                 Long coordinatorId = chooseCrm.getRegionCoordinatorId();
                 Long regionLeaderId = chooseCrm.getLeadId();
-                if (!Objects.equals(coordinatorId, regionLeaderId)){
+                if (!Objects.equals(coordinatorId, regionLeaderId)) {
                     // 不是由大区经理兼任的再去查档案,否则会报错(不存在档案)
-                    if (coordinatorId != null && !list.stream().map(ArchivesSourceResult::getUserId).collect(Collectors.toList()).contains(coordinatorId)) {
+                    if (coordinatorId != null && !list.stream().map(ArchivesSourceResult::getUserId)
+                            .collect(Collectors.toList()).contains(coordinatorId)) {
                         TBUserArchives chooseArchives = tbUserArchivesService.findByUserId(coordinatorId);
                         ArchivesSourceResult choose = new ArchivesSourceResult();
                         choose.setArchivesId(chooseArchives.getId());
@@ -585,8 +607,8 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
     }
 
     @Override
-    public List<ArchivesSourceResult> findArchivesSourceByType(RoleTypeEnum roleType) {
-        return this.baseMapper.findArchivesSourceByType(roleType);
+    public List<ArchivesSourceResult> findArchivesSourceByType(Set<RoleTypeEnum> roleTypes) {
+        return this.baseMapper.findArchivesSourceByType(roleTypes);
     }
 
     @Override

+ 8 - 3
sop-business/src/main/resources/mapper/TBUserArchivesMapper.xml

@@ -242,15 +242,20 @@
             sys_user su ON tbua.mobile_number = su.mobile_number
         <where>
             AND tbua.enable
-            <if test="roleType != null">
+            <if test="roleTypes != null and roleTypes != '' and roleTypes.size() > 0">
                 AND EXISTS( SELECT
                         1
                     FROM
                         sys_user_role sur
                     LEFT JOIN
                         sys_role sr ON sur.role_id = sr.id
-                    WHERE
-                        sur.user_id = su.id AND sr.type = #{roleType})
+                    <where>
+                        sur.user_id = su.id
+                        and sr.type in
+                        <foreach collection="roleTypes" item="item" index="index" open="(" separator="," close=")">
+                            #{item}
+                        </foreach>
+                    </where>)
             </if>
         </where>
     </select>