Browse Source

社区

master
zxc 5 years ago
parent
commit
eb51561ef2
  1. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  2. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java
  4. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java
  5. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java
  6. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java
  7. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java
  8. 324
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  9. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  10. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml
  11. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml
  12. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml
  13. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml
  14. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -177,8 +177,8 @@ public class DemoController {
}
@PostMapping("zxc2")
public Result getZxc2(){
indexCalculateCommunityService.calCommunityAll("45687aa479955f9d06204d415238f7cc", "202008");
public Result getZxc2(@RequestBody CalculateCommonFormDTO formDTO){
indexCalculateCommunityService.calCommunityAll(formDTO);
return new Result();
}

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

@ -61,6 +61,15 @@ public interface CommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* @Description 查询社区相关信息 存在下级客户
* @Param areaCode
* @Param monthId
* @author zxc
* @date 2021/1/15 下午2:18
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId);
/**
* 根据入参查询 查询社区相关信息
* @param customerId

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

@ -78,6 +78,16 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
*/
List<SubGridAvgResultDTO> selectSubGridAvgScore(@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 上午9:24
*/
List<SubGridAvgResultDTO> selectSubGridAvgScoreByAreaCode(@Param("monthId")String monthId, @Param("indexCode")String indexCode, @Param("areaCode")String areaCode);
/**
* 根据入参查询 网格相关分值记录
* @param customerId

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

@ -67,6 +67,15 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao<FactIndexGovr
*/
List<Map<String,Object>> selectCommunityGovernAbility(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level);
/**
* @Description 社区治理能力各个参数查询被吹哨次数办结项目数项目响应度超期项目率街道办结项目的处理效率level为street时存在办结项目率办结项目满意度存在下级客户时
* @Param areaCode
* @Param monthId
* @author zxc
* @date 2021/1/15 下午1:27
*/
List<Map<String,Object>> selectCommunityGovernAbilityExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* 根据组织类型删除数据
* @author zhaoqifeng

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

@ -78,6 +78,16 @@ 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根据areaCode
* @Param customerId
* @Param monthId
* @Param level
* @author zxc
* @date 2021/1/15 上午9:48
*/
List<Map<String,Object>> selectPublishArticleCountMapbyAreaCode(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* 根据组织类型删除数据
* @author zhaoqifeng

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

@ -79,6 +79,15 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao<FactIndexSe
*/
List<Map<String,Object>> selectActivityCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId,@Param("level")String level);
/**
* @Description 社区活动组织次数 存在下级客户
* @Param monthId
* @Param areaCode
* @author zxc
* @date 2021/1/15 下午1:53
*/
List<Map<String,Object>> selectActivityCountMapExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* 根据组织类型删除数据
* @author zhaoqifeng

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateCommunityService.java

@ -1,5 +1,7 @@
package com.epmet.service.evaluationindex.indexcal;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
/**
* @Author zxc
* @DateTime 2020/8/26 10:33 上午
@ -8,10 +10,9 @@ public interface IndexCalculateCommunityService {
/**
* @Description 计算社区相关总分
* @param customerId
* @param monthId
* @param formDTO
* @author zxc
* @date 2020/9/1 4:12 下午
*/
Boolean calCommunityAll(String customerId, String monthId);
Boolean calCommunityAll(CalculateCommonFormDTO formDTO);
}

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

@ -81,29 +81,52 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
private CommunitySelfSubScoreDao communitySelfSubScoreDao;
/**
* @param customerId
* @param monthId
* @param form
* @Description 计算社区相关总分
* @author zxc
* @date 2020/9/1 4:12 下午
*/
@Override
public Boolean calCommunityAll(String customerId, String monthId) {
Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate community-party-ability failure ......");
}
Boolean bBoolean = communityGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate community-govern-ability failure ......");
}
Boolean cBoolean = communityServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate community-service-ability failure ......");
}
Boolean dBoolean = communityRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate community-all insert failure ......");
public Boolean calCommunityAll(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
if (StringUtils.isEmpty(form.getCustomerAreaCode())) {
Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate community-party-ability failure ......");
}
Boolean bBoolean = communityGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate community-govern-ability failure ......");
}
Boolean cBoolean = communityServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate community-service-ability failure ......");
}
Boolean dBoolean = communityRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate community-all insert failure ......");
}
}else {
// 党建能力
Boolean aBoolean = communityPartyCalculateExistsSub(form);
if (!aBoolean.equals(true)) {
throw new RenException("calculate community-party-ability-exists-sub failure ......");
}
// 治理能力
Boolean bBoolean = communityGovernAbilityCalculateExistsSub(form);
if (!bBoolean.equals(true)) {
throw new RenException("calculate community-govern-ability-exists-sub failure ......");
}
// 服务能力
Boolean cBoolean = communityServiceAbilityCalculateExistsSub(form);
if (!cBoolean.equals(true)) {
throw new RenException("calculate community-service-ability-exists-sub failure ......");
}
Boolean dBoolean = communityRelateExistsSub(form);
if (!dBoolean.equals(true)) {
throw new RenException("calculate community-all-exists-sub insert failure ......");
}
}
//计算自身和下级
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO();
@ -565,4 +588,269 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
result.setFiveLevel(resultFive);
return result;
}
/**
* @Description 社区名义发文数量计算党建能力存在下级客户
* @Param form
* @author zxc
* @date 2021/1/15 上午9:18
*/
public Boolean communityPartyCalculateExistsSub(CalculateCommonFormDTO form) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_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.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.warn(IndexCalConstant.GRID_PARTY_AVG_NULL);
} else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE);
subPartyAvgList.forEach(party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
party.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>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapbyAreaCode( form.getMonthId(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.warn(IndexCalConstant.COMMUNITY_PUBLISH_ARTICLE_LIST_NULL);
} else {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
} else {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, 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(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();
log.info("communityPartyCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityPartyCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteOldRecord(form.getCustomerId(),form.getMonthId());
deleteAndInsert(result);
return true;
}
/**
* @Description 社区治理能力 存在下级客户
* @Param form
* @author zxc
* @date 2021/1/15 上午10:56
*/
public Boolean communityGovernAbilityCalculateExistsSub(CalculateCommonFormDTO form) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_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.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subGridGovernAvg)){
log.warn("社区下级治理能力平均分集合为空");
}else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridAvgResultDTO>> 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(form.getMonthId(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.warn(IndexCalConstant.COMMUNITY_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();
log.info("communityGovernAbilityCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
/**
* @Description 社区服务能力 存在下级客户
* @Param form
* @author zxc
* @date 2021/1/15 下午1:42
*/
public Boolean communityServiceAbilityCalculateExistsSub(CalculateCommonFormDTO form) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_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.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) {
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScoreByAreaCode(form.getMonthId(),IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(subGridServiceAvg)) {
log.warn("查询社区下级所有网格服务能力得分平均值集合为空");
} else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, 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(form.getMonthId(),form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.warn(IndexCalConstant.COMMUNITY_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();
log.info("communityServiceAbilityCalculateExistsSub getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculateExistsSub getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, form.getCustomerId(), form.getMonthId(), NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
/**
* @Description 社区相关计算 存在下级客户
* @Param form
* @author zxc
* @date 2021/1/15 下午1:47
*/
public Boolean communityRelateExistsSub(CalculateCommonFormDTO form) {
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId());
detailListByParentCode.forEach(detail -> {
factIndexCommunityScoreEntities.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
community.setScore(community.getScore().multiply(detail.getWeight()));
}
});
});
Map<String, List<FactIndexCommunityScoreDTO>> collect = factIndexCommunityScoreEntities.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
collect.forEach((key, value) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
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(IndexCalConstant.COMMUNITY_RELATE);
score.setAllParentIndexCode(NumConstant.ZERO_STR);
score.setWeight(new BigDecimal(NumConstant.ONE_NEG));
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
if (!CollectionUtils.isEmpty(result)){
factIndexCommunityScoreDao.insertCommunityPartyRecord(result);
}
return true;
}
}

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

@ -135,7 +135,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
//计算社区
start = System.currentTimeMillis();
try {
flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
flag = indexCalculateCommunityService.calCommunityAll(formDTO);
log.info("客户Id:{}【社区相关】计算完毕,总耗时:{}秒,result:{},result:{}", customerId, (System.currentTimeMillis() - start) / 1000, flag);
} catch (Exception e) {
log.error("indexCalculate calCommunityAll exception", e);

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

@ -122,4 +122,29 @@
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
<select id="selectCommunityInfoExistsSub" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">
SELECT
cs.CUSTOMER_ID,
cs.AGENCY_ID,
cs.MONTH_ID,
cs.QUARTER_ID,
cs.YEAR_ID,
cs.SCORE,
cs.INDEX_CODE,
cs.PARENT_AGENCY_ID
FROM
fact_index_community_score cs
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = cs.AGENCY_ID
WHERE
cs.del_flag = 0
AND CHAR_LENGTH(sca.AREA_CODE) >= 9
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND cs.MONTH_ID = #{monthId}
AND cs.IS_TOTAL = "0"
AND (cs.INDEX_CODE = "dangjiannengli"
OR cs.INDEX_CODE = "zhilinengli"
OR cs.INDEX_CODE = "fuwunengli")
</select>
</mapper>

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

@ -179,4 +179,27 @@
ORDER BY GRID_ID
</select>
<!-- 所有网格的平均值 -->
<select id="selectSubGridAvgScoreByAreaCode" resultType="com.epmet.dto.screen.result.SubGridAvgResultDTO">
SELECT
figc.agency_id AS agencyId,
figc.month_id as monthId,
figc.quarter_id as quarterId,
figc.year_id as yearId,
ROUND(AVG( figc.score ),6) AS score,
figc.customer_id as customerId,
sca.pid AS parentId
FROM
fact_index_grid_score figc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = figc.AGENCY_ID
WHERE
figc.del_flag = '0'
AND sca.DEL_FLAG = 0
AND figc.month_id = #{monthId}
AND figc.index_code = #{indexCode}
AND CHAR_LENGTH(sca.AREA_CODE) >= 9
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
GROUP BY figc.agency_id
</select>
</mapper>

25
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml

@ -149,4 +149,29 @@
AND MONTH_ID = #{monthId}
AND data_type = #{type}
</select>
<!-- 社区治理能力各个参数查询【被吹哨次数、办结项目数、项目响应度、超期项目率、【街道办结项目的处理效率,level为street时存在】、办结项目率、办结项目满意度】存在下级客户时 -->
<select id="selectCommunityGovernAbilityExistsSub" resultType="java.util.Map">
SELECT
gm.AGENCY_ID,
gm.PARENT_ID,
gm.MONTH_ID,
gm.QUARTER_ID,
gm.YEAR_ID,
gm.TRANSFERED_COUNT,
gm.CLOSED_PROJECT_COUNT,
gm.RESP_PROJECT_RATIO,
gm.OVERDUE_PROJECT_RATIO,
gm.CLOSED_PROJECT_RATIO,
gm.SATISFACTION_RATIO,
gm.HANDLE_PROJECT_RATIO
FROM
fact_index_govrn_ablity_org_monthly gm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = gm.AGENCY_ID
WHERE
gm.del_flag = '0'
AND gm.month_id = #{monthId}
AND CHAR_LENGTH(sca.AREA_CODE) >= 9
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
</select>
</mapper>

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

@ -112,4 +112,24 @@
AND month_id = #{monthId}
</select>
<!-- 查询社区下的发文数 Map【根据areaCode】 -->
<select id="selectPublishArticleCountMapbyAreaCode" resultType="java.util.Map">
SELECT
fm.AGENCY_ID,
fm.PARENT_ID,
fm.MONTH_ID,
fm.QUARTER_ID,
fm.YEAR_ID,
fm.PUBLISH_ARTICLE_COUNT,
fm.CUSTOMER_ID
FROM
fact_index_party_ablity_org_monthly fm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fm.AGENCY_ID
WHERE
fm.del_flag = '0'
AND fm.month_id = #{monthId}
AND CHAR_LENGTH(sca.AREA_CODE) >= 9
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
</select>
</mapper>

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

@ -111,4 +111,24 @@
AND customer_id = #{customerId}
AND month_id = #{monthId}
</select>
<!-- 社区活动组织次数 存在下级客户 -->
<select id="selectActivityCountMapExistsSub" resultType="java.util.Map">
SELECT
sm.AGENCY_ID,
sm.PARENT_ID,
sm.MONTH_ID,
sm.QUARTER_ID,
sm.YEAR_ID,
sm.ACTIVITY_COUNT,
sm.CUSTOMER_ID
FROM
fact_index_service_ablity_org_monthly sm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = sm.AGENCY_ID
WHERE
sm.del_flag = '0'
AND CHAR_LENGTH(sca.AREA_CODE) >= 9
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sm.month_id = #{monthId}
</select>
</mapper>

Loading…
Cancel
Save