Commit c996743e authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/develop' into develop

parents 569ed22e f3af0bd9
......@@ -64,7 +64,7 @@ public class TEmployeeInfo extends BaseEntity {
*/
@Schema(description = "员工类型(字典值,0外包1派遣2代理)")
@NotNull( message = "员工类型不可为空")
@Max(value = 1, message = "员工类型不可超过1位")
@Size(max = 1, message = "员工类型不可超过1位")
private String empNatrue;
/**
......@@ -137,7 +137,7 @@ public class TEmployeeInfo extends BaseEntity {
* 邮箱
*/
@Schema(description = "邮箱")
@Size(max = 32, message = "邮箱不可超过32位")
@Size(max = 50, message = "邮箱不可超过50位")
private String empEmail;
/**
......
......@@ -258,7 +258,6 @@ public class TEmployeeInfoController {
}
/**
* @param idList
* @Description: 通过ids批量减档人员档案表
* @Author: hgw
* @Date: 2022/6/21 19:42
......@@ -268,7 +267,7 @@ public class TEmployeeInfoController {
@SysLog("批量减档人员档案表")
@GetMapping("/batchMinusEmployee")
@PreAuthorize("@pms.hasPermission('temployeeinfo_batch_minus')")
public R<List<ErrorMessage>> batchMinusEmployee(@RequestExcel List<EmployeeLeaveVO> excelList, BindingResult bindingResult) {
public R<List<ErrorMessageVO>> batchMinusEmployee(@RequestExcel List<EmployeeLeaveVO> excelList, BindingResult bindingResult) {
return tEmployeeInfoService.batchMinusEmployee(excelList, bindingResult);
}
......
......@@ -22,6 +22,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeLog;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeLogService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
......@@ -30,6 +32,8 @@ import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 档案变更日志表
......@@ -115,4 +119,30 @@ public class TEmployeeLogController {
return R.ok(tEmployeeLogService.removeById(id));
}
/**
* @Description: 通过EMP_ID查询人员档案变更日志
* @Author: hgw
* @Date: 2022/6/28 16:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeLog>>
**/
@Operation(summary = "通过EMP_ID查询人员档案变更日志", description = "通过EMP_ID查询人员档案变更日志")
@GetMapping("/getByEmpId")
public R<List<TEmployeeLog>> getByEmpId(@RequestParam String empId) {
return R.ok(tEmployeeLogService.list(Wrappers.<TEmployeeLog>query().eq("EMP_ID", empId)
.eq("TYPE", CommonConstants.ZERO_INT)));
}
/**
* @Description: 通过PROJECT_ID查询项目档案变更日志
* @Author: hgw
* @Date: 2022/6/28 16:45
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeLog>>
**/
@Operation(summary = "通过PROJECT_ID查询项目档案变更日志", description = "通过PROJECT_ID查询项目档案变更日志")
@GetMapping("/getByProjectId")
public R<List<TEmployeeLog>> getByProjectId(@RequestParam String projectId) {
return R.ok(tEmployeeLogService.list(Wrappers.<TEmployeeLog>query().eq("PROJECT_ID", projectId)
.eq("TYPE", CommonConstants.ONE_INT)));
}
}
......@@ -128,7 +128,7 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
* @Date: 2022/6/23 17:12
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.pig4cloud.plugin.excel.vo.ErrorMessage>>
**/
R<List<ErrorMessage>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult);
R<List<ErrorMessageVO>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult);
/**
* @param employeeInfo 档案信息
......
......@@ -40,6 +40,7 @@ import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
......@@ -84,21 +85,26 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
* @date: 2022/6/27
*/
@Override
public R<Boolean> importZip(MultipartFile zipFile) {
//C:\Users\登录用户~1\AppData\Local\Temp\
String pathName = System.getProperty("java.io.tmpdir") + "shpFileCache/";
String dec = System.getProperty("java.io.tmpdir") + "shpFileCache/";
//获取文件名(包括后缀)
String pname = zipFile.getOriginalFilename();
pathName = pathName + pname;
public R<Boolean> importZip(MultipartFile zipFile){
try {
String pathName = ResourceUtils.getURL("classpath:").getPath() + "unloap/";
String dec = ResourceUtils.getURL("classpath:").getPath() + "unloap/";
File file1 = new File(pathName);
//如果文件夹不存在 创建文件夹
if (!file1.exists()) {
file1.mkdir();
}
//获取文件名(包括后缀)
String pname = zipFile.getOriginalFilename();
pathName = pathName + pname;
File file = new File(pathName);
zipFile.transferTo(file);
// 获取解压出来的文件名 不带后缀
unZip(file, dec);
//解析完成删除本次解析中生成的文件 删除此目录下的所有文件
deleteFile(dec);
deleteFolder(dec);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -136,8 +142,6 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
elecTypeMapData = dictMap.get("data");
elecTypeMap = elecTypeMapData.get("elec_archives_type");
}
//记录解压出来的所有文件名
List<String> filesName = new ArrayList<>();
// 判断源文件是否存在
if (!srcFile.exists()) {
throw new RuntimeException(srcFile.getPath() + "所指文件不存在");
......@@ -244,40 +248,72 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
return multipartFile;
}
/**
* 删除文件
*
* @param filePath
* @return
* 根据路径删除指定的目录或文件,无论存在与否
* @param path 要删除的目录或文件路径
* @return 删除成功返回 true,否则返回 false
*/
public static boolean deleteFile(String filePath) {
boolean flag = false;
File file = new File(filePath);
public static boolean deleteFolder(String path) {
File file = new File(path);
// 判断目录或文件是否存在
if (!file.exists()) {
return flag;
return false;
} else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
return deleteFile(path);
} else { // 为目录时调用删除目录方法
return deleteDirectory(path);
}
}
}
/**
* 删除单个文件
*/
private static boolean deleteFile(String path) {
File file = new File(path);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
return true;
}
if (!file.isDirectory()) {
return flag;
return false;
}
/**
* 删除目录(文件夹)以及目录下的文件
*/
private static boolean deleteDirectory(String path) {
//如果path不以文件分隔符结尾,自动添加文件分隔符
if (!path.endsWith(File.separator)) {
path = path + File.separator;
}
String[] tempList = file.list();
File temp;
for (int i = 0; i < tempList.length; i++) {
if (filePath.endsWith(File.separator)) {
temp = new File(filePath + tempList[i]);
} else {
temp = new File(filePath + File.separator + tempList[i]);
}
if (temp.isFile()) {
temp.delete();
File dirFile = new File(path);
//如果dir对应的文件不存在,或者不是一个目录,则退出
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
//删除文件夹下的所有文件(包括子目录)
File[] files = dirFile.listFiles();
for (File file : files) {
//删除子文件
if (file.isFile()) {
flag = deleteFile(file.getAbsolutePath());
} //删除子目录
else {
flag = deleteDirectory(file.getAbsolutePath());
}
if (temp.isDirectory()) {
// 先删除文件夹里面的文件
deleteFile(filePath + "/" + tempList[i]);
// 再删除空文件夹
deleteFile(filePath + "/" + tempList[i]);
flag = true;
if (!flag) {
break;
}
}
return flag;
if (!flag) {
return false;
}
//删除当前目录
return dirFile.delete();
}
}
......@@ -108,15 +108,12 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(employeeInfo.getEmpName());
checkIdCard.setIdCard(employeeInfo.getEmpIdcard());
List<TCheckIdCard> checkList = new ArrayList<>();
checkList.add(checkIdCard);
R<List<TCheckIdCard>> checkListR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckidcard/inner/checkIdCard", checkList, TCheckIdCard.class, SecurityConstants.FROM_IN);
R<TCheckIdCard> checkListR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardSingle", checkIdCard, TCheckIdCard.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
for (TCheckIdCard check : checkListR.getData()) {
if (check.getIsTrue() == CommonConstants.ZERO_INT) {
return R.failed(check.getReason());
}
TCheckIdCard check = checkListR.getData();
if (check.getIsTrue() == CommonConstants.ZERO_INT) {
return R.failed(check.getReason());
}
}
return R.ok();
......@@ -241,30 +238,19 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 数据合法情况
if (!CollUtil.isEmpty(errorMsg)) {
isTrue = false;
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ZERO_INT);
errorMessageVO.setEmpName(employee.getEmpName());
errorMessageVO.setEmpIdCard(employee.getEmpIdcard());
errorMessageVO.setErrorSet(errorMsg);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, employee.getEmpName()
, employee.getEmpIdcard(), errorMsg);
// 数据不合法
errorMessageList.add(errorMessageVO);
} else {
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ONE_INT);
errorMessageVO.setEmpName(employee.getEmpName());
errorMessageVO.setEmpIdCard(employee.getEmpIdcard());
errorMessageList.add(errorMessageVO);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, employee.getEmpName()
, employee.getEmpIdcard(), errorMsg);
canDeleteList.add(employee);
}
errorMessageList.add(errorMessageVO);
} else {
isTrue = false;
errorMsg.add("未找到人员!");
errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i+2);
errorMessageVO.setResult(CommonConstants.ZERO_INT);
errorMessageVO.setErrorSet(errorMsg);
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, null, null, errorMsg);
errorMessageList.add(errorMessageVO);
}
}
......@@ -288,6 +274,17 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
}
private ErrorMessageVO getErrorMessageVO(int i, int result, String empName, String idCard, Set<String> errorMsg) {
ErrorMessageVO errorMessageVO = new ErrorMessageVO();
errorMessageVO.setLineNum(i + 2);
// 结果:0错误;1正确
errorMessageVO.setResult(result);
errorMessageVO.setEmpName(empName);
errorMessageVO.setEmpIdCard(idCard);
errorMessageVO.setErrorSet(errorMsg);
return errorMessageVO;
}
@Override
public R<String> restoreEmployee(String id, String projectIds) {
TEmployeeInfo employee = this.getById(id);
......@@ -324,7 +321,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public R<List<ErrorMessage>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult) {
public R<List<ErrorMessageVO>> batchMinusEmployee(List<EmployeeLeaveVO> excelVOList, BindingResult bindingResult) {
if (excelVOList == null || excelVOList.isEmpty()) {
return R.failed(CommonConstants.DATA_CAN_NOT_EMPTY);
}
......@@ -332,8 +329,9 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
List<ErrorMessage> errorMessageList = new ArrayList<>();
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
List<ErrorMessageVO> errorMessageList = new ArrayList<>();
ErrorMessageVO errorMessageVO;
Map<Integer, Integer> errorMsgMap = new HashMap<>();
TEmployeeInfo employee;
List<TEmployeeInfo> canDeleteList = new ArrayList<>();
......@@ -342,6 +340,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
List<String> idCardList = new ArrayList<>();
String idCard;
boolean isTrue = true;
for (int i = 0; i < excelVOList.size(); i++) {
errorMsg = new HashSet<>();
excel = excelVOList.get(i);
......@@ -349,18 +348,24 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
idCard = excel.getEmpIdcard();
if (Common.isEmpty(idCard)) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST, excel.getEmpIdcard()));
errorMsgMap.put((i + 2L), new ErrorMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST));
errorMsgMap.put(i + 2, CommonConstants.ZERO_INT);
} else {
idCardList.add(idCard);
}
if (Common.isEmpty(excel.getLeaveReason())) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_LEAVEREASON_MUST, excel.getEmpIdcard()));
errorMsgMap.put((i + 2L), new ErrorMessage(ErrorCodes.ARCHIVES_IMPORT_EMP_IDCARD_MUST));
errorMsgMap.put(i + 2, CommonConstants.ZERO_INT);
}
// 数据不合法
if (!CollUtil.isEmpty(errorMsg)) {
errorMessageList.add(new ErrorMessage((i + 2L), errorMsg));
isTrue = false;
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, excel.getEmpName()
, idCard, errorMsg);
} else {
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, excel.getEmpName()
, idCard, errorMsg);
}
errorMessageList.add(errorMessageVO);
}
// 查找档案库
Map<String, TEmployeeInfo> existEmpMap = new HashMap<>();
......@@ -373,7 +378,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get((i + 2L)))) {
if (Common.isNotNull(errorMsgMap.get(i + 2))) {
continue;
}
errorMsg = new HashSet<>();
......@@ -398,10 +403,16 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
// 数据不合法
if (!CollUtil.isEmpty(errorMsg)) {
errorMessageList.add(new ErrorMessage((i + 2L), errorMsg));
isTrue = false;
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ZERO_INT, excel.getEmpName()
, excel.getEmpIdcard(), errorMsg);
} else {
errorMessageVO = this.getErrorMessageVO(i, CommonConstants.ONE_INT, excel.getEmpName()
, excel.getEmpIdcard(), errorMsg);
}
errorMessageList.add(errorMessageVO);
}
if (CollUtil.isNotEmpty(errorMessageList)) {
if (!isTrue && CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
} else {
// 仅更新自己
......@@ -602,6 +613,8 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
Map<Long, ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)) {
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(), errorMessage));
} else {
errorMessageList = new ArrayList<>();
}
// 获取身份证、手机号列表,批量查询档案
......@@ -720,19 +733,14 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
TCheckIdCard checkIdCard = new TCheckIdCard();
checkIdCard.setName(excel.getEmpName());
checkIdCard.setIdCard(excel.getEmpIdcard());
List<TCheckIdCard> checkList = new ArrayList<>();
checkList.add(checkIdCard);
R<List<TCheckIdCard>> checkListR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckidcard/inner/checkIdCard", checkList, TCheckIdCard.class, SecurityConstants.FROM_IN);
R<TCheckIdCard> checkListR = HttpDaprUtil.invokeMethodPost(daprCheckProperties.getAppUrl(), daprCheckProperties.getAppId()
, "/tcheckidcard/inner/checkIdCardSingle", checkIdCard, TCheckIdCard.class, SecurityConstants.FROM_IN);
if (checkListR != null && checkListR.getData() != null) {
for (TCheckIdCard check : checkListR.getData()) {
if (check.getIsTrue() == CommonConstants.ZERO_INT) {
errorMsg.add(check.getReason());
break;
}
TCheckIdCard check = checkListR.getData();
if (check.getIsTrue() == CommonConstants.ZERO_INT) {
errorMsg.add(check.getReason());
}
}
saveEmp.setEmpName(excel.getEmpName());
saveEmp.setEmpIdcard(excel.getEmpIdcard());
......
......@@ -159,7 +159,7 @@ public class TCheckIdCardController {
@SysLog("校验姓名身份证 --- 单个")
@Inner
@PostMapping("/inner/checkIdCardSingle")
public R<TCheckIdCard> checkIdCardSingle(String idCard, String name) {
return tCheckIdCardService.checkIdCardSingle(idCard, name);
public R<TCheckIdCard> checkIdCardSingle(@RequestBody TCheckIdCard tCheckIdCard) {
return tCheckIdCardService.checkIdCardSingle(tCheckIdCard);
}
}
......@@ -45,5 +45,5 @@ public interface TCheckIdCardService extends IService<TCheckIdCard> {
**/
R<List<TCheckIdCard>> checkIdCard(List<TCheckIdCard> checkList);
R<TCheckIdCard> checkIdCardSingle(String idCard, String name);
R<TCheckIdCard> checkIdCardSingle(TCheckIdCard tCheckIdCard);
}
......@@ -226,7 +226,9 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
}
@Override
public R<TCheckIdCard> checkIdCardSingle(String idCard, String name) {
public R<TCheckIdCard> checkIdCardSingle(TCheckIdCard tCheckIdCard) {
String idCard = tCheckIdCard.getIdCard();
String name = tCheckIdCard.getName();
if (Common.isEmpty(idCard) || Common.isEmpty(name)){
return R.failed(CommonConstants.PARAM_IS_NOT_EMPTY);
}
......@@ -237,13 +239,24 @@ public class TCheckIdCardServiceImpl extends ServiceImpl<TCheckIdCardMapper, TCh
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(checkIdCard)){
return R.ok(checkIdCard);
} else {
// 没找到正确的,再去找有没有错误的,如果还没有,再查
List<TCheckIdCard> checkList = baseMapper.selectList(Wrappers.<TCheckIdCard>query().lambda()
.eq(TCheckIdCard::getIdCard,idCard));
if (checkList != null && !checkList.isEmpty()) {
for (TCheckIdCard c : checkList) {
if (idCard.equals(c.getIdCard()) && name.equals(c.getName())) {
return R.ok(c);
}
}
}
TCheckIdCard c = new TCheckIdCard();
c.setIdCard(idCard);
c.setName(name);
ChecksUtil.checkIdCard(c,canCheckService.getCanCheck());
baseMapper.insert(c);
return R.ok(c);
}
TCheckIdCard c = new TCheckIdCard();
c.setIdCard(idCard);
c.setName(name);
ChecksUtil.checkIdCard(c,canCheckService.getCanCheck());
baseMapper.insert(c);
return R.ok(c);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment