适配重庆万州杨啡汽车修理厂、增加ProductId的校验

master
tyc 6 months ago
parent 08bc6a2e29
commit 608eb26f24
  1. 69
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/CertificateOfApprovalService.java
  2. 4
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/FieldMappingService.java
  3. 27
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/ProductQualifiedService.java
  4. 2
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/SupervisionService.java

@ -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

@ -46,14 +46,14 @@ public class FieldMappingService {
);
//产品编号
private static final List<String> SUPERVISION_AGENCY_CANDIDATES_BH_ZS = Arrays.asList(
"产品编号", "产品编码", "气瓶编号"
"产品编号:","产品编号", "产品编码", "气瓶编号"
);
//安装单位
private static final List<String> SUPERVISION_AGENCY_CANDIDATES_BH_AZDW = Arrays.asList(
"安装单位", "安装单位名称"
);
private static final List<String> VEHICLE_VIN = Arrays.asList(
"车辆识别代号"
"车辆识别代号","车架号码:"
);
/**

@ -34,6 +34,17 @@ public class ProductQualifiedService {
equipmentRegistryRespVO.setEquipmentType("特种气瓶");
equipmentRegistryRespVO.setProductName("车用气瓶");
equipmentRegistryRespVO.setCylinderQuantity(1);
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) {
equipmentRegistryRespVO.setProductId(productId);
}
}
//充装介质
boolean hasFillingMedium = texts.stream().anyMatch(t -> t.contains("液化天然气") || t.contains("LNG"));
@ -99,7 +110,23 @@ public class ProductQualifiedService {
}
return equipmentRegistryRespVO;
}
/**
* 检查productId字符串是否仅包含大小写字母"/" "-"
* @param input 待检查的字符串
* @return 如果匹配则返回原字符串否则返回 null
*/
public static String matchAllowedChars(String input) {
if (input == null || input.isEmpty()) {
return null;
}
// 正则表达式:仅允许大小写字母、数字、/ 和 -
String regex = "^[a-zA-Z0-9/-]+$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
return matcher.matches() ? input : null;
}
/**
* 匹配获取的内容和关键字在一行的情况
* @param keyword

@ -119,7 +119,7 @@ public class SupervisionService {
equipmentRegistryRespVOS.add(equipmentRegistryRespVO);
}
//车用气瓶安装合格证
boolean CertificateOfApproval = texts.stream().anyMatch(t -> t.contains("安装合格证") || t.contains("安装单位") || t.contains("安装单位名称") || t.contains("减压器编号"));
boolean CertificateOfApproval = texts.stream().anyMatch(t -> t.contains("安装合格证") || t.contains("安装单位") || t.contains("安装单位名称") || t.contains("减压器编号") || t.contains("安装检验合格证"));
if (CertificateOfApproval) {
equipmentRegistryRespVO = certificateOfApprovalService.getCertificateOfApproval(texts, postfix);
if (null == equipmentRegistryRespVO) {

Loading…
Cancel
Save