|  |  | @ -29,14 +29,19 @@ import com.epmet.constant.DataSourceConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.evaluationindex.screen.ScreenProjectCategoryOrgDailyDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.screen.ScreenProjectCategoryOrgDailyDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.screencoll.ScreenCollFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.crm.CustomerRelationEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.evaluationindex.screen.ScreenProjectCategoryOrgDailyEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.crm.CustomerRelationService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.screen.ScreenProjectCategoryOrgDailyService; | 
			
		
	
		
			
				
					|  |  |  | import com.google.common.collect.Lists; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.collections4.ListUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
	
		
			
				
					|  |  | @ -51,6 +56,8 @@ import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | @DataSource(DataSourceConstant.EVALUATION_INDEX) | 
			
		
	
		
			
				
					|  |  |  | public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<ScreenProjectCategoryOrgDailyDao, ScreenProjectCategoryOrgDailyEntity> implements ScreenProjectCategoryOrgDailyService { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private CustomerRelationService relationService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<ScreenProjectCategoryOrgDailyDTO> page(Map<String, Object> params) { | 
			
		
	
	
		
			
				
					|  |  | @ -131,4 +138,71 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  按组织计算分类统计项目数量 | 
			
		
	
		
			
				
					|  |  |  |      * @Param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @Param dateId | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/3/23 上午10:07 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public void extractProjectCategoryOrgData(String customerId, String dateId) { | 
			
		
	
		
			
				
					|  |  |  |         List<ScreenProjectCategoryOrgDailyEntity> needInsert = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         // 先查询有无子客户
 | 
			
		
	
		
			
				
					|  |  |  |         List<CustomerRelationEntity> relationInfo = relationService.selectSubCustomer(customerId); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(relationInfo)){ | 
			
		
	
		
			
				
					|  |  |  |             needInsert = disposeOneCustomer(customerId, dateId); | 
			
		
	
		
			
				
					|  |  |  |         }else { | 
			
		
	
		
			
				
					|  |  |  |             needInsert = disposeMoreCustomer(customerId,dateId,relationInfo); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         deleteAndInsert(customerId,dateId,needInsert); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  单客户处理 | 
			
		
	
		
			
				
					|  |  |  |      * @Param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @Param dateId | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/3/23 上午10:40 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private List<ScreenProjectCategoryOrgDailyEntity> disposeOneCustomer(String customerId, String dateId){ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  多客户处理 | 
			
		
	
		
			
				
					|  |  |  |      * @Param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @Param dateId | 
			
		
	
		
			
				
					|  |  |  |      * @Param relationInfo 子级客户信息 | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/3/23 上午10:40 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     private List<ScreenProjectCategoryOrgDailyEntity> disposeMoreCustomer(String customerId, String dateId,List<CustomerRelationEntity> relationInfo){ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  删除和新增 | 
			
		
	
		
			
				
					|  |  |  |      * @Param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @Param dateId | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2021/3/23 上午10:52 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void deleteAndInsert(String customerId, String dateId, List<ScreenProjectCategoryOrgDailyEntity> needInsert){ | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(needInsert)){ | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         Integer row = NumConstant.ZERO; | 
			
		
	
		
			
				
					|  |  |  |         do { | 
			
		
	
		
			
				
					|  |  |  |             row = baseDao.deleteByDateIdAndCustomerId(customerId, dateId); | 
			
		
	
		
			
				
					|  |  |  |         }while (row > NumConstant.ZERO && row == NumConstant.ONE_THOUSAND); | 
			
		
	
		
			
				
					|  |  |  |         List<List<ScreenProjectCategoryOrgDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); | 
			
		
	
		
			
				
					|  |  |  |         partition.forEach(p -> { | 
			
		
	
		
			
				
					|  |  |  |             insertBatch(p); | 
			
		
	
		
			
				
					|  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |