diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java index 2520d4bd89..084a3ed84c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsGroupServiceImpl.java @@ -23,6 +23,7 @@ import com.epmet.service.stats.*; import com.epmet.util.DimIdGenerator; import com.epmet.util.ModuleConstant; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -89,10 +90,15 @@ public class StatsGroupServiceImpl implements StatsGroupService { DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(formDTO); if (customerIds.size() != NumConstant.ZERO) { customerIds.forEach(customerId -> { + Boolean status = true; try { List gridsInfo = customerGridService.getCustomerGridIdList(customerId, dimIdBean.getDateId()); - List resultDTOS = groupDataService.groupGridDaily(customerId, dimIdBean, gridsInfo); - factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS, customerId); + List> partition = ListUtils.partition(gridsInfo, NumConstant.ONE_HUNDRED); + for (List p : partition) { + List resultDTOS = groupDataService.groupGridDaily(customerId, dimIdBean, p); + factGroupGridDailyService.statisticsGroupGridDaily(resultDTOS, customerId,status); + status = false; + } } catch (Exception e) { log.error(String.format(GroupConstant.STATS_FAILED_GRID_DAILY, customerId, LocalDate.now(), e)); } @@ -129,10 +135,15 @@ public class StatsGroupServiceImpl implements StatsGroupService { if (customerIds.size() != NumConstant.ZERO) { DimIdGenerator.DimIdBean dimIdBean = this.getDimIdBean(formDTO); customerIds.forEach(customerId -> { + Boolean status = true; try { List customerAgencyInfos = dimAgencyService.getAgencyInfoByCustomerId(customerId); - List agencyGroupDaily = this.getAgencyGroupDaily(customerAgencyInfos, dimIdBean, customerId); - factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily, customerId); + List> partition = ListUtils.partition(customerAgencyInfos, NumConstant.ONE_HUNDRED); + for (List p : partition) { + List agencyGroupDaily = this.getAgencyGroupDaily(p, dimIdBean, customerId); + factGroupAgencyDailyService.insertGroupAgencyDaily(agencyGroupDaily, customerId,status); + status = false; + } } catch (Exception e) { log.error(String.format(GroupConstant.STATS_FAILED_AGENCY_DAILY, customerId, LocalDate.now(), e)); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java index 812c2c73da..23b34b22af 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupAgencyDailyService.java @@ -101,7 +101,7 @@ public interface FactGroupAgencyDailyService extends BaseService agencyList,String customerId); + void insertGroupAgencyDaily(List agencyList,String customerId,Boolean status); /** * @param diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupGridDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupGridDailyService.java index bcf2157ecd..732e5062eb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupGridDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/FactGroupGridDailyService.java @@ -99,5 +99,5 @@ public interface FactGroupGridDailyService extends BaseService formDto,String customerId); + void statisticsGroupGridDaily(List formDto,String customerId,Boolean status); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java index 306849f76e..b822dcaaa0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupAgencyDailyServiceImpl.java @@ -113,12 +113,15 @@ public class FactGroupAgencyDailyServiceImpl extends BaseServiceImpl agencyList,String customerId) { + public void insertGroupAgencyDaily(List agencyList,String customerId,Boolean status) { if (!CollectionUtils.isEmpty(agencyList)){ - Integer delNum; - do { - delNum = baseDao.deleteInsertAgencyDailyByDateId(agencyList.get(NumConstant.ZERO).getDateId(),customerId); - }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); + // true 为当前客户第一回进入,需要删除历史数据 + if (status){ + Integer delNum; + do { + delNum = baseDao.deleteInsertAgencyDailyByDateId(agencyList.get(NumConstant.ZERO).getDateId(),customerId); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); + } List> partition = ListUtils.partition(agencyList, NumConstant.ONE_HUNDRED); partition.forEach(p -> { baseDao.insertGroupAgencyDaily(p); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java index f0c8d90832..993428d34f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/FactGroupGridDailyServiceImpl.java @@ -115,15 +115,18 @@ public class FactGroupGridDailyServiceImpl extends BaseServiceImpl formDto,String customerId) { + public void statisticsGroupGridDaily(List formDto,String customerId,Boolean status) { if (CollectionUtils.isEmpty(formDto)){ return; } String dateId = formDto.get(NumConstant.ZERO).getDateId(); - Integer delNum; - do { - delNum = baseDao.deleteInsertDateId(dateId,customerId); - }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); + // true 为当前客户第一回进入,需要删除历史数据 + if (status){ + Integer delNum; + do { + delNum = baseDao.deleteInsertDateId(dateId,customerId); + }while (delNum > NumConstant.ZERO && delNum == NumConstant.ONE_THOUSAND); + } List> partition = ListUtils.partition(formDto, NumConstant.ONE_HUNDRED); partition.forEach(p -> { baseDao.insertGroupGridDaily(p); diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java index 98e2f839c8..2db11324a7 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java @@ -3,14 +3,13 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.ProjectConstant; import com.epmet.dao.CalenderDao; import com.epmet.dto.form.CostDayFormDTO; import com.epmet.dto.form.TimestampIntervalFormDTO; import com.epmet.dto.form.WorkDayFormDTO; -import com.epmet.dto.result.CostDayResultDTO; import com.epmet.dto.form.WorkMinuteFormDTO; +import com.epmet.dto.result.CostDayResultDTO; import com.epmet.dto.result.WorkDayResultDTO; import com.epmet.entity.CalenderEntity; import com.epmet.service.WorkDayService; @@ -271,7 +270,7 @@ public class WorkDayServiceImpl implements WorkDayService { LocalDateTime initialTime = LocalDateTime.ofInstant(right.toInstant(), ZoneId.systemDefault()) .withHour(NumConstant.ZERO).withMinute(NumConstant.ZERO).withSecond(NumConstant.ZERO).withNano(NumConstant.ZERO); //ChronoUnit日期枚举类,between方法计算两个时间对象之间的时间量 - costMin += ChronoUnit.SECONDS.between(localDateTime, initialTime)/NumConstant.SIXTY; + costMin += ChronoUnit.SECONDS.between(initialTime, localDateTime)/NumConstant.SIXTY; } if(NumConstant.TWO == list.size()) { return costMin; diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml index 13a7758445..ca6eea46a8 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml @@ -60,6 +60,7 @@ DEL_FLAG = '0' AND QUERY_DATE BETWEEN #{begin} AND #{end} + order by query_date asc \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectDao.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectDao.java index 3006a8b4f6..b5a3e5107e 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectDao.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/dao/ProjectDao.java @@ -272,4 +272,15 @@ public interface ProjectDao extends BaseDao { * @Date 2022/1/4 16:45 */ List getGridMemberProjectList(@Param("agencyId") String agencyId, @Param("staffId") String staffId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 获取项目列表,用来计算项目耗时 + * @Param customerId + * @Param projectId + * @Param status + * @Return {@link List< ProjectEntity>} + * @Author zhaoqifeng + * @Date 2022/1/12 17:05 + */ + List getProjectListForWorkMinutes(@Param("customerId")String customerId, @Param("projectId")String projectId, @Param("status")String status); } \ No newline at end of file diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 9022c94686..e6e70e2c73 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -18,7 +18,6 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -59,6 +58,7 @@ import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import com.epmet.send.SendMqMsgUtil; import com.epmet.service.*; import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.google.common.base.Joiner; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -3079,11 +3079,7 @@ public class ProjectServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(dto.getCustomerId()), ProjectEntity::getCustomerId, dto.getCustomerId()); - wrapper.eq(StringUtils.isNotBlank(dto.getId()), ProjectEntity::getId, dto.getId()); - wrapper.eq(StringUtils.isNotBlank(dto.getStatus()), ProjectEntity::getStatus, dto.getStatus()); - list = baseDao.selectList(wrapper); + list = baseDao.getProjectListForWorkMinutes(dto.getCustomerId(), dto.getId(), dto.getStatus());; if (CollectionUtils.isNotEmpty(list)) { //提取项目ID,创建时间,更新时间 List intervalList = list.stream().map(item -> { diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml index 60c2050f24..0ce0ccba89 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/mapper/ProjectDao.xml @@ -506,4 +506,26 @@ ORDER BY CREATED_TIME DESC + \ No newline at end of file