Browse Source

指数年表、月表逻辑修改

dev_shibei_match
zhangyongzhangyong 5 years ago
parent
commit
300c001ef9
  1. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  2. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  3. 62
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  4. 32
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  5. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -56,14 +56,14 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
void batchInsertCustomerAgency(@Param("list") List<CustomerAgencyFormDTO> list, @Param("customerId")String customerId);
/**
* 返回当前客户下未匹配到的组织信息
* 返回当前客户下未匹配到的 社区级 组织信息
* @param customerId 客户id
* @param agencyIds 组织id集合
* @return java.util.List<com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity>
* @Author zhangyong
* @Date 14:38 2020-09-04
**/
List<ScreenCustomerAgencyEntity> selectListMismatcAgencyInfo(@Param("customerId")String customerId, @Param("agencyIds") String[] agencyIds);
List<ScreenCustomerAgencyEntity> selectListMismatcCommunityAgencyInfo(@Param("customerId")String customerId, @Param("agencyIds") String[] agencyIds);
/**
* 根据客户id查询区/街道 组织名称id
@ -82,4 +82,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @date 2020/9/8 3:36 下午
*/
String selectPid(@Param("agencyId")String agencyId);
/**
* 返回当前客户下未匹配到的 街道区县级 组织信息
* @param customerId 客户id
* @param agencyIds 组织id集合
* @return java.util.List<com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity>
* @Author zhangyong
* @Date 14:38 2020-09-04
**/
List<ScreenCustomerAgencyEntity> selectListMismatcStreetAndDistrictAgencyInfo(@Param("customerId")String customerId, @Param("agencyIds") String[] agencyIds);
}

15
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java

@ -80,4 +80,19 @@ public interface ScreenIndexDataMonthlyDao extends BaseDao<ScreenIndexDataMonthl
**/
Integer selectCountIndexDataMonthly(@Param("customerId") String customerId,
@Param("yearId") String yearId);
/**
* 批量删除月表数据
* 根据CUSTOMER_IDMONTH_IDORG_TYPE进行查询如果有数据则先进行物理删除, 一次删除1000条
*
* @param customerId
* @param monthId
* @param orgType
* @return java.util.Integer
* @Author zhangyong
* @Date 10:52 2020-08-18
**/
Integer deleteIndexDataMonthlyByOrgType(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("orgType") String orgType);
}

62
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

@ -198,12 +198,22 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
if (NumConstant.SIX != monthId.length()){
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId);
}
// 根据网格类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.GRID);
// 开始处理 网格相关分值表
this.startHandleIndexGridScore(monthId, customerId);
// 根据组织类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.AGENCY);
// 开始处理 社区相关分值表
this.startHandleIndexCommunityScore(monthId, customerId);
// 根据部门类型,删除 指数-指数数据(每月数值)表中 匹配的数据
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.DEPARTMENT);
// 开始处理 区直部门分值表
this.startHandleIndexDeptScore(monthId, customerId);
// 同样是 组织类型,所以不再重复删除了
// 开始处理 区/街道相关分数表
this.startHandleIndexAgencyScore(monthId, customerId);
@ -236,16 +246,15 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
} else {
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null);
}
boolean delFlag = true;
if (!CollectionUtils.isEmpty(mismatchGridList)){
// 如果进行不匹配查询,查到了其他网格信息,一律赋默认值
this.insertIndexMonthlyByGridDefaultScore(monthId, customerId, mismatchGridList);
delFlag = false;
}
// fact_index_grid_score 网格相关分值记录表 grid
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId);
// 开始处理实际分数
this.insertIndexDataMonthlyByGridScore(delFlag, monthId, customerId, gridScoreDTOS);
this.insertIndexDataMonthlyByGridScore(monthId, customerId, gridScoreDTOS);
}
/**
@ -272,17 +281,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
int deleteNum;
do {
deleteNum = screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId,monthId);
} while (deleteNum > NumConstant.ZERO);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 将网格相关分值记录表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param delFlag true: 执行删除语句false已经删过一次了本次只添加不删除
* @param monthId 202008
* @param customerId 客户id
* @param gridScoreDTOS 网格相关分值记录表 当前客户所属月份数据集
@ -290,7 +294,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByGridScore(boolean delFlag, String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){
private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId));
@ -333,12 +337,6 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
if (delFlag){
int deleteNum;
do {
deleteNum = screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId,monthId);
} while (deleteNum > NumConstant.ZERO);
}
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
}
@ -363,11 +361,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
for (int i = NumConstant.ZERO; i < indexCommunityIds.size(); i++){
communityIds[i] = indexCommunityIds.get(i);
}
// 进行不匹配查询(即返回社区相关分值表 中不存在的社区信息)。
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, communityIds);
// 进行不匹配查询(即返回社区相关分值表 中不存在的社区级】 组织信息)。
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, communityIds);
} else {
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchAgencyList)){
// 如果进行不匹配查询,查到了其他社区信息,一律赋默认值
this.insertIndexMonthlyByAgencyDefaultScore(monthId, customerId, mismatchAgencyList);
@ -399,7 +398,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyDTO.setServiceAblity(zero);
monthlyDTO.setGovernAblity(zero);
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, communityScoreDTOS.get(i).getAgencyId(),
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(),
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
@ -487,6 +486,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
} else {
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchDeptList)){
// 如果进行不匹配查询,查到了其他部门信息,一律赋默认值
this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList);
@ -518,7 +518,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyDTO.setServiceAblity(zero);
monthlyDTO.setGovernAblity(zero);
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, deptScoreDTOS.get(i).getDeptId(),
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(),
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
@ -592,10 +592,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
for (int i = NumConstant.ZERO; i < indexAgencyIds.size(); i++){
agencyIds[i] = indexAgencyIds.get(i);
}
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencyIds);
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, agencyIds);
} else {
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchAgencyList)){
this.insertIndexMonthlyByAgencyDefaultScore(monthId, customerId, mismatchAgencyList);
}
@ -770,4 +771,21 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
private String getMonthStr(String monthId){
return monthId.substring(NumConstant.FOUR, NumConstant.SIX);
}
/**
* 批量删除 指数-指数数据(每月数值) 表数据
*
* @param customerId
* @param monthId 202008
* @param orgType 组织类别 agency组织部门department网格grid
* @return void
* @Author zhangyong
* @Date 09:55 2020-09-12
**/
private void batchDelIndexDataMonthly( String customerId, String monthId, String orgType){
int deleteNum;
do {
deleteNum = screenIndexDataMonthlyDao.deleteIndexDataMonthlyByOrgType(customerId, monthId, orgType);
} while (deleteNum > NumConstant.ZERO);
}
}

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

@ -57,7 +57,7 @@
</foreach>
</insert>
<select id="selectListMismatcAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
<select id="selectListMismatcCommunityAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
AGENCY_ID agencyId,
AGENCY_NAME agencyName,
@ -69,6 +69,7 @@
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
AND `LEVEL` = 'community'
<if test="agencyIds != null and agencyIds!= ''">
AND AGENCY_ID NOT IN
<foreach item="item" collection="agencyIds" open="(" separator="," close=")">
@ -98,4 +99,33 @@
del_flag = '0'
AND agency_id = #{agencyId}
</select>
<select id="selectListMismatcStreetAndDistrictAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
agencyId,
agencyName,
pid,
pids,
`level`
FROM(
SELECT
AGENCY_ID agencyId,
AGENCY_NAME agencyName,
PID pid,
PIDS pids,
`LEVEL` `level`
FROM
screen_customer_agency
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND (`LEVEL` = 'street' OR `LEVEL` = 'district')
) agency
<if test="agencyIds != null and agencyIds!= ''">
WHERE agencyId NOT IN
<foreach item="item" collection="agencyIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

@ -87,4 +87,10 @@
AND CUSTOMER_ID = #{customerId}
) monthCount
</select>
<delete id="deleteIndexDataMonthlyByOrgType">
delete from screen_index_data_monthly
where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType}
limit 1000;
</delete>
</mapper>

Loading…
Cancel
Save