@ -2,6 +2,7 @@ package com.epmet.service.indexcal.impl; 
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					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.DateUtils ;  
			
		
	
		
			
				
					import  com.epmet.constant.IndexCalConstant ;  
			
		
	
		
			
				
					import  com.epmet.dao.indexcoll.FactIndexGovrnAblityGridMonthlyDao ;  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -70,33 +71,45 @@ 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 ) )  {  
			
		
	
		
			
				
					            //1、计算网格相关-党建能力
  
			
		
	
		
			
				
					            calculateGridDangJian ( formDTO ,  dangJianNengLiList ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( dangJianNengLiList ) )  {  
			
		
	
		
			
				
					            logger . warn ( "calculateGridDangJian customerId:{} have not any indexGroupDetail" ,  formDTO . getCustomerId ( ) ) ;  
			
		
	
		
			
				
					            throw  new  RenException ( "客户【网格相关:党建能力】指标权重信息不存在" ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        calculateGridDangJian ( formDTO ,  dangJianNengLiList ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        //2、计算网格相关-治理能力
  
			
		
	
		
			
				
					        List < IndexGroupDetailEntity >  zhiLiNengLiList  =  indexGroupDetailService . getDetailListByParentCode ( formDTO . getCustomerId ( ) ,  
			
		
	
		
			
				
					                IndexCodeEnum . WANG_GE_XIANG_GUAN . getCode ( ) ,  
			
		
	
		
			
				
					                IndexCodeEnum . ZHI_LI_NENG_LI . getCode ( ) ) ;  
			
		
	
		
			
				
					        if  ( ! CollectionUtils . isEmpty ( zhiLiNengLiList ) )  {  
			
		
	
		
			
				
					            //2、计算网格相关-治理能力
  
			
		
	
		
			
				
					            calculateGridZhiLi ( formDTO ,  zhiLiNengLiList ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( zhiLiNengLiList ) )  {  
			
		
	
		
			
				
					            logger . warn ( "calculateGridZhiLi customerId:{} have not any indexGroupDetail" ,  formDTO . getCustomerId ( ) ) ;  
			
		
	
		
			
				
					            throw  new  RenException ( "客户【网格相关:治理能力】指标权重信息不存在" ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        calculateGridZhiLi ( formDTO ,  zhiLiNengLiList ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        //3、计算网格相关-服务能力
  
			
		
	
		
			
				
					        List < IndexGroupDetailEntity >  fuWuNengLiList  =  indexGroupDetailService . getDetailListByParentCode ( formDTO . getCustomerId ( ) ,  
			
		
	
		
			
				
					                IndexCodeEnum . WANG_GE_XIANG_GUAN . getCode ( ) ,  
			
		
	
		
			
				
					                IndexCodeEnum . FU_WU_NENG_LI . getCode ( ) ) ;  
			
		
	
		
			
				
					        if  ( ! CollectionUtils . isEmpty ( fuWuNengLiList ) )  {  
			
		
	
		
			
				
					            //3、计算网格相关-服务能力
  
			
		
	
		
			
				
					            calculateGridFuWu ( formDTO ,  fuWuNengLiList ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( fuWuNengLiList ) )  {  
			
		
	
		
			
				
					            logger . warn ( "calculateGridFuWu customerId:{} have not any indexGroupDetail" ,  formDTO . getCustomerId ( ) ) ;  
			
		
	
		
			
				
					            throw  new  RenException ( "客户【网格相关:服务能力】指标权重信息不存在" ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        //计算网格相关总分
  
			
		
	
		
			
				
					        calculateGridFuWu ( formDTO ,  fuWuNengLiList ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					        //4、计算网格相关总分
  
			
		
	
		
			
				
					        List < IndexGroupDetailEntity >  wgxgList  =  indexGroupDetailService . getDetailListByParentCode ( formDTO . getCustomerId ( ) ,  
			
		
	
		
			
				
					                IndexCodeEnum . WANG_GE_XIANG_GUAN . getCode ( ) ) ;  
			
		
	
		
			
				
					        if  ( ! CollectionUtils . isEmpty ( wgxgList ) )  {  
			
		
	
		
			
				
					            calculateGridTotal ( formDTO ,  wgxgList , IndexCodeEnum . WANG_GE_XIANG_GUAN . getCode ( ) ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( wgxgList ) )  {  
			
		
	
		
			
				
					            logger . 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 ;  
			
		
	
		
			
				
					    }  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -122,9 +135,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					        logger . info ( String . format ( "共%s条数据,分%s次计算" ,  total ,  totalPage ) ) ;  
			
		
	
		
			
				
					        //每一组指标的最大值,key:code_MIN/MAX
  
			
		
	
		
			
				
					        Map < String ,  Object >  minAndMaxMap  =  queryPartyAblityGridMinAndMax ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( minAndMaxMap ) )  {  
			
		
	
		
			
				
					            logger . error ( "calculateGridDangJian queryPartyAblityGridMinAndMax customerId:{} monthId:{} have not any fact record" ,  formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					            return ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        //指标集合
  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  getGridCorrelationIndexInputVO ( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList = new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  build GridCorrelationIndexInputVO( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList   =   new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        //分页查询采集记录
  
			
		
	
		
			
				
					        for  ( int  pageNo  =  1 ;  pageNo  < =  totalPage ;  pageNo + + )  {  
			
		
	
		
			
				
					            int  pageIndex  =  ( pageNo  -  NumConstant . ONE )  *  IndexCalConstant . PAGE_SIZE ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -149,8 +166,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					                        //组织内党员的联系群众能力考评分(平均值)
  
			
		
	
		
			
				
					                        logger . info ( "组织内党员的联系群众能力考评分(平均值) 单独处理" ) ;  
			
		
	
		
			
				
					                        //网格内党员的联系群众能力考评分(平均值)
  
			
		
	
		
			
				
					                        String  gridId = ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ;  
			
		
	
		
			
				
					                        BigDecimal  contactMassesAvgValue  =  getGridContactMassesAvgValue ( formDTO , gridId ) ;  
			
		
	
		
			
				
					                        String  gridId   =   ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ;  
			
		
	
		
			
				
					                        BigDecimal  contactMassesAvgValue  =  getGridContactMassesAvgValue ( formDTO ,   gridId ) ;  
			
		
	
		
			
				
					                        SampleValue < BigDecimal >  contactMassesAblityValue  =  new  SampleValue ( ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ,  contactMassesAvgValue ) ;  
			
		
	
		
			
				
					                        value . getIndexValueVOs ( ) . add ( contactMassesAblityValue ) ;  
			
		
	
		
			
				
					                    }  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -160,96 +177,96 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            resultMapList . add ( resultMap ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        // 保存中间表
  
			
		
	
		
			
				
					        saveGridCorreLationDangJian  ( formDTO ,  resultMapList , IndexCodeEnum . DANG_JIAN_NENG_LI . getCode ( ) , NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					        saveGridCorreLationResult  ( formDTO ,  resultMapList ,   IndexCodeEnum . DANG_JIAN_NENG_LI . getCode ( ) ,   NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @return  java . util . Map < java . lang . String , java . math . BigDecimal >  
			
		
	
		
			
				
					     *  @param  calculateCommonFormDTO  
			
		
	
		
			
				
					     *  @return  java . util . Map < java . lang . String ,  java . math . BigDecimal >  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  获取网格内党员的联系群众能力考评分 ( 平均值 ) 的最大值 , 最小值  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 31  9 : 51  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  Map < String ,  BigDecimal >  getContactMassesAblityMap ( CalculateCommonFormDTO  calculateCommonFormDTO )  {  
			
		
	
		
			
				
					        Map < String ,  BigDecimal >  map = new  HashMap < > ( ) ;  
			
		
	
		
			
				
					        List < BigDecimal >  list = cpcScoreDao . selectListGridContactMassesAvgValue ( calculateCommonFormDTO ) ;  
			
		
	
		
			
				
					        if ( ! CollectionUtils . isEmpty ( list ) ) {  
			
		
	
		
			
				
					            BigDecimal  minValue = Collections . min ( list ) ;  
			
		
	
		
			
				
					            BigDecimal  maxValue = Collections . max ( list ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MIN , minValue ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MAX , maxValue ) ;  
			
		
	
		
			
				
					        Map < String ,  BigDecimal >  map   =   new  HashMap < > ( ) ;  
			
		
	
		
			
				
					        List < BigDecimal >  list   =   cpcScoreDao . selectListGridContactMassesAvgValue ( calculateCommonFormDTO ) ;  
			
		
	
		
			
				
					        if   ( ! CollectionUtils . isEmpty ( list ) )   {  
			
		
	
		
			
				
					            BigDecimal  minValue   =   Collections . min ( list ) ;  
			
		
	
		
			
				
					            BigDecimal  maxValue   =   Collections . max ( list ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MIN ,   minValue ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MAX ,   maxValue ) ;  
			
		
	
		
			
				
					            return  map ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        map . put ( StrConstant . MIN , new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MAX , new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MIN ,   new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MAX ,   new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        return  map ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @return  java . math . BigDecimal  
			
		
	
		
			
				
					     *  @param  calculateCommonFormDTO  
			
		
	
		
			
				
					     *  @param  gridId  网格id  
			
		
	
		
			
				
					     *  @param  gridId                  网格id  
			
		
	
		
			
				
					     *  @return  java . math . BigDecimal  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  获取网格 ( 组织 ) 内党员的联系群众能力考评分 ( 平均值 )  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 31  9 : 50  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  BigDecimal  getGridContactMassesAvgValue ( CalculateCommonFormDTO  calculateCommonFormDTO , String  gridId )  {  
			
		
	
		
			
				
					        BigDecimal  result = cpcScoreDao . selectGridContactMassesAvgValue ( calculateCommonFormDTO . getCustomerId ( ) , calculateCommonFormDTO . getMonthId ( ) , gridId ) ;  
			
		
	
		
			
				
					        if ( null = = result ) {  
			
		
	
		
			
				
					    private  BigDecimal  getGridContactMassesAvgValue ( CalculateCommonFormDTO  calculateCommonFormDTO ,   String  gridId )  {  
			
		
	
		
			
				
					        BigDecimal  result   =   cpcScoreDao . selectGridContactMassesAvgValue ( calculateCommonFormDTO . getCustomerId ( ) ,   calculateCommonFormDTO . getMonthId ( ) ,   gridId ) ;  
			
		
	
		
			
				
					        if   ( null   = =   result )   {  
			
		
	
		
			
				
					            return  new  BigDecimal ( NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        return  result ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @return  java . math . BigDecimal  
			
		
	
		
			
				
					     *  @param  formDTO  
			
		
	
		
			
				
					     *  @param  gridId  
			
		
	
		
			
				
					     *  @return  java . math . BigDecimal  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description    组织内党员的参与议事能力考评分 ( 平均值 )  
			
		
	
		
			
				
					     *  @description  组织内党员的参与议事能力考评分 ( 平均值 )  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 31  15 : 51  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  BigDecimal  getGridJoinIssueAvgValue ( CalculateCommonFormDTO  formDTO ,  String  gridId )  {  
			
		
	
		
			
				
					        BigDecimal  result = cpcScoreDao . selectGridJoinIssueAvgValue ( formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) , gridId ) ;  
			
		
	
		
			
				
					        if ( null = = result ) {  
			
		
	
		
			
				
					        BigDecimal  result   =   cpcScoreDao . selectGridJoinIssueAvgValue ( formDTO . getCustomerId ( ) ,   formDTO . getMonthId ( ) ,   gridId ) ;  
			
		
	
		
			
				
					        if   ( null   = =   result )   {  
			
		
	
		
			
				
					            return  new  BigDecimal ( NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        return  result ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					      
			
		
	
		
			
				
					
  
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @return  java . util . Map < java . lang . String , java . math . BigDecimal >  
			
		
	
		
			
				
					     *  @param  calculateCommonFormDTO  
			
		
	
		
			
				
					     *  @return  java . util . Map < java . lang . String ,  java . math . BigDecimal >  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  网格内党员的参与议事能力考评分 ( 平均值 )  最大值最小值  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 31  14 : 41  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  Map < String ,  BigDecimal >  getJoinIssueAblityMap ( CalculateCommonFormDTO  calculateCommonFormDTO ) {  
			
		
	
		
			
				
					        Map < String ,  BigDecimal >  map = new  HashMap < > ( ) ;  
			
		
	
		
			
				
					        List < BigDecimal >  list = cpcScoreDao . selectListJoinIssueAvgValue ( calculateCommonFormDTO ) ;  
			
		
	
		
			
				
					        if ( ! CollectionUtils . isEmpty ( list ) ) {  
			
		
	
		
			
				
					            BigDecimal  minValue = Collections . min ( list ) ;  
			
		
	
		
			
				
					            BigDecimal  maxValue = Collections . max ( list ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MIN , minValue ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MAX , maxValue ) ;  
			
		
	
		
			
				
					    private  Map < String ,  BigDecimal >  getJoinIssueAblityMap ( CalculateCommonFormDTO  calculateCommonFormDTO )   {  
			
		
	
		
			
				
					        Map < String ,  BigDecimal >  map   =   new  HashMap < > ( ) ;  
			
		
	
		
			
				
					        List < BigDecimal >  list   =   cpcScoreDao . selectListJoinIssueAvgValue ( calculateCommonFormDTO ) ;  
			
		
	
		
			
				
					        if   ( ! CollectionUtils . isEmpty ( list ) )   {  
			
		
	
		
			
				
					            BigDecimal  minValue   =   Collections . min ( list ) ;  
			
		
	
		
			
				
					            BigDecimal  maxValue   =   Collections . max ( list ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MIN ,   minValue ) ;  
			
		
	
		
			
				
					            map . put ( StrConstant . MAX ,   maxValue ) ;  
			
		
	
		
			
				
					            return  map ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        map . put ( StrConstant . MIN , new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MAX , new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MIN ,   new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        map . put ( StrConstant . MAX ,   new  BigDecimal ( NumConstant . ZERO_STR ) ) ;  
			
		
	
		
			
				
					        return  map ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @param  formDTO    客户id    月份id :   yyyyMM  
			
		
	
		
			
				
					     *  @param  formDTO         客户id    月份id :   yyyyMM  
			
		
	
		
			
				
					     *  @param  resultMapList  
			
		
	
		
			
				
					     *  @param  indexCode  指标编码  
			
		
	
		
			
				
					     *  @param  isTotal  1 : 总分 ; 0不是  
			
		
	
		
			
				
					     *  @param  indexCode       指标编码 :  党建能力 : dangjiannengli ; 治理能力 : zhilinengli ; 服务能力 : fuwunengli ;  
			
		
	
		
			
				
					     *  @param  isTotal         1 : 总分 ; 0不是  
			
		
	
		
			
				
					     *  @return  void  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  保存网格相关三大能力值  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 30  22 : 50  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  void  saveGridCorreLationDangJian  ( CalculateCommonFormDTO  formDTO ,  
			
		
	
		
			
				
					    private  void  saveGridCorreLationResult  ( CalculateCommonFormDTO  formDTO ,  
			
		
	
		
			
				
					                                             List < HashMap < String ,  BigDecimal > >  resultMapList ,  
			
		
	
		
			
				
					                                             String  indexCode ,  
			
		
	
		
			
				
					                                             String  isTotal )  {  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -277,7 +294,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            } ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        if  ( ! CollectionUtils . isEmpty ( gridScoreEntityList ) )  {  
			
		
	
		
			
				
					            gridScoreDao . deleteByCusAndMonthId ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ,  indexCode , isTotal ) ;  
			
		
	
		
			
				
					            gridScoreDao . deleteByCusAndMonthId ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ,  indexCode ,   isTotal ) ;  
			
		
	
		
			
				
					            gridScoreDao . insertBatches ( gridScoreEntityList ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					    }  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -286,21 +303,24 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					     *  @param  indexMap  
			
		
	
		
			
				
					     *  @return  java . util . List < com . epmet . support . normalizing . batch . IndexOutputVO >  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  
			
		
	
		
			
				
					     *  @description  调用计算器计算每个指标下 , 各个网格的总分   
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 30  21 : 40  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  HashMap < String ,  BigDecimal >  calculate ( Map < String ,  IndexInputVO < BigDecimal > >  indexMap )  {  
			
		
	
		
			
				
					        //构造入参
  
			
		
	
		
			
				
					        List < IndexInputVO >  indexInputVOS  =  this . getIndexInputVOList ( indexMap ) ;  
			
		
	
		
			
				
					        logger . info ( "计算的参数:{}" ,  indexInputVOS ) ;  
			
		
	
		
			
				
					        BatchScoreCalculator  batchScoreCalculator  =  new  BatchScoreCalculator ( ) ;  
			
		
	
		
			
				
					        return  batchScoreCalculator . getScoreCountOfSampleId ( indexInputVOS ) ;  
			
		
	
		
			
				
					        HashMap < String ,  BigDecimal >  resultMap  =  batchScoreCalculator . getScoreCountOfSampleId ( indexInputVOS ) ;  
			
		
	
		
			
				
					        logger . info ( "计算的结果:{}" ,  resultMap ) ;  
			
		
	
		
			
				
					        return  resultMap ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @param  indexMap  
			
		
	
		
			
				
					     *  @return  java . util . List < com . epmet . support . normalizing . batch . IndexInputVO >  
			
		
	
		
			
				
					     *  @author  yinzuomei  
			
		
	
		
			
				
					     *  @description  
			
		
	
		
			
				
					     *  @description  map遍历 , 转为List   
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 30  18 : 34  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  List < IndexInputVO >  getIndexInputVOList ( Map < String ,  IndexInputVO < BigDecimal > >  indexMap )  {  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -321,13 +341,14 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					     *  @description  构造网格相关   指标计算参数  
			
		
	
		
			
				
					     *  @Date  2020 / 8 / 30  15 : 56  
			
		
	
		
			
				
					     * * /  
			
		
	
		
			
				
					    private  Map < String ,  IndexInputVO < BigDecimal > >  get GridCorrelationIndexInputVO( CalculateCommonFormDTO  formDTO ,  List < IndexGroupDetailEntity >  indexList ,  Map < String ,  Object >  minAndMaxMap )  {  
			
		
	
		
			
				
					    private  Map < String ,  IndexInputVO < BigDecimal > >  build GridCorrelationIndexInputVO( CalculateCommonFormDTO  formDTO ,  List < IndexGroupDetailEntity >  indexList ,  Map < String ,  Object >  minAndMaxMap )  {  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  map  =  new  HashMap < > ( ) ;  
			
		
	
		
			
				
					        for  ( int  indexNum  =  0 ;  indexNum  <  indexList . size ( ) ;  indexNum + + )  {  
			
		
	
		
			
				
					            IndexGroupDetailEntity  index  =  indexList . get ( indexNum ) ;  
			
		
	
		
			
				
					        for  ( IndexGroupDetailEntity  index  :  indexList )  {  
			
		
	
		
			
				
					            IndexInputVO  indexInputVO  =  new  IndexInputVO ( ) ;  
			
		
	
		
			
				
					            // 指标code
  
			
		
	
		
			
				
					            indexInputVO . setIndexId ( index . getIndexCode ( ) ) ;  
			
		
	
		
			
				
					            //阈值
  
			
		
	
		
			
				
					            indexInputVO . setThreshold ( index . getThreshold ( ) ) ;  
			
		
	
		
			
				
					            //权重
  
			
		
	
		
			
				
					            indexInputVO . setWeight ( index . getWeight ( ) ) ;  
			
		
	
		
			
				
					            BigDecimal  minValue  =  null ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -335,22 +356,22 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            if  ( IndexCodeEnum . ZUZHINEIDANGYDLXQZNLKPFPJZ . getCode ( ) . equals ( index . getIndexCode ( ) ) )  {  
			
		
	
		
			
				
					                //组织内党员的联系群众能力考评分(平均值)  获取最大值,最小值
  
			
		
	
		
			
				
					                logger . info ( "组织内党员的联系群众能力考评分(平均值) 单独处理" ) ;  
			
		
	
		
			
				
					                Map < String , BigDecimal >  contactMassesAblityMap =  this . getContactMassesAblityMap ( formDTO ) ;  
			
		
	
		
			
				
					                minValue = contactMassesAblityMap . get ( StrConstant . MIN ) ;  
			
		
	
		
			
				
					                maxValue = contactMassesAblityMap . get ( StrConstant . MAX ) ;  
			
		
	
		
			
				
					            } else  if ( IndexCodeEnum . ZUZHINEIDANGYDSYYSNLKPFPJZ . getCode ( ) . equals ( index . getIndexCode ( ) ) ) {  
			
		
	
		
			
				
					                Map < String ,   BigDecimal >  contactMassesAblityMap   =  this . getContactMassesAblityMap ( formDTO ) ;  
			
		
	
		
			
				
					                minValue   =   contactMassesAblityMap . get ( StrConstant . MIN ) ;  
			
		
	
		
			
				
					                maxValue   =   contactMassesAblityMap . get ( StrConstant . MAX ) ;  
			
		
	
		
			
				
					            }   else  if   ( IndexCodeEnum . ZUZHINEIDANGYDSYYSNLKPFPJZ . getCode ( ) . equals ( index . getIndexCode ( ) ) )   {  
			
		
	
		
			
				
					                logger . info ( "组织内党员的参与议事能力考评分(平均值) 单独处理" ) ;  
			
		
	
		
			
				
					                Map < String , BigDecimal >  joinIssueAblityMap =  this . getJoinIssueAblityMap ( formDTO ) ;  
			
		
	
		
			
				
					                minValue = joinIssueAblityMap . get ( StrConstant . MIN ) ;  
			
		
	
		
			
				
					                maxValue = joinIssueAblityMap . get ( StrConstant . MAX ) ;  
			
		
	
		
			
				
					                Map < String ,   BigDecimal >  joinIssueAblityMap   =  this . getJoinIssueAblityMap ( formDTO ) ;  
			
		
	
		
			
				
					                minValue   =   joinIssueAblityMap . get ( StrConstant . MIN ) ;  
			
		
	
		
			
				
					                maxValue   =   joinIssueAblityMap . get ( StrConstant . MAX ) ;  
			
		
	
		
			
				
					            }  else  {  
			
		
	
		
			
				
					                //获取指标对应的列名
  
			
		
	
		
			
				
					                String  fieldName  =  indexCodeFieldReService . getFieldNameByIndexCode ( index . getIndexCode ( ) ) ;  
			
		
	
		
			
				
					                if ( StringUtils . isBlank ( fieldName ) ) {  
			
		
	
		
			
				
					                    logger . error ( "index_code:" +  index . getIndexCode ( ) + "  not find field_name") ;  
			
		
	
		
			
				
					                if   ( StringUtils . isBlank ( fieldName ) )   {  
			
		
	
		
			
				
					                    logger . error ( "index_code:{} " ,  index . getIndexCode ( ) , " not find field_name") ;  
			
		
	
		
			
				
					                    continue ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
					                logger . info ( "INDEX_CODE="  +   index . getIndexCode ( ) + ";FIELD_ID="  +  fieldName  ) ;  
			
		
	
		
			
				
					                logger . info ( "index_code:{} " ,  index . getIndexCode ( ) , "field_id :{} " , fieldName ) ;  
			
		
	
		
			
				
					                String  minValueKey  =  fieldName . concat ( StrConstant . UNDER_LINE ) . concat ( StrConstant . MIN ) ;  
			
		
	
		
			
				
					                String  maxValueKey  =  fieldName . concat ( StrConstant . UNDER_LINE ) . concat ( StrConstant . MAX ) ;  
			
		
	
		
			
				
					                minValue  =  new  BigDecimal ( String . valueOf ( minAndMaxMap . get ( minValueKey ) ) ) ;  
			
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
				@ -392,9 +413,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					        logger . info ( String . format ( "共%s条数据,分%s次计算" ,  total ,  totalPage ) ) ;  
			
		
	
		
			
				
					        //每一组指标的最大值,key:code_MIN/MAX
  
			
		
	
		
			
				
					        Map < String ,  Object >  minAndMaxMap  =  queryGovrnAblityGridMinAndMax ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( minAndMaxMap ) )  {  
			
		
	
		
			
				
					            logger . error ( "calculateGridZhiLi queryGovrnAblityGridMinAndMax customerId:{} monthId:{} have not any fact record" ,  formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					            return ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        //指标集合
  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  getGridCorrelationIndexInputVO ( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList = new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  build GridCorrelationIndexInputVO( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList   =   new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        //分页查询采集记录
  
			
		
	
		
			
				
					        for  ( int  pageNo  =  1 ;  pageNo  < =  totalPage ;  pageNo + + )  {  
			
		
	
		
			
				
					            int  pageIndex  =  ( pageNo  -  NumConstant . ONE )  *  IndexCalConstant . PAGE_SIZE ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -417,8 +442,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					                        value . getIndexValueVOs ( ) . add ( currentGridIndexValue ) ;  
			
		
	
		
			
				
					                    }  else  if  ( IndexCodeEnum . ZUZHINEIDANGYDSYYSNLKPFPJZ . getCode ( ) . equals ( key ) )  {  
			
		
	
		
			
				
					                        logger . info ( "组织内党员的参与议事能力考评分(平均值) 单独处理" ) ;  
			
		
	
		
			
				
					                        String  gridId = ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ;  
			
		
	
		
			
				
					                        BigDecimal  joinAvgValue  =  getGridJoinIssueAvgValue ( formDTO , gridId ) ;  
			
		
	
		
			
				
					                        String  gridId   =   ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ;  
			
		
	
		
			
				
					                        BigDecimal  joinAvgValue  =  getGridJoinIssueAvgValue ( formDTO ,   gridId ) ;  
			
		
	
		
			
				
					                        SampleValue < BigDecimal >  contactMassesAblityValue  =  new  SampleValue ( ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ,  joinAvgValue ) ;  
			
		
	
		
			
				
					                        value . getIndexValueVOs ( ) . add ( contactMassesAblityValue ) ;  
			
		
	
		
			
				
					                    }  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -428,7 +453,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            resultMapList . add ( resultMap ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        // 保存中间表
  
			
		
	
		
			
				
					        saveGridCorreLationDangJian  ( formDTO ,  resultMapList , IndexCodeEnum . ZHI_LI_NENG_LI . getCode ( ) , NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					        saveGridCorreLationResult  ( formDTO ,  resultMapList ,   IndexCodeEnum . ZHI_LI_NENG_LI . getCode ( ) ,   NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -452,9 +477,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					        logger . info ( String . format ( "共%s条数据,分%s次计算" ,  total ,  totalPage ) ) ;  
			
		
	
		
			
				
					        //每一组指标的最大值,key:code_MIN/MAX
  
			
		
	
		
			
				
					        Map < String ,  Object >  minAndMaxMap  =  queryServiceAblityGridMinAndMax ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					        if  ( CollectionUtils . isEmpty ( minAndMaxMap ) )  {  
			
		
	
		
			
				
					            logger . error ( "calculateGridFuWu queryServiceAblityGridMinAndMax customerId:{} monthId:{} have not any fact record" ,  formDTO . getCustomerId ( ) , formDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					            return ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        //指标集合
  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  getGridCorrelationIndexInputVO ( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList = new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        Map < String ,  IndexInputVO < BigDecimal > >  indexMap  =  build GridCorrelationIndexInputVO( formDTO ,  indexList ,  minAndMaxMap ) ;  
			
		
	
		
			
				
					        List < HashMap < String ,  BigDecimal > >  resultMapList   =   new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        //分页查询采集记录
  
			
		
	
		
			
				
					        for  ( int  pageNo  =  1 ;  pageNo  < =  totalPage ;  pageNo + + )  {  
			
		
	
		
			
				
					            int  pageIndex  =  ( pageNo  -  NumConstant . ONE )  *  IndexCalConstant . PAGE_SIZE ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -475,8 +504,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					                        //构造样本值对象
  
			
		
	
		
			
				
					                        SampleValue < BigDecimal >  currentGridIndexValue  =  new  SampleValue ( ( String )  recordMap . get ( IndexCalConstant . GRID_ID ) ,  new  BigDecimal ( sampleValueStr ) ) ;  
			
		
	
		
			
				
					                        value . getIndexValueVOs ( ) . add ( currentGridIndexValue ) ;  
			
		
	
		
			
				
					                    } else {  
			
		
	
		
			
				
					                        logger . error ( "index_code:" + key + " not find field_name" ) ;  
			
		
	
		
			
				
					                    }   else   {  
			
		
	
		
			
				
					                        logger . error ( "index_code:"   +   key   +   " not find field_name" ) ;  
			
		
	
		
			
				
					                    }  
			
		
	
		
			
				
					                } ) ;  
			
		
	
		
			
				
					            } ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -484,7 +513,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            resultMapList . add ( resultMap ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        // 保存中间表
  
			
		
	
		
			
				
					        saveGridCorreLationDangJian  ( formDTO ,  resultMapList , IndexCodeEnum . FU_WU_NENG_LI . getCode ( ) , NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					        saveGridCorreLationResult  ( formDTO ,  resultMapList ,   IndexCodeEnum . FU_WU_NENG_LI . getCode ( ) ,   NumConstant . ZERO_STR ) ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -498,9 +527,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					    private  void  calculateGridTotal ( CalculateCommonFormDTO  formDTO ,  List < IndexGroupDetailEntity >  indexList ,  String  indexCode )  {  
			
		
	
		
			
				
					        //查询总记录数
  
			
		
	
		
			
				
					        List < GridScoreDTO >  gridScoreDTOList  =  gridScoreDao . selectList ( formDTO ) ;  
			
		
	
		
			
				
					        if ( CollectionUtils . isEmpty ( gridScoreDTOList ) ) {  
			
		
	
		
			
				
					            logger . error ( "calculateGridTotal gridScoreDao.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 < GridScoreEntity >  gridScoreEntityList  =  new  ArrayList < > ( ) ;  
			
		
	
		
			
				
					        for ( GridScoreDTO  gridScoreDTO : gridScoreDTOList ) {  
			
		
	
		
			
				
					        for   ( GridScoreDTO  gridScoreDTO   :   gridScoreDTOList )   {  
			
		
	
		
			
				
					            GridScoreEntity  gridScoreEntity  =  new  GridScoreEntity ( ) ;  
			
		
	
		
			
				
					            gridScoreEntity . setCustomerId ( gridScoreDTO . getCustomerId ( ) ) ;  
			
		
	
		
			
				
					            gridScoreEntity . setGridId ( gridScoreDTO . getGridId ( ) ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -512,12 +545,12 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					            gridScoreEntity . setYearId ( gridScoreDTO . getYearId ( ) ) ;  
			
		
	
		
			
				
					            gridScoreEntity . setMonthId ( gridScoreDTO . getMonthId ( ) ) ;  
			
		
	
		
			
				
					            gridScoreEntity . setScore ( BigDecimal . ZERO ) ;  
			
		
	
		
			
				
					            if ( ! CollectionUtils . isEmpty ( gridScoreDTO . getDetailList ( ) ) & & gridScoreDTO . getDetailList ( ) . size ( ) ! = 3 ) {  
			
		
	
		
			
				
					                logger . error ( "customerId:" + gridScoreDTO . getCustomerId ( ) + ";gridId:" + gridScoreDTO . getGridId ( ) + ";monthId:" + gridScoreDTO . getMonthId ( ) + "能力值缺失,无法计算总值" ) ;  
			
		
	
		
			
				
					            if   ( ! CollectionUtils . isEmpty ( gridScoreDTO . getDetailList ( ) )   & &   gridScoreDTO . getDetailList ( ) . size ( )   ! =   3 )   {  
			
		
	
		
			
				
					                logger . error ( "customerId:"   +   gridScoreDTO . getCustomerId ( )   +   ";gridId:"   +   gridScoreDTO . getGridId ( )   +   ";monthId:"   +   gridScoreDTO . getMonthId ( )   +   "能力值缺失,无法计算总值" ) ;  
			
		
	
		
			
				
					                continue ;  
			
		
	
		
			
				
					            }  
			
		
	
		
			
				
					            for ( GridScoreDetailDTO  gridScoreDetailDTO : gridScoreDTO . getDetailList ( ) ) {  
			
		
	
		
			
				
					                BigDecimal  indexScore = gridScoreDetailDTO . getScore ( ) . multiply ( indexMap . get ( gridScoreDetailDTO . getIndexCode ( ) ) . getWeight ( ) ) ;  
			
		
	
		
			
				
					            for   ( GridScoreDetailDTO  gridScoreDetailDTO   :   gridScoreDTO . getDetailList ( ) )   {  
			
		
	
		
			
				
					                BigDecimal  indexScore   =   gridScoreDetailDTO . getScore ( ) . multiply ( indexMap . get ( gridScoreDetailDTO . getIndexCode ( ) ) . getWeight ( ) ) ;  
			
		
	
		
			
				
					                gridScoreEntity . setScore ( gridScoreEntity . getScore ( ) . add ( indexScore ) ) ;  
			
		
	
		
			
				
					            }  
			
		
	
		
			
				
					            gridScoreEntityList . add ( gridScoreEntity ) ;  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -529,12 +562,13 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    public  static  void  main ( String [ ]  args )  {  
			
		
	
		
			
				
					        BigDecimal  totalScore = BigDecimal . ZERO ;  
			
		
	
		
			
				
					        for ( int  i = 1 ; i < 5 ; i + + ) {  
			
		
	
		
			
				
					            totalScore = totalScore . add ( new  BigDecimal ( "1.00" ) ) ;  
			
		
	
		
			
				
					        BigDecimal  totalScore   =   BigDecimal . ZERO ;  
			
		
	
		
			
				
					        for   ( int  i   =   1 ;   i   <   5 ;   i + + )   {  
			
		
	
		
			
				
					            totalScore   =   totalScore . add ( new  BigDecimal ( "1.00" ) ) ;  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
					        System . out . println ( totalScore ) ;  
			
		
	
		
			
				
					    }  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					    / * *  
			
		
	
		
			
				
					     *  @param  customerId  
			
		
	
		
			
				
					     *  @return  com . epmet . dto . indexcal . CustomerGridInfoDTO