commit
9c32ba400c
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -1,14 +1,25 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("流程任务分配规则的创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmTaskAssignRuleCreateReqVO extends BpmTaskAssignRuleBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "流程模型的编号", required = true, example = "1024")
|
||||
@NotEmpty(message = "流程模型的编号不能为空")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty(value = "流程任务定义的编号", required = true, example = "2048")
|
||||
@NotEmpty(message = "流程任务定义的编号不能为空")
|
||||
private String taskDefinitionKey;
|
||||
|
||||
}
|
||||
|
||||
@ -1,17 +1,29 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("流程任务分配规则的 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmTaskAssignRuleRespVO extends BpmTaskAssignRuleBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务分配规则的编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "流程模型的编号", required = true, example = "2048")
|
||||
private String modelId;
|
||||
|
||||
@ApiModelProperty(value = "流程定义的编号", required = true, example = "4096")
|
||||
private String processDefinitionId;
|
||||
|
||||
@ApiModelProperty(value = "流程任务定义的编号", required = true, example = "2048")
|
||||
private String taskDefinitionKey;
|
||||
@ApiModelProperty(value = "流程任务定义的名字", required = true, example = "关注芋道")
|
||||
private String taskDefinitionName;
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,22 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.rule;
|
||||
|
||||
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.Set;
|
||||
|
||||
@ApiModel("流程任务分配规则的更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmTaskAssignRuleUpdateReqVO extends BpmTaskAssignRuleBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "任务分配规则的编号", required = true, example = "1024")
|
||||
@NotNull(message = "任务分配规则的编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
|
||||
@ -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-05",
|
||||
"type": 1,
|
||||
"reason": "我要请假啦啦啦!"
|
||||
}
|
||||
@ -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)
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.AssertTrue;
|
||||
|
||||
@ApiModel("请假申请创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOALeaveCreateReqVO extends BpmOALeaveBaseVO {
|
||||
|
||||
@AssertTrue(message = "结束时间,需要在开始时间之后")
|
||||
public boolean isEndTimeValid() {
|
||||
return !getEndTime().before(getStartTime());
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
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("请假申请分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOALeavePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "状态", example = "1", notes = "参见 bpm_process_instance_result 枚举")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "请假类型", example = "1", notes = "参见 bpm_oa_type")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "原因", example = "阅读芋道源码", notes = "模糊匹配")
|
||||
private String reason;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "开始申请时间")
|
||||
private Date beginCreateTime;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ApiModelProperty(value = "结束申请时间")
|
||||
private Date endCreateTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
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 static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ApiModel("请假申请 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmOALeaveRespVO extends BpmOALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "请假表单主键", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 bpm_process_instance_result 枚举")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "申请时间", required = true)
|
||||
@NotNull(message = "申请时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "流程id")
|
||||
private String processInstanceId;
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("请假申请创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveCreateReqVO extends OALeaveBaseVO {
|
||||
|
||||
/**
|
||||
* 对应 bpmn 文件 <process> 的 id
|
||||
*/
|
||||
@ApiModelProperty(value = "流程key")
|
||||
private String processKey;
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@ -1,56 +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("请假申请分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeavePageReqVO extends PageParam {
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
@ApiModel("请假申请 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class OALeaveRespVO extends OALeaveBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "请假表单主键", required = true)
|
||||
private Long id;
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmActivityService;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
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.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "流程活动实例")
|
||||
@RestController
|
||||
@RequestMapping("/bpm/activity")
|
||||
@Validated
|
||||
public class BpmActivityController {
|
||||
|
||||
@Resource
|
||||
private BpmActivityService activityService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation(value = "生成指定流程实例的高亮流程图",
|
||||
notes = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成")
|
||||
@ApiImplicitParam(name = "id", value = "流程实例的编号", required = true, dataTypeClass = String.class)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:task:query')")
|
||||
public CommonResult<List<BpmActivityRespVO>> getActivityList(
|
||||
@RequestParam("processInstanceId") String processInstanceId) {
|
||||
return success(activityService.getActivityListByProcessInstanceId(processInstanceId));
|
||||
}
|
||||
|
||||
@GetMapping("/generate-highlight-diagram")
|
||||
@ApiOperation(value = "生成指定流程实例的高亮流程图",
|
||||
notes = "只高亮进行中的任务。不过要注意,该接口暂时没用,通过前端的 ProcessViewer.vue 界面的 highlightDiagram 方法生成")
|
||||
@ApiImplicitParam(name = "id", value = "流程实例的编号", required = true, dataTypeClass = String.class)
|
||||
@PreAuthorize("@ss.hasPermission('bpm:task:query')")
|
||||
public void generateHighlightDiagram(@RequestParam("processInstanceId") String processInstanceId,
|
||||
HttpServletResponse response) throws IOException {
|
||||
byte[] bytes = activityService.generateHighlightDiagram(processInstanceId);
|
||||
ServletUtils.writeAttachment(response, StrUtil.format("流程图-{}.svg", processInstanceId), bytes);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("流程活动的 Response VO")
|
||||
@Data
|
||||
public class BpmActivityRespVO {
|
||||
|
||||
@ApiModelProperty(value = "流程活动的标识", required = true, example = "1024")
|
||||
private String key;
|
||||
@ApiModelProperty(value = "流程活动的类型", required = true, example = "StartEvent")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "流程活动的开始时间", required = true)
|
||||
private Date startTime;
|
||||
@ApiModelProperty(value = "流程活动的结束时间", required = true)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "关联的流程任务的编号", example = "2048", notes = "关联的流程任务,只有 UserTask 等类型才有")
|
||||
private String taskId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("流程实例的 Response VO")
|
||||
@Data
|
||||
public class BpmProcessInstanceRespVO {
|
||||
|
||||
@ApiModelProperty(value = "流程实例的编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "流程名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "流程分类", required = true, notes = "参见 bpm_model_category 数据字典", example = "1")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty(value = "流程实例的状态", required = true, notes = "参见 bpm_process_instance_status", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "流程实例的结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "提交时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", required = true)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "提交的表单值", required = true)
|
||||
private Map<String, Object> formVariables;
|
||||
|
||||
@ApiModelProperty(value = "业务的唯一标识", example = "1", notes = "例如说,请假申请的编号")
|
||||
private String businessKey;
|
||||
|
||||
/**
|
||||
* 发起流程的用户
|
||||
*/
|
||||
private User startUser;
|
||||
|
||||
/**
|
||||
* 流程定义
|
||||
*/
|
||||
private ProcessDefinition processDefinition;
|
||||
|
||||
@ApiModel("用户信息")
|
||||
@Data
|
||||
public static class User {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
private Long deptId;
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "研发部")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
||||
@ApiModel("流程定义信息")
|
||||
@Data
|
||||
public static class ProcessDefinition {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1024")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "表单类型", notes = "参见 bpm_model_form_type 数据字典", example = "1")
|
||||
private Integer formType;
|
||||
@ApiModelProperty(value = "表单编号", example = "1024", notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||
private Long formId;
|
||||
@ApiModelProperty(value = "表单的配置", required = true,
|
||||
notes = "JSON 字符串。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||
private String formConf;
|
||||
@ApiModelProperty(value = "表单项的数组", required = true,
|
||||
notes = "JSON 字符串的数组。在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||
private List<String> formFields;
|
||||
@ApiModelProperty(value = "自定义表单的提交路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/create",
|
||||
notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||
private String formCustomCreatePath;
|
||||
@ApiModelProperty(value = "自定义表单的查看路径,使用 Vue 的路由地址", example = "/bpm/oa/leave/view",
|
||||
notes = "在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空")
|
||||
private String formCustomViewPath;
|
||||
|
||||
@ApiModelProperty(value = "BPMN XML", required = true)
|
||||
private String bpmnXml;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("流程任务的 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO {
|
||||
|
||||
@ApiModelProperty(value = "任务定义的标识", required = true, example = "user-001")
|
||||
private String definitionKey;
|
||||
|
||||
/**
|
||||
* 审核的用户信息
|
||||
*/
|
||||
private User assigneeUser;
|
||||
|
||||
@ApiModel("用户信息")
|
||||
@Data
|
||||
public static class User {
|
||||
|
||||
@ApiModelProperty(value = "用户编号", required = true, example = "1")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
|
||||
private String nickname;
|
||||
|
||||
@ApiModelProperty(value = "部门编号", required = true, example = "1")
|
||||
private Long deptId;
|
||||
@ApiModelProperty(value = "部门名称", required = true, example = "研发部")
|
||||
private String deptName;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import net.bytebuddy.implementation.bind.annotation.Empty;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("流程任务的更新负责人的 Request VO")
|
||||
@Data
|
||||
public class BpmTaskUpdateAssigneeReqVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
@NotEmpty(message = "任务编号不能为空")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "新审批人的用户编号", required = true, example = "2048")
|
||||
@NotNull(message = "新审批人的用户编号不能为空")
|
||||
private Long assigneeUserId;
|
||||
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class TaskHandleVO {
|
||||
|
||||
private Object formObject;
|
||||
|
||||
|
||||
private List<TaskStepVO> historyTask;
|
||||
|
||||
|
||||
private String taskVariable;
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class TaskQueryReqVO {
|
||||
|
||||
private String processKey;
|
||||
|
||||
private String taskId;
|
||||
|
||||
private String businessKey;
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class TaskStepVO {
|
||||
|
||||
private String stepName;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
private String assignee;
|
||||
|
||||
private String comment;
|
||||
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.message;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import org.activiti.api.task.model.Task;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface BpmMessageConvert {
|
||||
|
||||
BpmMessageConvert INSTANCE = Mappers.getMapper(BpmMessageConvert.class);
|
||||
|
||||
default BpmMessageSendWhenTaskCreatedReqDTO convert(ProcessInstance processInstance, SysUserDO startUser, Task task) {
|
||||
BpmMessageSendWhenTaskCreatedReqDTO reqDTO = new BpmMessageSendWhenTaskCreatedReqDTO();
|
||||
copyTo(processInstance, reqDTO);
|
||||
copyTo(startUser, reqDTO);
|
||||
copyTo(task, reqDTO);
|
||||
return reqDTO;
|
||||
}
|
||||
@Mapping(source = "name", target = "processInstanceName")
|
||||
void copyTo(ProcessInstance from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to);
|
||||
@Mappings({
|
||||
@Mapping(source = "id", target = "startUserId"),
|
||||
@Mapping(source = "nickname", target = "startUserNickname")
|
||||
})
|
||||
void copyTo(SysUserDO from, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to);
|
||||
@Mappings({
|
||||
@Mapping(source = "id", target = "taskId"),
|
||||
@Mapping(source = "name", target = "taskName"),
|
||||
@Mapping(source = "assignee", target = "assigneeUserId")
|
||||
})
|
||||
void copyTo(Task task, @MappingTarget BpmMessageSendWhenTaskCreatedReqDTO to);
|
||||
|
||||
default BpmMessageSendWhenProcessInstanceRejectReqDTO convert(ProcessInstance processInstance, String comment) {
|
||||
BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO = new BpmMessageSendWhenProcessInstanceRejectReqDTO();
|
||||
copyTo(processInstance, reqDTO);
|
||||
reqDTO.setComment(comment);
|
||||
return reqDTO;
|
||||
}
|
||||
@Mapping(source = "name", target = "processInstanceName")
|
||||
void copyTo(ProcessInstance from, @MappingTarget BpmMessageSendWhenProcessInstanceRejectReqDTO to);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(source = "id", target = "processInstanceId"),
|
||||
@Mapping(source = "name", target = "processInstanceName"),
|
||||
@Mapping(source = "initiator", target = "startUserId")
|
||||
})
|
||||
BpmMessageSendWhenProcessInstanceApproveReqDTO convert(org.activiti.api.process.model.ProcessInstance processInstance);
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeaveRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 请假申请 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmOALeaveConvert {
|
||||
|
||||
BpmOALeaveConvert INSTANCE = Mappers.getMapper(BpmOALeaveConvert.class);
|
||||
|
||||
BpmOALeaveDO convert(BpmOALeaveCreateReqVO bean);
|
||||
|
||||
BpmOALeaveRespVO convert(BpmOALeaveDO bean);
|
||||
|
||||
List<BpmOALeaveRespVO> convertList(List<BpmOALeaveDO> list);
|
||||
|
||||
PageResult<BpmOALeaveRespVO> convertPage(PageResult<BpmOALeaveDO> page);
|
||||
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
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.framework.common.pojo.PageResult;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 请假申请 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface OALeaveConvert {
|
||||
|
||||
OALeaveConvert INSTANCE = Mappers.getMapper(OALeaveConvert.class);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.activity.BpmActivityRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.history.HistoricActivityInstance;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* BPM 活动 Convert
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmActivityConvert {
|
||||
|
||||
BpmActivityConvert INSTANCE = Mappers.getMapper(BpmActivityConvert.class);
|
||||
|
||||
List<BpmActivityRespVO> convertList(List<HistoricActivityInstance> list);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(source = "activityId", target = "key"),
|
||||
@Mapping(source = "activityType", target = "type")
|
||||
})
|
||||
BpmActivityRespVO convert(HistoricActivityInstance bean);
|
||||
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 请假申请 DO
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@TableName("oa_leave")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OALeaveDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 请假表单主键
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 流程id
|
||||
*/
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 申请人id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
/**
|
||||
* 请假类型
|
||||
*/
|
||||
private String leaveType;
|
||||
/**
|
||||
* 原因
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
private Date applyTime;
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.oa;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.oa.vo.BpmOALeavePageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
|
||||
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<BpmOALeaveDO> {
|
||||
|
||||
default PageResult<BpmOALeaveDO> selectPage(Long userId, BpmOALeavePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmOALeaveDO>()
|
||||
.eqIfPresent(BpmOALeaveDO::getUserId, userId)
|
||||
.eqIfPresent(BpmOALeaveDO::getResult, reqVO.getResult())
|
||||
.eqIfPresent(BpmOALeaveDO::getType, reqVO.getType())
|
||||
.likeIfPresent(BpmOALeaveDO::getReason, reqVO.getReason())
|
||||
.betweenIfPresent(BpmOALeaveDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(BpmOALeaveDO::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") );
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.enums.message;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Bpm 消息的枚举
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BpmMessageEnum {
|
||||
|
||||
PROCESS_INSTANCE_APPROVE("bpm_process_instance_approve"), // 流程任务被审批通过时,发送给申请人
|
||||
PROCESS_INSTANCE_REJECT("bpm_process_instance_reject"), // 流程任务被审批不通过时,发送给申请人
|
||||
TASK_ASSIGNED("bpm_task_assigned"); // 任务被分配时,发送给审批人
|
||||
|
||||
/**
|
||||
* 短信模板的标识
|
||||
*
|
||||
* 关联 {@link SysSmsTemplateDO#getCode()}
|
||||
*/
|
||||
private final String smsCode;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskRuleScriptEnum;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 分配给发起人的一级 Leader 审批的 Script 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskAssignLeaderX1Script extends BpmTaskAssignLeaderAbstractScript {
|
||||
|
||||
@Override
|
||||
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
|
||||
return calculateTaskCandidateUsers(task, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRuleScriptEnum getEnum() {
|
||||
return BpmTaskRuleScriptEnum.LEADER_X1;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskRuleScriptEnum;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 分配给发起人的二级 Leader 审批的 Script 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskAssignLeaderX2Script extends BpmTaskAssignLeaderAbstractScript {
|
||||
|
||||
@Override
|
||||
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
|
||||
return calculateTaskCandidateUsers(task, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRuleScriptEnum getEnum() {
|
||||
return BpmTaskRuleScriptEnum.LEADER_X2;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.definition.BpmTaskRuleScriptEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.behavior.script.BpmTaskAssignScript;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 分配给发起人审批的 Script 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTaskAssignStartUserScript implements BpmTaskAssignScript {
|
||||
|
||||
@Override
|
||||
public Set<Long> calculateTaskCandidateUsers(TaskEntity task) {
|
||||
Long userId = Long.parseLong(task.getProcessInstance().getStartUserId());
|
||||
return SetUtils.asSet(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRuleScriptEnum getEnum() {
|
||||
return BpmTaskRuleScriptEnum.START_USER;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
/**
|
||||
* {@link BpmProcessInstanceResultEvent} 的监听器
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public abstract class BpmProcessInstanceResultEventListener
|
||||
implements ApplicationListener<BpmProcessInstanceResultEvent> {
|
||||
|
||||
@Override
|
||||
public final void onApplicationEvent(BpmProcessInstanceResultEvent event) {
|
||||
if (!StrUtil.equals(event.getProcessDefinitionKey(), getProcessDefinitionKey())) {
|
||||
return;
|
||||
}
|
||||
onEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 返回监听的流程定义 Key
|
||||
*/
|
||||
protected abstract String getProcessDefinitionKey();
|
||||
|
||||
/**
|
||||
* 处理事件
|
||||
*
|
||||
* @param event 事件
|
||||
*/
|
||||
protected abstract void onEvent(BpmProcessInstanceResultEvent event);
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* {@link BpmProcessInstanceResultEvent} 的生产者
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Validated
|
||||
public class BpmProcessInstanceResultEventPublisher {
|
||||
|
||||
private final ApplicationEventPublisher publisher;
|
||||
|
||||
public void sendProcessInstanceResultEvent(@Valid BpmProcessInstanceResultEvent event) {
|
||||
publisher.publishEvent(event);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* BPM 发送流程实例被通过 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class BpmMessageSendWhenProcessInstanceApproveReqDTO {
|
||||
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的编号不能为空")
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 流程实例的名字
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的名字不能为空")
|
||||
private String processInstanceName;
|
||||
@NotNull(message = "发起人的用户编号")
|
||||
private Long startUserId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* BPM 发送流程实例被不通过 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class BpmMessageSendWhenProcessInstanceRejectReqDTO {
|
||||
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的编号不能为空")
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 流程实例的名字
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的名字不能为空")
|
||||
private String processInstanceName;
|
||||
@NotNull(message = "发起人的用户编号")
|
||||
private Long startUserId;
|
||||
|
||||
/**
|
||||
* 不通过理由
|
||||
*/
|
||||
@NotEmpty(message = "不通过理由不能为空")
|
||||
private String comment;
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* BPM 发送任务被分配 Request DTO
|
||||
*/
|
||||
@Data
|
||||
public class BpmMessageSendWhenTaskCreatedReqDTO {
|
||||
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的编号不能为空")
|
||||
private String processInstanceId;
|
||||
/**
|
||||
* 流程实例的名字
|
||||
*/
|
||||
@NotEmpty(message = "流程实例的名字不能为空")
|
||||
private String processInstanceName;
|
||||
@NotEmpty(message = "发起人的用户编号")
|
||||
private String startUserId;
|
||||
@NotEmpty(message = "发起人的昵称")
|
||||
private String startUserNickname;
|
||||
|
||||
/**
|
||||
* 流程任务的编号
|
||||
*/
|
||||
@NotEmpty(message = "流程任务的编号不能为空")
|
||||
private String taskId;
|
||||
/**
|
||||
* 流程任务的名字
|
||||
*/
|
||||
@NotEmpty(message = "流程任务的名字不能为空")
|
||||
private String taskName;
|
||||
|
||||
/**
|
||||
* 审批人的用户编号
|
||||
*/
|
||||
@NotNull(message = "审批人的用户编号不能为空")
|
||||
private Long assigneeUserId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.message.impl;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.message.BpmMessageEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.BpmMessageService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.service.sms.SysSmsCoreService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* BPM 消息 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class BpmMessageServiceImpl implements BpmMessageService {
|
||||
|
||||
@Resource
|
||||
private SysSmsCoreService smsCoreService;
|
||||
|
||||
@Value("${yudao.url.admin-ui}")
|
||||
private String adminUiUrl;
|
||||
|
||||
@Override
|
||||
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) {
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getStartUserId(),
|
||||
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsCode(), templateParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) {
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
||||
templateParams.put("comment", reqDTO.getComment());
|
||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getStartUserId(),
|
||||
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsCode(), templateParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) {
|
||||
Map<String, Object> templateParams = new HashMap<>();
|
||||
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName());
|
||||
templateParams.put("taskName", reqDTO.getTaskName());
|
||||
templateParams.put("startUserNickname", reqDTO.getStartUserNickname());
|
||||
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId()));
|
||||
smsCoreService.sendSingleSmsToAdmin(null, reqDTO.getAssigneeUserId(),
|
||||
BpmMessageEnum.TASK_ASSIGNED.getSmsCode(), templateParams);
|
||||
}
|
||||
|
||||
private String getProcessInstanceDetailUrl(String taskId) {
|
||||
return adminUiUrl + "bpm/process-instance/detail?id=" + taskId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
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.BpmOALeaveDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 请假申请 Service 接口
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface BpmOALeaveService {
|
||||
|
||||
/**
|
||||
* 创建请假申请
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createLeave(Long userId, @Valid BpmOALeaveCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新请假申请的状态
|
||||
*
|
||||
* @param id 编号
|
||||
* @param result 结果
|
||||
*/
|
||||
void updateLeaveResult(Long id, Integer result);
|
||||
|
||||
/**
|
||||
* 获得请假申请
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 请假申请
|
||||
*/
|
||||
BpmOALeaveDO getLeave(Long id);
|
||||
|
||||
/**
|
||||
* 获得请假申请分页
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 请假申请分页
|
||||
*/
|
||||
PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl;
|
||||
|
||||
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.BpmOALeaveConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.leave.BpmOALeaveDO;
|
||||
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.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.pojo.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
/**
|
||||
* OA 请假申请 Service 实现类
|
||||
*
|
||||
* @author jason
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmOALeaveServiceImpl implements BpmOALeaveService {
|
||||
|
||||
/**
|
||||
* OA 请假对应的流程定义 KEY
|
||||
*/
|
||||
public static final String PROCESS_KEY = "oa_leave";
|
||||
|
||||
@Resource
|
||||
private BpmOALeaveMapper leaveMapper;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createLeave(Long userId, BpmOALeaveCreateReqVO createReqVO) {
|
||||
// 插入 OA 请假单
|
||||
long day = DateUtil.betweenDay(createReqVO.getStartTime(), createReqVO.getEndTime(), false);
|
||||
BpmOALeaveDO leave = BpmOALeaveConvert.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 请假单中
|
||||
leaveMapper.updateById(new BpmOALeaveDO().setId(leave.getId()).setProcessInstanceId(processInstanceId));
|
||||
return leave.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLeaveResult(Long id, Integer result) {
|
||||
leaveMapper.updateById(new BpmOALeaveDO().setId(id).setResult(result));
|
||||
}
|
||||
|
||||
private void validateLeaveExists(Long id) {
|
||||
if (leaveMapper.selectById(id) == null) {
|
||||
throw exception(OA_LEAVE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmOALeaveDO getLeave(Long id) {
|
||||
return leaveMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO) {
|
||||
return leaveMapper.selectPage(userId, pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.oa.listener;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEvent;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti.core.event.BpmProcessInstanceResultEventListener;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.BpmOALeaveService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.oa.impl.BpmOALeaveServiceImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* OA 请假单的结果的监听器实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmOALeaveResultListener extends BpmProcessInstanceResultEventListener {
|
||||
|
||||
@Resource
|
||||
private BpmOALeaveService leaveService;
|
||||
|
||||
@Override
|
||||
protected String getProcessDefinitionKey() {
|
||||
return BpmOALeaveServiceImpl.PROCESS_KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEvent(BpmProcessInstanceResultEvent event) {
|
||||
leaveService.updateLeaveResult(Long.parseLong(event.getBusinessKey()), event.getResult());
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue