Browse Source

添加下级及自身分数 数据

master
jianjun 5 years ago
parent
commit
b70ef58633
  1. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySelfSubScoreDao.java
  2. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySelfSubScoreDao.java
  4. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java
  5. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  6. 86
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  7. 87
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  8. 87
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  9. 9
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySelfSubScoreDao.xml
  10. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml
  11. 75
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySelfSubScoreDao.xml
  12. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySelfSubScoreDao.java

@ -33,7 +33,7 @@ import java.util.List;
@Mapper
public interface AgencySelfSubScoreDao extends BaseDao<AgencySelfSubScoreEntity> {
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId);
int insertBatch(@Param("list") List<AgencySelfSubScoreEntity> list);
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("parentIndexCode") String parentIndexCode);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java

@ -19,8 +19,8 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -50,6 +50,7 @@ public interface AgencySubScoreDao extends BaseDao<AgencyScoreEntity> {
* @author zxc
* @date 2020/9/2 15:47
*/
Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType,@Param("delNum")Integer delNum);
Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType, @Param("delNum") Integer delNum);
List<AgencySubScoreEntity> selectSubListByPath(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("levelIndexPath") String levelIndexPath);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySelfSubScoreDao.java

@ -20,6 +20,9 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.indexcal.CommunitySelfSubScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社区相关 自身/下级分数表
@ -30,4 +33,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CommunitySelfSubScoreDao extends BaseDao<CommunitySelfSubScoreEntity> {
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
int insertBatch(@Param("list") List<CommunitySelfSubScoreEntity> communitySelfSubScoreEntities);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java

@ -49,6 +49,8 @@ public interface CommunitySubScoreDao extends BaseDao<FactIndexCommunitySubScore
* @author zxc
* @date 2020/9/1 9:03 上午
*/
Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId,@Param("delNum")Integer delNum);
Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("delNum") Integer delNum);
List<FactIndexCommunitySubScoreEntity> selectSubListByPath(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("levelIndexPath") String levelIndexPath);
}

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

@ -160,7 +160,6 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getGridId(), score.getScore(), score.getWeight(), partScore);
System.out.println("=====grid:" + score.getGridId() + ",originScore:" + score.getScore() + ",weight:" + score.getWeight() + ",finalScore:" + partScore + " ,selftotal:" + scoreEntity.getSelfScore() + ",subScore:" + scoreEntity.getSubScore());
});
deleteAndInsertSelfSubScore(formDTO, index.getIndexCode(), insertMap);
});

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

@ -6,19 +6,25 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
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.dao.evaluationindex.indexcal.CommunityScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CommunitySelfSubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CommunitySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao;
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.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CommunityCalResultDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.CommunitySelfSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.FactIndexCommunitySubScoreEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
@ -68,6 +74,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
private GridScoreDao factIndexGridScoreDao;
@Autowired
private CommunitySubScoreDao communitySubScoreDao;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
@Autowired
private CommunitySelfSubScoreDao communitySelfSubScoreDao;
/**
* @param customerId
@ -76,6 +86,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/1 4:12 下午
*/
@Override
public Boolean calCommunityAll(String customerId, String monthId) {
Boolean aBoolean = communityPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
@ -93,9 +104,84 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (!dBoolean.equals(true)) {
throw new RenException("calculate community-all insert failure ......");
}
//计算自身和下级
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO();
formDTO.setMonthId(monthId);
formDTO.setCustomerId(customerId);
calculateSelfSubScore(formDTO);
return true;
}
private void calculateSelfSubScore(CalculateCommonFormDTO formDTO) {
//todo 指标添加缓存
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.error("calculateSelfSubScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
indexList.forEach(index -> {
String levelIndexPath = index.getAllParentIndexCode().concat(StrConstant.COLON).concat(index.getIndexCode());
//获取出指标之间的关系
List<IndexGroupDetailEntity> selfSubIndexList = indexGroupDetailDao.selectSelfSubIndex(formDTO.getCustomerId(), levelIndexPath);
if (CollectionUtils.isEmpty(selfSubIndexList)) {
log.error("calculateSelfSubScore indexGroupDetailDao.selectSelfSubIndex return empty,customerId:{}", formDTO.getCustomerId());
return;
}
//获取该能力下的分数
List<FactIndexCommunitySubScoreEntity> subScore = communitySubScoreDao.selectSubListByPath(formDTO.getCustomerId(), formDTO.getMonthId(), levelIndexPath);
if (CollectionUtils.isEmpty(subScore)) {
log.error("calculateSelfSubScore communitySubScoreDao.selectSubListByPath return empty,customerId:{} ", formDTO.getCustomerId());
return;
}
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put("zishen", new HashSet<>());
selfSubParentMap.put("xiaji", new HashSet<>());
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf("xiaji") > -1) {
selfSubParentMap.get("xiaji").add(o.getIndexCode());
} else {
selfSubParentMap.get("zishen").add(o.getIndexCode());
}
});
Map<String, CommunitySelfSubScoreEntity> insertMap = new HashMap<>();
subScore.forEach(score -> {
String key = score.getAgencyId().concat(index.getIndexCode());
CommunitySelfSubScoreEntity scoreEntity = insertMap.get(key);
if (scoreEntity == null) {
scoreEntity = ConvertUtils.sourceToTarget(score, CommunitySelfSubScoreEntity.class);
insertMap.put(key, scoreEntity);
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get("xiaji").contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});
deleteAndInsertSelfSubScore(formDTO, index.getIndexCode(), insertMap);
});
}
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsertSelfSubScore(CalculateCommonFormDTO formDTO, String indexCode, Map<String, CommunitySelfSubScoreEntity> insertMap) {
int effectRow = 0;
do {
communitySelfSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode);
} while (effectRow > 0);
communitySelfSubScoreDao.insertBatch(new ArrayList<>(insertMap.values()));
}
/**
* @param customerId
* @Description 社区名义发文数量计算党建能力

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

@ -6,18 +6,24 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
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.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcal.AgencySelfSubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.AgencySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
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.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateDistrictService;
@ -65,11 +71,15 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
private ScreenCustomerAgencyDao customerAgencyDao;
@Autowired
private AgencySubScoreDao agencySubScoreDao;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
@Autowired
private AgencySelfSubScoreDao agencySelfSubScoreDao;
/**
* @Description 计算全区相关总分
* @param customerId
* @param monthId
* @Description 计算全区相关总分
* @author zxc
* @date 2020/9/2 3:12 下午
*/
@ -91,9 +101,84 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (!dBoolean.equals(true)) {
throw new RenException("calculate district-all insert failure ......");
}
//计算自身和下级
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO();
formDTO.setMonthId(monthId);
formDTO.setCustomerId(customerId);
calculateSelfSubScore(formDTO);
return true;
}
private void calculateSelfSubScore(CalculateCommonFormDTO formDTO) {
//todo 指标添加缓存
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.error("calculateSelfSubScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
indexList.forEach(index -> {
String levelIndexPath = index.getAllParentIndexCode().concat(StrConstant.COLON).concat(index.getIndexCode());
//获取出指标之间的关系
List<IndexGroupDetailEntity> selfSubIndexList = indexGroupDetailDao.selectSelfSubIndex(formDTO.getCustomerId(), levelIndexPath);
if (CollectionUtils.isEmpty(selfSubIndexList)) {
log.error("calculateSelfSubScore indexGroupDetailDao.selectSelfSubIndex return empty,customerId:{}", formDTO.getCustomerId());
return;
}
//获取该能力下的分数
List<AgencySubScoreEntity> subScore = agencySubScoreDao.selectSubListByPath(formDTO.getCustomerId(), formDTO.getMonthId(), levelIndexPath);
if (CollectionUtils.isEmpty(subScore)) {
log.error("calculateSelfSubScore communitySubScoreDao.selectSubListByPath return empty,customerId:{} ", formDTO.getCustomerId());
return;
}
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put("zishen", new HashSet<>());
selfSubParentMap.put("xiaji", new HashSet<>());
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf("xiaji") > -1) {
selfSubParentMap.get("xiaji").add(o.getIndexCode());
} else {
selfSubParentMap.get("zishen").add(o.getIndexCode());
}
});
Map<String, AgencySelfSubScoreEntity> insertMap = new HashMap<>();
subScore.forEach(score -> {
String key = score.getAgencyId().concat(index.getIndexCode());
AgencySelfSubScoreEntity scoreEntity = insertMap.get(key);
if (scoreEntity == null) {
scoreEntity = ConvertUtils.sourceToTarget(score, AgencySelfSubScoreEntity.class);
insertMap.put(key, scoreEntity);
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get("xiaji").contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});
deleteAndInsertSelfSubScore(formDTO, index.getIndexCode(), insertMap);
});
}
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsertSelfSubScore(CalculateCommonFormDTO formDTO, String indexCode, Map<String, AgencySelfSubScoreEntity> insertMap) {
int effectRow = 0;
do {
agencySelfSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode);
} while (effectRow > 0);
agencySelfSubScoreDao.insertBatch(new ArrayList<>(insertMap.values()));
}
/**
* @param customerId
* @Description 全区名义发文数量计算党建能力

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

@ -6,19 +6,25 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
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.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcal.AgencySelfSubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.AgencySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao;
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.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.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
@ -68,11 +74,15 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
private AgencyScoreDao agencyScoreDao;
@Autowired
private AgencySubScoreDao agencySubScoreDao;
@Autowired
private IndexGroupDetailDao indexGroupDetailDao;
@Autowired
private AgencySelfSubScoreDao agencySelfSubScoreDao;
/**
* @Description 计算街道相关总分
* @param customerId
* @param monthId
* @Description 计算街道相关总分
* @author zxc
* @date 2020/9/2 3:12 下午
*/
@ -94,9 +104,84 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (!dBoolean.equals(true)) {
throw new RenException("calculate street-all insert failure ......");
}
//计算自身和下级
CalculateCommonFormDTO formDTO = new CalculateCommonFormDTO();
formDTO.setMonthId(monthId);
formDTO.setCustomerId(customerId);
calculateSelfSubScore(formDTO);
return true;
}
private void calculateSelfSubScore(CalculateCommonFormDTO formDTO) {
//todo 指标添加缓存
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.error("calculateSelfSubScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
indexList.forEach(index -> {
String levelIndexPath = index.getAllParentIndexCode().concat(StrConstant.COLON).concat(index.getIndexCode());
//获取出指标之间的关系
List<IndexGroupDetailEntity> selfSubIndexList = indexGroupDetailDao.selectSelfSubIndex(formDTO.getCustomerId(), levelIndexPath);
if (CollectionUtils.isEmpty(selfSubIndexList)) {
log.error("calculateSelfSubScore indexGroupDetailDao.selectSelfSubIndex return empty,customerId:{}", formDTO.getCustomerId());
return;
}
//获取该能力下的分数
List<AgencySubScoreEntity> subScore = agencySubScoreDao.selectSubListByPath(formDTO.getCustomerId(), formDTO.getMonthId(), levelIndexPath);
if (CollectionUtils.isEmpty(subScore)) {
log.error("calculateSelfSubScore communitySubScoreDao.selectSubListByPath return empty,customerId:{} ", formDTO.getCustomerId());
return;
}
Map<String, Set<String>> selfSubParentMap = new HashMap<>();
selfSubParentMap.put("zishen", new HashSet<>());
selfSubParentMap.put("xiaji", new HashSet<>());
selfSubIndexList.forEach(o -> {
//找出自身 和下级的指标
if (o.getAllIndexCodePath().indexOf("xiaji") > -1) {
selfSubParentMap.get("xiaji").add(o.getIndexCode());
} else {
selfSubParentMap.get("zishen").add(o.getIndexCode());
}
});
Map<String, AgencySelfSubScoreEntity> insertMap = new HashMap<>();
subScore.forEach(score -> {
String key = score.getAgencyId().concat(index.getIndexCode());
AgencySelfSubScoreEntity scoreEntity = insertMap.get(key);
if (scoreEntity == null) {
scoreEntity = ConvertUtils.sourceToTarget(score, AgencySelfSubScoreEntity.class);
insertMap.put(key, scoreEntity);
scoreEntity.setSelfScore(new BigDecimal(0));
scoreEntity.setSubScore(new BigDecimal(0));
scoreEntity.setParentIndexCode(index.getIndexCode());
scoreEntity.setSelfWeight(new BigDecimal(0));
scoreEntity.setSubWeight(new BigDecimal(0));
}
BigDecimal partScore = score.getScore().multiply(score.getWeight());
if (selfSubParentMap.get("xiaji").contains(score.getIndexCode())) {
scoreEntity.setSubScore(scoreEntity.getSubScore().add(partScore));
scoreEntity.setSubWeight(scoreEntity.getSubWeight().add(score.getWeight()));
} else {
scoreEntity.setSelfScore(scoreEntity.getSelfScore().add(partScore));
scoreEntity.setSelfWeight(scoreEntity.getSelfWeight().add(score.getWeight()));
}
log.debug("=====key" + key + ",grid:{},originScore:{},weight:{},finalScore:{},total", score.getAgencyId(), score.getScore(), score.getWeight(), partScore);
});
deleteAndInsertSelfSubScore(formDTO, index.getIndexCode(), insertMap);
});
}
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsertSelfSubScore(CalculateCommonFormDTO formDTO, String indexCode, Map<String, AgencySelfSubScoreEntity> insertMap) {
int effectRow = 0;
do {
agencySelfSubScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode);
} while (effectRow > 0);
agencySelfSubScoreDao.insertBatch(new ArrayList<>(insertMap.values()));
}
/**
* @param customerId
* @Description 社区名义发文数量计算党建能力

9
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySelfSubScoreDao.xml

@ -4,11 +4,16 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.AgencySelfSubScoreDao">
<delete id="deleteByMonthId">
delete from fact_index_agency_self_sub_score limit 1000
delete from fact_index_agency_self_sub_score
where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
and PARENT_INDEX_CODE = #{parentIndexCode,jdbcType=VARCHAR}
limit 1000
</delete>
<insert id="insertBatch">
INSERT INTO fact_index_agency_self_sub_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID,
INSERT INTO fact_index_agency_self_sub_score
(ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID,
DATA_TYPE, SELF_SCORE, SUB_SCORE, PARENT_INDEX_CODE,ALL_PARENT_INDEX_CODE,
SELF_WEIGHT,SUB_WEIGHT,DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml

@ -46,4 +46,15 @@
LIMIT #{delNum}
</delete>
<select id="selectSubListByPath" resultType="com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity">
SELECT
ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, ORIGIN_VALUE, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE,
WEIGHT
FROM
fact_index_agency_sub_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

75
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySelfSubScoreDao.xml

@ -3,26 +3,59 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.CommunitySelfSubScoreDao">
<resultMap type="com.epmet.entity.evaluationindex.indexcal.CommunitySelfSubScoreEntity" id="factIndexCommunitySelfSubScoreMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="parentAgencyId" column="PARENT_AGENCY_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="scoreType" column="SCORE_TYPE"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
<result property="allParentIndexCode" column="ALL_PARENT_INDEX_CODE"/>
<result property="weight" column="WEIGHT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByMonthId">
delete from fact_index_community_self_sub_score
where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
AND PARENT_INDEX_CODE = #{parentIndexCode,jdbcType=VARCHAR}
limit 1000
</delete>
<insert id="insertBatch">
INSERT INTO `fact_index_grid_self_sub_score` (
`ID`,
`CUSTOMER_ID`,
`AGENCY_ID`,
`PARENT_AGENCY_ID`,
`QUARTER_ID`,
`YEAR_ID`,
`MONTH_ID`,
`SELF_SCORE`,
`SUB_SCORE`,
`PARENT_INDEX_CODE`,
`ALL_PARENT_INDEX_CODE`,
`SELF_WEIGHT`,
`SUB_WEIGHT`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
`CREATED_TIME`,
`UPDATED_BY`,
`UPDATED_TIME`
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.selfScore},
#{item.subScore},
#{item.parentIndexCode},
#{item.allParentIndexCode},
#{item.selfWeight},
#{item.subWeight},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

@ -44,4 +44,16 @@
LIMIT #{delNum}
</delete>
<select id="selectSubListByPath"
resultType="com.epmet.entity.evaluationindex.indexcal.FactIndexCommunitySubScoreEntity">
SELECT
ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, ORIGIN_VALUE, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE,
WEIGHT
FROM
fact_index_grid_sub_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND ALL_PARENT_INDEX_CODE = #{allIndexCodePath,jdbcType=VARCHAR}
</select>
</mapper>

Loading…
Cancel
Save