|
@@ -4,10 +4,8 @@ import cn.hutool.core.thread.ExecutorBuilder;
|
|
|
import com.persagy.apm.common.context.poems.PoemsContext;
|
|
|
import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BelongTypeEnum;
|
|
|
import com.persagy.apm.energy.report.monthly.config.type.constant.enums.BuildingTypeEnum;
|
|
|
-import com.persagy.apm.energy.report.monthly.config.type.model.ReportType;
|
|
|
-import com.persagy.apm.energy.report.monthly.config.type.service.IReportTypeService;
|
|
|
-import com.persagy.apm.energy.report.monthly.outline.constants.enums.ReportStateEnum;
|
|
|
import com.persagy.apm.energy.report.monthly.outline.model.ReportOutline;
|
|
|
+import com.persagy.apm.energy.report.monthly.outline.service.builder.IBusinessReportGenerator;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -26,11 +24,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|
|
@Slf4j
|
|
|
public class GenerateReportThreadPool {
|
|
|
@Autowired
|
|
|
- private BusinessProjectReportGenerator businessProjectReportGenerator;
|
|
|
- @Autowired
|
|
|
- private BusinessAreaReportGenerator businessAreaReportGenerator;
|
|
|
- @Autowired
|
|
|
- private IReportTypeService reportTypeService;
|
|
|
+ IBusinessReportGenerator businessReportGenerator;
|
|
|
|
|
|
private final ExecutorService es;
|
|
|
|
|
@@ -56,24 +50,9 @@ public class GenerateReportThreadPool {
|
|
|
String pd = PoemsContext.getContext().getPd();
|
|
|
String loginDevice = PoemsContext.getContext().getLoginDevice();
|
|
|
es.execute(() -> {
|
|
|
- try {
|
|
|
- PoemsContext.setContext(userId, loginDevice, pd);
|
|
|
- String reportTypeId = reportOutline.getReportTypeId();
|
|
|
- ReportType reportType = reportTypeService.queryReportTypeDetail(reportTypeId);
|
|
|
- if (BuildingTypeEnum.BUSINESS.getType().equals(reportType.getBuildingType())) {
|
|
|
- if (BelongTypeEnum.PROJECT.getType().equals(reportType.getBelongType())) {
|
|
|
- synchronized (reportOutline.getId().intern()) {
|
|
|
- businessProjectReportGenerator.generateReport(reportOutline);
|
|
|
- }
|
|
|
- } else {
|
|
|
- synchronized (reportOutline.getId().intern()) {
|
|
|
- businessAreaReportGenerator.generateReport(reportOutline);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("生成报告失败", e);
|
|
|
- reportOutline.setStatus(ReportStateEnum.BUILD_FAILED.getType());
|
|
|
+ PoemsContext.setContext(userId, loginDevice, pd);
|
|
|
+ synchronized (reportOutline.getId().intern()) {
|
|
|
+ businessReportGenerator.generateReport(reportOutline);
|
|
|
}
|
|
|
});
|
|
|
}
|