|
|
|
@ -8,10 +8,7 @@ import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.constant.IndexCalConstant; |
|
|
|
import com.epmet.constant.OrgTypeConstant; |
|
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
import com.epmet.constant.*; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.AgencySelfSubScoreDao; |
|
|
|
import com.epmet.dao.evaluationindex.indexcal.AgencySubScoreDao; |
|
|
|
@ -20,10 +17,12 @@ 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.IndexGroupDetailDao; |
|
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
|
import com.epmet.dto.indexcal.AgencyCalResultDTO; |
|
|
|
import com.epmet.dto.indexcal.AgencyScoreDTO; |
|
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
|
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO; |
|
|
|
import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; |
|
|
|
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity; |
|
|
|
import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity; |
|
|
|
@ -49,6 +48,7 @@ import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -80,6 +80,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
private IndexGroupDetailDao indexGroupDetailDao; |
|
|
|
@Autowired |
|
|
|
private AgencySelfSubScoreDao agencySelfSubScoreDao; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerAgencyDao customerAgencyDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param form |
|
|
|
@ -613,7 +615,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
//下属所有社区的党建能力平均值
|
|
|
|
detailListByParentCode.forEach(detail -> { |
|
|
|
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { |
|
|
|
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = disposeSubAvg(dispose, form); |
|
|
|
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) { |
|
|
|
log.warn(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL); |
|
|
|
} else if (subCommPartyAvgScore.size() > NumConstant.ZERO) { |
|
|
|
@ -623,6 +626,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
partition.forEach(publish -> { |
|
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
|
publish.forEach(c -> { |
|
|
|
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode())); |
|
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
|
index1SampleValues.add(s); |
|
|
|
@ -634,7 +638,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 街道名义发文数量
|
|
|
|
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode(),NumConstant.NINE); |
|
|
|
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubStreet(monthId,form.getCustomerAreaCode()); |
|
|
|
if (CollectionUtils.isEmpty(mapList)) { |
|
|
|
log.warn(IndexCalConstant.STREET_PUBLISH_ARTICLE_LIST_NULL); |
|
|
|
} else { |
|
|
|
@ -688,7 +692,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
Map<String, String> pid = new HashMap<>(); |
|
|
|
detailListByParentCode.forEach(detail -> { |
|
|
|
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) { |
|
|
|
List<SubCommunityAvgResultDTO> subGridGovernAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> subGridGovernAvg = disposeSubAvg(dispose,form); |
|
|
|
if (CollectionUtils.isEmpty(subGridGovernAvg)){ |
|
|
|
log.warn("查询街道下属所有社区治理能力汇总为空"); |
|
|
|
}else if (subGridGovernAvg.size() > NumConstant.ZERO) { |
|
|
|
@ -697,6 +702,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
governAvg.forEach(avg -> { |
|
|
|
List<SampleValue> index1SampleValues = new ArrayList<>(); |
|
|
|
avg.forEach(c -> { |
|
|
|
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode())); |
|
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
|
index1SampleValues.add(s); |
|
|
|
@ -708,7 +714,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 治理能力的六个五级指标
|
|
|
|
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(monthId,form.getCustomerAreaCode()); |
|
|
|
List<Map<String, Object>> communityGovernAbility = disposeFiveLevel(form); |
|
|
|
if (CollectionUtils.isEmpty(communityGovernAbility)){ |
|
|
|
log.warn(IndexCalConstant.STREET_GOVERN_ABILITY_NULL); |
|
|
|
}else{ |
|
|
|
@ -762,7 +768,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
detailListByParentCode.forEach(detail -> { |
|
|
|
String indexCode = detail.getIndexCode(); |
|
|
|
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) { |
|
|
|
List<SubCommunityAvgResultDTO> subCommServiceAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> subCommServiceAvg = disposeSubAvg(dispose,form); |
|
|
|
if (CollectionUtils.isEmpty(subCommServiceAvg)) { |
|
|
|
log.warn("查询街道下属社区服务能力得分平均值为空"); |
|
|
|
} else if (subCommServiceAvg.size() > NumConstant.ZERO) { |
|
|
|
@ -772,6 +779,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
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 -> { |
|
|
|
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode())); |
|
|
|
pid.put(c.getAgencyId(),c.getParentId()); |
|
|
|
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); |
|
|
|
index1SampleValues.add(s); |
|
|
|
@ -781,7 +789,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSubNotSelf(monthId,form.getCustomerAreaCode()); |
|
|
|
List<Map<String, Object>> communityActivityCountList = disposeActivityCount(form); |
|
|
|
if (CollectionUtils.isEmpty(communityActivityCountList)) { |
|
|
|
log.warn(IndexCalConstant.STREET_SERVICE_ABILITY_NULL); |
|
|
|
}else{ |
|
|
|
@ -826,7 +834,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
String customerId = form.getCustomerId(); |
|
|
|
String monthId = form.getMonthId(); |
|
|
|
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); |
|
|
|
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), NumConstant.NINE, monthId, IndexCalConstant.STREET_LEVEL); |
|
|
|
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), monthId, IndexCalConstant.STREET_LEVEL,form.getCustomerId()); |
|
|
|
detailListByParentCode.forEach(detail -> { |
|
|
|
agencyScoreList.forEach(community -> { |
|
|
|
if (detail.getIndexCode().equals(community.getIndexCode())) { |
|
|
|
@ -860,4 +868,76 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
public List<SubCommunityAvgResultDTO> disposeSubAvg(List<SubCommunityAvgResultDTO> avgScore, CalculateCommonFormDTO formDTO){ |
|
|
|
List<ScreenProjectOrgDailyDTO> orgIds = customerAgencyDao.selectAgencyByParentAreaCode(formDTO.getCustomerAreaCode()); |
|
|
|
List<SubCommunityAvgResultDTO> subAvgScores = new ArrayList<>(); |
|
|
|
orgIds.forEach(org -> { |
|
|
|
SubCommunityAvgResultDTO s = new SubCommunityAvgResultDTO(); |
|
|
|
s.setAgencyId(org.getOrgId()); |
|
|
|
subAvgScores.add(s); |
|
|
|
}); |
|
|
|
subAvgScores.forEach(subScore -> { |
|
|
|
if (!CollectionUtils.isEmpty(avgScore)){ |
|
|
|
avgScore.forEach(avg -> { |
|
|
|
if (subScore.getAgencyId().equals(avg.getParentId())){ |
|
|
|
subScore.setScore(avg.getScore()); |
|
|
|
avg.setScoreStatus(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
Map<Boolean, List<SubCommunityAvgResultDTO>> groupByStatus = avgScore.stream().collect(Collectors.groupingBy(SubCommunityAvgResultDTO::getScoreStatus)); |
|
|
|
List<SubCommunityAvgResultDTO> subAvgResultDTOS = groupByStatus.get(false); |
|
|
|
if (!CollectionUtils.isEmpty(subAvgResultDTOS)){ |
|
|
|
AtomicReference<BigDecimal> finalScore = new AtomicReference<>(new BigDecimal(NumConstant.ZERO)); |
|
|
|
subAvgResultDTOS.forEach(sub -> { |
|
|
|
finalScore.set(finalScore.get().add(sub.getScore())); |
|
|
|
}); |
|
|
|
BigDecimal divide = finalScore.get().divide(new BigDecimal(subAvgResultDTOS.size())); |
|
|
|
subAvgScores.forEach(s -> { |
|
|
|
if (s.getAgencyId().equals("1234085031077498881")){ |
|
|
|
s.setScore(divide); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return subAvgScores; |
|
|
|
} |
|
|
|
|
|
|
|
public List<Map<String, Object>> disposeFiveLevel(CalculateCommonFormDTO formDTO){ |
|
|
|
List<Map<String, Object>> result = new ArrayList<>(); |
|
|
|
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(formDTO.getMonthId(),formDTO.getCustomerAreaCode(), ScreenConstant.STREET); |
|
|
|
List<Map<String, Object>> kongCunGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityIsKongCun(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); |
|
|
|
if (!CollectionUtils.isEmpty(kongCunGovernAbility)){ |
|
|
|
kongCunGovernAbility.forEach(k -> { |
|
|
|
k.put("AGENCY_ID",k.get("PARENT_ID")); |
|
|
|
k.put("PARENT_ID",NumConstant.ZERO_STR); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(communityGovernAbility)){ |
|
|
|
result.addAll(communityGovernAbility); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(kongCunGovernAbility)){ |
|
|
|
result.addAll(kongCunGovernAbility); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public List<Map<String, Object>> disposeActivityCount(CalculateCommonFormDTO formDTO){ |
|
|
|
List<Map<String, Object>> result = new ArrayList<>(); |
|
|
|
List<Map<String, Object>> ActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSub(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); |
|
|
|
List<Map<String, Object>> kongCunActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapIsKongCun(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); |
|
|
|
if (!CollectionUtils.isEmpty(kongCunActivityCountList)){ |
|
|
|
kongCunActivityCountList.forEach(k -> { |
|
|
|
k.put("AGENCY_ID",k.get("PARENT_ID")); |
|
|
|
k.put("PARENT_ID",NumConstant.ZERO_STR); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(ActivityCountList)){ |
|
|
|
result.addAll(ActivityCountList); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(kongCunActivityCountList)){ |
|
|
|
result.addAll(kongCunActivityCountList); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|