@ -31,9 +31,10 @@ import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptSubScoreDao ;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao ;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao ;
import com.epmet.dto.indexcal.CalculateCommonFormDTO ;
import com.epmet.dto.indexcal.* ;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity ;
import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity ;
import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity ;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity ;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity ;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity ;
@ -63,6 +64,8 @@ import java.util.ArrayList;
import java.util.HashMap ;
import java.util.List ;
import java.util.Map ;
import java.util.function.Function ;
import java.util.stream.Collectors ;
/ * *
@ -94,26 +97,38 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
* @param formDTO
* @return java . lang . Boolean
* @author yinzuomei
* @description 区直部门 , 分值计算
* @description 区直部门相关 - 分值计算
* @Date 2020 / 8 / 26 10 : 51
* * /
@Override
public Boolean calculateDeptCorreLation ( CalculateCommonFormDTO formDTO ) {
//获取指标权重
calculateZhiLiNengLiScore ( formDTO ) ;
calculateDeptTotalScore ( formDTO ) ;
return true ;
}
/ * *
* @return void
* @param formDTO
* @author yinzuomei
* @description 区直部门 - 党建能力分值计算
* @Date 2020 / 9 / 10 17 : 21
* * /
private void calculateZhiLiNengLiScore ( CalculateCommonFormDTO formDTO ) {
//获取区直部门的治理能力下,五级指标权重
List < IndexGroupDetailEntity > indexGroupDetailEntityList = getDetailListByParentCode . getDetailListByParentCode ( formDTO . getCustomerId ( ) ,
IndexCodeEnum . QU_ZHI_BU_MEN . getCode ( ) ,
IndexCodeEnum . ZHI_LI_NENG_LI . getCode ( ) ) ;
if ( CollectionUtils . isEmpty ( indexGroupDetailEntityList ) ) {
log . warn ( "calculateDeptCorreLation customerId:{} have not any indexGroupDetail" , formDTO . getCustomerId ( ) ) ;
throw new RenException ( "客户【区直部门:治理能力】指标权重信息不存在" ) ;
throw new RenException ( "客户【区直部门:治理能力】下级 指标权重信息不存在" ) ;
}
log . info ( JSON . toJSONString ( indexGroupDetailEntityList ) ) ;
// log.info(JSON.toJSONString(indexGroupDetailEntityList));
//1、查询总记录数
int total = factIndexGovrnAblityDeptMonthlyDao . selectCount ( formDTO ) ;
if ( NumConstant . ZERO = = total ) {
log . warn ( String . format ( "customerId=%s,monthId=%s,fact_index_govrn_ablity_dept_monthly have not any fact record" , formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) ) ) ;
return Boolean . FALSE ;
return ;
}
//2、计算最大最小值
Map < String , Object > minAndMaxMap = factIndexGovrnAblityDeptMonthlyDao . selectExtremeValue ( formDTO ) ;
@ -139,7 +154,61 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
calculateScore ( formDTO , indexMap , crrentFactRecordList ) ;
}
} while ( ! CollectionUtils . isEmpty ( list ) & & pageNo + + > 0 ) ;
return true ;
log . info ( "区直部门-治理能力- 计算完成" ) ;
}
/ * *
* @return void
* @param formDTO
* @author yinzuomei
* @description 区直部门总分
* @Date 2020 / 9 / 10 17 : 20
* * /
private void calculateDeptTotalScore ( CalculateCommonFormDTO formDTO ) {
//计算区直部门总分
List < IndexGroupDetailEntity > indexList = getDetailListByParentCode . getDetailListByParentCode ( formDTO . getCustomerId ( ) ,
IndexCodeEnum . QU_ZHI_BU_MEN . getCode ( ) ) ;
if ( CollectionUtils . isEmpty ( indexList ) ) {
log . warn ( "calculateDeptTotalScore customerId:{} have not any indexGroupDetail" , formDTO . getCustomerId ( ) ) ;
throw new RenException ( "客户【区直部门】下级指标权重信息不存在" ) ;
}
//查询总记录数
List < DeotScore > deptScoreDTOList = deptScoreDao . selectList ( formDTO ) ;
if ( CollectionUtils . isEmpty ( deptScoreDTOList ) ) {
log . error ( "calculateDeptTotalScore deptScoreDao.selectList return empty,customerId:{},monthId:{}" , formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) ) ;
throw new RenException ( "客户一级指标分值记录不存在" ) ;
}
Map < String , IndexGroupDetailEntity > indexMap = indexList . stream ( ) . collect ( Collectors . toMap ( IndexGroupDetailEntity : : getIndexCode , Function . identity ( ) ) ) ;
List < DeptScoreEntity > deotScoreEntityList = new ArrayList < > ( ) ;
for ( DeotScore deptScore : deptScoreDTOList ) {
DeptScoreEntity deptScoreEntity = ConvertUtils . sourceToTarget ( deptScore , DeptScoreEntity . class ) ;
deptScoreEntity . setIsTotal ( NumConstant . ONE_STR ) ;
deptScoreEntity . setIndexCode ( IndexCodeEnum . QU_ZHI_BU_MEN . getCode ( ) ) ;
deptScoreEntity . setScore ( BigDecimal . ZERO ) ;
deptScoreEntity . setAllParentIndexCode ( NumConstant . ZERO_STR ) ;
for ( DeptScoreDetailDTO deptScoreDetailDTO : deptScore . getDetailList ( ) ) {
BigDecimal indexScore = deptScoreDetailDTO . getScore ( ) . multiply ( indexMap . get ( deptScoreDetailDTO . getIndexCode ( ) ) . getWeight ( ) ) ;
deptScoreEntity . setScore ( deptScoreEntity . getScore ( ) . add ( indexScore ) ) ;
}
deotScoreEntityList . add ( deptScoreEntity ) ;
}
//先删除
int effectRow ;
do {
effectRow = deptScoreDao . deleteByDeptIdAndMonthId ( formDTO . getCustomerId ( ) ,
formDTO . getMonthId ( ) ,
IndexCodeEnum . QU_ZHI_BU_MEN . getCode ( ) ,
IndexCalConstant . DELETE_SIZE ) ;
} while ( effectRow > NumConstant . ZERO ) ;
//后新增
if ( ! CollectionUtils . isEmpty ( deotScoreEntityList ) ) {
//批量插入
List < List < DeptScoreEntity > > partition = ListUtils . partition ( deotScoreEntityList , IndexCalConstant . INSERT_SIZE ) ;
partition . forEach ( list - > {
deptScoreDao . insertBatchEntity ( list ) ;
} ) ;
}
}
/ * *
@ -165,7 +234,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
//删除明细时,需要根据分组删,比方说当前计算的是区直部门治理能力,主表需要删除indexCode=zhilinengli的,明细需要删除区直部门:治理能力下面所有的指标明细
int detailDelteNum ;
do {
detailDelteNum = deptSubScoreDao . deleteByDeptIdAndMonthId ( formDTO . getCustomerId ( ) ,
detailDelteNum = deptSubScoreDao . deleteBatches ( formDTO . getCustomerId ( ) ,
formDTO . getMonthId ( ) ,
allParentIndexCode ,
IndexCalConstant . DELETE_SIZE ) ;