Commit f6950e7a authored by hongguangwu's avatar hongguangwu

MVP1.7.17-离职待办-优化代码

parent 07ec4846
......@@ -1069,17 +1069,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
String[] insuranceArr;
String errorMessage;
for (EmployeeRegistrationLeave leave : leaveList) {
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.ONE_STRING))
&& Common.isNotNull(leave.getSocialDispatchIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getSocialExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusSocial())
&& (leave.getDoStatusSocial().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.SIX_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.NINE_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.TEN_STRING)
)
) {
if (judgeToUpdateSocial(isExit, doType, nowTime, leave) ) {
leave.setFailSocialUser(userName);
vo = new TDispatchReduceVo();
vo.setLeaveId(leave.getId());
......@@ -1098,16 +1088,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
socialOldList.add(vo);
}
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.TWO_STRING))
&& Common.isNotNull(leave.getFundDispatchIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getFundExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusFund())
&& (leave.getDoStatusFund().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.NINE_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.TEN_STRING)
)
) {
if (judgeToUpdateFund(isExit, doType, nowTime, leave) ) {
leave.setFailFundUser(userName);
vo = new TDispatchReduceVo();
vo.setLeaveId(leave.getId());
......@@ -1126,15 +1107,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
fundOldList.add(vo);
}
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.THREE_STRING))
&& Common.isNotNull(leave.getInsuranceIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getInsuranceExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusInsurance())
&& (leave.getDoStatusInsurance().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusInsurance().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusInsurance().equals(CommonConstants.NINE_STRING)
)
) {
if (judgeToUpdateInsurance(isExit, doType, nowTime, leave) ) {
insuranceArr = leave.getInsuranceIdOld().split(",");
insuranceList = new ArrayList<>();
for (String id : insuranceArr) {
......@@ -1143,15 +1116,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
leaveInsuranceMap.put(leave.getId(), insuranceList);
}
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.FOUR_STRING))
&& Common.isNotNull(leave.getContractIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getContractExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusContract())
&& (leave.getDoStatusContract().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusContract().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusContract().equals(CommonConstants.TEN_STRING)
)
) {
if (judgeToUpdateContract(isExit, doType, nowTime, leave) ) {
leave.setFailContractUser(userName);
searchVo = new BaseSearchVO();
searchVo.setSearchKey(leave.getContractIdOld());
......@@ -1165,13 +1130,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
listParamContract.add(searchVo);
}
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.FIVE_STRING))
&& Common.isNotNull(leave.getEmpProjectIdOld())
&& Common.isNotNull(leave.getDoStatusProject())
&& (leave.getDoStatusProject().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusProject().equals(CommonConstants.NINE_STRING)
)
) {
if (judgeToUpdateProject(doType, leave) ) {
leave.setFailEmpUser(userName);
searchVo = new BaseSearchVO();
searchVo.setSearchKey(leave.getEmpProjectIdOld());
......@@ -1186,13 +1145,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
listParamProject.add(searchVo);
}
if ((Common.isEmpty(doType) || doType.contains(CommonConstants.SIX_STRING))
&& Common.isNotNull(leave.getEmpIdOld())
&& Common.isNotNull(leave.getDoStatusEmp())
&& (leave.getDoStatusEmp().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusEmp().equals(CommonConstants.NINE_STRING)
)
) {
if (judgeToUpdateEmp(doType, leave) ) {
leave.setFailEmpProjectUser(userName);
searchVo = new BaseSearchVO();
searchVo.setSearchKey(leave.getEmpProjectIdOld());
......@@ -1238,6 +1191,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateSocial(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setSocialId(successMap.get(leave.getId()));
......@@ -1255,6 +1209,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
}
}
// 公积金-完成
if (!fundOldList.isEmpty()) {
TDispatchReduceListVo paramListVo = new TDispatchReduceListVo();
......@@ -1278,6 +1233,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateFund(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setFundId(successMap.get(leave.getId()));
......@@ -1295,6 +1251,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
}
}
// 商险-完成
if (!insuranceOldList.isEmpty()) {
// 查找是 2待派单3发起失败9减员退回 的再去办
......@@ -1321,6 +1278,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
List<String> errorList = new ArrayList<>();
List<String> successList = new ArrayList<>();
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateInsurance(isExit, doType, nowTime, leave) ) {
errorMsg = new StringBuilder();
leave.setInsuranceId(leave.getInsuranceIdOld());
insuranceList = leaveInsuranceMap.get(leave.getId());
......@@ -1349,6 +1307,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
}
}
// 批量处理商险明细表的状态为失败:
if (!errorList.isEmpty()) {
leaveInsuranceMapper.updateLeaveInsuranceListByIdAndStatus(CommonConstants.THREE_STRING, errorList);
......@@ -1359,10 +1318,12 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateInsurance(isExit, doType, nowTime, leave) ) {
leave.setInsuranceId(leave.getInsuranceIdOld());
// 待办理
leave.setDoStatusInsurance(CommonConstants.FOUR_STRING);
}
}
leaveInsuranceMapper.updateLeaveInsuranceListByIdAndStatus(CommonConstants.FOUR_STRING, insuranceOldList);
}
}
......@@ -1391,6 +1352,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateContract(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setContractId(successMap.get(leave.getId()));
......@@ -1408,6 +1370,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
}
}
// 项目-完成
if (!listParamProject.isEmpty()) {
BaseSearchListVO paramVoProject = new BaseSearchListVO();
......@@ -1424,6 +1387,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
errorMap.put(message.getKey(), message.getMessage());
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateProject(doType, leave) ) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
......@@ -1434,15 +1398,18 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
leave.setDoStatusProject(CommonConstants.NINE_STRING);
}
}
}
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateProject(doType, leave) ) {
leave.setEmpProjectId(leave.getEmpProjectIdOld());
leave.setDoStatusProject(CommonConstants.EIGHT_STRING);
}
}
}
}
}
// 员工-完成
if (!listParamEmp.isEmpty()) {
BaseSearchListVO paramVoEmp = new BaseSearchListVO();
......@@ -1459,6 +1426,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
errorMap.put(message.getKey(), message.getMessage());
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateEmp(doType, leave) ) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
......@@ -1469,15 +1437,18 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
leave.setDoStatusEmp(CommonConstants.NINE_STRING);
}
}
}
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
if (judgeToUpdateEmp(doType, leave) ) {
leave.setEmpId(leave.getEmpIdOld());
leave.setDoStatusEmp(CommonConstants.EIGHT_STRING);
}
}
}
}
}
// 1社保2公积金3商险4合同5项目档案6人员档案
List<EmployeeRegistrationLeaveLog> logList = new ArrayList<>();
EmployeeRegistrationLeaveLog leaveLog;
......@@ -1511,8 +1482,7 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
leaveLog.setCreateTime(LocalDateTime.now());
leaveLog.setContent(preContent);
logList.add(leaveLog);
if (!isReturn) {
if ((Common.isNotNull(leave.getDoStatusSocial()) && CommonConstants.THREE_STRING.equals(leave.getDoStatusSocial()))
if (!isReturn && (Common.isNotNull(leave.getDoStatusSocial()) && CommonConstants.THREE_STRING.equals(leave.getDoStatusSocial()))
|| (Common.isNotNull(leave.getDoStatusFund()) && CommonConstants.THREE_STRING.equals(leave.getDoStatusFund()))
|| (Common.isNotNull(leave.getDoStatusContract()) && CommonConstants.THREE_STRING.equals(leave.getDoStatusContract()))
|| (Common.isNotNull(leave.getDoStatusInsurance()) && CommonConstants.THREE_STRING.equals(leave.getDoStatusInsurance()))
......@@ -1522,7 +1492,6 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
isReturn = true;
}
}
}
leaveLogService.saveBatch(logList);
this.updateBatchById(leaveList);
if (isReturn) {
......@@ -1532,6 +1501,72 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
private boolean judgeToUpdateEmp(String doType, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.SIX_STRING))
&& Common.isNotNull(leave.getEmpIdOld())
&& Common.isNotNull(leave.getDoStatusEmp())
&& (leave.getDoStatusEmp().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusEmp().equals(CommonConstants.NINE_STRING)
);
}
private boolean judgeToUpdateProject(String doType, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.FIVE_STRING))
&& Common.isNotNull(leave.getEmpProjectIdOld())
&& Common.isNotNull(leave.getDoStatusProject())
&& (leave.getDoStatusProject().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusProject().equals(CommonConstants.NINE_STRING)
);
}
private boolean judgeToUpdateContract(String isExit, String doType, LocalDateTime nowTime, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.FOUR_STRING))
&& Common.isNotNull(leave.getContractIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getContractExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusContract())
&& (leave.getDoStatusContract().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusContract().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusContract().equals(CommonConstants.TEN_STRING)
);
}
private boolean judgeToUpdateSocial(String isExit, String doType, LocalDateTime nowTime, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.ONE_STRING))
&& Common.isNotNull(leave.getSocialDispatchIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getSocialExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusSocial())
&& (leave.getDoStatusSocial().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.SIX_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.NINE_STRING)
|| leave.getDoStatusSocial().equals(CommonConstants.TEN_STRING)
);
}
private boolean judgeToUpdateFund(String isExit, String doType, LocalDateTime nowTime, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.TWO_STRING))
&& Common.isNotNull(leave.getFundDispatchIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getFundExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusFund())
&& (leave.getDoStatusFund().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.NINE_STRING)
|| leave.getDoStatusFund().equals(CommonConstants.TEN_STRING)
);
}
// 派单时,判断是否需要办理此条商险
private boolean judgeToUpdateInsurance(String isExit, String doType, LocalDateTime nowTime, EmployeeRegistrationLeave leave) {
return (Common.isEmpty(doType) || doType.contains(CommonConstants.THREE_STRING))
&& Common.isNotNull(leave.getInsuranceIdOld()) && (CommonConstants.ZERO_STRING.equals(isExit)
|| (CommonConstants.ONE_STRING.equals(isExit) && leave.getInsuranceExpectedTime().isBefore(nowTime)))
&& Common.isNotNull(leave.getDoStatusInsurance())
&& (leave.getDoStatusInsurance().equals(CommonConstants.TWO_STRING)
|| leave.getDoStatusInsurance().equals(CommonConstants.THREE_STRING)
|| leave.getDoStatusInsurance().equals(CommonConstants.NINE_STRING)
);
}
@Override
public void reduceHandleToLeave(BaseServiceParamListVO vo) {
if (vo == null) {
......
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