Commit 47beccd6 authored by tianbo's avatar tianbo

refactor(jg): 优化数据对接服务与设备处理逻辑

- 数据对接服务线程池大小调整为CPU核心数的两倍 - 电梯数据保存增加异常捕获处理 - Excel导入错误日志添加创建时间字段 - 错误结果抛出LocalBadRequest异常替代直接返回
parent 38f914f8
......@@ -3,10 +3,13 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
/**
* @author Administrator
* Excel导入错误日志
......@@ -18,10 +21,10 @@ public class ExcelImportErrorLogDto {
@Id
private Long sequenceNbr;
@Field(type = FieldType.Text)
@Field(type = FieldType.Keyword)
private String xaSerial;
@Field(type = FieldType.Text)
@Field(type = FieldType.Keyword)
private String record;
@Field(type = FieldType.Text)
......@@ -29,4 +32,7 @@ public class ExcelImportErrorLogDto {
@Field(type = FieldType.Text)
private String traceInfo;
@Field(type = FieldType.Date, format = DateFormat.date_hour_minute)
private Date createTime;
}
......@@ -123,7 +123,6 @@ public class CommonEquipDataProcessService {
private final RestHighLevelClient restHighLevelClient;
@Lazy
private final JgUseRegistrationServiceImpl jgUseRegistrationService;
private final CommonServiceImpl commonService;
......
......@@ -20,10 +20,14 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.HandleRes
import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgConstructionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.*;
......@@ -37,6 +41,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessStrategy {
@Lazy
private final CommonEquipDataProcessService commonEquipDataProcessService;
private final PieLineDataChangeServiceImpl pieLineDataChangeService;
......
......@@ -179,7 +179,7 @@ public class DataDockServiceImpl {
@Value("${pipeline.detail.path:/mixuap?appId=1742358052905971713&id=1867406434120003586&formType=detail&sequenceNbr=%s}")
private String pipelineRoutePath;
private final ExecutorService executorService = Executors.newFixedThreadPool(10);
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
/**
* 西安数据对接-保存设备信息
......@@ -2628,6 +2628,7 @@ public class DataDockServiceImpl {
CompletableFuture.allOf(
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
contextWrapper.apply();
try {
Object resultObj = saveElevatorDataInTransaction(equ, "jg_his_xa", null);
if (resultObj instanceof String) {
recordSet.add(resultObj.toString());
......@@ -2636,6 +2637,9 @@ public class DataDockServiceImpl {
Map<String, Object> result = (Map<String, Object>) resultObj;
inUseRecordSet.add(JSONObject.toJSONString(result));
}
} catch (LocalBadRequest e) {
inUseRecordSet.add(e.getMessage());
}
}, executorService)).toArray(CompletableFuture[]::new)
).join();
} catch (Exception e) {
......@@ -2724,6 +2728,7 @@ public class DataDockServiceImpl {
ExcelImportErrorLogDto errorLogDto = JSON.parseObject(toJSONString(equ), ExcelImportErrorLogDto.class);
errorLogDto.setErrorInfo(e.getMessage());
errorLogDto.setTraceInfo(traceInfo);
errorLogDto.setCreateTime(new Date());
excelImportErrorLogDao.save(errorLogDto);
String errorMessage = e.getMessage();
if (errorMessage == null) {
......@@ -2735,7 +2740,7 @@ public class DataDockServiceImpl {
errorResult.put("type", "error");
errorResult.put("msg", errorMessage);
errorResult.put("traceInfo", traceInfo);
return errorResult;
throw new LocalBadRequest(JSON.toJSONString(errorResult));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment