feat: 时间正则匹配通过 获取打职位变更时间

时间正则匹配通过 获取打职位变更时间
This commit is contained in:
yangjiyu
2022-08-08 18:15:09 +08:00
parent e0f89987ce
commit 7d354a40ad
2 changed files with 69 additions and 18 deletions
@@ -20,14 +20,38 @@ public class PdfFileDTO {
* 姓名
*/
private String name;
/**
* 现任公司
*/
private String currentCompany;
/**
* 现任部门
*/
private String currentDepartment;
/**
* 现任职位
*/
private String currentPosition;
/**
* 曾任公司
*/
private String previousCompany;
/**
* 曾任部门
*/
private String previousDepartment;
/**
* 曾任职位
*/
private String previousPosition;
/**
* 兼任公司
*/
private String partTimeCompany;
/**
* 兼任部门
*/
private String partTimeDepartment;
/**
* 兼任职位
*/
@@ -90,22 +90,48 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
pdfFileDTO.setChangeTime(changTime);
List<String> tempList2 = Arrays.stream(str.split("")).collect(Collectors.toList());
for (String str2 : tempList2) {
String company = "";
String department = "";
String post = "";
if (str2.contains("同志兼任")) {
String temp1 = str2.replaceAll(".*同志兼任", "");
String partPost = temp1.replaceAll(".*公司", "");
String pattern1 = "[\\u4e00-\\u9fa5]+?公司";
Matcher matcher1 = Pattern.compile(pattern1).matcher(temp1);
String branch = null;
if (matcher1.find()) {
branch = matcher1.group(0);
String temp2 = temp1.replaceAll(".*公司", "");
company = temp1.substring(0, temp1.length() - temp2.length());
if (temp2.contains("")) {
post = temp2.replaceAll(".*部", "");
} else if (temp2.contains("项目")) {
post = temp2.replaceAll(".*项目", "");
}
pdfFileDTO.setCurrentPosition(partPost);
department = temp2.substring(0, temp2.length() - post.length());
pdfFileDTO.setPartTimePosition(post);
pdfFileDTO.setPartTimeCompany(company);
pdfFileDTO.setPartTimeDepartment(department);
} else if (str2.contains("同志任")) {
pdfFileDTO.setCurrentPosition(str2.replaceAll(".*同志任", ""));
String temp1 = str2.replaceAll(".*同志任", "");
String temp2 = temp1.replaceAll(".*公司", "");
company = temp1.substring(0, temp1.length() - temp2.length());
if (temp2.contains("")) {
post = temp2.replaceAll(".*部", "");
} else if (temp2.contains("项目")) {
post = temp2.replaceAll(".*项目", "");
}
department = temp2.substring(0, temp2.length() - post.length());
pdfFileDTO.setCurrentPosition(post);
pdfFileDTO.setCurrentCompany(company);
pdfFileDTO.setCurrentDepartment(department);
} else if (str2.contains("不再担任")) {
pdfFileDTO.setPreviousPosition(str2.replaceAll(".*不再担任", ""));
String temp1 = str2.replaceAll(".*不再担任", "");
String temp2 = temp1.replaceAll(".*公司", "");
company = temp1.substring(0, temp1.length() - temp2.length());
if (temp2.contains("")) {
post = temp2.replaceAll(".*部", "");
} else if (temp2.contains("项目")) {
post = temp2.replaceAll(".*项目", "");
}
department = temp2.substring(0, temp2.length() - post.length());
pdfFileDTO.setPreviousPosition(post);
pdfFileDTO.setPreviousCompany(company);
pdfFileDTO.setPreviousDepartment(department);
}
}
log.info(pdfFileDTO.toString());
@@ -125,17 +151,18 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
*/
private void updateEmployee(List<PdfFileDTO> pdfFileDTOList) {
pdfFileDTOList.forEach(pdfFileDTO -> {
Employee employee = this.employeeMapper.selectOne(new QueryWrapper<Employee>().lambda().eq(Employee::getName, pdfFileDTO.getName()));
Employee employee = this.employeeMapper.selectOne(new QueryWrapper<Employee>().lambda().eq(Employee::getName,
pdfFileDTO.getName()));
Assert.notNull(employee, "这个员工不存在");
Post post = this.postMapper.selectOne(new QueryWrapper<Post>().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();
.employee_key(employee.getEmployeeKey())
.original_position(post.getCurrentPosition())
.change_position(pdfFileDTO.getPreviousPosition())
.change_time(pdfFileDTO.getChangeTime())
.build();
this.employeeChangeMapper.insert(employeeChange);
});
}
@@ -165,7 +192,7 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
*/
private void saveEmployeeApproval(List<EmployeeApprovalDTO> dataList) {
List<String> 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)) {