From 851bc4f3d7e1c6b7bec6f372d8e3e0562b1ae862 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 16 Nov 2020 15:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=8A=BD=E5=8F=96=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=E4=BD=BF=E7=94=A8=E7=BA=BF=E7=A8=8B=E6=B1=A0=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScreenExtractDailyController.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index c2e4d0f6d6..07919aa425 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -1,24 +1,33 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.*; + /** * @Author zxc * @DateTime 2020/9/24 9:42 上午 */ +@Slf4j @RestController @RequestMapping("screenextract") public class ScreenExtractDailyController { - + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() + .setNameFormat("ScreenExtractDailyController-pool-%d").build(); + ExecutorService threadPool = new ThreadPoolExecutor(1, 1, + 10L, TimeUnit.MINUTES, + new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private ScreenExtractService screenExtractService; @@ -28,10 +37,17 @@ public class ScreenExtractDailyController { * @author zxc * @date 2020/9/24 10:15 上午 */ - @Async @PostMapping("extractdailyall") public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - screenExtractService.extractDailyAll(extractOriginFormDTO); + threadPool.submit(() -> { + log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); + try { + screenExtractService.extractDailyAll(extractOriginFormDTO); + log.info("screenExtractDaily end"); + } catch (Exception e) { + log.error("screenExtractDaily exception", e); + } + }); return new Result(); }