|
@@ -27,17 +27,17 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopInfo> implements SopAnalyseService {
|
|
public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopInfo> implements SopAnalyseService {
|
|
|
|
+
|
|
@Resource
|
|
@Resource
|
|
private SysUserService sysUserService;
|
|
private SysUserService sysUserService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<TBService> list(Long startTime,Long endTime) {
|
|
|
|
|
|
+ public List<TBService> list(Long startTime, Long endTime) {
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
|
|
DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
|
|
- return this.baseMapper.list(startTime,endTime,dpr);
|
|
|
|
|
|
+ return this.baseMapper.list(startTime, endTime, dpr);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* * ①可按照大区/人力供应商进行切换如图;
|
|
* * ①可按照大区/人力供应商进行切换如图;
|
|
* * ②按照派单数TOP3的大区、人力供应商显示;
|
|
* * ②按照派单数TOP3的大区、人力供应商显示;
|
|
@@ -47,24 +47,27 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
@Deprecated
|
|
@Deprecated
|
|
@Override
|
|
@Override
|
|
public List<Map<String, Object>> overview1(Long serviceId, SopAnalyseGroupEnum group) {
|
|
public List<Map<String, Object>> overview1(Long serviceId, SopAnalyseGroupEnum group) {
|
|
- List<Map<String, Object>> list = this.baseMapper.overview(serviceId);
|
|
|
|
|
|
+ List<Map<String, Object>> list = this.baseMapper.overview(serviceId, group.name());
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
- list.stream().filter(map->map.get("region_name")!=null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("region_name", k);
|
|
|
|
- processOverviewData(v, map);
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ list.stream().filter(map -> map.get("region_name") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("region_name", k);
|
|
|
|
+ processOverviewData(v, map);
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
- list.stream().filter(map -> map.get("supplier")!=null).collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("supplier", k);
|
|
|
|
- processOverviewData(v, map);
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ list.stream().filter(map -> map.get("supplier") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("supplier", k);
|
|
|
|
+ processOverviewData(v, map);
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- return result.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("crmNum").toString()))).limit(3).collect(Collectors.toList());
|
|
|
|
|
|
+ return result.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("crmNum").toString())))
|
|
|
|
+ .limit(3).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -78,34 +81,40 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
|
|
List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
|
|
List<SopWarnOverview> result = new ArrayList<>();
|
|
List<SopWarnOverview> result = new ArrayList<>();
|
|
switch (group) {
|
|
switch (group) {
|
|
- case REGION:
|
|
|
|
- Set<Long> regionIdSet = sopMonitorList.stream().filter(e -> e.getRegionId() != null && e.getRegionId() > 0).map(SopMonitor::getRegionId).collect(Collectors.toSet());
|
|
|
|
- for (Long regionId : regionIdSet) {
|
|
|
|
- List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> regionId.equals(e.getRegionId())).collect(Collectors.toList());
|
|
|
|
- String regionName = dataCell.get(0).getRegionName();
|
|
|
|
- SopWarnOverview regionOverview = buildSopOverviewStatistic(dataCell);
|
|
|
|
- regionOverview.setRegionId(regionId);
|
|
|
|
- regionOverview.setRegionName(regionName);
|
|
|
|
- result.add(regionOverview);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case SUPPLIER:
|
|
|
|
- // 由大区经理兼任不显示
|
|
|
|
- Set<Long> supplierIdSet = sopMonitorList.stream().filter(e -> e.getSupplierId() != null && e.getSupplierId() > 0).map(SopMonitor::getSupplierId).collect(Collectors.toSet());
|
|
|
|
- for (Long supplierId : supplierIdSet) {
|
|
|
|
- List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> supplierId.equals(e.getSupplierId())).collect(Collectors.toList());
|
|
|
|
- SopWarnOverview supplierOverview = buildSopOverviewStatistic(dataCell);
|
|
|
|
- supplierOverview.setSupplierName(dataCell.get(0).getSupplierName());
|
|
|
|
- supplierOverview.setSupplierId(supplierId);
|
|
|
|
- result.add(supplierOverview);
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ case REGION:
|
|
|
|
+ Set<Long> regionIdSet = sopMonitorList.stream().filter(e -> e.getRegionId() != null && e.getRegionId() > 0)
|
|
|
|
+ .map(SopMonitor::getRegionId).collect(Collectors.toSet());
|
|
|
|
+ for (Long regionId : regionIdSet) {
|
|
|
|
+ List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> regionId.equals(e.getRegionId()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ String regionName = dataCell.get(0).getRegionName();
|
|
|
|
+ SopWarnOverview regionOverview = buildSopOverviewStatistic(dataCell);
|
|
|
|
+ regionOverview.setRegionId(regionId);
|
|
|
|
+ regionOverview.setRegionName(regionName);
|
|
|
|
+ result.add(regionOverview);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case SUPPLIER:
|
|
|
|
+ // 由大区经理兼任不显示
|
|
|
|
+ Set<Long> supplierIdSet = sopMonitorList.stream()
|
|
|
|
+ .filter(e -> e.getSupplierId() != null && e.getSupplierId() > 0).map(SopMonitor::getSupplierId)
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+ for (Long supplierId : supplierIdSet) {
|
|
|
|
+ List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> supplierId.equals(e.getSupplierId()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ SopWarnOverview supplierOverview = buildSopOverviewStatistic(dataCell);
|
|
|
|
+ supplierOverview.setSupplierName(dataCell.get(0).getSupplierName());
|
|
|
|
+ supplierOverview.setSupplierId(supplierId);
|
|
|
|
+ result.add(supplierOverview);
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建sop监控统计
|
|
* 创建sop监控统计
|
|
|
|
+ *
|
|
* @param dataCell 数据集
|
|
* @param dataCell 数据集
|
|
* @return sop监控
|
|
* @return sop监控
|
|
*/
|
|
*/
|
|
@@ -113,7 +122,8 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
SopWarnOverview sopWarnOverview = new SopWarnOverview();
|
|
SopWarnOverview sopWarnOverview = new SopWarnOverview();
|
|
if (CollectionUtils.isNotEmpty(dataCell)) {
|
|
if (CollectionUtils.isNotEmpty(dataCell)) {
|
|
int crmNum = (int) dataCell.stream().map(SopMonitor::getCrmNo).distinct().count();
|
|
int crmNum = (int) dataCell.stream().map(SopMonitor::getCrmNo).distinct().count();
|
|
- int finishCrmNum = (int) (crmNum - dataCell.stream().filter(e -> !e.getFinishStatus()).map(SopMonitor::getCrmNo).distinct().count());
|
|
|
|
|
|
+ int finishCrmNum = (int) (crmNum - dataCell.stream().filter(e -> !e.getFinishStatus())
|
|
|
|
+ .map(SopMonitor::getCrmNo).distinct().count());
|
|
int effectAvgTimeCount = 0;
|
|
int effectAvgTimeCount = 0;
|
|
long effectTotalMinutes = 0L;
|
|
long effectTotalMinutes = 0L;
|
|
int violationNum = 0;
|
|
int violationNum = 0;
|
|
@@ -124,15 +134,14 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
for (SopMonitor sopMonitor : dataCell) {
|
|
for (SopMonitor sopMonitor : dataCell) {
|
|
SopMonitorEnum sopMonitorType = sopMonitor.getSopMonitorType();
|
|
SopMonitorEnum sopMonitorType = sopMonitor.getSopMonitorType();
|
|
switch (sopMonitorType) {
|
|
switch (sopMonitorType) {
|
|
- case DELAY_WARN:
|
|
|
|
- delayNum++;
|
|
|
|
- break;
|
|
|
|
- case VIOLATION:
|
|
|
|
- violationNum++;
|
|
|
|
- break;
|
|
|
|
|
|
+ case DELAY_WARN:
|
|
|
|
+ delayNum++;
|
|
|
|
+ break;
|
|
|
|
+ case VIOLATION:
|
|
|
|
+ violationNum++;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
Boolean finishStatus = sopMonitor.getFinishStatus();
|
|
Boolean finishStatus = sopMonitor.getFinishStatus();
|
|
if (finishStatus) {
|
|
if (finishStatus) {
|
|
Long startTime = sopMonitor.getStartTime();
|
|
Long startTime = sopMonitor.getStartTime();
|
|
@@ -144,12 +153,12 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
}
|
|
}
|
|
|
|
|
|
switch (sopMonitorType) {
|
|
switch (sopMonitorType) {
|
|
- case DELAY_WARN:
|
|
|
|
- finishDelayNum++;
|
|
|
|
- break;
|
|
|
|
- case VIOLATION:
|
|
|
|
- finishViolationNum++;
|
|
|
|
- break;
|
|
|
|
|
|
+ case DELAY_WARN:
|
|
|
|
+ finishDelayNum++;
|
|
|
|
+ break;
|
|
|
|
+ case VIOLATION:
|
|
|
|
+ finishViolationNum++;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -158,7 +167,8 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
sopWarnOverview.setFinishCrmNum(finishCrmNum);
|
|
sopWarnOverview.setFinishCrmNum(finishCrmNum);
|
|
BigDecimal avgMinutes = new BigDecimal(0);
|
|
BigDecimal avgMinutes = new BigDecimal(0);
|
|
if (effectAvgTimeCount > 0) {
|
|
if (effectAvgTimeCount > 0) {
|
|
- avgMinutes = new BigDecimal(effectTotalMinutes).divide(new BigDecimal(effectAvgTimeCount), 2, RoundingMode.HALF_UP);
|
|
|
|
|
|
+ avgMinutes = new BigDecimal(effectTotalMinutes).divide(new BigDecimal(effectAvgTimeCount), 2,
|
|
|
|
+ RoundingMode.HALF_UP);
|
|
}
|
|
}
|
|
sopWarnOverview.setAvgMinutes(avgMinutes);
|
|
sopWarnOverview.setAvgMinutes(avgMinutes);
|
|
sopWarnOverview.setViolationNum(violationNum);
|
|
sopWarnOverview.setViolationNum(violationNum);
|
|
@@ -169,26 +179,38 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
return sopWarnOverview;
|
|
return sopWarnOverview;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
private static void processOverviewData(List<Map<String, Object>> v, Map<String, Object> map) {
|
|
private static void processOverviewData(List<Map<String, Object>> v, Map<String, Object> map) {
|
|
//派单数
|
|
//派单数
|
|
map.put("crmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size());
|
|
map.put("crmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size());
|
|
//已完成派单数
|
|
//已完成派单数
|
|
- map.put("finishCrmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).values().stream().filter(list1 -> list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("sopStatus"))) || list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("status")))).count());
|
|
|
|
|
|
+ map.put("finishCrmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).values().stream()
|
|
|
|
+ .filter(list1 -> list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("sopStatus")))
|
|
|
|
+ || list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("status")))).count());
|
|
//违规数
|
|
//违规数
|
|
- map.put("violationNum", v.stream().filter(map1 -> map1.get("vid") != null).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
|
|
|
|
+ map.put("violationNum", v.stream().filter(map1 -> map1.get("vid") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
//已关闭违规数
|
|
//已关闭违规数
|
|
- map.put("finishViolationNum", v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus"))).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
|
|
|
|
+ map.put("finishViolationNum",
|
|
|
|
+ v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus")))
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
//延期数
|
|
//延期数
|
|
- map.put("delayNum", v.stream().filter(map1 -> map1.get("did") != null).collect(Collectors.groupingBy(map1 -> map1.get("did"))).size());
|
|
|
|
|
|
+ map.put("delayNum", v.stream().filter(map1 -> map1.get("did") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("did"))).size());
|
|
//已关闭延期数
|
|
//已关闭延期数
|
|
- map.put("finishDelayNum", v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
|
|
- Double processViolationTime = v.stream().filter(map1 -> map1.get("vdiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
|
|
|
|
- Double processDelayTime = v.stream().filter(map1 -> map1.get("ddiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
|
|
|
|
|
|
+ map.put("finishDelayNum",
|
|
|
|
+ v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus")))
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
|
|
|
|
+ Double processViolationTime = v.stream().filter(map1 -> map1.get("vdiff") != null)
|
|
|
|
+ .mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
|
|
|
|
+ Double processDelayTime = v.stream().filter(map1 -> map1.get("ddiff") != null)
|
|
|
|
+ .mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
|
|
//平均处理时限分钟
|
|
//平均处理时限分钟
|
|
- int total = (Integer.parseInt(map.get("finishViolationNum").toString()) + Integer.parseInt(map.get("finishDelayNum").toString()));
|
|
|
|
- map.put("avgMinutes", total == 0 ? 0 : new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2, RoundingMode.HALF_UP));
|
|
|
|
-
|
|
|
|
|
|
+ int total = (Integer.parseInt(map.get("finishViolationNum").toString()) + Integer.parseInt(
|
|
|
|
+ map.get("finishDelayNum").toString()));
|
|
|
|
+ map.put("avgMinutes", total == 0 ?
|
|
|
|
+ 0 :
|
|
|
|
+ new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2,
|
|
|
|
+ RoundingMode.HALF_UP));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -208,40 +230,49 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
@Override
|
|
@Override
|
|
public List<Map<String, Object>> processing(Long serviceId, SopAnalyseGroupEnum group, SopAnalyseSortEnum sort) {
|
|
public List<Map<String, Object>> processing(Long serviceId, SopAnalyseGroupEnum group, SopAnalyseSortEnum sort) {
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
- List<Map<String, Object>> list = this.baseMapper.overview(serviceId);
|
|
|
|
|
|
+ List<Map<String, Object>> list = this.baseMapper.overview(serviceId, group.name());
|
|
if (group.equals(SopAnalyseGroupEnum.CRM)) {
|
|
if (group.equals(SopAnalyseGroupEnum.CRM)) {
|
|
- list.stream().filter(map->map.get("name")!=null).collect(Collectors.groupingBy(map -> map.get("name"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("crmName", k);
|
|
|
|
- //大区
|
|
|
|
- map.put("region_name", v.get(0).get("region_name"));
|
|
|
|
- processing(v, map);
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ list.stream().filter(map -> map.get("name") != null).collect(Collectors.groupingBy(map -> map.get("name")))
|
|
|
|
+ .forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("crmName", k);
|
|
|
|
+ //大区
|
|
|
|
+ map.put("region_name", v.get(0).get("region_name"));
|
|
|
|
+ processing(v, map);
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
} else if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
} else if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
- list.stream().filter(map->map.get("region_name")!=null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("region_name", k);
|
|
|
|
- processing(v, map);
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ list.stream().filter(map -> map.get("region_name") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("region_name", k);
|
|
|
|
+ processing(v, map);
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
- list.stream().filter(map->map.get("supplier")!=null).collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("supplier", k);
|
|
|
|
- //大区
|
|
|
|
- map.put("region_name", v.get(0).get("region_name"));
|
|
|
|
- processing(v, map);
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ list.stream().filter(map -> map.get("supplier") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("supplier", k);
|
|
|
|
+ //大区
|
|
|
|
+ map.put("region_name", v.get(0).get("region_name"));
|
|
|
|
+ processing(v, map);
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
if (sort.equals(SopAnalyseSortEnum.PENDING)) {
|
|
if (sort.equals(SopAnalyseSortEnum.PENDING)) {
|
|
- return result.stream().sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("pendingProcessing").toString()))).limit(10).collect(Collectors.toList());
|
|
|
|
|
|
+ return result.stream()
|
|
|
|
+ .sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("pendingProcessing").toString())))
|
|
|
|
+ .limit(10).collect(Collectors.toList());
|
|
} else if (sort.equals(SopAnalyseSortEnum.SLOWEST)) {
|
|
} else if (sort.equals(SopAnalyseSortEnum.SLOWEST)) {
|
|
- return result.stream().sorted(Comparator.comparingDouble(o -> -Double.parseDouble(o.get("avgMinutes").toString()))).limit(10).collect(Collectors.toList());
|
|
|
|
|
|
+ return result.stream()
|
|
|
|
+ .sorted(Comparator.comparingDouble(o -> -Double.parseDouble(o.get("avgMinutes").toString())))
|
|
|
|
+ .limit(10).collect(Collectors.toList());
|
|
} else if (sort.equals(SopAnalyseSortEnum.FASTEST)) {
|
|
} else if (sort.equals(SopAnalyseSortEnum.FASTEST)) {
|
|
- return result.stream().sorted(Comparator.comparingDouble(o -> Double.parseDouble(o.get("avgMinutes").toString()))).limit(10).collect(Collectors.toList());
|
|
|
|
|
|
+ return result.stream()
|
|
|
|
+ .sorted(Comparator.comparingDouble(o -> Double.parseDouble(o.get("avgMinutes").toString())))
|
|
|
|
+ .limit(10).collect(Collectors.toList());
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
|
|
|
|
@@ -251,22 +282,33 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
//区域协调人
|
|
//区域协调人
|
|
map.put("real_name", v.get(0).get("real_name"));
|
|
map.put("real_name", v.get(0).get("real_name"));
|
|
//违规数
|
|
//违规数
|
|
- Integer violationNum = v.stream().filter(map1 -> map1.get("did") != null).collect(Collectors.groupingBy(map1 -> map1.get("did"))).size();
|
|
|
|
|
|
+ Integer violationNum = v.stream().filter(map1 -> map1.get("did") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("did"))).size();
|
|
//已关闭违规数
|
|
//已关闭违规数
|
|
- Long finishViolationNum = v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).count();
|
|
|
|
|
|
+ Long finishViolationNum = v.stream()
|
|
|
|
+ .filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).count();
|
|
//延期数
|
|
//延期数
|
|
- Integer delayNum = v.stream().filter(map1 -> map1.get("vid") != null).collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size();
|
|
|
|
|
|
+ Integer delayNum = v.stream().filter(map1 -> map1.get("vid") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size();
|
|
//已关闭延期数
|
|
//已关闭延期数
|
|
- Long finishDelayNum = v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus"))).count();
|
|
|
|
- Double processViolationTime = v.stream().filter(map1 -> map1.get("ddiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
|
|
|
|
- Double processDelayTime = v.stream().filter(map1 -> map1.get("vdiff") != null).mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
|
|
|
|
|
|
+ Long finishDelayNum = v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus")))
|
|
|
|
+ .count();
|
|
|
|
+ Double processViolationTime = v.stream().filter(map1 -> map1.get("ddiff") != null)
|
|
|
|
+ .mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
|
|
|
|
+ Double processDelayTime = v.stream().filter(map1 -> map1.get("vdiff") != null)
|
|
|
|
+ .mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
|
|
//平均处理时限分钟
|
|
//平均处理时限分钟
|
|
long total = finishViolationNum + finishDelayNum;
|
|
long total = finishViolationNum + finishDelayNum;
|
|
- map.put("avgMinutes", total == 0 ? 0 : new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
+ map.put("avgMinutes", total == 0 ?
|
|
|
|
+ 0 :
|
|
|
|
+ new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2,
|
|
|
|
+ RoundingMode.HALF_UP));
|
|
//待处理总数数
|
|
//待处理总数数
|
|
map.put("pendingProcessing", violationNum + delayNum - total);
|
|
map.put("pendingProcessing", violationNum + delayNum - total);
|
|
//预警均值
|
|
//预警均值
|
|
- map.put("avgWarn", new BigDecimal(violationNum + delayNum).divide(new BigDecimal(v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2, RoundingMode.HALF_UP));
|
|
|
|
|
|
+ map.put("avgWarn", new BigDecimal(violationNum + delayNum).divide(
|
|
|
|
+ new BigDecimal(v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
|
|
|
|
+ RoundingMode.HALF_UP));
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -276,10 +318,11 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
@Override
|
|
@Override
|
|
public Map<Object, List<Map<String, Object>>> trend1(Long serviceId) {
|
|
public Map<Object, List<Map<String, Object>>> trend1(Long serviceId) {
|
|
List<Map<String, Object>> list = this.baseMapper.trend(serviceId);
|
|
List<Map<String, Object>> list = this.baseMapper.trend(serviceId);
|
|
-// Map<Object, List<Map<String, Object>>> collect1 = list.stream().collect(Collectors.groupingBy(map -> map.get("click_date")));
|
|
|
|
-// Map<Object, Map<Object, List<Map<String, Object>>>> collect = new HashMap<>();
|
|
|
|
-// collect1.forEach((k, v) -> collect.put(k,v.stream().filter(map -> map.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier")))));
|
|
|
|
- return list.stream().filter(map -> map.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier")));
|
|
|
|
|
|
+ // Map<Object, List<Map<String, Object>>> collect1 = list.stream().collect(Collectors.groupingBy(map -> map.get("click_date")));
|
|
|
|
+ // Map<Object, Map<Object, List<Map<String, Object>>>> collect = new HashMap<>();
|
|
|
|
+ // collect1.forEach((k, v) -> collect.put(k,v.stream().filter(map -> map.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier")))));
|
|
|
|
+ return list.stream().filter(map -> map.get("supplier") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map1 -> map1.get("supplier")));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -290,7 +333,8 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<SopSupplierAvgViewTimes> trend(Long serviceId) {
|
|
public List<SopSupplierAvgViewTimes> trend(Long serviceId) {
|
|
- List<CrmSupplierRelation> crmSupplierRelationList = this.baseMapper.findCrmSupplierRelationByServiceId(serviceId);
|
|
|
|
|
|
+ List<CrmSupplierRelation> crmSupplierRelationList = this.baseMapper.findCrmSupplierRelationByServiceId(
|
|
|
|
+ serviceId);
|
|
Map<Long, Set<String>> supplierCrmNumMap = new HashMap<>();
|
|
Map<Long, Set<String>> supplierCrmNumMap = new HashMap<>();
|
|
for (CrmSupplierRelation crmSupplierRelation : crmSupplierRelationList) {
|
|
for (CrmSupplierRelation crmSupplierRelation : crmSupplierRelationList) {
|
|
String crmNo = crmSupplierRelation.getCrmNo();
|
|
String crmNo = crmSupplierRelation.getCrmNo();
|
|
@@ -304,7 +348,6 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
|
|
List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
List<Long> times = new ArrayList<>();
|
|
List<Long> times = new ArrayList<>();
|
|
@@ -325,25 +368,24 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
List<SopSupplierAvgViewTimes> result = new ArrayList<>();
|
|
List<SopSupplierAvgViewTimes> result = new ArrayList<>();
|
|
for (Long time : times) {
|
|
for (Long time : times) {
|
|
// 当天之前的预警(大区经理兼任的不算)
|
|
// 当天之前的预警(大区经理兼任的不算)
|
|
- List<SopMonitor> monitorTimeCell = sopMonitorList
|
|
|
|
- .stream()
|
|
|
|
- .filter(e -> !e.getFinishStatus() && e.getStartTime() < time && e.getSupplierId() != null && e.getSupplierId() > 0)
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
+ List<SopMonitor> monitorTimeCell = sopMonitorList.stream()
|
|
|
|
+ .filter(e -> !e.getFinishStatus() && e.getStartTime() < time && e.getSupplierId() != null
|
|
|
|
+ && e.getSupplierId() > 0).collect(Collectors.toList());
|
|
|
|
|
|
- List<Long> supplierIdList = monitorTimeCell.stream().map(SopMonitor::getSupplierId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> supplierIdList = monitorTimeCell.stream().map(SopMonitor::getSupplierId).distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
List<SopSupplierAvgView> sopSupplierAvgViewList = new ArrayList<>();
|
|
List<SopSupplierAvgView> sopSupplierAvgViewList = new ArrayList<>();
|
|
for (Long supplierId : supplierIdList) {
|
|
for (Long supplierId : supplierIdList) {
|
|
- List<SopMonitor> monitorSupplierCell = monitorTimeCell
|
|
|
|
- .stream()
|
|
|
|
- .filter(e -> e.getSupplierId().equals(supplierId))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
|
+ List<SopMonitor> monitorSupplierCell = monitorTimeCell.stream()
|
|
|
|
+ .filter(e -> e.getSupplierId().equals(supplierId)).collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(monitorSupplierCell)) {
|
|
if (CollectionUtils.isNotEmpty(monitorSupplierCell)) {
|
|
String supplierName = monitorSupplierCell.get(0).getSupplierName();
|
|
String supplierName = monitorSupplierCell.get(0).getSupplierName();
|
|
int warnCount = monitorSupplierCell.size();
|
|
int warnCount = monitorSupplierCell.size();
|
|
if (supplierCrmNumMap.containsKey(supplierId)) {
|
|
if (supplierCrmNumMap.containsKey(supplierId)) {
|
|
int crmCount = supplierCrmNumMap.get(supplierId).size();
|
|
int crmCount = supplierCrmNumMap.get(supplierId).size();
|
|
- BigDecimal rate = new BigDecimal(warnCount).divide(new BigDecimal(crmCount), 2, RoundingMode.HALF_UP);
|
|
|
|
|
|
+ BigDecimal rate = new BigDecimal(warnCount).divide(new BigDecimal(crmCount), 2,
|
|
|
|
+ RoundingMode.HALF_UP);
|
|
|
|
|
|
SopSupplierAvgView sopSupplierAvgView = new SopSupplierAvgView();
|
|
SopSupplierAvgView sopSupplierAvgView = new SopSupplierAvgView();
|
|
sopSupplierAvgView.setSupplierId(supplierId);
|
|
sopSupplierAvgView.setSupplierId(supplierId);
|
|
@@ -369,11 +411,13 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
// 补零
|
|
// 补零
|
|
for (SopSupplierAvgViewTimes supplierAvgViewTimes : result) {
|
|
for (SopSupplierAvgViewTimes supplierAvgViewTimes : result) {
|
|
List<SopSupplierAvgView> list = supplierAvgViewTimes.getSopSupplierAvgViewInfo();
|
|
List<SopSupplierAvgView> list = supplierAvgViewTimes.getSopSupplierAvgViewInfo();
|
|
- if (CollectionUtils.isEmpty(list)){
|
|
|
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
list = new ArrayList<>();
|
|
list = new ArrayList<>();
|
|
}
|
|
}
|
|
- List<Long> alreadyUsedSupplierIdList = list.stream().map(SopSupplierAvgView::getSupplierId).collect(Collectors.toList());
|
|
|
|
- List<Long> needFillIdList = supplierInfoMap.keySet().stream().filter(k -> !alreadyUsedSupplierIdList.contains(k)).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> alreadyUsedSupplierIdList = list.stream().map(SopSupplierAvgView::getSupplierId)
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<Long> needFillIdList = supplierInfoMap.keySet().stream()
|
|
|
|
+ .filter(k -> !alreadyUsedSupplierIdList.contains(k)).collect(Collectors.toList());
|
|
for (Long supplierId : needFillIdList) {
|
|
for (Long supplierId : needFillIdList) {
|
|
SopSupplierAvgView view = new SopSupplierAvgView();
|
|
SopSupplierAvgView view = new SopSupplierAvgView();
|
|
view.setRate(new BigDecimal(0));
|
|
view.setRate(new BigDecimal(0));
|
|
@@ -394,41 +438,54 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
@Override
|
|
@Override
|
|
public List<Map<String, Object>> attendance(Long serviceId, SopAnalyseGroupEnum group) {
|
|
public List<Map<String, Object>> attendance(Long serviceId, SopAnalyseGroupEnum group) {
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
- List<Map<String, Object>> attendance = this.baseMapper.attendance(serviceId);
|
|
|
|
|
|
+ List<Map<String, Object>> attendance = this.baseMapper.attendance(serviceId, group.name());
|
|
if (group.equals(SopAnalyseGroupEnum.CRM)) {
|
|
if (group.equals(SopAnalyseGroupEnum.CRM)) {
|
|
- attendance.stream().filter(map -> map.get("name")!=null).collect(Collectors.groupingBy(map -> map.get("name"))).forEach((k, v) -> v.stream().filter(map -> map.get("dname")!=null).collect(Collectors.groupingBy(map -> map.get("dname"))).forEach((x, y)->{
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("crmName", k);
|
|
|
|
- map.put("dname", x);
|
|
|
|
- map.put("real_name", v.get(0).get("real_name"));
|
|
|
|
- map.put("total", y.stream().filter(map1 -> map1.get("id") != null).count());
|
|
|
|
- result.add(map);
|
|
|
|
- }));
|
|
|
|
-
|
|
|
|
|
|
+ attendance.stream().filter(map -> map.get("name") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("name"))).forEach(
|
|
|
|
+ (k, v) -> v.stream().filter(map -> map.get("dname") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("dname"))).forEach((x, y) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("crmName", k);
|
|
|
|
+ map.put("dname", x);
|
|
|
|
+ map.put("real_name", v.get(0).get("real_name"));
|
|
|
|
+ map.put("total", y.stream().filter(map1 -> map1.get("id") != null).count());
|
|
|
|
+ result.add(map);
|
|
|
|
+ }));
|
|
|
|
|
|
} else if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
} else if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
- attendance.stream().filter(map -> map.get("region_name")!=null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("region_name", k);
|
|
|
|
- map.put("real_name", v.get(0).get("real_name"));
|
|
|
|
- long total = v.stream().filter(map1 -> map1.get("id") != null).count();
|
|
|
|
- map.put("total", total);
|
|
|
|
- map.put("avg", Double.parseDouble(total+"")/v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size());
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ attendance.stream().filter(map -> map.get("region_name") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("region_name", k);
|
|
|
|
+ map.put("real_name", v.get(0).get("real_name"));
|
|
|
|
+ long total = v.stream().filter(map1 -> map1.get("id") != null).count();
|
|
|
|
+ map.put("total", total);
|
|
|
|
+ map.put("avg", total == 0 ?
|
|
|
|
+ 0 :
|
|
|
|
+ new BigDecimal(total).divide(new BigDecimal(
|
|
|
|
+ v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
|
|
|
|
+ RoundingMode.HALF_UP));
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
|
|
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
} else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
|
|
- attendance.stream().filter(map -> map.get("supplier")!=null).collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("supplier", k);
|
|
|
|
- long total = v.stream().filter(map1 -> map1.get("id") != null).count();
|
|
|
|
- map.put("total",total);
|
|
|
|
- map.put("avg", Double.parseDouble(total+"")/v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size());
|
|
|
|
- result.add(map);
|
|
|
|
- });
|
|
|
|
|
|
+ attendance.stream().filter(map -> map.get("supplier") != null)
|
|
|
|
+ .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("supplier", k);
|
|
|
|
+ long total = v.stream().filter(map1 -> map1.get("id") != null).count();
|
|
|
|
+ map.put("total", total);
|
|
|
|
+ map.put("avg", total == 0 ?
|
|
|
|
+ 0 :
|
|
|
|
+ new BigDecimal(total).divide(new BigDecimal(
|
|
|
|
+ v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
|
|
|
|
+ RoundingMode.HALF_UP));
|
|
|
|
+ result.add(map);
|
|
|
|
+ });
|
|
|
|
|
|
}
|
|
}
|
|
- return result.stream().sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("total").toString()))).limit(10).collect(Collectors.toList());
|
|
|
|
|
|
+ return result.stream().sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("total").toString())))
|
|
|
|
+ .limit(10).collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|