From 41a62736595ba2d121a3082a204237b6b043a54b Mon Sep 17 00:00:00 2001 From: yangjiyu Date: Tue, 30 Aug 2022 17:34:12 +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 时间正则匹配通过 获取打职位变更时间 --- .../com/aos/fileidentify/entity/Post.java | 6 +++ .../service/impl/FileIdentifyServiceImpl.java | 42 +++++++++++-------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/aos/fileidentify/entity/Post.java b/src/main/java/com/aos/fileidentify/entity/Post.java index 3f88bf9..a93ceb6 100644 --- a/src/main/java/com/aos/fileidentify/entity/Post.java +++ b/src/main/java/com/aos/fileidentify/entity/Post.java @@ -1,6 +1,7 @@ package com.aos.fileidentify.entity; import com.baomidou.mybatisplus.annotation.TableName; + import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -65,4 +66,9 @@ public class Post { * Post type */ private String postType; + /** + * 是否为兼任 + */ + private Boolean isPart; + } 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 fa0bd73..135d36e 100644 --- a/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java +++ b/src/main/java/com/aos/fileidentify/service/impl/FileIdentifyServiceImpl.java @@ -28,10 +28,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; +import javafx.geometry.Pos; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -54,9 +56,8 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { * Employee mapper */ private final EmployeeMapper employeeMapper; - + /** Employee change mapper */ private final EmployeeChangeMapper employeeChangeMapper; - /** * Post mapper */ @@ -154,16 +155,21 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { Employee employee = 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, "职务信息不存在"); - post.setCurrentPosition(pdfFileDTO.getCurrentPosition()); - EmployeeChange employeeChange = EmployeeChange.builder() - .employee_key(employee.getEmployeeKey()) - .original_position(post.getCurrentPosition()) - .change_position(pdfFileDTO.getPreviousPosition()) - .change_time(pdfFileDTO.getChangeTime()) - .build(); - this.employeeChangeMapper.insert(employeeChange); + List postList = this.postMapper.selectList(new QueryWrapper().lambda().eq(Post::getEmployeeKey, + employee.getEmployeeKey())); + //获取倒现任职位 + Post post = + postList.stream().filter(p -> p.getCurrentPosition().equals(pdfFileDTO.getPreviousPosition())).findAny().orElse(null); + if (Objects.nonNull(post)) { + post.setCurrentPosition(pdfFileDTO.getCurrentPosition()); + EmployeeChange employeeChange = EmployeeChange.builder() + .employee_key(employee.getEmployeeKey()) + .original_position(post.getCurrentPosition()) + .change_position(pdfFileDTO.getPreviousPosition()) + .change_time(pdfFileDTO.getChangeTime()) + .build(); + this.employeeChangeMapper.insert(employeeChange); + } }); } @@ -193,17 +199,18 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { private void saveEmployeeApproval(List dataList) { List employeeKeyList = employeeMapper.selectList(new QueryWrapper<>()).stream().map(Employee::getEmployeeKey).collect(Collectors.toList()); - for (EmployeeApprovalDTO employeeApprovalDTO : dataList) { + dataList.forEach(employeeApprovalDTO -> { String employKey = CodeUtils.getEmployeeKey(employeeApprovalDTO.getName(), employeeApprovalDTO.getBirth().toString()); + boolean flag = Objects.nonNull(employeeApprovalDTO.getIsConcurrently()) && employeeApprovalDTO.getIsConcurrently().equals("兼"); if (employeeKeyList.contains(employKey)) { - this.savePost(employeeApprovalDTO, employKey); + this.savePost(employeeApprovalDTO, employKey, flag); } else { employeeKeyList.add(employKey); this.saveEmployee(employeeApprovalDTO, employKey); - this.savePost(employeeApprovalDTO, employKey); + this.savePost(employeeApprovalDTO, employKey, flag); } log.info(employeeApprovalDTO.toString()); - } + }); } /** @@ -213,9 +220,10 @@ public class FileIdentifyServiceImpl implements FileIdentifyService { * @param employKey employ key * @since 1.0.0 */ - private void savePost(EmployeeApprovalDTO employeeApprovalDTO, String employKey) { + private void savePost(EmployeeApprovalDTO employeeApprovalDTO, String employKey, Boolean isPart) { Post post = new Post(); BeanUtils.copyProperties(employeeApprovalDTO, post); + post.setIsPart(isPart); post.setEmployeeKey(employKey); this.postMapper.insert(post); }