caozixuan 1 ano atrás
pai
commit
b231195aba

+ 5 - 3
sop-api/src/main/java/com/qmth/sop/server/api/TBUserArchivesAllocationController.java

@@ -52,10 +52,11 @@ public class TBUserArchivesAllocationController {
                                                  @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, pageNumber, pageSize));
+        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmAllocationPage(SystemConstant.convertIdToLong(serviceUnitId), province, city, area, customName, gap, regionId, pageNumber, pageSize));
     }
 
     @ApiOperation(value = "人员调配管理-小计查询")
@@ -66,9 +67,10 @@ public class TBUserArchivesAllocationController {
                                                      @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 = "分配差额") @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));
+        return ResultUtil.ok(tbUserArchivesAllocationService.findCrmAllocationSubTotal(SystemConstant.convertIdToLong(serviceUnitId), province, city, area, customName, gap, regionId));
     }
 
     @ApiOperation(value = "人员调配管理-根据派单号查询派单分配信息")

+ 5 - 1
sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesAllocationMapper.java

@@ -32,6 +32,7 @@ public interface TBUserArchivesAllocationMapper extends BaseMapper<TBUserArchive
      * @param area          县
      * @param customName    客户名称
      * @param gap           差额
+     * @param regionId      大区id
      * @param dpr           数据权限
      * @return 分页查询结果
      */
@@ -42,6 +43,7 @@ public interface TBUserArchivesAllocationMapper extends BaseMapper<TBUserArchive
                                                               @Param("area") String area,
                                                               @Param("customName") String customName,
                                                               @Param("gap") Integer gap,
+                                                              @Param("regionId") Long regionId,
                                                               @Param("dpr") DataPermissionDto dpr);
 
     /**
@@ -54,7 +56,8 @@ public interface TBUserArchivesAllocationMapper extends BaseMapper<TBUserArchive
      * @param customName    客户名称
      * @param gap           差额
      * @param crmIdList     派单id集合
-     * @param crmStatus 派单状态枚举
+     * @param crmStatus     派单状态枚举
+     * @param regionId      大区id
      * @param dpr           数据权限
      * @return 查询结果
      */
@@ -66,6 +69,7 @@ public interface TBUserArchivesAllocationMapper extends BaseMapper<TBUserArchive
                                                                  @Param("gap") Integer gap,
                                                                  @Param("crmIdList") List<Long> crmIdList,
                                                                  @Param("crmStatus") CrmStatusEnum crmStatus,
+                                                                 @Param("regionId") Long regionId,
                                                                  @Param("dpr") DataPermissionDto dpr);
 
     List<CrmArchivesAllocationResult> findAllocationByCrmNo(@Param("crmNo") String crmNo);

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

@@ -30,11 +30,12 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
      * @param area          县区名称
      * @param customName    客户名称
      * @param gap           分配差额
+     * @param regionId      大区id
      * @param pageNumber    分页页数
      * @param pageSize      分页容量
      * @return 分页查询结果
      */
-    IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Integer pageNumber, Integer pageSize);
+    IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId, Integer pageNumber, Integer pageSize);
 
     /**
      * 查询派单小计
@@ -45,9 +46,10 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
      * @param area          县区名称
      * @param customName    客户名称
      * @param gap           分配差额
+     * @param regionId      大区id
      * @return 小计结果
      */
-    UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province, String city, String area, String customName, Integer gap);
+    UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId);
 
     /**
      * 分配派单

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

@@ -58,7 +58,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
     private SysUserService sysUserService;
 
     @Override
-    public IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Integer pageNumber, Integer pageSize) {
+    public IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId, Integer pageNumber, Integer pageSize) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long userId = requestUser.getId();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(userId);
@@ -67,11 +67,11 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         city = SystemConstant.translateSpecificSign(city);
         area = SystemConstant.translateSpecificSign(area);
         customName = SystemConstant.translateSpecificSign(customName);
-        return this.baseMapper.findCrmAllocationPage(new Page<>(pageNumber, pageSize), serviceUnitId, province, city, area, customName, gap, dpr);
+        return this.baseMapper.findCrmAllocationPage(new Page<>(pageNumber, pageSize), serviceUnitId, province, city, area, customName, gap, regionId, dpr);
     }
 
     @Override
-    public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province, String city, String area, String customName, Integer gap) {
+    public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Long regionId) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         Long userId = requestUser.getId();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(userId);
@@ -80,7 +80,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         city = SystemConstant.translateSpecificSign(city);
         area = SystemConstant.translateSpecificSign(area);
         customName = SystemConstant.translateSpecificSign(customName);
-        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province, city, area, customName, gap, null, null, dpr);
+        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province, city, area, customName, gap, null, null,regionId, dpr);
         Integer publishedCrmCount = Math.toIntExact(list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
         Integer totalCrmCount = list.size();
 
@@ -251,7 +251,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
     public void autoEditCrmAllocationBatch(AutoAllocationParam autoAllocationParam) {
         Long serviceUnitId = autoAllocationParam.getServiceUnitId();
         List<Long> crmIdList = autoAllocationParam.getCrmIdList();
-        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, CrmStatusEnum.UN_PUBLISH, null);
+        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, CrmStatusEnum.UN_PUBLISH, null,null);
         // crm按照差额倒序
         crmSourceList = crmSourceList.stream().filter(e -> e.getUnDistributed() > 0)
                 .sorted(Comparator.comparing(UserArchivesAllocationResult::getUnDistributed).reversed())
@@ -433,7 +433,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
         Long crmId = tbCrm.getId();
         List<Long> crmIdList = new ArrayList<>();
         crmIdList.add(crmId);
-        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, null, null);
+        List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList, null, null,null);
         if (CollectionUtils.isEmpty(crmSourceList)) {
             throw ExceptionResultEnum.ERROR.exception("未找到派单信息");
         } else if (crmSourceList.size() > 1) {

+ 7 - 0
sop-business/src/main/resources/mapper/TBUserArchivesAllocationMapper.xml

@@ -97,6 +97,9 @@
             <if test="gap != null">
                 AND (result.coordinatorUnDistributed + result.effectUnDistributed + result.assistantUnDistributed) &lt;= #{gap}
             </if>
+            <if test="regionId != null">
+                AND result.regionId = #{regionId}
+            </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">
@@ -145,6 +148,7 @@
                 IF(IFNULL(assistantQ.quota, 0) - IFNULL(assistantR.reality, 0) &lt; 0, 0, IFNULL(assistantQ.quota, 0) - IFNULL(assistantR.reality, 0)) AS assistantUnDistributed,
                 tbc.status AS crmStatus,
                 tbs.service_lead_id AS serviceUnitLeaderId,
+                tbc.region_id AS regionId,
                 tbc.lead_id AS regionManagerId,
                 rm.real_name AS regionManagerName,
                 pu.real_name AS publishUserName,
@@ -216,6 +220,9 @@
             <if test="crmStatus != null">
                 AND result.crmStatus = #{crmStatus}
             </if>
+            <if test="regionId != null">
+                AND result.regionId = #{regionId}
+            </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <choose>
                     <when test="dpr.hasBusiness">