|
|
@ -18,6 +18,7 @@ import com.epmet.dao.evaluationindex.indexcoll.*; |
|
|
|
import com.epmet.dao.evaluationindex.screen.*; |
|
|
|
import com.epmet.dto.ScreenCustomerGridDTO; |
|
|
|
import com.epmet.dto.indexcal.AgencyScoreDTO; |
|
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
|
import com.epmet.dto.indexcal.DeptScoreDTO; |
|
|
|
import com.epmet.dto.indexcollect.form.*; |
|
|
|
import com.epmet.dto.screen.FactIndexCommunityScoreDTO; |
|
|
@ -44,7 +45,6 @@ import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -225,9 +225,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @date 2020/10/20 2:59 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId) { |
|
|
|
if (NumConstant.SIX != monthId.length()) { |
|
|
|
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId); |
|
|
|
public void insertScreenIndexDataMonthlyAndYearly(CalculateCommonFormDTO formDTO) { |
|
|
|
if (NumConstant.SIX != formDTO.getMonthId().length()) { |
|
|
|
throw new RuntimeException("入参monthId格式不正确:monthId =" + formDTO.getMonthId()); |
|
|
|
} |
|
|
|
RLock lock = distributedLock.getLock(LockConstants.STATS_LOCK_NAME); |
|
|
|
try { |
|
|
@ -236,26 +236,27 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
} |
|
|
|
allParentIds.cleanUp(); |
|
|
|
// 根据网格类型,删除 指数-指数数据(每月数值)表中 匹配的数据
|
|
|
|
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.GRID); |
|
|
|
this.batchDelIndexDataMonthly(formDTO.getCustomerId(), formDTO.getMonthId(), OrgTypeConstant.GRID); |
|
|
|
// 开始处理 网格相关分值表
|
|
|
|
this.startHandleIndexGridScore(monthId, customerId); |
|
|
|
this.startHandleIndexGridScore(formDTO); |
|
|
|
|
|
|
|
// 根据组织类型,删除 指数-指数数据(每月数值)表中 匹配的数据
|
|
|
|
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.AGENCY); |
|
|
|
this.batchDelIndexDataMonthly(formDTO.getCustomerId(), formDTO.getMonthId(), OrgTypeConstant.AGENCY); |
|
|
|
// 开始处理 社区相关分值表
|
|
|
|
this.startHandleIndexCommunityScore(monthId, customerId); |
|
|
|
this.startHandleIndexCommunityScore(formDTO); |
|
|
|
|
|
|
|
// 根据部门类型,删除 指数-指数数据(每月数值)表中 匹配的数据
|
|
|
|
this.batchDelIndexDataMonthly(customerId, monthId, OrgTypeConstant.DEPARTMENT); |
|
|
|
this.batchDelIndexDataMonthly(formDTO.getCustomerId(), formDTO.getMonthId(), OrgTypeConstant.DEPARTMENT); |
|
|
|
// 开始处理 区直部门分值表
|
|
|
|
this.startHandleIndexDeptScore(monthId, customerId); |
|
|
|
this.startHandleIndexDeptScore(formDTO); |
|
|
|
|
|
|
|
// 同样是 组织类型,所以不再重复删除了
|
|
|
|
// 开始处理 区/街道相关分数表
|
|
|
|
this.startHandleIndexAgencyScore(monthId, customerId); |
|
|
|
//todo
|
|
|
|
this.startHandleIndexAgencyScore(formDTO); |
|
|
|
|
|
|
|
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
|
|
|
|
this.insertIndexDataYear(monthId, customerId); |
|
|
|
this.insertIndexDataYear(formDTO.getMonthId(), formDTO.getCustomerId()); |
|
|
|
allParentIds.invalidateAll(); |
|
|
|
} finally { |
|
|
|
distributedLock.unLock(lock); |
|
|
@ -266,13 +267,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* 目标:将网格的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果网格相关分值表 中的网格数量不全,需要从 网格(党支部)信息表 中,先查询到缺少的网格信息,赋上默认值后,插入 指数-指数数据(月表) |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexGridScore(String monthId, String customerId){ |
|
|
|
private void startHandleIndexGridScore(CalculateCommonFormDTO formDTO){ |
|
|
|
String customerId=formDTO.getCustomerId(); |
|
|
|
String monthId=formDTO.getMonthId(); |
|
|
|
List<ScreenCustomerGridDTO> mismatchGridList = new ArrayList<>(); |
|
|
|
// 查询网格相关分值记录 表已经存在的网格id
|
|
|
|
List<String> indexGridIds = factIndexGridScoreDao.selectListGridId(customerId, monthId); |
|
|
@ -283,9 +284,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
gridIds[i] = indexGridIds.get(i); |
|
|
|
} |
|
|
|
// 进行不匹配查询(即返回网格相关分值表 中不存在的网格信息)。
|
|
|
|
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, gridIds); |
|
|
|
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, gridIds,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} else { |
|
|
|
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null); |
|
|
|
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(mismatchGridList)){ |
|
|
@ -295,7 +296,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// fact_index_grid_score 网格相关分值记录表 grid
|
|
|
|
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId); |
|
|
|
// 开始处理实际分数
|
|
|
|
this.insertIndexDataMonthlyByGridScore(monthId, customerId, gridScoreDTOS); |
|
|
|
this.insertIndexDataMonthlyByGridScore(monthId, customerId, gridScoreDTOS,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -340,12 +341,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS) { |
|
|
|
private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS,String customerAreaCode,List<String> subCustomerIds) { |
|
|
|
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); |
|
|
|
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
|
|
|
|
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId)); |
|
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
|
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId); |
|
|
|
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId,customerAreaCode,subCustomerIds); |
|
|
|
if (!CollectionUtils.isEmpty(parentGridList)) { |
|
|
|
parentGridList.forEach(o -> { |
|
|
|
allParentIds.put(o.getGridId(), o.getAllParentIds()); |
|
|
@ -399,13 +400,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* 目标:将社区的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果社区相关分值表 中的社区数量不全,需要从 组织机构信息 中,先查询到缺少的社区信息,赋上默认值后,在插入 指数-指数数据(月表) |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexCommunityScore(String monthId, String customerId){ |
|
|
|
private void startHandleIndexCommunityScore(CalculateCommonFormDTO formDTO){ |
|
|
|
String customerId=formDTO.getCustomerId(); |
|
|
|
String monthId=formDTO.getMonthId(); |
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = new ArrayList<>(); |
|
|
|
// 查询社区相关分值记录id
|
|
|
|
List<String> indexCommunityIds = factIndexCommunityScoreDao.selectListCommunityId(customerId, monthId); |
|
|
@ -416,9 +417,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
communityIds[i] = indexCommunityIds.get(i); |
|
|
|
} |
|
|
|
// 进行不匹配查询(即返回社区相关分值表 中不存在的【社区级】 组织信息)。
|
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, communityIds); |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, communityIds,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} else { |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, null); |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcCommunityAgencyInfo(customerId, null,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(mismatchAgencyList)){ |
|
|
@ -429,7 +430,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 查询社区相关分值记录
|
|
|
|
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId); |
|
|
|
// 开始处理实际分数
|
|
|
|
this.insertIndexDataMonthlyByCommunityScore(monthId, customerId, communityScoreDTOS); |
|
|
|
this.insertIndexDataMonthlyByCommunityScore(monthId, customerId, communityScoreDTOS,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -474,12 +475,14 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByCommunityScore(String monthId, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS) { |
|
|
|
private void insertIndexDataMonthlyByCommunityScore(String monthId, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS, |
|
|
|
String customerAreaCode, |
|
|
|
List<String> subCustomerIds) { |
|
|
|
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); |
|
|
|
// 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据
|
|
|
|
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); |
|
|
|
// 根据客户id,查询区/街道 组织名称、id
|
|
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId,customerAreaCode,subCustomerIds); |
|
|
|
if (!CollectionUtils.isEmpty(parentAgencyList)) { |
|
|
|
parentAgencyList.forEach(o -> { |
|
|
|
allParentIds.put(o.getAgencyId(), o.getPids()); |
|
|
@ -534,13 +537,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* 目标:将区直部门的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果 区直部门分值表 中的部门数量不全,需要从 部门信息表 中,先查询到缺少的部门信息,赋上默认值后,在插入 指数-指数数据(月表) |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexDeptScore(String monthId, String customerId){ |
|
|
|
private void startHandleIndexDeptScore(CalculateCommonFormDTO formDTO){ |
|
|
|
String customerId=formDTO.getCustomerId(); |
|
|
|
String monthId=formDTO.getMonthId(); |
|
|
|
List<ScreenCustomerDeptEntity> mismatchDeptList = new ArrayList<>(); |
|
|
|
// 查询社 区直部门分值表
|
|
|
|
List<String> indexDeptIds = deptScoreDao.selectListDeptId(customerId, monthId); |
|
|
@ -549,9 +552,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
for (int i = NumConstant.ZERO; i < indexDeptIds.size(); i++){ |
|
|
|
depeIds[i] = indexDeptIds.get(i); |
|
|
|
} |
|
|
|
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, depeIds); |
|
|
|
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, depeIds,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} else { |
|
|
|
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null); |
|
|
|
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(mismatchDeptList)) { |
|
|
@ -568,7 +571,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 查询社 区直部门分值表
|
|
|
|
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId); |
|
|
|
// 开始处理实际分数
|
|
|
|
this.insertIndexDataMonthlyByDeptScore(monthId, customerId, deptScoreDTOS); |
|
|
|
this.insertIndexDataMonthlyByDeptScore(monthId, customerId, deptScoreDTOS,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -613,11 +616,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByDeptScore(String monthId, String customerId, List<DeptScoreDTO> deptScoreDTOS){ |
|
|
|
private void insertIndexDataMonthlyByDeptScore(String monthId, String customerId, List<DeptScoreDTO> deptScoreDTOS, |
|
|
|
String customerAreaCode, |
|
|
|
List<String> subCustomerIds){ |
|
|
|
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); |
|
|
|
// 根据部门id 进行分组,最后组装一条数据 一个部门id 对应 4条数据
|
|
|
|
Map<String, List<DeptScoreDTO>> collect = deptScoreDTOS.stream().collect(Collectors.groupingBy(DeptScoreDTO::getDeptId)); |
|
|
|
List<ScreenCustomerDeptEntity> parentDeptList = screenCustomerDeptDao.selectListDeptInfo(customerId); |
|
|
|
List<ScreenCustomerDeptEntity> parentDeptList = screenCustomerDeptDao.selectListDeptInfo(customerId,customerAreaCode,subCustomerIds); |
|
|
|
for(Map.Entry<String,List<DeptScoreDTO>> deptScore : collect.entrySet()){ |
|
|
|
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); |
|
|
|
// 给4个指数 赋默认值
|
|
|
@ -666,13 +671,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* 目标:将 区/街道的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果 区/街道相关分数表 中的组织数量不全,需要从 组织机构信息 中,先查询到缺少的组织信息,赋上默认值后,在插入 区/街道相关分数表。 一对四 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexAgencyScore(String monthId, String customerId){ |
|
|
|
private void startHandleIndexAgencyScore(CalculateCommonFormDTO formDTO){ |
|
|
|
String customerId=formDTO.getCustomerId(); |
|
|
|
String monthId=formDTO.getMonthId(); |
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = new ArrayList<>(); |
|
|
|
List<String> indexAgencyIds = agencyScoreDaol.selectListAgencyId(customerId, monthId); |
|
|
|
if (indexAgencyIds.size() > NumConstant.ZERO){ |
|
|
@ -680,9 +685,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
for (int i = NumConstant.ZERO; i < indexAgencyIds.size(); i++){ |
|
|
|
agencyIds[i] = indexAgencyIds.get(i); |
|
|
|
} |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, agencyIds); |
|
|
|
//todo 平阴县areaCode重复
|
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, agencyIds,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} else { |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, null); |
|
|
|
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcStreetAndDistrictAgencyInfo(customerId, null,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(mismatchAgencyList)){ |
|
|
@ -691,7 +697,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// fact_index_agency_score 区/街道相关分数表 agency
|
|
|
|
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId); |
|
|
|
// 开始处理实际分数
|
|
|
|
this.insertIndexDataMonthlyByAgencyScore(monthId, customerId, agencyScoreDTOS); |
|
|
|
this.insertIndexDataMonthlyByAgencyScore(monthId, customerId, agencyScoreDTOS,formDTO.getCustomerAreaCode(),formDTO.getSubCustomerIds()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -704,11 +710,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByAgencyScore(String monthId, String customerId, List<AgencyScoreDTO> agencyScoreDTOS) { |
|
|
|
private void insertIndexDataMonthlyByAgencyScore(String monthId, String customerId, List<AgencyScoreDTO> agencyScoreDTOS, |
|
|
|
String customerAreaCode, |
|
|
|
List<String> subCustomerIds) { |
|
|
|
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); |
|
|
|
// 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据
|
|
|
|
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); |
|
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId,customerAreaCode,subCustomerIds); |
|
|
|
int j = 0; |
|
|
|
if (!CollectionUtils.isEmpty(parentAgencyList)) { |
|
|
|
parentAgencyList.forEach(o -> { |
|
|
|