Commit 028d9827 authored by hongguangwu's avatar hongguangwu

合同申请提交拦截

parent 9ee6a40c
......@@ -33,6 +33,12 @@ public class EmployeeConstants {
public static final String DEPT_NO_EXIST = "未找到对应的项目或者项目已停止合作,请核实";
public static final String CHECK_ERROR = "校验服务错误,请联系管理员!";
public static final String CHECK_NO_RESPONSE = "校验服务器未返回,请联系管理员!";
// 拦截合同使用
public static final String SITUATION_ONE = "正常签订";
public static final String SITUATION_TWO = "正常续签";
public static final String SITUATION_THREE = "离职再入职";
public static final String SITUATION_SIX = "作废";
public static final String SITUATION_SEVEN = "终止";
public static final String EMPID_NOT_EMPTY = "员工ID、项目ID不可为空;";
......
......@@ -137,6 +137,7 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
}
private R<List<ErrorMessage>> setBaseInfo(TEmployeeContractInfo tEmployeeContractInfo, TEmployeeProject tEmployeeProject) {
// 获取人员档案
TEmployeeInfo tEmployeeInfo = tEmployeeInfoMapper.selectById(tEmployeeContractInfo.getEmpId());
// 获取项目
......@@ -162,6 +163,11 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
if (user == null || Common.isEmpty(user.getId())) {
return R.failed(CommonConstants.PLEASE_LOG_IN);
}
// 新增合同拦截:
R<List<ErrorMessage>> failed = judgeRule(tEmployeeContractInfo);
if (failed != null) return failed;
// 初始化
this.initEmployeeContract(tEmployeeContractInfo, tEmployeeInfo, tEmployeeProject, user);
......@@ -180,6 +186,60 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
return this.saveContractAndAtta(tEmployeeContractInfo,user);
}
/**
* @param tEmployeeContractInfo
* @Description: 合同新增前的拦截
* @Author: hgw
* @Date: 2022/12/23 14:54
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.List < com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage>>
**/
private R<List<ErrorMessage>> judgeRule(TEmployeeContractInfo tEmployeeContractInfo) {
if (Common.isEmpty(tEmployeeContractInfo.getSituation())) {
// "新签合同(正常签订): 同一项目针对合同存在 在用的禁止发起;
if (EmployeeConstants.SITUATION_ONE.equals(tEmployeeContractInfo.getSituation())) {
TEmployeeContractInfo contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getEmpIdcard, tEmployeeContractInfo.getEmpIdcard())
.eq(TEmployeeContractInfo::getDeptNo, tEmployeeContractInfo.getDeptNo())
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_STRING).last(CommonConstants.LAST_ONE_SQL));
if (contractInfo != null) {
return R.failed("该项目已存在在用合同,禁止新签!");
}
} else if (EmployeeConstants.SITUATION_TWO.equals(tEmployeeContractInfo.getSituation())) {
// "正常续签(正常续签): 要求后一份合同的开始时间要等于上一份合同的结束日期+1天(限制)"
TEmployeeContractInfo contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getEmpIdcard, tEmployeeContractInfo.getEmpIdcard())
.eq(TEmployeeContractInfo::getDeptNo, tEmployeeContractInfo.getDeptNo())
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_STRING).last(CommonConstants.LAST_ONE_SQL));
if (contractInfo != null && (contractInfo.getContractEnd() == null
|| !(DateUtil.formatDate(DateUtil.addDayByDate(contractInfo.getContractEnd(),1)).equals(DateUtil.formatDate(tEmployeeContractInfo.getContractStart())))
)) {
return R.failed("续签请注意上一份合同的截止日期!");
}
} else if (EmployeeConstants.SITUATION_THREE.equals(tEmployeeContractInfo.getSituation())) {
// 离职再入职: 同一项目存在可用禁止发起,存在审核通过且不可用允许发起
TEmployeeContractInfo contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getEmpIdcard, tEmployeeContractInfo.getEmpIdcard())
.eq(TEmployeeContractInfo::getDeptNo, tEmployeeContractInfo.getDeptNo())
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_STRING).last(CommonConstants.LAST_ONE_SQL));
if (contractInfo != null) {
return R.failed("该项目已存在在用合同,禁止离职再入职!");
} else {
contractInfo = this.getOne(Wrappers.<TEmployeeContractInfo>query().lambda()
.eq(TEmployeeContractInfo::getEmpIdcard, tEmployeeContractInfo.getEmpIdcard())
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.isNotNull(TEmployeeContractInfo::getAuditTimeLast).last(CommonConstants.LAST_ONE_SQL));
if (contractInfo == null) {
return R.failed("该人员不存在审核通过一次的合同,禁止离职再入职!");
}
}
}
}
return null;
}
@Override
public R<List<ErrorMessage>> updateContract(TEmployeeContractInfo tEmployeeContractInfo) {
try {
......
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