소스 검색

项目角色待调配额盘点报表修改

wangliang 1 년 전
부모
커밋
dd4c24a3e8

+ 11 - 4
sop-api/src/main/java/com/qmth/sop/server/api/ServiceAnalyseController.java

@@ -1,12 +1,15 @@
 package com.qmth.sop.server.api;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
+import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.business.entity.TBService;
 import com.qmth.sop.business.service.ServiceAnalyseService;
+import com.qmth.sop.business.service.TBCrmService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.ResultUtil;
@@ -23,7 +26,6 @@ import java.text.DecimalFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * 服务单元分析 控制器
@@ -42,6 +44,9 @@ public class ServiceAnalyseController {
     @Resource
     ServiceAnalyseService serviceAnalyseService;
 
+    @Resource
+    TBCrmService tbCrmService;
+
     //服务单元列表
     @ApiOperation(value = "服务单元列表接口")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
@@ -137,9 +142,11 @@ public class ServiceAnalyseController {
                                @ApiParam(value = "大区", required = true) @RequestParam Long regionId) {
         Map<String, Object> map = new HashMap<>();
         map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId, regionId, null));
-        List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, null);
-        map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
-        map.put("regionCities", crmAllocation.stream().filter(e -> e.getCity() != null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
+//        List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, null);
+//        map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
+//        map.put("regionCities", crmAllocation.stream().filter(e -> e.getCity() != null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
+        map.put("projectWait", serviceAnalyseService.findWaitZone(regionId));
+        map.put("regionCities", tbCrmService.count(new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getRegionId, regionId)));
         return ResultUtil.ok(map);
     }
 

+ 18 - 11
sop-business/src/main/java/com/qmth/sop/business/mapper/ServiceAnalyseMapper.java

@@ -17,31 +17,38 @@ import java.util.Map;
  * </p>
  *
  * @author dhshu
- *
  */
 public interface ServiceAnalyseMapper extends BaseMapper<TBService> {
 
 
-    List<TBService> list(@Param("startTime")Long startTime, @Param("endTime")Long endTime, @Param("dpr") DataPermissionDto dpr);
+    List<TBService> list(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-    List<Map<String,Object>> projectProgress(@Param("serviceUnitId") Long serviceUnitId);
+    List<Map<String, Object>> projectProgress(@Param("serviceUnitId") Long serviceUnitId);
 
-    List<Map<String,Object>> equipmentOutboundTotal(@Param("serviceUnitId") Long serviceUnitId);
+    List<Map<String, Object>> equipmentOutboundTotal(@Param("serviceUnitId") Long serviceUnitId);
 
     Integer projectCount(@Param("serviceUnitId") Long serviceUnitId);
 
-    List<Map<String,Object>> supplierDistribution(@Param("serviceUnitId") Long serviceUnitId);
+    List<Map<String, Object>> supplierDistribution(@Param("serviceUnitId") Long serviceUnitId);
+
+    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
 
-    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("serviceUnitId") Long serviceUnitId,@Param("supplierId") Long supplierId);
+    List<Map<String, Object>> supplierRole(@Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
 
-    List<Map<String,Object>> supplierRole(@Param("serviceUnitId")Long serviceUnitId, @Param("supplierId") Long supplierId);
+    List<Map<String, Object>> supplierRegion(@Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
 
-    List<Map<String,Object>> supplierRegion(@Param("serviceUnitId") Long serviceUnitId,@Param("supplierId") Long supplierId);
 
+    List<Map<String, Object>> device(@Param("serviceUnitId") Long serviceUnitId);
 
-    List<Map<String, Object>> device(@Param("serviceUnitId")Long serviceUnitId);
+    List<Map<String, Object>> personnel(@Param("serviceUnitId") Long serviceUnitId);
 
-    List<Map<String, Object>> personnel(@Param("serviceUnitId")Long serviceUnitId);
+    List<UserArchivesAllocationResult> findCrmAllocation(@Param("serviceUnitId") Long serviceUnitId, @Param("regionId") Long regionId, @Param("supplierId") Long supplierId);
 
-    List<UserArchivesAllocationResult> findCrmAllocation(@Param("serviceUnitId")Long serviceUnitId,@Param("regionId") Long regionId,@Param("supplierId") Long supplierId);
+    /**
+     * 查找当前大区待划定派单数量
+     *
+     * @param regionId
+     * @return
+     */
+    int findWaitZone(@Param("regionId") Long regionId);
 }

+ 11 - 3
sop-business/src/main/java/com/qmth/sop/business/service/ServiceAnalyseService.java

@@ -12,7 +12,7 @@ import java.util.List;
 import java.util.Map;
 
 public interface ServiceAnalyseService extends IService<TBService> {
-    List<TBService> list(Long startTime,Long endTime);
+    List<TBService> list(Long startTime, Long endTime);
 
     Map<String, Object> overview(Long serviceUnitId);
 
@@ -20,9 +20,9 @@ public interface ServiceAnalyseService extends IService<TBService> {
 
     IPage<TBCrmResult> supplierDetail(Page<Object> objectPage, Long serviceUnitId, Long supplierId);
 
-    List<Map<String,Object>> supplierRole(Long serviceUnitId, Long supplierId);
+    List<Map<String, Object>> supplierRole(Long serviceUnitId, Long supplierId);
 
-    List<Map<String,Object>> supplierRegion(Long serviceUnitId,Long supplierId);
+    List<Map<String, Object>> supplierRegion(Long serviceUnitId, Long supplierId);
 
     List<Map<String, Object>> device(Long serviceUnitId);
 
@@ -31,4 +31,12 @@ public interface ServiceAnalyseService extends IService<TBService> {
     UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId);
 
     List<UserArchivesAllocationResult> findCrmAllocation(Long serviceUnitId, Long regionId, Long supplierId);
+
+    /**
+     * 查找当前大区待划定派单数量
+     *
+     * @param regionId
+     * @return
+     */
+    int findWaitZone(Long regionId);
 }

+ 31 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/ServiceAnalyseServiceImpl.java

@@ -10,10 +10,8 @@ import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBService;
 import com.qmth.sop.business.mapper.ServiceAnalyseMapper;
-import com.qmth.sop.business.service.ServiceAnalyseService;
-import com.qmth.sop.business.service.SysUserService;
-import com.qmth.sop.business.service.TBSopInfoService;
-import com.qmth.sop.business.service.TBUserArchivesSupplierService;
+import com.qmth.sop.business.service.*;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.CrmStatusEnum;
 import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
@@ -35,6 +33,9 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
     @Resource
     private SysUserService sysUserService;
 
+    @Resource
+    TBUserArchivesAllocationService tbUserArchivesAllocationService;
+
     @Override
     public List<TBService> list(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
@@ -148,19 +149,21 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
     @Override
     public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId) {
 
-        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocation(serviceUnitId, regionId, supplierId);
-        Integer publishedCrmCount = Math.toIntExact(list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
-        Integer totalCrmCount = list.size();
-
-        Integer coordinatorQuota = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorQuota).sum();
-        Integer coordinatorDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorDistributed).sum();
-
-        Integer effectQuota = list.stream().mapToInt(UserArchivesAllocationResult::getEffectQuota).sum();
-        Integer effectDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getEffectDistributed).sum();
-
-        Integer assistantQuota = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantQuota).sum();
-        Integer assistantDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantDistributed).sum();
-
+//        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocation(serviceUnitId, regionId, supplierId);
+        IPage<UserArchivesAllocationResult> userArchivesAllocationResultIPage = tbUserArchivesAllocationService.findCrmAllocationPage(serviceUnitId, null, null, null, null, null, regionId, SystemConstant.PAGE_NUMBER_MIN, SystemConstant.PAGE_SIZE_MAX_SELECT);
+        Integer publishedCrmCount = 0, totalCrmCount = 0, coordinatorQuota = 0, coordinatorDistributed = 0, effectQuota = 0,
+                effectDistributed = 0, assistantQuota = 0, assistantDistributed = 0;
+        if (Objects.nonNull(userArchivesAllocationResultIPage)) {
+            List<UserArchivesAllocationResult> list = userArchivesAllocationResultIPage.getRecords();
+            publishedCrmCount = Math.toIntExact(list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
+            totalCrmCount = list.size();
+            coordinatorQuota = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorQuota).sum();
+            coordinatorDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorDistributed).sum();
+            effectQuota = list.stream().mapToInt(UserArchivesAllocationResult::getEffectQuota).sum();
+            effectDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getEffectDistributed).sum();
+            assistantQuota = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantQuota).sum();
+            assistantDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantDistributed).sum();
+        }
         UserArchivesAllocationSubTotalResult result = new UserArchivesAllocationSubTotalResult();
         result.setPublishedCrmCount(publishedCrmCount);
         result.setTotalCrmCount(totalCrmCount);
@@ -177,4 +180,15 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
     public List<UserArchivesAllocationResult> findCrmAllocation(Long serviceUnitId, Long regionId, Long supplierId) {
         return this.baseMapper.findCrmAllocation(serviceUnitId, regionId, supplierId);
     }
+
+    /**
+     * 查找当前大区待划定派单数量
+     *
+     * @param regionId
+     * @return
+     */
+    @Override
+    public int findWaitZone(Long regionId) {
+        return this.baseMapper.findWaitZone(regionId);
+    }
 }

+ 11 - 0
sop-business/src/main/resources/mapper/ServiceAnalyseMapper.xml

@@ -202,6 +202,7 @@
 <!--            </if>-->
         </where>
     </select>
+
     <select id="findCrmAllocation" resultType="com.qmth.sop.business.bean.result.UserArchivesAllocationResult">
         SELECT
         *,
@@ -294,6 +295,7 @@
         </where>
         ORDER BY result.serviceUnitId DESC, result.crmId DESC
     </select>
+
     <select id="device" resultType="java.util.Map">
         SELECT
         su.`name`,
@@ -353,6 +355,15 @@
         GROUP BY
         su.`name`,
         r.region_name
+    </select>
 
+    <select id="findWaitZone" resultType="java.lang.Integer">
+        select IFNULL(count(1),0) as c from t_b_crm tbc
+        left join sys_custom sc on sc.id = tbc.custom_id
+        where exists(
+                SELECT tbsr.id FROM t_b_service_region tbsr
+                        left join t_b_service_region_detail tbsrd on tbsrd.service_region_id = tbsr.id
+                where tbsr.id = #{regionId} and sc.province = tbsrd.province and sc.city = tbsrd.city)
+          and tbc.service_id is null and tbc.enable = 1
     </select>
 </mapper>