入职申请

This commit is contained in:
furongxin 2024-07-03 11:00:51 +08:00
parent 264a1350e8
commit b8beed61da
6 changed files with 75 additions and 25 deletions

View File

@ -6,7 +6,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.BpmOAEntryRespVO
import cn.iocoder.yudao.module.bpm.convert.oa.BpmOAEntryConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAEntryDO;
import cn.iocoder.yudao.module.bpm.service.oa.BpmOAEntryService;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.dept.dto.PostRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -18,7 +21,6 @@ import javax.annotation.security.PermitAll;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* OA 入职申请 Controller
@ -35,14 +37,17 @@ public class BpmOAEntryController {
private BpmOAEntryService entryService;
@Resource
private FileApi fileApi;
private DeptApi deptApi;
@Resource
private PostApi postApi;
@PostMapping("/create")
@Operation(summary = "创建请求申请")
@PermitAll
public CommonResult<Long> createEntry(@Valid @RequestBody BpmOAEntryCreateReqVO createReqVO) {
return success(entryService.createEntry(getLoginUserId(), createReqVO));
return success(entryService.createEntry(createReqVO));
}
@GetMapping("/get")
@ -58,10 +63,47 @@ public class BpmOAEntryController {
@GetMapping("/getByOpenId")
@Operation(summary = "获得入职申请")
@Parameter(name = "openId", description = "编号", required = true, example = "1024")
@PermitAll
public CommonResult<BpmOAEntryRespVO> getEntryByOpenId(@RequestParam("openId") String openId) {
BpmOAEntryDO entry = entryService.getEntryByOpenId(openId);
return success(BpmOAEntryConvert.INSTANCE.convert(entry));
if (entry == null) {
return success(null);
}
BpmOAEntryRespVO respVO = BpmOAEntryConvert.INSTANCE.convert(entry);
// 设备部门名称
respVO.setEntryDeptName(getDept(entry.getEntryDeptId()).getName());
// 设备岗位名称
respVO.setEntryPostName(getPost(entry.getEntryPostId()).getName());
return success(respVO);
}
/**
* 获得部门信息
* @param deptId 部门id
* @return 部门信息
*/
public DeptRespDTO getDept(Long deptId) {
if (deptId == null) {
return new DeptRespDTO();
}
return deptApi.getDept(deptId).getCheckedData();
}
/**
* 获得岗位信息
* @param postId 岗位ID
* @return
*/
public PostRespVO getPost(Long postId) {
if (postId == null) {
return new PostRespVO();
}
return postApi.getPost(postId).getCheckedData();
}
}

View File

@ -1,8 +1,10 @@
package cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.upload.UploadUserFile;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ -25,9 +27,6 @@ public class BpmOAEntryCreateReqVO {
@NotNull(message = "发起人的用户编号不能为空")
private Long userId;
@Schema(description = "发起人的部门编号", example = "9099")
private Long deptId;
@Schema(description = "新入职用户编号", example = "6311")
private Long entryUserId;
@ -49,7 +48,8 @@ public class BpmOAEntryCreateReqVO {
private String idcard;
@Schema(description = "入职时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "入职时间不能为空")
@NotNull(message = "入职时间不能为空")
@DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY)
private LocalDate entryDate;
@Schema(description = "人脸图片地址")

View File

@ -24,16 +24,21 @@ public class BpmOAEntryRespVO extends BpmOABaseRespVO {
@NotNull(message = "发起人的用户编号不能为空")
private Long userId;
@Schema(description = "发起人的部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9099")
@NotNull(message = "发起人的部门编号不能为空")
private Long deptId;
@Schema(description = "新入职用户编号", example = "6311")
private Long entryUserId;
@Schema(description = "新入职用户部门编号", example = "10237")
private Long entryDeptId;
@Schema(description = "新入职用户部门名称", example = "研发部")
private String entryDeptName;
@Schema(description = "新入职用户岗位编号", example = "10237")
private Long entryPostId;
@Schema(description = "新入职用户岗位名称", example = "职工")
private String entryPostName;
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "用户昵称不能为空")
private String nickname;

View File

@ -17,7 +17,7 @@ import java.util.List;
*
* @author 符溶馨
*/
@TableName("bpm_oa_entry")
@TableName(value ="bpm_oa_entry", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ -35,10 +35,6 @@ public class BpmOAEntryDO extends BaseDO {
* 发起人的用户编号
*/
private Long userId;
/**
* 发起人的部门编号
*/
private Long deptId;
/**
* 新入职用户编号
*/
@ -47,6 +43,11 @@ public class BpmOAEntryDO extends BaseDO {
* 新入职用户部门编号
*/
private Long entryDeptId;
/**
* 新入职用户部门编号
*/
private Long entryPostId;
/**
* 用户昵称
*/
@ -75,7 +76,7 @@ public class BpmOAEntryDO extends BaseDO {
* 附件基本信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<UploadUserFile> fileItems ;
private List<UploadUserFile> fileItems;
/**
* 用章的结果
*

View File

@ -10,11 +10,10 @@ public interface BpmOAEntryService {
/**
* 创建入职申请
*
* @param userId 用户编号
* @param createReqVO 创建信息
* @return 编号
*/
Long createEntry(Long userId, @Valid BpmOAEntryCreateReqVO createReqVO);
Long createEntry(@Valid BpmOAEntryCreateReqVO createReqVO);
/**
* 更新入职申请的状态

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.service.oa;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.entry.BpmOAEntryCreateReqVO;
@ -38,16 +39,16 @@ public class BpmOAEntryServiceImpl implements BpmOAEntryService{
private BpmProcessInstanceApi processInstanceApi;
@Override
public Long createEntry(Long userId, BpmOAEntryCreateReqVO createReqVO) {
public Long createEntry(BpmOAEntryCreateReqVO createReqVO) {
//插入OA 入职申请
BpmOAEntryDO entry = BpmOAEntryConvert.INSTANCE.convert(createReqVO).setUserId(userId)
BpmOAEntryDO entry = BpmOAEntryConvert.INSTANCE.convert(createReqVO)
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
entryMapper.insert(entry) ;
// 发起 BPM 流程
Map<String, Object> processInstanceVariables = new HashMap<>();
String processInstanceId = processInstanceApi.createProcessInstance(userId,
String processInstanceId = processInstanceApi.createProcessInstance(createReqVO.getUserId(),
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(entry.getId()))).getCheckedData();
@ -79,6 +80,8 @@ public class BpmOAEntryServiceImpl implements BpmOAEntryService{
@Override
public BpmOAEntryDO getEntryByOpenId(String openId) {
return entryMapper.selectOne(BpmOAEntryDO::getOpenId, openId);
return entryMapper.selectOne(new LambdaQueryWrapperX<BpmOAEntryDO>()
.eq(BpmOAEntryDO::getOpenId, openId)
.eq(BpmOAEntryDO::getResult, BpmProcessInstanceResultEnum.REJECT.getResult()));
}
}