From 15e5bb3b09d3e5f630fb817a49a99248cf9a9f4d Mon Sep 17 00:00:00 2001 From: yujintao Date: Fri, 20 Dec 2019 09:20:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/KpiMetaDataServiceImpl.java | 69 +++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiMetaDataServiceImpl.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiMetaDataServiceImpl.java index 05bbe366a..762cbc6e8 100644 --- a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiMetaDataServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiMetaDataServiceImpl.java @@ -137,49 +137,64 @@ public class KpiMetaDataServiceImpl extends BaseServiceImpl gridList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); - do { eventReportAmountFormDto.setGridIdList(gridList); // 从events模块获取统计数据 List reportAmountList = this.getMetaDateFromEventsModule(eventReportAmountFormDto); // 组装元数据对象并插入数据库 this.insertBatch(this.packageMetaDataList(reportAmountList, eventReportAmountFormDto, kpiCycle)); - pageIndex++; gridList = deptUtils.getDeptIdList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); } while (CollUtil.isNotEmpty(gridList)); } + /** + * 根据月、季、年 以及当前月份,获取考核周期开始日 + * + * @param kpiCycle 月、季、年 + * @return java.util.Date 若返回空值:当前月份无法针对传入的考核周期进行考核 + * @author work@yujt.net.cn + * @date 2019/12/20 09:13 + */ + private Date getKpiStartDateByCycle(String kpiCycle) { + LocalDate startDate = null; + YearMonth now = YearMonth.now(); + if (KpiCycleEnum.KPI_CYCLE_MONTH.getValue().equals(kpiCycle)) { + startDate = now.minusMonths(NumConstant.ONE).atDay(NumConstant.ONE); + } else if (KpiCycleEnum.KPI_CYCLE_QUARTER.getValue().equals(kpiCycle)) { + int monthValue = now.getMonthValue(); + if (monthValue != NumConstant.ONE && monthValue != NumConstant.FOUR && monthValue != NumConstant.SEVEN && monthValue != NumConstant.TEN) { + log.error("当前日期:{},无法按照{}进行绩效考核", LocalDate.now().toString(), kpiCycle); + } else { + startDate = now.minusMonths(NumConstant.THREE).atDay(NumConstant.ONE); + } + } else if (KpiCycleEnum.KPI_CYCLE_YEAR.getValue().equals(kpiCycle)) { + if (now.getMonthValue() != NumConstant.ONE) { + log.error("当前日期:{},无法按照{}进行绩效考核", LocalDate.now().toString(), kpiCycle); + } else { + startDate = now.minusMonths(NumConstant.TWELVE).atDay(NumConstant.ONE); + } + } + if (null == startDate) { + return null; + } + return LocalDateUtils.localDateToDate(startDate); + } + /** * 从events模块获取统计数据 *