|
@@ -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) {
|