|  |  | @ -1,7 +1,9 @@ | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.service.evaluationindex.indexcal.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import cn.hutool.core.collection.CollectionUtil; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.dynamic.datasource.annotation.DataSource; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.enums.EnvEnum; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
	
		
			
				
					|  |  | @ -17,16 +19,16 @@ import com.epmet.redis.IndexCalRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.crm.CustomerRelationService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.indexcal.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.stats.DimCustomerService; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.util.DimIdGenerator; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.scheduling.annotation.Async; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Date; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * @author liujianjun | 
			
		
	
	
		
			
				
					|  |  | @ -58,6 +60,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |     private ScreenCustomerAgencyDao screenCustomerAgencyDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private CustomerRelationService customerRelationService; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DimCustomerService dimCustomerService; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { | 
			
		
	
	
		
			
				
					|  |  | @ -67,14 +71,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |                 formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             //按照客户分组
 | 
			
		
	
		
			
				
					|  |  |  |             List<String> customerIds = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |             Set<String> customerIds = new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  |             if (StringUtils.isBlank(formDTO.getCustomerId())) { | 
			
		
	
		
			
				
					|  |  |  |                 log.error("什么情况下走的这个方法,应该干掉他,因为...=====param:{}",JSON.toJSONString(formDTO)); | 
			
		
	
		
			
				
					|  |  |  |                 Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); | 
			
		
	
		
			
				
					|  |  |  |                 if (!externalCustomerIdsResult.success()) { | 
			
		
	
		
			
				
					|  |  |  |                     log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); | 
			
		
	
		
			
				
					|  |  |  |                     return false; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 customerIds = externalCustomerIdsResult.getData(); | 
			
		
	
		
			
				
					|  |  |  |                 customerIds.addAll(externalCustomerIdsResult.getData()); | 
			
		
	
		
			
				
					|  |  |  |             } else { | 
			
		
	
		
			
				
					|  |  |  |                 customerIds.add(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
	
		
			
				
					|  |  | @ -95,8 +100,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             return flag; | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             e.printStackTrace(); | 
			
		
	
		
			
				
					|  |  |  |             log.warn("indexCalculate exception:{}",e); | 
			
		
	
		
			
				
					|  |  |  |             log.warn("indexCalculate late exception",e); | 
			
		
	
		
			
				
					|  |  |  |             log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); | 
			
		
	
		
			
				
					|  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |             //清除缓存
 | 
			
		
	
	
		
			
				
					|  |  | @ -212,12 +216,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { | 
			
		
	
		
			
				
					|  |  |  |     public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         List<String> customerIds = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isEmpty(formDTO.getCustomerId())){ | 
			
		
	
		
			
				
					|  |  |  |             Result<List<String>> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); | 
			
		
	
		
			
				
					|  |  |  |             if (!externalCustomerIds.success()){ | 
			
		
	
		
			
				
					|  |  |  |                 log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); | 
			
		
	
		
			
				
					|  |  |  |                 return false; | 
			
		
	
		
			
				
					|  |  |  |             int pageNo = NumConstant.ONE; | 
			
		
	
		
			
				
					|  |  |  |             int pageSize = NumConstant.ONE_HUNDRED; | 
			
		
	
		
			
				
					|  |  |  |             List<String> customerIdList = null; | 
			
		
	
		
			
				
					|  |  |  |             do { | 
			
		
	
		
			
				
					|  |  |  |                 customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); | 
			
		
	
		
			
				
					|  |  |  |                 if (!CollectionUtils.isEmpty(customerIdList)){ | 
			
		
	
		
			
				
					|  |  |  |                     customerIds.addAll(customerIdList); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             customerIds = externalCustomerIds.getData(); | 
			
		
	
		
			
				
					|  |  |  |             } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); | 
			
		
	
		
			
				
					|  |  |  |         }else { | 
			
		
	
		
			
				
					|  |  |  |             customerIds.add(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
	
		
			
				
					|  |  | 
 |