Commit faf17561 authored by 韩桐桐's avatar 韩桐桐

fix(jg):西安数据对接接口,bug修改

parent 94083a7a
package com.yeejoin.amos.api.openapi.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class DictParamsConverter implements Converter<String> {
private static final Map<String, String> dictMap = new HashMap<>();
static {
// 填充映射关系
dictMap.put("油", "5961");
dictMap.put("电", "5962");
dictMap.put("煤", "5963");
dictMap.put("水煤浆", "5964");
dictMap.put("生物质", "5965");
dictMap.put("余热", "5966");
dictMap.put("其他", "5967");
dictMap.put("射线", "5969");
dictMap.put("超声", "5970");
dictMap.put("磁粉", "5971");
dictMap.put("渗透", "5972");
dictMap.put("固定式", "5990");
dictMap.put("半挂式", "5991");
dictMap.put("公用管道", "5992");
dictMap.put("工业管道", "5993");
dictMap.put("锅筒(锅壳)", "6005");
dictMap.put("过热器出口集箱", "6006");
dictMap.put("启动分离器", "6007");
dictMap.put("长输管道", "5994");
dictMap.put("磁粉", "5988");
dictMap.put("射线", "5986");
dictMap.put("超声", "5987");
dictMap.put("渗透", "5989");
dictMap.put("A1", "6094");
dictMap.put("A2", "6095");
dictMap.put("A7", "6100");
dictMap.put("A8", "6101");
dictMap.put("A3", "6096");
dictMap.put("A4", "6097");
dictMap.put("A5", "6098");
dictMap.put("A6", "6099");
dictMap.put("牵引索", "6167");
dictMap.put("平衡索", "6168");
dictMap.put("Ⅰ类", "1");
dictMap.put("Ⅱ类", "2");
dictMap.put("Ⅲ类", "3");
dictMap.put("ⅢA类", "4");
dictMap.put("ⅢB类", "5");
dictMap.put("ⅢC类", "6");
dictMap.put("M1", "6531");
dictMap.put("M2", "6532");
dictMap.put("M3", "6533");
dictMap.put("M4", "6534");
dictMap.put("M5", "6535");
dictMap.put("M6", "6536");
dictMap.put("M7", "6537");
dictMap.put("M8", "6538");
dictMap.put("M9", "6539");
dictMap.put("M10", "6540");
dictMap.put("A级", "5957");
dictMap.put("B级", "5958");
dictMap.put("C级", "5959");
dictMap.put("D级", "5960");
dictMap.put("GC1", "6002");
dictMap.put("GC2", "6003");
dictMap.put("GC3", "6004");
}
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
return dictMap.getOrDefault(cellValue, null);
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return new CellData("");
}
public static void main(String[] args) {
}
}
\ No newline at end of file
package com.yeejoin.amos.api.openapi.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class InformationSituationConverter implements Converter<String> {
private static final String TYPE_QR_CODE = "二维码";
private static final String TYPE_STAMP = "电子标签";
private static final String TYPE_NO = "无";
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (TYPE_QR_CODE.equals(cellValue)) {
return "1";
} else if (TYPE_STAMP.equals(cellValue)) {
return "2";
}
return "99";
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("1")) {
return new CellData(TYPE_QR_CODE);
} else if (o.equals("2")) {
return new CellData(TYPE_STAMP);
}
return new CellData(TYPE_NO);
}
}
\ No newline at end of file
package com.yeejoin.amos.api.openapi.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class VehicleCylinderConverter implements Converter<String> {
private static final String WHETHER = "是";
private static final String NOT = "否";
@Override
public Class<?> supportJavaTypeKey() {
// 实体类中对象属性类型
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
// Excel中对应的CellData属性类型
return CellDataTypeEnum.STRING;
}
@Override
public String convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty,
GlobalConfiguration globalConfiguration) {
// 从Cell中读取数据
String cellValue = cellData.getStringValue();
// 判断Excel中的值,将其转换为预期的数值
if (WHETHER.equals(cellValue)) {
return "1";
} else if (NOT.equals(cellValue)) {
return "0";
}
return null;
}
@Override
public CellData convertToExcelData(String o, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
// 判断实体类中获取的值,转换为Excel预期的值,并封装为CellData对象
if (o == null) {
return new CellData("");
} else if (o.equals("1")) {
return new CellData(WHETHER);
} else if (o.equals("0")) {
return new CellData(NOT);
}
return new CellData("");
}
}
\ No newline at end of file
......@@ -24,17 +24,17 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
//----------------------------------------------------------------------基本信息
@ApiModelProperty(value = "设备种类")
@ExcelProperty(value = "设备种类",converter = EquListConverter.class)
@ExcelProperty(value = "设备种类", converter = EquListConverter.class)
@NotBlank(message = "设备种类不能为空")
private String equList;
@ApiModelProperty(value = "设备类别")
@ExcelProperty(value = "设备类别",converter = EquCategoryConverter.class)
@ExcelProperty(value = "设备类别", converter = EquCategoryConverter.class)
@NotBlank(message = "设备类别不能为空")
private String equCategory;
@ApiModelProperty(value = "设备品种")
@ExcelProperty(value = "设备品种",converter = EquDefineConverter.class)
@ExcelProperty(value = "设备品种", converter = EquDefineConverter.class)
private String equDefine;
@ApiModelProperty(value = "单位内编号")
......@@ -64,7 +64,32 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "设备代码")
@ExcelProperty(value = "设备代码")
private String equCode;//判断是否必填和位数
private String equCode;
@ApiModelProperty(value = "工程(装置)名称")
@ExcelProperty(value = "工程(装置)名称")
private String projectContraption;
@ApiModelProperty(value = "是否球罐")
@ExcelProperty(value = "是否球罐", converter = VehicleCylinderConverter.class)
private String whetherSphericalTank;
@ApiModelProperty(value = "是否撬装式压力容器")
@ExcelProperty(value = "是否撬装式压力容器")
private String whetherSkidMountedPressureVessel;
@ApiModelProperty(value = "是否车用气瓶")
@ExcelProperty(value = "是否车用气瓶", converter = VehicleCylinderConverter.class)
@NotBlank(message = "是否车用气瓶不能为空")
private String whetherVehicleCylinder;
@ApiModelProperty(value = "信息化管理情况")
@ExcelProperty(value = "信息化管理情况", converter = InformationSituationConverter.class)
private String informationSituation;
@ApiModelProperty(value = "二维码或者电子标签编号")
@ExcelProperty(value = "二维码或者电子标签编号")
private String informationManageCode;
//-----------------------------------------------------------------------使用信息
......@@ -175,7 +200,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "起升高度(m)")
private String liftingHeight;
@ExcelProperty(value = "工作级别")
@ExcelProperty(value = "工作级别", converter = DictParamsConverter.class)
@ApiModelProperty(value = "工作级别")
private String workLevel;
......@@ -183,7 +208,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "燃爆物质")
private String explosiveSubstance;
@ExcelProperty(value = "区域防爆等级")
@ExcelProperty(value = "区域防爆等级", converter = DictParamsConverter.class)
@ApiModelProperty(value = "区域防爆等级")
private String explosionProofGrade;
......@@ -340,7 +365,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "防爆温度组别")
private String temperatureGroup;
@ExcelProperty(value = "防爆设备保护级别")
@ExcelProperty(value = "防爆设备保护级别", converter = DictParamsConverter.class)
@ApiModelProperty(value = "防爆设备保护级别")
private String protectGrade;
......@@ -382,7 +407,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
//--------------------------------------------------------------锅炉----技术参数
@ExcelProperty(value = "设备级别")
@ExcelProperty(value = "设备级别", converter = DictParamsConverter.class)
@ApiModelProperty(value = "设备级别")
private String deviceLevel;
......@@ -438,11 +463,11 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "燃烧方式")
private String combustionMode;
@ExcelProperty(value = "燃料(热源)种类")
@ExcelProperty(value = "燃料(热源)种类", converter = DictParamsConverter.class)
@ApiModelProperty(value = "燃料(热源)种类")
private String fuelType;
@ExcelProperty(value = "主要受压部件-名称")
@ExcelProperty(value = "主要受压部件-名称", converter = DictParamsConverter.class)
@ApiModelProperty(value = "主要受压部件-名称")
private String nameOfPressureParts;
......@@ -454,7 +479,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "主要受压部件-壁厚(mm)")
private String wallThicknessOfPressureParts;
@ExcelProperty(value = "主要受压部件-无损检测方法")
@ExcelProperty(value = "主要受压部件-无损检测方法", converter = DictParamsConverter.class)
@ApiModelProperty(value = "主要受压部件-无损检测方法")
private String nonDestructiveTestingMethodsForPressureParts;
......@@ -516,7 +541,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "壁厚")
private String wallThickness;
@ExcelProperty(value = "无损检测方法(气瓶)")
@ExcelProperty(value = "无损检测方法(气瓶)", converter = DictParamsConverter.class)
@ApiModelProperty(value = "无损检测方法(气瓶)")
private String qpLossless;
......@@ -552,7 +577,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "材料(瓶体)")
private String bottleBody;
@ExcelProperty(value = "无损检测方法(管路)")
@ExcelProperty(value = "无损检测方法(管路)", converter = DictParamsConverter.class)
@ApiModelProperty(value = "无损检测方法(管路)")
private String glLossless;
......@@ -712,11 +737,11 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "最高允许工作压力(壳程)")
private String maxPressureShell;
@ExcelProperty(value = "主体结构型式")
@ExcelProperty(value = "主体结构型式", converter = DictParamsConverter.class)
@ApiModelProperty(value = "主体结构型式")
private String mainStructureType;
@ExcelProperty(value = "无损检测方法")
@ExcelProperty(value = "无损检测方法", converter = DictParamsConverter.class)
@ApiModelProperty(value = "无损检测方法")
private String checkLossless;
......@@ -798,7 +823,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
//--------------------------------------------------------------------压力管道----技术参数
@ExcelProperty(value = "管道类别")
@ExcelProperty(value = "管道类别", converter = DictParamsConverter.class)
@ApiModelProperty(value = "管道类别")
private String pipelineClass;
......@@ -822,8 +847,8 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "介质")
private String medium_YLGD;
@ExcelProperty(value = "起/始位置 (经纬度)")
@ApiModelProperty(value = "起/始位置 (经纬度)")
@ExcelProperty(value = "起/始位置 (经纬度)(格式:经度-纬度)")
@ApiModelProperty(value = "起/始位置 (经纬度)(格式:经度-纬度)")
private String startePosition;
@ExcelProperty(value = "温度(℃)")
......@@ -834,7 +859,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "管道编号")
private String pipelineNumber;
@ExcelProperty(value = "管道级别")
@ExcelProperty(value = "管道级别", converter = DictParamsConverter.class)
@ApiModelProperty(value = "管道级别")
private String deviceLevel_YLGD;
......@@ -930,7 +955,7 @@ public class XiAnEquipInfoExcelDto extends BaseDto {
@ApiModelProperty(value = "运量(p/h)")
private String freightVolume;
@ExcelProperty(value = "运载索")
@ExcelProperty(value = "运载索", converter = DictParamsConverter.class)
@ApiModelProperty(value = "运载索")
private String carrierLine;
......
......@@ -92,4 +92,14 @@ public interface TzsJgServiceFeignClient {
*/
@RequestMapping(value = "/common/checkEquCodeUniqueness", method = RequestMethod.GET)
Boolean selectByEquCodeAndClaimStatus(@RequestParam("equCode") String equCode);
/**
* 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
*
* @param factoryNum
* @return
*/
@RequestMapping(value = "/common/checkEquCodeUniqueness", method = RequestMethod.GET)
Integer checkFactoryNumUniquenessForVehicleCylinder(@RequestParam("factoryNum") String factoryNum);
}
......@@ -12,9 +12,9 @@ import com.yeejoin.amos.api.openapi.dto.XiAnEquipInfoExcelDto;
import com.yeejoin.amos.api.openapi.feign.TzsJgServiceFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
......@@ -127,24 +127,16 @@ public class XiAnDataDockServiceImpl {
// 每读一行都会执行
@Override
public void invoke(XiAnEquipInfoExcelDto data, AnalysisContext context) {
XiAnEquipInfoExcelDto fireExperts = new XiAnEquipInfoExcelDto();
BeanUtils.copyProperties(data, fireExperts);
// 数据检查
checkExcelData(sheetName, data, context, sheetError);
useInnerCodeList.add(data.getUseInnerCode());
equCodeList.add(data.getEquCode());
dataList.add(fireExperts);
dataList.add(data);
}
// 每个sheet页读完都会执行
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (CollectionUtils.isEmpty(dataList)) {
resultError.put("allSheet", "你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
}
// 记录每一个sheet页的错误集
if (!ValidationUtil.isEmpty(sheetError)) {
resultError.put(String.format("%s sheet页", sheetName), sheetError);
......@@ -152,8 +144,14 @@ public class XiAnDataDockServiceImpl {
}
}).headRowNumber(4).sheet(sheetNo, sheetName).doRead();
}
excelReader.finish(); // 关闭 reader,释放资源
if (CollectionUtils.isEmpty(dataList)) {
resultError.put("allSheet", "你上传了一个空数据的Excel文档!");
throw new BadRequest("你上传了一个空数据的Excel文档!");
}
// 检查 resultError中的每一项,若存在内容,则有错误信息,直接抛异常
if (!ValidationUtil.isEmpty(resultError)) {
throw new BadRequest(JSON.toJSONString(resultError));
......@@ -255,6 +253,10 @@ public class XiAnDataDockServiceImpl {
* @param rowError 错误集合
*/
private void commonFieldCheck(XiAnEquipInfoExcelDto data, StringBuilder rowError) {
boolean isPressureVessel = !ObjectUtils.isEmpty(data.getEquList()) && "2000".equals(data.getEquList());// 是否压力容器
boolean isPressurePiping = !ObjectUtils.isEmpty(data.getEquList()) && "8000".equals(data.getEquList());// 是否压力管道
// 基本信息
checkNotBlank(data.getEquList(), "设备种类不能为空;", rowError);
checkNotBlank(data.getEquCategory(), "设备类别不能为空;", rowError);
......@@ -264,7 +266,7 @@ public class XiAnDataDockServiceImpl {
}
checkNotBlank(data.getProductName(), "产品名称不能为空;", rowError);
checkNotBlank(data.getEquType(), "设备型号不能为空;", rowError);
checkNotBlank(data.getEquCodeType(), "是否有设备代码不能为空;", rowError);
checkNotBlank(data.getEquCodeType(), "有无设备代码不能为空;", rowError);
if ("1".equals(data.getEquCodeType())) {
checkNotBlank(data.getEquCode(), "设备代码不能为空;", rowError);
String equCode = data.getEquCode();
......@@ -285,11 +287,48 @@ public class XiAnDataDockServiceImpl {
} else {
data.setEquCode("");
}
if (isPressurePiping) {// 校验压力管道特有的参数
checkNotBlank(data.getProjectContraption(), "工程(装置)名称不能为空;", rowError);
} else {
data.setProjectContraption("");
}
if (isPressureVessel) {// 校验压力容器特有的参数
boolean isGasCylinder = !ObjectUtils.isEmpty(data.getEquCategory()) && "2300".equals(data.getEquCategory());// 是否气瓶
boolean isFixedGasCylinder = !ObjectUtils.isEmpty(data.getEquCategory()) && "2100".equals(data.getEquCategory());//是否固定式压力容器
boolean isOxygenChamber = !ObjectUtils.isEmpty(data.getEquCategory()) && "2400".equals(data.getEquCategory());//是否氧舱
boolean isMobilePressureVessel = !ObjectUtils.isEmpty(data.getEquCategory()) && "2100".equals(data.getEquCategory());//是否移动式压力容器
boolean isSpecialGasCylinder = isGasCylinder && !ObjectUtils.isEmpty(data.getEquDefine()) && "23T0".equals(data.getEquDefine());// 是否特种气瓶
boolean isCarGasCylinder = isSpecialGasCylinder && (ObjectUtils.isEmpty(data.getWhetherVehicleCylinder()) && "1".equals(data.getWhetherVehicleCylinder()));// 是否车用气瓶
if (isGasCylinder) {
// 不是车用气瓶
if (!isCarGasCylinder) {
checkNotBlank(data.getInformationSituation(), "信息化管理情况不能为空;", rowError);
if (!ObjectUtils.isEmpty(data.getInformationSituation())) {
checkNotBlank(data.getInformationManageCode(), "二维码或者电子标签编号不能为空;", rowError);
}
}
if (isSpecialGasCylinder) {
checkNotBlank(data.getWhetherVehicleCylinder(), "是否车用气瓶不能为空;", rowError);
}
if (isFixedGasCylinder) {
checkNotBlank(data.getWhetherSphericalTank(), "是否球罐不能为空;", rowError);
data.setWhetherSkidMountedPressureVessel("0");
}
// 是车用气瓶 或者 是氧舱 或者 是固定式压力容器 或者 是移动式压力容器
if (isCarGasCylinder || isOxygenChamber || isMobilePressureVessel || isFixedGasCylinder) {
data.setInformationSituation("");
data.setInformationManageCode("");
}
}
checkFactoryNumUniqueness(isCarGasCylinder, data, rowError);
}
// 使用信息
checkNotBlank(data.getUseUnitCode(), "使用单位统一社会信用代码不能为空;", rowError);
Optional.ofNullable(data.getUseUnitCode()).ifPresent(v -> checkCreditCode(v, "使用单位统一社会信用代码格式不正确;", rowError));
checkNotBlank(data.getUseUnit(), "使用单位名称不能为空;", rowError);
// 设计信息
checkNotBlank(data.getDesignUnitCreditCode(), "设计单位统一社会信用代码不能为空;", rowError);
Optional.ofNullable(data.getDesignUnitCreditCode()).ifPresent(v -> checkCreditCode(v, "设计单位统一社会信用代码格式不正确;", rowError));
checkNotBlank(data.getDesignUnitName(), "设计单位名称不能为空;", rowError);
checkNotBlank(data.getDesignUseDate(), "设计使用年限不能为空;", rowError);
Optional.ofNullable(data.getDesignUseDate()).ifPresent(v -> checkDateFormatNumber(v, "设计使用年限不能为数字以外的其他类型;", rowError));
......@@ -298,10 +337,10 @@ public class XiAnDataDockServiceImpl {
Optional.ofNullable(data.getAppraisalDate()).ifPresent(v -> checkDateFormatCorrect(v, "设计文件鉴定日期格式不正确;", rowError));
// 制造信息
checkNotBlank(data.getProduceUnitCreditCode(), "制造单位统一社会信用代码不能为空;", rowError);
Optional.ofNullable(data.getProduceUnitCreditCode()).ifPresent(v -> checkCreditCode(v, "制造单位统一社会信用代码格式不正确;", rowError));
checkNotBlank(data.getProduceUnitName(), "制造单位名称不能为空;", rowError);
checkNotBlank(data.getProduceLicenseNum(), "制造许可编号不能为空;", rowError);
checkNotBlank(data.getFactoryNum(), "出厂编号/产品编码不能为空;", rowError);
checkFactoryNumUniqueness(data.getFactoryNum(), null, rowError);//todo
checkNotBlank(data.getProduceDate(), "制造日期不能为空;", rowError);
Optional.ofNullable(data.getProduceDate()).ifPresent(v -> checkDateFormatCorrect(v, "制造日期格式不正确;", rowError));
}
......@@ -320,6 +359,20 @@ public class XiAnDataDockServiceImpl {
}
/**
* 检查上传Excel中的统一信用代码格式
*
* @param code 待检查数据
* @param errorMessage 错误内容
* @param rowError 错误集
*/
private void checkCreditCode(String code, String errorMessage, StringBuilder rowError) {
String regex = "^[A-Z0-9]{15}(?:[A-Z0-9]{3})?$";
if (!code.matches(regex)) {
rowError.append(errorMessage);
}
}
/**
* 检查上传Excel中的数字格式是否正确
*
* @param date 待检查数据
......@@ -332,11 +385,18 @@ public class XiAnDataDockServiceImpl {
}
}
private void checkFactoryNumUniqueness(String factoryNum, String sequenceNbr, StringBuilder rowError) {
// 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
// if (commonService.checkFactoryNumUniquenessForVehicleCylinder(factoryNum, sequenceNbr) > 0) {
// rowError.append("出厂编号/产品编码系统中已存在!");
// }
/**
* 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
*
* @param data
*/
private void checkFactoryNumUniqueness(boolean isCarGasCylinder, XiAnEquipInfoExcelDto data, StringBuilder rowError) {
if (isCarGasCylinder) {
// 车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)
if (jgServiceFeignClient.checkFactoryNumUniquenessForVehicleCylinder(data.getFactoryNum()) > 0) {
rowError.append("出厂编号/产品编码系统中已存在!");
}
}
}
/**
......@@ -407,6 +467,15 @@ public class XiAnDataDockServiceImpl {
checkNotBlank(data.getTemperature_YLGD(), "温度不能为空;", rowError);
checkNotBlank(data.getPipelineNumber(), "管道编号不能为空;", rowError);
checkNotBlank(data.getDeviceLevel_YLGD(), "管道级别不能为空;", rowError);
Optional.ofNullable(data.getStartePosition()).ifPresent(v -> {
if (v.split("-").length <= 1) {
rowError.append("起/始位置 (经纬度)格式不正确");
}
});
if (!ObjectUtils.isEmpty(data.getStartePosition()) && data.getStartePosition().split("-").length == 2) {
String[] split = data.getStartePosition().split("-");
data.setStartePosition(String.format("{\"latitude\":%s,\"longitude\":%s}", split[0], split[1]));
}
}
/**
......
......@@ -633,4 +633,11 @@ public class CommonController extends BaseController {
public Boolean checkEquCodeUniqueness(@RequestParam("equCode") String equCode) {
return commonService.checkEquCodeUniqueness(equCode);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/checkFactoryNumUniquenessForVehicleCylinder")
@ApiOperation(httpMethod = "GET", value = "车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)", notes = "车用气瓶业务里面的 出厂编号/产品编码 校验唯一性(产品编号在车用气瓶范围内全局唯一)")
public Integer checkFactoryNumUniquenessForVehicleCylinder(@RequestParam("factoryNum") String factoryNum) {
return commonService.checkFactoryNumUniquenessForVehicleCylinder(factoryNum,null);
}
}
......@@ -3,14 +3,17 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -28,6 +31,8 @@ import static com.alibaba.fastjson.JSON.toJSONString;
public class XiAnDataDockServiceImpl {
@Autowired
CodeUtil codeUtil;
@Autowired
private ESEquipmentCategory esEquipmentCategory;
@Autowired
private CategoryOtherInfoMapper categoryOtherInfoMapper;
......@@ -43,20 +48,45 @@ public class XiAnDataDockServiceImpl {
private IdxBizJgSupervisionInfoServiceImpl idxBizJgSupervisionInfoService;
@Autowired
private IdxBizJgOtherInfoServiceImpl idxBizJgOtherInfoService;
// @Autowired
// private EquipTechParamLiftingMapper equipTechParamLiftingMapper;
// @Autowired
// private EquipTechParamVehicleMapper equipTechParamVehicleMapper;
// @Autowired
// private EquipTechParamBoilerMapper equipTechParamBoilerMapper;
// @Autowired
// private EquipTechParamVesselMapper equipTechParamVesselMapper;
// @Autowired
// private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
// @Autowired
// private EquipTechParamRidesMapper equipTechParamRidesMapper;
// @Autowired
// private EquipTechParamRopewayMapper equipTechParamRopewayMapper;
@Autowired
private EquipTechParamLiftingMapper equipTechParamLiftingMapper;
IIdxBizJgTechParamsVehicleService iIdxBizJgTechParamsVehicleService;
@Autowired
private EquipTechParamVehicleMapper equipTechParamVehicleMapper;
IIdxBizJgTechParamsLiftingService iIdxBizJgTechParamsLiftingService;
@Autowired
private EquipTechParamBoilerMapper equipTechParamBoilerMapper;
IIdxBizJgTechParamsBoilerService iIdxBizJgTechParamsBoilerService;
@Autowired
IIdxBizJgTechParamsVesselService iIdxBizJgTechParamsVesselService;
@Autowired
private EquipTechParamVesselMapper equipTechParamVesselMapper;
IIdxBizJgTechParamsPipelineService iIdxBizJgTechParamsPipelineService;
@Autowired
private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
IIdxBizJgTechParamsRidesService iIdxBizJgTechParamsRidesService;
@Autowired
private EquipTechParamRidesMapper equipTechParamRidesMapper;
IIdxBizJgTechParamsRopewayService iIdxBizJgTechParamsRopewayService;
@Autowired
private EquipTechParamRopewayMapper equipTechParamRopewayMapper;
private TransactionTemplate transactionTemplate;
/**
* 保存设备信息
......@@ -65,29 +95,31 @@ public class XiAnDataDockServiceImpl {
* @return 保存结果
*/
@Transactional(rollbackFor = Exception.class)
@GlobalTransactional(rollbackFor = Exception.class)
public boolean saveEquipmentData(List<Map<?, ?>> equLists) {
// 异步
CompletableFuture.allOf(equLists.stream().map(equ ->
CompletableFuture.runAsync(() -> {
String record = UUID.randomUUID().toString();
String equList = String.valueOf(equ.get("equList"));
// 保存到设备表
saveUseInfo(equ, record);
saveDesignInfo(equ, record);
saveFactoryInfo(equ, record);
saveRegisterInfo(equ, record);
saveSupervisionInfo(equ, record);
saveOtherInfo(equ, record);
// 保存技术参数
saveTechParams(equ, record, equList);
// 保存到ES
saveEquInfoToEs(record);
})
).toArray(CompletableFuture[]::new)).join();
CompletableFuture.allOf(equLists.stream().map(equ -> CompletableFuture.runAsync(() -> saveEquipmentDataInTransaction(equ))).toArray(CompletableFuture[]::new)).join();
return Boolean.TRUE;
}
private void saveEquipmentDataInTransaction(Map<?, ?> equ) {
transactionTemplate.execute(status -> {
String record = UUID.randomUUID().toString();
String equList = String.valueOf(equ.get("equList"));
// 保存到设备表
saveUseInfo(equ, record);
saveDesignInfo(equ, record);
saveFactoryInfo(equ, record);
saveRegisterInfo(equ, record);
saveSupervisionInfo(equ, record);
saveOtherInfo(equ, record);
// 保存技术参数
saveTechParams(equ, record, equList);
// 保存到ES
saveEquInfoToEs(record);
return null;
});
}
/**
* 保存使用信息表
*
......@@ -102,8 +134,8 @@ public class XiAnDataDockServiceImpl {
useInfo.setDataSource("jg_his_xx");
useInfo.setIsNotEs("1");
useInfo.setIsIntoManagement(Boolean.FALSE);
useInfo.setUseUnitCreditCode(String.valueOf(equ.get("useUnitCode")));
useInfo.setUseUnitName(String.valueOf(equ.get("useUnit")));
useInfo.setUseUnitCreditCode(String.valueOf(equ.get("useUnitCode")).trim());
useInfo.setUseUnitName(String.valueOf(equ.get("useUnit")).trim());
idxBizJgUseInfoService.save(useInfo);
}
}
......@@ -217,10 +249,11 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveLiftingParams(Map<?, ?> equ, String record) {
EquipTechParamLifting equipTechParamLifting = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamLifting.class);
IdxBizJgTechParamsLifting equipTechParamLifting = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsLifting.class);
if (!ValidationUtil.isEmpty(equipTechParamLifting)) {
equipTechParamLifting.setRecord(record);
equipTechParamLiftingMapper.insert(equipTechParamLifting);
equipTechParamLifting.setRecDate(new Date());
iIdxBizJgTechParamsLiftingService.saveOrUpdateData(equipTechParamLifting);
}
}
......@@ -231,10 +264,11 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveVehicleParams(Map<?, ?> equ, String record) {
EquipTechParamVehicle equipTechParamVehicle = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamVehicle.class);
IdxBizJgTechParamsVehicle equipTechParamVehicle = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsVehicle.class);
if (!ValidationUtil.isEmpty(equipTechParamVehicle)) {
equipTechParamVehicle.setRecord(record);
equipTechParamVehicleMapper.insert(equipTechParamVehicle);
equipTechParamVehicle.setRecDate(new Date());
iIdxBizJgTechParamsVehicleService.saveOrUpdateData(equipTechParamVehicle);
}
}
......@@ -245,10 +279,11 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveBoilerParams(Map<?, ?> equ, String record) {
EquipTechParamBoiler equipTechParamBoiler = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamBoiler.class);
IdxBizJgTechParamsBoiler equipTechParamBoiler = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsBoiler.class);
if (!ValidationUtil.isEmpty(equipTechParamBoiler)) {
equipTechParamBoiler.setRecord(record);
equipTechParamBoilerMapper.insert(equipTechParamBoiler);
equipTechParamBoiler.setRecDate(new Date());
iIdxBizJgTechParamsBoilerService.saveOrUpdateData(equipTechParamBoiler);
}
}
......@@ -259,10 +294,11 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveVesselParams(Map<?, ?> equ, String record) {
EquipTechParamVessel equipTechParamVessel = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamVessel.class);
IdxBizJgTechParamsVessel equipTechParamVessel = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsVessel.class);
if (!ValidationUtil.isEmpty(equipTechParamVessel)) {
equipTechParamVessel.setRecord(record);
equipTechParamVesselMapper.insert(equipTechParamVessel);
equipTechParamVessel.setRecDate(new Date());
iIdxBizJgTechParamsVesselService.saveOrUpdateData(equipTechParamVessel);
}
}
......@@ -273,10 +309,15 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void savePipelineParams(Map<?, ?> equ, String record) {
EquipTechParamPipeline equipTechParamPipeline = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamPipeline.class);
IdxBizJgTechParamsPipeline equipTechParamPipeline = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsPipeline.class);
if (!ValidationUtil.isEmpty(equipTechParamPipeline)) {
equipTechParamPipeline.setWallThickness(String.valueOf(equ.get("wallThickness_YLGD")));
equipTechParamPipeline.setMedium(String.valueOf(equ.get("medium_YLGD")));
equipTechParamPipeline.setTemperature(String.valueOf(equ.get("temperature_YLGD")));
equipTechParamPipeline.setDeviceLevel(String.valueOf(equ.get("deviceLevel_YLGD")));
equipTechParamPipeline.setRecord(record);
equipTechParamPipelineMapper.insert(equipTechParamPipeline);
equipTechParamPipeline.setRecDate(new Date());
iIdxBizJgTechParamsPipelineService.saveOrUpdateData(equipTechParamPipeline);
}
}
......@@ -287,10 +328,14 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveRidesParams(Map<?, ?> equ, String record) {
EquipTechParamRides equipTechParamRides = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamRides.class);
IdxBizJgTechParamsRides equipTechParamRides = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsRides.class);
if (!ValidationUtil.isEmpty(equipTechParamRides)) {
equipTechParamRides.setRecord(record);
equipTechParamRidesMapper.insert(equipTechParamRides);
equipTechParamRides.setRecDate(new Date());
equipTechParamRides.setRunningSpeed(String.valueOf(equ.get("runningSpeed_DXYLSS")));
equipTechParamRides.setSlideLength(String.valueOf(equ.get("slideLength_DXYLSS")));
equipTechParamRides.setOperatingHeight(String.valueOf(equ.get("operatingHeight_DXYLSS")));
iIdxBizJgTechParamsRidesService.saveOrUpdateData(equipTechParamRides);
}
}
......@@ -301,10 +346,11 @@ public class XiAnDataDockServiceImpl {
* @param record
*/
private void saveRopewayParams(Map<?, ?> equ, String record) {
EquipTechParamRopeway equipTechParamRopeway = JSON.parseObject(JSON.toJSONString(equ), EquipTechParamRopeway.class);
IdxBizJgTechParamsRopeway equipTechParamRopeway = JSON.parseObject(JSON.toJSONString(equ), IdxBizJgTechParamsRopeway.class);
if (!ValidationUtil.isEmpty(equipTechParamRopeway)) {
equipTechParamRopeway.setRecord(record);
equipTechParamRopewayMapper.insert(equipTechParamRopeway);
equipTechParamRopeway.setRecDate(new Date());
iIdxBizJgTechParamsRopewayService.saveOrUpdateData(equipTechParamRopeway);
}
}
......
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