Browse Source

emm,org

dev_shibei_match
zxc 4 years ago
parent
commit
ba9e395d87
  1. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/GridAndOrgCategoryCountResultDTO.java
  2. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  3. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java
  4. 70
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridAndOrgDailyServiceImpl.java
  5. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  6. 62
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml

5
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 orgId;
/**
* 组织类型
*/
private String orgType;
/** /**
* 网格ID * 网格ID
*/ */

10
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.indexcal.AgencyAndParentResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO; import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO; import com.epmet.dto.screencoll.form.CustomerAgencyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
@ -244,4 +245,13 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
*/ */
List<CustomerAgencyDTO> selectByCustomerId(@Param("customerId") String customerId); List<CustomerAgencyDTO> selectByCustomerId(@Param("customerId") String customerId);
/**
* @Description 查询父子客户的组织平阴
* @param customerIds 平阴榆山锦水的客户ID
* @param customerId 孔村的客户ID🤬
* @author zxc
* @date 2021/11/10 2:52 下午
*/
List<GridAndOrgCategoryCountResultDTO> selectParentSonAgency(@Param("customerIds") List<String> customerIds ,@Param("customerId") String customerId);
} }

23
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<ScreenProjectDataEntity> {
List<ScreenProjectDataDTO> selectProjectList(@Param("customerId") String customerId, @Param("projectId") String projectId); List<ScreenProjectDataDTO> 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<GridAndOrgCategoryCountResultDTO> selectGridCategoryProjectCount(@Param("customerIds") List<String> customerIds,@Param("dateId") String dateId, List<GridAndOrgCategoryCountResultDTO> selectGridCategoryProjectCount(@Param("customerIds") List<String> customerIds,@Param("dateId") String dateId,
@Param("status")String status,@Param("customerId") String customerId, @Param("status")String status,@Param("customerId") String customerId,
@Param("subCount")Integer subCount); @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<GridAndOrgCategoryCountResultDTO> selectOrgCategoryProjectCount(@Param("dateId") String dateId, @Param("status")String status,
@Param("customerId") String customerId, @Param("subCount")Integer subCount,
@Param("allAgencies") List<GridAndOrgCategoryCountResultDTO> allAgencies);
} }

70
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.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.PingYinConstant;
import com.epmet.constant.ProjectConstant; 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.ScreenProjectCategoryGridDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao;
import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao;
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO;
import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO;
import com.epmet.entity.crm.CustomerRelationEntity; import com.epmet.entity.crm.CustomerRelationEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity; import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryGridDailyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity;
import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService; import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridAndOrgDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService; import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryGridDailyService;
import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
@ -45,7 +50,11 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr
@Autowired @Autowired
private ScreenProjectCategoryGridDailyService gridDailyService; private ScreenProjectCategoryGridDailyService gridDailyService;
@Autowired @Autowired
private ScreenProjectCategoryOrgDailyService orgDailyService;
@Autowired
private ScreenProjectCategoryOrgDailyDao orgDailyDao; private ScreenProjectCategoryOrgDailyDao orgDailyDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
/** /**
* @Description 分类下的项目数grid * @Description 分类下的项目数grid
@ -110,6 +119,8 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr
/** /**
* @Description 分类下的项目数org * @Description 分类下的项目数org
* 项目分类来源
* 本级直接立项 + 下级 + 直属网格
* @param customerId * @param customerId
* @param dateId * @param dateId
* @author zxc * @author zxc
@ -120,5 +131,64 @@ public class ScreenProjectCategoryGridAndOrgDailyServiceImpl implements ScreenPr
List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId);
List<String> customerIds = new ArrayList<>(); List<String> customerIds = new ArrayList<>();
customerIds.add(customerId); customerIds.add(customerId);
List<GridAndOrgCategoryCountResultDTO> result = new ArrayList<>();
if (CollectionUtils.isEmpty(relationInfo)){
// one customer
List<ScreenProjectOrgDailyDTO> agencies = screenCustomerAgencyDao.selectAgencyByCustomer(customerId);
List<GridAndOrgCategoryCountResultDTO> allAgencies = ConvertUtils.sourceToTarget(agencies, GridAndOrgCategoryCountResultDTO.class);
result = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.FOUR, allAgencies);
List<GridAndOrgCategoryCountResultDTO> 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<String> 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<GridAndOrgCategoryCountResultDTO> allAgencies = screenCustomerAgencyDao.selectParentSonAgency(subCustomerIds, PingYinConstant.KONG_CUN_CUSTOMER_ID);
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(allAgencies, NumConstant.FIFTY);
List<GridAndOrgCategoryCountResultDTO> allOrgCategoryList = result;
partition.forEach(p -> {
List<GridAndOrgCategoryCountResultDTO> allOrgList = screenProjectDataDao.selectOrgCategoryProjectCount(dateId, ProjectConstant.PROJECT_STATUS_ALL, customerId, NumConstant.TWO, p);
List<GridAndOrgCategoryCountResultDTO> 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<GridAndOrgCategoryCountResultDTO> needInsert){
List<List<GridAndOrgCategoryCountResultDTO>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
orgDailyService.insertBatch(ConvertUtils.sourceToTarget(p, ScreenProjectCategoryOrgDailyEntity.class));
log.info("插入的组织项目分类为" + JSON.toJSONString(p));
});
} }
} }

25
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -505,4 +505,29 @@
AND customer_id = #{customerId} AND customer_id = #{customerId}
</select> </select>
<!-- 查询父子客户的组织【平阴】 -->
<select id="selectParentSonAgency" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
`LEVEL` AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID IN
<foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c}
</foreach>
UNION ALL
SELECT
AGENCY_ID AS orgId,
PID,
REPLACE(PIDS,',',':') AS pids,
CASE WHEN `LEVEL` = 'district' THEN 'street' ELSE `LEVEL` END AS orgType
FROM screen_customer_agency
WHERE DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND `LEVEL` != 'street'
</select>
</mapper> </mapper>

62
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml

@ -270,6 +270,7 @@
a.CREATED_TIME ASC a.CREATED_TIME ASC
</select> </select>
<!-- 查询网格下的项目分类 -->
<select id="selectGridCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO"> <select id="selectGridCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
SELECT SELECT
#{dateId} AS dateId, #{dateId} AS dateId,
@ -292,8 +293,9 @@
<foreach collection="customerIds" item="c" separator="," open="(" close=")"> <foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c} #{c}
</foreach> </foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') = #{dateId} AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid' AND pd.ORG_TYPE = 'grid'
AND pc.level = 2
<if test=' status = "closed" '> <if test=' status = "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case') AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if> </if>
@ -320,11 +322,67 @@
<foreach collection="customerIds" item="c" separator="," open="(" close=")"> <foreach collection="customerIds" item="c" separator="," open="(" close=")">
#{c} #{c}
</foreach> </foreach>
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') = #{dateId} AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND pd.ORG_TYPE = 'grid' AND pd.ORG_TYPE = 'grid'
<if test=' status = "closed" '> <if test=' status = "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case') AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if> </if>
GROUP BY pd.ORG_ID,categoryCode GROUP BY pd.ORG_ID,categoryCode
</select> </select>
<!-- 查询组织下的项目分类 -->
<select id="selectOrgCategoryProjectCount" resultType="com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO">
<foreach collection="allAgencies" item="a" separator=" UNION ALL ">
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
pc.CATEGORY_CODE,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status = "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
<if test=' status = "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND pc.level = 2
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE #{a.orgId}
<if test=' status = "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY pc.CATEGORY_CODE
UNION ALL
SELECT
#{dateId} AS dateId,
#{customerId} AS customerId,
left(pc.CATEGORY_CODE, #{subCount}) AS categoryCode,
#{a.orgId} AS orgId,
#{a.pid} AS pid,
#{a.pids} AS pids,
#{a.orgType} AS orgType,
pc.`LEVEL`,
<if test=' status = "closed" '>
COUNT(DISTINCT pc.PROJECT_ID) AS projectTotal
</if>
<if test=' status = "all" '>
COUNT(DISTINCT pc.PROJECT_ID) AS closedProjectTotal
</if>
FROM screen_project_data pd
LEFT JOIN screen_project_category pc ON (pc.PROJECT_ID = pd.PROJECT_ID AND pc.DEL_FLAG = '0')
WHERE pd.DEL_FLAG = '0'
AND DATE_FORMAT(pd.PROJECT_CREATE_TIME,'%Y%m%d') <![CDATA[ <= ]]> #{dateId}
AND ALL_PARENT_IDS LIKE #{a.orgId}
<if test=' status = "closed" '>
AND pd.PROJECT_STATUS_CODE IN ('closed','closed_case')
</if>
GROUP BY categoryCode
</foreach>
</select>
</mapper> </mapper>

Loading…
Cancel
Save