Commit f7c2a8b7 authored by tianbo's avatar tianbo

fix(jg):优化电梯数据保存逻辑并完善检验类型映射

- 修改数据保存失败时的异常信息,包含具体错误描述 - 启用检验类型和检验结论的字典映射转换逻辑 - 新增"电梯检测"和"委托检验"类型的字典映射- 调整批量保存电梯数据的批次大小为1000 - 增加对上传结果状态的判断,异常时抛出运行时异常 - 完善Excel导入字段的数值格式化注解 - 更新检验/检测类型和结论的Excel表头名称 -修复空Excel文件上传时的异常处理逻辑
parent cc841257
......@@ -28,6 +28,7 @@ public class UsePlaceConverter implements Converter<String> {
dictMap.put("地铁站", "6641");
dictMap.put("机场", "6642");
dictMap.put("车站", "6643");
dictMap.put("大型商业综合体", "6644");
dictMap.put("商业综合体", "6644");
dictMap.put("超市", "6645");
dictMap.put("餐饮场所", "6646");
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.api.openapi.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.yeejoin.amos.api.openapi.converter.*;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import com.yeejoin.amos.boot.module.common.api.converter.CommonCustomConverter;
......@@ -217,11 +218,11 @@ public class XiAnElevatorExcelDto extends BaseDto {
private String inspectOrgCode;
@ApiModelProperty(value = "检验类型")
@ExcelProperty(value = "检验类型")
@ExcelProperty(value = "检验/检测类型")
private String inspectType;
@ApiModelProperty(value = "检验结论")
@ExcelProperty(value = "检验结论")
@ExcelProperty(value = "检验/检测结论")
private String inspectConclusion;
@ApiModelProperty(value = "检验日期")
......@@ -292,22 +293,27 @@ public class XiAnElevatorExcelDto extends BaseDto {
//--------------------------------------------------------------------电梯索道----技术参数
@ApiModelProperty(value = "额定速度(m/s)")
@ExcelProperty(value = "额定速度(m/s)")
@NumberFormat("#.##")
private BigDecimal ratedSpeed;
@ApiModelProperty(value = "额定速度(上行)(m/s)")
@ExcelProperty(value = "额定速度(上行)(m/s)")
@NumberFormat("#.##")
private BigDecimal ratedSpeedUp;
@ApiModelProperty(value = "额定速度(下行)(m/s)")
@ExcelProperty(value = "额定速度(下行)(m/s)")
@NumberFormat("#.##")
private BigDecimal ratedSpeedDown;
@ApiModelProperty(value = "提升高度(m)")
@ExcelProperty(value = "提升高度(m)")
@NumberFormat("#.##")
private BigDecimal liftingHeight;
@ApiModelProperty(value = "额定载重量(kg)")
@ExcelProperty(value = "额定载重量(kg)")
@NumberFormat("#.##")
private BigDecimal ratedLoadCapacity;
@ApiModelProperty(value = "层数(层)")
......@@ -328,18 +334,22 @@ public class XiAnElevatorExcelDto extends BaseDto {
@ApiModelProperty(value = "名义速度(m/s)")
@ExcelProperty(value = "名义速度(m/s)")
@NumberFormat("#.##")
private BigDecimal nominalSpeed;
@ApiModelProperty(value = "倾斜角")
@ExcelProperty(value = "倾斜角")
@NumberFormat("#.##")
private BigDecimal angleRoll;
@ApiModelProperty(value = "名义宽度(mm)")
@ExcelProperty(value = "名义宽度(mm)")
@NumberFormat("#.##")
private BigDecimal nominalWidth;
@ApiModelProperty(value = "使用区段长度(m)")
@ExcelProperty(value = "使用区段长度(m)")
@NumberFormat("#.##")
private BigDecimal useSectionLength;
@ApiModelProperty(value = "输送能力(P/h)")
......
......@@ -618,13 +618,13 @@ public class XiAnDataDockServiceImpl {
excelReader.finish();
if (CollectionUtils.isEmpty(dataList)) {
resultError.put("allSheet", "你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
}
if (!ValidationUtil.isEmpty(resultError)) {
throw new BadRequest(JSON.toJSONString(resultError));
}
return dataList;
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest(e.getCause().getMessage());
}
}
......@@ -777,7 +777,7 @@ public class XiAnDataDockServiceImpl {
*/
public Map<String, String> batchSaveElevatorData(List<XiAnElevatorExcelDto> elevatorExcelDtos) {
log.info("解析成功,准备上传数据,条数:{}", elevatorExcelDtos.size());
int batchSize = 5000;
int batchSize = 1000;
int totalSize = elevatorExcelDtos.size();
Map<String, String> rMap = new HashMap<>();
// 主线程中获取登录信息传递到异步线程中
......@@ -802,8 +802,12 @@ public class XiAnDataDockServiceImpl {
.filter(item -> item instanceof String)
.forEach(item -> importResult.add((String) item));
}
if (resultMap.containsKey("status") && resultMap.get("status") != "200") {
throw new RuntimeException(resultMap.get("message").toString());
}
} catch (Exception e) {
log.error("西安数据上传,保存数据失败: ", e);
throw new RuntimeException(e.getMessage());
} finally {
semaphore.release(); // 释放许可
}
......
......@@ -158,7 +158,7 @@ public class CommonCustomConverter {
}
LinkedHashMap<String, Object> company = findAllCompaniesByPartialPath(name);
if (company == null) {
return "";
return "610100";
}
return company.get("companyCode").toString();
}
......
......@@ -21,7 +21,8 @@ public class InspectTypeConverter implements Converter<String> {
dictMap.put("改造监督检验", "GZJDJY");
dictMap.put("维修监督检验", "WXJDJY");
dictMap.put("制造监督检验", "ZZJDJY");
dictMap.put("电梯检测", "DTJC");
dictMap.put("委托检验", "WTJY");
}
@Override
......
......@@ -2706,7 +2706,7 @@ public class DataDockServiceImpl {
excelImportErrorLogDao.save(errorLogDto);
log.error("{}数据:保存时出现异常,对应数据:{}", dataSource, toJSONString(equ), e);
log.error("==========================西安电梯数据:保存时出现异常,对应数据:{}==========================",record);
throw new RuntimeException("保存电梯数据失败", e);
throw new RuntimeException("保存电梯数据失败:" + e.getMessage());
}
}
......@@ -3267,8 +3267,10 @@ public class DataDockServiceImpl {
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setSequenceNbr(String.valueOf(sequence.nextId()));
//inspectionDetectionInfo.setInspectType(InspectTypeConverter.dictMap.get(inspectionDetectionInfo.getInspectType()));
//inspectionDetectionInfo.setInspectConclusion(InspectConclusionConverter.dictMap.get(inspectionDetectionInfo.getInspectConclusion()));
if (!ValidationUtil.isEmpty(equ.get("xaSerial"))) {
inspectionDetectionInfo.setInspectType(InspectTypeConverter.dictMap.get(inspectionDetectionInfo.getInspectType()));
inspectionDetectionInfo.setInspectConclusion(InspectConclusionConverter.dictMap.get(inspectionDetectionInfo.getInspectConclusion()));
}
inspectionDetectionInfoMapper.insert(inspectionDetectionInfo);
equ.put("inspectType",inspectionDetectionInfo.getInspectType());
equ.put("inspectConclusion",inspectionDetectionInfo.getInspectConclusion());
......
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