|
@ -7,11 +7,14 @@ import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
|
|
|
import com.epmet.dto.extract.form.ExtractIndexFormDTO; |
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
import com.epmet.dto.indexcal.CustomerSubInfoDTO; |
|
|
import com.epmet.dto.indexcal.CustomerSubInfoDTO; |
|
|
|
|
|
import com.epmet.dto.indexcal.IndexStatisticsFormDTO; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.redis.IndexCalRedis; |
|
|
import com.epmet.redis.IndexCalRedis; |
|
|
import com.epmet.service.crm.CustomerRelationService; |
|
|
import com.epmet.service.crm.CustomerRelationService; |
|
|
|
|
|
import com.epmet.service.evaluationindex.extract.dataToIndex.IndexOriginExtractService; |
|
|
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.util.DimIdGenerator; |
|
|
import com.epmet.util.DimIdGenerator; |
|
@ -55,6 +58,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private CustomerRelationService customerRelationService; |
|
|
private CustomerRelationService customerRelationService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IndexOriginExtractService indexOriginExtractService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { |
|
|
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { |
|
@ -203,4 +208,36 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { |
|
|
private Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) { |
|
|
private Map<String, CustomerSubInfoDTO> getCustomerInfoMap(List<String> customerIds) { |
|
|
return customerRelationService.getCustomerInfoMap(customerIds); |
|
|
return customerRelationService.getCustomerInfoMap(customerIds); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
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; |
|
|
|
|
|
} |
|
|
|
|
|
customerIds = externalCustomerIds.getData(); |
|
|
|
|
|
}else customerIds.add(formDTO.getCustomerId()); |
|
|
|
|
|
List<String> monthIds = new ArrayList<>(); |
|
|
|
|
|
if (StringUtils.isNotEmpty(formDTO.getStartMonth()) && StringUtils.isNotEmpty(formDTO.getEndMonth())){ |
|
|
|
|
|
monthIds = DateUtils.getMonthBetween(formDTO.getStartMonth(),formDTO.getEndMonth()); |
|
|
|
|
|
}else { |
|
|
|
|
|
if (StringUtils.isEmpty(formDTO.getMonthId())){ |
|
|
|
|
|
// 默认上月
|
|
|
|
|
|
monthIds.add(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); |
|
|
|
|
|
}else monthIds.add(formDTO.getMonthId()); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> finalMonthIds = monthIds; |
|
|
|
|
|
customerIds.forEach(customerId -> { |
|
|
|
|
|
finalMonthIds.forEach(monthId -> { |
|
|
|
|
|
CalculateCommonFormDTO extractFormDTO = new CalculateCommonFormDTO(); |
|
|
|
|
|
extractFormDTO.setCustomerId(customerId); |
|
|
|
|
|
extractFormDTO.setMonthId(monthId); |
|
|
|
|
|
this.indexCalculate(extractFormDTO); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|