|
|
@ -1,7 +1,10 @@ |
|
|
|
package com.epmet.service.evaluationindex.indexcoll.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; |
|
|
@ -15,10 +18,17 @@ import com.epmet.dto.indexcollect.form.*; |
|
|
|
import com.epmet.dto.screen.FactIndexCommunityScoreDTO; |
|
|
|
import com.epmet.dto.screen.FactIndexGridScoreDTO; |
|
|
|
import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO; |
|
|
|
import com.epmet.dto.screencoll.form.IndexDataYearlyFormDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; |
|
|
|
import com.epmet.eum.IndexCodeEnum; |
|
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -38,6 +48,7 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
|
public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(FactIndexCollectServiceImpl.class); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; |
|
|
@ -207,51 +218,71 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
if (NumConstant.SIX != monthId.length()){ |
|
|
|
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId); |
|
|
|
} |
|
|
|
String year = monthId.substring(NumConstant.ZERO, NumConstant.FOUR); |
|
|
|
String month = monthId.substring(NumConstant.FOUR, NumConstant.SIX); |
|
|
|
// 开始处理 网格相关分值表
|
|
|
|
this.startHandleIndexGridScore(monthId, customerId); |
|
|
|
// 开始处理 社区相关分值表
|
|
|
|
this.startHandleIndexCommunityScore(monthId, customerId); |
|
|
|
// 开始处理 区直部门分值表
|
|
|
|
this.startHandleIndexDeptScore(monthId, customerId); |
|
|
|
// 开始处理 区/街道相关分数表
|
|
|
|
this.startHandleIndexAgencyScore(monthId, customerId); |
|
|
|
|
|
|
|
// fact_index_grid_score 网格相关分值记录表 grid
|
|
|
|
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId); |
|
|
|
if (null != gridScoreDTOS && gridScoreDTOS.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexDataMonthlyByGridScore(month, year, customerId, gridScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
// fact_index_community_score 社区相关分数表 agency
|
|
|
|
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId); |
|
|
|
if (null != communityScoreDTOS && communityScoreDTOS.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexDataMonthlyByCommunityScore(month, year, customerId, communityScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
// fact_index_dept_score 区直部门分值表 department
|
|
|
|
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId); |
|
|
|
if (null != deptScoreDTOS && deptScoreDTOS.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexDataMonthlyByDeptScore(month, year, customerId, deptScoreDTOS); |
|
|
|
} |
|
|
|
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
|
|
|
|
this.insertIndexDataYear(monthId, customerId); |
|
|
|
} |
|
|
|
|
|
|
|
// fact_index_agency_score 区/街道相关分数表 agency
|
|
|
|
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId); |
|
|
|
if (null != agencyScoreDTOS && agencyScoreDTOS.size() > NumConstant.ZERO) { |
|
|
|
this.insertIndexDataMonthlyByAgencyScore(month, year, customerId, agencyScoreDTOS); |
|
|
|
/** |
|
|
|
* 目标:将网格的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果网格相关分值表 中的网格数量不全,需要从 网格(党支部)信息表 中,先查询到缺少的网格信息,赋上默认值后,在插入网格相关分值表。 一对四 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexGridScore(String monthId, String customerId){ |
|
|
|
// 查询网格相关分值记录 表已经存在的网格id
|
|
|
|
List<String> indexGridIds = factIndexGridScoreDao.selectListGridId(customerId, monthId); |
|
|
|
if (indexGridIds.size() > NumConstant.ZERO){ |
|
|
|
// 根据网格相关分值表 中查询到的网格id,去 网格(党支部)信息表 进行不匹配查询。
|
|
|
|
String[] gridIds = new String[indexGridIds.size()]; |
|
|
|
for (int i = NumConstant.ZERO; i < indexGridIds.size(); i++){ |
|
|
|
gridIds[i] = indexGridIds.get(i); |
|
|
|
} |
|
|
|
// 进行不匹配查询(即返回网格相关分值表 中不存在的网格信息)。
|
|
|
|
List<ScreenCustomerGridDTO> mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, gridIds); |
|
|
|
// 将 网格相关分值表 中,本月份没有的网格信息,按照 4种类型,各新增一遍,赋默认值 0
|
|
|
|
if (mismatchGridList.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 将所有的网格按照 4种类型,各赋一遍默认值
|
|
|
|
List<ScreenCustomerGridDTO> mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null); |
|
|
|
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList); |
|
|
|
} |
|
|
|
|
|
|
|
// 插入年表 screen_index_data_yearly
|
|
|
|
// 开始处理实际分数
|
|
|
|
// fact_index_grid_score 网格相关分值记录表 grid
|
|
|
|
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId); |
|
|
|
this.insertIndexDataMonthlyByGridScore(monthId, customerId, gridScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将网格相关分值记录表 数据 插入月表 screenIndexDataMonthlyDao |
|
|
|
* |
|
|
|
* @param month 08 |
|
|
|
* @param year 2020 |
|
|
|
* @param monthId 202008 |
|
|
|
* @param customerId 客户id |
|
|
|
* @param gridScoreDTOS 网格相关分值记录表 当前客户所属月份数据集 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByGridScore(String month, String year, 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)); |
|
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
|
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId); |
|
|
|
String[] orgIds = new String[collect.size()]; |
|
|
|
int j = 0; |
|
|
|
for(Map.Entry<String,List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()){ |
|
|
@ -259,6 +290,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 网格id
|
|
|
|
orgIds[j] = gridScore.getKey(); |
|
|
|
j++; |
|
|
|
// 给4个指数 赋默认值
|
|
|
|
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); |
|
|
|
for ( int i = 0; i < gridScore.getValue().size(); i++){ |
|
|
|
if (NumConstant.ONE_STR.equals(gridScore.getValue().get(i).getIsTotal())){ |
|
|
|
// 是总分
|
|
|
@ -267,41 +300,88 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
monthlyFormDTO.setIndexTotal(gridScore.getValue().get(i).getScore()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 赋值 党建能力、治理能力、服务能力
|
|
|
|
monthlyFormDTO = this.setValueAblityMonthlyFor(gridScore.getValue().get(i).getIndexCode(), |
|
|
|
// 赋实际值 党建能力、治理能力、服务能力
|
|
|
|
monthlyFormDTO = this.setValueAbilityMonthlyFor(gridScore.getValue().get(i).getIndexCode(), |
|
|
|
gridScore.getValue().get(i).getScore(), |
|
|
|
monthlyFormDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
|
ScreenCustomerGridDTO parentGridInfo = screenCustomerGridDao.selectParentGridInfo(customerId, gridScore.getKey()); |
|
|
|
if (null == parentGridInfo){ |
|
|
|
// 匹配网格的 上级组织id 和 组织名称
|
|
|
|
String parentAgencyId = ""; |
|
|
|
String gridName = ""; |
|
|
|
for (ScreenCustomerGridDTO gridDTO : parentGridList){ |
|
|
|
if (gridScore.getKey().equals(gridDTO.getGridId())){ |
|
|
|
parentAgencyId = gridDTO.getParentAgencyId(); |
|
|
|
gridName = gridDTO.getGridName(); |
|
|
|
} |
|
|
|
} |
|
|
|
if ("".equals(parentAgencyId)){ |
|
|
|
throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey()); |
|
|
|
} |
|
|
|
// 补充表中其他字段
|
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, gridScore.getKey(), |
|
|
|
parentGridInfo.getParentAgencyId(), parentGridInfo.getGridName(), monthlyFormDTO); |
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(), |
|
|
|
parentAgencyId, gridName, monthlyFormDTO); |
|
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
|
} |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, getYearStr(monthId), monthId, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 目标:将社区的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果社区相关分值表 中的社区数量不全,需要从 组织机构信息 中,先查询到缺少的社区信息,赋上默认值后,在插入社区相关分值表。 一对四 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexCommunityScore(String monthId, String customerId){ |
|
|
|
// 查询社区相关分值记录id
|
|
|
|
List<String> indexCommunityIds = factIndexCommunityScoreDao.selectListCommunityId(customerId, monthId); |
|
|
|
if (indexCommunityIds.size() > NumConstant.ZERO){ |
|
|
|
// 根据社区相关分值表 中查询到的社区id,去 组织机构信息 进行不匹配查询。
|
|
|
|
String[] communityIds = new String[indexCommunityIds.size()]; |
|
|
|
for (int i = NumConstant.ZERO; i < indexCommunityIds.size(); i++){ |
|
|
|
communityIds[i] = indexCommunityIds.get(i); |
|
|
|
} |
|
|
|
// 进行不匹配查询(即返回社区相关分值表 中不存在的社区信息)。
|
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, communityIds); |
|
|
|
// 将 社区相关分数表 中,本月份没有的社区信息,按照 4种类型,各新增一遍,赋默认值 0
|
|
|
|
if (mismatchAgencyList.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 将所有的社区按照 4种类型,各赋一遍默认值
|
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null); |
|
|
|
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList); |
|
|
|
} |
|
|
|
// 开始处理实际分数
|
|
|
|
// fact_index_community_score 社区相关分数表 agency
|
|
|
|
// 查询社区相关分值记录
|
|
|
|
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId); |
|
|
|
this.insertIndexDataMonthlyByCommunityScore(monthId, customerId, communityScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 社区相关分数表 数据 插入月表 screenIndexDataMonthlyDao |
|
|
|
* |
|
|
|
* @param month 08 |
|
|
|
* @param year 2020 |
|
|
|
* @param monthId 202008 |
|
|
|
* @param customerId 客户id |
|
|
|
* @param communityScoreDTOS 社区相关分数表 当前客户所属月份数据集 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByCommunityScore(String month, String year, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS){ |
|
|
|
private void insertIndexDataMonthlyByCommunityScore(String monthId, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS){ |
|
|
|
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); |
|
|
|
String[] orgIds = new String[collect.size()]; |
|
|
|
int j = 0; |
|
|
|
for(Map.Entry<String,List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()){ |
|
|
@ -309,6 +389,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 组织id
|
|
|
|
orgIds[j] = communityScore.getKey(); |
|
|
|
j++; |
|
|
|
// 给4个指数 赋默认值
|
|
|
|
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); |
|
|
|
for ( int i = 0; i < communityScore.getValue().size(); i++){ |
|
|
|
if (NumConstant.ONE_STR.equals(communityScore.getValue().get(i).getIsTotal())){ |
|
|
|
// 是总分
|
|
|
@ -318,7 +400,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 赋值 党建能力、治理能力、服务能力
|
|
|
|
monthlyFormDTO = this.setValueAblityMonthlyFor(communityScore.getValue().get(i).getIndexCode(), |
|
|
|
monthlyFormDTO = this.setValueAbilityMonthlyFor(communityScore.getValue().get(i).getIndexCode(), |
|
|
|
communityScore.getValue().get(i).getScore(), |
|
|
|
monthlyFormDTO); |
|
|
|
} |
|
|
@ -326,36 +408,76 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
|
|
|
|
// 当前组织 的上级组织id
|
|
|
|
String parentAgencyId = communityScore.getValue().get(NumConstant.ZERO).getParentAgencyId(); |
|
|
|
// 查询 组织名称
|
|
|
|
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, communityScore.getKey()); |
|
|
|
if (null == agencyName){ |
|
|
|
// 获取 组织名称
|
|
|
|
String agencyName = ""; |
|
|
|
for (ScreenCustomerAgencyEntity agencyScoreDTO : parentAgencyList) { |
|
|
|
if (communityScore.getKey().equals(agencyScoreDTO.getAgencyId())) { |
|
|
|
agencyName = agencyScoreDTO.getAgencyName(); |
|
|
|
} |
|
|
|
} |
|
|
|
if ("".equals(agencyName)){ |
|
|
|
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey()); |
|
|
|
} |
|
|
|
// 补充表中其他字段
|
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, communityScore.getKey(), |
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(), |
|
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
|
// 补充表中其他字段
|
|
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
|
} |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, getYearStr(monthId), monthId, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 目标:将区直部门的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果 区直部门分值表 中的部门数量不全,需要从 部门信息表 中,先查询到缺少的部门信息,赋上默认值后,在插入 区直部门分值表。 一对四 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexDeptScore(String monthId, String customerId){ |
|
|
|
// 查询社 区直部门分值表
|
|
|
|
List<String> indexDeptIds = deptScoreDao.selectListDeptId(customerId, monthId); |
|
|
|
if (indexDeptIds.size() > NumConstant.ZERO){ |
|
|
|
String[] depeIds = new String[indexDeptIds.size()]; |
|
|
|
for (int i = NumConstant.ZERO; i < indexDeptIds.size(); i++){ |
|
|
|
depeIds[i] = indexDeptIds.get(i); |
|
|
|
} |
|
|
|
List<ScreenCustomerDeptEntity> mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, depeIds); |
|
|
|
if (mismatchDeptList.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexDeptScoreDefaultValueFor(monthId, customerId, mismatchDeptList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<ScreenCustomerDeptEntity> mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null); |
|
|
|
this.insertIndexDeptScoreDefaultValueFor(monthId, customerId, mismatchDeptList); |
|
|
|
} |
|
|
|
// 开始处理实际分数
|
|
|
|
// fact_index_dept_score 区直部门分值表 department
|
|
|
|
// 查询社 区直部门分值表
|
|
|
|
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId); |
|
|
|
this.insertIndexDataMonthlyByDeptScore(monthId, customerId, deptScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将区直部门分值表 数据 插入月表 screenIndexDataMonthlyDao |
|
|
|
* |
|
|
|
* @param month 08 |
|
|
|
* @param year 2020 |
|
|
|
* @param monthId 202008 |
|
|
|
* @param customerId 客户id |
|
|
|
* @param deptScoreDTOS 区直部门分值表 当前客户所属月份数据集 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByDeptScore(String month, String year, String customerId, List<DeptScoreDTO> deptScoreDTOS){ |
|
|
|
private void insertIndexDataMonthlyByDeptScore(String monthId, String customerId, List<DeptScoreDTO> deptScoreDTOS){ |
|
|
|
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); |
|
|
|
String[] orgIds = new String[collect.size()]; |
|
|
|
int j = 0; |
|
|
|
for(Map.Entry<String,List<DeptScoreDTO>> deptScore : collect.entrySet()){ |
|
|
@ -363,46 +485,85 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 部门id
|
|
|
|
orgIds[j] = deptScore.getKey(); |
|
|
|
j++; |
|
|
|
// 给4个指数 赋默认值
|
|
|
|
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); |
|
|
|
for ( int i = 0; i < deptScore.getValue().size(); i++){ |
|
|
|
if (NumConstant.ONE_STR.equals(deptScore.getValue().get(i).getIsTotal())){ |
|
|
|
// 是总分 总指数 = IS_TOTAL = 1
|
|
|
|
monthlyFormDTO.setIndexTotal(deptScore.getValue().get(i).getScore()); |
|
|
|
} else { |
|
|
|
// 赋值 党建能力、治理能力、服务能力
|
|
|
|
monthlyFormDTO = this.setValueAblityMonthlyFor(deptScore.getValue().get(i).getIndexCode(), |
|
|
|
deptScore.getValue().get(i).getScore(), |
|
|
|
monthlyFormDTO); |
|
|
|
} |
|
|
|
// 区直街道的总分 就是 治理能力
|
|
|
|
monthlyFormDTO.setIndexTotal(deptScore.getValue().get(i).getScore()); |
|
|
|
// 赋值 治理能力
|
|
|
|
monthlyFormDTO = this.setValueAbilityMonthlyFor(deptScore.getValue().get(i).getIndexCode(), |
|
|
|
deptScore.getValue().get(i).getScore(), |
|
|
|
monthlyFormDTO); |
|
|
|
} |
|
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
|
ScreenCustomerDeptEntity parentDeptInfo = screenCustomerDeptDao.selectParentDeptInfo(customerId, deptScore.getKey()); |
|
|
|
if (null == parentDeptInfo){ |
|
|
|
String parentAgencyId = ""; |
|
|
|
String deptName = ""; |
|
|
|
for (ScreenCustomerDeptEntity deptEntity : parentDeptList) { |
|
|
|
if (deptScore.getKey().equals(deptEntity.getDeptId())) { |
|
|
|
parentAgencyId = deptEntity.getParentAgencyId(); |
|
|
|
deptName = deptEntity.getDeptName(); |
|
|
|
} |
|
|
|
} |
|
|
|
if ("".equals(parentAgencyId)){ |
|
|
|
throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey()); |
|
|
|
} |
|
|
|
// 补充表中其他字段
|
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, deptScore.getKey(), |
|
|
|
parentDeptInfo.getParentAgencyId(), parentDeptInfo.getDeptName(), monthlyFormDTO); |
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(), |
|
|
|
parentAgencyId, deptName, monthlyFormDTO); |
|
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
|
} |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, getYearStr(monthId), monthId, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 目标:将 区/街道的 党建能力、治理能力、服务能力、总指数 得分。 整理后(4条合1条) 插入 指数-指数数据(月表) |
|
|
|
* 如果 区/街道相关分数表 中的组织数量不全,需要从 组织机构信息 中,先查询到缺少的组织信息,赋上默认值后,在插入 区/街道相关分数表。 一对四 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:44 2020-09-04 |
|
|
|
**/ |
|
|
|
private void startHandleIndexAgencyScore(String monthId, String customerId){ |
|
|
|
List<String> indexAgencyIds = agencyScoreDaol.selectListAgencyId(customerId, monthId); |
|
|
|
if (indexAgencyIds.size() > NumConstant.ZERO){ |
|
|
|
String[] agencyIds = new String[indexAgencyIds.size()]; |
|
|
|
for (int i = NumConstant.ZERO; i < indexAgencyIds.size(); i++){ |
|
|
|
agencyIds[i] = indexAgencyIds.get(i); |
|
|
|
} |
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencyIds); |
|
|
|
if (mismatchAgencyList.size() > NumConstant.ZERO){ |
|
|
|
this.insertIndexAgencyScoreDefaultValueFor(monthId, customerId, mismatchAgencyList); |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null); |
|
|
|
this.insertIndexAgencyScoreDefaultValueFor(monthId, customerId, mismatchAgencyList); |
|
|
|
} |
|
|
|
// 开始处理实际分数
|
|
|
|
// fact_index_agency_score 区/街道相关分数表 agency
|
|
|
|
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId); |
|
|
|
this.insertIndexDataMonthlyByAgencyScore(monthId, customerId, agencyScoreDTOS); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将区/街道相关分数表 数据 插入月表 screenIndexDataMonthlyDao |
|
|
|
* |
|
|
|
* @param month 08 |
|
|
|
* @param year 2020 |
|
|
|
* @param monthId 202008 |
|
|
|
* @param customerId 客户id |
|
|
|
* @param agencyScoreDTOS 区/街道相关分数表 当前客户所属月份数据集 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:17 2020-09-03 |
|
|
|
**/ |
|
|
|
private void insertIndexDataMonthlyByAgencyScore(String month, String year, String customerId, List<AgencyScoreDTO> agencyScoreDTOS){ |
|
|
|
private void insertIndexDataMonthlyByAgencyScore(String monthId, String customerId, List<AgencyScoreDTO> agencyScoreDTOS){ |
|
|
|
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); |
|
|
|
String[] orgIds = new String[collect.size()]; |
|
|
|
int j = 0; |
|
|
|
for(Map.Entry<String,List<AgencyScoreDTO>> agencyScore : collect.entrySet()){ |
|
|
@ -410,13 +571,15 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 组织id(eg:社区或者街道id)
|
|
|
|
orgIds[j] = agencyScore.getKey(); |
|
|
|
j++; |
|
|
|
// 给4个指数 赋默认值
|
|
|
|
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); |
|
|
|
for ( int i = 0; i < agencyScore.getValue().size(); i++){ |
|
|
|
if (NumConstant.ONE_STR.equals(agencyScore.getValue().get(i).getIsTotal())){ |
|
|
|
// 是总分 总指数 = IS_TOTAL = 1
|
|
|
|
monthlyFormDTO.setIndexTotal(agencyScore.getValue().get(i).getScore()); |
|
|
|
} else { |
|
|
|
// 赋值 党建能力、治理能力、服务能力
|
|
|
|
monthlyFormDTO = this.setValueAblityMonthlyFor(agencyScore.getValue().get(i).getIndexCode(), |
|
|
|
monthlyFormDTO = this.setValueAbilityMonthlyFor(agencyScore.getValue().get(i).getIndexCode(), |
|
|
|
agencyScore.getValue().get(i).getScore(), |
|
|
|
monthlyFormDTO); |
|
|
|
} |
|
|
@ -424,23 +587,29 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
// 当前组织 的上级组织id
|
|
|
|
String parentAgencyId = agencyScore.getValue().get(NumConstant.ZERO).getParentAgencyId(); |
|
|
|
// 查询 组织名称
|
|
|
|
String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, agencyScore.getKey()); |
|
|
|
if (null == agencyName){ |
|
|
|
String agencyName = ""; |
|
|
|
for (ScreenCustomerAgencyEntity agencyScoreDTO : parentAgencyList) { |
|
|
|
if (agencyScore.getKey().equals(agencyScoreDTO.getAgencyId())) { |
|
|
|
agencyName = agencyScoreDTO.getAgencyName(); |
|
|
|
} |
|
|
|
} |
|
|
|
if ("".equals(agencyName)){ |
|
|
|
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey()); |
|
|
|
} |
|
|
|
// 补充表中其他字段
|
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, agencyScore.getKey(), |
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(), |
|
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
|
} |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
|
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, getYearStr(monthId), monthId, orgIds); |
|
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 指数-指数数据(每月数值) 表 字段补全,待新增 |
|
|
|
* @param year 2020 |
|
|
|
* @param month 08 |
|
|
|
* @param monthId 202008 |
|
|
|
* @param orgType 组织类别 agency:组织;部门:department;网格:grid |
|
|
|
* @param orgId 组织Id 可以为网格,机关id |
|
|
|
* @param parentId 上级组织id |
|
|
@ -450,10 +619,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:29 2020-09-03 |
|
|
|
**/ |
|
|
|
private IndexDataMonthlyFormDTO supplementIndexDataMonthlyTable(String year, String month, String orgType, String orgId, String parentId, |
|
|
|
private IndexDataMonthlyFormDTO supplementIndexDataMonthlyTable(String monthId, String orgType, String orgId, String parentId, |
|
|
|
String orgName, IndexDataMonthlyFormDTO monthlyFormDTO){ |
|
|
|
monthlyFormDTO.setYearId(year); |
|
|
|
monthlyFormDTO.setMonthId(year + month); |
|
|
|
monthlyFormDTO.setYearId(getYearStr(monthId)); |
|
|
|
monthlyFormDTO.setMonthId(monthId); |
|
|
|
monthlyFormDTO.setOrgType(orgType); |
|
|
|
monthlyFormDTO.setOrgId(orgId); |
|
|
|
// 根据网格id,查询其上级组织id、组织名称
|
|
|
@ -463,8 +632,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 赋值 党建能力、治理能力、服务能力 |
|
|
|
* (总指数 赋默认值) |
|
|
|
* 赋实际值 党建能力、治理能力、服务能力 |
|
|
|
* @param IndexCode 组织类别 |
|
|
|
* @param Score 分数 |
|
|
|
* @param monthlyFormDTO 待保存的数据 |
|
|
@ -472,17 +640,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 09:26 2020-09-04 |
|
|
|
**/ |
|
|
|
private IndexDataMonthlyFormDTO setValueAblityMonthlyFor(String IndexCode, BigDecimal Score, |
|
|
|
IndexDataMonthlyFormDTO monthlyFormDTO){ |
|
|
|
// 赋默认值
|
|
|
|
if (null == monthlyFormDTO.getIndexTotal() && null == monthlyFormDTO.getPartyDevAblity() |
|
|
|
&& null == monthlyFormDTO.getGovernAblity() && null == monthlyFormDTO.getServiceAblity()){ |
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
|
monthlyFormDTO.setIndexTotal(zero); |
|
|
|
monthlyFormDTO.setPartyDevAblity(zero); |
|
|
|
monthlyFormDTO.setGovernAblity(zero); |
|
|
|
monthlyFormDTO.setServiceAblity(zero); |
|
|
|
} |
|
|
|
private IndexDataMonthlyFormDTO setValueAbilityMonthlyFor(String IndexCode, BigDecimal Score, IndexDataMonthlyFormDTO monthlyFormDTO){ |
|
|
|
// 赋实际值
|
|
|
|
if (IndexCodeEnum.DANG_JIAN_NENG_LI.getCode().equals(IndexCode)){ |
|
|
|
// 党建能力
|
|
|
@ -496,4 +654,257 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
} |
|
|
|
return monthlyFormDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置 指数-指数数据(月、年) 表 |
|
|
|
* 总指数、党建能力指数、治理能力、服务能力 默认值 0 |
|
|
|
* @param monthlyFormDTO |
|
|
|
* @return com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 11:01 2020-09-04 |
|
|
|
**/ |
|
|
|
private IndexDataMonthlyFormDTO setIndexDefaultValueFor(IndexDataMonthlyFormDTO monthlyFormDTO){ |
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
|
monthlyFormDTO.setIndexTotal(zero); |
|
|
|
monthlyFormDTO.setPartyDevAblity(zero); |
|
|
|
monthlyFormDTO.setGovernAblity(zero); |
|
|
|
monthlyFormDTO.setServiceAblity(zero); |
|
|
|
return monthlyFormDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 网格相关分值记录表 默认值,一条网格,按照组织类别的不同 需要插入4次 |
|
|
|
* |
|
|
|
* @param monthId 例:202008 |
|
|
|
* @param customerId |
|
|
|
* @param mismatchGridList 网格相关分值记录表 中缺少的网格集合 |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:02 2020-09-04 |
|
|
|
**/ |
|
|
|
private void insertIndexGridScoreDefaultValue(String monthId, String customerId, List<ScreenCustomerGridDTO> mismatchGridList){ |
|
|
|
List<FactIndexGridScoreDTO> insertIndexGridScoreDTOS = new ArrayList<>(); |
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
|
for (ScreenCustomerGridDTO gridDTO : mismatchGridList){ |
|
|
|
FactIndexGridScoreDTO indexGridScoreDTO = new FactIndexGridScoreDTO(); |
|
|
|
// 赋默认值 - 党建能力指数
|
|
|
|
indexGridScoreDTO.setGridId(gridDTO.getGridId()); |
|
|
|
indexGridScoreDTO.setAgencyId(gridDTO.getParentAgencyId()); |
|
|
|
indexGridScoreDTO.setAllParentIds(gridDTO.getAllParentIds()); |
|
|
|
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
|
|
|
|
indexGridScoreDTO.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
|
indexGridScoreDTO.setYearId(getYearStr(monthId)); |
|
|
|
indexGridScoreDTO.setMonthId(monthId); |
|
|
|
// 0 or 1
|
|
|
|
indexGridScoreDTO.setIsTotal(NumConstant.ZERO_STR); |
|
|
|
indexGridScoreDTO.setScore(zero); |
|
|
|
indexGridScoreDTO.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); |
|
|
|
indexGridScoreDTO.setDelFlag(NumConstant.ZERO_STR); |
|
|
|
insertIndexGridScoreDTOS.add(indexGridScoreDTO); |
|
|
|
|
|
|
|
FactIndexGridScoreDTO indexGridScoreDTO1 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class); |
|
|
|
// 赋默认值 - 治理能力
|
|
|
|
indexGridScoreDTO1.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
|
insertIndexGridScoreDTOS.add(indexGridScoreDTO1); |
|
|
|
|
|
|
|
FactIndexGridScoreDTO indexGridScoreDTO2 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class); |
|
|
|
// 赋默认值 - 服务能力
|
|
|
|
indexGridScoreDTO2.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode()); |
|
|
|
insertIndexGridScoreDTOS.add(indexGridScoreDTO2); |
|
|
|
|
|
|
|
FactIndexGridScoreDTO indexGridScoreDTO3 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class); |
|
|
|
indexGridScoreDTO3.setIsTotal(NumConstant.ONE_STR); |
|
|
|
// 赋默认值 - 网格相关
|
|
|
|
indexGridScoreDTO3.setIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); |
|
|
|
insertIndexGridScoreDTOS.add(indexGridScoreDTO3); |
|
|
|
} |
|
|
|
factIndexGridScoreDao.batchInsertGridScoreData(insertIndexGridScoreDTOS, customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 社区相关分数表 默认值,一条组织id,按照组织类别的不同 需要插入4次 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @param mismatchAgencyList |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:02 2020-09-04 |
|
|
|
**/ |
|
|
|
private void insertIndexCommunityScoreDefaultValue(String monthId, String customerId, List<ScreenCustomerAgencyEntity> mismatchAgencyList){ |
|
|
|
List<FactIndexCommunityScoreEntity> insertIndexCommunityScore = new ArrayList<>(); |
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
|
for (ScreenCustomerAgencyEntity agencyDTO : mismatchAgencyList){ |
|
|
|
FactIndexCommunityScoreEntity communityScore1 = new FactIndexCommunityScoreEntity(); |
|
|
|
// 赋默认值 - 党建能力指数
|
|
|
|
communityScore1.setAgencyId(agencyDTO.getAgencyId()); |
|
|
|
communityScore1.setParentAgencyId(agencyDTO.getPid()); |
|
|
|
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
|
|
|
|
communityScore1.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
|
communityScore1.setYearId(getYearStr(monthId)); |
|
|
|
communityScore1.setMonthId(monthId); |
|
|
|
// 0 or 1
|
|
|
|
communityScore1.setIsTotal(NumConstant.ZERO_STR); |
|
|
|
communityScore1.setScore(zero); |
|
|
|
communityScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); |
|
|
|
insertIndexCommunityScore.add(communityScore1); |
|
|
|
|
|
|
|
// 赋默认值 - 治理能力
|
|
|
|
FactIndexCommunityScoreEntity communityScore2 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class); |
|
|
|
communityScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
|
insertIndexCommunityScore.add(communityScore2); |
|
|
|
|
|
|
|
// 赋默认值 - 服务能力
|
|
|
|
FactIndexCommunityScoreEntity communityScore3 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class); |
|
|
|
communityScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode()); |
|
|
|
insertIndexCommunityScore.add(communityScore3); |
|
|
|
|
|
|
|
// 赋默认值 - 社区相关
|
|
|
|
FactIndexCommunityScoreEntity communityScore4 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class); |
|
|
|
communityScore4.setIsTotal(NumConstant.ONE_STR); |
|
|
|
communityScore4.setIndexCode(IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); |
|
|
|
insertIndexCommunityScore.add(communityScore4); |
|
|
|
} |
|
|
|
factIndexCommunityScoreDao.batchInsertCommunityScoreData(insertIndexCommunityScore, customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 区直部门分值表 默认值,一条部门id,按照组织类别的不同 需要插入1次 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @param mismatchDeptList |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:02 2020-09-04 |
|
|
|
**/ |
|
|
|
private void insertIndexDeptScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerDeptEntity> mismatchDeptList){ |
|
|
|
List<DeptScoreEntity> insertIndexDeptScore = new ArrayList<>(); |
|
|
|
for (ScreenCustomerDeptEntity deptDTO : mismatchDeptList){ |
|
|
|
DeptScoreEntity deptScore2 = new DeptScoreEntity(); |
|
|
|
// 赋默认值 - 治理能力
|
|
|
|
deptScore2.setDeptId(deptDTO.getDeptId()); |
|
|
|
deptScore2.setAgencyId(deptDTO.getParentAgencyId()); |
|
|
|
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
|
|
|
|
deptScore2.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
|
deptScore2.setYearId(getYearStr(monthId)); |
|
|
|
deptScore2.setMonthId(monthId); |
|
|
|
deptScore2.setIsTotal(NumConstant.ZERO_STR); |
|
|
|
deptScore2.setScore(new BigDecimal(NumConstant.ZERO)); |
|
|
|
deptScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
|
deptScore2.setDelFlag(NumConstant.ZERO_STR); |
|
|
|
insertIndexDeptScore.add(deptScore2); |
|
|
|
} |
|
|
|
deptScoreDao.batchInsertDeptScoreData(insertIndexDeptScore, customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 区/街道相关分数表 默认值,一条组织id,按照组织类别的不同 需要插入4次 |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @param mismatchAgencyList |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 14:02 2020-09-04 |
|
|
|
**/ |
|
|
|
private void insertIndexAgencyScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerAgencyEntity> mismatchAgencyList){ |
|
|
|
BigDecimal zero = new BigDecimal(NumConstant.ZERO); |
|
|
|
List<AgencyScoreEntity> insertIndexAgencyScore = new ArrayList<>(); |
|
|
|
for (ScreenCustomerAgencyEntity agencyDTO : mismatchAgencyList){ |
|
|
|
if (OrgTypeConstant.COMMUNITY.equals(agencyDTO.getLevel()) || OrgTypeConstant.STREET.equals(agencyDTO.getLevel()) |
|
|
|
|| OrgTypeConstant.DISTRICT.equals(agencyDTO.getLevel())){ |
|
|
|
AgencyScoreEntity agencyScore1 = new AgencyScoreEntity(); |
|
|
|
// 赋默认值 - 党建能力指数
|
|
|
|
agencyScore1.setAgencyId(agencyDTO.getAgencyId()); |
|
|
|
agencyScore1.setParentAgencyId(agencyDTO.getPid()); |
|
|
|
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
|
|
|
|
agencyScore1.setQuarterId(DateUtils.getQuarterId(monthId)); |
|
|
|
agencyScore1.setYearId(getYearStr(monthId)); |
|
|
|
agencyScore1.setMonthId(monthId); |
|
|
|
// 0 or 1
|
|
|
|
agencyScore1.setIsTotal(NumConstant.ZERO_STR); |
|
|
|
agencyScore1.setScore(zero); |
|
|
|
agencyScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); |
|
|
|
|
|
|
|
AgencyScoreEntity agencyScore2 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class); |
|
|
|
// 赋默认值 - 治理能力
|
|
|
|
agencyScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); |
|
|
|
|
|
|
|
AgencyScoreEntity agencyScore3 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class); |
|
|
|
// 赋默认值 - 服务能力
|
|
|
|
agencyScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode()); |
|
|
|
|
|
|
|
AgencyScoreEntity agencyScore4 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class); |
|
|
|
agencyScore4.setIsTotal(NumConstant.ONE_STR); |
|
|
|
if (OrgTypeConstant.COMMUNITY.equals(agencyDTO.getLevel())){ |
|
|
|
// 赋默认值 - 全区相关
|
|
|
|
agencyScore4.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode()); |
|
|
|
agencyScore4.setDataType(OrgTypeConstant.DISTRICT); |
|
|
|
agencyScore1.setDataType(OrgTypeConstant.DISTRICT); |
|
|
|
agencyScore2.setDataType(OrgTypeConstant.DISTRICT); |
|
|
|
agencyScore3.setDataType(OrgTypeConstant.DISTRICT); |
|
|
|
} else if (OrgTypeConstant.STREET.equals(agencyDTO.getLevel()) || OrgTypeConstant.DISTRICT.equals(agencyDTO.getLevel())){ |
|
|
|
// 赋默认值 - 街道相关
|
|
|
|
agencyScore4.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode()); |
|
|
|
agencyScore4.setDataType(OrgTypeConstant.STREET); |
|
|
|
agencyScore1.setDataType(OrgTypeConstant.STREET); |
|
|
|
agencyScore2.setDataType(OrgTypeConstant.STREET); |
|
|
|
agencyScore3.setDataType(OrgTypeConstant.STREET); |
|
|
|
} |
|
|
|
insertIndexAgencyScore.add(agencyScore1); |
|
|
|
insertIndexAgencyScore.add(agencyScore2); |
|
|
|
insertIndexAgencyScore.add(agencyScore3); |
|
|
|
insertIndexAgencyScore.add(agencyScore4); |
|
|
|
} |
|
|
|
} |
|
|
|
agencyScoreDaol.batchInsertAgencyScoreData(insertIndexAgencyScore, customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly |
|
|
|
* |
|
|
|
* @param monthId |
|
|
|
* @param customerId |
|
|
|
* @return void |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 22:06 2020-09-04 |
|
|
|
**/ |
|
|
|
private void insertIndexDataYear(String monthId, String customerId){ |
|
|
|
List<IndexDataMonthlyFormDTO> monthlyFormList = screenIndexDataMonthlyDao.selectListIndexDataMonthlyByYear(customerId, getYearStr(monthId), getMonthStr(monthId)); |
|
|
|
String[] orgIds = new String[monthlyFormList.size()]; |
|
|
|
for (int i = NumConstant.ZERO; i < monthlyFormList.size(); i++){ |
|
|
|
orgIds[i] = monthlyFormList.get(i).getOrgId(); |
|
|
|
} |
|
|
|
if (monthlyFormList.size() > NumConstant.ZERO){ |
|
|
|
screenIndexDataYearlyDao.deleteIndexDataYearly(customerId, getYearStr(monthId), orgIds); |
|
|
|
List<IndexDataYearlyFormDTO> entity = ConvertUtils.sourceToTarget(monthlyFormList, IndexDataYearlyFormDTO.class); |
|
|
|
screenIndexDataYearlyDao.batchInsertIndexDataYearly(entity, customerId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将月份id,拆分成 年份 |
|
|
|
* |
|
|
|
* @param monthId 202008 |
|
|
|
* @return java.lang.String |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:39 2020-09-04 |
|
|
|
**/ |
|
|
|
private String getYearStr(String monthId){ |
|
|
|
return monthId.substring(NumConstant.ZERO, NumConstant.FOUR); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 将月份id,拆分成 月份 |
|
|
|
* |
|
|
|
* @param monthId 202008 |
|
|
|
* @return java.lang.String |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 13:39 2020-09-04 |
|
|
|
**/ |
|
|
|
private String getMonthStr(String monthId){ |
|
|
|
return monthId.substring(NumConstant.FOUR, NumConstant.SIX); |
|
|
|
} |
|
|
|
} |
|
|
|