Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_screen_data

dev_shibei_match
yinzuomei 5 years ago
parent
commit
7a843a47a5
  1. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java
  2. 51
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java
  3. 46
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java
  4. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java
  5. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  6. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java
  8. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java
  9. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java
  10. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java
  11. 79
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  12. 424
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  13. 22
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  14. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml
  15. 26
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml
  16. 69
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java

@ -14,6 +14,10 @@ public interface IndexCalConstant {
String AGENCY_ID="AGENCY_ID";
String PARENT_AGENCY_ID = "parentAgencyId";
String PARENT_ID = "PARENT_ID";
String CUSTOMER_ID="CUSTOMER_ID";
String MONTH_ID="MONTH_ID";

51
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/9/2 6:01 下午
*/
@Data
public class SubCommunityAvgResultDTO implements Serializable {
private static final long serialVersionUID = 7681907923515081626L;
/**
*
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 分数
*/
private BigDecimal score;
}

46
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java

@ -0,0 +1,46 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/9/2 5:54 下午
*/
@Data
public class SubCommunityGovernAvgResultDTO implements Serializable {
private static final long serialVersionUID = 4591964909777753497L;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 分数
*/
private BigDecimal score;
}

2
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java → epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java

@ -10,7 +10,7 @@ import java.math.BigDecimal;
* @DateTime 2020/8/28 3:15 下午
*/
@Data
public class SubGridPartyAvgResultDTO implements Serializable {
public class SubGridAvgResultDTO implements Serializable {
private static final long serialVersionUID = 1592381327492545907L;

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

@ -19,6 +19,7 @@ import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.indexcal.GridCorreLationService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
import com.epmet.service.stats.DimAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,6 +51,8 @@ public class DemoController {
private IndexCalculateCommunityService indexCalculateCommunityService;
@Autowired
private GridCorreLationService gridCorreLationService;
@Autowired
private IndexCalculateStreetService indexCalculateStreetService;
@GetMapping("testAlarm")
public void testAlarm() {
@ -442,4 +445,11 @@ public class DemoController {
entity.setUpdatedBy(IndexCalConstant.insertUser);
return entity;
}
@PostMapping("streetZxc")
public void getStreet(){
String customerId = "b09527201c4409e19d1dbc5e3c3429a1";
String monthId = "202008";
indexCalculateStreetService.calStreetAll(customerId,monthId);
}
}

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

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -52,5 +53,13 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType);
/**
* @Description 查询街道相关信息
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<AgencyScoreDTO> selectStreetInfo(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("dataType")String dataType);
}

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

@ -64,7 +64,7 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao<FactIndexGovr
void batchInsertFactIndexGovrnAblityOrgMonthly(@Param("list") List<OrgGovrnAbilityFormDTO> list, @Param("customerId")String customerId);
/**
* @Description 社区治理能力各个参数查询被吹哨次数办结项目数项目响应度超期项目率办结项目率办结项目满意度
* @Description 社区治理能力各个参数查询被吹哨次数办结项目数项目响应度超期项目率街道办结项目的处理效率level为street时存在办结项目率办结项目满意度
* @param customerId
* @param monthId
* @author zxc

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java

@ -18,6 +18,9 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.SubCommunityGovernAvgResultDTO;
import com.epmet.dto.indexcal.SubCommunityPartyAvgResultDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity;
import org.apache.ibatis.annotations.Mapper;
@ -61,4 +64,13 @@ public interface FactIndexCommunityScoreDao extends BaseDao<FactIndexCommunitySc
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* @Description 街道下级所有社区得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}

25
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java

@ -19,7 +19,7 @@ package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
import com.epmet.entity.evaluationindex.screen.FactIndexGridScoreEntity;
import org.apache.ibatis.annotations.Mapper;
@ -37,30 +37,11 @@ import java.util.List;
public interface FactIndexGridScoreDao extends BaseDao<FactIndexGridScoreEntity> {
/**
* @Description 下属所有网格的党建能力平均值
* @Description 下属所有网格的平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/28 3:20 下午
*/
List<SubGridPartyAvgResultDTO> selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId);
/**
* @Description 社区下属所有网格治理能力汇总平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 9:19 上午
*/
List<SubGridGovernAvgResultDTO> selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 社区下级所有网格服务能力得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubGridServiceAvgResultDTO> selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
List<SubGridAvgResultDTO> selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java

@ -28,6 +28,9 @@ public enum IndexCodeEnum {
XIA_SHU_SUO_YOU_WGDDJNLPJZ("xiashusuoyouwgddjnlpjz","下属所有网格的党建能力(平均值)",5),
SHE_QU_XIA_SHU_SYWGZLNLHZPJZ("shequxiashusywgzlnlhzpjz","社区下属所有网格治理能力汇总(平均值)",5),
SHE_QU_XIA_JI_SYWGFWNLDFPJZ("shequxiajisywgfwnldfpjz","社区下级所有网格服务能力得分(平均值) ",5),
JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ("jiedaoxiashusysqdjnlhzpjz","街道下属所有社区党建能力汇总(平均值)",5),
JIE_DAO_XIA_SHU_SYSQZLNLHZ("jiedaoxiashusysqzlnlhz","街道下属所有社区治理能力汇总 (平均值) ",5),
JIE_DAO_XIA_SHU_SQFWNLDFPYZ("jiedaoxiashusqfwnldfpjz","街道下属社区服务能力得分 (平均值) ",5),
;
private String code;

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

@ -14,9 +14,7 @@ import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao;
import com.epmet.dao.evaluationindex.screen.FactIndexGridScoreDao;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
@ -80,23 +78,26 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
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<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error("查询下属所有网格的党建能力平均值集合为空");
return;
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subGridPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubGridPartyAvgResultDTO>> partition = ListUtils.partition(subGridPartyAvgScore, indexEnd);
partition.forEach(publish -> {
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd);
subPartyAvgList.forEach( party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
party.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -107,8 +108,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
} else {
// 社区名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(mapList)) {
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.error("查询社区名义发文数量集合为空");
return;
}
@ -116,17 +117,19 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】");
return;
}else if (mapList.size() == NumConstant.ONE){
sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
}else if (publishArticleCountList.size() == NumConstant.ONE){
pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (mapList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = mapList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
}else if (publishArticleCountList.size() > NumConstant.ONE) {
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(mapList, 10);
publishArticleList.forEach(publish -> {
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, 10);
publishArticleList.forEach( publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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);
});
@ -138,7 +141,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
@ -158,18 +161,21 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
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<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (subGridGovernAvg.size() == NumConstant.ONE) {
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridGovernAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, 10);
List<List<SubGridAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, 10);
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);
});
@ -185,7 +191,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.error("查询治理能力的六个五级指标集合为空");
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
@ -200,6 +207,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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);
});
@ -211,7 +219,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
@ -231,20 +239,23 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return false;
}
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<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subGridServiceAvg.size() == NumConstant.ONE) {
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId().toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),subGridServiceAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (subGridServiceAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridServiceAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10);
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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);
});
@ -258,7 +269,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.error("查询社区活动组织次数集合为空");
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
@ -273,6 +285,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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);
});
@ -284,7 +297,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
@ -319,6 +332,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
@ -394,7 +408,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) {
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
@ -406,6 +420,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
pid.forEach((agency,parentAgency) -> {
if (k.equals(agency)){
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
@ -419,10 +438,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode){
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map<String,String> pid){
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -1,10 +1,42 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.druid.util.StringUtils;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService;
import com.epmet.service.evaluationindex.screen.IndexGroupDetailService;
import com.epmet.support.normalizing.BigDecimalScoreCalculator;
import com.epmet.support.normalizing.Correlation;
import com.epmet.support.normalizing.ScoreCalculator;
import com.epmet.support.normalizing.ScoreConstants;
import com.epmet.support.normalizing.batch.BatchScoreCalculator;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author zxc
@ -15,6 +47,21 @@ import org.springframework.stereotype.Service;
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetService {
@Autowired
private FactIndexPartyAblityOrgMonthlyDao factIndexPartyAblityOrgMonthlyDao;
@Autowired
private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao;
@Autowired
private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao;
@Autowired
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private FactIndexCommunityScoreDao communityScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDao;
/**
* @Description 计算街道相关总分
* @param customerId
@ -24,6 +71,381 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
*/
@Override
public Boolean calStreetAll(String customerId, String monthId) {
return null;
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 ......");
}
return true;
}
/**
* @param customerId
* @Description 社区名义发文数量计算党建能力
* @author zxc
* @date 2020/8/26 10:46 上午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean streetPartyCalculate(String customerId, String monthId) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
return false;
}
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.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.error("查询下属所有社区的党建能力平均值集合为空");
return;
}else if (subCommPartyAvgScore.size() == NumConstant.ONE){
pid.put(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subCommPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (subCommPartyAvgScore.size() > NumConstant.ONE) {
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 街道名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId, IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(mapList)) {
log.error("查询街道名义发文数量集合为空");
return;
}
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldName)) {
log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】");
return;
}else if (mapList.size() == NumConstant.ONE){
pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (mapList.size() > NumConstant.ONE) {
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, 10);
publishArticleList.forEach(publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道治理能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/26 1:40 下午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean streetGovernAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
return false;
}
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.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (subGridGovernAvg.size() == NumConstant.ONE) {
pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, 10);
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId,IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.error("查询治理能力的六个五级指标集合为空");
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
System.err.println(fieldNameByIndexCode);
System.err.println(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + 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, 10);
governAbilityList.forEach(governAbility -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道服务能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:38 下午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean streetServiceAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
return false;
}
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.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subCommServiceAvg.size() == NumConstant.ONE) {
pid.put(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),subCommServiceAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (subCommServiceAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> serviceAvgList = ListUtils.partition(subCommServiceAvg, 10);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
} else {
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMap(customerId, monthId,IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error("查询街道活动组织次数集合为空");
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + 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, 10);
communityActivityList.forEach(communityActivity -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
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.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid
);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道相关计算
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/3 9:21 上午
*/
public Boolean streetRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectStreetInfo(customerId, 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);
value.forEach(street -> {
score.setScore(score.getScore().add(street.getScore()));
score.setParentAgencyId(street.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), result);
return true;
}
/**
* @param list
* @Description BigDecimal类型获取最大数和最小数
* @author zxc
* @date 2020/8/27 1:30 下午
*/
public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List<BigDecimal> list) {
BigDecimal max = Collections.max(list);
BigDecimal min = Collections.min(list);
MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO();
result.setMax(max);
result.setMin(min);
return result;
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllCommunityList
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<AgencyScoreDTO> subAllCommunityList) {
if (!CollectionUtils.isEmpty(subAllCommunityList)) {
agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.STREET_LEVEL);
agencyScoreDao.insertStreetRecord(subAllCommunityList);
}
}
/**
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setCustomerId(customerId);
score.setAgencyId(k);
score.setMonthId(monthId);
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
pid.forEach((agency,parentAgency) -> {
if (k.equals(agency)){
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
}
/**
* @Description 当查询结果为一条时调用此方法
* @param agencyId
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map<String,String> pid){
HashMap<String, BigDecimal> scoreCountOfSample = new HashMap<>();
scoreCountOfSample.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -42,4 +42,26 @@
AND index_code = #{indexCode}
AND data_type = #{dataType}
</delete>
<!-- 查询街道相关信息 -->
<select id="selectStreetInfo" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_agency_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "jiedaoxiangguan"
AND data_type = #{dataType}
</select>
</mapper>

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

@ -102,7 +102,8 @@
RESP_PROJECT_RATIO,
OVERDUE_PROJECT_RATIO,
CLOSED_PROJECT_RATIO,
SATISFACTION_RATIO
SATISFACTION_RATIO,
HANDLE_PROJECT_RATIO
FROM
fact_index_govrn_ablity_org_monthly
WHERE

26
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml

@ -50,14 +50,38 @@
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_community_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "shequxiangguan"
</select>
<!-- 街道下级所有社区服务能力得分平均值 -->
<select id="selectSubCommAvgScore" resultType="com.epmet.dto.indexcal.SubCommunityAvgResultDTO">
SELECT
fics.agency_id,
fics.month_id,
fics.quarter_id,
fics.year_id,
AVG( fics.score ) 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.AGENCY_ID
WHERE
fics.del_flag = '0'
AND sca.DEL_FLAG = 0
AND fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.agency_id
</select>
</mapper>

69
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml

@ -3,60 +3,25 @@
<mapper namespace="com.epmet.dao.evaluationindex.screen.FactIndexGridScoreDao">
<!-- 下属所有网格的党建能力平均值 -->
<select id="selectSubGridPartyAvgScore" resultType="com.epmet.dto.screen.result.SubGridPartyAvgResultDTO">
<!-- 下属所有网格的平均值 -->
<select id="selectSubGridAvgScore" resultType="com.epmet.dto.screen.result.SubGridAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
figc.agency_id AS agencyId,
figc.month_id as monthId,
figc.quarter_id as quarterId,
figc.year_id as yearId,
AVG( figc.score ) AS score,
figc.customer_id as customerId,
sca.pid AS parentId
FROM
fact_index_grid_score
fact_index_grid_score figc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = figc.AGENCY_ID
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'dangjiannengli'
GROUP BY agency_id
</select>
<!-- 社区下属所有网格治理能力汇总平均值 -->
<select id="selectSubGridGovernAvgScore" resultType="com.epmet.dto.screen.result.SubGridGovernAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'zhilinengli'
GROUP BY agency_id
</select>
<!-- 社区下级所有网格服务能力得分平均值 -->
<select id="selectSubGridServiceAvgScore" resultType="com.epmet.dto.screen.result.SubGridServiceAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'fuwunengli'
GROUP BY agency_id
figc.del_flag = '0'
AND sca.DEL_FLAG = 0
AND figc.customer_id = #{customerId}
AND figc.month_id = #{monthId}
AND figc.index_code = #{indexCode}
GROUP BY figc.agency_id
</select>
</mapper>
Loading…
Cancel
Save