feat: 变更操作变更操作

变更操作变更操作变更操作
This commit is contained in:
yangjiyu
2022-07-11 17:41:24 +08:00
parent d25e541a4a
commit f3dc9eeb03
14 changed files with 246 additions and 56 deletions
@@ -3,24 +3,60 @@ package com.aos.fileidentify.common;
import lombok.Data;
import lombok.experimental.SuperBuilder;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @param <T> parameter
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Data
@SuperBuilder
public class ResultDTO<T> {
/** Success */
private boolean success;
/** Code */
private int code;
/** Data */
private T data;
/** Message */
private String message;
/**
* Result dto
*
* @since 1.0.0
*/
public ResultDTO() {
}
/**
* Result dto
*
* @param success success
* @param data data
* @since 1.0.0
*/
public ResultDTO(boolean success, T data) {
this.success = success;
this.data = data;
}
/**
* Result dto
*
* @param success success
* @param code code
* @param data data
* @param msg msg
* @since 1.0.0
*/
public ResultDTO(boolean success, int code, T data, String msg) {
this.success = success;
this.code = code;
@@ -28,17 +64,38 @@ public class ResultDTO<T> {
this.message = msg;
}
/**
* Result dto
*
* @param success success
* @param code code
* @param msg msg
* @since 1.0.0
*/
public ResultDTO(boolean success, int code, String msg) {
this.success = success;
this.code = code;
this.message = msg;
}
/**
* Result dto
*
* @param success success
* @param msg msg
* @since 1.0.0
*/
public ResultDTO(boolean success, String msg) {
this.success = success;
this.message = msg;
}
/**
* Is success
*
* @return the boolean
* @since 1.0.0
*/
public boolean isSuccess() {
return success;
}
@@ -13,6 +13,7 @@ import java.util.function.Consumer;
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
*
* @param <T> parameter
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
@@ -10,15 +10,16 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version x.x.x
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.04 09:50
* @since x.x.x
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Configuration
@EnableSwagger2
@@ -8,6 +8,16 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Configuration
@MapperScan("com.aos.fileidentify.mapper")
public class MybatisPlusConfig {
@@ -15,7 +25,8 @@ public class MybatisPlusConfig {
* IPage的分页使用的是拦截器,属于物理分页,好处就是处理大量数据时,查询速度快。
* 有兴趣的同学可以看看什么是物理分页和逻辑分页。
*
* @return
* @return mybatis plus interceptor
* @since 1.0.0
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
@@ -17,15 +17,16 @@ import lombok.AllArgsConstructor;
import javax.validation.constraints.NotBlank;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version x.x.x
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.06 12:44
* @since x.x.x
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Api(value = "员工数据服务")
@RestController
@@ -33,6 +34,7 @@ import javax.validation.constraints.NotBlank;
@AllArgsConstructor
public class EmployeeController {
/** Employee service */
private final EmployeeService employeeService;
@@ -51,6 +53,8 @@ public class EmployeeController {
/**
* Gets all employee *
*
* @param page page
* @param pageSize page size
* @return the all employee
* @since 0.0.1
*/
@@ -13,17 +13,18 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version x.x.x
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.04 09:53
* @since x.x.x
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Api(value = "PDF文件上传识别服务")
@Api(value = "文件上传识别服务")
@RestController
@RequestMapping(value = "/fileIdentify")
@AllArgsConstructor
@@ -39,6 +40,7 @@ public class FileIdentifyController {
* Identify pdf
*
* @param file file
* @return the result dto
* @since 0.0.1
*/
@ApiOperation(value = "pdf文件解析服务")
@@ -53,19 +55,29 @@ public class FileIdentifyController {
/**
* Identify excel
* Identify employee excel
*
* @param file file
* @since 0.0.1
* @return the result dto
* @since 1.0.0
*/
@ApiOperation(value = "excel文件解析服务")
@PostMapping(value = "/excel")
public ResultDTO identifyExcel(@RequestPart("excel") MultipartFile file) {
this.fileIdentifyService.processExcel(file);
@ApiOperation(value = "员工基础excel文件解析服务")
@PostMapping(value = "/excel/employee")
public ResultDTO identifyEmployeeExcel(@RequestPart("excel") MultipartFile file) {
this.fileIdentifyService.processEmployeeExcel(file);
return ResultDTO.builder()
.code(20000)
.message("操作成功")
.build();
}
@ApiOperation(value = "员工变更excel文件解析服务")
@PostMapping(value = "/excel/change")
public ResultDTO identifyChangeExcel(@RequestPart("excel") MultipartFile file) {
this.fileIdentifyService.processChangeExcel(file);
return ResultDTO.builder()
.code(20000)
.message("操作成功")
.build();
}
}
@@ -8,16 +8,16 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.io.Serializable;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: 用于EsayExel中转换实现{@link Serializable}的字段,将{@link Serializable#toString()}输出到excel中。
* </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author xianzhiping
* @version 2.3.0
* @email "mailto:xianzhiping@fkhwl.com"
* @date 2022.01.19 16:49
* @since 2.3.0
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
public class SerializableStringConverter implements Converter<Serializable> {
/**
@@ -6,6 +6,16 @@ import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Data
@TableName("t_employee_basic")
public class Employee extends BaseEntity {
@@ -5,6 +5,16 @@ import lombok.Data;
import java.util.Date;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@Data
@TableName("t_employee_post")
public class Post {
@@ -6,25 +6,34 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version x.x.x
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.06 12:47
* @since x.x.x
* @date 2022.07.11 17:30
* @since 1.0.0
*/
public interface EmployeeService {
/**
* Gets all employee *
*
* @param page page
* @param pageSize page size
* @return the all employee
* @since 0.0.1
*/
ResultDTO<IPage<Employee>> getAllEmployee(Integer page, Integer pageSize);
/**
* Gets all employee *
*
* @return the all employee
* @since 1.0.0
*/
ResultDTO<List<Employee>> getAllEmployee();
}
@@ -27,5 +27,13 @@ public interface FileIdentifyService {
* @param file file
* @since 0.0.1
*/
void processExcel(MultipartFile file);
void processEmployeeExcel(MultipartFile file);
/**
* processExcel
*
* @param file file
* @since 0.0.1
*/
void processChangeExcel(MultipartFile file);
}
@@ -4,46 +4,55 @@ import com.aos.fileidentify.common.ResultDTO;
import com.aos.fileidentify.entity.Employee;
import com.aos.fileidentify.mapper.EmployeeMapper;
import com.aos.fileidentify.service.EmployeeService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sun.net.httpserver.Authenticator;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* <p>Company: 成都返空汇网络技术有限公司</p>
* <p>Description: </p>
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version x.x.x
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.06 12:52
* @since x.x.x
* @date 2022.07.11 17:30
* @since 1.0.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class EmployeeServiceImpl implements EmployeeService {
/** Employee mapper */
private final EmployeeMapper employeeMapper;
/**
* Gets all employee *
*
* @param page page
* @param pageSize page size
* @return the all employee
* @since 1.0.0
*/
@Override
public ResultDTO<IPage<Employee>> getAllEmployee(Integer page, Integer pageSize) {
return new ResultDTO<>(true, 20000, this.employeeMapper.selectPage(new Page<>(page, pageSize), null), null);
}
/**
* Gets all employee *
*
* @return the all employee
* @since 1.0.0
*/
@Override
public ResultDTO<List<Employee>> getAllEmployee() {
QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
@@ -5,6 +5,7 @@ import com.aos.fileidentify.config.AosPageReadListener;
import com.aos.fileidentify.entity.Employee;
import com.aos.fileidentify.entity.Post;
import com.aos.fileidentify.entity.dto.EmployeeApprovalDTO;
import com.aos.fileidentify.entity.dto.EmployeeChangeDTO;
import com.aos.fileidentify.entity.dto.PdfFileDTO;
import com.aos.fileidentify.mapper.EmployeeMapper;
import com.aos.fileidentify.mapper.PostMapper;
@@ -43,8 +44,10 @@ import lombok.extern.slf4j.Slf4j;
@AllArgsConstructor
public class FileIdentifyServiceImpl implements FileIdentifyService {
/** Employee mapper */
private final EmployeeMapper employeeMapper;
/** Post mapper */
private final PostMapper postMapper;
/**
@@ -84,7 +87,6 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
}
}
/**
* Process excel
*
@@ -92,18 +94,45 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
* @since 0.0.1
*/
@Override
public void processExcel(MultipartFile file) {
public void processEmployeeExcel(MultipartFile file) {
Assert.notNull(file, "上传数据为空");
try {
EasyExcel.read(file.getInputStream(), EmployeeApprovalDTO.class, new AosPageReadListener<EmployeeApprovalDTO>(dataList -> {
this.saveEmployeeApproval(dataList);
})).doReadAll();
EasyExcel.read(file.getInputStream(), EmployeeApprovalDTO.class, new AosPageReadListener<>(this::saveEmployeeApproval)).doReadAll();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void processChangeExcel(MultipartFile file) {
Assert.notNull(file, "上传数据为空");
try {
EasyExcel.read(file.getInputStream(), EmployeeChangeDTO.class, new AosPageReadListener<>(this::updateEmployeeApproval)).doReadAll();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Update employee approval
*
* @param employeeChangeDTOList employee change dto list
* @since 1.0.0
*/
private void updateEmployeeApproval(List<EmployeeChangeDTO> employeeChangeDTOList) {
employeeChangeDTOList.forEach(employeeChangeDTO -> {
});
}
/**
* Save employee approval
*
* @param dataList data list
* @since 1.0.0
*/
private void saveEmployeeApproval(List<EmployeeApprovalDTO> dataList) {
List<String> employeeKeyList =
employeeMapper.selectList(new QueryWrapper<>()).stream().map(Employee::getEmployeeKey).collect(Collectors.toList());
@@ -120,6 +149,13 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
}
}
/**
* Save post
*
* @param employeeApprovalDTO employee approval dto
* @param employKey employ key
* @since 1.0.0
*/
private void savePost(EmployeeApprovalDTO employeeApprovalDTO, String employKey) {
Post post = new Post();
BeanUtils.copyProperties(employeeApprovalDTO, post);
@@ -127,6 +163,13 @@ public class FileIdentifyServiceImpl implements FileIdentifyService {
this.postMapper.insert(post);
}
/**
* Save employee
*
* @param employeeApprovalDTO employee approval dto
* @param employKey employ key
* @since 1.0.0
*/
private void saveEmployee(EmployeeApprovalDTO employeeApprovalDTO, String employKey) {
Employee employee = new Employee();
BeanUtils.copyProperties(employeeApprovalDTO, employee);
@@ -3,12 +3,27 @@ package com.aos.fileidentify.util;
import lombok.experimental.UtilityClass;
import org.apache.commons.codec.digest.DigestUtils;
/**
* <p>Company: 成都返空汇网络技术有限公司 </p>
* <p>Description: </p>
*
* @author yangjiyu
* @version 1.0.0
* @email "mailto:yangjiyu@fkhwl.com"
* @date 2022.07.11 17:29
* @since 1.0.0
*/
@UtilityClass
public class CodeUtils {
/**
* 用于生成员工的唯一主键
* */
*
* @param name name
* @param birth birth
* @return the employee key
* @since 1.0.0
*/
public static String getEmployeeKey(String name, String birth) {
return DigestUtils.md5Hex(name + birth);
}