Commit 2fb6df10 authored by fangxinjiang's avatar fangxinjiang

VO调整

parent 75b0d3f2
......@@ -31,7 +31,7 @@ public class EmpDisabilityExcelVO implements Serializable {
*/
@NotNull(message = "员工身份证不能为空")
@ExcelProperty(value ="员工身份证")
private String empCode;
private String empIdcard;
/**
* 员工姓名
*/
......
......@@ -7,9 +7,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
......
......@@ -25,8 +25,6 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpDisabilityInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
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;
......
......@@ -18,9 +18,7 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserInfo;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDataAuth;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
......@@ -37,16 +35,13 @@ import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.support.SimpleValueWrapper;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
......
......@@ -21,7 +21,6 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeProjectVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult;
......
......@@ -18,11 +18,14 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpDisabilityInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpDisabilityInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
......@@ -34,9 +37,7 @@ import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
* 员工伤残信息表
......@@ -49,6 +50,8 @@ import java.util.Set;
public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInfoMapper, TEmpDisabilityInfo> implements TEmpDisabilityInfoService {
private final TAttaInfoMapper attaInfoMapper;
private final TEmployeeInfoMapper employeeInfoMapper;
/**
* @Author fxj
* @Description 员工伤残信息导入
......@@ -59,37 +62,71 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
@Override
public R<List<ErrorMessage>> importTmpDisability(List<EmpDisabilityExcelVO> excelVOList, BindingResult bindingResult) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
List<ErrorMessage> errorList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long,ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorList)){
errorList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
// 个性化校验逻辑
List<TEmpDisabilityInfo> list = this.list();
// 执行数据插入操作 组装 PostDto
TEmployeeInfo emp;
TEmpDisabilityInfo exist;
Set<String> errorMsg;
List<ErrorMessage> temp = new ArrayList<>();
ErrorMessage errorMessage;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
continue;
}
errorMsg = new HashSet<>();
EmpDisabilityExcelVO excel = excelVOList.get(i);
Set<String> errorMsg = new HashSet<>();
// 检验岗位名称或者岗位编码是否存在
boolean match = list.stream().anyMatch(info -> excel.getDisabilityName().equals(info.getDisabilityName()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_DISABILITY_NAME_EXISTING, excel.getDisabilityName()));
emp = employeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
checkRes(list, emp, errorMsg, excel);
exist = baseMapper.selectOne(Wrappers.<TEmpDisabilityInfo>query().lambda()
.eq(TEmpDisabilityInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpDisabilityInfo::getDisabilityName,excel.getDisabilityName())
.eq(TEmpDisabilityInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_DISABILITY_NAME_EXISTING, excel.getEmpName()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel);
}
else {
insertExcelPost(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
return R.ok(temp);
}
return R.ok();
private void checkRes(List<TEmpDisabilityInfo> list, TEmployeeInfo emp, Set<String> errorMsg, EmpDisabilityExcelVO excel) {
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
return;
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
return;
}
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getDisabilityName().equals(info.getDisabilityName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_DISABILITY_NAME_EXISTING, excel.getEmpName()));
return;
}
}
@Override
public R<Boolean> saveDiy(TEmpDisabilityInfo tEmpDisabilityInfo) {
tEmpDisabilityInfo.setDeleteFlag(CommonConstants.ZERO_STRING);
......@@ -108,11 +145,14 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
}
/**
* 插入excel Post
* 插入excel
*/
private void insertExcelPost(EmpDisabilityExcelVO excel) {
private void insertExcelPost(EmpDisabilityExcelVO excel, TEmployeeInfo emp) {
TEmpDisabilityInfo insert = new TEmpDisabilityInfo();
BeanUtil.copyProperties(excel, insert);
insert.setDeleteFlag(CommonConstants.ZERO_STRING);
insert.setEmpCode(emp.getEmpCode());
insert.setEmpId(emp.getId());
this.save(insert);
}
}
......@@ -221,7 +221,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
return;
}
// 检查添加人员是否已经存在
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getEducationName().equals(info.getEducationName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
......
......@@ -72,7 +72,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
TEmpFamily exist;
Set<String> errorMsg;
List<ErrorMessage> temp = new ArrayList<>();
ErrorMessage errorMessage = null;
ErrorMessage errorMessage;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
......@@ -118,7 +118,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
return;
}
// 检查添加人员是否已经存在
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getFamilyName().equals(info.getFamilyName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
......
......@@ -105,7 +105,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
.eq(TEmpProfessionalQualification::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getEmpName()));
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING, excel.getEmpName()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
......@@ -120,7 +120,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
return R.ok(temp);
}
/**
* 插入excel family
* 插入excel
*/
private void insertExcelPost(EmpCertificateExcelVO excel,TEmployeeInfo emp) {
TEmpProfessionalQualification insert = new TEmpProfessionalQualification();
......@@ -139,14 +139,14 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
return;
}
// 检查添加人员是否已经存在
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getQualificationLevel()
.equals(info.getQualificationLevel())
&& excel.getEmpIdcard().equals(info.getEmpIdcard())
&& excel.getQualificationType().equals(info.getQualificationType()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getEmpName()));
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING, excel.getEmpName()));
return;
}
}
......
......@@ -23,8 +23,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TAttaInfoMapper;
......@@ -149,7 +147,7 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
wrapper.eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING);
wrapper.last(CommonConstants.LAST_ONE_SQL);
if (Common.isNotNull(baseMapper.selectOne(wrapper))){
return MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, recording.getEmpName());
return MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_WORK_RECORD_EXISTING, recording.getEmpName());
}
return null;
}
......@@ -163,14 +161,14 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
return;
}
// 检查添加人员是否已经存在
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getWorkDepart().equals(info.getWorkDepart())
&& excel.getWorkUnit().equals(info.getWorkUnit())
&& excel.getWorkJob().equals(info.getWorkJob())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getEmpName()));
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_WORK_RECORD_EXISTING, excel.getEmpName()));
return;
}
}
......
......@@ -22,8 +22,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.constants.ArchivesConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.*;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
......
......@@ -225,4 +225,9 @@ public interface ErrorCodes {
* 项目档案状态为已审核,禁止删除
*/
String CHECKS_PROJECT_DELETE_ERROR = "checks.project.delete.error";
/**
* 已存在对应身份证的证书信息
*/
String ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING = "archives.emp.certificate.name.existing";
}
......@@ -61,6 +61,8 @@ checks.reduce.project.error=\u5B58\u5728\u5DF2\u51CF\u9879\u7684\u9879\u76EE\uFF
checks.emp.exit.error=\u4EBA\u5458\u4E0D\u5728\u8BE5\u9879\u76EE\uFF0C\u65E0\u6CD5\u66F4\u65B0
checks.project.delete.error=\u9879\u76EE\u6863\u6848\u72B6\u6001\u4E3A\u5DF2\u5BA1\u6838\uFF0C\u7981\u6B62\u5220\u9664
archives.emp.certificate.name.existing=ARCHIVES_EMP_CERTIFICATE_NAME_EXISTING
......
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