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,19 +1191,21 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setSocialId(successMap.get(leave.getId()));
leave.setDoStatusSocial(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (judgeToUpdateSocial(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setSocialId(successMap.get(leave.getId()));
leave.setDoStatusSocial(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailSocialRemark(errorMessage);
leave.setFailSocialTime(LocalDateTime.now());
leave.setDoStatusSocial(CommonConstants.THREE_STRING);
}
leave.setFailSocialRemark(errorMessage);
leave.setFailSocialTime(LocalDateTime.now());
leave.setDoStatusSocial(CommonConstants.THREE_STRING);
}
}
}
......@@ -1278,19 +1233,21 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setFundId(successMap.get(leave.getId()));
leave.setDoStatusFund(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (judgeToUpdateFund(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setFundId(successMap.get(leave.getId()));
leave.setDoStatusFund(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailFundRemark(errorMessage);
leave.setFailFundTime(LocalDateTime.now());
leave.setDoStatusFund(CommonConstants.THREE_STRING);
}
leave.setFailFundRemark(errorMessage);
leave.setFailFundTime(LocalDateTime.now());
leave.setDoStatusFund(CommonConstants.THREE_STRING);
}
}
}
......@@ -1321,31 +1278,33 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
List<String> errorList = new ArrayList<>();
List<String> successList = new ArrayList<>();
for (EmployeeRegistrationLeave leave : leaveList) {
errorMsg = new StringBuilder();
leave.setInsuranceId(leave.getInsuranceIdOld());
insuranceList = leaveInsuranceMap.get(leave.getId());
if (insuranceList != null) {
// 处理每一条商险
for (String insuranceId : insuranceList) {
if (errorMap.get(insuranceId) != null) {
errorMsg.append(errorMap.get(insuranceId)).append(CommonConstants.SEMICOLON_STRING);
errorList.add(insuranceId);
} else {
successList.add(insuranceId);
if (judgeToUpdateInsurance(isExit, doType, nowTime, leave) ) {
errorMsg = new StringBuilder();
leave.setInsuranceId(leave.getInsuranceIdOld());
insuranceList = leaveInsuranceMap.get(leave.getId());
if (insuranceList != null) {
// 处理每一条商险
for (String insuranceId : insuranceList) {
if (errorMap.get(insuranceId) != null) {
errorMsg.append(errorMap.get(insuranceId)).append(CommonConstants.SEMICOLON_STRING);
errorList.add(insuranceId);
} else {
successList.add(insuranceId);
}
}
}
if (errorMsg.length() > CommonConstants.ZERO_INT) {
leave.setFailInsuranceUser(userName);
errorMessage = errorMsg.toString();
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (errorMsg.length() > CommonConstants.ZERO_INT) {
leave.setFailInsuranceUser(userName);
errorMessage = errorMsg.toString();
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailInsuranceRemark(errorMessage);
leave.setFailInsuranceTime(LocalDateTime.now());
leave.setDoStatusInsurance(CommonConstants.THREE_STRING);
} else {
// 待减员
leave.setDoStatusInsurance(CommonConstants.FOUR_STRING);
}
leave.setFailInsuranceRemark(errorMessage);
leave.setFailInsuranceTime(LocalDateTime.now());
leave.setDoStatusInsurance(CommonConstants.THREE_STRING);
} else {
// 待减员
leave.setDoStatusInsurance(CommonConstants.FOUR_STRING);
}
}
}
......@@ -1359,9 +1318,11 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
leave.setInsuranceId(leave.getInsuranceIdOld());
// 待办理
leave.setDoStatusInsurance(CommonConstants.FOUR_STRING);
if (judgeToUpdateInsurance(isExit, doType, nowTime, leave) ) {
leave.setInsuranceId(leave.getInsuranceIdOld());
// 待办理
leave.setDoStatusInsurance(CommonConstants.FOUR_STRING);
}
}
leaveInsuranceMapper.updateLeaveInsuranceListByIdAndStatus(CommonConstants.FOUR_STRING, insuranceOldList);
}
......@@ -1391,19 +1352,21 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
}
}
for (EmployeeRegistrationLeave leave : leaveList) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setContractId(successMap.get(leave.getId()));
leave.setDoStatusContract(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (judgeToUpdateContract(isExit, doType, nowTime, leave) ) {
// 成功
if (successMap.get(leave.getId()) != null) {
leave.setContractId(successMap.get(leave.getId()));
leave.setDoStatusContract(CommonConstants.FOUR_STRING);
} else if (errorMap.get(leave.getId()) != null) {
// 失败
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailContractRemark(errorMessage);
leave.setFailContractTime(LocalDateTime.now());
leave.setDoStatusContract(CommonConstants.THREE_STRING);
}
leave.setFailContractRemark(errorMessage);
leave.setFailContractTime(LocalDateTime.now());
leave.setDoStatusContract(CommonConstants.THREE_STRING);
}
}
}
......@@ -1424,21 +1387,25 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
errorMap.put(message.getKey(), message.getMessage());
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (judgeToUpdateProject(doType, leave) ) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailEmpProjectRemark(errorMessage);
leave.setFailEmpProjectTime(LocalDateTime.now());
leave.setDoStatusProject(CommonConstants.NINE_STRING);
}
leave.setFailEmpProjectRemark(errorMessage);
leave.setFailEmpProjectTime(LocalDateTime.now());
leave.setDoStatusProject(CommonConstants.NINE_STRING);
}
}
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
leave.setEmpProjectId(leave.getEmpProjectIdOld());
leave.setDoStatusProject(CommonConstants.EIGHT_STRING);
if (judgeToUpdateProject(doType, leave) ) {
leave.setEmpProjectId(leave.getEmpProjectIdOld());
leave.setDoStatusProject(CommonConstants.EIGHT_STRING);
}
}
}
}
......@@ -1459,21 +1426,25 @@ public class EmployeeRegistrationLeaveServiceImpl extends ServiceImpl<EmployeeRe
errorMap.put(message.getKey(), message.getMessage());
}
for (EmployeeRegistrationLeave leave : leaveList) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
if (judgeToUpdateEmp(doType, leave) ) {
if (errorMap.get(leave.getId()) != null) {
errorMessage = errorMap.get(leave.getId());
if (Common.isNotNull(errorMessage) && errorMessage.length() > 300) {
errorMessage = errorMessage.substring(0, 300);
}
leave.setFailEmpRemark(errorMessage);
leave.setFailEmpTime(LocalDateTime.now());
leave.setDoStatusEmp(CommonConstants.NINE_STRING);
}
leave.setFailEmpRemark(errorMessage);
leave.setFailEmpTime(LocalDateTime.now());
leave.setDoStatusEmp(CommonConstants.NINE_STRING);
}
}
} else {
// 全部成功
for (EmployeeRegistrationLeave leave : leaveList) {
leave.setEmpId(leave.getEmpIdOld());
leave.setDoStatusEmp(CommonConstants.EIGHT_STRING);
if (judgeToUpdateEmp(doType, leave) ) {
leave.setEmpId(leave.getEmpIdOld());
leave.setDoStatusEmp(CommonConstants.EIGHT_STRING);
}
}
}
}
......@@ -1511,16 +1482,14 @@ 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()))
|| (Common.isNotNull(leave.getDoStatusProject()) && CommonConstants.NINE_STRING.equals(leave.getDoStatusProject()))
|| (Common.isNotNull(leave.getDoStatusEmp()) && CommonConstants.NINE_STRING.equals(leave.getDoStatusEmp()))
) {
isReturn = true;
}
isReturn = true;
}
}
leaveLogService.saveBatch(logList);
......@@ -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