|
|
|
|
@ -55,7 +55,10 @@ public class CertificateOfApprovalService { |
|
|
|
|
productId = one+"/"+two; |
|
|
|
|
equipmentRegistryRespVO.setCylinderQuantity(2); |
|
|
|
|
} |
|
|
|
|
equipmentRegistryRespVO.setProductId(productId); |
|
|
|
|
productId = matchAllowedChars(productId); |
|
|
|
|
if (productId != null) { |
|
|
|
|
equipmentRegistryRespVO.setProductId(productId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return equipmentRegistryRespVO; |
|
|
|
|
} |
|
|
|
|
@ -73,8 +76,10 @@ public class CertificateOfApprovalService { |
|
|
|
|
} |
|
|
|
|
String productId = extractManufacturer(texts, fieldMap.get("productId"), productIdOffset); |
|
|
|
|
if (ObjectUtil.isNotEmpty(productId)) { |
|
|
|
|
//气瓶编号
|
|
|
|
|
equipmentRegistryRespVO.setProductId(productId); |
|
|
|
|
productId = matchAllowedChars(productId); |
|
|
|
|
if (productId != null) { |
|
|
|
|
equipmentRegistryRespVO.setProductId(productId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), 1); |
|
|
|
|
if (ObjectUtil.isNotEmpty(nominalWorkingPressure)) { |
|
|
|
|
@ -90,18 +95,58 @@ public class CertificateOfApprovalService { |
|
|
|
|
} |
|
|
|
|
equipmentRegistryRespVO.setVehicleVin(vehicleVin); |
|
|
|
|
} |
|
|
|
|
int contractorOffset = 1; |
|
|
|
|
if (!postfix.equals("pdf")) { |
|
|
|
|
contractorOffset = 1; |
|
|
|
|
String contractor = extractManufacturer(texts, fieldMap.get("contractor"), 0); |
|
|
|
|
if (contractor == null) { |
|
|
|
|
int contractorOffset = 1; |
|
|
|
|
if (!postfix.equals("pdf")) { |
|
|
|
|
contractorOffset = 1; |
|
|
|
|
} |
|
|
|
|
contractor = extractManufacturer(texts, fieldMap.get("contractor"), contractorOffset); |
|
|
|
|
if (ObjectUtil.isNotEmpty(contractor)) { |
|
|
|
|
//安装单位
|
|
|
|
|
equipmentRegistryRespVO.setContractor(contractor); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
contractor = matchInstallationUnit(fieldMap.get("contractor"), contractor); |
|
|
|
|
if (contractor != null) { |
|
|
|
|
equipmentRegistryRespVO.setContractor(contractor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
String contractor = extractManufacturer(texts, fieldMap.get("contractor"), contractorOffset); |
|
|
|
|
if (ObjectUtil.isNotEmpty(contractor)) { |
|
|
|
|
//安装单位
|
|
|
|
|
equipmentRegistryRespVO.setContractor(contractor); |
|
|
|
|
return equipmentRegistryRespVO; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 检查productId字符串是否仅包含大小写字母、"/" 和 "-" |
|
|
|
|
* @param input 待检查的字符串 |
|
|
|
|
* @return 如果匹配则返回原字符串,否则返回 null |
|
|
|
|
*/ |
|
|
|
|
public static String matchAllowedChars(String input) { |
|
|
|
|
if (input == null || input.isEmpty()) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return equipmentRegistryRespVO; |
|
|
|
|
// 正则表达式:仅允许大小写字母、数字、/ 和 -
|
|
|
|
|
String regex = "^[a-zA-Z0-9/-]+$"; |
|
|
|
|
Pattern pattern = Pattern.compile(regex); |
|
|
|
|
Matcher matcher = pattern.matcher(input); |
|
|
|
|
|
|
|
|
|
return matcher.matches() ? input : null; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 匹配安装单位名称,返回冒号后的单位名称(如"重庆方州杨啡汽车修理厂") |
|
|
|
|
* @param keyword 关键字,如"安装单位"或"安装单位名称" |
|
|
|
|
* @param input 待匹配的字符串 |
|
|
|
|
* @return 匹配的单位名称(如"重庆方州杨啡汽车修理厂"),否则返回null |
|
|
|
|
*/ |
|
|
|
|
public static String matchInstallationUnit(String keyword, String input) { |
|
|
|
|
// 构建正则表达式,匹配关键字 + 可选冒号 + 单位名称(公司或修理厂)
|
|
|
|
|
String regex = keyword + "[::]?\\s*([^\\s]+(?:公司|修理厂|厂))"; |
|
|
|
|
Pattern pattern = Pattern.compile(regex); |
|
|
|
|
Matcher matcher = pattern.matcher(input); |
|
|
|
|
|
|
|
|
|
if (matcher.find()) { |
|
|
|
|
return matcher.group(1); // 返回匹配的单位名称
|
|
|
|
|
} |
|
|
|
|
return null; // 未匹配到有效单位
|
|
|
|
|
} |
|
|
|
|
private static String extractVin(String text) { |
|
|
|
|
// 正则表达式直接匹配以 L 开头的 17 位字符
|
|
|
|
|
@ -125,7 +170,7 @@ public class CertificateOfApprovalService { |
|
|
|
|
|
|
|
|
|
// 使用 Stream 查找关键词位置
|
|
|
|
|
int index = IntStream.range(0, recTexts.size()) |
|
|
|
|
.filter(i -> recTexts.get(i).equals(keyword)) |
|
|
|
|
.filter(i -> recTexts.get(i).contains(keyword)) |
|
|
|
|
.findFirst() |
|
|
|
|
.orElse(-1); // 未找到返回-1
|
|
|
|
|
|
|
|
|
|
|