Commit 413d02a4 authored by fangxinjiang's avatar fangxinjiang

MVP1.2:合同批量审核

parent 85f01152
......@@ -125,4 +125,15 @@ public class ArchivesConstants {
* 项目 获取区域数据失败:
*/
public static final String SETTLE_DOMAIN_CHECK_AREA_NOT_EXISTS = "获取区域数据失败:";
/**
* 合同审核意见不可为空
*/
public static final String CONTRACT_AUDIT_STATUS_NOT_EMPTY = "审核意见必填!";
/**
* 审核说明不可超过200字
*/
public static final String CONTRACT_AUDIT_REMARK_TOO_LONG = "审核说明不可超过200字!";
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author fxj
* @Date 2022/12/12
* @Description
* @Version 1.0
*/
@Data
public class EmpContractAuditVo implements Serializable {
/**
* 审核状态(0:待提交;1:待审核;2审核通过;3审核不通过)
*/
@Schema(description = "审核状态(0:待提交;1:待审核;2审核通过;3审核不通过)")
private Integer auditStatus;
/**
* 审核原因
*/
@Schema(description = "审核说明,前端传参用,字段不存数据库,数据库存审核记录")
@TableField(exist = false)
private String auditRemark;
/**
* 待审核IDS
*/
private List<String> ids;
}
......@@ -19,8 +19,10 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.constants.ArchivesConstants;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeContractInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpContractAuditVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeContractSearchVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
......@@ -28,6 +30,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
......@@ -219,14 +222,34 @@ public class TEmployeeContractInfoController {
@PreAuthorize("@pms.hasPermission('temployeecontractinfo_audit')")
public R<String> auditContract(@RequestBody TEmployeeContractInfo tEmployeeContractInfo) {
if (Common.isEmpty(tEmployeeContractInfo.getAuditStatus())) {
return R.failed("审核意见必填!");
return R.failed(ArchivesConstants.CONTRACT_AUDIT_STATUS_NOT_EMPTY);
}
if (Common.isNotNull(tEmployeeContractInfo.getAuditRemark()) && tEmployeeContractInfo.getAuditRemark().length() > 200) {
return R.failed("审核说明不可超过200字!");
return R.failed(ArchivesConstants.CONTRACT_AUDIT_REMARK_TOO_LONG);
}
return tEmployeeContractInfoService.auditContract(tEmployeeContractInfo);
}
/**
* @Author fxj
* @Description 批量审核员工合同
* @Date 16:21 2022/12/12
**/
@Operation(summary = "审核-员工合同(主键:ID;审核意见auditStatus(2审核通过;3审核不通过);审核说明auditRemark;)权限temployeecontractinfo_audit", description = "审核-员工合同")
@SysLog("批量审核员工合同")
@PostMapping("/auditContractBatch")
@PreAuthorize("@pms.hasPermission('temployeecontractinfo_audit')")
public R<List<ErrorMessage>> auditContractBatch(@RequestBody EmpContractAuditVo contractAuditVo) {
if (Common.isEmpty(contractAuditVo.getIds())) {
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
if (Common.isEmpty(contractAuditVo.getAuditStatus())) {
return R.failed(ArchivesConstants.CONTRACT_AUDIT_STATUS_NOT_EMPTY);
}
if (Common.isNotNull(contractAuditVo.getAuditRemark()) && contractAuditVo.getAuditRemark().length() > 200) {
return R.failed(ArchivesConstants.CONTRACT_AUDIT_REMARK_TOO_LONG);
}
return tEmployeeContractInfoService.auditContractBatch(contractAuditVo);
}
/**
* 审核员工合同
* 审核通过后,变为在用,项目内其他的合同不再用
......
......@@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeContractInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpContractAuditVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeContractExportVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.ErrorVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TEmployeeContractSearchVo;
......@@ -175,4 +176,6 @@ public interface TEmployeeContractInfoService extends IService<TEmployeeContract
* @return
**/
void exportAuditContractInfo(TEmployeeContractSearchVo contractInfo, HttpServletResponse response);
R<List<ErrorMessage>> auditContractBatch(EmpContractAuditVo contractAuditVo);
}
......@@ -67,6 +67,7 @@ import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
......@@ -1192,4 +1193,119 @@ public class TEmployeeContractInfoServiceImpl extends ServiceImpl<TEmployeeContr
return baseMapper.noPageCountDiy(searchVo);
}
/**
* @Author fxj
* @Description 批量审核合同
* @Date 16:45 2022/12/12
**/
@Override
public R<List<ErrorMessage>> auditContractBatch(EmpContractAuditVo contractAuditVo) {
List<TEmployeeContractInfo> contractInfos = baseMapper.selectBatchIds(contractAuditVo.getIds());
if (Common.isEmpty(contractInfos)){
return R.failed(CommonConstants.NO_DATA_TO_HANDLE);
}
List<ErrorMessage> errorMessages = new ArrayList<>();
TEmployeeContractInfo tEmployeeContractInfo;
TEmployeeContractInfo contractInfoInUse;
TEmployeeProject tEmployeeProject;
TEmployeeInfo tEmployeeInfo;
int i =1;
for (TEmployeeContractInfo contract:contractInfos){
i++;
if (contract.getAuditStatus() != CommonConstants.ONE_INT) {
errorMessages.add(new ErrorMessage(i,"不是待审核状态!",CommonConstants.RED));
continue;
}
tEmployeeContractInfo = new TEmployeeContractInfo();
tEmployeeContractInfo.setAuditRemark(contractAuditVo.getAuditRemark());
tEmployeeContractInfo.setAuditStatus(contractAuditVo.getAuditStatus());
tEmployeeContractInfo.setId(contract.getId());
if (tEmployeeContractInfo.getAuditStatus() == CommonConstants.dingleDigitIntArray[2]) {
// 非作废、终止,本条变为在用
if (Common.isEmpty(contract.getSituation())
|| (!EmployeeConstants.SITUATION_SIX.equals(contract.getSituation())
&& !EmployeeConstants.SITUATION_SEVEN.equals(contract.getSituation()))) {
// 其他变为不在用
baseMapper.updateInUseStatusById(contract.getEmpId(), contract.getDeptNo(), contract.getId(), CommonConstants.ONE_STRING);
tEmployeeContractInfo.setAuditTimeLast(LocalDateTime.now());
tEmployeeContractInfo.setInUse(CommonConstants.ZERO_STRING);
// 更新档案、项目合同状态为(1可用)
tEmployeeProject = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query()
.lambda().eq(TEmployeeProject::getEmpId, contract.getEmpId())
.eq(TEmployeeProject::getDeptId, contract.getSettleDomain())
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.last(CommonConstants.LAST_ONE_SQL));
if (tEmployeeProject != null) {
tEmployeeProject.setContractStatus(CommonConstants.ONE_INT);
tEmployeeProjectService.updateById(tEmployeeProject);
}
// 更新档案、项目合同状态为(1在用)
tEmployeeInfo = tEmployeeInfoMapper.selectById(contract.getEmpId());
if (tEmployeeInfo != null) {
tEmployeeInfo.setContractStatus(CommonConstants.ONE_INT);
tEmployeeInfoMapper.updateById(tEmployeeInfo);
}
} else {
//先停用项目内的其他的员工合同————不要这个逻辑了
// 2022-7-22 16:54:12 产品倩倩与测试说,作废终止审核通过,仅将原先选择的合同不在用即可
if (Common.isNotNull(contract.getOldContractId())) {
TEmployeeContractInfo old = this.getById(contract.getOldContractId());
if (old != null && Common.isNotNull(old.getId())) {
if (!CommonConstants.ZERO_STRING.equals(old.getInUse())) {
errorMessages.add(new ErrorMessage(i,"关联的原合同已不在用!",CommonConstants.RED));
continue;
} else {
old.setInUse(CommonConstants.ONE_STRING);
this.updateById(old);
}
} else {
errorMessages.add(new ErrorMessage(i,"未找到关联的原合同!",CommonConstants.RED));
continue;
}
} else {
errorMessages.add(new ErrorMessage(i,"未找到关联的原合同!",CommonConstants.RED));
continue;
}
// 作废、终止审核通过:
// 更新项目合同状态为(2不在用),档案状态要判断
tEmployeeProject = tEmployeeProjectService.getOne(Wrappers.<TEmployeeProject>query()
.lambda().eq(TEmployeeProject::getEmpId, contract.getEmpId())
.eq(TEmployeeProject::getDeptId, contract.getSettleDomain())
.eq(TEmployeeProject::getProjectStatus, CommonConstants.ZERO_INT)
.eq(TEmployeeProject::getDeleteFlag, CommonConstants.STATUS_NORMAL)
.last(CommonConstants.LAST_ONE_SQL));
if (tEmployeeProject != null) {
tEmployeeProject.setContractStatus(CommonConstants.TWO_INT);
tEmployeeProjectService.updateById(tEmployeeProject);
}
// 更新档案、项目合同状态为(0无合同 1在用 2不在用)
tEmployeeInfo = tEmployeeInfoMapper.selectById(contract.getEmpId());
if (tEmployeeInfo != null) {
// 判断人员有无审核通过的其他合同
contractInfoInUse = this.getOne(Wrappers.<TEmployeeContractInfo>query()
.lambda().eq(TEmployeeContractInfo::getEmpId, contract.getEmpId())
.and(obj->obj.ge(TEmployeeContractInfo::getContractEnd,DateUtil.getThisDayByPatten("yyyy-MM-dd"))
.or().isNull(TEmployeeContractInfo::getContractEnd))
.eq(TEmployeeContractInfo::getInUse, CommonConstants.ZERO_INT)
.eq(TEmployeeContractInfo::getDeleteFlag, CommonConstants.ZERO_INT)
.last(CommonConstants.LAST_ONE_SQL));
if (contractInfoInUse != null) {
tEmployeeInfo.setContractStatus(CommonConstants.ONE_INT);
} else {
tEmployeeInfo.setContractStatus(CommonConstants.TWO_INT);
}
tEmployeeInfoMapper.updateById(tEmployeeInfo);
}
}
}
// 不是待提交,记录审核记录
this.setAuditInfo(tEmployeeContractInfo);
this.updateById(tEmployeeContractInfo);
errorMessages.add(new ErrorMessage(i,"更新成功!",CommonConstants.GREEN));
}
return R.ok(errorMessages);
}
}
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