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.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.util.DimIdGenerator; 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.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; 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 org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.concurrent.*;
/** /**
* 指标计算controller * 指标计算controller
@ -23,9 +26,16 @@ import java.util.Date;
* @author liujianjun@elink-cn.com * @author liujianjun@elink-cn.com
* @date 2020/8/24 14:38 * @date 2020/8/24 14:38
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("indexcalculate") @RequestMapping("indexcalculate")
public class IndexCalculateController { 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 @Autowired
private IndexCalculateService indexCalculateService; private IndexCalculateService indexCalculateService;
@ -44,12 +54,15 @@ public class IndexCalculateController {
@ExternalAppRequestAuth @ExternalAppRequestAuth
@PostMapping("all") @PostMapping("all")
public Result<Boolean> indexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody CalculateCommonFormDTO formDTO) { public Result<Boolean> indexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody CalculateCommonFormDTO formDTO) {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId()); singleThreadPool.execute(() -> {
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
if (aBoolean) { long start = System.currentTimeMillis();
return new Result<Boolean>().ok(true); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
} if (aBoolean) {
return new Result<Boolean>().error("指标计算失败"); log.error("全部指标计算完成,总耗时:{}秒", (System.currentTimeMillis() - start) / 1000);
}
});
return new Result<Boolean>().ok(true);
} }
@PostMapping("reAll") @PostMapping("reAll")

Loading…
Cancel
Save