Commit 8ac021ed authored by fangxinjiang's avatar fangxinjiang

代码优化

parent 0c755ff3
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/20
* @Description
* @Version 1.0
*/
@Data
public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
/**
* @Author fxj
......
......@@ -84,19 +84,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
}
// 检查添加人员是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getEducationName().equals(info.getEducationName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING, excel.getEmpName()));
}
checkRes(emp, errorMsg, excel, list);
exist = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda()
.eq(TEmpEducation::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpEducation::getEducationName,excel.getEducationName())
......@@ -185,28 +173,16 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
continue;
}
errorMsg = new HashSet<>();
EmpEducationExcelVO excel = excelVOList.get(i);
EmpEducationUpdateExcelVo excel = excelVOList.get(i);
emp = employeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
}
// 检查添加人员是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getEducationName().equals(info.getEducationName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING, excel.getEmpName()));
}
checkRes(emp, errorMsg, excel, list);
exist = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda()
.eq(TEmpEducation::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpEducation::getEducationName,excel.getEducationName())
.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING)
.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING).ne(TEmpEducation::getId,excel.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING, excel.getEducationName()));
......@@ -225,6 +201,25 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
return R.ok();
}
private void checkRes(TEmployeeInfo emp, Set<String> errorMsg, EmpEducationExcelVO excel, List<TEmpEducation> list) {
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.getEducationName().equals(info.getEducationName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING, excel.getEmpName()));
return;
}
}
private void updateEducationOfEmp(TEmpEducation education) {
if (CommonConstants.ZERO_STRING.equals(education.getHighIdentification())){
EmpEducationUpdateVo updateVo = new EmpEducationUpdateVo();
......
......@@ -83,19 +83,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
}
// 检查添加人员是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getFamilyName().equals(info.getFamilyName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getFamilyName()));
}
checkRes(list, emp, errorMsg, excel);
exist = baseMapper.selectOne(Wrappers.<TEmpFamily>query().lambda()
.eq(TEmpFamily::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpFamily::getFamilyName,excel.getFamilyName())
......@@ -118,6 +106,25 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
return R.ok();
}
private void checkRes(List<TEmpFamily> list, TEmployeeInfo emp, Set<String> errorMsg, EmpFamilyExcelVO 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.getFamilyName().equals(info.getFamilyName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getFamilyName()));
return;
}
}
@Override
public String checkRepeat(String empIdcard, String familyName, String updateId) {
LambdaQueryWrapper<TEmpFamily> wrapper = Wrappers.lambdaQuery();
......
......@@ -75,21 +75,7 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
}
// 检查添加人员是否已经存在
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()));
}
checkRes(list, emp, errorMsg, excel);
exist = baseMapper.selectOne(Wrappers.<TEmpWorkRecording>query().lambda()
.eq(TEmpWorkRecording::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpWorkRecording::getWorkUnit,excel.getWorkUnit())
......@@ -114,6 +100,27 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
return R.ok();
}
private void checkRes(List<TEmpWorkRecording> list, TEmployeeInfo emp, Set<String> errorMsg, EmpWorkRecordExcelVO 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.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()));
return;
}
}
/**
* 插入excel work record
*/
......
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