Browse Source

社区相关优化 2

dev_shibei_match
zxc 5 years ago
parent
commit
ec598da9e3
  1. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  2. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java
  3. 45
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  5. 19
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml

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

@ -129,22 +129,9 @@ public class DemoController {
return new Result().ok(list);
}
@PostMapping("zxc")
public Result getZxc(){
// indexCalculateCommunityService.communityPublishArticleCountCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
indexCalculateCommunityService.communityGovernAbilityCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxc1")
public Result getZxc1(){
indexCalculateCommunityService.communityPartyCalculate("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}
@PostMapping("zxc2")
public Result getZxc2(){
indexCalculateCommunityService.calAll("b09527201c4409e19d1dbc5e3c3429a1","202008");
indexCalculateCommunityService.calCommunityAll("b09527201c4409e19d1dbc5e3c3429a1","202008");
return new Result();
}

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

@ -25,6 +25,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 党建能力-街道及社区相关事实表
@ -72,4 +73,13 @@ public interface FactIndexPartyAblityOrgMonthlyDao extends BaseDao<FactIndexPart
* @date 2020/8/26 10:49 上午
*/
List<CommunityPublishArticleCountResultDTO> selectPublishArticleCount(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 查询社区下的发文数 Map
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/26 10:49 上午
*/
List<Map<String,Object>> selectPublishArticleCountMap(@Param("customerId")String customerId, @Param("monthId")String monthId);
}

45
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateCommunityServiceImpl.java

@ -62,7 +62,6 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
*/
@Transactional(rollbackFor = Exception.class)
public Boolean communityPartyCalculate(String customerId, String monthId) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(),IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
@ -98,10 +97,48 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
indexStart++;
}while (collect.size() == NumConstant.TEN);
}
}else {
List<IndexInputVO> indexInputVOS = new ArrayList<>();
List<Map<String, Object>> maps = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId);
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(indexGroup.getIndexCode());
if (!StringUtils.isEmpty(fieldNameByIndexCode)) {
if (maps.get(NumConstant.ZERO).containsKey(fieldNameByIndexCode)) {
List<BigDecimal> decimalList = maps.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
Integer indexStart = NumConstant.ZERO;
Integer indexEnd = NumConstant.TEN;
List<Map<String, Object>> collect;
do {
collect = maps.stream().skip(indexEnd * indexStart).limit(indexEnd).collect(Collectors.toList());
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
collect.forEach(c -> {
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
FactIndexCommunityScoreDTO publishArticle = new FactIndexCommunityScoreDTO();
BeanUtils.copyProperties(c,publishArticle);
communityPublishArticle.add(publishArticle);
});
IndexInputVO index1VO = new IndexInputVO(indexGroup.getIndexId(), index1SampleValues, indexGroup.getThreshold(), indexGroup.getWeight(), sc1);
indexInputVOS.add(index1VO);
} while (collect.size() == NumConstant.TEN);
}
}
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
scoreCountOfSampleId.forEach((key,value) -> {
communityPublishArticle.forEach(grid -> {
if (key.equals(grid.getAgencyId())) {
grid.setCustomerId(customerId);
grid.setIndexCode(IndexCalConstant.COMMUNITY_GOVERN);
grid.setScore(grid.getScore().add(value));
}
});
});
}
});
// 社区名义发文数量
List<CommunityPublishArticleCountResultDTO> publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId);
/*List<CommunityPublishArticleCountResultDTO> publishArticleCounts = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCount(customerId, monthId);
detailListByParentCode.forEach(indexGroup -> {
if (indexGroup.getIndexCode().equals("shequmingyifwsl")) {
if (publishArticleCounts.size() == NumConstant.ONE) {
@ -134,7 +171,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
} while (collect.size() == NumConstant.TEN);
}
}
});
});*/
subAllGridList.forEach(grid -> {
communityPublishArticle.forEach(publish -> {
if (grid.getAgencyId().equals(publish.getAgencyId())){
@ -196,9 +233,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
List<Map<String,Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId);
if (communityGovernAbility.size() == NumConstant.ONE){
// TODO
}else if (communityGovernAbility.size() > NumConstant.ONE){
List<IndexInputVO> indexInputVOS = new ArrayList<>();
detailListByParentCode.forEach(detail -> {

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

@ -75,7 +75,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
}
//计算社区
try {
indexCalculateCommunityService.calAll(customerId, formDTO.getMonthId());
indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);

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

@ -90,4 +90,23 @@
AND month_id = #{monthId}
</select>
<!-- 查询社区下的发文数 Map -->
<select id="selectPublishArticleCountMap" resultType="java.util.Map">
SELECT
AGENCY_ID,
PARENT_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
PUBLISH_ARTICLE_COUNT,
CUSTOMER_ID
FROM
fact_index_party_ablity_org_monthly
WHERE
del_flag = '0'
AND data_type = 'community'
AND customer_id = #{customerId}
AND month_id = #{monthId}
</select>
</mapper>

Loading…
Cancel
Save