|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
package cn.iocoder.yudao.server.service; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.iocoder.yudao.module.special.controller.admin.equipmentregistry.vo.EquipmentRegistryRespVO; |
|
|
|
|
@ -29,52 +30,88 @@ public class CertificateOfApprovalService { |
|
|
|
|
EquipmentRegistryRespVO equipmentRegistryRespVO = new EquipmentRegistryRespVO(); |
|
|
|
|
equipmentRegistryRespVO.setEquipmentType("特种气瓶"); |
|
|
|
|
equipmentRegistryRespVO.setProductName("车用气瓶"); |
|
|
|
|
boolean productQualified = texts.stream().anyMatch(t -> t.equals("安装单位名称")); |
|
|
|
|
Map<String, String> fieldMap = new HashMap<>(); |
|
|
|
|
if (productQualified) { |
|
|
|
|
fieldMap = fieldMappingService.getCertificateMapping("安装单位名称", texts); |
|
|
|
|
} else { |
|
|
|
|
fieldMap = fieldMappingService.getCertificateMapping("安装单位", texts); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int productIdOffset = 1; |
|
|
|
|
if (!postfix.equals("pdf")) { |
|
|
|
|
productIdOffset = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean containsNumber = texts.stream().anyMatch(s -> s.contains("减压器编号")); |
|
|
|
|
boolean containsManufacturer = texts.stream().anyMatch(s -> s.contains("生产厂家")); |
|
|
|
|
boolean containsVolumeAndQuantity = texts.stream().anyMatch(s -> s.contains("容积、数量")); |
|
|
|
|
if (containsNumber && containsManufacturer && containsVolumeAndQuantity) { |
|
|
|
|
//北京福田汽车股份有限公司特殊处理
|
|
|
|
|
equipmentRegistryRespVO.setContractor("北京福田汽车股份有限公司"); |
|
|
|
|
String vehicleVin = extractManufacturer(texts, "车架号", 1); |
|
|
|
|
if (vehicleVin != null) { |
|
|
|
|
equipmentRegistryRespVO.setVehicleVin(vehicleVin); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean oneNum = texts.stream().anyMatch(s -> s.contains("气瓶1编号")); |
|
|
|
|
String productId = ""; |
|
|
|
|
if (oneNum) { |
|
|
|
|
String one = extractManufacturer(texts, "气瓶1编号", 1); |
|
|
|
|
String oneL = extractManufacturerContains(texts, "气瓶1:", 0); |
|
|
|
|
String oneL = extractManufacturerContains(texts, "气瓶1:", 1); |
|
|
|
|
|
|
|
|
|
String productId = ""; |
|
|
|
|
if (one != null) { |
|
|
|
|
String two = extractManufacturer(texts, "气瓶2编号", 1); |
|
|
|
|
if (two == null) { |
|
|
|
|
if (oneL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
oneL = oneL.substring(0, oneL.length() - 1); |
|
|
|
|
} |
|
|
|
|
// 转换为double并累加
|
|
|
|
|
|
|
|
|
|
equipmentRegistryRespVO.setCylinderVolume(oneL); |
|
|
|
|
productId = one; |
|
|
|
|
equipmentRegistryRespVO.setCylinderQuantity(1); |
|
|
|
|
} else { |
|
|
|
|
productId = one+"/"+two; |
|
|
|
|
equipmentRegistryRespVO.setCylinderQuantity(2); |
|
|
|
|
} |
|
|
|
|
productId = matchAllowedChars(productId); |
|
|
|
|
if (productId != null) { |
|
|
|
|
equipmentRegistryRespVO.setProductId(productId); |
|
|
|
|
String three = extractManufacturer(texts, "气瓶3编号", 1); |
|
|
|
|
if (three == null) { |
|
|
|
|
String twoL = extractManufacturerContains(texts, "气瓶2:", 1); |
|
|
|
|
if (twoL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
twoL = twoL.substring(0, twoL.length() - 1); |
|
|
|
|
} |
|
|
|
|
double oneNo = Double.parseDouble(oneL); |
|
|
|
|
if (oneL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
oneL = oneL.substring(0, oneL.length() - 1); |
|
|
|
|
} |
|
|
|
|
double twoNo = Double.parseDouble(twoL); |
|
|
|
|
|
|
|
|
|
double total = oneNo + twoNo; |
|
|
|
|
equipmentRegistryRespVO.setCylinderVolume(NumberUtil.toStr(total)); |
|
|
|
|
productId = one + "/" + two; |
|
|
|
|
equipmentRegistryRespVO.setCylinderQuantity(2); |
|
|
|
|
} else { |
|
|
|
|
String twoL = extractManufacturerContains(texts, "气瓶2:", 1); |
|
|
|
|
String threeL = extractManufacturerContains(texts, "气瓶3:", 1); |
|
|
|
|
if (twoL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
twoL = twoL.substring(0, twoL.length() - 1); |
|
|
|
|
} |
|
|
|
|
if (oneL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
oneL = oneL.substring(0, oneL.length() - 1); |
|
|
|
|
} |
|
|
|
|
if (threeL.endsWith("L")) { |
|
|
|
|
// 移除末尾的"L"
|
|
|
|
|
threeL = threeL.substring(0, threeL.length() - 1); |
|
|
|
|
} |
|
|
|
|
double oneNo = Double.parseDouble(oneL); |
|
|
|
|
double twoNo = Double.parseDouble(twoL); |
|
|
|
|
double threeNo = Double.parseDouble(threeL); |
|
|
|
|
double total = oneNo + twoNo + threeNo; |
|
|
|
|
equipmentRegistryRespVO.setCylinderVolume(NumberUtil.toStr(total)); |
|
|
|
|
productId = one + "/" + two + "/" + three; |
|
|
|
|
equipmentRegistryRespVO.setCylinderQuantity(3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return equipmentRegistryRespVO; |
|
|
|
|
} |
|
|
|
|
boolean productQualified = texts.stream().anyMatch(t -> t.equals("安装单位名称")); |
|
|
|
|
Map<String, String> fieldMap = new HashMap<>(); |
|
|
|
|
if (productQualified) { |
|
|
|
|
fieldMap = fieldMappingService.getCertificateMapping("安装单位名称", texts); |
|
|
|
|
} else { |
|
|
|
|
fieldMap = fieldMappingService.getCertificateMapping("安装单位", texts); |
|
|
|
|
productId = extractManufacturer(texts, fieldMap.get("productId"), productIdOffset); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int productIdOffset = 1; |
|
|
|
|
if (!postfix.equals("pdf")) { |
|
|
|
|
productIdOffset = 1; |
|
|
|
|
} |
|
|
|
|
String productId = extractManufacturer(texts, fieldMap.get("productId"), productIdOffset); |
|
|
|
|
if (ObjectUtil.isNotEmpty(productId)) { |
|
|
|
|
productId = matchAllowedChars(productId); |
|
|
|
|
if (productId != null) { |
|
|
|
|
@ -95,7 +132,16 @@ public class CertificateOfApprovalService { |
|
|
|
|
} |
|
|
|
|
equipmentRegistryRespVO.setVehicleVin(vehicleVin); |
|
|
|
|
} |
|
|
|
|
String contractor = extractManufacturer(texts, fieldMap.get("contractor"), 0); |
|
|
|
|
String contractor = null; |
|
|
|
|
boolean containsNumber = texts.stream().anyMatch(s -> s.contains("减压器编号")); |
|
|
|
|
boolean containsManufacturer = texts.stream().anyMatch(s -> s.contains("生产厂家")); |
|
|
|
|
boolean containsVolumeAndQuantity = texts.stream().anyMatch(s -> s.contains("容积、数量")); |
|
|
|
|
if (containsNumber && containsManufacturer && containsVolumeAndQuantity) { |
|
|
|
|
//北京福田汽车股份有限公司特殊处理
|
|
|
|
|
contractor = "北京福田汽车股份有限公司"; |
|
|
|
|
} else { |
|
|
|
|
contractor = extractManufacturer(texts, fieldMap.get("contractor"), 0); |
|
|
|
|
} |
|
|
|
|
if (contractor == null) { |
|
|
|
|
return null; |
|
|
|
|
} else { |
|
|
|
|
|