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