|
|
@@ -271,6 +271,7 @@ public class BaiduOcrUtil { |
|
|
|
String birthday = LocalDate.parse(birthdayStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy.MM.dd")); |
|
|
|
res.setBirthday(birthday); |
|
|
|
}catch (Exception e){ |
|
|
|
res.setBirthday(null); |
|
|
|
logger.info("解析身份证生日异常", e); |
|
|
|
} |
|
|
|
} |
|
|
@@ -317,6 +318,7 @@ public class BaiduOcrUtil { |
|
|
|
String register = LocalDate.parse(registerStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|
|
|
res.setRegister(register); |
|
|
|
}catch (Exception e){ |
|
|
|
res.setRegister(null); |
|
|
|
logger.info("解析注册日期异常,", e); |
|
|
|
} |
|
|
|
} |
|
|
@@ -327,9 +329,9 @@ public class BaiduOcrUtil { |
|
|
|
String issue = LocalDate.parse(issueStr, DateTimeFormatter.ofPattern("yyyyMMdd")).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
|
|
|
res.setIssue(issue); |
|
|
|
}catch (Exception e){ |
|
|
|
res.setIssue(null); |
|
|
|
logger.info("解析发证日期异常,", e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
res.setIssueUnit(getValue(wordsResultObj, "发证机关")); |
|
|
@@ -340,13 +342,13 @@ public class BaiduOcrUtil { |
|
|
|
res.setAlc(getValue(wordsResultObj, "核定载质量")); |
|
|
|
|
|
|
|
String outsideDimensions = getValue(wordsResultObj, "外廓尺寸"); |
|
|
|
if (StringUtils.hasText(outsideDimensions) && outsideDimensions.contains("^")) { |
|
|
|
outsideDimensions.replace("^", ""); |
|
|
|
outsideDimensions = outsideDimensions.toLowerCase(); |
|
|
|
if (StringUtils.hasText(outsideDimensions)) { |
|
|
|
outsideDimensions = outsideDimensions.replaceAll("[\\^\\s]", "").toLowerCase(); |
|
|
|
res.setOverall(outsideDimensions); |
|
|
|
}else { |
|
|
|
res.setOverall(null); |
|
|
|
} |
|
|
|
|
|
|
|
res.setOverall(getValue(wordsResultObj, "外廓尺寸")); |
|
|
|
res.setTowing(getValue(wordsResultObj, "准牵引总质量")); |
|
|
|
res.setNote(getValue(wordsResultObj, "备注")); |
|
|
|
res.setInspection(getValue(wordsResultObj, "检验记录")); |
|
|
@@ -516,7 +518,7 @@ public class BaiduOcrUtil { |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException { |
|
|
|
String imagePath = "C:\\Users\\32258\\Desktop\\gy\\ocr测试图片\\cs.png"; // 图片文件的路径 |
|
|
|
String imagePath = "C:\\Users\\32258\\Desktop\\gy\\ocr测试图片\\cs2.jpg"; // 图片文件的路径 |
|
|
|
try { |
|
|
|
// 读取图片文件 |
|
|
|
File file = new File(imagePath); |