update 人员

This commit is contained in:
mash 2023-02-09 16:32:39 +08:00
parent ed9dee7a0d
commit 9642903945
2 changed files with 44 additions and 19 deletions

View File

@ -1,5 +1,6 @@
package com.ydool.staff.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -15,9 +16,13 @@ import com.ydool.staff.mapper.AlterationMapper;
import com.ydool.staff.service.IAlterationService;
import com.ydool.system.entity.Dept;
import com.ydool.system.entity.User;
import com.ydool.system.mapper.DeptMapper;
import com.ydool.system.mapper.UserMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -32,17 +37,32 @@ import java.util.stream.Collectors;
@Service
public class AlterationServiceImpl extends BaseService<AlterationMapper, Alteration> implements IAlterationService {
@Resource
private UserMapper userMapper;
@Override
public AjaxResult alterationList(String id) {
List<Alteration> list = list(new LambdaQueryWrapper<Alteration>().eq(Alteration::getRelevancyId, id));
List<AlterationDto> alterationDtos = BeanUtil.copyToList(list, AlterationDto.class);
for (Alteration dto : list) {
UserMapper userMapper = SpringUtil.getBean(UserMapper.class);
User user = userMapper.selectById(dto.getCreatedId());
for (AlterationDto alterationDto : alterationDtos) {
alterationDto.setCreatedName(user.getUserName());
List<AlterationDto> alterationDtos = new ArrayList<>();
DeptMapper deptMapper = SpringUtil.getBean(DeptMapper.class);
for (Alteration alteration : list) {
AlterationDto dto = BeanUtil.copyProperties(alteration, AlterationDto.class);
User user = userMapper.selectById(alteration.getCreatedId());
dto.setCreatedName(user.getUserName());
if ("presentDept".equals(alteration.getFieldName())){
Dept deptBeforeChange = deptMapper.selectById(dto.getBeforeChange());
Dept deptAfterChange = deptMapper.selectById(dto.getAfterChange());
dto.setBeforeChange(deptBeforeChange.getName());
dto.setAfterChange(deptAfterChange.getName());
}
if ("freshGraduate".equals(alteration.getFieldName())){
if ("0".equals(alteration.getBeforeChange())){
dto.setBeforeChange("");
}if ("1".equals(alteration.getAfterChange())){
dto.setAfterChange("");
}
}
alterationDtos.add(dto);
}
return AjaxResult.ok().data(alterationDtos);
}

View File

@ -160,6 +160,7 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
String card = StringUtils.join(saveFilePath(cardFile, AgesConst.CARD_FILE, AgesConst.UPDATE, updateRequest.getId()), ',');
String education = StringUtils.join(saveFilePath(educationFile,AgesConst.EDUCATION_FILE,AgesConst.UPDATE,updateRequest.getId()),',');
String audit = StringUtils.join(saveFilePath(auditFile,AgesConst.AUDIT_FILE,AgesConst.UPDATE,updateRequest.getId()),',');
System.out.println("per = " + per);
if (per.getAuditState().equals(0)||per.getAuditState().equals(1)) {
return AjaxResult.fail().msg("该人员修改的资料未审批完成,请联系管理员!");
}
@ -271,20 +272,24 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
}
public void saveAlteration(String details,Object before ,Object after,String type, String id,String fieldName){
if (!before.equals(after)){
Alteration alteration = new Alteration();
alteration.setDetails(details);
alteration.setFieldName(fieldName);
alteration.setType(type);
alteration.setRelevancyId(id);
if (ObjectUtil.isNotNull(before)){
alteration.setBeforeChange( before.toString());
}else {
alteration.setBeforeChange("");
if (ObjectUtil.isNotNull(after)){
System.out.println("after = " + after);
if (!before.equals(after)){
Alteration alteration = new Alteration();
alteration.setDetails(details);
alteration.setFieldName(fieldName);
alteration.setType(type);
alteration.setRelevancyId(id);
if (ObjectUtil.isNotNull(before)){
alteration.setBeforeChange( before.toString());
}else {
alteration.setBeforeChange("");
}
alteration.setAfterChange(after.toString());
alterationMapper.insert(alteration);
}
alteration.setAfterChange(after.toString());
alterationMapper.insert(alteration);
}
}
public List<AttachmentDto> nameAndPath(String file,String id){
if (StrUtil.isNotBlank(file)){