Procházet zdrojové kódy

fix:大区在服务人数对比

caozixuan před 1 rokem
rodič
revize
dfc41377a6

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

@@ -199,13 +199,14 @@ public class ServiceAnalyseController {
 
     /**
      * 10.大区服务人数分布及对比:
-     * ①当前服务单元下各大区在服务人员的数量分布及对比。单个柱形图可按供应商占比分颜色展示占比。
+     * 1.当前服务单元下各大区在服务人员的数量分布及对比。单个柱形图可按供应商占比分颜色展示占比。
+     * 2.在服务人员:发布的派单所占用的资源
+     * 3.按照自小单元 大区-供应商 去重
      */
     @ApiOperation(value = "大区服务人数分布及对比")
     @RequestMapping(value = "/region/personnel", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "大区服务人数分布及对比", response = Map.class)})
     public Result personnel(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        List<Map<String, Object>> list = serviceAnalyseService.personnel(serviceUnitId);
-        return ResultUtil.ok(list);
+        return ResultUtil.ok(serviceAnalyseService.personnel(serviceUnitId));
     }
 }

+ 56 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/analyze/ServiceUnitPersonnel.java

@@ -0,0 +1,56 @@
+package com.qmth.sop.business.bean.result.analyze;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+/**
+ * @Description: 大区在服务人数及对比
+ * @Author: CaoZixuan
+ * @Date: 2023-11-21
+ */
+public class ServiceUnitPersonnel {
+    @ApiModelProperty("大区id")
+    private Long regionId;
+
+    @ApiModelProperty("大区名称")
+    private String regionName;
+
+    @ApiModelProperty("供应商在服务人数")
+    private List<SupplierPersonnel> supplierPersonnelInfo;
+
+    @ApiModelProperty("大区在服务人数")
+    private Integer count;
+
+    public Long getRegionId() {
+        return regionId;
+    }
+
+    public void setRegionId(Long regionId) {
+        this.regionId = regionId;
+    }
+
+    public String getRegionName() {
+        return regionName;
+    }
+
+    public void setRegionName(String regionName) {
+        this.regionName = regionName;
+    }
+
+    public List<SupplierPersonnel> getSupplierPersonnelInfo() {
+        return supplierPersonnelInfo;
+    }
+
+    public void setSupplierPersonnelInfo(List<SupplierPersonnel> supplierPersonnelInfo) {
+        this.supplierPersonnelInfo = supplierPersonnelInfo;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+}

+ 43 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/analyze/SupplierPersonnel.java

@@ -0,0 +1,43 @@
+package com.qmth.sop.business.bean.result.analyze;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 供应商在服务人员数
+ * @Author: CaoZixuan
+ * @Date: 2023-11-21
+ */
+public class SupplierPersonnel {
+    @ApiModelProperty("供应商id")
+    private Long supplierId;
+
+    @ApiModelProperty("供应商名称")
+    private String supplierName;
+
+    @ApiModelProperty("供应商下在服务人员人数")
+    private Integer count;
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+}

+ 5 - 1
sop-business/src/main/java/com/qmth/sop/business/service/ServiceAnalyseService.java

@@ -7,6 +7,7 @@ import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
 import com.qmth.sop.business.bean.result.analyze.ServiceUnitOverview;
+import com.qmth.sop.business.bean.result.analyze.ServiceUnitPersonnel;
 import com.qmth.sop.business.entity.TBService;
 
 import java.util.List;
@@ -30,7 +31,10 @@ public interface ServiceAnalyseService extends IService<TBService> {
 
     List<Map<String, Object>> device(Long serviceUnitId);
 
-    List<Map<String, Object>> personnel(Long serviceUnitId);
+    @Deprecated
+    List<Map<String, Object>> personnel1(Long serviceUnitId);
+
+    List<ServiceUnitPersonnel> personnel(Long serviceUnitId);
 
     UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId);
 

+ 74 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/ServiceAnalyseServiceImpl.java

@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
+import com.qmth.sop.business.bean.result.CrmArchivesAllocationResult;
 import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
 import com.qmth.sop.business.bean.result.analyze.ServiceUnitOverview;
+import com.qmth.sop.business.bean.result.analyze.ServiceUnitPersonnel;
+import com.qmth.sop.business.bean.result.analyze.SupplierPersonnel;
 import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.mapper.ServiceAnalyseMapper;
 import com.qmth.sop.business.service.*;
@@ -51,6 +54,12 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
     @Resource
     private SysDeviceService sysDeviceService;
 
+    @Resource
+    private TBServiceRegionService tbServiceRegionService;
+
+    @Resource
+    private SysSupplierService sysSupplierService;
+
     @Override
     public List<TBService> list(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
@@ -261,11 +270,75 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
         return this.baseMapper.device(serviceUnitId);
     }
 
+    @Deprecated
     @Override
-    public List<Map<String, Object>> personnel(Long serviceUnitId) {
+    public List<Map<String, Object>> personnel1(Long serviceUnitId) {
         return this.baseMapper.personnel(serviceUnitId);
     }
 
+    @Override
+    public List<ServiceUnitPersonnel> personnel(Long serviceUnitId) {
+        List<TBCrm> publishCrmList = tbCrmService.list(new QueryWrapper<TBCrm>()
+                .lambda()
+                .eq(TBCrm::getServiceId, serviceUnitId)
+                .eq(TBCrm::getEnable, true)
+                .eq(TBCrm::getStatus, CrmStatusEnum.PUBLISH));
+
+        Set<Long> regionIdSet = publishCrmList.stream().map(TBCrm::getRegionId).collect(Collectors.toSet());
+
+        List<ServiceUnitPersonnel> serviceUnitPersonnelList = new ArrayList<>();
+        for (Long regionId : regionIdSet) {
+            TBServiceRegion tbServiceRegion = tbServiceRegionService.getById(regionId);
+            if (Objects.isNull(tbServiceRegion)) {
+                throw ExceptionResultEnum.ERROR.exception("未找到大区信息");
+            }
+            String regionName = tbServiceRegion.getRegionName();
+
+            List<TBCrm> crmList = publishCrmList.stream()
+                    .filter(e -> regionId.equals(e.getRegionId()))
+                    .collect(Collectors.toList());
+
+            // 大区下供应商和人员关系Map
+            Map<Long, Set<Long>> supplierMap = new HashMap<>();
+            for (TBCrm tbCrm : crmList) {
+                List<CrmArchivesAllocationResult> detail = tbUserArchivesAllocationService.findAllocationByCrmNo(tbCrm.getCrmNo());
+                detail.forEach(e -> {
+                    Long supplierId = e.getSupplierId();
+                    Long userId = e.getUserId();
+                    if (supplierMap.containsKey(supplierId)) {
+                        supplierMap.get(supplierId).add(userId);
+                    } else {
+                        Set<Long> userIdSet = new HashSet<>();
+                        userIdSet.add(userId);
+                        supplierMap.put(supplierId, userIdSet);
+                    }
+                });
+            }
+
+            List<SupplierPersonnel> supplierPersonnelList = new ArrayList<>();
+            int count = 0;
+            for (Long supplierId : supplierMap.keySet()) {
+                SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
+                String supplierName = sysSupplier.getName();
+
+                SupplierPersonnel supplierPersonnel = new SupplierPersonnel();
+                supplierPersonnel.setSupplierId(supplierId);
+                supplierPersonnel.setSupplierName(supplierName);
+                int cellCount = supplierMap.get(supplierId).size();
+                supplierPersonnel.setCount(cellCount);
+                supplierPersonnelList.add(supplierPersonnel);
+                count = count + cellCount;
+            }
+            ServiceUnitPersonnel serviceUnitPersonnel = new ServiceUnitPersonnel();
+            serviceUnitPersonnel.setRegionId(regionId);
+            serviceUnitPersonnel.setRegionName(regionName);
+            serviceUnitPersonnel.setSupplierPersonnelInfo(supplierPersonnelList);
+            serviceUnitPersonnel.setCount(count);
+            serviceUnitPersonnelList.add(serviceUnitPersonnel);
+        }
+        return serviceUnitPersonnelList;
+    }
+
 
     @Override
     public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId) {

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

@@ -243,7 +243,7 @@
             sr.type AS type,
             tbua.id AS archivesId,
             tbua.name AS archiverName,
-            tbuas.id AS supplierId,
+            tbuas.supplier_id AS supplierId,
             ss.name AS supplierName,
             tbua.province AS archivesProvince,
             tbua.city AS archivesCity,