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; ...@@ -3,10 +3,13 @@ package com.yeejoin.amos.boot.module.common.api.dto;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id; 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.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
/** /**
* @author Administrator * @author Administrator
* Excel导入错误日志 * Excel导入错误日志
...@@ -18,10 +21,10 @@ public class ExcelImportErrorLogDto { ...@@ -18,10 +21,10 @@ public class ExcelImportErrorLogDto {
@Id @Id
private Long sequenceNbr; private Long sequenceNbr;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String xaSerial; private String xaSerial;
@Field(type = FieldType.Text) @Field(type = FieldType.Keyword)
private String record; private String record;
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
...@@ -29,4 +32,7 @@ public class ExcelImportErrorLogDto { ...@@ -29,4 +32,7 @@ public class ExcelImportErrorLogDto {
@Field(type = FieldType.Text) @Field(type = FieldType.Text)
private String traceInfo; private String traceInfo;
@Field(type = FieldType.Date, format = DateFormat.date_hour_minute)
private Date createTime;
} }
...@@ -123,7 +123,6 @@ public class CommonEquipDataProcessService { ...@@ -123,7 +123,6 @@ public class CommonEquipDataProcessService {
private final RestHighLevelClient restHighLevelClient; private final RestHighLevelClient restHighLevelClient;
@Lazy
private final JgUseRegistrationServiceImpl jgUseRegistrationService; private final JgUseRegistrationServiceImpl jgUseRegistrationService;
private final CommonServiceImpl commonService; private final CommonServiceImpl commonService;
......
...@@ -20,10 +20,14 @@ import com.yeejoin.amos.boot.module.jg.biz.edit.process.equip.strategy.HandleRes ...@@ -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.process.equip.strategy.IEquipChangeDataProcessStrategy;
import com.yeejoin.amos.boot.module.jg.biz.edit.typeHandler.PieLineLevelTypeHandler; 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.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 lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
...@@ -37,6 +41,7 @@ import java.util.stream.Collectors; ...@@ -37,6 +41,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessStrategy { public class SingleProjectEquipChangeProcess implements IEquipChangeDataProcessStrategy {
@Lazy
private final CommonEquipDataProcessService commonEquipDataProcessService; private final CommonEquipDataProcessService commonEquipDataProcessService;
private final PieLineDataChangeServiceImpl pieLineDataChangeService; private final PieLineDataChangeServiceImpl pieLineDataChangeService;
......
...@@ -179,7 +179,7 @@ public class DataDockServiceImpl { ...@@ -179,7 +179,7 @@ public class DataDockServiceImpl {
@Value("${pipeline.detail.path:/mixuap?appId=1742358052905971713&id=1867406434120003586&formType=detail&sequenceNbr=%s}") @Value("${pipeline.detail.path:/mixuap?appId=1742358052905971713&id=1867406434120003586&formType=detail&sequenceNbr=%s}")
private String pipelineRoutePath; private String pipelineRoutePath;
private final ExecutorService executorService = Executors.newFixedThreadPool(10); private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
/** /**
* 西安数据对接-保存设备信息 * 西安数据对接-保存设备信息
...@@ -2628,13 +2628,17 @@ public class DataDockServiceImpl { ...@@ -2628,13 +2628,17 @@ public class DataDockServiceImpl {
CompletableFuture.allOf( CompletableFuture.allOf(
equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> { equLists.parallelStream().map(equ -> CompletableFuture.runAsync(() -> {
contextWrapper.apply(); contextWrapper.apply();
Object resultObj = saveElevatorDataInTransaction(equ, "jg_his_xa", null); try {
if (resultObj instanceof String) { Object resultObj = saveElevatorDataInTransaction(equ, "jg_his_xa", null);
recordSet.add(resultObj.toString()); if (resultObj instanceof String) {
} recordSet.add(resultObj.toString());
if (resultObj instanceof Map) { }
Map<String, Object> result = (Map<String, Object>) resultObj; if (resultObj instanceof Map) {
inUseRecordSet.add(JSONObject.toJSONString(result)); Map<String, Object> result = (Map<String, Object>) resultObj;
inUseRecordSet.add(JSONObject.toJSONString(result));
}
} catch (LocalBadRequest e) {
inUseRecordSet.add(e.getMessage());
} }
}, executorService)).toArray(CompletableFuture[]::new) }, executorService)).toArray(CompletableFuture[]::new)
).join(); ).join();
...@@ -2724,6 +2728,7 @@ public class DataDockServiceImpl { ...@@ -2724,6 +2728,7 @@ public class DataDockServiceImpl {
ExcelImportErrorLogDto errorLogDto = JSON.parseObject(toJSONString(equ), ExcelImportErrorLogDto.class); ExcelImportErrorLogDto errorLogDto = JSON.parseObject(toJSONString(equ), ExcelImportErrorLogDto.class);
errorLogDto.setErrorInfo(e.getMessage()); errorLogDto.setErrorInfo(e.getMessage());
errorLogDto.setTraceInfo(traceInfo); errorLogDto.setTraceInfo(traceInfo);
errorLogDto.setCreateTime(new Date());
excelImportErrorLogDao.save(errorLogDto); excelImportErrorLogDao.save(errorLogDto);
String errorMessage = e.getMessage(); String errorMessage = e.getMessage();
if (errorMessage == null) { if (errorMessage == null) {
...@@ -2735,7 +2740,7 @@ public class DataDockServiceImpl { ...@@ -2735,7 +2740,7 @@ public class DataDockServiceImpl {
errorResult.put("type", "error"); errorResult.put("type", "error");
errorResult.put("msg", errorMessage); errorResult.put("msg", errorMessage);
errorResult.put("traceInfo", traceInfo); 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