@ -11,6 +11,7 @@ import com.epmet.constant.DataSourceConstant; 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.constant.IndexCalConstant ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcal.CpcScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcal.GridScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcal.GridSelfSubScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcal.GridSubScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao ;  
				
			 
			
		
	
	
		
			
				
					
						
						
						
							
								 
							 
						
					 
				
				 
				
					@ -19,8 +20,8 @@ import com.epmet.dao.evaluationindex.screen.IndexGroupDetailDao; 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dto.ScreenCustomerGridDTO ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.dto.indexcal.* ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.entity.evaluationindex.indexcal.GridScoreEntity ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.entity.evaluationindex.indexcal.GridSelfSubScoreEntity ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					import  com.epmet.eum.IndexCodeEnum ;  
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				
					@ -75,6 +76,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    private  GridSubScoreDao  gridSubScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    @Autowired  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    private  IndexGroupDetailDao  indexGroupDetailDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    @Autowired  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    private  GridSelfSubScoreDao  gridSelfSubScoreDao ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    / * *  
				
			 
			
		
	
	
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
				
				 
				
					@ -122,22 +125,57 @@ public class GridCorreLationServiceImpl implements GridCorreLationService { 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                log . error ( "calculateSelfSubScore gridSubScoreDao.selectSubListByPath return empty,customerId:{} " ,  formDTO . getCustomerId ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                return ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            }  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            Map < String ,  String >  selfSubParentMap  =  new  HashMap < > ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            Map < String ,  Set < String > >  selfSubParentMap  =  new  HashMap < > ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            selfSubParentMap . put ( "zishen" ,  new  HashSet < > ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            selfSubParentMap . put ( "xiaji" ,  new  HashSet < > ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            selfSubIndexList . forEach ( o  - >  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                //找出自身 和下级的指标
  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                if  ( o . getAllParent IndexCode ( ) . contains ( "xiaji" ) )  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                    selfSubParentMap . put ( o . getAllParentIndexCode ( ) ,  "xiaji" ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                if  ( o . getAllIndexCodePath  ( ) . indexOf ( "xiaji" )  >  - 1  )  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                    selfSubParentMap . get ( "xiaji" ) . add ( o . getIndexCode ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                }  else  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                    selfSubParentMap . put ( o . getAllParentIndexCode ( ) ,  "zishen" ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                    selfSubParentMap . get ( "zishen" ) . add ( o . getIndexCode ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                }  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            } ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            Map < String ,  AgencySelfSubScoreEntity >  insertList   =  new  HashMap < > ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            Map < String ,  GridSelfSubScoreEntity >  insertMap   =  new  HashMap < > ( ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            subScore . forEach ( score  - >  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                insertList . get ( score . getAllParentIndexCode ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                String  key  =  score . getGridId ( ) . concat ( index . getIndexCode ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                GridSelfSubScoreEntity  scoreEntity  =  insertMap . get ( key ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                if  ( scoreEntity  = =  null )  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                    scoreEntity  =  ConvertUtils . sourceToTarget ( score ,  GridSelfSubScoreEntity . 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 ( ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					                BigDecimal  partWeight  =  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 . 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 ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					        } ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    }  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    @Transactional ( rollbackFor  =  Exception . class )  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    public  void  deleteAndInsertSelfSubScore ( CalculateCommonFormDTO  formDTO ,  String  indexCode ,  Map < String ,  GridSelfSubScoreEntity >  insertMap )  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					        int  effectRow  =  0 ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					        do  {  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					            gridSelfSubScoreDao . deleteByMonthId ( formDTO . getCustomerId ( ) ,  formDTO . getMonthId ( ) ,  indexCode ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					        }  while  ( effectRow  >  0 ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					        gridSelfSubScoreDao . insertBatch ( new  ArrayList < > ( insertMap . values ( ) ) ) ;  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    }  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					
 
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					    / * *  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					     *  @param  formDTO  
				
			 
			
		
	
		
			
				
					 
					 
				
				 
				
					     *  @return  void