Browse Source

指标计算优化

dev_shibei_match
zxc 5 years ago
parent
commit
2a1674c13b
  1. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  2. 44
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  3. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  5. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml
  6. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -74,4 +74,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @Date 16:57 2020-09-03
**/
List<ScreenCustomerAgencyEntity> selectListAgencyInfo(@Param("customerId")String customerId);
/**
* @Description 根据agencyId查询上级组织Id
* @param agencyId
* @author zxc
* @date 2020/9/8 3:36 下午
*/
String selectPid(@Param("agencyId")String agencyId);
}

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

@ -10,6 +10,7 @@ import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
@ -55,6 +56,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
private AgencyScoreDao agencyScoreDao;
@Autowired
private DeptScoreDao deptScoreDao;
@Autowired
private ScreenCustomerAgencyDao customerAgencyDao;
/**
* @Description 计算全区相关总分
@ -107,18 +110,14 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error(IndexCalConstant.DISTRICT_PARTY_AVG_NULL);
return;
} else if (subGridPartyAvgScore.size() == NumConstant.ONE) {
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) {
} else if (subGridPartyAvgScore.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> 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());
pid.put(c.getParentId(),customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
@ -184,18 +183,17 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
if (districtGovernAvgList.size() == NumConstant.ONE) {
pid.put(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(), districtGovernAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
if (CollectionUtils.isEmpty(districtGovernAvgList)) {
log.error("查询所有街道治理能力平均值集合为空");
return;
} else if (districtGovernAvgList.size() > NumConstant.ONE) {
} else if (districtGovernAvgList.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(districtGovernAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(districtGovernAvgList, 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());
pid.put(c.getParentId(),customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
@ -205,17 +203,16 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
} else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (deptScoreAvgList.size() == NumConstant.ONE) {
pid.put(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(), deptScoreAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
if (CollectionUtils.isEmpty(deptScoreAvgList)) {
log.error("查询所有直属部门治理能力平均值集合为空");
return;
} else if (deptScoreAvgList.size() > NumConstant.ONE) {
} else if (deptScoreAvgList.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(), c.getParentId());
pid.put(c.getParentId(),customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -254,19 +251,18 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) {
List<SubAgencyScoreAvgResultDTO> subStreetAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
if (subStreetAvgList.size() == NumConstant.ONE) {
pid.put(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(), subStreetAvgList.get(NumConstant.ZERO).getParentId());
sizeOne(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
if (CollectionUtils.isEmpty(subStreetAvgList)) {
log.error("查询区下属街道服务能力汇总平均值集合为空");
return;
} else if (subStreetAvgList.size() > NumConstant.ONE) {
} else if (subStreetAvgList.size() > NumConstant.ZERO) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subStreetAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> serviceAvgList = ListUtils.partition(subStreetAvgList, 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());
pid.put(c.getParentId(), customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);

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

@ -12,6 +12,7 @@ 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.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
@ -61,6 +62,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
private FactIndexCommunityScoreDao communityScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDao;
@Autowired
private ScreenCustomerAgencyDao customerAgencyDao;
/**
* @Description 计算街道相关总分
@ -113,18 +116,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.error(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL);
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) {
} 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());
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -190,17 +189,16 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
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);
if (CollectionUtils.isEmpty(subGridGovernAvg)){
log.error("查询街道下属所有社区治理能力汇总为空");
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
}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());
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -269,18 +267,17 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
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);
if (CollectionUtils.isEmpty(subCommServiceAvg)) {
log.error("查询街道下属社区服务能力得分平均值为空");
return;
} else if (subCommServiceAvg.size() > NumConstant.ONE) {
} 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());
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});

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

@ -101,7 +101,7 @@
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
AND fics.DATA_TYPE = #{dataType}
GROUP BY fics.agency_id
GROUP BY fics.parent_agency_id
</select>
<insert id="batchInsertAgencyScoreData" parameterType="map">

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

@ -65,7 +65,7 @@
<!-- 街道下级所有社区服务能力得分平均值 -->
<select id="selectSubCommAvgScore" resultType="com.epmet.dto.indexcal.SubCommunityAvgResultDTO">
SELECT
fics.agency_id,
fics.PARENT_AGENCY_ID AS agencyId,
fics.month_id,
fics.quarter_id,
fics.year_id,
@ -74,14 +74,14 @@
sca.pid AS parentId
FROM
fact_index_community_score fics
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.AGENCY_ID
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 fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.agency_id
GROUP BY fics.parent_agency_id
</select>
<select id="selectListCommunityScore" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">

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

@ -87,4 +87,15 @@
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
</select>
<!-- 根据agencyId查询上级组织Id -->
<select id="selectPid" resultType="java.lang.String">
SELECT
pid
FROM
screen_customer_agency
WHERE
del_flag = '0'
AND agency_id = #{agencyId}
</select>
</mapper>

Loading…
Cancel
Save