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); }