From 861f90cee38ffa505f2ab879a376ac0652d09be5 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 3 Mar 2021 17:30:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=BC=80=E6=96=B0=E6=96=B9=E6=B3=95=E3=80=90=E5=8F=AF=E5=A4=9A?= =?UTF-8?q?=E6=9C=88=E4=B8=80=E8=B5=B7=E8=AE=A1=E7=AE=97=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/indexcal/IndexStatisticsFormDTO.java | 23 ++++++++++++ .../controller/IndexCalculateController.java | 7 ++++ .../indexcal/IndexCalculateService.java | 3 ++ .../impl/IndexCalculateServiceImpl.java | 37 +++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/IndexStatisticsFormDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/IndexStatisticsFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/IndexStatisticsFormDTO.java new file mode 100644 index 0000000000..dd63b1fea7 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/IndexStatisticsFormDTO.java @@ -0,0 +1,23 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/3/3 下午4:32 + */ +@Data +public class IndexStatisticsFormDTO implements Serializable { + + private static final long serialVersionUID = 1127307237675056558L; + + private String customerId; + + private String monthId; + + private String startMonth; + + private String endMonth; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index 26380abda1..58bd3ab491 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java @@ -10,6 +10,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.CalculateStatus; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.IndexStatisticsFormDTO; import com.epmet.model.CalculateFlagModel; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; @@ -335,4 +336,10 @@ public class IndexCalculateController { factIndexCollectService.insertDeptGovrnAbility(formDTO, externalAppRequestParam.getCustomerId()); return new Result(); }*/ + + @PostMapping("indexstatistics") + public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){ + indexCalculateService.indexStatistics(formDTO); + return new Result(); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java index 7866473d6f..4e7c074a57 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java @@ -1,6 +1,7 @@ package com.epmet.service.evaluationindex.indexcal; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.IndexStatisticsFormDTO; /** * 指标计算service @@ -16,4 +17,6 @@ public interface IndexCalculateService { * @return */ Boolean indexCalculate(CalculateCommonFormDTO formDTO); + + Boolean indexStatistics(IndexStatisticsFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index db48bb1214..72e3369716 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -7,11 +7,14 @@ import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; 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.CustomerSubInfoDTO; +import com.epmet.dto.indexcal.IndexStatisticsFormDTO; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.redis.IndexCalRedis; 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.indexcoll.FactIndexCollectService; import com.epmet.util.DimIdGenerator; @@ -55,6 +58,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { private ScreenCustomerAgencyDao screenCustomerAgencyDao; @Autowired private CustomerRelationService customerRelationService; + @Autowired + private IndexOriginExtractService indexOriginExtractService; @Override public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { @@ -203,4 +208,36 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { private Map getCustomerInfoMap(List customerIds) { return customerRelationService.getCustomerInfoMap(customerIds); } + + @Override + public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { + List customerIds = new ArrayList<>(); + if (StringUtils.isEmpty(formDTO.getCustomerId())){ + Result> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); + if (!externalCustomerIds.success()){ + log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); + return false; + } + customerIds = externalCustomerIds.getData(); + }else customerIds.add(formDTO.getCustomerId()); + List 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 finalMonthIds = monthIds; + customerIds.forEach(customerId -> { + finalMonthIds.forEach(monthId -> { + CalculateCommonFormDTO extractFormDTO = new CalculateCommonFormDTO(); + extractFormDTO.setCustomerId(customerId); + extractFormDTO.setMonthId(monthId); + this.indexCalculate(extractFormDTO); + }); + }); + return null; + } } From 0d54716db35312a0353014c01659f699ee00fd7e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 3 Mar 2021 17:43:19 +0800 Subject: [PATCH 2/3] indexstatistics --- .../epmet/dto/screencoll/form/CustomerAgencyFormDTO.java | 5 +++-- .../java/com/epmet/controller/plugins/OfsController.java | 6 +++--- .../indexcal/impl/IndexCalculateServiceImpl.java | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/CustomerAgencyFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/CustomerAgencyFormDTO.java index 0ef8749799..2ef49407e4 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/CustomerAgencyFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/CustomerAgencyFormDTO.java @@ -60,7 +60,7 @@ public class CustomerAgencyFormDTO implements Serializable { private String level; /** - * 行政地区编码 + * 行政地区编码,孔村、榆山、锦水以及孔村要有值 */ private String areaCode; @@ -75,7 +75,8 @@ public class CustomerAgencyFormDTO implements Serializable { private String isDisplay; /** - * 当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701 + * v2升级:当前组织的上级行政地区编码add0204;举例平阴县对应的是济南市3701 + * 孔村、榆山、锦水以及孔村要有值 */ private String parentAreaCode; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/plugins/OfsController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/plugins/OfsController.java index 09f5942c5c..ca112ac6a9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/plugins/OfsController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/plugins/OfsController.java @@ -26,7 +26,7 @@ public class OfsController { * @param customerId * @param formDTO * @author yinzuomei - * @description 【146】一张清单 + * @description 【146】一张清单 isFirst=true时,根据customerId先删除后增加 * @Date 2021/1/22 10:19 **/ @PostMapping("onelist-daily") @@ -40,7 +40,7 @@ public class OfsController { * @param customerId * @param formDTO * @author yinzuomei - * @description 【146】合同监管 + * @description 【146】合同监管 isFirst=true时,根据customerId先删除后增加 * @Date 2021/1/22 10:42 **/ @PostMapping("contract-daily") @@ -54,7 +54,7 @@ public class OfsController { * @param customerId * @param formDTO * @author yinzuomei - * @description 【146】竞标管理 + * @description 【146】竞标管理 isFirst=true时,根据customerId先删除后增加 * @Date 2021/1/22 10:53 **/ @PostMapping("bid-daily") diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index 72e3369716..afcfe24d75 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -2,12 +2,13 @@ package com.epmet.service.evaluationindex.indexcal.impl; import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; 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.CustomerSubInfoDTO; import com.epmet.dto.indexcal.IndexStatisticsFormDTO; @@ -235,9 +236,11 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { CalculateCommonFormDTO extractFormDTO = new CalculateCommonFormDTO(); extractFormDTO.setCustomerId(customerId); extractFormDTO.setMonthId(monthId); - this.indexCalculate(extractFormDTO); + long start = System.currentTimeMillis(); + boolean calFlag=this.indexCalculate(extractFormDTO); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + calFlag + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); }); }); - return null; + return true; } } From 3b03299ef9fd9ce925dfd2d6934f0af53e12629e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 3 Mar 2021 18:41:54 +0800 Subject: [PATCH 3/3] indexstatistics --- .../indexcal/impl/IndexCalculateServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index afcfe24d75..d517fd70ec 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -22,6 +22,7 @@ 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 java.util.ArrayList; @@ -210,6 +211,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { return customerRelationService.getCustomerInfoMap(customerIds); } + @Async @Override public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { List customerIds = new ArrayList<>(); @@ -224,6 +226,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { List monthIds = new ArrayList<>(); if (StringUtils.isNotEmpty(formDTO.getStartMonth()) && StringUtils.isNotEmpty(formDTO.getEndMonth())){ monthIds = DateUtils.getMonthBetween(formDTO.getStartMonth(),formDTO.getEndMonth()); + log.info(JSON.toJSONString(monthIds)); }else { if (StringUtils.isEmpty(formDTO.getMonthId())){ // 默认上月 @@ -238,7 +241,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { extractFormDTO.setMonthId(monthId); long start = System.currentTimeMillis(); boolean calFlag=this.indexCalculate(extractFormDTO); - HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + calFlag + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + extractFormDTO.getCustomerId() + ";monthId:" + extractFormDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + calFlag + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); }); }); return true;