|
|
|
@ -2,15 +2,19 @@ package com.biutag.supervision.service.report; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.biutag.supervision.constants.enums.CheckStatusEnum; |
|
|
|
import com.biutag.supervision.constants.enums.CheckStatusEnum; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.domain.NegativeVo; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.dto.report.BusinessLineOverviewSection; |
|
|
|
import com.biutag.supervision.pojo.dto.report.OverviewSection; |
|
|
|
import com.biutag.supervision.pojo.dto.report.OverviewSection; |
|
|
|
import com.biutag.supervision.pojo.dto.report.ReportViewModel; |
|
|
|
import com.biutag.supervision.pojo.dto.report.ReportViewModel; |
|
|
|
import com.biutag.supervision.pojo.entity.NegativeBlame; |
|
|
|
import com.biutag.supervision.pojo.entity.NegativeBlame; |
|
|
|
import com.biutag.supervision.pojo.param.NegativeQueryParam; |
|
|
|
import com.biutag.supervision.pojo.param.NegativeQueryParam; |
|
|
|
import com.biutag.supervision.pojo.param.negativeBlame.NegativeBlameQueryParam; |
|
|
|
import com.biutag.supervision.pojo.param.negativeBlame.NegativeBlameQueryParam; |
|
|
|
|
|
|
|
import com.biutag.supervision.pojo.vo.DictProblemSourceTree; |
|
|
|
import com.biutag.supervision.pojo.vo.NegativeQueryVo; |
|
|
|
import com.biutag.supervision.pojo.vo.NegativeQueryVo; |
|
|
|
import com.biutag.supervision.repository.negative.NegativeResourceService; |
|
|
|
import com.biutag.supervision.repository.negative.NegativeResourceService; |
|
|
|
import com.biutag.supervision.repository.negativeBlame.NegativeBlameResourceService; |
|
|
|
import com.biutag.supervision.repository.negativeBlame.NegativeBlameResourceService; |
|
|
|
import com.biutag.supervision.service.NegativeQueryService; |
|
|
|
import com.biutag.supervision.service.NegativeQueryService; |
|
|
|
|
|
|
|
import com.biutag.supervision.service.SupDictProblemSourceService; |
|
|
|
import com.biutag.supervision.util.DateCompareRangeUtil; |
|
|
|
import com.biutag.supervision.util.DateCompareRangeUtil; |
|
|
|
import com.biutag.supervision.util.ReportTrendUtil; |
|
|
|
import com.biutag.supervision.util.ReportTrendUtil; |
|
|
|
import com.biutag.supervision.util.TimeUtil; |
|
|
|
import com.biutag.supervision.util.TimeUtil; |
|
|
|
@ -21,6 +25,7 @@ import java.math.BigDecimal; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
|
@ -35,6 +40,9 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private NegativeQueryService negativeQueryService; |
|
|
|
private NegativeQueryService negativeQueryService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private SupDictProblemSourceService supDictProblemSourceService; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ReportViewModel buildViewModel(NegativeQueryParam request) { |
|
|
|
public ReportViewModel buildViewModel(NegativeQueryParam request) { |
|
|
|
String periodStart = TimeUtil.formatDate(request.getCrtTime().get(0)); |
|
|
|
String periodStart = TimeUtil.formatDate(request.getCrtTime().get(0)); |
|
|
|
@ -43,10 +51,53 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
vm.setPeriodStart(periodStart); |
|
|
|
vm.setPeriodStart(periodStart); |
|
|
|
vm.setPeriodEnd(periodEnd); |
|
|
|
vm.setPeriodEnd(periodEnd); |
|
|
|
vm.setOverviewSection(buildOverviewSection(request, periodStart, periodEnd)); |
|
|
|
vm.setOverviewSection(buildOverviewSection(request, periodStart, periodEnd)); |
|
|
|
//
|
|
|
|
vm.setBusinessLineOverviewSection(buildbusinessLineOverviewSection(request, periodStart, periodEnd)); |
|
|
|
return vm; |
|
|
|
return vm; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 业务条线的总览 |
|
|
|
|
|
|
|
* @param request |
|
|
|
|
|
|
|
* @param periodStart |
|
|
|
|
|
|
|
* @param periodEnd |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private BusinessLineOverviewSection buildbusinessLineOverviewSection(NegativeQueryParam request, String periodStart, String periodEnd) { |
|
|
|
|
|
|
|
// 总体数据
|
|
|
|
|
|
|
|
NegativeQueryParam ztNegativeQueryParam = request.newQueryParam(); |
|
|
|
|
|
|
|
List<NegativeQueryVo> ztNegativeList = negativeQueryService.page(ztNegativeQueryParam).getRecords(); |
|
|
|
|
|
|
|
Map<String, DictProblemSourceTree> idMap = supDictProblemSourceService.buildIdMap(); |
|
|
|
|
|
|
|
// 计数
|
|
|
|
|
|
|
|
Map<String, Long> aggByParentLabel = ztNegativeList.stream() |
|
|
|
|
|
|
|
.map(NegativeQueryVo::getProblemSourcesCode) // 收集二级id
|
|
|
|
|
|
|
|
.map(childId -> parentLabel2Level(childId, idMap)) // 解析未一级label
|
|
|
|
|
|
|
|
.collect(Collectors.groupingBy(s -> s, Collectors.counting())); |
|
|
|
|
|
|
|
// 排序
|
|
|
|
|
|
|
|
List<Map.Entry<String, Long>> sorted = aggByParentLabel.entrySet().stream() |
|
|
|
|
|
|
|
.sorted((a, b) -> Long.compare(b.getValue(), a.getValue())) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
// 3)拼接总览文本(全部列出)
|
|
|
|
|
|
|
|
StringBuilder businessLineOverviewText = new StringBuilder(); |
|
|
|
|
|
|
|
for (int i = 0; i < sorted.size(); i++) { |
|
|
|
|
|
|
|
String label = sorted.get(i).getKey(); |
|
|
|
|
|
|
|
int cnt = Math.toIntExact(sorted.get(i).getValue()); |
|
|
|
|
|
|
|
businessLineOverviewText.append(i + 1) |
|
|
|
|
|
|
|
.append("、") |
|
|
|
|
|
|
|
.append(label) |
|
|
|
|
|
|
|
.append(",") |
|
|
|
|
|
|
|
.append(cnt) |
|
|
|
|
|
|
|
.append("条,占比") |
|
|
|
|
|
|
|
.append(ReportTrendUtil.percent(cnt, ztNegativeList.size())) |
|
|
|
|
|
|
|
.append("%;"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
BusinessLineOverviewSection businessLineOverviewSection = new BusinessLineOverviewSection(); |
|
|
|
|
|
|
|
businessLineOverviewSection.setPeriodStart(periodStart); |
|
|
|
|
|
|
|
businessLineOverviewSection.setPeriodEnd(periodEnd); |
|
|
|
|
|
|
|
businessLineOverviewSection.setBusinessLineTotal(ztNegativeList.size()); |
|
|
|
|
|
|
|
businessLineOverviewSection.setBusinessLineOverviewText(businessLineOverviewText.toString()); |
|
|
|
|
|
|
|
return businessLineOverviewSection; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 总体情况计算 |
|
|
|
* 总体情况计算 |
|
|
|
* |
|
|
|
* |
|
|
|
@ -59,13 +110,16 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
|
|
|
|
|
|
|
|
DateCompareRangeUtil.CompareDateRange compareDateRange = DateCompareRangeUtil.buildCompareDateRange(request.getCrtTime().get(0), request.getCrtTime().get(1)); |
|
|
|
DateCompareRangeUtil.CompareDateRange compareDateRange = DateCompareRangeUtil.buildCompareDateRange(request.getCrtTime().get(0), request.getCrtTime().get(1)); |
|
|
|
// 总体数据
|
|
|
|
// 总体数据
|
|
|
|
List<NegativeQueryVo> ztNegativeList = negativeQueryService.page(request).getRecords(); |
|
|
|
NegativeQueryParam ztnegativeQueryParam = request.newQueryParam(); |
|
|
|
|
|
|
|
List<NegativeQueryVo> ztNegativeList = negativeQueryService.page(ztnegativeQueryParam).getRecords(); |
|
|
|
// 环比数据
|
|
|
|
// 环比数据
|
|
|
|
request.setCrtTime(compareDateRange.mom()); |
|
|
|
NegativeQueryParam hbNegativeQueryParam = request.newQueryParam(); |
|
|
|
List<NegativeQueryVo> hbNegativList = negativeQueryService.page(request).getRecords(); |
|
|
|
hbNegativeQueryParam.setCrtTime(compareDateRange.mom()); |
|
|
|
|
|
|
|
List<NegativeQueryVo> hbNegativList = negativeQueryService.page(hbNegativeQueryParam).getRecords(); |
|
|
|
// 同比数据
|
|
|
|
// 同比数据
|
|
|
|
request.setCrtTime(compareDateRange.yoy()); |
|
|
|
NegativeQueryParam tbNegativeQueryParam = request.newQueryParam(); |
|
|
|
List<NegativeQueryVo> tbNegativList = negativeQueryService.page(request).getRecords(); |
|
|
|
tbNegativeQueryParam.setCrtTime(compareDateRange.yoy()); |
|
|
|
|
|
|
|
List<NegativeQueryVo> tbNegativList = negativeQueryService.page(tbNegativeQueryParam).getRecords(); |
|
|
|
// 市局下发数据
|
|
|
|
// 市局下发数据
|
|
|
|
List<NegativeQueryVo> sjxfNegativeList = ztNegativeList.stream().filter(one -> Objects.equals(0, one.getCrtDepartLevel())).toList(); |
|
|
|
List<NegativeQueryVo> sjxfNegativeList = ztNegativeList.stream().filter(one -> Objects.equals(0, one.getCrtDepartLevel())).toList(); |
|
|
|
// 分县市局下发数据
|
|
|
|
// 分县市局下发数据
|
|
|
|
@ -73,11 +127,11 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
// 办结数据
|
|
|
|
// 办结数据
|
|
|
|
List<NegativeQueryVo> bjNegativeList = ztNegativeList.stream().filter(one -> !Objects.isNull(one.getCompleteDate())).toList(); |
|
|
|
List<NegativeQueryVo> bjNegativeList = ztNegativeList.stream().filter(one -> !Objects.isNull(one.getCompleteDate())).toList(); |
|
|
|
// 办结中属实数据
|
|
|
|
// 办结中属实数据
|
|
|
|
List<NegativeQueryVo> bjssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.TRUE_LIST.contains(one.getCheckStatus())).toList(); |
|
|
|
List<NegativeQueryVo> bjssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.TRUE_SET.contains(one.getCheckStatus())).toList(); |
|
|
|
// 办结中基本属实数据
|
|
|
|
// 办结中基本属实数据
|
|
|
|
List<NegativeQueryVo> bjjbssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.PART_TRUE_LIST.contains(one.getCheckStatus())).toList(); |
|
|
|
List<NegativeQueryVo> bjjbssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.PART_TRUE_SET.contains(one.getCheckStatus())).toList(); |
|
|
|
// 办结中不属实数据
|
|
|
|
// 办结中不属实数据
|
|
|
|
List<NegativeQueryVo> bjbssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.FALSE_LIST.contains(one.getCheckStatus())).toList(); |
|
|
|
List<NegativeQueryVo> bjbssNegativeList = bjNegativeList.stream().filter(one -> CheckStatusEnum.FALSE_SET.contains(one.getCheckStatus())).toList(); |
|
|
|
// 属实 基本属实中的问责数据
|
|
|
|
// 属实 基本属实中的问责数据
|
|
|
|
List<String> ssNegativeIds = Stream.concat(bjssNegativeList.stream(), bjjbssNegativeList.stream()) |
|
|
|
List<String> ssNegativeIds = Stream.concat(bjssNegativeList.stream(), bjjbssNegativeList.stream()) |
|
|
|
.map(NegativeQueryVo::getId).filter(StrUtil::isNotBlank).distinct().toList(); |
|
|
|
.map(NegativeQueryVo::getId).filter(StrUtil::isNotBlank).distinct().toList(); |
|
|
|
@ -167,12 +221,12 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
|
|
|
|
|
|
|
|
// 属实
|
|
|
|
// 属实
|
|
|
|
int verified = (int) closed.stream() |
|
|
|
int verified = (int) closed.stream() |
|
|
|
.filter(n -> CheckStatusEnum.TRUE_LIST.contains(n.getCheckStatus())) |
|
|
|
.filter(n -> CheckStatusEnum.TRUE_SET.contains(n.getCheckStatus())) |
|
|
|
.count(); |
|
|
|
.count(); |
|
|
|
|
|
|
|
|
|
|
|
// 基本属实
|
|
|
|
// 基本属实
|
|
|
|
int partVerified = (int) closed.stream() |
|
|
|
int partVerified = (int) closed.stream() |
|
|
|
.filter(n -> CheckStatusEnum.PART_TRUE_LIST.contains(n.getCheckStatus())) |
|
|
|
.filter(n -> CheckStatusEnum.PART_TRUE_SET.contains(n.getCheckStatus())) |
|
|
|
.count(); |
|
|
|
.count(); |
|
|
|
|
|
|
|
|
|
|
|
// 查实率 = (属实 + 基本属实) / 办结
|
|
|
|
// 查实率 = (属实 + 基本属实) / 办结
|
|
|
|
@ -180,4 +234,18 @@ public class ReportDataServiceImpl implements ReportDataService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String parentLabel2Level(String childId, Map<String, DictProblemSourceTree> idMap) { |
|
|
|
|
|
|
|
if (StrUtil.isBlank(childId)) { |
|
|
|
|
|
|
|
return "未归类"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DictProblemSourceTree child = idMap.get(childId); |
|
|
|
|
|
|
|
if (child == null) { |
|
|
|
|
|
|
|
return "未归类"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DictProblemSourceTree parent = idMap.get(child.getParentId()); |
|
|
|
|
|
|
|
// 若 child 没父,说明 child 自己就是一级(兜底)
|
|
|
|
|
|
|
|
return parent != null ? StrUtil.blankToDefault(parent.getLabel(), "未归类") |
|
|
|
|
|
|
|
: StrUtil.blankToDefault(child.getLabel(), "未归类"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |