|
@@ -1,7 +1,12 @@
|
|
|
package com.qmth.sop.business.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.sop.business.bean.dto.DataPermissionDto;
|
|
|
+import com.qmth.sop.business.bean.result.analyze.sopWarn.SopMonitor;
|
|
|
+import com.qmth.sop.business.bean.result.analyze.sopWarn.SopMonitorEnum;
|
|
|
+import com.qmth.sop.business.bean.result.analyze.sopWarn.SopWarnOverview;
|
|
|
import com.qmth.sop.business.entity.SysUser;
|
|
|
import com.qmth.sop.business.entity.TBService;
|
|
|
import com.qmth.sop.business.entity.TBSopInfo;
|
|
@@ -11,9 +16,12 @@ import com.qmth.sop.business.service.SysUserService;
|
|
|
import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
|
|
|
import com.qmth.sop.common.enums.SopAnalyseSortEnum;
|
|
|
import com.qmth.sop.common.util.ServletUtil;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -36,8 +44,9 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
|
* * ③完成进度:该大区/供应商派单的完成进度,按照派单已有完成SOP,且没有在执行的SOP认为是已完成的派单;
|
|
|
* * ④平均处理时限:该大区/供应商预警处理的平均时限。按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
|
|
|
*/
|
|
|
+ @Deprecated
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> overview(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>> result = new ArrayList<>();
|
|
|
if (group.equals(SopAnalyseGroupEnum.REGION)) {
|
|
@@ -58,6 +67,108 @@ public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopIn
|
|
|
return result.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("crmNum").toString()))).limit(3).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * * ①可按照大区/人力供应商进行切换如图;
|
|
|
+ * * ②按照派单数TOP3的大区、人力供应商显示;
|
|
|
+ * * ③完成进度:该大区/供应商派单的完成进度,按照派单已有完成SOP,且没有在执行的SOP认为是已完成的派单;
|
|
|
+ * * ④平均处理时限:该大区/供应商预警处理的平均时限。按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<SopWarnOverview> overview(Long serviceId, SopAnalyseGroupEnum group) {
|
|
|
+ List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
|
|
|
+ List<SopWarnOverview> result = new ArrayList<>();
|
|
|
+ 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().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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建sop监控统计
|
|
|
+ * @param dataCell 数据集
|
|
|
+ * @return sop监控
|
|
|
+ */
|
|
|
+ private SopWarnOverview buildSopOverviewStatistic(List<SopMonitor> dataCell) {
|
|
|
+ SopWarnOverview sopWarnOverview = new SopWarnOverview();
|
|
|
+ if (CollectionUtils.isNotEmpty(dataCell)) {
|
|
|
+ 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 effectAvgTimeCount = 0;
|
|
|
+ long effectTotalMinutes = 0L;
|
|
|
+ int violationNum = 0;
|
|
|
+ int finishViolationNum = 0;
|
|
|
+ int delayNum = 0;
|
|
|
+ int finishDelayNum = 0;
|
|
|
+
|
|
|
+ for (SopMonitor sopMonitor : dataCell) {
|
|
|
+ SopMonitorEnum sopMonitorType = sopMonitor.getSopMonitorType();
|
|
|
+ switch (sopMonitorType) {
|
|
|
+ case DELAY_WARN:
|
|
|
+ delayNum++;
|
|
|
+ break;
|
|
|
+ case VIOLATION:
|
|
|
+ violationNum++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Boolean finishStatus = sopMonitor.getFinishStatus();
|
|
|
+ if (finishStatus) {
|
|
|
+ Long startTime = sopMonitor.getStartTime();
|
|
|
+ Long closeTime = sopMonitor.getCloseTime();
|
|
|
+ if (startTime != null && startTime > 0 && closeTime != null && closeTime > 0) {
|
|
|
+ effectAvgTimeCount++;
|
|
|
+ long cellMinutes = DateUtil.between(new Date(startTime), new Date(closeTime), DateUnit.MINUTE);
|
|
|
+ effectTotalMinutes = effectTotalMinutes + cellMinutes;
|
|
|
+ }
|
|
|
+
|
|
|
+ switch (sopMonitorType) {
|
|
|
+ case DELAY_WARN:
|
|
|
+ finishDelayNum++;
|
|
|
+ break;
|
|
|
+ case VIOLATION:
|
|
|
+ finishViolationNum++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ sopWarnOverview.setCrmNum(crmNum);
|
|
|
+ sopWarnOverview.setFinishCrmNum(finishCrmNum);
|
|
|
+ BigDecimal avgMinutes = new BigDecimal(0);
|
|
|
+ if (effectAvgTimeCount > 0) {
|
|
|
+ avgMinutes = new BigDecimal(effectTotalMinutes).divide(new BigDecimal(effectAvgTimeCount), 2, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ sopWarnOverview.setAvgMinutes(avgMinutes);
|
|
|
+ sopWarnOverview.setViolationNum(violationNum);
|
|
|
+ sopWarnOverview.setFinishViolationNum(finishViolationNum);
|
|
|
+ sopWarnOverview.setDelayNum(delayNum);
|
|
|
+ sopWarnOverview.setFinishDelayNum(finishDelayNum);
|
|
|
+ }
|
|
|
+ return sopWarnOverview;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
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());
|