|
|
@ -2,16 +2,20 @@ package com.epmet.service.impl; |
|
|
|
|
|
|
|
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.entity.project.ProjectEntity; |
|
|
|
import com.epmet.entity.project.ProjectProcessEntity; |
|
|
|
import com.epmet.entity.stats.DimDateEntity; |
|
|
|
import com.epmet.entity.stats.FactAgencyProjectDailyEntity; |
|
|
|
import com.epmet.entity.stats.FactAgencyProjectMonthlyEntity; |
|
|
|
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.stereotype.Service; |
|
|
|
|
|
|
@ -63,13 +67,20 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void statsAgencyProject(String customerId) { |
|
|
|
//1:执行机关日数据统计
|
|
|
|
agencyDateProjectStats(customerId); |
|
|
|
//2:执行机关月数据统计
|
|
|
|
if (Calendar.getInstance().get(Calendar.DATE) == 1) { |
|
|
|
agencyMonthProjectStats(customerId); |
|
|
|
} |
|
|
|
//1:根据客户Id查询机关维度表数据
|
|
|
|
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO(); |
|
|
|
dimAgencyDTO.setCustomerId(customerId); |
|
|
|
List<DimAgencyDTO> dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); |
|
|
|
|
|
|
|
if (null != dimAgencyList && dimAgencyList.size() > NumConstant.ZERO) { |
|
|
|
//2:执行机关日数据统计
|
|
|
|
agencyDateProjectStats(customerId, dimAgencyList); |
|
|
|
|
|
|
|
//3:执行机关月数据统计
|
|
|
|
if (Calendar.getInstance().get(Calendar.DATE) == 1) { |
|
|
|
agencyMonthProjectStats(customerId, dimAgencyList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -77,28 +88,18 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关日统计 |
|
|
|
**/ |
|
|
|
private String agencyDateProjectStats(String customerId) { |
|
|
|
private String agencyDateProjectStats(String customerId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
Date date = yesterDay(); |
|
|
|
//1:查询各维度表Id,方便使用 //TODO
|
|
|
|
DimDateDTO dimDateDTO = new DimDateDTO(); |
|
|
|
dimDateDTO.setCreatedTime(date); |
|
|
|
dimDateDTO = dimDateService.getDimDate(dimDateDTO).get(0); |
|
|
|
|
|
|
|
//2:根据客户Id查询机关维度表数据
|
|
|
|
DimAgencyDTO dimAgencyDTO = new DimAgencyDTO(); |
|
|
|
dimAgencyDTO.setCustomerId(customerId); |
|
|
|
List<DimAgencyDTO> dimAgencyList = dimAgencyService.getDimAgencyList(dimAgencyDTO); |
|
|
|
if (null == dimAgencyList || dimAgencyList.size() < NumConstant.ONE) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
//1:查询各维度表Id,方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(yesterDay()); |
|
|
|
|
|
|
|
//3:根据客户Id查询项目业务表数据
|
|
|
|
//2:根据客户Id查询项目业务表数据
|
|
|
|
List<ProjectEntity> projectList = projectService.getProjectList(customerId); |
|
|
|
|
|
|
|
//4:查询项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
|
|
|
|
//3:查询项目处理进展表中是创建项目和结案两种进展的有效数据(创建日期截取yyyy-mm-dd格式字段值)
|
|
|
|
List<ProjectProcessEntity> processList = projectProcessService.getProcessList(customerId); |
|
|
|
|
|
|
|
//5:遍历统计每个机关各项指标数
|
|
|
|
//4:遍历统计每个机关各项指标数
|
|
|
|
//批量机关日统计新增对象
|
|
|
|
List<FactAgencyProjectDailyEntity> dimDateEntityList = new ArrayList<>(); |
|
|
|
//计算百分比使用,保留小数点后两位
|
|
|
@ -172,11 +173,10 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
agencyDailyEntity.setCustomerId(customerId); |
|
|
|
agencyDailyEntity.setAgencyId(agency.getId()); |
|
|
|
agencyDailyEntity.setParentId(agency.getPid()); |
|
|
|
//TODO
|
|
|
|
agencyDailyEntity.setDateId(""); |
|
|
|
agencyDailyEntity.setWeekId(""); |
|
|
|
agencyDailyEntity.setMonthId(""); |
|
|
|
agencyDailyEntity.setYearId(""); |
|
|
|
agencyDailyEntity.setDateId(dimId.getDateId()); |
|
|
|
agencyDailyEntity.setWeekId(dimId.getWeekId()); |
|
|
|
agencyDailyEntity.setMonthId(dimId.getMonthId()); |
|
|
|
agencyDailyEntity.setYearId(dimId.getYearId()); |
|
|
|
agencyDailyEntity.setProjectTotal(projectTotal.intValue()); |
|
|
|
agencyDailyEntity.setPendingTotal(pendingTotal.intValue()); |
|
|
|
agencyDailyEntity.setClosedTotal(closedTotal.intValue()); |
|
|
@ -199,8 +199,15 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
dimDateEntityList.add(agencyDailyEntity); |
|
|
|
} |
|
|
|
|
|
|
|
//6:批量保存机关日统计数据
|
|
|
|
//先删后增
|
|
|
|
if (null != dimDateEntityList && dimDateEntityList.size() > NumConstant.ZERO) { |
|
|
|
//5:根据客户Id、日维度Id批量物理删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectDailyEntity delEntity = new FactAgencyProjectDailyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setDateId(dimId.getDateId()); |
|
|
|
factAgencyProjectDailyService.delDateProject(delEntity); |
|
|
|
|
|
|
|
//6:批量保存机关日统计数据
|
|
|
|
factAgencyProjectDailyService.insertBatch(dimDateEntityList); |
|
|
|
} |
|
|
|
return null; |
|
|
@ -211,8 +218,76 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
* @Author sun |
|
|
|
* @Description 数据-项目-机关月统计 |
|
|
|
**/ |
|
|
|
private void agencyMonthProjectStats(String customerId) { |
|
|
|
private String agencyMonthProjectStats(String customerId, List<DimAgencyDTO> dimAgencyList) { |
|
|
|
//1:获取个维度Id方便使用
|
|
|
|
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(yesterDay()); |
|
|
|
|
|
|
|
//2:获取昨天日期所在月份的起始日期和结束日期
|
|
|
|
MonthProjectListFormDTO formDTO = new MonthProjectListFormDTO(); |
|
|
|
formDTO.setCustomerId(customerId); |
|
|
|
formDTO.setStartTime(getMonthBegin(yesterDay())); |
|
|
|
formDTO.setEndTime(getMonthEnd(yesterDay())); |
|
|
|
|
|
|
|
//批量月数据新增对象
|
|
|
|
List<FactAgencyProjectMonthlyEntity> monthlyEntityList = new ArrayList<>(); |
|
|
|
//3:遍历机关维度数据,分别统计每个组织月数据
|
|
|
|
for (DimAgencyDTO agency : dimAgencyList) { |
|
|
|
//4:查询上一月机关日统计数据,按时间倒序
|
|
|
|
formDTO.setAgencyId(agency.getId()); |
|
|
|
List<FactAgencyProjectDailyEntity> projectDailyList = factAgencyProjectDailyService.getMonthProjectList(formDTO); |
|
|
|
|
|
|
|
//5:汇总统计上一月机关月统计数据
|
|
|
|
//月增量中项目总数、处理中总数、已结案总数、已结案已解决总数、已结案未解决总数
|
|
|
|
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(); |
|
|
|
} |
|
|
|
//6:实体字段属性赋值
|
|
|
|
FactAgencyProjectMonthlyEntity monthlyEntity = new FactAgencyProjectMonthlyEntity(); |
|
|
|
monthlyEntity.setCustomerId(customerId); |
|
|
|
monthlyEntity.setAgencyId(agency.getId()); |
|
|
|
monthlyEntity.setParentId(agency.getPid()); |
|
|
|
monthlyEntity.setMonthId(dimId.getMonthId()); |
|
|
|
monthlyEntity.setQuarterId(dimId.getQuarterId()); |
|
|
|
monthlyEntity.setYearId(dimId.getYearId()); |
|
|
|
if (null != projectDailyList && projectDailyList.size() > NumConstant.ZERO) { |
|
|
|
FactAgencyProjectDailyEntity 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); |
|
|
|
} |
|
|
|
|
|
|
|
if (null != monthlyEntityList && monthlyEntityList.size() > NumConstant.ZERO) { |
|
|
|
//7:根据客户Id、月份Id批量删除一下可能存在的历史数据
|
|
|
|
FactAgencyProjectMonthlyEntity delEntity = new FactAgencyProjectMonthlyEntity(); |
|
|
|
delEntity.setCustomerId(customerId); |
|
|
|
delEntity.setMonthId(dimId.getMonthId()); |
|
|
|
factAgencyProjectMonthlyService.delMonthProject(delEntity); |
|
|
|
|
|
|
|
//8:批量保存机关月统计数据
|
|
|
|
factAgencyProjectMonthlyService.insertBatch(monthlyEntityList); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -251,4 +326,47 @@ public class StatsProjectServiceImpl implements StatsProjectService { |
|
|
|
return date; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 获取指定日期所在月份开始的时间 |
|
|
|
**/ |
|
|
|
public Date getMonthBegin(Date date) { |
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
c.setTime(date); |
|
|
|
//设置为1号,当前日期既为本月第一天
|
|
|
|
c.set(Calendar.DAY_OF_MONTH, 1); |
|
|
|
//将小时至0
|
|
|
|
c.set(Calendar.HOUR_OF_DAY, 0); |
|
|
|
//将分钟至0
|
|
|
|
c.set(Calendar.MINUTE, 0); |
|
|
|
//将秒至0
|
|
|
|
c.set(Calendar.SECOND, 0); |
|
|
|
//将毫秒至0
|
|
|
|
c.set(Calendar.MILLISECOND, 0); |
|
|
|
//获取本月第一天的时间
|
|
|
|
return c.getTime(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 获取指定日期所在月份结束的时间 |
|
|
|
**/ |
|
|
|
public Date getMonthEnd(Date date) { |
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
c.setTime(date); |
|
|
|
//设置为当月最后一天
|
|
|
|
c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); |
|
|
|
//将小时至23
|
|
|
|
c.set(Calendar.HOUR_OF_DAY, 23); |
|
|
|
//将分钟至59
|
|
|
|
c.set(Calendar.MINUTE, 59); |
|
|
|
//将秒至59
|
|
|
|
c.set(Calendar.SECOND, 59); |
|
|
|
//将毫秒至999
|
|
|
|
c.set(Calendar.MILLISECOND, 999); |
|
|
|
//获取本月最后一天的时间
|
|
|
|
System.out.println(c.getTime()); |
|
|
|
System.out.println(c); |
|
|
|
return c.getTime(); |
|
|
|
} |
|
|
|
} |
|
|
|