diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index d5645f214d..1eb3c2d50a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -12,6 +12,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.utils.DateUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.formula.functions.T; /** * @author Mark sunlightcs@gmail.com @@ -568,6 +569,15 @@ public class RedisKeys { return rootPrefix.concat("message:mq:blocked:").concat(blockedMsgLabel); } + /** + * desc:获取执行完毕的 业务 参数结果key + * @param bizMethod + * @return + */ + public static String getBackDoorbizExcuteResult(String bizMethod) { + return rootPrefix.concat("backdoor:").concat(bizMethod); + } + /** * @description 登录票据。目前只有IC基层治理平台用到 * diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java index 11c019e4d9..8c7ce5e97d 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenProjectDataDao.java @@ -55,6 +55,7 @@ public interface ScreenProjectDataDao { * @date 2021/11/5 1:40 下午 */ List selectCategoryProjectList(@Param("customerId") String customerId,@Param("orgId") String orgId, - @Param("categoryCode")String categoryCode,@Param("status")String status); + @Param("categoryCode")String categoryCode,@Param("status")String status, + @Param("startTime")String startTime,@Param("endTime")String endTime); } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java index 24cab9b221..afbd2e9abe 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/ScreenProjectServiceImpl.java @@ -382,7 +382,7 @@ public class ScreenProjectServiceImpl implements ScreenProjectService { PageCategoryProjectListResultDTO result = new PageCategoryProjectListResultDTO(); List list; PageInfo objectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) - .doSelectPageInfo(() -> screenProjectDataDao.selectCategoryProjectList(tokenDto.getCustomerId(), formDTO.getOrgId(), formDTO.getCategoryCode(), formDTO.getStatus())); + .doSelectPageInfo(() -> screenProjectDataDao.selectCategoryProjectList(tokenDto.getCustomerId(), formDTO.getOrgId(), formDTO.getCategoryCode(), formDTO.getStatus(),formDTO.getStartTime(),formDTO.getEndTime())); list = objectPageInfo.getList(); result.setTotal(Integer.valueOf(String.valueOf(objectPageInfo.getTotal()))); diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml index accf6111e4..370f73fdf8 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenProjectDataDao.xml @@ -162,24 +162,29 @@ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 98cfbaf838..e47ce1845e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -60,9 +62,7 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -73,7 +73,8 @@ import java.util.concurrent.Future; public class DemoController { @Autowired private StatsDemoService demoService; - + @Autowired + private RedisUtils redisUtils; @Autowired private ExecutorService executorService; @@ -1084,16 +1085,21 @@ public class DemoController { @RequestParam(name = "startDate",required = false)String startDate, @RequestParam(name = "endDate",required = false)String endDate ){ + long start = System.currentTimeMillis(); + Set result = new LinkedHashSet<>(); if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){ List daysBetween = DateUtils.getDaysBetween(startDate, endDate); daysBetween.forEach(d -> { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d); + result.add(d); + redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); }); }else { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); + redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); } long end = System.currentTimeMillis(); long l = (end - start) / 1000; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java index e402f3268f..26aa8892d9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java @@ -80,7 +80,7 @@ public interface ScreenProjectDataDao extends BaseDao { * @author zxc * @date 2021/11/10 3:12 下午 */ - List selectGridCategoryProjectCount(@Param("customerIds") List customerIds,@Param("dateId") String dateId, + List selectGridCategoryProjectCount(@Param("dateId") String dateId,@Param("parentCustomerId") String parentCustomerId, @Param("status")String status,@Param("customerId") String customerId, @Param("subCount")Integer subCount); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java index 352ccc9d76..b1eb748aef 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java @@ -65,6 +65,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr */ @Override public void extractCategoryProjectGridData(String customerId, String dateId) { + log.info("开始执行网格项目分类统计"); + long start = System.currentTimeMillis(); List relationInfo = relationService.selectSubCustomer(customerId); List customerIds = new ArrayList<>(); customerIds.add(customerId); @@ -72,19 +74,28 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr List closedList = new ArrayList<>(); if (CollectionUtils.isEmpty(relationInfo)){ // 单客户 - allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); - closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); + allList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.FOUR); + closedList = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.FOUR); }else { // 多客户 List subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); customerIds.addAll(subCustomerIds); - allList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_ALL,customerId, NumConstant.TWO); - closedList = screenProjectDataDao.selectGridCategoryProjectCount(customerIds, dateId, ProjectConstant.PROJECT_STATUS_CLOSED,customerId, NumConstant.TWO); + List finalAllList = allList; + List finalClosedList1 = closedList; + customerIds.forEach(c -> { + List all = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_ALL, c, NumConstant.TWO); + finalAllList.addAll(all); + List closed = screenProjectDataDao.selectGridCategoryProjectCount(dateId, customerId, ProjectConstant.PROJECT_STATUS_CLOSED, c, NumConstant.TWO); + finalClosedList1.addAll(closed); + }); } List finalClosedList = closedList; allList.forEach(a -> finalClosedList.stream().filter(c -> c.getGridId().equals(a.getGridId()) && c.getCategoryCode().equals(a.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); gridDel(customerId,dateId); + log.info("网格-所有项目分类即将插入的集合{}",JSON.toJSONString(allList)); gridInsert(allList); + long end = System.currentTimeMillis(); + log.info("网格项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); } /** @@ -128,6 +139,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr */ @Override public void extractCategoryProjectOrgData(String customerId, String dateId) { + log.info("开始执行组织项目分类统计"); + long start = System.currentTimeMillis(); List relationInfo = relationService.selectSubCustomer(customerId); List customerIds = new ArrayList<>(); customerIds.add(customerId); @@ -136,14 +149,18 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr // one customer List agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId); List allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class); + result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); + List closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); + result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal()))); + + List oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); List oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); + result.addAll(oneLevelList); - List closedList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); - result.forEach(r -> closedList.stream().filter(c -> r.getOrgId().equals(c.getOrgId()) && r.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> r.setClosedProjectTotal(c.getClosedProjectTotal()))); - }else { + }else { // more customers // 去除孔村的客户ID,孔村镇的单独查😡 List subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); @@ -153,22 +170,28 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr continue; } } + subCustomerIds.add(customerId); List allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID); List> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY); List allOrgCategoryList = result; partition.forEach(p -> { List allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); - List oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies); - List oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.FOUR, allAgencies); - oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); - allOrgList.addAll(oneLevelList); List closedOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); allOrgList.forEach(a -> closedOrgList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); + + List oneLevelList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p); + List oneLevelClosedList = screenProjectDataDao.selectOrgCategoryOneLevelProjectCount(dateId, ProjectConstant.PROJECT_STATUS_CLOSED, customerId, NumConstant.TWO, p); + oneLevelList.forEach(a -> oneLevelClosedList.stream().filter(c -> a.getOrgId().equals(c.getOrgId()) && a.getCategoryCode().equals(c.getCategoryCode())).forEach(c -> a.setClosedProjectTotal(c.getClosedProjectTotal()))); + + allOrgList.addAll(oneLevelList); allOrgCategoryList.addAll(allOrgList); }); } orgDel(customerId,dateId); + log.info("组织-即将插入的项目分类{}",JSON.toJSONString(result)); orgInsert(result); + long end = System.currentTimeMillis(); + log.info("组织项目分类统计结束,耗时:"+ (end-start)/1000 + "s"); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java index d5b114852a..82af987c23 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java @@ -373,11 +373,12 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl SELECT #{dateId} AS dateId, - #{customerId} AS customerId, + #{parentCustomerId} AS customerId, pc.CATEGORY_CODE, pd.ORG_ID AS gridId, pd.PARENT_ID AS pid, @@ -287,12 +287,9 @@ COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal FROM screen_project_data pd - LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0') + inner JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0' AND pc.CATEGORY_CODE IS NOT NULL) WHERE pd.DEL_FLAG = '0' - AND pd.CUSTOMER_ID IN - - #{c} - + AND pd.CUSTOMER_ID =#{customerId} AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') #{dateId} AND pd.ORG_TYPE = 'grid' AND pc.level = 2 @@ -303,7 +300,7 @@ UNION ALL SELECT #{dateId} AS dateId, - #{customerId} AS customerId, + #{parentCustomerId} AS customerId, left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode, pd.ORG_ID AS gridId, pd.PARENT_ID AS pid, @@ -316,12 +313,9 @@ COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal FROM screen_project_data pd - INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0') + INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0' AND pc.CATEGORY_CODE IS NOT NULL) WHERE pd.DEL_FLAG = '0' - AND pd.CUSTOMER_ID IN - - #{c} - + AND pd.CUSTOMER_ID = #{customerId} AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') #{dateId} AND pd.ORG_TYPE = 'grid' @@ -350,7 +344,7 @@ COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal FROM screen_project_data pd - LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0') + inner JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0' AND pc.CATEGORY_CODE IS NOT NULL) WHERE pd.DEL_FLAG = '0' AND pc.level = 2 AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') #{dateId} @@ -381,7 +375,7 @@ COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal FROM screen_project_data pd - INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0') + INNER JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0' AND pc.CATEGORY_CODE IS NOT NULL) WHERE pd.DEL_FLAG = '0' AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') #{dateId} AND ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%')