Browse Source

网格议题统计

master
zhaoqifeng 5 years ago
parent
commit
03b20e20b1
  1. 15
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  2. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java
  3. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java
  4. 140
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java

15
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java

@ -14,6 +14,7 @@ import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -347,4 +348,18 @@ public class DateUtils {
System.out.println(666);
}
/**
* 获取日期前一天
* @author zhaoqifeng
* @date 2020/6/22 11:08
* @param date
* @return java.util.Date
*/
public static Date getBeforeDay(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, -1);
return calendar.getTime();
}
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/StatsIssueController.java

@ -0,0 +1,33 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.StatsIssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/6/22 14:26
*/
@RequestMapping("statsissue")
@RestController
public class StatsIssueController {
@Autowired
private StatsIssueService statsIssueService;
/**
* 议题统计
* @author zhaoqifeng
* @date 2020/6/22 14:28
* @param
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("issuestats")
public Result agencyGridIssueStats() {
statsIssueService.agencyGridIssueStats();
return new Result();
}
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsIssueService.java

@ -8,6 +8,15 @@ import java.util.Date;
* @date 2020/6/17 16:51
*/
public interface StatsIssueService {
/**
* 机关和网格议题统计
* @author zhaoqifeng
* @date 2020/6/22 10:58
* @param
* @return void
*/
void agencyGridIssueStats();
/**
* 机关下议题日统计
* @author zhaoqifeng

140
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsIssueServiceImpl.java

@ -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));
}
}
/**

Loading…
Cancel
Save