|
@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.indexcoll.impl; |
|
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
import com.epmet.constant.OrgTypeConstant; |
|
@ -23,16 +24,20 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; |
|
|
import com.epmet.eum.IndexCodeEnum; |
|
|
import com.epmet.eum.IndexCodeEnum; |
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; |
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; |
|
|
|
|
|
import com.google.common.cache.Cache; |
|
|
|
|
|
import com.google.common.cache.CacheBuilder; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -43,6 +48,7 @@ import java.util.stream.Collectors; |
|
|
@Service |
|
|
@Service |
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
@DataSource(DataSourceConstant.EVALUATION_INDEX) |
|
|
public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
|
|
Cache<String, String> allParentIds = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.HOURS).build(); |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; |
|
|
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; |
|
@ -219,6 +225,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
|
|
|
|
|
|
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
|
|
|
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
|
|
|
this.insertIndexDataYear(monthId, customerId); |
|
|
this.insertIndexDataYear(monthId, customerId); |
|
|
|
|
|
allParentIds.invalidateAll(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -283,6 +290,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScoreDTOS.get(i).getGridId(), |
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScoreDTOS.get(i).getGridId(), |
|
|
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO); |
|
|
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO); |
|
|
|
|
|
monthlyDTO.setAllParentIds(gridScoreDTOS.get(i).getAllParentIds()); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
} |
|
|
} |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
@ -304,6 +312,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId)); |
|
|
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId)); |
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
// 查询网格的 上级组织id 和 组织名称
|
|
|
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId); |
|
|
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(parentGridList)) { |
|
|
|
|
|
parentGridList.forEach(o -> { |
|
|
|
|
|
allParentIds.put(o.getGridId(), o.getGridId()); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
for (Map.Entry<String, List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()) { |
|
|
for (Map.Entry<String, List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()) { |
|
|
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); |
|
|
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); |
|
|
|
|
|
|
|
@ -339,6 +352,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(), |
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(), |
|
|
parentAgencyId, gridName, monthlyFormDTO); |
|
|
parentAgencyId, gridName, monthlyFormDTO); |
|
|
|
|
|
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId())); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
} |
|
|
} |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
@ -409,6 +423,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(), |
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(), |
|
|
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO); |
|
|
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO); |
|
|
|
|
|
monthlyDTO.setAllParentIds(communityScoreDTOS.get(i).getPids()); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
} |
|
|
} |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
@ -430,6 +445,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); |
|
|
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); |
|
|
// 根据客户id,查询区/街道 组织名称、id
|
|
|
// 根据客户id,查询区/街道 组织名称、id
|
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(parentAgencyList)) { |
|
|
|
|
|
parentAgencyList.forEach(o -> { |
|
|
|
|
|
allParentIds.put(o.getAgencyId(), o.getPids()); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
for (Map.Entry<String, List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()) { |
|
|
for (Map.Entry<String, List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()) { |
|
|
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); |
|
|
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); |
|
|
// 给4个指数 赋默认值
|
|
|
// 给4个指数 赋默认值
|
|
@ -465,6 +485,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(), |
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(), |
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
|
|
|
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId())); |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
} |
|
|
} |
|
@ -498,6 +519,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(mismatchDeptList)) { |
|
|
if (!CollectionUtils.isEmpty(mismatchDeptList)) { |
|
|
|
|
|
mismatchDeptList.forEach(o -> { |
|
|
|
|
|
String pids = allParentIds.getIfPresent(o.getParentAgencyId()); |
|
|
|
|
|
if (!StringUtils.isEmpty(pids)) { |
|
|
|
|
|
allParentIds.put(o.getDeptId(), pids.concat(StrConstant.COLON).concat(o.getParentAgencyId())); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
// 如果进行不匹配查询,查到了其他部门信息,一律赋默认值
|
|
|
// 如果进行不匹配查询,查到了其他部门信息,一律赋默认值
|
|
|
this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList); |
|
|
this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList); |
|
|
} |
|
|
} |
|
@ -534,6 +561,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(), |
|
|
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(), |
|
|
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO); |
|
|
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO); |
|
|
|
|
|
monthlyDTO.setAllParentIds(allParentIds.getIfPresent(monthlyDTO.getOrgId())); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
monthlyFormDTOList.add(monthlyDTO); |
|
|
} |
|
|
} |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
|
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); |
|
@ -585,6 +613,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(), |
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(), |
|
|
parentAgencyId, deptName, monthlyFormDTO); |
|
|
parentAgencyId, deptName, monthlyFormDTO); |
|
|
|
|
|
//部门表没有 allParentIds 所以直接获取 然后拼接
|
|
|
|
|
|
String ppIds = allParentIds.getIfPresent(monthlyFormDTO.getParentId()); |
|
|
|
|
|
if (!StringUtils.isEmpty(ppIds)) { |
|
|
|
|
|
monthlyFormDTO.setAllParentIds(ppIds.concat(StrConstant.COLON).concat(monthlyFormDTO.getParentId())); |
|
|
|
|
|
} |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
} |
|
|
} |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
@ -640,6 +673,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); |
|
|
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); |
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); |
|
|
int j = 0; |
|
|
int j = 0; |
|
|
|
|
|
if (!CollectionUtils.isEmpty(parentAgencyList)) { |
|
|
|
|
|
parentAgencyList.forEach(o -> { |
|
|
|
|
|
allParentIds.put(o.getAgencyId(), o.getPids()); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
for (Map.Entry<String, List<AgencyScoreDTO>> agencyScore : collect.entrySet()) { |
|
|
for (Map.Entry<String, List<AgencyScoreDTO>> agencyScore : collect.entrySet()) { |
|
|
if (NumConstant.ZERO_STR.equals(agencyScore.getKey())) { |
|
|
if (NumConstant.ZERO_STR.equals(agencyScore.getKey())) { |
|
|
log.warn("insertIndexDataMonthlyByAgencyScore agencyyId is 0"); |
|
|
log.warn("insertIndexDataMonthlyByAgencyScore agencyyId is 0"); |
|
@ -675,6 +713,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { |
|
|
// 补充表中其他字段
|
|
|
// 补充表中其他字段
|
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(), |
|
|
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(), |
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
parentAgencyId, agencyName, monthlyFormDTO); |
|
|
|
|
|
if ("S2-C1".equals(monthlyFormDTO.getOrgId())) { |
|
|
|
|
|
System.out.println("======" + allParentIds.getIfPresent(monthlyFormDTO.getOrgId())); |
|
|
|
|
|
} |
|
|
|
|
|
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId())); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
monthlyFormDTOList.add(monthlyFormDTO); |
|
|
} |
|
|
} |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|
if (monthlyFormDTOList.size() > NumConstant.ZERO){ |
|
|