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