Browse Source

data_monthly插入时添加allPids

master
jianjun 5 years ago
parent
commit
7c6ac4a364
  1. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/IndexDataMonthlyFormDTO.java
  2. 42
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  3. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  4. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/IndexDataMonthlyFormDTO.java

@ -41,6 +41,11 @@ public class IndexDataMonthlyFormDTO implements Serializable {
*/
private String parentId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 组织名称
*/

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

@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.indexcoll.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
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.eum.IndexCodeEnum;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -43,6 +48,7 @@ import java.util.stream.Collectors;
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class FactIndexCollectServiceImpl implements FactIndexCollectService {
Cache<String, String> allParentIds = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.HOURS).build();
@Autowired
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao;
@ -219,6 +225,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
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(),
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO);
monthlyDTO.setAllParentIds(gridScoreDTOS.get(i).getAllParentIds());
monthlyFormDTOList.add(monthlyDTO);
}
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));
// 查询网格的 上级组织id 和 组织名称
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()) {
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
@ -339,6 +352,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(),
parentAgencyId, gridName, monthlyFormDTO);
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
@ -409,6 +423,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(),
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO);
monthlyDTO.setAllParentIds(communityScoreDTOS.get(i).getPids());
monthlyFormDTOList.add(monthlyDTO);
}
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));
// 根据客户id,查询区/街道 组织名称、id
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()) {
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 给4个指数 赋默认值
@ -465,6 +485,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO);
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
// 补充表中其他字段
monthlyFormDTOList.add(monthlyFormDTO);
}
@ -498,6 +519,12 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
}
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);
}
@ -534,6 +561,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(),
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO);
monthlyDTO.setAllParentIds(allParentIds.getIfPresent(monthlyDTO.getOrgId()));
monthlyFormDTOList.add(monthlyDTO);
}
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
@ -585,6 +613,11 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(),
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);
}
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));
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId);
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()) {
if (NumConstant.ZERO_STR.equals(agencyScore.getKey())) {
log.warn("insertIndexDataMonthlyByAgencyScore agencyyId is 0");
@ -675,6 +713,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(),
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);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){

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

@ -81,7 +81,8 @@
<select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT
AGENCY_ID agencyId,
AGENCY_NAME agencyName
AGENCY_NAME agencyName,
PIDS pids
FROM
screen_customer_agency
WHERE

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

@ -126,7 +126,8 @@
SELECT
GRID_ID gridId,
GRID_NAME gridName,
PARENT_AGENCY_ID parentAgencyId
PARENT_AGENCY_ID parentAgencyId,
ALL_PARENT_IDS allParentIds
FROM
screen_customer_grid
WHERE

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

@ -19,6 +19,7 @@
ORG_TYPE,
ORG_ID,
PARENT_ID,
ALL_PARENT_IDS,
ORG_NAME,
INDEX_TOTAL,
PARTY_DEV_ABLITY,
@ -43,6 +44,7 @@
#{item.orgType},
#{item.orgId},
#{item.parentId},
#{item.allParentIds},
#{item.orgName},
#{item.indexTotal},

Loading…
Cancel
Save