From ba9e395d87a691afecf4f2e17224e4033700b784 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 10 Nov 2021 17:05:49 +0800 Subject: [PATCH] emm,org --- .../GridAndOrgCategoryCountResultDTO.java | 5 ++ .../screen/ScreenCustomerAgencyDao.java | 10 +++ .../screen/ScreenProjectDataDao.java | 23 ++++++ ...ectCategoryGridAndOrgDailyServiceImpl.java | 70 +++++++++++++++++++ .../screen/ScreenCustomerAgencyDao.xml | 25 +++++++ .../screen/ScreenProjectDataDao.xml | 62 +++++++++++++++- 6 files changed, 193 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java index de4f1c8a58..f62e1c3d54 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java @@ -20,6 +20,11 @@ public class GridAndOrgCategoryCountResultDTO implements Serializable { */ private String orgId; + /** + * 组织类型 + */ + private String orgType; + /** * 网格ID */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index e6155e982e..84f989ddf9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -28,6 +28,7 @@ import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.dto.indexcal.AgencyAndParentResultDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; +import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.dto.screen.result.TreeResultDTO; import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; @@ -244,4 +245,13 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectByCustomerId(@Param("customerId") String customerId); + /** + * @Description 查询父子客户的组织【平阴】 + * @param customerIds 平阴,榆山,锦水的客户ID + * @param customerId 孔村的客户ID🤬 + * @author zxc + * @date 2021/11/10 2:52 下午 + */ + List selectParentSonAgency(@Param("customerIds") List customerIds ,@Param("customerId") String customerId); + } 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 dd77e140c5..5a9155f237 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 @@ -70,7 +70,30 @@ public interface ScreenProjectDataDao extends BaseDao { List selectProjectList(@Param("customerId") String customerId, @Param("projectId") String projectId); + /** + * @Description 查询网格下的项目分类 + * @param customerIds 父子客户的customerId + * @param dateId 日期ID + * @param status 所有项目:all,已结案项目:closed + * @param customerId 父级客户ID + * @param subCount 分类截取位数 + * @author zxc + * @date 2021/11/10 3:12 下午 + */ List selectGridCategoryProjectCount(@Param("customerIds") List customerIds,@Param("dateId") String dateId, @Param("status")String status,@Param("customerId") String customerId, @Param("subCount")Integer subCount); + + /** + * @Description 查询组织下的项目分类 + * @param dateId 日期ID + * @param status 所有项目:all,已结案项目:closed + * @param customerId 父级客户ID + * @param subCount 分类截取位数 + * @author zxc + * @date 2021/11/10 3:14 下午 + */ + List selectOrgCategoryProjectCount(@Param("dateId") String dateId, @Param("status")String status, + @Param("customerId") String customerId, @Param("subCount")Integer subCount, + @Param("allAgencies") List allAgencies); } 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 9eb635ff4e..05070b22ca 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 @@ -5,16 +5,21 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.PingYinConstant; import com.epmet.constant.ProjectConstant; +import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryGridDailyDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; +import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.entity.crm.CustomerRelationEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity; +import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService; import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService; +import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; @@ -45,7 +50,11 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr @Autowired private ScreenProjectCategoryGridDailyService gridDailyService; @Autowired + private ScreenProjectCategoryOrgDailyService orgDailyService; + @Autowired private ScreenProjectCategoryOrgDailyDao orgDailyDao; + @Autowired + private ScreenCustomerAgencyDao screenCustomerAgencyDao; /** * @Description 分类下的项目数【grid】 @@ -110,6 +119,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr /** * @Description 分类下的项目数【org】 + * 项目分类来源 + * 本级【直接立项】 + 下级 + 直属网格 * @param customerId * @param dateId * @author zxc @@ -120,5 +131,64 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr List relationInfo = relationService.selectSubCustomer(customerId); List customerIds = new ArrayList<>(); customerIds.add(customerId); + List result = new ArrayList<>(); + if (CollectionUtils.isEmpty(relationInfo)){ + // 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()))); + }else { + // more customers + // 去除孔村的客户ID,孔村镇的单独查😡 + List subCustomerIds = relationInfo.stream().map(CustomerRelationEntity::getCustomerId).collect(Collectors.toList()); + for (int i = NumConstant.ZERO; i < subCustomerIds.size(); i++) { + if (subCustomerIds.get(i).equals(PingYinConstant.KONG_CUN_CUSTOMER_ID)){ + customerIds.remove(i); + continue; + } + } + 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 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()))); + allOrgCategoryList.addAll(allOrgList); + }); + } + orgDel(customerId,dateId); + } + + /** + * @Description 项目分类组织删除 + * @param customerId + * @param dateId + * @author zxc + * @date 2021/11/10 4:58 下午 + */ + @Transactional(rollbackFor = Exception.class) + public void orgDel(String customerId,String dateId){ + Integer num = NumConstant.ZERO; + do { + num = orgDailyDao.deleteByDateIdAndCustomerId(customerId, dateId); + }while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND); + } + + /** + * @Description 项目分类组织插入 + * @param needInsert + * @author zxc + * @date 2021/11/10 5:03 下午 + */ + @Transactional(rollbackFor = Exception.class) + public void orgInsert(List needInsert){ + List> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class)); + log.info("插入的组织项目分类为" + JSON.toJSONString(p)); + }); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 12ccf09ab0..df067fcab1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -505,4 +505,29 @@ AND customer_id = #{customerId} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml index 199776d15e..201ae4fada 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml @@ -270,6 +270,7 @@ a.CREATED_TIME ASC + + + +