bpm 的 OA 请假的示例后端优化~
parent
531629634b
commit
ec978c4441
|
@ -0,0 +1,12 @@
|
|||
### 请求 /bpm/oa/leave/create 接口 => 成功
|
||||
POST {{baseUrl}}/bpm/oa/leave/create
|
||||
Content-Type: application/json
|
||||
tenant-id: 1
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
{
|
||||
"startTime": "2022-03-01",
|
||||
"endTime": "2022-03-03",
|
||||
"type": 1,
|
||||
"reason": "我要请假啦啦啦!"
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
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,用于演示自己存储数据,接入工作流的例子
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Api(tags = "OA 请假申请")
|
||||
@RestController
|
||||
@RequestMapping("/bpm/oa/leave")
|
||||
@Validated
|
||||
public class BpmOALeaveController {
|
||||
|
||||
@Resource
|
||||
private BpmOALeaveService leaveService;
|
||||
|
||||
// TODO @芋艿:权限
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建请求申请")
|
||||
public CommonResult<Long> createLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
|
||||
return success(leaveService.createLeave(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/cancel")
|
||||
@ApiOperation("取消请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
public CommonResult<Boolean> cancelLeave(@RequestParam("id") Long id) {
|
||||
leaveService.cancelLeave(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
public CommonResult<OALeaveRespVO> getLeave(@RequestParam("id") Long id) {
|
||||
OALeaveDO leave = leaveService.getLeave(id);
|
||||
return success(OALeaveConvert.INSTANCE.convert(leave));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得请假申请分页")
|
||||
public CommonResult<PageResult<OALeaveRespVO>> getLeavePage(@Valid OALeavePageReqVO pageVO) {
|
||||
PageResult<OALeaveDO> pageResult = leaveService.getLeavePage(getLoginUserId(), pageVO);
|
||||
return success(OALeaveConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.OALeaveService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
|
||||
@Api(tags = "请假申请")
|
||||
@RestController
|
||||
@RequestMapping("/oa/leave")
|
||||
@Validated
|
||||
public class OALeaveController {
|
||||
|
||||
@Resource
|
||||
private OALeaveService leaveService;
|
||||
|
||||
|
||||
|
||||
@PostMapping("/form-key/create")
|
||||
@ApiOperation("创建外置请假申请")
|
||||
public CommonResult<Long> createFormKeyLeave(@Valid @RequestBody OALeaveCreateReqVO createReqVO) {
|
||||
// processKey 前台传入
|
||||
return success(leaveService.createLeave(createReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/getLeaveApplyMembers")
|
||||
@ApiOperation("获取本人请假申请流程中审批人员,可先检查这些人员是否存在")
|
||||
public CommonResult<OALeaveApplyMembersVO> getLeaveApplyMembers() {
|
||||
return success(leaveService.getLeaveApplyMembers());
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("更新请假申请")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:update')")
|
||||
public CommonResult<Boolean> updateLeave(@Valid @RequestBody OALeaveUpdateReqVO updateReqVO) {
|
||||
leaveService.updateLeave(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:delete')")
|
||||
public CommonResult<Boolean> deleteLeave(@RequestParam("id") Long id) {
|
||||
leaveService.deleteLeave(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得请假申请")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:query')")
|
||||
public CommonResult<OALeaveRespVO> getLeave(@RequestParam("id") Long id) {
|
||||
OALeaveDO leave = leaveService.getLeave(id);
|
||||
return success(OALeaveConvert.INSTANCE.convert(leave));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得请假申请列表")
|
||||
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:query')")
|
||||
public CommonResult<List<OALeaveRespVO>> getLeaveList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<OALeaveDO> list = leaveService.getLeaveList(ids);
|
||||
return success(OALeaveConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得请假申请分页")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:query')")
|
||||
public CommonResult<PageResult<OALeaveRespVO>> getLeavePage(@Valid OALeavePageReqVO pageVO) {
|
||||
//值查询自己申请请假
|
||||
// TODO @芋艿:这里的传值,到底前端搞,还是后端搞。
|
||||
pageVO.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
|
||||
PageResult<OALeaveDO> pageResult = leaveService.getLeavePage(pageVO);
|
||||
return success(OALeaveConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ApiOperation("导出请假申请 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('oa:leave:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportLeaveExcel(@Valid OALeaveExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<OALeaveDO> list = leaveService.getLeaveList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<OALeaveExcelVO> datas = OALeaveConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "请假申请.xls", "数据", OALeaveExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("请假申请审批人员 Response VO")
|
||||
@Data
|
||||
@Builder
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class OALeaveApplyMembersVO {
|
||||
|
||||
@ApiModelProperty(value = "部门的hr")
|
||||
private String hr;
|
||||
|
||||
@ApiModelProperty(value = "部门的项目经理")
|
||||
private String pm;
|
||||
|
||||
@ApiModelProperty(value = "部门的部门经理")
|
||||
private String bm;
|
||||
}
|
|
@ -2,22 +2,31 @@ package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
|||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("请假申请创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveCreateReqVO extends OALeaveBaseVO {
|
||||
public class OALeaveCreateReqVO {
|
||||
|
||||
/**
|
||||
* 对应 bpmn 文件 <process> 的 id
|
||||
*/
|
||||
@ApiModelProperty(value = "流程key")
|
||||
private String processKey;
|
||||
@ApiModelProperty(value = "请假的开始时间", required = true)
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date startTime;
|
||||
@ApiModelProperty(value = "请假的结束时间", required = true)
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型", required = true, example = "1", notes = "参见 bpm_oa_type")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "原因", required = true, example = "阅读芋道源码")
|
||||
private String reason;
|
||||
|
||||
@ApiModelProperty(value = "流程用户任务的变量")
|
||||
private Map<String,Object> taskVariables;
|
||||
}
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 请假申请 Excel VO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Data
|
||||
public class OALeaveExcelVO {
|
||||
|
||||
@ExcelProperty("请假表单主键")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ExcelProperty("状态")
|
||||
private Integer status;
|
||||
|
||||
@ExcelProperty("申请人id")
|
||||
private String userId;
|
||||
|
||||
@ExcelProperty("开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@ExcelProperty("结束时间")
|
||||
private Date endTime;
|
||||
|
||||
@ExcelProperty("请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ExcelProperty("原因")
|
||||
private String reason;
|
||||
|
||||
@ExcelProperty("申请时间")
|
||||
private Date applyTime;
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel(value = "请假申请 Excel 导出 Request VO", description = "参数和 OaLeavePageReqVO 是一致的")
|
||||
@Data
|
||||
public class OALeaveExportReqVO {
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "申请人id")
|
||||
private String userId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始时间")
|
||||
private Date beginStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始时间")
|
||||
private Date endStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始结束时间")
|
||||
private Date beginEndTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束结束时间")
|
||||
private Date endEndTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String reason;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始申请时间")
|
||||
private Date beginApplyTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束申请时间")
|
||||
private Date endApplyTime;
|
||||
|
||||
}
|
|
@ -14,43 +14,21 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
|||
@ToString(callSuper = true)
|
||||
public class OALeavePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
@ApiModelProperty(value = "状态", example = "1", notes = "参见 bpm_process_instance_result 枚举")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "请假类型", example = "1", notes = "参见 bpm_oa_type")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "申请人id")
|
||||
private String userId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始开始时间")
|
||||
private Date beginStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束开始时间")
|
||||
private Date endStartTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始结束时间")
|
||||
private Date beginEndTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束结束时间")
|
||||
private Date endEndTime;
|
||||
|
||||
@ApiModelProperty(value = "请假类型")
|
||||
private String leaveType;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
@ApiModelProperty(value = "原因", example = "阅读芋道源码", notes = "模糊匹配")
|
||||
private String reason;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始申请时间")
|
||||
private Date beginApplyTime;
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束申请时间")
|
||||
private Date endApplyTime;
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("请假申请更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveUpdateReqVO extends OALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "请假表单主键", required = true)
|
||||
@NotNull(message = "请假表单主键不能为空")
|
||||
private Long id;
|
||||
|
||||
// TODO @json:swagger 和 validator 的注解要加哈。
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String comment;
|
||||
|
||||
private Map<String,Object> variables;
|
||||
|
||||
// TODO @芋艿:variables 的作用是啥。
|
||||
|
||||
}
|
|
@ -1,17 +1,14 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveExcelVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveUpdateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请假申请 Convert
|
||||
*
|
||||
|
@ -24,14 +21,10 @@ public interface OALeaveConvert {
|
|||
|
||||
OALeaveDO convert(OALeaveCreateReqVO bean);
|
||||
|
||||
OALeaveDO convert(OALeaveUpdateReqVO bean);
|
||||
|
||||
OALeaveRespVO convert(OALeaveDO bean);
|
||||
|
||||
List<OALeaveRespVO> convertList(List<OALeaveDO> list);
|
||||
|
||||
PageResult<OALeaveRespVO> convertPage(PageResult<OALeaveDO> page);
|
||||
|
||||
List<OALeaveExcelVO> convertList02(List<OALeaveDO> list);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
|
||||
/**
|
||||
* 请假申请 DO
|
||||
* OA 请假申请 DO
|
||||
*
|
||||
* @author 芋艿
|
||||
* {@link #day} 请假天数,目前先简单做。一般是分成请假上午和下午,可以是 1 整天,可以是 0.5 半天
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName("oa_leave")
|
||||
@TableName("bpm_oa_leave")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@ -25,17 +30,20 @@ public class OALeaveDO extends BaseDO {
|
|||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 流程id
|
||||
* 申请人的用户编号
|
||||
*
|
||||
* 关联 {@link SysUserDO#getId()}
|
||||
*/
|
||||
private String processInstanceId;
|
||||
private Long userId;
|
||||
/**
|
||||
* 状态
|
||||
* 请假类型
|
||||
*/
|
||||
private Integer status;
|
||||
@TableField("`type`")
|
||||
private String type;
|
||||
/**
|
||||
* 申请人id
|
||||
* 原因
|
||||
*/
|
||||
private String userId;
|
||||
private String reason;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
|
@ -45,16 +53,22 @@ public class OALeaveDO extends BaseDO {
|
|||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 请假类型
|
||||
* 请假天数
|
||||
*/
|
||||
private String leaveType;
|
||||
private Long day;
|
||||
/**
|
||||
* 原因
|
||||
* 请假的结果
|
||||
*
|
||||
* 枚举 {@link cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum}
|
||||
* 考虑到简单,所以直接复用了 BpmProcessInstanceResultEnum 枚举,也可以自己定义一个枚举哈
|
||||
*/
|
||||
private String reason;
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 申请时间
|
||||
* 对应的流程编号
|
||||
*
|
||||
* 关联 {@link ProcessInstance#getId()}
|
||||
*/
|
||||
private Date applyTime;
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 请假申请 Mapper
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOALeaveMapper extends BaseMapperX<OALeaveDO> {
|
||||
|
||||
default PageResult<OALeaveDO> selectPage(Long userId, OALeavePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<OALeaveDO>()
|
||||
.eqIfPresent(OALeaveDO::getId, userId)
|
||||
.eqIfPresent(OALeaveDO::getResult, reqVO.getResult())
|
||||
.eqIfPresent(OALeaveDO::getType, reqVO.getType())
|
||||
.likeIfPresent(OALeaveDO::getReason, reqVO.getReason())
|
||||
.betweenIfPresent(OALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(OALeaveDO::getId));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeaveExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.OALeavePageReqVO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 请假申请 Mapper
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface OALeaveMapper extends BaseMapperX<OALeaveDO> {
|
||||
|
||||
default PageResult<OALeaveDO> selectPage(OALeavePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<OALeaveDO>()
|
||||
.eqIfPresent("process_instance_id", reqVO.getProcessInstanceId())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.betweenIfPresent("start_time", reqVO.getBeginStartTime(), reqVO.getEndStartTime())
|
||||
.betweenIfPresent("end_time", reqVO.getBeginEndTime(), reqVO.getEndEndTime())
|
||||
.eqIfPresent("leave_type", reqVO.getLeaveType())
|
||||
.eqIfPresent("reason", reqVO.getReason())
|
||||
.betweenIfPresent("apply_time", reqVO.getBeginApplyTime(), reqVO.getEndApplyTime())
|
||||
.orderByDesc("id") );
|
||||
}
|
||||
|
||||
default List<OALeaveDO> selectList(OALeaveExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<OALeaveDO>()
|
||||
.eqIfPresent("process_instance_id", reqVO.getProcessInstanceId())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.eqIfPresent("user_id", reqVO.getUserId())
|
||||
.betweenIfPresent("start_time", reqVO.getBeginStartTime(), reqVO.getEndStartTime())
|
||||
.betweenIfPresent("end_time", reqVO.getBeginEndTime(), reqVO.getEndEndTime())
|
||||
.eqIfPresent("leave_type", reqVO.getLeaveType())
|
||||
.eqIfPresent("reason", reqVO.getReason())
|
||||
.betweenIfPresent("apply_time", reqVO.getBeginApplyTime(), reqVO.getEndApplyTime())
|
||||
.orderByDesc("id") );
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,7 @@ import java.util.Set;
|
|||
*
|
||||
* @author yunlong.li
|
||||
* @author ZJQ
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface BpmProcessDefinitionService {
|
||||
|
||||
|
@ -75,6 +76,14 @@ public interface BpmProcessDefinitionService {
|
|||
*/
|
||||
ProcessDefinition getProcessDefinition2(String id);
|
||||
|
||||
/**
|
||||
* 获得流程定义标识对应的激活的流程定义
|
||||
*
|
||||
* @param key 流程定义的标识
|
||||
* @return 流程定义
|
||||
*/
|
||||
ProcessDefinition getActiveProcessDefinition(String key);
|
||||
|
||||
/**
|
||||
* 获得编号对应的 BpmProcessDefinitionExtDO
|
||||
*
|
||||
|
|
|
@ -42,6 +42,7 @@ import static java.util.Collections.emptyList;
|
|||
*
|
||||
* @author yunlongn
|
||||
* @author ZJQ
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
|
@ -137,14 +138,9 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
|||
return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得流程定义标识对应的激活的流程定义
|
||||
*
|
||||
* @param processDefinitionKey 流程定义的标识
|
||||
* @return 流程定义
|
||||
*/
|
||||
private ProcessDefinition getActiveProcessDefinition(String processDefinitionKey) {
|
||||
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey).active().singleResult();
|
||||
@Override
|
||||
public ProcessDefinition getActiveProcessDefinition(String key) {
|
||||
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).active().singleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 接口
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface BpmOALeaveService {
|
||||
|
||||
/**
|
||||
* 创建请假申请
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createLeave(Long userId, @Valid OALeaveCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 删除请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void cancelLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 请假申请
|
||||
*/
|
||||
OALeaveDO getLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请分页
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 请假申请分页
|
||||
*/
|
||||
PageResult<OALeaveDO> getLeavePage(Long userId, OALeavePageReqVO pageReqVO);
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.OALeaveMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import org.activiti.engine.delegate.DelegateExecution;
|
||||
import org.activiti.engine.delegate.ExecutionListener;
|
||||
|
@ -19,7 +19,7 @@ import java.util.Objects;
|
|||
public class LeaveApplyEndProcessor implements ExecutionListener {
|
||||
|
||||
@Resource
|
||||
private OALeaveMapper leaveMapper;
|
||||
private BpmOALeaveMapper leaveMapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -29,9 +29,9 @@ public class LeaveApplyEndProcessor implements ExecutionListener {
|
|||
OALeaveDO updateDo = new OALeaveDO();
|
||||
updateDo.setId(Long.valueOf(businessKey));
|
||||
if (Objects.equals(approved, true)) {
|
||||
updateDo.setStatus(BpmProcessInstanceResultEnum.APPROVE.getResult());
|
||||
updateDo.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
|
||||
} else {
|
||||
updateDo.setStatus(BpmProcessInstanceResultEnum.REJECT.getResult());
|
||||
updateDo.setResult(BpmProcessInstanceResultEnum.REJECT.getResult());
|
||||
}
|
||||
|
||||
leaveMapper.updateById(updateDo);
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 接口
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
public interface OALeaveService {
|
||||
|
||||
/**
|
||||
* 创建请假申请
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createLeave(@Valid OALeaveCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新请假申请
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateLeave(@Valid OALeaveUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 请假申请
|
||||
*/
|
||||
OALeaveDO getLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 请假申请列表
|
||||
*/
|
||||
List<OALeaveDO> getLeaveList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得请假申请分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 请假申请分页
|
||||
*/
|
||||
PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得请假申请列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 请假申请列表
|
||||
*/
|
||||
List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取本人请假申请流程中审批人员
|
||||
* @return 包括,本人部门的项目经理, 部门经理, HR
|
||||
*/
|
||||
OALeaveApplyMembersVO getLeaveApplyMembers();
|
||||
}
|
|
@ -1,25 +1,16 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.oa.OALeaveConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.OALeaveDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.OALeaveMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa.BpmOALeaveMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.OALeaveService;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysPostDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.dept.SysPostMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user.SysUserMapper;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import org.activiti.api.task.model.Task;
|
||||
import org.activiti.api.task.model.builders.TaskPayloadBuilder;
|
||||
import org.activiti.api.task.runtime.TaskRuntime;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -31,91 +22,56 @@ import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstan
|
|||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 实现类
|
||||
* OA 请假申请 Service 实现类
|
||||
*
|
||||
* @author 芋艿
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class OALeaveServiceImpl implements OALeaveService {
|
||||
public class OALeaveServiceImpl implements BpmOALeaveService {
|
||||
|
||||
/**
|
||||
* OA 请假对应的流程定义 KEY
|
||||
*/
|
||||
private static final String PROCESS_KEY = "oa_leave";
|
||||
|
||||
@Resource
|
||||
private OALeaveMapper leaveMapper;
|
||||
private BpmOALeaveMapper leaveMapper;
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@Resource
|
||||
private org.activiti.engine.TaskService activitiTaskService;
|
||||
|
||||
@Resource
|
||||
private TaskRuntime taskRuntime;
|
||||
|
||||
@Resource
|
||||
private SysPostMapper sysPostMapper;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper sysUserMapper;
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createLeave(OALeaveCreateReqVO createReqVO) {
|
||||
// 插入 OA 请假单
|
||||
OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO);
|
||||
leave.setStatus(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
// TODO @jason:应该是存储 userId??
|
||||
leave.setUserId(SecurityFrameworkUtils.getLoginUser().getUsername());
|
||||
leaveMapper.insert(leave);
|
||||
Date startTime = createReqVO.getStartTime();
|
||||
Date endTime = createReqVO.getEndTime();
|
||||
long day = DateUtil.betweenDay(startTime, endTime, false);
|
||||
public Long createLeave(Long userId, OALeaveCreateReqVO createReqVO) {
|
||||
// TODO 芋道源码
|
||||
// 校验是否超过请假天数的上限;
|
||||
long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false);
|
||||
if (day <= 0) {
|
||||
throw ServiceExceptionUtil.exception(OA_DAY_LEAVE_ERROR);
|
||||
}
|
||||
Map<String, Object> taskVariables = createReqVO.getTaskVariables();
|
||||
taskVariables.put("day", day);
|
||||
// 创建工作流
|
||||
Long id = leave.getId();
|
||||
String businessKey = String.valueOf(id);
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(createReqVO.getProcessKey(), businessKey, taskVariables);
|
||||
String processInstanceId = processInstance.getProcessInstanceId();
|
||||
|
||||
// 插入 OA 请假单
|
||||
OALeaveDO leave = OALeaveConvert.INSTANCE.convert(createReqVO).setUserId(userId).setDay(day)
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
leaveMapper.insert(leave);
|
||||
|
||||
// 发起 BPM 流程
|
||||
Map<String, Object> processInstanceVariables = new HashMap<>();
|
||||
processInstanceVariables.put("day", day);
|
||||
String processInstanceId = processInstanceService.createProcessInstance(userId,
|
||||
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY)
|
||||
.setVariables(processInstanceVariables).setBusinessKey(String.valueOf(leave.getId())));
|
||||
|
||||
// 将工作流的编号,更新到 OA 请假单中
|
||||
OALeaveDO updateDo = new OALeaveDO();
|
||||
updateDo.setProcessInstanceId(processInstanceId);
|
||||
updateDo.setId(id);
|
||||
leaveMapper.updateById(updateDo);
|
||||
return id;
|
||||
leaveMapper.updateById(new OALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId));
|
||||
return leave.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateLeave(OALeaveUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateLeaveExists(updateReqVO.getId());
|
||||
|
||||
final Task task = taskRuntime.task(updateReqVO.getTaskId());
|
||||
activitiTaskService.addComment(task.getId(), task.getProcessInstanceId(), updateReqVO.getComment());
|
||||
Map<String, Object> variables = updateReqVO.getVariables();
|
||||
|
||||
//如何得到部门领导人, 暂时写死
|
||||
variables.put("deptLeader", "admin");
|
||||
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(task.getId())
|
||||
.withVariables(variables)
|
||||
.build());
|
||||
|
||||
// TOTO @芋道源码 貌似 IDEA 会自动加上final(不需要加 final 哈。虽然是不变,但是代码比较少这么去写)
|
||||
Object reApply = variables.get("reApply");
|
||||
if(Objects.equals(reApply, true)){
|
||||
// 更新 表单
|
||||
OALeaveDO updateObj = OALeaveConvert.INSTANCE.convert(updateReqVO);
|
||||
leaveMapper.updateById(updateObj);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @jason:要不,请假不支持删除,只支持取消?
|
||||
@Override
|
||||
public void deleteLeave(Long id) {
|
||||
public void cancelLeave(Long id) {
|
||||
// TODO 需要重新实现
|
||||
// 校验存在
|
||||
this.validateLeaveExists(id);
|
||||
// 删除
|
||||
|
@ -134,62 +90,8 @@ public class OALeaveServiceImpl implements OALeaveService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<OALeaveDO> getLeaveList(Collection<Long> ids) {
|
||||
return leaveMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<OALeaveDO> getLeavePage(OALeavePageReqVO pageReqVO) {
|
||||
return leaveMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OALeaveDO> getLeaveList(OALeaveExportReqVO exportReqVO) {
|
||||
return leaveMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取本人请假申请流程中审批人员
|
||||
* @return 包括,本人部门的项目经理, 部门经理, hr
|
||||
*/
|
||||
@Override
|
||||
public OALeaveApplyMembersVO getLeaveApplyMembers() {
|
||||
final Long id = SecurityFrameworkUtils.getLoginUser().getId();
|
||||
//项目经理
|
||||
//TODO jason 定义enum
|
||||
SysPostDO pmPostDO = sysPostMapper.selectByCode("pm");
|
||||
if (Objects.isNull(pmPostDO)) {
|
||||
throw ServiceExceptionUtil.exception(OA_PM_POST_NOT_EXISTS);
|
||||
}
|
||||
SysUserDO userDO = sysUserMapper.selectById(id);
|
||||
final List<SysUserDO> pmUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), pmPostDO.getId());
|
||||
if (CollUtil.isEmpty(pmUsers)) {
|
||||
throw ServiceExceptionUtil.exception(OA_DEPART_PM_POST_NOT_EXISTS);
|
||||
}
|
||||
|
||||
//部门经理
|
||||
SysPostDO bmPostDO = sysPostMapper.selectByCode("bm");
|
||||
if (Objects.isNull(bmPostDO)) {
|
||||
throw ServiceExceptionUtil.exception(OA_BM_POST_NOT_EXISTS);
|
||||
}
|
||||
|
||||
final List<SysUserDO> bmUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), bmPostDO.getId());
|
||||
if (CollUtil.isEmpty(bmUsers)) {
|
||||
throw ServiceExceptionUtil.exception(OA_DEPART_BM_POST_NOT_EXISTS);
|
||||
}
|
||||
//人事
|
||||
SysPostDO hrPostDO = sysPostMapper.selectByCode("hr");
|
||||
if (Objects.isNull(hrPostDO)) {
|
||||
throw ServiceExceptionUtil.exception(OA_HR_POST_NOT_EXISTS);
|
||||
}
|
||||
final List<SysUserDO> hrUsers = sysUserMapper.selectListByDepartIdAndPostId(userDO.getDeptId(), hrPostDO.getId());
|
||||
if (CollUtil.isEmpty(hrUsers)) {
|
||||
throw ServiceExceptionUtil.exception(OA_DEPART_BM_POST_NOT_EXISTS);
|
||||
}
|
||||
return OALeaveApplyMembersVO.builder().pm(pmUsers.get(0).getUsername())
|
||||
.bm(bmUsers.get(0).getUsername())
|
||||
.hr(hrUsers.get(0).getUsername()).build();
|
||||
public PageResult<OALeaveDO> getLeavePage(Long userId, OALeavePageReqVO pageReqVO) {
|
||||
return leaveMapper.selectPage(userId, pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
|
|||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
|
@ -21,7 +22,7 @@ import java.util.Set;
|
|||
public interface BpmProcessInstanceService {
|
||||
|
||||
/**
|
||||
* 创建流程实例
|
||||
* 创建流程实例(提供给前端)
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
|
@ -29,6 +30,15 @@ public interface BpmProcessInstanceService {
|
|||
*/
|
||||
String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 创建流程实例(提供给内部)
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqDTO 创建信息
|
||||
* @return 实例的编号
|
||||
*/
|
||||
String createProcessInstance(Long userId, @Valid BpmProcessInstanceCreateReqDTO createReqDTO);
|
||||
|
||||
/**
|
||||
* 取消流程实例
|
||||
*
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程实例的创建 Request DTO
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Data
|
||||
public class BpmProcessInstanceCreateReqDTO {
|
||||
|
||||
/**
|
||||
* 流程定义的标识
|
||||
*/
|
||||
@NotEmpty(message = "流程定义的标识不能为空")
|
||||
private String processDefinitionKey;
|
||||
/**
|
||||
* 变量实例
|
||||
*/
|
||||
private Map<String, Object> variables;
|
||||
|
||||
/**
|
||||
* 业务的唯一标识
|
||||
*
|
||||
* 例如说,请假申请的编号。通过它,可以查询到对应的实例
|
||||
*/
|
||||
@NotEmpty(message = "业务的唯一标识")
|
||||
private String businessKey;
|
||||
}
|
|
@ -16,6 +16,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDef
|
|||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.dto.BpmProcessInstanceCreateReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.service.dept.SysDeptService;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
||||
|
@ -81,8 +82,23 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createProcessInstance(Long userId, BpmProcessInstanceCreateReqVO createReqVO) {
|
||||
// 校验流程定义
|
||||
// 获得流程定义
|
||||
ProcessDefinition definition = processDefinitionService.getProcessDefinition(createReqVO.getProcessDefinitionId());
|
||||
// 发起流程
|
||||
return createProcessInstance0(userId, definition, createReqVO.getVariables(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createProcessInstance(Long userId, BpmProcessInstanceCreateReqDTO createReqDTO) {
|
||||
// 获得流程定义
|
||||
ProcessDefinition definition = processDefinitionService.getActiveProcessDefinition(createReqDTO.getProcessDefinitionKey());
|
||||
// 发起流程
|
||||
return createProcessInstance0(userId, definition, createReqDTO.getVariables(), createReqDTO.getBusinessKey());
|
||||
}
|
||||
|
||||
private String createProcessInstance0(Long userId, ProcessDefinition definition,
|
||||
Map<String, Object> variables, String businessKey) {
|
||||
// 校验流程定义
|
||||
if (definition == null) {
|
||||
throw exception(PROCESS_DEFINITION_NOT_EXISTS);
|
||||
}
|
||||
|
@ -91,14 +107,13 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||
}
|
||||
|
||||
// 创建流程实例
|
||||
Map<String, Object> variables = createReqVO.getVariables();
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceById(createReqVO.getProcessDefinitionId(), variables);
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceById(definition.getId(), businessKey, variables);
|
||||
// 设置流程名字
|
||||
runtimeService.setProcessInstanceName(instance.getId(), definition.getName());
|
||||
|
||||
// 补全流程实例的拓展表
|
||||
processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO().setProcessInstanceId(instance.getId())
|
||||
.setFormVariables(createReqVO.getVariables()));
|
||||
.setFormVariables(variables));
|
||||
|
||||
// 添加初始的评论 TODO 芋艿:在思考下
|
||||
// Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult();
|
||||
|
|
Loading…
Reference in New Issue