From e7db73a2b578ad89431f8f44c7a5eb4e1942c209 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Sep 2020 10:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=95=B0=E9=87=8F=E6=8E=A7?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FactOriginExtractController.java | 13 +++++-------- .../impl/IndexOriginExtractServiceImpl.java | 2 +- .../impl/FactOriginExtractServiceImpl.java | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java index 29ea5d9fa2..10a938fb7a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.extract.form.ExtractFormDTO; import com.epmet.service.evaluationindex.extract.todata.*; -import com.epmet.util.DimIdGenerator; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -13,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Date; +import java.util.List; /** @@ -45,14 +44,12 @@ public class FactOriginExtractController { @PostMapping("extractall") public Result extractAll(@RequestBody ExtractFormDTO extractFormDTO) { if (StringUtils.isNotBlank(extractFormDTO.getStartDate()) && StringUtils.isNotBlank(extractFormDTO.getEndDate())) { - Date startDate = DateUtils.stringToDate(extractFormDTO.getStartDate(), "yyyyMMdd"); - Date endDate = DateUtils.stringToDate(extractFormDTO.getEndDate(), "yyyyMMdd"); - do { - String dateDimId = DimIdGenerator.getDateDimId(startDate); + List daysBetween = DateUtils.getDaysBetween(extractFormDTO.getStartDate(), extractFormDTO.getEndDate()); + for (int i = 0; i < daysBetween.size(); i++) { + String dateDimId = daysBetween.get(i); extractFormDTO.setDateId(dateDimId); factOriginExtractService.extractAll(extractFormDTO); - startDate = DateUtils.addDateDays(DateUtils.stringToDate(extractFormDTO.getStartDate(), "yyyyMMdd"), 1); - } while (endDate.compareTo(startDate) >= 0); + } } else { factOriginExtractService.extractAll(extractFormDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 0c4e534716..23a4de5128 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -27,7 +27,7 @@ import java.util.concurrent.*; public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() .setNameFormat("indexOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(2, 8, + ExecutorService threadPool = new ThreadPoolExecutor(1, 1, 10L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index 47b8c50387..14a2b1c351 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -27,7 +27,7 @@ import java.util.concurrent.*; public class FactOriginExtractServiceImpl implements FactOriginExtractService { ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() .setNameFormat("factOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(4, 8, + ExecutorService threadPool = new ThreadPoolExecutor(1, 1, 10L, TimeUnit.MINUTES, new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @@ -53,13 +53,14 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { List customerIds = new ArrayList<>(); if (StringUtils.isNotBlank(customerId)) { customerIds.add(customerId); - } - int pageNo = NumConstant.ONE; - int pageSize = NumConstant.ONE_HUNDRED; - customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize); - if (CollectionUtils.isEmpty(customerIds)) { - log.error("extractAll 获取客户Id为空"); - return; + } else { + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_HUNDRED; + customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize); + if (CollectionUtils.isEmpty(customerIds)) { + log.error("extractAll 获取客户Id为空"); + return; + } } String finalDateId = dateId; @@ -67,7 +68,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { ExtractFormDTO param = new ExtractFormDTO(); param.setCustomerId(cId); param.setDateId(finalDateId); - // log.warn(); + log.debug("extractAll param:{}", JSON.toJSONString(param)); submitJob(param); });