
24 changed files with 1292 additions and 205 deletions
@ -0,0 +1,40 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author XuanXuan |
|||
* @date 2021/3/28 15:50 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
/*@NoArgsConstructor |
|||
@AllArgsConstructor*/ |
|||
public class FlowCommentDto implements Serializable { |
|||
public FlowCommentDto() { |
|||
} |
|||
|
|||
public FlowCommentDto(String type, String comment) { |
|||
this.type = type; |
|||
this.comment = comment; |
|||
} |
|||
|
|||
/** |
|||
* |
|||
*/ |
|||
private static final long serialVersionUID = 1929734226858491967L; |
|||
|
|||
/** |
|||
* 意见类别 1正常(同意)意见 2退回意见 3 驳回意见 4 委派意见 5 转办意见 6 终止流程 7 撤回流程 |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 意见内容 |
|||
*/ |
|||
private String comment; |
|||
|
|||
} |
@ -0,0 +1,98 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* <p>工作流任务<p> |
|||
* |
|||
* @author XuanXuan |
|||
* @date 2021-04-03 |
|||
*/ |
|||
@ApiModel("工作流任务相关-返回参数") |
|||
@Data |
|||
public class FlowTask extends BaseEntity implements Serializable { |
|||
|
|||
@ApiModelProperty("任务编号") |
|||
private String taskId; |
|||
|
|||
@ApiModelProperty("任务名称") |
|||
private String taskName; |
|||
|
|||
@ApiModelProperty("任务Key") |
|||
private String taskDefKey; |
|||
|
|||
@ApiModelProperty("任务执行人Id") |
|||
private Long assigneeId; |
|||
|
|||
@ApiModelProperty("部门名称") |
|||
private String deptName; |
|||
|
|||
@ApiModelProperty("流程发起人部门名称") |
|||
private String startDeptName; |
|||
|
|||
@ApiModelProperty("任务执行人名称") |
|||
private String assigneeName; |
|||
|
|||
@ApiModelProperty("任务执行人头像") |
|||
private String assigneeHeadImage; |
|||
|
|||
@ApiModelProperty("流程发起人Id") |
|||
private String startUserId; |
|||
|
|||
@ApiModelProperty("流程发起人名称") |
|||
private String startUserName; |
|||
|
|||
@ApiModelProperty("流程类型") |
|||
private String category; |
|||
|
|||
@ApiModelProperty("流程变量信息") |
|||
private Object procVars; |
|||
|
|||
@ApiModelProperty("局部变量信息") |
|||
private Object taskLocalVars; |
|||
|
|||
@ApiModelProperty("流程部署编号") |
|||
private String deployId; |
|||
|
|||
@ApiModelProperty("流程ID") |
|||
private String procDefId; |
|||
|
|||
@ApiModelProperty("流程key") |
|||
private String procDefKey; |
|||
|
|||
@ApiModelProperty("流程定义名称") |
|||
private String procDefName; |
|||
|
|||
@ApiModelProperty("流程定义内置使用版本") |
|||
private int procDefVersion; |
|||
|
|||
@ApiModelProperty("流程实例ID") |
|||
private String procInsId; |
|||
|
|||
@ApiModelProperty("历史流程实例ID") |
|||
private String hisProcInsId; |
|||
|
|||
@ApiModelProperty("任务耗时") |
|||
private String duration; |
|||
|
|||
@ApiModelProperty("任务意见") |
|||
private FlowCommentDto comment = new FlowCommentDto(); |
|||
|
|||
@ApiModelProperty("候选执行人") |
|||
private String candidate; |
|||
|
|||
@ApiModelProperty("任务创建时间") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date createTime; |
|||
|
|||
@ApiModelProperty("任务完成时间") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date finishTime; |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @author hanweijia |
|||
* @date 2021/11/06 13:53 |
|||
* @description |
|||
*/ |
|||
@Data |
|||
public class FlowTaskQuery implements Query { |
|||
private static final long serialVersionUID = -7395299971899690002L; |
|||
@ApiModelProperty(value = "用户sid", required = true) |
|||
private String userSid; |
|||
@ApiModelProperty(value = "zd", required = true) |
|||
private String zd; |
|||
@ApiModelProperty(value = "days", required = true) |
|||
private String days; |
|||
|
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* <p>流程任务<p> |
|||
* |
|||
* @author XuanXuan |
|||
* @date 2021-04-03 |
|||
*/ |
|||
@ApiModel("工作流任务相关--请求参数") |
|||
@Data |
|||
public class FlowTaskVo { |
|||
|
|||
@ApiModelProperty("任务Id") |
|||
private String taskId; |
|||
|
|||
@ApiModelProperty("用户Id") |
|||
private String userId; |
|||
@ApiModelProperty("用户Sid") |
|||
private String userSid; |
|||
|
|||
@ApiModelProperty("任务意见") |
|||
private String comment; |
|||
|
|||
@ApiModelProperty("流程实例Id") |
|||
private String instanceId; |
|||
|
|||
@ApiModelProperty("节点") |
|||
private String targetKey; |
|||
|
|||
@ApiModelProperty("流程变量信息") |
|||
private Map<String, Object> values=new HashMap<>(); |
|||
|
|||
@ApiModelProperty("审批人") |
|||
private String assignee; |
|||
|
|||
@ApiModelProperty("候选人") |
|||
private List<String> candidateUsers=new ArrayList<>(); |
|||
|
|||
@ApiModelProperty("审批组") |
|||
private List<String> candidateGroups=new ArrayList<>(); |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.yxt.common.core.domain.BaseEntity; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class Flowable extends BaseEntity { |
|||
} |
@ -0,0 +1,37 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class FlowableFallback implements FlowableFeign { |
|||
@Override |
|||
public ResultBean businessStart(String procDefId, String userSid, Map<String, Object> variables) { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean processPagerList(Integer pageNum, Integer pageSize) { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean stopProcess(FlowTaskVo flowTaskVo) { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean deleteProcess(String procInsId) { |
|||
return null; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,76 @@ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Api(tags = "Flowable") |
|||
@FeignClient( |
|||
contextId = "anrui-flowable-Flowable", |
|||
name = "anrui-flowable", |
|||
path = "v1/flow", |
|||
fallback = FlowableFallback.class) |
|||
public interface FlowableFeign { |
|||
/** |
|||
* 业务系统发起流程申请 |
|||
* |
|||
* @param procDefId 流程定义id |
|||
* @param userSid 用户sid |
|||
* @param variables form参数 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/businessStart/{procDefId}/{userSid}") |
|||
public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, |
|||
@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables); |
|||
|
|||
/** |
|||
* 流程定义列表 一般业务中不需要查询该列表 |
|||
* |
|||
* @param pageNum 页数 |
|||
* @param pageSize 容量 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/processPagerList/{userSid}") |
|||
public ResultBean processPagerList(@ApiParam(value = "当前页码", required = true) @RequestParam("pageNum") Integer pageNum, |
|||
@ApiParam(value = "每页条数", required = true) @RequestParam("pageSize") Integer pageSize); |
|||
|
|||
/** |
|||
* 我的流程 我发起的流程 |
|||
* |
|||
* @param userSid 用户sid |
|||
* @param taskQueryPagerQuery 查询参数 |
|||
* @return |
|||
*/ |
|||
@PostMapping("/myprocess/{userSid}") |
|||
public ResultBean myprocess(@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody PagerQuery<FlowTaskQuery> taskQueryPagerQuery); |
|||
|
|||
/** |
|||
* 取消申请 |
|||
* |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
@ApiOperation(value = "取消申请") |
|||
@PostMapping(value = "/task/stopProcess") |
|||
@ResponseBody |
|||
ResultBean stopProcess(@ApiParam(value = "工作流任务相关--请求参数") @RequestBody FlowTaskVo flowTaskVo); |
|||
|
|||
/** |
|||
* 删除流程实例 |
|||
* |
|||
* @param procInsId 流程实例id |
|||
* @return |
|||
*/ |
|||
@ApiOperation(value = "删除流程实例") |
|||
@DeleteMapping(value = "/task/deleteProcess/{procInsId}") |
|||
@ResponseBody |
|||
ResultBean deleteProcess(@ApiParam(value = "流程实例id") @PathVariable(value = "procInsId") String procInsId); |
|||
} |
@ -0,0 +1,90 @@ |
|||
/********************************************************* |
|||
********************************************************* |
|||
******************** ******************* |
|||
************* ************ |
|||
******* _oo0oo_ ******* |
|||
*** o8888888o *** |
|||
* 88" . "88 * |
|||
* (| -_- |) * |
|||
* 0\ = /0 * |
|||
* ___/`---'\___ * |
|||
* .' \\| |// '. *
|
|||
* / \\||| : |||// \ *
|
|||
* / _||||| -:- |||||- \ * |
|||
* | | \\\ - /// | | *
|
|||
* | \_| ''\---/'' |_/ | * |
|||
* \ .-\__ '-' ___/-. / * |
|||
* ___'. .' /--.--\ `. .'___ * |
|||
* ."" '< `.___\_<|>_/___.' >' "". * |
|||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
|||
* \ \ `_. \_ __\ /__ _/ .-` / / * |
|||
* =====`-.____`.___ \_____/___.-`___.-'===== * |
|||
* `=---=' * |
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
|||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__********* |
|||
*********************************************************/ |
|||
package com.yxt.anrui.flowable.api.flow; |
|||
|
|||
import com.yxt.common.core.query.Query; |
|||
|
|||
/** |
|||
* Project: anrui-parent <br/> |
|||
* File: TaskQuery.java <br/> |
|||
* Class: com.yxt.anrui.portal.biz.flow.TaskQuery <br/> |
|||
* Description: <描述类的功能>. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021/10/27 下午3:36 <br/> |
|||
* |
|||
* @author popo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
public class TaskQuery implements Query { |
|||
|
|||
private String userSid; |
|||
private String days; |
|||
private String zd1; |
|||
private String processDefinitionId; |
|||
private String startTime; |
|||
|
|||
public String getZd1() { |
|||
return zd1; |
|||
} |
|||
|
|||
public void setZd1(String zd1) { |
|||
this.zd1 = zd1; |
|||
} |
|||
|
|||
public String getProcessDefinitionId() { |
|||
return processDefinitionId; |
|||
} |
|||
|
|||
public void setProcessDefinitionId(String processDefinitionId) { |
|||
this.processDefinitionId = processDefinitionId; |
|||
} |
|||
|
|||
public String getUserSid() { |
|||
return userSid; |
|||
} |
|||
|
|||
public void setUserSid(String userSid) { |
|||
this.userSid = userSid; |
|||
} |
|||
|
|||
public String getDays() { |
|||
return days; |
|||
} |
|||
|
|||
public void setDays(String days) { |
|||
this.days = days; |
|||
} |
|||
|
|||
public String getStartTime() { |
|||
return startTime; |
|||
} |
|||
|
|||
public void setStartTime(String startTime) { |
|||
this.startTime = startTime; |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
package com.yxt.anrui.flowable.biz.flow; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.yxt.anrui.flowable.api.flow.Flowable; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Mapper |
|||
public interface FlowableMapper extends BaseMapper<Flowable> { |
|||
void insetFlowableTask(Map<String,Object> params); |
|||
} |
@ -0,0 +1,59 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.yxt.anrui.flowable.biz.flow.FlowableMapper"> |
|||
<insert id="insetFlowableTask" parameterType="com.yxt.anrui.flowable.api.flow.Flowable"> |
|||
insert into `act_ru_task` ( `days`, `zd`,initiator,outcome) |
|||
VALUES |
|||
( |
|||
#{days,jdbcType=VARCHAR}, |
|||
#{zd,jdbcType=VARCHAR} |
|||
#{initiator,jdbcType=VARCHAR} |
|||
#{outcome,jdbcType=VARCHAR} |
|||
) |
|||
</insert> |
|||
<!-- |
|||
<insert id="insetFlowableTask"> |
|||
insert into `act_ru_task` (`REV`, `EXECUTION_ID`, `PROC_INST_ID`, `PROC_DEF_ID`, |
|||
`TASK_DEF_ID`, `SCOPE_ID`, `SUB_SCOPE_ID`, `SCOPE_TYPE`, `SCOPE_DEFINITION_ID`, |
|||
`PROPAGATED_STAGE_INST_ID`, `NAME`, `PARENT_TASK_ID`, `DESCRIPTION`, |
|||
`TASK_DEF_KEY`, `OWNER`, `ASSIGNEE`, `DELEGATION`, `PRIORITY`, |
|||
`CREATE_TIME`, `DUE_DATE`, `CATEGORY`, `SUSPENSION_STATE`, `TENANT_ID`, |
|||
`FORM_KEY`, `CLAIM_TIME`, `IS_COUNT_ENABLED`, `VAR_COUNT`, `ID_LINK_COUNT`, |
|||
`SUB_TASK_COUNT`, `days`, `reason`) |
|||
VALUES |
|||
( |
|||
#{item.modelSid,jdbcType=VARCHAR},<!–sid–> |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR}, |
|||
#{item.modelSid,jdbcType=VARCHAR} |
|||
) |
|||
</insert> |
|||
--> |
|||
</mapper> |
@ -0,0 +1,92 @@ |
|||
/********************************************************* |
|||
********************************************************* |
|||
******************** ******************* |
|||
************* ************ |
|||
******* _oo0oo_ ******* |
|||
*** o8888888o *** |
|||
* 88" . "88 * |
|||
* (| -_- |) * |
|||
* 0\ = /0 * |
|||
* ___/`---'\___ * |
|||
* .' \\| |// '. *
|
|||
* / \\||| : |||// \ *
|
|||
* / _||||| -:- |||||- \ * |
|||
* | | \\\ - /// | | *
|
|||
* | \_| ''\---/'' |_/ | * |
|||
* \ .-\__ '-' ___/-. / * |
|||
* ___'. .' /--.--\ `. .'___ * |
|||
* ."" '< `.___\_<|>_/___.' >' "". * |
|||
* | | : `- \`.;`\ _ /`;.`/ - ` : | | * |
|||
* \ \ `_. \_ __\ /__ _/ .-` / / * |
|||
* =====`-.____`.___ \_____/___.-`___.-'===== * |
|||
* `=---=' * |
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * |
|||
*********__佛祖保佑__永无BUG__验收通过__钞票多多__********* |
|||
*********************************************************/ |
|||
package com.yxt.anrui.flowable.biz.flow; |
|||
|
|||
|
|||
import com.yxt.anrui.flowable.api.flow.FlowTaskQuery; |
|||
import com.yxt.anrui.flowable.api.flow.FlowTaskVo; |
|||
import com.yxt.anrui.flowable.api.flow.FlowableFeign; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiParam; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* Project: anrui-parent <br/> |
|||
* File: FlowableRest.java <br/> |
|||
* Class: com.yxt.anrui.portal.biz.flow.FlowableRest <br/> |
|||
* Description: <描述类的功能>. <br/> |
|||
* Copyright: Copyright (c) 2011 <br/> |
|||
* Company: https://gitee.com/liuzp315 <br/>
|
|||
* Makedate: 2021/10/23 上午11:13 <br/> |
|||
* |
|||
* @author popo |
|||
* @version 1.0 |
|||
* @since 1.0 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("v1/flow") |
|||
@Api(tags = "业务系统中业务和工作流相关操作") |
|||
public class FlowableRest implements FlowableFeign { |
|||
|
|||
@Autowired |
|||
private FlowableService flowableService; |
|||
|
|||
@Override |
|||
public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, |
|||
@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { |
|||
return flowableService.businessStart(procDefId, userSid, variables); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean processPagerList(@ApiParam(value = "当前页码", required = true) @RequestParam("pageNum") Integer pageNum, |
|||
@ApiParam(value = "每页条数", required = true) @RequestParam("pageSize") Integer pageSize) { |
|||
return flowableService.processPagerList(pageNum, pageSize); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean myprocess(@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody PagerQuery<FlowTaskQuery> taskQueryPagerQuery) { |
|||
return flowableService.myprocess(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean stopProcess(FlowTaskVo flowTaskVo) { |
|||
flowableService.stopProcess(flowTaskVo); |
|||
return ResultBean.fireSuccess(); |
|||
} |
|||
|
|||
@Override |
|||
public ResultBean deleteProcess(String procInsId) { |
|||
flowableService.deleteProcess(procInsId); |
|||
return ResultBean.fireSuccess(); |
|||
} |
|||
} |
@ -0,0 +1,265 @@ |
|||
package com.yxt.anrui.flowable.biz.flow; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import com.yxt.anrui.flowable.api.flow.FlowTaskQuery; |
|||
import com.yxt.anrui.flowable.api.flow.FlowTaskVo; |
|||
import com.yxt.anrui.flowable.api.flow.Flowable; |
|||
import com.yxt.anrui.flowable.api.flow.TaskQuery; |
|||
import com.yxt.anrui.flowable.api.flowtask.FlowTask; |
|||
import com.yxt.anrui.flowable.api.flowtask.LatestTaskVo; |
|||
import com.yxt.anrui.flowable.api.utils.ProcessStateEnum; |
|||
import com.yxt.anrui.flowable.biz.flowdefinition.FlowDefinitionService; |
|||
import com.yxt.anrui.flowable.biz.flowtask.FlowTaskService; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskParam; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessTaskQuery; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; |
|||
import com.yxt.anrui.flowable.sqloperationsymbol.SQLOperationSymbol; |
|||
import com.yxt.common.base.service.MybatisBaseService; |
|||
import com.yxt.common.base.utils.StringUtils; |
|||
import com.yxt.common.core.query.PagerQuery; |
|||
import com.yxt.common.core.result.ResultBean; |
|||
import io.swagger.annotations.ApiParam; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class FlowableService extends MybatisBaseService<FlowableMapper, Flowable> { |
|||
@Autowired |
|||
private FlowDefinitionService flowDefinitionService; |
|||
@Autowired |
|||
private FlowTaskService flowTaskService; |
|||
|
|||
public ResultBean businessStart(@ApiParam(value = "流程定义id") @PathVariable(value = "procDefId") String procDefId, |
|||
@ApiParam(value = "用户sid") @PathVariable(value = "userSid") String userSid, |
|||
@ApiParam(value = "变量集合,json对象") @RequestBody Map<String, Object> variables) { |
|||
|
|||
variables.put("procDefId", procDefId); |
|||
variables.put("userSid", userSid); |
|||
BusinessVariables bv = BusinessVariables.builder().build(); |
|||
bv.setDetailUrl(""); |
|||
bv.setHandleUrl(""); |
|||
bv.setFormVariables(variables); |
|||
ResultBean<FlowTask> rb = flowDefinitionService.businessStart(bv); |
|||
if (!rb.getSuccess()) { |
|||
return rb; |
|||
} |
|||
String procId = rb.getData().getProcInsId(); |
|||
List<LatestTaskVo> list = flowTaskService.getLatestTasks(procId); |
|||
String nodeState = list.get(0).getName_(); |
|||
String task_def_key_ = list.get(0).getTask_def_key_(); |
|||
Map<String, String> map = new HashMap<>(); |
|||
map.put("sid", variables.get("businessSid").toString()); |
|||
map.put("nodeState", nodeState); |
|||
map.put("procInsId", rb.getData().getProcInsId()); |
|||
map.put("taskDefKey", task_def_key_); |
|||
return new ResultBean().success().setData(map); |
|||
} |
|||
|
|||
public ResultBean myprocess(String userSid, PagerQuery<FlowTaskQuery> taskQueryPagerQuery) { |
|||
PagerQuery<BusinessTaskQuery> pq = new PagerQuery<>(); |
|||
String days = taskQueryPagerQuery.getParams().getDays(); |
|||
String zd = taskQueryPagerQuery.getParams().getZd(); |
|||
pq.setCurrent(taskQueryPagerQuery.getCurrent()); |
|||
pq.setSize(taskQueryPagerQuery.getSize()); |
|||
BusinessTaskQuery businessTaskQuery = BusinessTaskQuery.create(); |
|||
if (StringUtils.isNotBlank(zd)) { |
|||
BusinessTaskParam businessTaskParam = new BusinessTaskParam(); |
|||
businessTaskParam.setField("zd"); |
|||
businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.LIKE); |
|||
businessTaskParam.setValue(zd); |
|||
businessTaskQuery.add(businessTaskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(days)) { |
|||
BusinessTaskParam businessTaskParam = new BusinessTaskParam(); |
|||
businessTaskParam.setField("days"); |
|||
businessTaskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
businessTaskParam.setValue(days); |
|||
businessTaskQuery.add(businessTaskParam); |
|||
} |
|||
pq.setParams(businessTaskQuery); |
|||
return flowTaskService.businessMyprocessNew(userSid, pq); |
|||
} |
|||
|
|||
public ResultBean processPagerList(Integer pageNum, Integer pageSize) { |
|||
return flowDefinitionService.pagerListNew(pageNum, pageSize); |
|||
} |
|||
|
|||
public ResultBean todoTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
TaskQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return ResultBean.fireFail().setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
|
|||
String days = params.getDays(); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String startTime = params.getStartTime(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(days)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("zd1"); |
|||
taskParam.setValue(days); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startTime)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startTime"); |
|||
taskParam.setValue(startTime); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskService.businessTodoListNew(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
public ResultBean doneTaskList(String userSid, PagerQuery<TaskQuery> pQuery) { |
|||
TaskQuery params = pQuery.getParams(); |
|||
if (StringUtils.isBlank(userSid)) { |
|||
return ResultBean.fireFail().setMsg("用户SID为空"); |
|||
} |
|||
PagerQuery<BusinessTaskQuery> taskQueryPagerQuery = new PagerQuery<>(); |
|||
taskQueryPagerQuery.setCurrent(pQuery.getCurrent()).setSize(pQuery.getSize()); |
|||
String zd1 = params.getZd1(); |
|||
String processDefinitionId = params.getProcessDefinitionId(); |
|||
String startTime = params.getStartTime(); |
|||
BusinessTaskQuery taskQuery = new BusinessTaskQuery(); |
|||
List<BusinessTaskParam> taskParamList = new ArrayList<>(); |
|||
if (StringUtils.isNotBlank(zd1)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("zd1"); |
|||
taskParam.setValue(zd1); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(startTime)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("startTime"); |
|||
taskParam.setValue(startTime); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.EQUAL); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
if (StringUtils.isNotBlank(processDefinitionId)) { |
|||
BusinessTaskParam taskParam = new BusinessTaskParam(); |
|||
taskParam.setField("processDefinitionId"); |
|||
taskParam.setSqlOperationSymbol(SQLOperationSymbol.NONE); |
|||
taskParam.setValue(processDefinitionId); |
|||
taskParamList.add(taskParam); |
|||
} |
|||
taskQuery.setFields(taskParamList); |
|||
taskQueryPagerQuery.setParams(taskQuery); |
|||
return flowTaskService.businessDoneListNew(userSid, taskQueryPagerQuery); |
|||
} |
|||
|
|||
/** |
|||
* 取消 |
|||
* |
|||
* @param variables |
|||
* @return |
|||
*/ |
|||
public ResultBean complete(Map<String, Object> variables) { |
|||
BusinessVariables bv = BusinessVariables.builder().build(); |
|||
bv.setDetailUrl(""); |
|||
bv.setHandleUrl(""); |
|||
bv.setFormVariables(variables); |
|||
ResultBean<FlowTask> resultBean = flowTaskService.businessComplete(bv); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
String nodeState = ""; |
|||
if (resultBean.getData() != null) { |
|||
ResultBean<List<LatestTaskVo>> listResultBean = flowTaskService.getLatestTasksNew(resultBean.getData().getProcInsId()); |
|||
if (listResultBean.getSuccess() && listResultBean.getData() != null && listResultBean.getData().size() != 0) { |
|||
nodeState = listResultBean.getData().get(0).getName_(); |
|||
} else { |
|||
nodeState = ProcessStateEnum.FINISHED.getStateName(); |
|||
} |
|||
} |
|||
Map<String, String> map = new HashMap<>(); |
|||
map.put("nodeState", nodeState); |
|||
return new ResultBean().success().setData(map); |
|||
} |
|||
|
|||
/** |
|||
* 撤回 |
|||
* |
|||
* @param userSid |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
public ResultBean revokeProcess(String userSid, FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
fl.setUserSid(userSid); |
|||
ResultBean<List<LatestTaskVo>> resultBean = flowTaskService.revokeProcess(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
String nodeState = resultBean.getData().get(0).getName_(); |
|||
Map<String, String> map = new HashMap<>(); |
|||
map.put("nodeState", nodeState); |
|||
return new ResultBean().success().setData(map); |
|||
} |
|||
|
|||
public ResultBean flowRecord(String procInsId, String deployId) { |
|||
return flowTaskService.businessFlowRecord(procInsId, deployId); |
|||
} |
|||
|
|||
public ResultBean taskReject(FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
ResultBean<List<LatestTaskVo>> resultBean = flowTaskService.taskReject(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
String nodeState = resultBean.getData().get(0).getName_(); |
|||
Map<String, String> map = new HashMap<>(); |
|||
map.put("nodeState", nodeState); |
|||
return new ResultBean().success().setData(map); |
|||
} |
|||
|
|||
/** |
|||
* 终止流程 |
|||
* |
|||
* @param flowTaskVo |
|||
* @return |
|||
*/ |
|||
public ResultBean breakProcess(FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
ResultBean resultBean = flowTaskService.breakProcess(fl); |
|||
if (!resultBean.getSuccess()) { |
|||
return resultBean; |
|||
} |
|||
Map<String, String> map = new HashMap<>(); |
|||
map.put("nodeState", String.valueOf(resultBean.getData())); |
|||
return resultBean.success().setData(map); |
|||
} |
|||
|
|||
public void stopProcess(FlowTaskVo flowTaskVo) { |
|||
com.yxt.anrui.flowable.api.flowtask.FlowTaskVo fl = new com.yxt.anrui.flowable.api.flowtask.FlowTaskVo(); |
|||
BeanUtil.copyProperties(flowTaskVo, fl); |
|||
flowTaskService.stopProcess(flowTaskVo.getUserSid(), fl); |
|||
} |
|||
|
|||
public void deleteProcess(String procInsId) { |
|||
flowTaskService.deleteProcessNew(procInsId); |
|||
} |
|||
} |
@ -1,4 +1,22 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
|||
<mapper namespace="com.yxt.anrui.scm.biz.scmvehiclereturn.ScmVehicleReturnMapper"> |
|||
<select id="pagerList" resultType="com.yxt.anrui.scm.api.scmvehiclereturn.ScmVehicleReturnVo"> |
|||
select sr.sid, |
|||
sr.applicationCode, |
|||
sr.applicationName, |
|||
sr.modifyTime, |
|||
sr.reason, |
|||
(select count(*) from scm_vehicle_return_details sd where sd.vehicleOutSid = sr.sid) as num |
|||
from scm_vehicle_return sr |
|||
</select> |
|||
|
|||
<update id="modifyFlowState"> |
|||
update scm_vehicle_return |
|||
set procDefId=#{procDefId}, |
|||
nodeState=#{nodeState}, |
|||
procInstSid=#{procInstSid}, |
|||
nodeSid=#{nodeSid} |
|||
where sid = #{businessSid} |
|||
</update> |
|||
</mapper> |
Loading…
Reference in new issue