Browse Source

社区相关优化

dev_shibei_match
zxc 5 years ago
parent
commit
c46d36ab0d
  1. 1
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java
  2. 6
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java
  3. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  4. 79
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  5. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml

1
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java

@ -132,6 +132,7 @@ public class AgencyScoreDTO implements Serializable {
this.score = new BigDecimal(NumConstant.ZERO);
this.indexCode = "";
this.dataType = IndexCalConstant.STREET_LEVEL;
this.allParentIndexCode = "";
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";

6
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java

@ -84,6 +84,11 @@ public class FactIndexCommunityScoreDTO implements Serializable {
*/
private String indexCode;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
/**
* 删除状态
*/
@ -124,6 +129,7 @@ public class FactIndexCommunityScoreDTO implements Serializable {
this.isTotal = "0";
this.score = new BigDecimal(0);
this.indexCode = "";
this.allParentIndexCode = "";
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";

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

@ -47,11 +47,10 @@ public interface CommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity
* @Description 删除旧记录
* @param customerId
* @param monthId
* @param indexCode
* @author zxc
* @date 2020/9/1 9:03 上午
*/
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode);
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* @Description 查询社区相关信息

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

@ -26,6 +26,7 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
@ -102,7 +103,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -133,7 +134,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -141,9 +142,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
@ -185,7 +187,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -216,7 +218,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -224,9 +226,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
// HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
@ -265,7 +268,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -295,7 +298,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
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(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -303,9 +306,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
// HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
@ -338,6 +342,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE);
score.setAllParentIndexCode(NumConstant.ZERO_STR);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
@ -402,7 +407,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<FactIndexCommunityScoreDTO> subAllGridList) {
if (!CollectionUtils.isEmpty(subAllGridList)) {
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
}
@ -439,6 +443,49 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return result;
}
public List<FactIndexCommunityScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map<String, String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
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.getTotalScore());
score.setAllParentIndexCode(allParentIndexCode);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
score.setParentAgencyId(parentAgency);
}
});
if (!CollectionUtils.isEmpty(v.getDetails())) {
v.getDetails().forEach(fiveDetail -> {
FactIndexCommunityScoreDTO s = new FactIndexCommunityScoreDTO();
s.setCustomerId(customerId);
s.setAgencyId(k);
s.setMonthId(monthId);
s.setQuarterId(DateUtils.getQuarterId(monthId));
s.setYearId(DateUtils.getYearId(monthId));
s.setIsTotal(isTotal);
s.setIndexCode(fiveDetail.getIndexCode());
s.setScore(fiveDetail.getScore());
s.setAllParentIndexCode(fiveDetail.getAllParentIndexCode());
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
});
}
result.add(score);
});
return result;
}
/**
* @param agencyId
* @param customerId

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

@ -5,7 +5,7 @@
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
@ -19,6 +19,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
@ -38,7 +39,6 @@
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
</delete>
<!-- 查询社区相关信息 -->
@ -59,7 +59,9 @@
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "shequxiangguan"
AND INDEX_CODE = "dangjiannengli"
OR INDEX_CODE = "zhilinengli"
OR INDEX_CODE = "fuwunengli"
</select>
<!-- 街道下级所有社区服务能力得分平均值 -->

Loading…
Cancel
Save