Browse Source

代码优化

master
yinzuomei 5 years ago
parent
commit
ecd133006e
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  2. 113
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java

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

@ -100,7 +100,9 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
**/
@Override
public Boolean calculateDeptCorreLation(CalculateCommonFormDTO formDTO) {
//1、区直部门-治理能力下五级指标分值计算+ 治理能力总分计算
calculateZhiLiNengLiScore(formDTO);
//2、区直部门 总分计算
calculateDeptTotalScore(formDTO);
return true;
}

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

@ -82,69 +82,39 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
**/
@Override
public Boolean calculateGridCorreLation(CalculateCommonFormDTO formDTO) {
boolean resultFlag = false;
//1、计算网格相关-党建能力
List<IndexGroupDetailEntity> dangJianNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(dangJianNengLiList)) {
log.warn("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:党建能力】指标权重信息不存在");
}
calculateGridDangJian(formDTO, dangJianNengLiList);
calculateGridDangJian(formDTO);
//2、计算网格相关-治理能力
List<IndexGroupDetailEntity> zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(zhiLiNengLiList)) {
log.warn("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:治理能力】指标权重信息不存在");
}
calculateGridZhiLi(formDTO, zhiLiNengLiList);
calculateGridZhiLi(formDTO);
//3、计算网格相关-服务能力
List<IndexGroupDetailEntity> fuWuNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(fuWuNengLiList)) {
log.warn("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:服务能力】指标权重信息不存在");
}
calculateGridFuWu(formDTO, fuWuNengLiList);
calculateGridFuWu(formDTO);
//4、计算网格相关总分
List<IndexGroupDetailEntity> wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(wgxgList)) {
log.warn("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
calculateGridTotal(formDTO, wgxgList, IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
resultFlag = true;
return resultFlag;
calculateGridTotal(formDTO);
return true;
}
/**
* @param formDTO
* @param indexList
* @return void
* @author yinzuomei
* @description 计算网格相关-党建能力
* @Date 2020/8/26 16:47
**/
@Transactional(rollbackFor = Exception.class)
public void calculateGridDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
public void calculateGridDangJian(CalculateCommonFormDTO formDTO) {
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:党建能力】指标权重信息不存在");
}
//查询总记录数
int total = factIndexPartyAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
log.warn(String.format("customerId=%s,monthId=%s,没有上传网格相关-党建能力-五级指标数据", formDTO.getCustomerId(), formDTO.getMonthId()));
return;
}
//只有一个网格的事实记录时无需处理以下代码注释
/*else if (NumConstant.ONE == total) {
//只有一个网格时
log.warn(String.format("indexCode:%s,customerId:%s,monthId:%s,only one fact_index_party_ablity_grid_monthly record",IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),formDTO.getCustomerId(),formDTO.getMonthId()));
this.handleOneGridScene(formDTO,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
}*/
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
log.info(String.format("共%s条数据,分%s次计算", total, totalPage));
@ -196,7 +166,6 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),
IndexCalConstant.GRID_DJ_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
@ -368,7 +337,6 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
private void saveGridCorreLationResult(CalculateCommonFormDTO formDTO,
List<HashMap<String, CalculateResult>> resultMapList,
String indexCode,
String allParentIndexCode,
String isTotal) {
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
@ -442,8 +410,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
//如果想看每一个指标的分值调用下面的方法
List<IndexOutputVO> listTemp=batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
log.info("计算的结果(List)"+JSON.toJSONString(listTemp));
/*List<IndexOutputVO> listTemp=batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
log.info("计算的结果(List)"+JSON.toJSONString(listTemp));*/
HashMap<String, CalculateResult> resultMap = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("计算的结果{}", resultMap);
@ -531,25 +499,25 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
/**
* @param formDTO
* @param indexList
* @return void
* @author yinzuomei
* @description 计算网格相关-治理能力
* @Date 2020/8/26 16:47
**/
private void calculateGridZhiLi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridZhiLi(CalculateCommonFormDTO formDTO) {
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:治理能力】指标权重信息不存在");
}
//查询总记录数
int total = factIndexGovrnAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
log.warn(String.format("customerId%s,monthId%s,没有上传网格相关-治理能力-五级指标数据", formDTO.getCustomerId(), formDTO.getMonthId()));
return;
}
//只有一个网格的事实记录时无需处理以下代码注释
/*else if (NumConstant.ONE == total) {
//只有一个网格时
log.warn(String.format("indexCode:%s,customerId:%s,monthId:%s,only one fact_index_govrn_ablity_grid_monthly record",IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),formDTO.getCustomerId(),formDTO.getMonthId()));
this.handleOneGridScene(formDTO,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
}*/
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
log.info(String.format("共%s条数据,分%s次计算", total, totalPage));
@ -598,32 +566,31 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),
IndexCalConstant.GRID_ZL_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
/**
* @param formDTO
* @param indexList
* @return void
* @author yinzuomei
* @description 计算网格相关-服务能力
* @Date 2020/8/26 16:48
**/
private void calculateGridFuWu(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridFuWu(CalculateCommonFormDTO formDTO) {
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:服务能力】指标权重信息不存在");
}
//查询总记录数
int total = factIndexServiceAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
log.warn(String.format("customerId:%s,monthId:%s,没有上传网格相关-服务能力-五级指标数据", formDTO.getCustomerId(), formDTO.getMonthId()));
return;
}
//只有一个网格的事实记录时无需处理以下代码注释
/*else if (NumConstant.ONE == total) {
//只有一个网格时
log.warn(String.format("indexCode:%s,customerId:%s,monthId:%s,only one fact_index_service_ablity_grid_monthly record",IndexCodeEnum.FU_WU_NENG_LI.getCode(),formDTO.getCustomerId(),formDTO.getMonthId()));
this.handleOneGridScene(formDTO,IndexCodeEnum.FU_WU_NENG_LI.getCode());
}*/
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
log.info(String.format("共%s条数据,分%s次计算", total, totalPage));
@ -668,19 +635,23 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.FU_WU_NENG_LI.getCode(),
IndexCalConstant.GRID_FW_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
/**
* @param formDTO
* @param indexList
* @return void
* @author yinzuomei
* @description 计算网格相关总分
* @Date 2020/8/26 16:50
**/
private void calculateGridTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, String indexCode) {
private void calculateGridTotal(CalculateCommonFormDTO formDTO) {
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在");
}
//查询总记录数
List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO);
if(CollectionUtils.isEmpty(gridScoreDTOList)){
@ -692,13 +663,9 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
for (GridScoreDTO gridScoreDTO : gridScoreDTOList) {
GridScoreEntity gridScoreEntity = ConvertUtils.sourceToTarget(gridScoreDTO, GridScoreEntity.class);
gridScoreEntity.setIsTotal(NumConstant.ONE_STR);
gridScoreEntity.setIndexCode(indexCode);
gridScoreEntity.setIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
gridScoreEntity.setScore(BigDecimal.ZERO);
gridScoreEntity.setAllParentIndexCode(NumConstant.ZERO_STR);
/*if (!CollectionUtils.isEmpty(gridScoreDTO.getDetailList()) && gridScoreDTO.getDetailList().size() != 3) {
log.error("customerId:" + gridScoreDTO.getCustomerId() + ";gridId:" + gridScoreDTO.getGridId() + ";monthId:" + gridScoreDTO.getMonthId() + "能力值缺失,无法计算总值");
continue;
}*/
log.warn("customerId:" + gridScoreDTO.getCustomerId() + ";gridId:" + gridScoreDTO.getGridId() + ";monthId:" + gridScoreDTO.getMonthId() + "能力值缺失");
for (GridScoreDetailDTO gridScoreDetailDTO : gridScoreDTO.getDetailList()) {
BigDecimal indexScore = gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight());
@ -711,7 +678,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
do {
effectRow =gridScoreDao.deleteBatches(formDTO.getCustomerId(),
formDTO.getMonthId(),
indexCode,
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCalConstant.DELETE_SIZE);
} while (effectRow > NumConstant.ZERO);
//批量插入

Loading…
Cancel
Save