Browse Source

Merge remote-tracking branch 'remotes/origin/dev_screen_data' into dev_temp

dev_shibei_match
jianjun 5 years ago
parent
commit
266c4fde9b
  1. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

25
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

@ -8,6 +8,8 @@ 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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.concurrent.*;
/**
* 指标计算controller
@ -23,9 +26,16 @@ import java.util.Date;
* @author liujianjun@elink-cn.com
* @date 2020/8/24 14:38
*/
@Slf4j
@RestController
@RequestMapping("indexcalculate")
public class IndexCalculateController {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("indexcalculate-pool-%d").build();
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
@Autowired
private IndexCalculateService indexCalculateService;
@ -44,12 +54,15 @@ public class IndexCalculateController {
@ExternalAppRequestAuth
@PostMapping("all")
public Result<Boolean> indexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody CalculateCommonFormDTO formDTO) {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
return new Result<Boolean>().error("指标计算失败");
singleThreadPool.execute(() -> {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
long start = System.currentTimeMillis();
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
log.error("全部指标计算完成,总耗时:{}秒", (System.currentTimeMillis() - start) / 1000);
}
});
return new Result<Boolean>().ok(true);
}
@PostMapping("reAll")

Loading…
Cancel
Save