From f151b5a43cbe4c7c58a678f8b3ec9bcfe72fa919 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 11 Sep 2020 10:18:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A1=E7=AE=97=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IndexCalculateController.java | 6 ++++-- .../indexcal/impl/IndexCalculateServiceImpl.java | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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 887482d1a4..0acdf28890 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 @@ -5,13 +5,13 @@ import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.util.DimIdGenerator; import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.sun.org.apache.xpath.internal.operations.Bool; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -77,7 +77,7 @@ public class IndexCalculateController { long start = System.currentTimeMillis(); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); if (aBoolean) { - log.error("全部指标计算完成,总耗时:{}秒", (System.currentTimeMillis() - start) / 1000); + log.error("客户Id:{},全部指标计算完成,总耗时:{}秒", customerId, (System.currentTimeMillis() - start) / 1000); } redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), false); }); @@ -94,10 +94,12 @@ public class IndexCalculateController { @PostMapping("reAll") public Result calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { + long start = System.currentTimeMillis(); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); if (aBoolean) { return new Result().ok(true); } + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + formDTO.getCustomerId() + ",calculateAll全部指标计算完成,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); return new Result().error("指标计算失败"); } 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 5ab74faadf..1a3f3c0e3c 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; 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.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.DataSourceConstant; import com.epmet.dto.indexcal.CalculateCommonFormDTO; @@ -71,6 +72,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { Boolean flag = false; for (String customerId : customerIds) { CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId()); + long start = System.currentTimeMillis(); try { //计算党员相关的 try { @@ -81,8 +83,11 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { log.error("indexCalculate cpcIndexCalculate exception", e); throw new RenException("indexCalculate cpcIndexCalculate exception", e); } + //测试用 + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【党员相关】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); //计算网格 + start = System.currentTimeMillis(); try { flag = gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO); log.info("indexCalculate calculateGridCorreLation return result:{}", flag); @@ -90,37 +95,46 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { log.error("indexCalculate calculateGridCorreLation exception", e); throw new RenException("indexCalculate calculateGridCorreLation exception", e); } + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【网格相关】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); //计算社区 + start = System.currentTimeMillis(); try { flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId()); log.info("indexCalculate calCommunityAll return result:{}", flag); + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【社区相关】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); } catch (Exception e) { log.error("indexCalculate calCommunityAll exception", e); throw new RenException("indexCalculate calAll exception", e); } //计算街道 + start = System.currentTimeMillis(); try { flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId()); log.info("indexCalculate calStreetAll return result:{}", flag); + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【街道相关】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); } catch (Exception e) { log.error("indexCalculate calStreetAll exception", e); throw new RenException("indexCalculate calStreetAll exception", e); } //计算区直属 + start = System.currentTimeMillis(); try { flag = deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO); log.info("indexCalculate calculateDeptCorreLation return result:{}", flag); + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【区直部门】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); } catch (Exception e) { log.error("indexCalculate calculateDeptCorreLation exception", e); throw new RenException("indexCalculate calculateDeptCorreLation exception", e); } //计算全区 + start = System.currentTimeMillis(); try { indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId()); log.info("indexCalculate calDistrictAll return result:{}", flag); + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 【全区相关】计算完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); } catch (Exception e) { log.error("indexCalculate calDistrictAll exception", e); throw new RenException("indexCalculate calDistrictAll exception", e); @@ -131,8 +145,10 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { //计算完毕后 将结果插入大屏相关数据表 if (flag) { + start = System.currentTimeMillis(); try { factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId()); + HttpClientManager.getInstance().sendAlarmMsg("客户Id:" + customerId + " 分数插入到大屏显示库完毕,总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); } catch (Exception e) { log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e); flag = false;