|
|
@ -19,7 +19,9 @@ import com.epmet.service.project.ProjectService; |
|
|
|
import com.epmet.service.stats.*; |
|
|
|
import com.epmet.util.DimIdGenerator; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
@ -33,6 +35,8 @@ import java.util.stream.Collectors; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
@Autowired |
|
|
|
private DimCustomerService dimCustomerService; |
|
|
|
@Autowired |
|
|
|
private IssueService issueService; |
|
|
|
@Autowired |
|
|
@ -46,8 +50,47 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
@Autowired |
|
|
|
private FactIssueAgencyMonthlyService factIssueAgencyMonthlyService; |
|
|
|
@Autowired |
|
|
|
private FactIssueGridDailyService factIssueGridDailyService; |
|
|
|
@Autowired |
|
|
|
private FactIssueGridMonthlyService factIssueGridMonthlyService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void agencyGridIssueStats() { |
|
|
|
int pageNo = 1; |
|
|
|
int pageSize = 100; |
|
|
|
List<String> customerIdList = null; |
|
|
|
do { |
|
|
|
customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); |
|
|
|
if (!CollectionUtils.isEmpty(customerIdList)) { |
|
|
|
for (String customerId : customerIdList) { |
|
|
|
//遍历统计每一个客户数据
|
|
|
|
customerStats(customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
} while (!CollectionUtils.isEmpty(customerIdList) && customerIdList.size() == pageSize); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 一个客户一个线程, 分别统计机关日/月数据和网格日/月数据 |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/6/22 11:03 |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
@Async |
|
|
|
public void customerStats(String customerId) { |
|
|
|
//获取当前日期前一天
|
|
|
|
Date date = DateUtils.getBeforeDay(new Date()); |
|
|
|
//机关议题日统计
|
|
|
|
saveIssueAgencyDaily(customerId, date); |
|
|
|
//机关议题月统计
|
|
|
|
saveIssueAgencyMonthly(customerId, date); |
|
|
|
//网格议题日统计
|
|
|
|
saveIssueGridDaily(customerId, date); |
|
|
|
//网格议题月统计
|
|
|
|
saveIssueGridMonthly(customerId, date); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void saveIssueAgencyDaily(String customerId, Date date) { |
|
|
|
String dateString = DateUtils.format(date); |
|
|
@ -216,9 +259,13 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
totalList.stream().collect(Collectors.groupingBy(IssueProjectDTO::getStatus)); |
|
|
|
List<IssueProjectDTO> resolveList = totalMap.get(IssueConstant.RESLOVED); |
|
|
|
List<IssueProjectDTO> unResolveList = totalMap.get(IssueConstant.UNRESLOVED); |
|
|
|
resolveMap = resolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
unResolveMap = unResolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
if (null != resolveList) { |
|
|
|
resolveMap = resolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
} |
|
|
|
if (null != unResolveList) { |
|
|
|
unResolveMap = unResolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
} |
|
|
|
List<IssueProjectDTO> incList = issueProjectList.stream().flatMap(ip -> |
|
|
|
closedProjectIncList.stream().filter(closed -> ip.getIssueId().equals(closed.getIssueId())).map(project -> { |
|
|
|
IssueProjectDTO dto = new IssueProjectDTO(); |
|
|
@ -232,9 +279,13 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
incList.stream().collect(Collectors.groupingBy(IssueProjectDTO::getStatus)); |
|
|
|
List<IssueProjectDTO> resolveIncList = incMap.get(IssueConstant.RESLOVED); |
|
|
|
List<IssueProjectDTO> unResolveIncList = incMap.get(IssueConstant.UNRESLOVED); |
|
|
|
resolveIncMap = resolveIncList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
unResolveIncMap = unResolveIncList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
if (null != resolveIncList) { |
|
|
|
resolveIncMap = resolveIncList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
} |
|
|
|
if (null != unResolveIncList) { |
|
|
|
unResolveIncMap = unResolveIncList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<FactIssueGridDailyEntity> list = new ArrayList<>(); |
|
|
@ -242,7 +293,8 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
for (DimGridEntity grid : gridList) { |
|
|
|
FactIssueGridDailyEntity entity = initIssueGridDaily(dimId); |
|
|
|
entity.setCustomerId(grid.getCustomerId()); |
|
|
|
entity.setAgencyId(grid.getId()); |
|
|
|
entity.setAgencyId(grid.getAgencyId()); |
|
|
|
entity.setGridId(grid.getId()); |
|
|
|
//总量统计
|
|
|
|
saveGridTotal(gridTotalList, grid, entity); |
|
|
|
//增量统计
|
|
|
@ -259,8 +311,9 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
} |
|
|
|
//已关闭项目已解决未解决统计
|
|
|
|
saveClosedProject(resolveMap, unResolveMap, resolveIncMap, unResolveIncMap, grid, entity); |
|
|
|
list.add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
factIssueGridDailyService.insertBatch(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -298,9 +351,13 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
totalList.stream().collect(Collectors.groupingBy(IssueProjectDTO::getStatus)); |
|
|
|
List<IssueProjectDTO> resolveList = totalMap.get(IssueConstant.RESLOVED); |
|
|
|
List<IssueProjectDTO> unResolveList = totalMap.get(IssueConstant.UNRESLOVED); |
|
|
|
resolveMap = resolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
unResolveMap = unResolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
if (null != resolveList) { |
|
|
|
resolveMap = resolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, Collectors.counting())); |
|
|
|
} |
|
|
|
if (null != unResolveList) { |
|
|
|
unResolveMap = unResolveList.stream().collect(Collectors.groupingBy(IssueProjectDTO:: getGridId, |
|
|
|
Collectors.counting())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<FactIssueGridMonthlyEntity> list = new ArrayList<>(); |
|
|
@ -325,12 +382,14 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
monthly.setClosedCaseTotal(total); |
|
|
|
monthly.setClosedCaseResolvedTotal(resolve); |
|
|
|
monthly.setClosedCaseUnresolvedTotal(unResolve); |
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolve); |
|
|
|
BigDecimal unresolved = new BigDecimal(unResolve); |
|
|
|
BigDecimal closed = new BigDecimal(total); |
|
|
|
monthly.setClosedCaseResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
monthly.setClosedCaseUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
if(total > NumConstant.ZERO) { |
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolve); |
|
|
|
BigDecimal unresolved = new BigDecimal(unResolve); |
|
|
|
BigDecimal closed = new BigDecimal(total); |
|
|
|
monthly.setClosedCaseResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
monthly.setClosedCaseUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
|
|
|
|
//各指标增量统计
|
|
|
|
for (int i = 0; i < gridMonthlyIncListList.size(); i++) { |
|
|
@ -350,7 +409,7 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
} |
|
|
|
|
|
|
|
monthly.setCustomerId(grid.getCustomerId()); |
|
|
|
monthly.setAgencyId(grid.getId()); |
|
|
|
monthly.setAgencyId(grid.getAgencyId()); |
|
|
|
monthly.setGridId(grid.getId()); |
|
|
|
list.add(monthly); |
|
|
|
} |
|
|
@ -383,13 +442,14 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
entity.setClosedCaseIncr(inc); |
|
|
|
entity.setClosedCaseResolvedIncr(resolveInc); |
|
|
|
entity.setClosedCaseUnresolvedIncr(unResolveInc); |
|
|
|
|
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolve); |
|
|
|
BigDecimal unresolved = new BigDecimal(unResolve); |
|
|
|
BigDecimal closed = new BigDecimal(total); |
|
|
|
entity.setClosedCaseResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedCaseUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
if(total != NumConstant.ZERO) { |
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolve); |
|
|
|
BigDecimal unresolved = new BigDecimal(unResolve); |
|
|
|
BigDecimal closed = new BigDecimal(total); |
|
|
|
entity.setClosedCaseResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedCaseUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -452,13 +512,14 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
} |
|
|
|
entity.setClosedResolvedTotal(resolvedCount); |
|
|
|
entity.setClosedUnresolvedTotal(unresolvedCount); |
|
|
|
|
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolvedCount); |
|
|
|
BigDecimal unresolved = new BigDecimal(unresolvedCount); |
|
|
|
BigDecimal closed = new BigDecimal(entity.getClosedTotal()); |
|
|
|
entity.setClosedResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
if(entity.getClosedTotal() > NumConstant.ZERO) { |
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolvedCount); |
|
|
|
BigDecimal unresolved = new BigDecimal(unresolvedCount); |
|
|
|
BigDecimal closed = new BigDecimal(entity.getClosedTotal()); |
|
|
|
entity.setClosedResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -744,13 +805,14 @@ public class StatsIssueServiceImpl implements StatsIssueService { |
|
|
|
} |
|
|
|
entity.setClosedResolvedTotal(resolvedCount); |
|
|
|
entity.setClosedUnresolvedTotal(unresolvedCount); |
|
|
|
|
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolvedCount); |
|
|
|
BigDecimal unresolved = new BigDecimal(unresolvedCount); |
|
|
|
BigDecimal closed = new BigDecimal(entity.getClosedTotal()); |
|
|
|
entity.setClosedResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
if (entity.getClosedTotal() > NumConstant.ZERO) { |
|
|
|
BigDecimal hundred = new BigDecimal(NumConstant.ONE_HUNDRED); |
|
|
|
BigDecimal resolved = new BigDecimal(resolvedCount); |
|
|
|
BigDecimal unresolved = new BigDecimal(unresolvedCount); |
|
|
|
BigDecimal closed = new BigDecimal(entity.getClosedTotal()); |
|
|
|
entity.setClosedResolvedPercent(resolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
entity.setClosedUnresolvedPercent(unresolved.multiply(hundred).divide(closed, NumConstant.TWO, RoundingMode.HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|