审批数据改动

This commit is contained in:
mash 2023-02-20 13:30:40 +08:00
parent ecc71b73a5
commit c6643ee103
11 changed files with 181 additions and 40 deletions

View File

@ -27,7 +27,7 @@ public class Generator {
public static void main(String[] args) {
//表名
String tableName = "t_lc_audit_log";
String tableName = "t_lc_personnel_middle";
//表前缀
String tablePrefix = "t_lc_";
//作者

View File

@ -132,4 +132,7 @@ public class PersonnelUpdateDto {
@ApiModelProperty(value = "审批资料附件")
private List<AttachmentDto> auditFiles;
@ApiModelProperty(value = "审批按钮")
private Boolean auditBtn = false;
}

View File

@ -47,4 +47,5 @@ public class Alteration extends BaseEntity{
}

View File

@ -4,15 +4,14 @@ package com.ydool.staff.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ydool.common.base.BaseEntity;
import java.time.LocalDate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDate;
/**
* <p>
* 人员表
@ -154,4 +153,7 @@ public class Personnel extends BaseEntity {
@ApiModelProperty(value = "单据状态")
private String receipts;
@ApiModelProperty(value = "数据状态0历史数据 1暂存数据2当前数据")
private String state;
}

View File

@ -0,0 +1,36 @@
package com.ydool.staff.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ydool.common.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* 人员修改中间表
* </p>
*
* @author msh
* @since 2023-02-20
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("t_lc_personnel_middle")
@ApiModel(value="PersonnelMiddle对象", description="人员修改中间表")
public class PersonnelMiddle extends BaseEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "变更前id")
private String beforeId;
@ApiModelProperty(value = "变更后id")
private String afterId;
@ApiModelProperty(value = "数据状态0历史数据 1待定数据")
private String state;
}

View File

@ -0,0 +1,18 @@
package com.ydool.staff.mapper;
import com.ydool.staff.entity.PersonnelMiddle;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 人员修改中间表 Mapper 接口
* </p>
*
* @author msh
* @since 2023-02-20
*/
@Mapper
public interface PersonnelMiddleMapper extends MPJBaseMapper<PersonnelMiddle> {
}

View File

@ -0,0 +1,14 @@
package com.ydool.staff.service;
/**
* <p>
* 人员修改中间表 服务类
* </p>
*
* @author msh
* @since 2023-02-20
*/
public interface IPersonnelMiddleService {
}

View File

@ -11,9 +11,11 @@ import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.entity.Audit;
import com.ydool.staff.entity.AuditLog;
import com.ydool.staff.entity.Personnel;
import com.ydool.staff.entity.PersonnelMiddle;
import com.ydool.staff.mapper.AuditLogMapper;
import com.ydool.staff.mapper.AuditMapper;
import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.mapper.PersonnelMiddleMapper;
import com.ydool.staff.request.AuditRequest;
import com.ydool.staff.service.IAuditService;
import com.ydool.system.entity.Config;
@ -46,7 +48,8 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
@Resource
private PersonnelMapper personnelMapper;
@Resource
private PersonnelMiddleMapper personnelMiddleMapper;
@Override
public AjaxResult getAuditList(Page page) {
@ -64,6 +67,7 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
if (ObjectUtil.isEmpty(one)){
return AjaxResult.fail().msg("该用户不能审批!");
}
List<Audit> list = list(new LambdaQueryWrapper<Audit>().eq(Audit::getPersonnelId, auditRequest.getPersonnelId()));
//同意
if ("2".equals(auditRequest.getStatus())){
@ -91,8 +95,15 @@ public class AuditServiceImpl extends BaseService<AuditMapper, Audit> implements
if (update){
saveAuditLog(auditRequest.getPersonnelId(),loginId,"一般终审通过");
Personnel personnel = personnelMapper.selectById(auditRequest.getPersonnelId());
personnel.setAuditState(2);
personnel.setAlterationSign("2");
PersonnelMiddle middle = personnelMiddleMapper.selectOne(new LambdaQueryWrapper<PersonnelMiddle>().eq(PersonnelMiddle::getBeforeId, personnel.getId()).eq(PersonnelMiddle::getState, "1"));
System.out.println("middle = " + middle);
Personnel personnel1 = personnelMapper.selectById(middle.getAfterId());
String id = personnel1.getId();
personnel1.setState("2");
personnel1.setId(personnel.getId());
personnel.setId(id);
personnel.setState("0");
personnelMapper.updateById(personnel1);
personnelMapper.updateById(personnel);
}

View File

@ -0,0 +1,21 @@
package com.ydool.staff.service.impl;
import com.ydool.staff.entity.PersonnelMiddle;
import com.ydool.common.base.BaseService;
import com.ydool.staff.mapper.PersonnelMiddleMapper;
import com.ydool.staff.service.IPersonnelMiddleService;
import org.springframework.stereotype.Service;
/**
* <p>
* 人员修改中间表 服务类
* </p>
*
* @author msh
* @since 2023-02-20
*/
@Service
public class PersonnelMiddleServiceImpl extends BaseService<PersonnelMiddleMapper, PersonnelMiddle> implements IPersonnelMiddleService {
}

View File

@ -25,6 +25,7 @@ import com.ydool.staff.entity.Attachment;
import com.ydool.staff.entity.Audit;
import com.ydool.staff.entity.CompanyName;
import com.ydool.staff.entity.Personnel;
import com.ydool.staff.entity.PersonnelMiddle;
import com.ydool.staff.entity.SelectRequest;
import com.ydool.staff.excel.ExcelPersonnel;
import com.ydool.staff.excel.PersonnelExportVO;
@ -34,6 +35,7 @@ import com.ydool.staff.mapper.AuditLogMapper;
import com.ydool.staff.mapper.AuditMapper;
import com.ydool.staff.mapper.CompanyNameMapper;
import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.mapper.PersonnelMiddleMapper;
import com.ydool.staff.request.AttachmentRequest;
import com.ydool.staff.request.ChangeRequest;
import com.ydool.staff.request.PersonnelDeleteRequest;
@ -56,6 +58,7 @@ import org.thymeleaf.util.StringUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@ -100,6 +103,8 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
@Resource
private ConfigMapper configMapper;
@Resource
private PersonnelMiddleMapper personnelMiddleMapper;
/**
@ -133,11 +138,21 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
if (StrUtil.isNotBlank(id)) {
Personnel personnel = personnelMapper.selectById(id);
PersonnelUpdateDto personnelUpdateDto = BeanUtil.copyProperties(personnel, PersonnelUpdateDto.class);
List<Audit> list = auditMapper.selectList(new LambdaQueryWrapper<Audit>()
.eq(Audit::getPersonnelId, personnel.getId())
.eq(Audit::getApprover,StpUtil.getLoginIdAsString()));
for (Audit audit : list) {
if (ArgsConst.WAITING.equals(audit.getAuditOrder())){
personnelUpdateDto.setAuditBtn(true);
}
}
personnelUpdateDto.setCardFiles(nameAndPath(personnel.getCardFile(), personnel.getId()));
personnelUpdateDto.setEngageFiles(nameAndPath(personnel.getEngageFile(), personnel.getId()));
personnelUpdateDto.setEducationFiles(nameAndPath(personnel.getEducationFile(), personnel.getId()));
personnelUpdateDto.setJobTitleFiles(nameAndPath(personnel.getJobTitleFile(), personnel.getId()));
personnelUpdateDto.setAuditFiles(nameAndPath(personnel.getAuditFile(), personnel.getId()));
return AjaxResult.ok().data(personnelUpdateDto);
}
return AjaxResult.fail().msg("查询失败!");
@ -193,6 +208,7 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updatePersonnel(PersonnelUpdateRequest updateRequest) {
PersonnelMiddle middle = new PersonnelMiddle();
Personnel per = get(updateRequest.getId());
List<AttachmentRequest> cardFile = updateRequest.getCardFile();
List<AttachmentRequest> educationFile = updateRequest.getEducationFile();
@ -204,20 +220,25 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
return AjaxResult.fail().msg("该人员修改的资料未审批完成,请联系管理员!");
}
String type = ArgsConst.PERSONNEL;
saveAlteration("民族更改", per.getNation(), updateRequest.getNation(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getNation));
saveAlteration("政治面貌更改", per.getPoliticsStatus(), updateRequest.getPoliticsStatus(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getPoliticsStatus));
saveAlteration("学历更改", per.getEducation(), updateRequest.getEducation(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getEducation));
saveAlteration("是否应届毕业生更改", per.getFreshGraduate(), updateRequest.getFreshGraduate(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getFreshGraduate));
saveAlteration("毕业院校更改", per.getAcademy(), updateRequest.getAcademy(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getAcademy));
saveAlteration("专业更改", per.getSpecialty(), updateRequest.getSpecialty(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getSpecialty));
saveAlteration("所在部门更改", per.getPresentDept(), updateRequest.getPresentDept(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getPresentDept));
saveAlteration("合同形式更改", per.getContractModality(), updateRequest.getContractModality(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getContractModality));
saveAlteration("身份证附件更改", per.getCardFile(), card, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getCardFile));
saveAlteration("学历证书附件更改", per.getEducationFile(), education, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getEducationFile));
saveAlteration("审批资料附件更改", per.getAuditFile(), audit, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getAuditFile));
per.setAlterationSign("1");
boolean update = updateById(per);
middle.setBeforeId(per.getId());
per.setNation(saveAlteration("民族更改", per.getNation(), updateRequest.getNation(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getNation)));
per.setPoliticsStatus(saveAlteration("政治面貌更改", per.getPoliticsStatus(), updateRequest.getPoliticsStatus(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getPoliticsStatus)));
per.setEducation(saveAlteration("学历更改", per.getEducation(), updateRequest.getEducation(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getEducation)));
per.setFreshGraduate(saveAlteration("是否应届毕业生更改", per.getFreshGraduate(), updateRequest.getFreshGraduate(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getFreshGraduate)));
per.setAcademy(saveAlteration("毕业院校更改", per.getAcademy(), updateRequest.getAcademy(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getAcademy)));
per.setSpecialty(saveAlteration("专业更改", per.getSpecialty(), updateRequest.getSpecialty(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getSpecialty)));
per.setPresentDept(saveAlteration("所在部门更改", per.getPresentDept(), updateRequest.getPresentDept(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getPresentDept)));
per.setContractModality(saveAlteration("合同形式更改", per.getContractModality(), updateRequest.getContractModality(), type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getContractModality)));
per.setCardFile(saveAlteration("身份证附件更改", per.getCardFile(), card, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getCardFile)));
per.setEducationFile(saveAlteration("学历证书附件更改", per.getEducationFile(), education, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getEducationFile)));
per.setAuditFile(saveAlteration("审批资料附件更改", per.getAuditFile(), audit, type, updateRequest.getId(), ColumnUtil.getFieldName(Personnel::getAuditFile)));
per.setId("");
per.setState("1");
save(per);
middle.setAfterId(per.getId());
personnelMiddleMapper.insert(middle);
saveAttachment(cardFile, ArgsConst.CARD_FILE, updateRequest.getId(), ArgsConst.UPDATE);
saveAttachment(educationFile, ArgsConst.EDUCATION_FILE, updateRequest.getId(), ArgsConst.UPDATE);
saveAttachment(auditFile, ArgsConst.AUDIT_FILE, updateRequest.getId(), ArgsConst.UPDATE);
@ -225,8 +246,10 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
}
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updateChange(ChangeRequest request) {
Personnel per = get(request.getId());
PersonnelMiddle middle = new PersonnelMiddle();
List<AttachmentRequest> cardFiles = request.getCardFiles();
List<AttachmentRequest> jobTitleFiles = request.getJobTitleFiles();
List<AttachmentRequest> engageFiles = request.getEngageFiles();
@ -241,22 +264,30 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
String engage = StringUtils.join(saveFilePath(engageFiles, ArgsConst.ENGAGE_FILE, type, request.getId()), ',');
String education = StringUtils.join(saveFilePath(educationFiles, ArgsConst.EDUCATION_FILE, type, request.getId()), ',');
String audit = StringUtils.join(saveFilePath(auditFiles, ArgsConst.AUDIT_FILE, type, request.getId()), ',');
saveAlteration("录用方式更改",per.getHireType(),request.getHireType(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getHireType));
saveAlteration("执业资格更改",per.getQualification(),request.getQualification(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getQualification));
saveAlteration("专业技术职称更改",per.getJobTitle(),request.getJobTitle(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getJobTitle));
saveAlteration("岗位职务更改",per.getPosition(),request.getPosition(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getPosition));
saveAlteration("工作状态更改",per.getWorkState(),request.getWorkState(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getWorkState));
saveAlteration("人员性质更改",per.getPersonnelCharacter(),request.getPersonnelCharacter(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getPersonnelCharacter));
saveAlteration("年薪更改",per.getAnnualSalary(),request.getAnnualSalary(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getAnnualSalary));
saveAlteration("退休时间更改",per.getRetirementTime(),request.getRetirementTime(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getRetirementTime));
saveAlteration("人员招聘单号更改",per.getRecruitNumber(),request.getRecruitNumber(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getRecruitNumber));
saveAlteration("身份证附件更改",per.getCardFile(),card,type,request.getId(),ColumnUtil.getFieldName(Personnel::getCardFile));
saveAlteration("聘任证书附件更改",per.getEngageFile(),jobTitle,type,request.getId(),ColumnUtil.getFieldName(Personnel::getEngageFile));
saveAlteration("职称证书附件更改",per.getJobTitleFile(),engage,type,request.getId(),ColumnUtil.getFieldName(Personnel::getJobTitleFile));
saveAlteration("学历证书附件更改",per.getEducationFile(),education,type,request.getId(),ColumnUtil.getFieldName(Personnel::getEducationFile));
saveAlteration("审批资料附件更改",per.getAuditFile(),audit,type,request.getId(),ColumnUtil.getFieldName(Personnel::getAuditFile));
per.setAlterationSign("0");
boolean update = updateById(per);
middle.setBeforeId(per.getId());
per.setHireType(saveAlteration("录用方式更改",per.getHireType(),request.getHireType(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getHireType)));
per.setQualification(saveAlteration("执业资格更改",per.getQualification(),request.getQualification(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getQualification)));
per.setJobTitle(saveAlteration("专业技术职称更改",per.getJobTitle(),request.getJobTitle(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getJobTitle)));
per.setPosition(saveAlteration("岗位职务更改",per.getPosition(),request.getPosition(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getPosition)));
per.setWorkState(saveAlteration("工作状态更改",per.getWorkState(),request.getWorkState(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getWorkState)));
per.setPersonnelCharacter(saveAlteration("人员性质更改",per.getPersonnelCharacter(),request.getPersonnelCharacter(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getPersonnelCharacter)));
per.setAnnualSalary(Integer.valueOf(saveAlteration("年薪更改",per.getAnnualSalary(),request.getAnnualSalary(),type,request.getId(), ColumnUtil.getFieldName(Personnel::getAnnualSalary))));
per.setRecruitNumber(saveAlteration("人员招聘单号更改",per.getRecruitNumber(),request.getRecruitNumber(),type,request.getId(),ColumnUtil.getFieldName(Personnel::getRecruitNumber)));
per.setCardFile(saveAlteration("身份证附件更改",per.getCardFile(),card,type,request.getId(),ColumnUtil.getFieldName(Personnel::getCardFile)));
per.setEngageFile(saveAlteration("聘任证书附件更改",per.getEngageFile(),jobTitle,type,request.getId(),ColumnUtil.getFieldName(Personnel::getEngageFile)));
per.setJobTitleFile(saveAlteration("职称证书附件更改",per.getJobTitleFile(),engage,type,request.getId(),ColumnUtil.getFieldName(Personnel::getJobTitleFile)));
per.setEducationFile(saveAlteration("学历证书附件更改",per.getEducationFile(),education,type,request.getId(),ColumnUtil.getFieldName(Personnel::getEducationFile)));
per.setAuditFile(saveAlteration("审批资料附件更改",per.getAuditFile(),audit,type,request.getId(),ColumnUtil.getFieldName(Personnel::getAuditFile)));
if (ObjectUtil.isNotNull(per.getRetirementTime())){
per.setRetirementTime(LocalDate.parse(saveAlteration("退休时间更改",per.getRetirementTime(),request.getRetirementTime(),type,request.getId(), ColumnUtil.getFieldName(Personnel::getRetirementTime))));
}
per.setId("");
per.setState("1");
save(per);
middle.setAfterId(per.getId());
personnelMiddleMapper.insert(middle);
saveAttachment(cardFiles, ArgsConst.CARD_FILE, request.getId(), ArgsConst.UPDATE);
saveAttachment(jobTitleFiles, ArgsConst.JOBTITLE_FILE, request.getId(), ArgsConst.UPDATE);
saveAttachment(engageFiles, ArgsConst.ENGAGE_FILE, request.getId(), ArgsConst.UPDATE);
@ -312,7 +343,7 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
return null;
}
public void saveAlteration(String details,Object before ,Object after,String type, String id,String fieldName){
public String saveAlteration(String details,Object before ,Object after,String type, String id,String fieldName){
if (ObjectUtil.isNotNull(after)){
if (!after.equals(before)){
Alteration alteration = new Alteration();
@ -327,9 +358,11 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
}
alteration.setAfterChange(after.toString());
alterationMapper.insert(alteration);
}
}
}
return (String) after;
}
return (String) before;
}
public List<AttachmentDto> nameAndPath(String file, String id) {
@ -366,6 +399,7 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
.eq(ObjectUtil.isNotNull(request.getResignationTime()),Personnel::getResignationTime,request.getResignationTime())
.eq(StrUtil.isNotBlank(request.getWorkState()),Personnel::getWorkState,request.getWorkState())
.eq(StrUtil.isNotBlank(request.getReceipts()),Personnel::getReceipts,request.getReceipts())
.eq(Personnel::getState,"2")
.eq(StrUtil.isNotBlank(request.getAlterationSign()),Personnel::getAlterationSign,request.getAlterationSign());
wrapper.lambda().like(Personnel::getUserName,request.getUserName())
.like(Personnel::getNumberId,request.getNumberId())
@ -461,7 +495,9 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
@Transactional(rollbackFor = Exception.class)
public AjaxResult giveAudit(String id, String type) {
String loginId = (String) StpUtil.getLoginId();
if ("1".equals(get(id).getAuditState())) {
return AjaxResult.fail().msg("该数据已送审,请勿重复操作!");
}
for(int i=0;i<2;i++ ){
Audit audit = new Audit();
audit.setPersonnelId(id);
@ -485,7 +521,6 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
}
auditMapper.insert(audit);
}
Personnel personnel = get(id);
personnel.setAuditState(1);
personnel.setAlterationSign("1");

View File

@ -2,8 +2,8 @@ package ${package.ServiceImpl};
import ${package.Entity}.${entity};
import com.ydool.common.base.BaseService;
import com.ydool.system.mapper.${entity}Mapper;
import com.ydool.system.service.${table.serviceName};
import com.ydool.staff.mapper.${entity}Mapper;
import com.ydool.staff.service.${table.serviceName};
import org.springframework.stereotype.Service;
/**