Commit 8ac021ed authored by fangxinjiang's avatar fangxinjiang

代码优化

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