|
|
|
@ -25,11 +25,15 @@ import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.LocalDateUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.KpiMetaDataDao; |
|
|
|
import com.elink.esua.epdc.dto.EventCountFromDTO; |
|
|
|
import com.elink.esua.epdc.dto.KpiMetaDataDTO; |
|
|
|
import com.elink.esua.epdc.dto.events.form.EventCountSqlFromDTO; |
|
|
|
import com.elink.esua.epdc.dto.events.form.KpiEventEvaluationFromDTO; |
|
|
|
import com.elink.esua.epdc.entity.KpiMetaDataEntity; |
|
|
|
import com.elink.esua.epdc.enums.KpiCycleEnum; |
|
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.feign.EventFeignClient; |
|
|
|
import com.elink.esua.epdc.redis.KpiMetaDataRedis; |
|
|
|
@ -39,12 +43,12 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.xml.crypto.Data; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.Month; |
|
|
|
import java.time.Period; |
|
|
|
import java.time.YearMonth; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 绩效考核的元数据 |
|
|
|
@ -118,14 +122,13 @@ public class KpiMetaDataServiceImpl extends BaseServiceImpl<KpiMetaDataDao, KpiM |
|
|
|
|
|
|
|
@Override |
|
|
|
public void createMataData() { |
|
|
|
// 获取所有网格
|
|
|
|
Result<List<Long>> listResult = adminFeignClient.listAllGridId(); |
|
|
|
//容量
|
|
|
|
int pageSize = 10; |
|
|
|
//页码
|
|
|
|
int pageIndex = 1; |
|
|
|
while (true) { |
|
|
|
Result<List<Long>> listResult1 = adminFeignClient.pageDeptIdByTypeKey(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
|
// 分页获取所有网格
|
|
|
|
Result<List<Long>> listResult = adminFeignClient.pageDeptIdByTypeKey(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
|
if (listResult == null || listResult.getData() == null) { |
|
|
|
throw new RuntimeException("获取网格列表失败"); |
|
|
|
} |
|
|
|
@ -157,4 +160,78 @@ public class KpiMetaDataServiceImpl extends BaseServiceImpl<KpiMetaDataDao, KpiM |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void createEvaluationData() { |
|
|
|
//查询sql入参
|
|
|
|
//月
|
|
|
|
KpiEventEvaluationFromDTO monthFromDto; |
|
|
|
//季度
|
|
|
|
KpiEventEvaluationFromDTO quarterFromDto; |
|
|
|
// 年
|
|
|
|
KpiEventEvaluationFromDTO yearFromDto; |
|
|
|
//统计月
|
|
|
|
//取本月第一天
|
|
|
|
YearMonth now = YearMonth.now(); |
|
|
|
LocalDate startTime = now.minusMonths(1).atDay(1); |
|
|
|
LocalDate endTime = now.atDay(1); |
|
|
|
Date endTimeDate = LocalDateUtils.localDateToDate(startTime); |
|
|
|
//按月统计
|
|
|
|
|
|
|
|
monthFromDto = new KpiEventEvaluationFromDTO(); |
|
|
|
monthFromDto.setEndTime(LocalDateUtils.localDateToDate(endTime)); |
|
|
|
monthFromDto.setStartTime(endTimeDate); |
|
|
|
|
|
|
|
//按照季度
|
|
|
|
int nowMonth = now.getMonthValue(); |
|
|
|
//上个季度第一天
|
|
|
|
LocalDate lastQuarter = now.minusMonths(3).atDay(1); |
|
|
|
Date startQuarterDate = LocalDateUtils.localDateToDate(lastQuarter); |
|
|
|
quarterFromDto = new KpiEventEvaluationFromDTO(); |
|
|
|
quarterFromDto.setStartTime(startQuarterDate); |
|
|
|
quarterFromDto.setEndTime(endTimeDate); |
|
|
|
//年统计
|
|
|
|
//上个季度第一天
|
|
|
|
LocalDate lastYear = now.minusYears(1).atDay(1); |
|
|
|
yearFromDto = new KpiEventEvaluationFromDTO(); |
|
|
|
yearFromDto.setStartTime(LocalDateUtils.localDateToDate(lastYear)); |
|
|
|
yearFromDto.setEndTime(endTimeDate); |
|
|
|
//容量
|
|
|
|
int pageSize = 10; |
|
|
|
//页码
|
|
|
|
int pageIndex = 1; |
|
|
|
List<KpiMetaDataDTO> kpiMetaDataDTOList; |
|
|
|
while (true) { |
|
|
|
// 分页获取所有网格
|
|
|
|
Result<List<Long>> listResult = adminFeignClient.pageDeptIdByTypeKey(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, pageSize, pageIndex); |
|
|
|
if (listResult == null || listResult.getData() == null) { |
|
|
|
throw new RuntimeException("获取网格列表失败"); |
|
|
|
} |
|
|
|
if (listResult.getData().size() == 0) { |
|
|
|
//所有网格获取完成 跳出循环
|
|
|
|
return; |
|
|
|
} |
|
|
|
//月统计
|
|
|
|
List<Long> gridList = listResult.getData(); |
|
|
|
monthFromDto.setGridIdList(gridList); |
|
|
|
monthFromDto.setType(KpiCycleEnum.KPI_CYCLE_MONTH.getValue()); |
|
|
|
kpiMetaDataDTOList = eventFeignClient.queryEvaluationData(monthFromDto).getData(); |
|
|
|
insertBatch(ConvertUtils.sourceToTarget(kpiMetaDataDTOList, KpiMetaDataEntity.class)); |
|
|
|
// 1,4,7,10 月份的时候统计 季度 季度第一天统计上一季度
|
|
|
|
if (nowMonth == NumConstant.ONE || nowMonth == NumConstant.FOUR || nowMonth == NumConstant.SEVEN || nowMonth == NumConstant.TEN) { |
|
|
|
monthFromDto.setType(KpiCycleEnum.KPI_CYCLE_QUARTER.getValue()); |
|
|
|
kpiMetaDataDTOList = eventFeignClient.queryEvaluationData(quarterFromDto).getData(); |
|
|
|
insertBatch(ConvertUtils.sourceToTarget(kpiMetaDataDTOList, KpiMetaDataEntity.class)); |
|
|
|
} |
|
|
|
|
|
|
|
// 一月份统计去年的
|
|
|
|
if (nowMonth == NumConstant.ONE) { |
|
|
|
monthFromDto.setType(KpiCycleEnum.KPI_CYCLE_YEAR.getValue()); |
|
|
|
kpiMetaDataDTOList = eventFeignClient.queryEvaluationData(yearFromDto).getData(); |
|
|
|
insertBatch(ConvertUtils.sourceToTarget(kpiMetaDataDTOList, KpiMetaDataEntity.class)); |
|
|
|
} |
|
|
|
//页码
|
|
|
|
pageIndex++; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |