适配上海荣华高压容器有限公司的产品合格证

master
tyc 6 months ago
parent 986ac6df31
commit 08bc6a2e29
  1. 16
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/FieldMappingService.java
  2. 84
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/ProductQualifiedService.java
  3. 9
      yudao-server/src/main/java/cn/iocoder/yudao/server/service/SupervisionService.java

@ -42,7 +42,7 @@ public class FieldMappingService {
);
//气瓶容积
private static final List<String> SUPERVISION_AGENCY_CANDIDATES_ZS = Arrays.asList(
"实测水容积:", "公称容积", "气瓶容积", "容积", "水容积:"
"实测水容积:", "公称容积", "容积", "水容积:", "气瓶容积","积:"
);
//产品编号
private static final List<String> SUPERVISION_AGENCY_CANDIDATES_BH_ZS = Arrays.asList(
@ -63,10 +63,10 @@ public class FieldMappingService {
String redisKey = "special_equipment:field_mapping:" + companyId;
// 1. 尝试从缓存读取
Map<String, String> cachedMap = (Map<String, String>) redisTemplate.opsForValue().get(redisKey);
/*Map<String, String> cachedMap = (Map<String, String>) redisTemplate.opsForValue().get(redisKey);
if (cachedMap != null) {
return cachedMap;
}
}*/
// 2. 缓存未命中,自动识别字段名
Map<String, String> fieldMap = new HashMap<>();
@ -75,7 +75,7 @@ public class FieldMappingService {
fieldMap.put("supervisionAgencyField", detectField(texts, SUPERVISION_AGENCY_CANDIDATES));
fieldMap.put("productBatchNumber", detectField(texts, SUPERVISION_AGENCY_CANDIDATES_CPPH));
// 3. 存入缓存(有效期 30 天)
redisTemplate.opsForValue().set(redisKey, fieldMap, 365, TimeUnit.DAYS);
//redisTemplate.opsForValue().set(redisKey, fieldMap, 365, TimeUnit.DAYS);
return fieldMap;
}
@ -86,10 +86,10 @@ public class FieldMappingService {
String redisKey = "special_equipment:field_mapping:" + companyId;
// 1. 尝试从缓存读取
Map<String, String> cachedMap = (Map<String, String>) redisTemplate.opsForValue().get(redisKey);
/*Map<String, String> cachedMap = (Map<String, String>) redisTemplate.opsForValue().get(redisKey);
if (cachedMap != null) {
return cachedMap;
}
}*/
// 2. 缓存未命中,自动识别字段名
Map<String, String> fieldMap = new HashMap<>();
@ -100,7 +100,7 @@ public class FieldMappingService {
fieldMap.put("contractor", detectField(texts, SUPERVISION_AGENCY_CANDIDATES_BH_AZDW));
fieldMap.put("vehicleVin", detectField(texts, VEHICLE_VIN));
// 3. 存入缓存(有效期 30 天)
redisTemplate.opsForValue().set(redisKey, fieldMap, 365, TimeUnit.DAYS);
//redisTemplate.opsForValue().set(redisKey, fieldMap, 365, TimeUnit.DAYS);
return fieldMap;
}
@ -110,7 +110,7 @@ public class FieldMappingService {
*/
private String detectField(List<String> texts, List<String> candidates) {
return candidates.stream()
.filter(candidate -> texts.stream().anyMatch(text -> text.equals(candidate)))
.filter(candidate -> texts.stream().anyMatch(text -> text.contains(candidate)))
.findFirst()
.orElse(candidates.get(0)); // 返回候选列表的第一个值作为默认值
}

@ -47,35 +47,48 @@ public class ProductQualifiedService {
if (!postfix.equals("pdf")) {
nominalWorkingPressureOffset = 2;
}
String nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), nominalWorkingPressureOffset);
if (ObjectUtil.isNotEmpty(nominalWorkingPressure)) {
if (nominalWorkingPressure.equals("MPa")) {
nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), 2);
String nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), 0);
if (nominalWorkingPressure != null) {
nominalWorkingPressure = matchWaterVolume(fieldMap.get("nominalWorkingPressure"), nominalWorkingPressure, "MPa");
if (nominalWorkingPressure != null) {
equipmentRegistryRespVO.setNominalWorkingPressure(nominalWorkingPressure);
}
} else {
nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), nominalWorkingPressureOffset);
if (ObjectUtil.isNotEmpty(nominalWorkingPressure)) {
if (nominalWorkingPressure.equals("MPa")) {
nominalWorkingPressure = extractManufacturer(texts, fieldMap.get("nominalWorkingPressure"), 2);
}
//气瓶公称工作压力
equipmentRegistryRespVO.setNominalWorkingPressure(nominalWorkingPressure);
}
//气瓶公称工作压力
equipmentRegistryRespVO.setNominalWorkingPressure(nominalWorkingPressure);
}
int cylinderVolumeOffset = 1;
if (!postfix.equals("pdf")) {
cylinderVolumeOffset = 1;
}
String cylinderVolume = extractManufacturer(texts, fieldMap.get("cylinderVolume"), cylinderVolumeOffset);
if (isNumeric(cylinderVolume) || isNumericL(cylinderVolume)) {
equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
return equipmentRegistryRespVO;
String cylinderVolume = extractManufacturer(texts, fieldMap.get("cylinderVolume"), 0);
if (cylinderVolume != null) {
cylinderVolume = matchWaterVolume(fieldMap.get("cylinderVolume"), cylinderVolume, "L");
if (cylinderVolume != null) {
return equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
}
} else {
if (cylinderVolume != null && cylinderVolume.equals("L")) {
//处理识别到上一行的情况
cylinderVolume = extractManufacturer(texts, fieldMap.get("cylinderVolume"), -1);
if (isNumeric(cylinderVolume)) {
equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
return equipmentRegistryRespVO;
}
cylinderVolume = extractManufacturer(texts, fieldMap.get("cylinderVolume"), cylinderVolumeOffset);
if (isNumeric(cylinderVolume) || isNumericL(cylinderVolume)) {
return equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
} else {
cylinderVolume = extractManufacturer(texts, "实测水容机: ", 1);
if (isNumeric(cylinderVolume) || isNumericL(cylinderVolume)) {
equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
return equipmentRegistryRespVO;
if (cylinderVolume != null && cylinderVolume.equals("L")) {
//处理识别到上一行的情况
cylinderVolume = extractManufacturer(texts, fieldMap.get("cylinderVolume"), -1);
if (isNumeric(cylinderVolume)) {
return equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
}
} else {
cylinderVolume = extractManufacturer(texts, "实测水容机: ", 1);
if (isNumeric(cylinderVolume) || isNumericL(cylinderVolume)) {
return equipmentRegistryRespVO.setCylinderVolume(cylinderVolume);
}
}
}
}
@ -86,6 +99,35 @@ public class ProductQualifiedService {
}
return equipmentRegistryRespVO;
}
/**
* 匹配获取的内容和关键字在一行的情况
* @param keyword
* @param input
* @return
*/
public static String matchWaterVolume(String keyword, String input,String unitStr) {
// 构建正则表达式,冒号可选(全角或半角),数字部分必须存在,L可选
String regex = keyword + "[::]?\\s*(\\d+(?:\\.\\d+)?)\\s*("+unitStr+")?";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
if (matcher.find()) {
String numberStr = matcher.group(1);
String unit = matcher.group(2); // 可选的 "L"
try {
double number = Double.parseDouble(numberStr);
if (number > 0 && number < 3000) {
return numberStr + (unit != null ? unit : ""); // 返回数字 + L(如果有)
}
} catch (NumberFormatException e) {
return null;
}
}
return null;
}
public static boolean isNumeric(String str) {
if (str == null || str.isEmpty()) {
return false;

@ -129,15 +129,16 @@ public class SupervisionService {
equipmentRegistryRespVOS.add(equipmentRegistryRespVO);
}
//车用气瓶产品合格证
boolean productQualified = texts.stream().anyMatch(t -> t.equals("产品合格证") || t.contains("公称工作压力") || t.contains("水溶机") ||
t.equals("实测水溶机:") || t.equals("工作压力") || t.equals("气瓶容积")
boolean productQualified = texts.stream().anyMatch(t -> t.contains("产品合格证") || t.contains("气密性试验压力") || t.contains("气密试验压力") || t.contains("气瓶重量")
);
if (productQualified) {
//排除批量检验
boolean allProduct = texts.stream().anyMatch(t -> t.contains("批量") || t.contains("本批")
);
if (productQualified && !allProduct) {
equipmentRegistryRespVO = productQualifiedService.getCertificateOfApproval(texts, postfix);
if (null == equipmentRegistryRespVO) {
continue;
}
equipmentRegistryRespVO.setType("productQualified");
equipmentRegistryRespVOS.add(equipmentRegistryRespVO);
}

Loading…
Cancel
Save