请假
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
This commit is contained in:
parent
2db74358d5
commit
7db4b89faf
@ -0,0 +1,54 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.qjgl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.qjgl.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.qjgl.QjglDO;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请假管理 Service 接口
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
public interface QjglService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建请假管理
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createQjgl(Long userId, @Valid QjglSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新请假管理
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateQjgl(@Valid QjglSaveReqVO updateReqVO);
|
||||||
|
void updateQjglStatus(Long id, Integer status);
|
||||||
|
/**
|
||||||
|
* 删除请假管理
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteQjgl(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得请假管理
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 请假管理
|
||||||
|
*/
|
||||||
|
QjglDO getQjgl(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得请假管理分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 请假管理分页
|
||||||
|
*/
|
||||||
|
PageResult<QjglDO> getQjglPage(QjglPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.qjgl;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.home.controller.admin.qjgl.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.dataobject.qjgl.QjglDO;
|
||||||
|
import cn.iocoder.yudao.module.home.dal.mysql.qjgl.QjglMapper;
|
||||||
|
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.enums.task.BpmTaskStatusEnum;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.home.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请假管理 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 君风
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class QjglServiceImpl implements QjglService {
|
||||||
|
|
||||||
|
public static final String PROCESS_KEY = "pch-qjgl-001";
|
||||||
|
@Resource
|
||||||
|
private QjglMapper qjglMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BpmProcessInstanceApi processInstanceApi;
|
||||||
|
@Override
|
||||||
|
public Long createQjgl(Long userId,QjglSaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
QjglDO qjgl = BeanUtils.toBean(createReqVO, QjglDO.class)
|
||||||
|
.setUserId(userId).setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||||
|
qjglMapper.insert(qjgl);
|
||||||
|
|
||||||
|
// 发起 BPM 流程
|
||||||
|
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||||
|
String processInstanceId = processInstanceApi.createProcessInstance(userId,
|
||||||
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||||
|
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(qjgl.getId()))
|
||||||
|
.setStartUserSelectAssignees(createReqVO.getStartUserSelectAssignees()));
|
||||||
|
|
||||||
|
// 将工作流的编号,更新到 OA 请假单中
|
||||||
|
qjglMapper.updateById(new QjglDO().setId(qjgl.getId()).setProcessInstanceId(processInstanceId));
|
||||||
|
// 返回
|
||||||
|
return qjgl.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateQjgl(QjglSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateQjglExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
QjglDO updateObj = BeanUtils.toBean(updateReqVO, QjglDO.class);
|
||||||
|
qjglMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void updateQjglStatus(Long id, Integer status) {
|
||||||
|
validateQjglExists(id);
|
||||||
|
qjglMapper.updateById(new QjglDO().setId(id).setStatus(status));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteQjgl(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateQjglExists(id);
|
||||||
|
// 删除
|
||||||
|
qjglMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateQjglExists(Long id) {
|
||||||
|
if (qjglMapper.selectById(id) == null) {
|
||||||
|
throw exception(QJGL_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QjglDO getQjgl(Long id) {
|
||||||
|
return qjglMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<QjglDO> getQjglPage(QjglPageReqVO pageReqVO) {
|
||||||
|
return qjglMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.module.home.service.qjgl.listener;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.home.service.qjgl.QjglService;
|
||||||
|
import cn.iocoder.yudao.module.home.service.qjgl.QjglServiceImpl;
|
||||||
|
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEvent;
|
||||||
|
import cn.iocoder.yudao.module.bpm.event.BpmProcessInstanceStatusEventListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OA 请假单的结果的监听器实现类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class QjglStatusListener extends BpmProcessInstanceStatusEventListener {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QjglService qjglService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getProcessDefinitionKey() {
|
||||||
|
return QjglServiceImpl.PROCESS_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onEvent(BpmProcessInstanceStatusEvent event) {
|
||||||
|
qjglService.updateQjglStatus(Long.parseLong(event.getBusinessKey()), event.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user