|
@ -2,21 +2,22 @@ package com.epmet.service.evaluationindex.indexcal.impl; |
|
|
|
|
|
|
|
|
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.exception.RenException; |
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
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.dto.indexcal.CalculateCommonFormDTO; |
|
|
import com.epmet.dto.indexcal.CalculateCommonFormDTO; |
|
|
import com.epmet.dto.screen.form.IndexCalculateForm; |
|
|
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.redis.IndexCodeFieldReRedis; |
|
|
import com.epmet.redis.IndexCodeFieldReRedis; |
|
|
import com.epmet.service.evaluationindex.indexcal.*; |
|
|
import com.epmet.service.evaluationindex.indexcal.*; |
|
|
|
|
|
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; |
|
|
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.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.Date; |
|
|
import java.util.Date; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
@ -44,26 +45,33 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { |
|
|
private IndexCalculateDistrictService indexCalculateDistrictService; |
|
|
private IndexCalculateDistrictService indexCalculateDistrictService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private DeptScoreService deptScoreService; |
|
|
private DeptScoreService deptScoreService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private FactIndexCollectService factIndexCollectService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Boolean indexCalculate(IndexCalculateForm formDTO) { |
|
|
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { |
|
|
try { |
|
|
try { |
|
|
if (StringUtils.isBlank(formDTO.getMonthId())) { |
|
|
if (StringUtils.isBlank(formDTO.getMonthId())) { |
|
|
//默认 当前月份-1
|
|
|
//默认 当前月份-1
|
|
|
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); |
|
|
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); |
|
|
} |
|
|
} |
|
|
//按照客户分组
|
|
|
//按照客户分组
|
|
|
if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) { |
|
|
List<String> customerIds = new ArrayList<>(); |
|
|
|
|
|
if (StringUtils.isBlank(formDTO.getCustomerId())) { |
|
|
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; |
|
|
} |
|
|
} |
|
|
formDTO.setCustomerIds(externalCustomerIdsResult.getData()); |
|
|
customerIds = externalCustomerIdsResult.getData(); |
|
|
|
|
|
} else { |
|
|
|
|
|
customerIds.add(formDTO.getCustomerId()); |
|
|
} |
|
|
} |
|
|
Boolean flag = false; |
|
|
Boolean flag = false; |
|
|
for (String customerId : formDTO.getCustomerIds()) { |
|
|
for (String customerId : customerIds) { |
|
|
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); |
|
|
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); |
|
|
|
|
|
try { |
|
|
//计算党员相关的
|
|
|
//计算党员相关的
|
|
|
try { |
|
|
try { |
|
|
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); |
|
|
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); |
|
@ -71,7 +79,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { |
|
|
log.info("indexCalculate cpcIndexCalculate return result:{}", flag); |
|
|
log.info("indexCalculate cpcIndexCalculate return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate cpcIndexCalculate exception", e); |
|
|
log.error("indexCalculate cpcIndexCalculate exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate cpcIndexCalculate exception", e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//计算网格
|
|
|
//计算网格
|
|
@ -80,42 +88,55 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { |
|
|
log.info("indexCalculate calculateGridCorreLation return result:{}", flag); |
|
|
log.info("indexCalculate calculateGridCorreLation return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate calculateGridCorreLation exception", e); |
|
|
log.error("indexCalculate calculateGridCorreLation exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate calculateGridCorreLation exception", e); |
|
|
} |
|
|
} |
|
|
//计算社区
|
|
|
//计算社区
|
|
|
try { |
|
|
try { |
|
|
indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); |
|
|
flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); |
|
|
log.info("indexCalculate calAll return result:{}", flag); |
|
|
log.info("indexCalculate calCommunityAll return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate calAll exception", e); |
|
|
log.error("indexCalculate calCommunityAll exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate calAll exception", e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//计算街道
|
|
|
//计算街道
|
|
|
try { |
|
|
try { |
|
|
indexCalculateStreetService.calStreetAll(customerId,formDTO.getMonthId()); |
|
|
flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId()); |
|
|
log.info("indexCalculate calAll return result:{}", flag); |
|
|
log.info("indexCalculate calStreetAll return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate calAll exception", e); |
|
|
log.error("indexCalculate calStreetAll exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate calStreetAll exception", e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//计算区直属
|
|
|
//计算区直属
|
|
|
try { |
|
|
try { |
|
|
deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO); |
|
|
flag = deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO); |
|
|
log.info("indexCalculate calAll return result:{}", flag); |
|
|
log.info("indexCalculate calculateDeptCorreLation return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate calAll exception", e); |
|
|
log.error("indexCalculate calculateDeptCorreLation exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate calculateDeptCorreLation exception", e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//计算全区
|
|
|
//计算全区
|
|
|
try { |
|
|
try { |
|
|
indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId()); |
|
|
indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId()); |
|
|
log.info("indexCalculate calAll return result:{}", flag); |
|
|
log.info("indexCalculate calDistrictAll return result:{}", flag); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("indexCalculate calAll exception", e); |
|
|
log.error("indexCalculate calDistrictAll exception", e); |
|
|
break; |
|
|
throw new RenException("indexCalculate calDistrictAll exception", e); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (RenException e) { |
|
|
|
|
|
flag = false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//计算完毕后 将结果插入大屏相关数据表
|
|
|
|
|
|
if (flag) { |
|
|
|
|
|
try { |
|
|
|
|
|
factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e); |
|
|
|
|
|
flag = false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return flag; |
|
|
return flag; |
|
|