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