|
|
|
@ -4,23 +4,20 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.dto.project.form.MonthProjectListFormDTO; |
|
|
|
import com.epmet.dto.stats.DimAgencyDTO; |
|
|
|
import com.epmet.dto.stats.DimDateDTO; |
|
|
|
import com.epmet.dto.stats.DimGridDTO; |
|
|
|
import com.epmet.entity.issue.IssueEntity; |
|
|
|
import com.epmet.entity.project.ProjectEntity; |
|
|
|
import com.epmet.entity.project.ProjectProcessEntity; |
|
|
|
import com.epmet.entity.stats.DimDateEntity; |
|
|
|
import com.epmet.entity.stats.DimGridEntity; |
|
|
|
import com.epmet.entity.stats.FactAgencyProjectDailyEntity; |
|
|
|
import com.epmet.entity.stats.FactAgencyProjectMonthlyEntity; |
|
|
|
import com.epmet.entity.stats.*; |
|
|
|
import com.epmet.service.Issue.IssueService; |
|
|
|
import com.epmet.service.StatsProjectService; |
|
|
|
import com.epmet.service.project.ProjectProcessService; |
|
|
|
import com.epmet.service.project.ProjectService; |
|
|
|
import com.epmet.service.stats.*; |
|
|
|
import com.epmet.util.DimIdGenerator; |
|
|
|
import oracle.sql.NUMBER; |
|
|
|
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.text.DateFormat; |
|
|
|
@ -37,25 +34,19 @@ import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
@Service |
|
|
|
public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DimCustomerService dimCustomerService; |
|
|
|
@Autowired |
|
|
|
private DimAgencyService dimAgencyService; |
|
|
|
@Autowired |
|
|
|
private DimGridService dimGridService; |
|
|
|
@Autowired |
|
|
|
private DimDateService dimDateService; |
|
|
|
@Autowired |
|
|
|
private DimWeekService dimWeekService; |
|
|
|
@Autowired |
|
|
|
private DimMonthService dimMonthService; |
|
|
|
@Autowired |
|
|
|
private DimQuarterService dimQuarterService; |
|
|
|
@Autowired |
|
|
|
private DimYearService dimYearService; |
|
|
|
@Autowired |
|
|
|
private ProjectService projectService; |
|
|
|
@Autowired |
|
|
|
private ProjectProcessService projectProcessService; |
|
|
|
@Autowired |
|
|
|
private IssueService issueService; |
|
|
|
@Autowired |
|
|
|
private FactAgencyProjectDailyService factAgencyProjectDailyService; |
|
|
|
@Autowired |
|
|
|
private FactAgencyProjectMonthlyService factAgencyProjectMonthlyService; |
|
|
|
@ -65,27 +56,75 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
private FactGridProjectMonthlyService factGridProjectMonthlyService; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关日(月)统计 |
|
|
|
* @Description 数据-项目-机关、网格日(月)统计 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void statsAgencyProject(String customerId) { |
|
|
|
//1:根据客户Id查询机关维度表数据
|
|
|
|
public void agencyGridProjectStats() { |
|
|
|
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 sun |
|
|
|
* @Description 一个客户一个线程, 分别统计机关/网格日/月数据 |
|
|
|
**/ |
|
|
|
@Async |
|
|
|
public void customerStats(String customerId) { |
|
|
|
Date date = new Date(); |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(date); |
|
|
|
|
|
|
|
//2:根据客户Id查询机关维度表数据
|
|
|
|
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO(); |
|
|
|
dimAgencyDTO.setCustomerId(customerId); |
|
|
|
List<DimAgencyDTO> dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); |
|
|
|
|
|
|
|
//3:根据客户Id查询网格维度表数据
|
|
|
|
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
|
|
|
|
//4:根据客户Id查询项目业务表已结案数据(查询传入日期及之前的数据)
|
|
|
|
ProjectEntity projectEntity = new ProjectEntity(); |
|
|
|
projectEntity.setCustomerId(customerId); |
|
|
|
projectEntity.setCreatedTime(date); |
|
|
|
projectEntity.setStatus(ProjectConstant.CLOSED); |
|
|
|
List<ProjectEntity> projectList = projectService.getProjectList(projectEntity); |
|
|
|
|
|
|
|
//5:查询项目处理进展表中有效数据(创建日期截取yyyy-mm-dd格式字段值)(查询传入日期及之前的数据)
|
|
|
|
List<ProjectProcessEntity> processList = projectProcessService.getProcessList(projectEntity); |
|
|
|
|
|
|
|
//6:机关层级日月统计
|
|
|
|
if (null != dimAgencyList && dimAgencyList.size() > NumConstant.ZERO) { |
|
|
|
//2:执行机关日数据统计
|
|
|
|
agencyDateProjectStats(customerId, dimAgencyList); |
|
|
|
//6.1:执行机关日数据统计
|
|
|
|
agencyDateProjectStats(customerId, dimId, dimAgencyList, projectList, processList); |
|
|
|
|
|
|
|
//6.2:执行机关月数据统计
|
|
|
|
if (Calendar.getInstance().get(Calendar.DATE) == 1) { |
|
|
|
agencyMonthProjectStats(customerId, dimId, dimAgencyList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//7:网格层级日月统计
|
|
|
|
if (null != dimGridList && dimGridList.size() > NumConstant.ZERO) { |
|
|
|
//7.1:执行网格日数据统计
|
|
|
|
gridDateProjectStats(customerId, dimId, dimGridList, projectList, processList); |
|
|
|
|
|
|
|
//3:执行机关月数据统计
|
|
|
|
//7.2:执行网格月数据统计
|
|
|
|
if (Calendar.getInstance().get(Calendar.DATE) == 1) { |
|
|
|
agencyMonthProjectStats(customerId, dimAgencyList); |
|
|
|
gridMonthProjectStats(customerId, dimId, dimGridList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -93,31 +132,18 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关日统计 |
|
|
|
**/ |
|
|
|
private String agencyDateProjectStats(String customerId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
private String agencyDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimAgencyDTO> dimAgencyList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(yesterDay()); |
|
|
|
|
|
|
|
//2:根据客户Id查询项目业务表已结案数据(查询当前日期之前的数据不包含当天的)
|
|
|
|
ProjectEntity projectEntity = new ProjectEntity(); |
|
|
|
projectEntity.setCustomerId(customerId); |
|
|
|
projectEntity.setCreatedTime(yesterDay()); |
|
|
|
projectEntity.setStatus(ProjectConstant.CLOSED); |
|
|
|
List<ProjectEntity> projectList = projectService.getProjectList(projectEntity); |
|
|
|
|
|
|
|
//3:查询项目处理进展表中有效数据(创建日期截取yyyy-mm-dd格式字段值)(查询当前日期之前的数据不包含当天的)
|
|
|
|
List<ProjectProcessEntity> processList = projectProcessService.getProcessList(projectEntity); |
|
|
|
|
|
|
|
//4:遍历统计每个机关各项指标数
|
|
|
|
//批量机关日统计新增对象
|
|
|
|
List<FactAgencyProjectDailyEntity> dimDateEntityList = new ArrayList<>(); |
|
|
|
List<FactAgencyProjectDailyEntity> projectDateEntityList = new ArrayList<>(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
|
NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
|
numberFormat.setMaximumFractionDigits(2); |
|
|
|
//遍历机关维度数据
|
|
|
|
|
|
|
|
//1:遍历机关维度数据,统计每个机关各项指标数
|
|
|
|
for (DimAgencyDTO agency : dimAgencyList) { |
|
|
|
//存放当前机关及所有下级机关Id
|
|
|
|
Map map = new HashMap<>(); |
|
|
|
//1.1:存放当前机关及所有下级机关Id
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
map.put(agency.getId(), agency.getId()); |
|
|
|
String subPids = ((null == agency.getPids() || "".equals(agency.getPids())) ? agency.getId() : agency.getPids() + ":" + agency.getId()); |
|
|
|
dimAgencyList.forEach(sub -> { |
|
|
|
@ -125,21 +151,21 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
map.put(sub.getId(), sub.getId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
//机关下截止当前日期的项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
//机关下截止当前日期的项目总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
AtomicInteger projectTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger closedTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger resolvedTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger unResolvedTotal = new AtomicInteger(0); |
|
|
|
//日增量中项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
//日增量中项目总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
AtomicInteger projectIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger closedIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger resolvedIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger unResolvedIncr = new AtomicInteger(0); |
|
|
|
//存放已结案项目Id,用于统计已结案中已解决未解决数
|
|
|
|
//存放已结案项目Id,用于统计已结案中已解决、未解决数
|
|
|
|
Map<String, String> closeMap = new HashMap<>(); |
|
|
|
//存放前一日已结案项目Id,用于统计日增量中已结案项目的已解决、未解决数量
|
|
|
|
Map<String, String> closeDateMap = new HashMap<>(); |
|
|
|
//遍历进展数据,统计截止当日的项目总量、处理中总量、已结案总量以及日增量中的项目总量、处理中总量、已结案总量
|
|
|
|
//1.2:遍历进展数据,统计截止当日的项目总量、处理中总量、已结案总量以及日增量中的项目总量、处理中总量、已结案总量
|
|
|
|
processList.forEach(process -> { |
|
|
|
//当前机关及下级
|
|
|
|
if (map.containsKey(process.getAgencyId())) { |
|
|
|
@ -163,7 +189,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//遍历项目业务数据,统计截止当日的已结案已解决总量、已结案未解决总量以及日增量中的已结案已解决总量、已结案未解决总量
|
|
|
|
//1.3:遍历项目业务数据,统计截止当日的已结案已解决总量、已结案未解决总量以及日增量中的已结案已解决总量、已结案未解决总量
|
|
|
|
projectList.forEach(project -> { |
|
|
|
//当前机关及下级
|
|
|
|
if (map.containsKey(project.getAgencyId())) { |
|
|
|
@ -190,7 +216,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//封装日数据对象
|
|
|
|
//1.4:封装机关日数据对象
|
|
|
|
FactAgencyProjectDailyEntity agencyDailyEntity = new FactAgencyProjectDailyEntity(); |
|
|
|
agencyDailyEntity.setCustomerId(customerId); |
|
|
|
agencyDailyEntity.setAgencyId(agency.getId()); |
|
|
|
@ -198,6 +224,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
agencyDailyEntity.setDateId(dimId.getDateId()); |
|
|
|
agencyDailyEntity.setWeekId(dimId.getWeekId()); |
|
|
|
agencyDailyEntity.setMonthId(dimId.getMonthId()); |
|
|
|
agencyDailyEntity.setQuarterId(dimId.getQuarterId()); |
|
|
|
agencyDailyEntity.setYearId(dimId.getYearId()); |
|
|
|
agencyDailyEntity.setProjectTotal(projectTotal.intValue()); |
|
|
|
agencyDailyEntity.setPendingTotal(projectTotal.intValue() - closedTotal.intValue()); |
|
|
|
@ -218,20 +245,21 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
agencyDailyEntity.setResolvedIncr(resolvedIncr.intValue()); |
|
|
|
agencyDailyEntity.setUnresolvedIncr(unResolvedIncr.intValue()); |
|
|
|
|
|
|
|
dimDateEntityList.add(agencyDailyEntity); |
|
|
|
projectDateEntityList.add(agencyDailyEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//先删后增
|
|
|
|
if (null != dimDateEntityList && dimDateEntityList.size() > NumConstant.ZERO) { |
|
|
|
//5:根据客户Id、日维度Id批量物理删除一下可能存在的历史数据
|
|
|
|
//2:批量保存数据,先删后增
|
|
|
|
if (null != projectDateEntityList && projectDateEntityList.size() > NumConstant.ZERO) { |
|
|
|
//2.1:根据客户Id、日维度Id批量物理删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectDailyEntity delEntity = new FactAgencyProjectDailyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setDateId(dimId.getDateId()); |
|
|
|
factAgencyProjectDailyService.delDateProject(delEntity); |
|
|
|
|
|
|
|
//6:批量保存机关日统计数据
|
|
|
|
factAgencyProjectDailyService.insertBatch(dimDateEntityList); |
|
|
|
//2.2:批量保存机关日统计数据
|
|
|
|
factAgencyProjectDailyService.insertBatch(projectDateEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@ -240,37 +268,36 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关月统计 |
|
|
|
**/ |
|
|
|
private String agencyMonthProjectStats(String customerId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
//1:获取个维度Id方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(yesterDay()); |
|
|
|
private String agencyMonthProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//批量月数据新增对象
|
|
|
|
List<FactAgencyProjectMonthlyEntity> monthlyEntityList = new ArrayList<>(); |
|
|
|
|
|
|
|
//2:获取昨天日期所在月份的起始日期和结束日期
|
|
|
|
//1:获取昨天日期所在月份的起始日期和结束日期
|
|
|
|
MonthProjectListFormDTO formDTO = new MonthProjectListFormDTO(); |
|
|
|
formDTO.setCustomerId(customerId); |
|
|
|
formDTO.setStartTime(getMonthBegin(yesterDay())); |
|
|
|
formDTO.setEndTime(getMonthEnd(yesterDay())); |
|
|
|
formDTO.setStartTime(getMonthBegin(date)); |
|
|
|
formDTO.setEndTime(getMonthEnd(date)); |
|
|
|
|
|
|
|
//批量月数据新增对象
|
|
|
|
List<FactAgencyProjectMonthlyEntity> monthlyEntityList = new ArrayList<>(); |
|
|
|
//3:遍历机关维度数据,分别统计每个组织月数据
|
|
|
|
//2:遍历机关维度数据,分别统计每个组织月数据
|
|
|
|
for (DimAgencyDTO agency : dimAgencyList) { |
|
|
|
//4:查询上一月机关日统计数据,按时间倒序
|
|
|
|
//2.1:查询上一月机关日统计数据,按时间倒序
|
|
|
|
formDTO.setAgencyId(agency.getId()); |
|
|
|
List<FactAgencyProjectDailyEntity> projectDailyList = factAgencyProjectDailyService.getMonthProjectList(formDTO); |
|
|
|
|
|
|
|
//5:汇总统计上一月机关月统计数据
|
|
|
|
//2.2:汇总统计上一月机关月统计数据
|
|
|
|
//月增量中项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
int pendingIncr = 0; |
|
|
|
int closedIncr = 0; |
|
|
|
int resolvedIncr = 0; |
|
|
|
int unResolvedIncr = 0; |
|
|
|
for (FactAgencyProjectDailyEntity date : projectDailyList) { |
|
|
|
pendingIncr += date.getPendingIncr(); |
|
|
|
closedIncr += date.getClosedIncr(); |
|
|
|
resolvedIncr += date.getResolvedIncr(); |
|
|
|
unResolvedIncr += date.getUnresolvedIncr(); |
|
|
|
for (FactAgencyProjectDailyEntity daily : projectDailyList) { |
|
|
|
pendingIncr += daily.getPendingIncr(); |
|
|
|
closedIncr += daily.getClosedIncr(); |
|
|
|
resolvedIncr += daily.getResolvedIncr(); |
|
|
|
unResolvedIncr += daily.getUnresolvedIncr(); |
|
|
|
} |
|
|
|
//6:实体字段属性赋值
|
|
|
|
//2.3:实体字段属性赋值
|
|
|
|
FactAgencyProjectMonthlyEntity monthlyEntity = new FactAgencyProjectMonthlyEntity(); |
|
|
|
monthlyEntity.setCustomerId(customerId); |
|
|
|
monthlyEntity.setAgencyId(agency.getId()); |
|
|
|
@ -299,65 +326,155 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
monthlyEntityList.add(monthlyEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//3:批量新增数据,先删后增
|
|
|
|
if (null != monthlyEntityList && monthlyEntityList.size() > NumConstant.ZERO) { |
|
|
|
//7:根据客户Id、月份Id批量删除一下可能存在的历史数据
|
|
|
|
//3.1:根据客户Id、月份Id批量删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectMonthlyEntity delEntity = new FactAgencyProjectMonthlyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setMonthId(dimId.getMonthId()); |
|
|
|
factAgencyProjectMonthlyService.delMonthProject(delEntity); |
|
|
|
|
|
|
|
//8:批量保存机关月统计数据
|
|
|
|
//3.2:批量保存机关月统计数据
|
|
|
|
factAgencyProjectMonthlyService.insertBatch(monthlyEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-网格日(月)统计 |
|
|
|
* @Description 数据-项目-网格日统计 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void statsGridProject(String customerId) { |
|
|
|
//1:根据客户Id查询网格维度表数据
|
|
|
|
List<DimGridEntity> dimGridList = dimGridService.getGridListByCustomerId(customerId); |
|
|
|
private String gridDateProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimGridEntity> dimGridList, List<ProjectEntity> projectList, List<ProjectProcessEntity> processList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//批量网格日统计新增对象
|
|
|
|
List<FactGridProjectDailyEntity> gridDateEntityList = new ArrayList<>(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
|
NumberFormat numberFormat = NumberFormat.getInstance(); |
|
|
|
numberFormat.setMaximumFractionDigits(2); |
|
|
|
|
|
|
|
if (null != dimGridList && dimGridList.size() > NumConstant.ZERO) { |
|
|
|
//2:执行机关日数据统计
|
|
|
|
gridDateProjectStats(customerId, dimGridList); |
|
|
|
//1:根据客户Id查询议题库已转项目的网格项目关系数据
|
|
|
|
List<IssueEntity> gridProjectList = issueService.getGridProjectList(customerId); |
|
|
|
|
|
|
|
//3:执行机关月数据统计
|
|
|
|
if (Calendar.getInstance().get(Calendar.DATE) == 1) { |
|
|
|
gridMonthProjectStats(customerId, dimGridList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//2:遍历网格维度数据,统计每个网格各项指标数据
|
|
|
|
for (DimGridEntity grid : dimGridList) { |
|
|
|
//2.1:存放网格下的项目Id
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
gridProjectList.forEach(gridProject -> { |
|
|
|
if (grid.getId().equals(gridProject.getGridId())) { |
|
|
|
map.put(gridProject.getProjectId(), gridProject.getGridId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
//网格下截止当前日期的项目总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
AtomicInteger projectTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger closedTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger resolvedTotal = new AtomicInteger(0); |
|
|
|
AtomicInteger unResolvedTotal = new AtomicInteger(0); |
|
|
|
//网格日增量中项目总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
AtomicInteger projectIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger closedIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger resolvedIncr = new AtomicInteger(0); |
|
|
|
AtomicInteger unResolvedIncr = new AtomicInteger(0); |
|
|
|
//存放已结案项目Id,用于统计已结案中已解决、未解决数
|
|
|
|
Map<String, String> closeMap = new HashMap<>(); |
|
|
|
//存放前一日已结案项目Id,用于统计日增量中已结案项目的已解决、未解决数量
|
|
|
|
Map<String, String> closeDateMap = new HashMap<>(); |
|
|
|
//2.2:遍历进展数据,统计截止当日的项目总量、处理中总量、已结案总量以及日增量中的项目总量、处理中总量、已结案总量
|
|
|
|
//截止当日项目总数
|
|
|
|
projectTotal.addAndGet(map.size()); |
|
|
|
processList.forEach(process -> { |
|
|
|
//是网格下的项目,且是已结案的
|
|
|
|
if (map.containsKey(process.getProjectId())) { |
|
|
|
//进展表中是创建项目状态的数据总数即为该网格下项目总数
|
|
|
|
if (ProjectConstant.CREATED.equals(process.getOperation()) && date.equals(process.getCreatedTime())) { |
|
|
|
//日增量总数
|
|
|
|
projectIncr.addAndGet(1); |
|
|
|
} |
|
|
|
if (ProjectConstant.CLOSE.equals(process.getOperation())) { |
|
|
|
//截止当日的已结案总数
|
|
|
|
closedTotal.addAndGet(1); |
|
|
|
closeMap.put(process.getProjectId(), process.getProjectId()); |
|
|
|
if (date.equals(process.getCreatedTime())) { |
|
|
|
//日增量中已结案总数
|
|
|
|
closedIncr.addAndGet(1); |
|
|
|
closeDateMap.put(process.getProjectId(), process.getProjectId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//2.3:遍历项目业务数据,统计截止当日的已结案已解决总量、已结案未解决总量以及日增量中的已结案已解决总量、已结案未解决总量
|
|
|
|
projectList.forEach(project -> { |
|
|
|
//当前机关及下级
|
|
|
|
if (map.containsKey(project.getId())) { |
|
|
|
if (closeMap.containsKey(project.getId())) { |
|
|
|
//已结案已解决
|
|
|
|
if (ProjectConstant.RESOLVED.equals(project.getClosedStatus())) { |
|
|
|
//截止当日的已结案已解决总量
|
|
|
|
resolvedTotal.addAndGet(1); |
|
|
|
if (closeDateMap.containsKey(project.getId())) { |
|
|
|
//日增量中的已结案已解决总量
|
|
|
|
resolvedIncr.addAndGet(1); |
|
|
|
} |
|
|
|
} |
|
|
|
//已结案未解决
|
|
|
|
if (ProjectConstant.UNRESOLVED.equals(project.getClosedStatus())) { |
|
|
|
//截止当日的已结案未解决总量
|
|
|
|
unResolvedTotal.addAndGet(1); |
|
|
|
if (closeDateMap.containsKey(project.getId())) { |
|
|
|
//日增量中的已结案未解决总量
|
|
|
|
unResolvedIncr.addAndGet(1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
* @param customerId |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-网格日统计 |
|
|
|
**/ |
|
|
|
private String gridDateProjectStats(String customerId, List<DimGridEntity> dimGridList) { |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(yesterDay()); |
|
|
|
//2.4:封装日数据对象
|
|
|
|
FactGridProjectDailyEntity gridDailyEntity = new FactGridProjectDailyEntity(); |
|
|
|
gridDailyEntity.setCustomerId(customerId); |
|
|
|
gridDailyEntity.setAgencyId(grid.getAgencyId()); |
|
|
|
gridDailyEntity.setGridId(grid.getId()); |
|
|
|
gridDailyEntity.setDateId(dimId.getDateId()); |
|
|
|
gridDailyEntity.setWeekId(dimId.getWeekId()); |
|
|
|
gridDailyEntity.setMonthId(dimId.getMonthId()); |
|
|
|
gridDailyEntity.setQuarterId(dimId.getQuarterId()); |
|
|
|
gridDailyEntity.setYearId(dimId.getYearId()); |
|
|
|
gridDailyEntity.setProjectTotal(projectTotal.intValue()); |
|
|
|
gridDailyEntity.setPendingTotal(projectTotal.intValue() - closedTotal.intValue()); |
|
|
|
gridDailyEntity.setClosedTotal(closedTotal.intValue()); |
|
|
|
gridDailyEntity.setResolvedTotal(resolvedTotal.intValue()); |
|
|
|
gridDailyEntity.setUnresolvedTotal(unResolvedTotal.intValue()); |
|
|
|
if (projectTotal.intValue() > NumConstant.ZERO) { |
|
|
|
gridDailyEntity.setPendingRatio(new BigDecimal(numberFormat.format((float) gridDailyEntity.getPendingTotal() / (float) projectTotal.intValue() * 100))); |
|
|
|
gridDailyEntity.setClosedRatio(new BigDecimal(numberFormat.format((float) closedTotal.intValue() / (float) projectTotal.intValue() * 100))); |
|
|
|
} |
|
|
|
if (closedTotal.intValue() > NumConstant.ZERO) { |
|
|
|
gridDailyEntity.setResolvedRatio(new BigDecimal(numberFormat.format((float) resolvedTotal.intValue() / (float) closedTotal.intValue() * 100))); |
|
|
|
gridDailyEntity.setUnresolvedRatio(new BigDecimal(numberFormat.format((float) unResolvedTotal.intValue() / (float) closedTotal.intValue() * 100))); |
|
|
|
} |
|
|
|
gridDailyEntity.setProjectIncr(projectIncr.intValue()); |
|
|
|
gridDailyEntity.setPendingIncr(projectIncr.intValue() - closedIncr.intValue()); |
|
|
|
gridDailyEntity.setClosedIncr(closedIncr.intValue()); |
|
|
|
gridDailyEntity.setResolvedIncr(resolvedIncr.intValue()); |
|
|
|
gridDailyEntity.setUnresolvedIncr(unResolvedIncr.intValue()); |
|
|
|
|
|
|
|
//2:根据客户Id查询项目业务表已结案数据(查询当前日期之前的数据不包含当天的)
|
|
|
|
ProjectEntity projectEntity = new ProjectEntity(); |
|
|
|
projectEntity.setCustomerId(customerId); |
|
|
|
projectEntity.setCreatedTime(yesterDay()); |
|
|
|
List<ProjectEntity> projectList = projectService.getProjectList(projectEntity); |
|
|
|
gridDateEntityList.add(gridDailyEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//3:查询项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)(查询当前日期之前的数据不包含当天的)
|
|
|
|
List<ProjectProcessEntity> processList = projectProcessService.getProcessList(projectEntity); |
|
|
|
//3:批量新增数据,先删后增
|
|
|
|
if (null != gridDateEntityList && gridDateEntityList.size() > NumConstant.ZERO) { |
|
|
|
//3.1:根据客户Id、日维度Id批量物理删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectDailyEntity delEntity = new FactAgencyProjectDailyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setDateId(dimId.getDateId()); |
|
|
|
factGridProjectDailyService.delDateProject(delEntity); |
|
|
|
|
|
|
|
//4:根据客户Id查询议题表已转项目的网格项目关系数据
|
|
|
|
List<IssueEntity> gridProjectList = null; |
|
|
|
//5:遍历统计每个网格各项指标数据
|
|
|
|
//6:批量保存网格日统计数据
|
|
|
|
//7:判断当前日期是否为当月首日,执行网格月数据统计
|
|
|
|
//3.2:批量保存网格日统计数据
|
|
|
|
factGridProjectDailyService.insertBatch(gridDateEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
@ -368,7 +485,74 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-网格月统计 |
|
|
|
**/ |
|
|
|
private String gridMonthProjectStats(String customerId, List<DimGridEntity> dimGridList) { |
|
|
|
private String gridMonthProjectStats(String customerId, DimIdGenerator.DimIdBean dimId, List<DimGridEntity> dimGridList) { |
|
|
|
//批量月数据新增对象
|
|
|
|
List<FactGridProjectMonthlyEntity> monthlyEntityList = new ArrayList<>(); |
|
|
|
|
|
|
|
//1:获取昨天日期所在月份的起始日期和结束日期
|
|
|
|
MonthProjectListFormDTO formDTO = new MonthProjectListFormDTO(); |
|
|
|
formDTO.setCustomerId(customerId); |
|
|
|
formDTO.setStartTime(getMonthBegin(yesterDay())); |
|
|
|
formDTO.setEndTime(getMonthEnd(yesterDay())); |
|
|
|
|
|
|
|
//2:遍历网格维度数据,分别统计每个网格月数据
|
|
|
|
for (DimGridEntity grid : dimGridList) { |
|
|
|
//2.1:查询上一月网格日统计数据,按时间倒序
|
|
|
|
formDTO.setGridId(grid.getId()); |
|
|
|
List<FactGridProjectDailyEntity> projectDailyList = factGridProjectDailyService.getMonthProjectList(formDTO); |
|
|
|
|
|
|
|
//2.2:汇总统计上一月网格月统计数据
|
|
|
|
//月增量中项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
int pendingIncr = 0; |
|
|
|
int closedIncr = 0; |
|
|
|
int resolvedIncr = 0; |
|
|
|
int unResolvedIncr = 0; |
|
|
|
for (FactGridProjectDailyEntity date : projectDailyList) { |
|
|
|
pendingIncr += date.getPendingIncr(); |
|
|
|
closedIncr += date.getClosedIncr(); |
|
|
|
resolvedIncr += date.getResolvedIncr(); |
|
|
|
unResolvedIncr += date.getUnresolvedIncr(); |
|
|
|
} |
|
|
|
//2.3:实体字段属性赋值
|
|
|
|
FactGridProjectMonthlyEntity monthlyEntity = new FactGridProjectMonthlyEntity(); |
|
|
|
monthlyEntity.setCustomerId(customerId); |
|
|
|
monthlyEntity.setAgencyId(grid.getAgencyId()); |
|
|
|
monthlyEntity.setGridId(grid.getId()); |
|
|
|
monthlyEntity.setMonthId(dimId.getMonthId()); |
|
|
|
monthlyEntity.setQuarterId(dimId.getQuarterId()); |
|
|
|
monthlyEntity.setYearId(dimId.getYearId()); |
|
|
|
if (null != projectDailyList && projectDailyList.size() > NumConstant.ZERO) { |
|
|
|
FactGridProjectDailyEntity entity = projectDailyList.get(0); |
|
|
|
monthlyEntity.setProjectTotal(entity.getProjectTotal()); |
|
|
|
monthlyEntity.setPendingTotal(entity.getPendingTotal()); |
|
|
|
monthlyEntity.setPendingRatio(entity.getPendingRatio()); |
|
|
|
monthlyEntity.setClosedTotal(entity.getClosedTotal()); |
|
|
|
monthlyEntity.setClosedRatio(entity.getClosedRatio()); |
|
|
|
monthlyEntity.setResolvedTotal(entity.getResolvedTotal()); |
|
|
|
monthlyEntity.setResolvedRatio(entity.getResolvedRatio()); |
|
|
|
monthlyEntity.setUnresolvedTotal(entity.getUnresolvedTotal()); |
|
|
|
monthlyEntity.setUnresolvedRatio(entity.getUnresolvedRatio()); |
|
|
|
monthlyEntity.setProjectIncr(pendingIncr + closedIncr); |
|
|
|
monthlyEntity.setPendingIncr(pendingIncr); |
|
|
|
monthlyEntity.setClosedIncr(closedIncr); |
|
|
|
monthlyEntity.setResolvedIncr(resolvedIncr); |
|
|
|
monthlyEntity.setUnresolvedIncr(unResolvedIncr); |
|
|
|
} |
|
|
|
|
|
|
|
monthlyEntityList.add(monthlyEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//3:批量新增数据,先删后增
|
|
|
|
if (null != monthlyEntityList && monthlyEntityList.size() > NumConstant.ZERO) { |
|
|
|
//3.1:根据客户Id、月份Id批量物理删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectMonthlyEntity delEntity = new FactAgencyProjectMonthlyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setMonthId(dimId.getMonthId()); |
|
|
|
factGridProjectMonthlyService.delMonthProject(delEntity); |
|
|
|
|
|
|
|
//3.2:批量保存机关月统计数据
|
|
|
|
factGridProjectMonthlyService.insertBatch(monthlyEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
|
@ -430,8 +614,7 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
//将毫秒至999
|
|
|
|
c.set(Calendar.MILLISECOND, 999); |
|
|
|
//获取本月最后一天的时间
|
|
|
|
System.out.println(c.getTime()); |
|
|
|
System.out.println(c); |
|
|
|
return c.getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |