From 2e3a8c17bda306004bf19d54f1c109aab3d62e31 Mon Sep 17 00:00:00 2001 From: yangjiyu Date: Tue, 12 Jul 2022 18:20:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=97=B6=E9=97=B4=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=80=9A=E8=BF=87=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=89=93=E8=81=8C=E4=BD=8D=E5=8F=98=E6=9B=B4=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 时间正则匹配通过 获取打职位变更时间 --- .../service/impl/FileIdentifyServiceImpl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java b/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java index a3b5d37..37272af 100644 --- a/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java +++ b/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java @@ -66,13 +66,11 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { Assert.notNull(file, "上传数据为空"); try { String pdfContent = PdfUtils.getPdfContent(file); - - String pattern = "[〇一二三四五六七八九十]{4}年[〇一二三四五六七八九十]{1,3}月[〇一二三四五六七八九十]{1,3}日"; - Pattern r = Pattern.compile(pattern); - Matcher m = r.matcher(pdfContent); - boolean aa = m.matches(); - - + String pattern = "....年[\\u4E00-\\u9FA5]+月[\\u4E00-\\u9FA5]+日"; + Matcher m = Pattern.compile(pattern).matcher(pdfContent); + if (m.find()) { + String changTime = m.group(0); + } String title = pdfContent.replaceAll("任命通知.*", "") + "任命通知"; String mainBody = pdfContent.replaceAll(".*现公布如下:", "").replaceAll("特此通知.*", ""); List tempList = Arrays.stream(mainBody.split("。")).collect(Collectors.toList()); @@ -109,7 +107,7 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { private void updateEmployee(List pdfFileDTOList) { pdfFileDTOList.forEach(pdfFileDTO -> { Employee employee = - this.employeeMapper.selectOne(new QueryWrapper().lambda().eq(Employee::getName, pdfFileDTO.getName())); + this.employeeMapper.selectOne(new QueryWrapper().lambda().eq(Employee::getName, pdfFileDTO.getName())); Assert.notNull(employee, "这个员工不存在"); Post post = this.postMapper.selectOne(new QueryWrapper().lambda().eq(Post::getEmployeeKey, employee.getEmployeeKey())); Assert.notNull(post, "职务信息不存在"); @@ -144,7 +142,7 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { */ private void saveEmployeeApproval(List dataList) { List employeeKeyList = - employeeMapper.selectList(new QueryWrapper<>()).stream().map(Employee::getEmployeeKey).collect(Collectors.toList()); + employeeMapper.selectList(new QueryWrapper<>()).stream().map(Employee::getEmployeeKey).collect(Collectors.toList()); for (EmployeeApprovalDTO employeeApprovalDTO : dataList) { String employKey = CodeUtils.getEmployeeKey(employeeApprovalDTO.getName(), employeeApprovalDTO.getBirth().toString()); if (employeeKeyList.contains(employKey)) {