人员相关

This commit is contained in:
mash 2023-02-02 16:26:08 +08:00
parent 32c068b260
commit 3852f86f68
9 changed files with 259 additions and 41 deletions

View File

@ -7,9 +7,11 @@ import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.PersonnelDto; import com.ydool.staff.dto.PersonnelDto;
import com.ydool.staff.request.PersonnelDeleteRequest; import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.request.PersonnelRequest; import com.ydool.staff.request.PersonnelRequest;
import com.ydool.staff.request.PersonnelUpdateRequest;
import com.ydool.staff.service.IPersonnelService; import com.ydool.staff.service.IPersonnelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -35,9 +37,13 @@ public class PersonnelController extends BaseController {
private IPersonnelService personnelService; private IPersonnelService personnelService;
@GetMapping(value = "personnelList") @GetMapping(value = "personnelList")
@ApiOperation(value = "人员列表",response = PersonnelDto.class) @ApiOperation(value = "人员列表,传id查一条",response = PersonnelDto.class)
public AjaxResult personnelList(){ @ApiImplicitParams({
return personnelService.personnelList(); @ApiImplicitParam(name = "current", value = "当前页"),
@ApiImplicitParam(name = "size", value = "每页条数"),
@ApiImplicitParam(name = "id", value = "人员id")})
public AjaxResult personnelList(String id){
return personnelService.personnelList(getPage(),id);
} }
@PostMapping(value = "savePersonnel") @PostMapping(value = "savePersonnel")
@ -50,5 +56,10 @@ public class PersonnelController extends BaseController {
public AjaxResult deletePersonnel(@RequestBody PersonnelDeleteRequest personnelDeleteRequest){ public AjaxResult deletePersonnel(@RequestBody PersonnelDeleteRequest personnelDeleteRequest){
return personnelService.deleteByIds(personnelDeleteRequest); return personnelService.deleteByIds(personnelDeleteRequest);
} }
@PostMapping(value = "updatePersonnel")
@ApiOperation(value = "修改人员")
public AjaxResult updatePersonnel(@RequestBody PersonnelUpdateRequest personnelDeleteRequest){
return personnelService.updatePersonnel(personnelDeleteRequest);
}
} }

View File

@ -1,8 +1,14 @@
package com.ydool.staff.dto; package com.ydool.staff.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ydool.common.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
/** /**
* @author msh * @author msh
* @version 1.0 * @version 1.0
@ -10,6 +16,10 @@ import lombok.Data;
*/ */
@Data @Data
public class PersonnelDto { public class PersonnelDto {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "变更标志") @ApiModelProperty(value = "变更标志")
private String alterationSign; private String alterationSign;
@ -17,7 +27,7 @@ public class PersonnelDto {
private String companyName; private String companyName;
@ApiModelProperty(value = "姓名") @ApiModelProperty(value = "姓名")
private String name; private String userName;
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
private String numberId; private String numberId;
@ -28,4 +38,14 @@ public class PersonnelDto {
@ApiModelProperty(value = "人员类型") @ApiModelProperty(value = "人员类型")
private String personnelType; private String personnelType;
/**
* 创建时间
*/
@TableField(value = "created_at", fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ApiModelProperty(value = "创建时间")
private LocalDateTime createdAt;
} }

View File

@ -41,10 +41,10 @@ public class Personnel extends BaseEntity {
private String companyName; private String companyName;
@ApiModelProperty(value = "性别") @ApiModelProperty(value = "性别")
private String gender; private Integer gender;
@ApiModelProperty(value = "出生日期") @ApiModelProperty(value = "出生日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday; private Date birthday;
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
@ -60,7 +60,7 @@ public class Personnel extends BaseEntity {
private String education; private String education;
@ApiModelProperty(value = "是否应届毕业生") @ApiModelProperty(value = "是否应届毕业生")
private String freshGraduate; private Integer freshGraduate;
@ApiModelProperty(value = "毕业院校") @ApiModelProperty(value = "毕业院校")
private String academy; private String academy;
@ -99,23 +99,23 @@ public class Personnel extends BaseEntity {
private BigDecimal annualSalary; private BigDecimal annualSalary;
@ApiModelProperty(value = "入职时间") @ApiModelProperty(value = "入职时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date hiredate; private Date hireDate;
@ApiModelProperty(value = "退休时间") @ApiModelProperty(value = "退休时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date retirementTime; private Date retirementTime;
@ApiModelProperty(value = "离职时间") @ApiModelProperty(value = "离职时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date resignationTime; private Date resignationTime;
@ApiModelProperty(value = "退休返聘开始时间") @ApiModelProperty(value = "退休返聘开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date txfpStartTime; private Date txfpStartTime;
@ApiModelProperty(value = "退休返聘结束时间") @ApiModelProperty(value = "退休返聘结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date txfpEndTime; private Date txfpEndTime;
@ApiModelProperty(value = "人员招聘单号") @ApiModelProperty(value = "人员招聘单号")
@ -130,8 +130,20 @@ public class Personnel extends BaseEntity {
@ApiModelProperty(value = "终审意见") @ApiModelProperty(value = "终审意见")
private String finalTrialRemark; private String finalTrialRemark;
@ApiModelProperty(value = "相关附件") @ApiModelProperty(value = "身份证附件")
private String attachmentFile; private String cardFile;
@ApiModelProperty(value = "聘任证书附件")
private String engageFile;
@ApiModelProperty(value = "职称证书附件")
private String jobTitleFile;
@ApiModelProperty(value = "学历证书附件")
private String educationFile;
@ApiModelProperty(value = "审批资料附件")
private String auditFile;
@ApiModelProperty(value = "变更标志") @ApiModelProperty(value = "变更标志")
private String alterationSign; private String alterationSign;

View File

@ -35,7 +35,7 @@ public class PersonnelRequest {
private String gender; private String gender;
@ApiModelProperty(value = "出生日期") @ApiModelProperty(value = "出生日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday; private Date birthday;
@ApiModelProperty(value = "身份证号") @ApiModelProperty(value = "身份证号")
@ -107,23 +107,23 @@ public class PersonnelRequest {
private BigDecimal annualSalary; private BigDecimal annualSalary;
@ApiModelProperty(value = "入职时间") @ApiModelProperty(value = "入职时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date hiredate; private Date hiredate;
@ApiModelProperty(value = "退休时间") @ApiModelProperty(value = "退休时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date retirementTime; private Date retirementTime;
@ApiModelProperty(value = "离职时间") @ApiModelProperty(value = "离职时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date resignationTime; private Date resignationTime;
@ApiModelProperty(value = "退休返聘开始时间") @ApiModelProperty(value = "退休返聘开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date txfpStartTime; private Date txfpStartTime;
@ApiModelProperty(value = "退休返聘结束时间") @ApiModelProperty(value = "退休返聘结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date txfpEndTime; private Date txfpEndTime;
@ApiModelProperty(value = "人员招聘单号") @ApiModelProperty(value = "人员招聘单号")

View File

@ -0,0 +1,61 @@
package com.ydool.staff.request;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author msh
* @version 1.0
* @date 2023/2/1 11:53
*/
@Data
public class PersonnelUpdateRequest {
@ApiModelProperty(value = "id")
@NotBlank(message = "id不能为空")
private String id;
@ApiModelProperty(value = "民族")
@NotBlank(message = "民族不能为空")
private String nation;
@ApiModelProperty(value = "政治面貌")
@NotBlank(message = "政治面貌不能为空")
private String politicsStatus;
@ApiModelProperty(value = "学历")
@NotBlank(message = "学历不能为空")
private String education;
@ApiModelProperty(value = "是否应届毕业生")
@NotBlank(message = "是否应届毕业生不能为空")
private Integer freshGraduate;
@ApiModelProperty(value = "毕业院校")
@NotBlank(message = "毕业院校不能为空")
private String academy;
@ApiModelProperty(value = "专业")
@NotBlank(message = "专业不能为空")
private String specialty;
@ApiModelProperty(value = "所在部门")
@NotBlank(message = "所在部门不能为空")
private String presentDept;
@ApiModelProperty(value = "合同形式")
@NotBlank(message = "合同形式不能为空")
private String contractModality;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "相关附件")
private List<AttachmentRequest> attachmentList;
}

View File

@ -1,6 +1,7 @@
package com.ydool.staff.service; package com.ydool.staff.service;
import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.Attachment;
import com.ydool.staff.request.AttachmentRequest;
/** /**
* <p> * <p>
@ -13,5 +14,9 @@ import com.ydool.staff.entity.Attachment;
public interface IAttachmentService { public interface IAttachmentService {
boolean savePersonnel(Attachment attachment); boolean savePersonnel(Attachment attachment);
boolean deleteById(String targetType,String id);
Attachment selectFile(String path, String id);
} }

View File

@ -1,8 +1,10 @@
package com.ydool.staff.service; package com.ydool.staff.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.request.PersonnelDeleteRequest; import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.request.PersonnelRequest; import com.ydool.staff.request.PersonnelRequest;
import com.ydool.staff.request.PersonnelUpdateRequest;
import java.util.List; import java.util.List;
@ -19,11 +21,27 @@ public interface IPersonnelService {
* 人员列表 * 人员列表
* @return * @return
*/ */
AjaxResult personnelList(); AjaxResult personnelList(Page page , String id);
/**
* 新增保存
* @param personnelRequest
* @return
*/
AjaxResult savePersonnel(PersonnelRequest personnelRequest); AjaxResult savePersonnel(PersonnelRequest personnelRequest);
/**
* 删除/批量删除人员
* @param personnelDeleteRequest
* @return
*/
AjaxResult deleteByIds(PersonnelDeleteRequest personnelDeleteRequest); AjaxResult deleteByIds(PersonnelDeleteRequest personnelDeleteRequest);
/**
* 修改人员信息
* @param personnelDeleteRequest
* @return
*/
AjaxResult updatePersonnel(PersonnelUpdateRequest personnelDeleteRequest);
} }

View File

@ -1,8 +1,10 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ydool.common.base.BaseService; import com.ydool.common.base.BaseService;
import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.Attachment;
import com.ydool.staff.mapper.AttachmentMapper; import com.ydool.staff.mapper.AttachmentMapper;
import com.ydool.staff.request.AttachmentRequest;
import com.ydool.staff.service.IAttachmentService; import com.ydool.staff.service.IAttachmentService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -22,5 +24,17 @@ public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachm
public boolean savePersonnel(Attachment entity) { public boolean savePersonnel(Attachment entity) {
return save(entity); return save(entity);
} }
@Override
public boolean deleteById(String targetType,String id) {
return remove(new LambdaQueryWrapper<Attachment>().eq(Attachment::getTargetType,targetType).eq(Attachment::getTargetId,id));
}
@Override
public Attachment selectFile(String path, String id) {
return getOne(new LambdaQueryWrapper<Attachment>().eq(Attachment::getAttachment, path).eq(Attachment::getTargetId,id));
}
} }

View File

@ -1,24 +1,31 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.common.base.BaseService;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.dto.PersonnelDto; import com.ydool.staff.dto.PersonnelDto;
import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.Attachment;
import com.ydool.staff.entity.Personnel; import com.ydool.staff.entity.Personnel;
import com.ydool.common.base.BaseService;
import com.ydool.staff.mapper.PersonnelMapper; import com.ydool.staff.mapper.PersonnelMapper;
import com.ydool.staff.request.AttachmentRequest; import com.ydool.staff.request.AttachmentRequest;
import com.ydool.staff.request.PersonnelDeleteRequest; import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.request.PersonnelRequest; import com.ydool.staff.request.PersonnelRequest;
import com.ydool.staff.request.PersonnelUpdateRequest;
import com.ydool.staff.service.IAttachmentService; import com.ydool.staff.service.IAttachmentService;
import com.ydool.staff.service.IPersonnelService; import com.ydool.staff.service.IPersonnelService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils; import org.thymeleaf.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -38,20 +45,22 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
* @return * @return
*/ */
@Override @Override
public AjaxResult personnelList() { public AjaxResult personnelList(Page page , String id) {
List<Personnel> list = list(); if (ObjectUtil.isNotNull(id)){
List<PersonnelDto> personnelDtos = new ArrayList<>(); Personnel personnel = get(id);
for (Personnel personnel : list) { return AjaxResult.ok().data(personnel);
PersonnelDto dto = new PersonnelDto();
dto.setAlterationSign(personnel.getAlterationSign());
dto.setCompanyName(personnel.getCompanyName());
dto.setName(personnel.getUserName());
dto.setNumberId(personnel.getNumberId());
dto.setPresentDept(personnel.getPresentDept());
dto.setPersonnelType(personnel.getPersonnelType());
personnelDtos.add(dto);
} }
return AjaxResult.ok().data(personnelDtos); LambdaQueryWrapper<Personnel> wrapper = new LambdaQueryWrapper<>();
Page personnelPage = page(page, wrapper);
List<Personnel> list = personnelPage.getRecords();
personnelPage.setRecords(list.stream().map(e->{
PersonnelDto dto = BeanUtil.copyProperties(e, PersonnelDto.class);
dto.setCreatedAt(e.getCreatedAt());
return dto;
}).collect(Collectors.toList()));
return AjaxResult.ok().data(personnelPage);
} }
/** /**
@ -63,10 +72,28 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
public AjaxResult savePersonnel(PersonnelRequest personnelRequest) { public AjaxResult savePersonnel(PersonnelRequest personnelRequest) {
List<AttachmentRequest> attachmentList = personnelRequest.getAttachmentList(); List<AttachmentRequest> attachmentList = personnelRequest.getAttachmentList();
Personnel personnel = BeanUtil.copyProperties(personnelRequest, Personnel.class); Personnel personnel = BeanUtil.copyProperties(personnelRequest, Personnel.class);
ArrayList<String> s = new ArrayList<>(); ArrayList<String> card = new ArrayList<>();
ArrayList<String> engage = new ArrayList<>();
ArrayList<String> jobTitle = new ArrayList<>();
ArrayList<String> education = new ArrayList<>();
ArrayList<String> audit = new ArrayList<>();
for (AttachmentRequest request : attachmentList) { for (AttachmentRequest request : attachmentList) {
s.add(request.getPath()); if ("card".equals(request.getTargetType())){
personnel.setAttachmentFile(StringUtils.join(s,',')); card.add(request.getPath());
personnel.setCardFile(StringUtils.join(card,','));
}else if ("engage".equals(request.getTargetType())){
engage.add(request.getPath());
personnel.setEngageFile(StringUtils.join(engage,','));
}else if ("jobTitle".equals(request.getTargetType())){
jobTitle.add(request.getPath());
personnel.setJobTitleFile(StringUtils.join(jobTitle,','));
}else if ("education".equals(request.getTargetType())){
education.add(request.getPath());
personnel.setEducationFile(StringUtils.join(education,','));
}else if ("audit".equals(request.getTargetType())){
audit.add(request.getPath());
personnel.setAuditFile(StringUtils.join(audit,','));
}
} }
boolean save = save(personnel); boolean save = save(personnel);
List<AttachmentRequest> list = personnelRequest.getAttachmentList(); List<AttachmentRequest> list = personnelRequest.getAttachmentList();
@ -87,10 +114,60 @@ public class PersonnelServiceImpl extends BaseService<PersonnelMapper, Personnel
public AjaxResult deleteByIds(PersonnelDeleteRequest personnelDeleteRequest) { public AjaxResult deleteByIds(PersonnelDeleteRequest personnelDeleteRequest) {
List<String> ids = personnelDeleteRequest.getIds(); List<String> ids = personnelDeleteRequest.getIds();
boolean flag = false; boolean flag = false;
if (1<ids.size()){
for (String id : ids) { for (String id : ids) {
flag = removeById(id); flag = removeById(id);
} }
return flag?AjaxResult.ok().msg("批量删除成功!"):AjaxResult.fail().msg("批量删除失败!");
}
flag = removeById(ids.get(0));
return flag?AjaxResult.ok().msg("删除成功!"):AjaxResult.fail().msg("删除失败!"); return flag?AjaxResult.ok().msg("删除成功!"):AjaxResult.fail().msg("删除失败!");
} }
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updatePersonnel(PersonnelUpdateRequest updateRequest) {
Personnel personnel = BeanUtil.copyProperties(updateRequest, Personnel.class);
List<AttachmentRequest> attachmentList = updateRequest.getAttachmentList();
ArrayList<String> card = new ArrayList<>();
ArrayList<String> engage = new ArrayList<>();
ArrayList<String> jobTitle = new ArrayList<>();
ArrayList<String> education = new ArrayList<>();
ArrayList<String> audit = new ArrayList<>();
for (AttachmentRequest request : attachmentList) {
if ("card".equals(request.getTargetType())){
card.add(request.getPath());
personnel.setCardFile(StringUtils.join(card,','));
attachmentService.deleteById(request.getTargetType(),updateRequest.getId());
}else if ("engage".equals(request.getTargetType())){
engage.add(request.getPath());
personnel.setEngageFile(StringUtils.join(engage,','));
attachmentService.deleteById(request.getTargetType(),updateRequest.getId());
}else if ("jobTitle".equals(request.getTargetType())){
jobTitle.add(request.getPath());
personnel.setJobTitleFile(StringUtils.join(jobTitle,','));
attachmentService.deleteById(request.getTargetType(),updateRequest.getId());
}else if ("education".equals(request.getTargetType())){
education.add(request.getPath());
personnel.setEducationFile(StringUtils.join(education,','));
attachmentService.deleteById(request.getTargetType(),updateRequest.getId());
}else if ("audit".equals(request.getTargetType())){
audit.add(request.getPath());
personnel.setAuditFile(StringUtils.join(audit,','));
attachmentService.deleteById(request.getTargetType(),updateRequest.getId());
}
}
boolean update = updateById(personnel);
for (AttachmentRequest request : attachmentList) {
Attachment attachment = new Attachment();
attachment.setTargetType(request.getTargetType());
attachment.setSize(request.getSize());
attachment.setAttachment(request.getPath());
attachment.setTitle(request.getName());
attachment.setTargetId(personnel.getId());
attachmentService.savePersonnel(attachment);
}
return update ? AjaxResult.ok().msg("修改成功!"):AjaxResult.fail().msg("修改失败!");
}
} }