Browse Source

jiedao

dev_shibei_match
zxc 5 years ago
parent
commit
c396fc3377
  1. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  2. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  3. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java
  4. 321
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  5. 26
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  6. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml
  7. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java

@ -62,6 +62,16 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
*/
List<AgencyScoreDTO> selectAgencyScoreInfo(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType);
/**
* @Description 查询fact_index_agency_score相关信息 存在下级客户
* @Param areaCode
* @Param monthId
* @Param dataType
* @author zxc
* @date 2021/1/15 下午4:23
*/
List<AgencyScoreDTO> selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType);
/**
* @Description 区下级街道得分平均值
* @param customerId

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java

@ -88,6 +88,16 @@ public interface CommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
/**
* @Description 街道下级所有社区得分平均值 存在下级客户
* @Param monthId
* @Param indexCode
* @Param areaCode
* @author zxc
* @date 2021/1/15 下午3:19
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScoreExistSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("areaCode")String areaCode);
/**
* 根据入参查询 查询社区id
* @param customerId

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java

@ -78,6 +78,15 @@ public interface FactIndexPartyAblityOrgMonthlyDao extends BaseDao<FactIndexPart
*/
List<Map<String,Object>> selectPublishArticleCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level);
/**
* @Description 查询社区下的发文数 Map 存在下级客户
* @Param monthId
* @Param areaCode
* @author zxc
* @date 2021/1/15 下午3:31
*/
List<Map<String,Object>> selectPublishArticleCountMapExistSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* @Description 查询社区下的发文数 Map根据areaCode
* @Param customerId

321
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java

@ -91,21 +91,43 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
public Boolean calStreetAll(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
Boolean aBoolean = streetPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate street-party-ability failure ......");
}
Boolean bBoolean = streetGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate street-govern-ability failure ......");
}
Boolean cBoolean = streetServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate street-service-ability failure ......");
}
Boolean dBoolean = streetRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate street-all insert failure ......");
if (StringUtils.isEmpty(form.getCustomerAreaCode())) {
Boolean aBoolean = streetPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate street-party-ability failure ......");
}
Boolean bBoolean = streetGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate street-govern-ability failure ......");
}
Boolean cBoolean = streetServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate street-service-ability failure ......");
}
Boolean dBoolean = streetRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate street-all insert failure ......");
}
}else {
//党建能力
Boolean aBoolean = streetPartyCalculateExistsSub(form);
if (!aBoolean.equals(true)) {
throw new RenException("calculate street-party-ability-exists-sub failure ......");
}
// 治理能力
Boolean bBoolean = streetGovernAbilityCalculateExistsSub(form);
if (!bBoolean.equals(true)) {
throw new RenException("calculate street-govern-ability-exists-sub failure ......");
}
// 服务能力
Boolean cBoolean = streetServiceAbilityCalculateExistsSub(form);
if (!cBoolean.equals(true)) {
throw new RenException("calculate street-service-ability-exists-sub failure ......");
}
Boolean dBoolean = streetRelateExistsSub(form);
if (!dBoolean.equals(true)) {
throw new RenException("calculate street-all-exists-sub insert failure ......");
}
}
//计算自身和下级
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO();
@ -569,4 +591,273 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
result.setFiveLevel(resultFive);
return result;
}
/**
* @param form
* @Description 社区名义发文数量计算党建能力
* @author zxc
* @date 2020/8/26 10:46 上午
*/
public Boolean streetPartyCalculateExistsSub(CalculateCommonFormDTO form) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return true;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
//下属所有社区的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScoreExistSub(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.warn(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL);
} else if (subCommPartyAvgScore.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubCommunityAvgResultDTO>> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd);
partition.forEach(publish -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 街道名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSub(monthId,form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(mapList)) {
log.warn(IndexCalConstant.STREET_PUBLISH_ARTICLE_LIST_NULL);
} else {
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldName)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
} else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(mapList.stream().map(m -> new BigDecimal(m.get(fieldName).toString())).collect(Collectors.toList()));
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(mapList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach(publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldName))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1);
indexInputVOS.add(index1VO);
});
}
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("streetPartyAbilityCalculateExistsSub getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetPartyAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL);
insertDetail(result);
return true;
}
/**
* @Description 街道治理能力
* @param form
* @author zxc
* @date 2020/8/26 1:40 下午
*/
public Boolean streetGovernAbilityCalculateExistsSub(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return true;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subGridGovernAvg = communityScoreDao.selectSubCommAvgScoreExistSub(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subGridGovernAvg)){
log.warn("查询街道下属所有社区治理能力汇总为空");
}else if (subGridGovernAvg.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSub(monthId,form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.warn(IndexCalConstant.STREET_GOVERN_ABILITY_NULL);
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> governAbilityList = ListUtils.partition(communityGovernAbility, IndexCalConstant.PAGE_SIZE);
governAbilityList.forEach(governAbility -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
governAbility.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("streetGovernAbilityCalculateExistsSub getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetGovernAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
insertDetail(result);
return true;
}
/**
* @Description 街道服务能力
* @param form
* @author zxc
* @date 2020/8/31 1:38 下午
*/
public Boolean streetServiceAbilityCalculateExistsSub(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return true;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) {
List<SubCommunityAvgResultDTO> subCommServiceAvg = communityScoreDao.selectSubCommAvgScoreExistSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subCommServiceAvg)) {
log.warn("查询街道下属社区服务能力得分平均值为空");
} else if (subCommServiceAvg.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> serviceAvgList = ListUtils.partition(subCommServiceAvg, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1);
indexInputVOS.add(index1VO);
});
}
} else {
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSub(monthId,form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.warn(IndexCalConstant.STREET_SERVICE_ABILITY_NULL);
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityActivityCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> communityActivityList = ListUtils.partition(communityActivityCountList, IndexCalConstant.PAGE_SIZE);
communityActivityList.forEach(communityActivity -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
communityActivity.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(), c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("streetServiceAbilityCalculateExistsSub getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetServiceAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
insertDetail(result);
return true;
}
/**
* @Description 街道相关计算
* @param form
* @author zxc
* @date 2020/9/3 9:21 上午
*/
public Boolean streetRelateExistsSub(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), monthId, IndexCalConstant.STREET_LEVEL);
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
community.setScore(community.getScore().multiply(detail.getWeight()));
}
});
});
Map<String, List<AgencyScoreDTO>> collect = agencyScoreList.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
List<AgencyScoreDTO> result = new ArrayList<>();
collect.forEach((key, value) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setIsTotal(NumConstant.ONE_STR);
score.setCustomerId(customerId);
score.setAgencyId(key);
score.setMonthId(monthId);
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
score.setDataType(IndexCalConstant.STREET_LEVEL);
score.setAllParentIndexCode(NumConstant.ZERO_STR);
score.setWeight(new BigDecimal(NumConstant.ONE_NEG));
value.forEach(street -> {
score.setScore(score.getScore().add(street.getScore()));
score.setParentAgencyId(street.getParentAgencyId());
});
result.add(score);
});
if (!CollectionUtils.isEmpty(result)){
agencyScoreDao.insertStreetRecord(result);
}
return true;
}
}

26
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -124,4 +124,30 @@
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
<!-- 查询【fact_index_agency_score】相关信息 存在下级客户 -->
<select id="selectAgencyScoreInfoExistsSub" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
fias.CUSTOMER_ID,
fias.AGENCY_ID,
fias.MONTH_ID,
fias.QUARTER_ID,
fias.YEAR_ID,
fias.SCORE,
fias.INDEX_CODE,
fias.PARENT_AGENCY_ID
FROM
fact_index_agency_score fias
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fias.AGENCY_ID
WHERE
fias.del_flag = 0
AND CHAR_LENGTH(sca.AREA_CODE) >= 6
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND fias.MONTH_ID = #{monthId}
AND fias.data_type = #{dataType}
AND fias.IS_TOTAL = "0"
AND (fias.INDEX_CODE = "zhilinengli"
OR fias.INDEX_CODE = "dangjiannengli"
OR fias.INDEX_CODE = "fuwunengli")
</select>
</mapper>

23
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml

@ -147,4 +147,27 @@
OR cs.INDEX_CODE = "zhilinengli"
OR cs.INDEX_CODE = "fuwunengli")
</select>
<!-- 街道下级所有社区得分平均值 存在下级客户 -->
<select id="selectSubCommAvgScoreExistSub" resultType="com.epmet.dto.indexcal.SubCommunityAvgResultDTO">
SELECT
fics.PARENT_AGENCY_ID AS agencyId,
fics.month_id,
fics.quarter_id,
fics.year_id,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id,
sca.pid AS parentId
FROM
fact_index_community_score fics
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.PARENT_AGENCY_ID
WHERE
fics.del_flag = '0'
AND sca.DEL_FLAG = 0
AND CHAR_LENGTH(sca.AREA_CODE) >= 6
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.parent_agency_id
</select>
</mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml

@ -132,4 +132,24 @@
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
</select>
<!-- 查询社区下的发文数 Map 存在下级客户 -->
<select id="selectPublishArticleCountMapExistSub" resultType="java.util.Map">
SELECT
pm.AGENCY_ID,
pm.PARENT_ID,
pm.MONTH_ID,
pm.QUARTER_ID,
pm.YEAR_ID,
pm.PUBLISH_ARTICLE_COUNT,
pm.CUSTOMER_ID
FROM
fact_index_party_ablity_org_monthly pm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = pm.AGENCY_ID
WHERE
pm.del_flag = '0'
AND CHAR_LENGTH(sca.AREA_CODE) >= 6
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND pm.month_id = #{monthId}
</select>
</mapper>

Loading…
Cancel
Save