Browse Source

年表、月表 -- 展示接口优化

dev_shibei_match
zhangyongzhangyong 5 years ago
parent
commit
bcfb1adb92
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  2. 328
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

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

@ -65,7 +65,7 @@ public interface ScreenIndexDataMonthlyDao extends BaseDao<ScreenIndexDataMonthl
* 获取今年的各月份的平均值
* @param customerId
* @param yearId
* @param month
* @param month 做除法运算
* @return java.util.List<com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO>
* @Author zhangyong
* @Date 15:51 2020-09-04

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

@ -27,6 +27,8 @@ 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;
@ -46,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;
@ -225,12 +228,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
this.startHandleIndexAgencyScore(monthId, customerId);
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
this.insertIndexDataYear(this.getYearStr(monthId), this.getMonthStr(monthId), customerId);
this.insertIndexDataYear(monthId, customerId);
}
/**
* 目标将网格的 党建能力治理能力服务能力总指数 得分 整理后(4条合1条) 插入 指数-指数数据(月表)
* 如果网格相关分值表 中的网格数量不全需要从 网格(党支部)信息表() 先查询到缺少的网格信息赋上默认值后插入网格相关分值表()
* 如果网格相关分值表 中的网格数量不全需要从 网格(党支部)信息表 先查询到缺少的网格信息赋上默认值后在插入网格相关分值表 一对四
*
* @param monthId
* @param customerId
@ -242,40 +245,39 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 查询网格相关分值记录 表已经存在的网格id
List<String> indexGridIds = factIndexGridScoreDao.selectListGridId(customerId, monthId);
if (indexGridIds.size() > NumConstant.ZERO){
// 根据网格相关分值表 中查询到的网格id,去 网格(党支部)信息表 进行不匹配查询(即返回网格相关分值表 中不存在的网格信息)
// 根据网格相关分值表 中查询到的网格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.insertIndexGridScoreDefaultValueFor(monthId, customerId, mismatchGridList);
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList);
}
} else {
// 将所有的网格按照 4种类型,各赋一遍默认值
List<ScreenCustomerGridDTO> mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null);
this.insertIndexGridScoreDefaultValueFor(monthId, customerId, mismatchGridList);
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList);
}
// 开始处理实际分数
// fact_index_grid_score 网格相关分值记录表 grid
String[] dateArr = yearOrMonth(monthId);
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId);
this.insertIndexDataMonthlyByGridScore(dateArr[NumConstant.ONE], dateArr[NumConstant.ZERO], customerId, gridScoreDTOS);
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));
@ -286,6 +288,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())){
// 是总分
@ -294,8 +298,8 @@ 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);
}
@ -306,55 +310,64 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, gridScore.getKey(),
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(),
parentGridInfo.getParentAgencyId(), parentGridInfo.getGridName(), monthlyFormDTO);
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
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,去 网格(党支部)信息表 进行不匹配查询(即返回网格相关分值表 中不存在的网格信息)。
// 根据社区相关分值表 中查询到的社区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
// 将 社区相关分数表 中,本月份没有的社区信息,按照 4种类型,各新增一遍,赋默认值 0
if (mismatchAgencyList.size() > NumConstant.ZERO){
this.insertIndexCommunityScoreDefaultValueFor(monthId, customerId, mismatchAgencyList);
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList);
}
} else {
// 将所有的社区按照 4种类型,各赋一遍默认值
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
this.insertIndexCommunityScoreDefaultValueFor(monthId, customerId, mismatchAgencyList);
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList);
}
// 开始处理实际分数
// fact_index_community_score 社区相关分数表 agency
String[] dateArr = yearOrMonth(monthId);
// 查询社区相关分值记录
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId);
this.insertIndexDataMonthlyByCommunityScore(dateArr[NumConstant.ONE], dateArr[NumConstant.ZERO], customerId, communityScoreDTOS);
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));
@ -365,6 +378,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())){
// 是总分
@ -374,7 +389,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);
}
@ -388,17 +403,27 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
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.GRID, communityScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO);
// 补充表中其他字段
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds);
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);
@ -417,24 +442,22 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
// 开始处理实际分数
// fact_index_dept_score 区直部门分值表 department
String[] dateArr = yearOrMonth(monthId);
// 查询社 区直部门分值表
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId);
this.insertIndexDataMonthlyByDeptScore(dateArr[NumConstant.ONE], dateArr[NumConstant.ZERO], customerId, deptScoreDTOS);
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));
@ -445,11 +468,13 @@ 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++){
// 区直街道的总分 就是 治理能力
monthlyFormDTO.setIndexTotal(deptScore.getValue().get(i).getScore());
// 赋值 治理能力
monthlyFormDTO = this.setValueAblityMonthlyFor(deptScore.getValue().get(i).getIndexCode(),
monthlyFormDTO = this.setValueAbilityMonthlyFor(deptScore.getValue().get(i).getIndexCode(),
deptScore.getValue().get(i).getScore(),
monthlyFormDTO);
}
@ -459,22 +484,34 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey());
}
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, deptScore.getKey(),
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, deptScore.getKey(),
parentDeptInfo.getParentAgencyId(), parentDeptInfo.getDeptName(), 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[] agencys = new String[indexAgencyIds.size()];
String[] agencyIds = new String[indexAgencyIds.size()];
for (int i = NumConstant.ZERO; i < indexAgencyIds.size(); i++){
agencys[i] = indexAgencyIds.get(i);
agencyIds[i] = indexAgencyIds.get(i);
}
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencys);
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencyIds);
if (mismatchAgencyList.size() > NumConstant.ZERO){
this.insertIndexAgencyScoreDefaultValueFor(monthId, customerId, mismatchAgencyList);
}
@ -484,23 +521,21 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
// 开始处理实际分数
// fact_index_agency_score 区/街道相关分数表 agency
String[] dateArr = yearOrMonth(monthId);
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId);
this.insertIndexDataMonthlyByAgencyScore(dateArr[NumConstant.ONE], dateArr[NumConstant.ZERO], customerId, agencyScoreDTOS);
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));
@ -511,13 +546,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);
}
@ -530,18 +567,19 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
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.GRID, 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
@ -551,10 +589,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、组织名称
@ -564,8 +602,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
/**
* 赋值 党建能力治理能力服务能力
* (总指数 赋默认值)
* 赋实际值 党建能力治理能力服务能力
* @param IndexCode 组织类别
* @param Score 分数
* @param monthlyFormDTO 待保存的数据
@ -573,17 +610,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)){
// 党建能力
@ -611,22 +638,23 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTO.setIndexTotal(zero);
monthlyFormDTO.setPartyDevAblity(zero);
monthlyFormDTO.setGovernAblity(zero);
monthlyFormDTO.setServiceAblity(zero);
return monthlyFormDTO;
}
/**
* 新增 网格相关分值记录表 默认值一条网格按照组织类别的不同 需要插入4次
*
* @param monthId
* @param monthId 202008
* @param customerId
* @param mismatchGridList
* @param mismatchGridList 网格相关分值记录表 中缺少的网格集合
* @return void
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexGridScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerGridDTO> mismatchGridList){
String[] dateArr = yearOrMonth(monthId);
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();
// 赋默认值 - 党建能力指数
@ -635,11 +663,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
indexGridScoreDTO.setAllParentIds(gridDTO.getAllParentIds());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
indexGridScoreDTO.setQuarterId(DateUtils.getQuarterId(monthId));
indexGridScoreDTO.setYearId(dateArr[NumConstant.ZERO]);
indexGridScoreDTO.setYearId(getYearStr(monthId));
indexGridScoreDTO.setMonthId(monthId);
indexGridScoreDTO.setIsTotal(NumConstant.ZERO_STR); // 0 or 1
indexGridScoreDTO.setScore(new BigDecimal(NumConstant.ZERO));
indexGridScoreDTO.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); // 4种类型
// 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);
@ -649,10 +678,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
indexGridScoreDTO1.setAgencyId(gridDTO.getParentAgencyId());
indexGridScoreDTO1.setAllParentIds(gridDTO.getAllParentIds());
indexGridScoreDTO1.setQuarterId(DateUtils.getQuarterId(monthId));
indexGridScoreDTO1.setYearId(dateArr[NumConstant.ZERO]);
indexGridScoreDTO1.setYearId(getYearStr(monthId));
indexGridScoreDTO1.setMonthId(monthId);
indexGridScoreDTO1.setIsTotal(NumConstant.ZERO_STR);
indexGridScoreDTO1.setScore(new BigDecimal(NumConstant.ZERO));
indexGridScoreDTO1.setScore(zero);
indexGridScoreDTO1.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
indexGridScoreDTO1.setDelFlag(NumConstant.ZERO_STR);
insertIndexGridScoreDTOS.add(indexGridScoreDTO1);
@ -663,10 +692,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
indexGridScoreDTO2.setAgencyId(gridDTO.getParentAgencyId());
indexGridScoreDTO2.setAllParentIds(gridDTO.getAllParentIds());
indexGridScoreDTO2.setQuarterId(DateUtils.getQuarterId(monthId));
indexGridScoreDTO2.setYearId(dateArr[NumConstant.ZERO]);
indexGridScoreDTO2.setYearId(getYearStr(monthId));
indexGridScoreDTO2.setMonthId(monthId);
indexGridScoreDTO2.setIsTotal(NumConstant.ZERO_STR);
indexGridScoreDTO2.setScore(new BigDecimal(NumConstant.ZERO));
indexGridScoreDTO2.setScore(zero);
indexGridScoreDTO2.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
indexGridScoreDTO2.setDelFlag(NumConstant.ZERO_STR);
insertIndexGridScoreDTOS.add(indexGridScoreDTO2);
@ -677,10 +706,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
indexGridScoreDTO3.setAgencyId(gridDTO.getParentAgencyId());
indexGridScoreDTO3.setAllParentIds(gridDTO.getAllParentIds());
indexGridScoreDTO3.setQuarterId(DateUtils.getQuarterId(monthId));
indexGridScoreDTO3.setYearId(dateArr[NumConstant.ZERO]);
indexGridScoreDTO3.setYearId(getYearStr(monthId));
indexGridScoreDTO3.setMonthId(monthId);
indexGridScoreDTO3.setIsTotal(NumConstant.ONE_STR);
indexGridScoreDTO3.setScore(new BigDecimal(NumConstant.ZERO));
indexGridScoreDTO3.setScore(zero);
indexGridScoreDTO3.setIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
indexGridScoreDTO3.setDelFlag(NumConstant.ZERO_STR);
insertIndexGridScoreDTOS.add(indexGridScoreDTO3);
@ -698,9 +727,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexCommunityScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerAgencyEntity> mismatchAgencyList){
String[] dateArr = yearOrMonth(monthId);
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();
// 赋默认值 - 党建能力指数
@ -708,23 +737,23 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
communityScore1.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
communityScore1.setQuarterId(DateUtils.getQuarterId(monthId));
communityScore1.setYearId(dateArr[NumConstant.ZERO]);
communityScore1.setYearId(getYearStr(monthId));
communityScore1.setMonthId(monthId);
communityScore1.setIsTotal(NumConstant.ZERO_STR); // 0 or 1
communityScore1.setScore(new BigDecimal(NumConstant.ZERO));
communityScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); // 4种类型
// 0 or 1
communityScore1.setIsTotal(NumConstant.ZERO_STR);
communityScore1.setScore(zero);
communityScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore1);
FactIndexCommunityScoreEntity communityScore2 = new FactIndexCommunityScoreEntity();
// 赋默认值 - 治理能力
communityScore2.setAgencyId(agencyDTO.getAgencyId());
communityScore2.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
communityScore2.setQuarterId(DateUtils.getQuarterId(monthId));
communityScore2.setYearId(dateArr[NumConstant.ZERO]);
communityScore2.setYearId(getYearStr(monthId));
communityScore2.setMonthId(monthId);
communityScore2.setIsTotal(NumConstant.ZERO_STR);
communityScore2.setScore(new BigDecimal(NumConstant.ZERO));
communityScore2.setScore(zero);
communityScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore2);
@ -732,12 +761,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 赋默认值 - 服务能力
communityScore3.setAgencyId(agencyDTO.getAgencyId());
communityScore3.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
communityScore3.setQuarterId(DateUtils.getQuarterId(monthId));
communityScore3.setYearId(dateArr[NumConstant.ZERO]);
communityScore3.setYearId(getYearStr(monthId));
communityScore3.setMonthId(monthId);
communityScore3.setIsTotal(NumConstant.ZERO_STR);
communityScore3.setScore(new BigDecimal(NumConstant.ZERO));
communityScore3.setScore(zero);
communityScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore3);
@ -745,20 +773,28 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 赋默认值 - 社区相关
communityScore4.setAgencyId(agencyDTO.getAgencyId());
communityScore4.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
communityScore4.setQuarterId(DateUtils.getQuarterId(monthId));
communityScore4.setYearId(dateArr[NumConstant.ZERO]);
communityScore4.setYearId(getYearStr(monthId));
communityScore4.setMonthId(monthId);
communityScore4.setIsTotal(NumConstant.ONE_STR);
communityScore4.setScore(new BigDecimal(NumConstant.ZERO));
communityScore4.setScore(zero);
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){
String[] dateArr = yearOrMonth(monthId);
List<DeptScoreEntity> insertIndexDeptScore = new ArrayList<>();
for (ScreenCustomerDeptEntity deptDTO : mismatchDeptList){
DeptScoreEntity deptScore2 = new DeptScoreEntity();
@ -767,7 +803,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
deptScore2.setAgencyId(deptDTO.getParentAgencyId());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
deptScore2.setQuarterId(DateUtils.getQuarterId(monthId));
deptScore2.setYearId(dateArr[NumConstant.ZERO]);
deptScore2.setYearId(getYearStr(monthId));
deptScore2.setMonthId(monthId);
deptScore2.setIsTotal(NumConstant.ZERO_STR);
deptScore2.setScore(new BigDecimal(NumConstant.ZERO));
@ -778,8 +814,18 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
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){
String[] dateArr = yearOrMonth(monthId);
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
List<AgencyScoreEntity> insertIndexAgencyScore = new ArrayList<>();
for (ScreenCustomerAgencyEntity agencyDTO : mismatchAgencyList){
if ("community".equals(agencyDTO.getLevel()) || "street".equals(agencyDTO.getLevel())
@ -790,11 +836,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
agencyScore1.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore1.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore1.setYearId(dateArr[NumConstant.ZERO]);
agencyScore1.setYearId(getYearStr(monthId));
agencyScore1.setMonthId(monthId);
agencyScore1.setIsTotal(NumConstant.ZERO_STR); // 0 or 1
agencyScore1.setScore(new BigDecimal(NumConstant.ZERO));
agencyScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); // 4种类型
// 0 or 1
agencyScore1.setIsTotal(NumConstant.ZERO_STR);
agencyScore1.setScore(zero);
agencyScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
AgencyScoreEntity agencyScore2 = new AgencyScoreEntity();
// 赋默认值 - 治理能力
@ -802,96 +849,77 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
agencyScore2.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore2.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore2.setYearId(dateArr[NumConstant.ZERO]);
agencyScore2.setYearId(getYearStr(monthId));
agencyScore2.setMonthId(monthId);
agencyScore2.setIsTotal(NumConstant.ZERO_STR);
agencyScore2.setScore(new BigDecimal(NumConstant.ZERO));
agencyScore2.setScore(zero);
agencyScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
AgencyScoreEntity agencyScore3 = new AgencyScoreEntity();
// 赋默认值 - 服务能力
agencyScore3.setAgencyId(agencyDTO.getAgencyId());
agencyScore3.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore3.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore3.setYearId(dateArr[NumConstant.ZERO]);
agencyScore3.setYearId(getYearStr(monthId));
agencyScore3.setMonthId(monthId);
agencyScore3.setIsTotal(NumConstant.ZERO_STR);
agencyScore3.setScore(new BigDecimal(NumConstant.ZERO));
agencyScore3.setScore(zero);
agencyScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
AgencyScoreEntity agencyScore4 = new AgencyScoreEntity();
agencyScore4.setAgencyId(agencyDTO.getAgencyId());
agencyScore4.setParentAgencyId(agencyDTO.getPid());
agencyScore4.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore4.setYearId(getYearStr(monthId));
agencyScore4.setMonthId(monthId);
agencyScore4.setIsTotal(NumConstant.ONE_STR);
agencyScore4.setScore(zero);
if ("community".equals(agencyDTO.getLevel())){
AgencyScoreEntity agencyScore4 = new AgencyScoreEntity();
// 赋默认值 - 全区相关
agencyScore4.setAgencyId(agencyDTO.getAgencyId());
agencyScore4.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore4.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore4.setYearId(dateArr[NumConstant.ZERO]);
agencyScore4.setMonthId(monthId);
agencyScore4.setIsTotal(NumConstant.ONE_STR);
agencyScore4.setScore(new BigDecimal(NumConstant.ZERO));
agencyScore4.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode());
agencyScore4.setDataType("district");
agencyScore1.setDataType("district");
agencyScore2.setDataType("district");
agencyScore3.setDataType("district");
insertIndexAgencyScore.add(agencyScore4);
} else if ("street".equals(agencyDTO.getLevel()) || "district".equals(agencyDTO.getLevel())){
AgencyScoreEntity agencyScore4 = new AgencyScoreEntity();
// 赋默认值 - 街道相关
agencyScore4.setAgencyId(agencyDTO.getAgencyId());
agencyScore4.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore4.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore4.setYearId(dateArr[NumConstant.ZERO]);
agencyScore4.setMonthId(monthId);
agencyScore4.setIsTotal(NumConstant.ONE_STR);
agencyScore4.setScore(new BigDecimal(NumConstant.ZERO));
agencyScore4.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
agencyScore4.setDataType("street");
agencyScore1.setDataType("street");
agencyScore2.setDataType("street");
agencyScore3.setDataType("street");
insertIndexAgencyScore.add(agencyScore4);
}
insertIndexAgencyScore.add(agencyScore1);
insertIndexAgencyScore.add(agencyScore2);
insertIndexAgencyScore.add(agencyScore3);
insertIndexAgencyScore.add(agencyScore4);
}
}
agencyScoreDaol.batchInsertAgencyScoreData(insertIndexAgencyScore, customerId);
}
private void insertIndexDataYear(String year, String month, String customerId){
List<IndexDataMonthlyFormDTO> monthlyFormList = screenIndexDataMonthlyDao.selectListIndexDataMonthlyByYear(customerId, year, month);
String[] orgIds = new String[monthlyFormList.size()];
for (int i = NumConstant.ZERO; i < monthlyFormList.size(); i++){
orgIds[i] = monthlyFormList.get(i).getOrgId();
}
screenIndexDataYearlyDao.deleteIndexDataYearly(customerId, year, orgIds);
List<IndexDataYearlyFormDTO> entity = ConvertUtils.sourceToTarget(monthlyFormList, IndexDataYearlyFormDTO.class);
screenIndexDataYearlyDao.batchInsertIndexDataYearly(entity, customerId);
}
/**
* 将月份id拆分 dateArr[0] = 年份 dateArr[1] = 月份
* 根据年汇总今年各项得到计算平均值后 插入年表 screen_index_data_yearly
*
* @param monthId 202008
* @return java.lang.String[]
* @param monthId
* @param customerId
* @return void
* @Author zhangyong
* @Date 13:39 2020-09-04
* @Date 22:06 2020-09-04
**/
private String[] yearOrMonth(String monthId){
String[] dateArr = new String[NumConstant.TWO];
dateArr[NumConstant.ZERO] = monthId.substring(NumConstant.ZERO, NumConstant.FOUR);
dateArr[NumConstant.ONE] = monthId.substring(NumConstant.FOUR, NumConstant.SIX);
return dateArr;
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拆分成 年份
*

Loading…
Cancel
Save