diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowCommentDto.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowCommentDto.java new file mode 100644 index 0000000000..a8fd9f6d19 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowCommentDto.java @@ -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; + +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTask.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTask.java new file mode 100644 index 0000000000..f5d0a8f6cd --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTask.java @@ -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; + +/** + *

工作流任务

+ * + * @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; +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskQuery.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskQuery.java new file mode 100644 index 0000000000..bdfb9c4037 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskQuery.java @@ -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; + + +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskVo.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskVo.java new file mode 100644 index 0000000000..e3f83a3238 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowTaskVo.java @@ -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; + +/** + *

流程任务

+ * + * @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 values=new HashMap<>(); + + @ApiModelProperty("审批人") + private String assignee; + + @ApiModelProperty("候选人") + private List candidateUsers=new ArrayList<>(); + + @ApiModelProperty("审批组") + private List candidateGroups=new ArrayList<>(); + +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/Flowable.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/Flowable.java new file mode 100644 index 0000000000..ac33d6abe7 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/Flowable.java @@ -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 { +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFallback.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFallback.java new file mode 100644 index 0000000000..351c8dc900 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFallback.java @@ -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 variables) { + return null; + } + + @Override + public ResultBean processPagerList(Integer pageNum, Integer pageSize) { + return null; + } + + @Override + public ResultBean myprocess(String userSid, PagerQuery taskQueryPagerQuery) { + return null; + } + + @Override + public ResultBean stopProcess(FlowTaskVo flowTaskVo) { + return null; + } + + @Override + public ResultBean deleteProcess(String procInsId) { + return null; + } + + +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFeign.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFeign.java new file mode 100644 index 0000000000..c9e7870250 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/FlowableFeign.java @@ -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 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 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); +} diff --git a/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/TaskQuery.java b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/TaskQuery.java new file mode 100644 index 0000000000..680660d6f2 --- /dev/null +++ b/anrui-flowable/anrui-flowable-api/src/main/java/com/yxt/anrui/flowable/api/flow/TaskQuery.java @@ -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
+ * File: TaskQuery.java
+ * Class: com.yxt.anrui.portal.biz.flow.TaskQuery
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2021/10/27 下午3:36
+ * + * @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; + } +} diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.java new file mode 100644 index 0000000000..24bd590d87 --- /dev/null +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.java @@ -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 { + void insetFlowableTask(Map params); +} diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.xml b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.xml new file mode 100644 index 0000000000..1b4d4fa4c8 --- /dev/null +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableMapper.xml @@ -0,0 +1,59 @@ + + + + + insert into `act_ru_task` ( `days`, `zd`,initiator,outcome) + VALUES + ( + #{days,jdbcType=VARCHAR}, + #{zd,jdbcType=VARCHAR} + #{initiator,jdbcType=VARCHAR} + #{outcome,jdbcType=VARCHAR} + ) + + + \ No newline at end of file diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java new file mode 100644 index 0000000000..c10e82fa06 --- /dev/null +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableRest.java @@ -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
+ * File: FlowableRest.java
+ * Class: com.yxt.anrui.portal.biz.flow.FlowableRest
+ * Description: <描述类的功能>.
+ * Copyright: Copyright (c) 2011
+ * Company: https://gitee.com/liuzp315
+ * Makedate: 2021/10/23 上午11:13
+ * + * @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 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 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(); + } +} diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableService.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableService.java new file mode 100644 index 0000000000..003f6035fc --- /dev/null +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flow/FlowableService.java @@ -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 { + @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 variables) { + + variables.put("procDefId", procDefId); + variables.put("userSid", userSid); + BusinessVariables bv = BusinessVariables.builder().build(); + bv.setDetailUrl(""); + bv.setHandleUrl(""); + bv.setFormVariables(variables); + ResultBean rb = flowDefinitionService.businessStart(bv); + if (!rb.getSuccess()) { + return rb; + } + String procId = rb.getData().getProcInsId(); + List list = flowTaskService.getLatestTasks(procId); + String nodeState = list.get(0).getName_(); + String task_def_key_ = list.get(0).getTask_def_key_(); + Map 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 taskQueryPagerQuery) { + PagerQuery 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 pQuery) { + TaskQuery params = pQuery.getParams(); + if (StringUtils.isBlank(userSid)) { + return ResultBean.fireFail().setMsg("用户SID为空"); + } + PagerQuery 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 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 pQuery) { + TaskQuery params = pQuery.getParams(); + if (StringUtils.isBlank(userSid)) { + return ResultBean.fireFail().setMsg("用户SID为空"); + } + PagerQuery 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 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 variables) { + BusinessVariables bv = BusinessVariables.builder().build(); + bv.setDetailUrl(""); + bv.setHandleUrl(""); + bv.setFormVariables(variables); + ResultBean resultBean = flowTaskService.businessComplete(bv); + if (!resultBean.getSuccess()) { + return resultBean; + } + String nodeState = ""; + if (resultBean.getData() != null) { + ResultBean> 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 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> resultBean = flowTaskService.revokeProcess(fl); + if (!resultBean.getSuccess()) { + return resultBean; + } + String nodeState = resultBean.getData().get(0).getName_(); + Map 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> resultBean = flowTaskService.taskReject(fl); + if (!resultBean.getSuccess()) { + return resultBean; + } + String nodeState = resultBean.getData().get(0).getName_(); + Map 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 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); + } +} diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionRest.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionRest.java index a4345ead12..28bdfa1638 100644 --- a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionRest.java +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionRest.java @@ -1,8 +1,6 @@ package com.yxt.anrui.flowable.biz.flowdefinition; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yxt.anrui.flowable.api.flowdefinition.FlowDefinitionFeign; -import com.yxt.anrui.flowable.api.flowdefinition.FlowDefinitionVo; import com.yxt.anrui.flowable.api.flowdefinition.FlowSaveXmlQuery; import com.yxt.anrui.flowable.api.flowdefinition.SysUser; import com.yxt.anrui.flowable.api.flowtask.FlowTask; @@ -11,7 +9,6 @@ import com.yxt.anrui.portal.api.sysrole.SysRoleFeign; import com.yxt.anrui.portal.api.sysrole.SysRoleVo; import com.yxt.anrui.portal.api.sysuser.SysUserFeign; import com.yxt.anrui.portal.api.sysuser.SysUserVo; -import com.yxt.common.base.utils.StringUtils; import com.yxt.common.core.result.ResultBean; import io.swagger.annotations.Api; import io.swagger.annotations.ApiParam; @@ -76,8 +73,7 @@ public class FlowDefinitionRest implements FlowDefinitionFeign { @Override public ResultBean pagerList(Integer pageNum, Integer pageSize) { - Page pageList = flowDefinitionService.list(pageNum, pageSize); - return ResultBean.fireSuccess().setData(pageList); + return flowDefinitionService.pagerListNew(pageNum, pageSize); } @Override @@ -144,34 +140,6 @@ public class FlowDefinitionRest implements FlowDefinitionFeign { @Override public ResultBean businessStart(@ApiParam(value = "变量集合") @RequestBody BusinessVariables dto) { - ResultBean resultBean= new ResultBean<>(); - Map variables = dto.getFormVariables(); - variables.put("handleUrl",dto.getHandleUrl()); - variables.put("detailUrl",dto.getDetailUrl()); - Object procDefId_obj = variables.get("procDefId"); - Object userSid_obj = variables.get("userSid"); - String procDefId=null; - String userSid=null; - if(procDefId_obj==null){ - return resultBean.fail().setData(new FlowTask()).setMsg("procDefId 不能为空"); - }else{ - procDefId = (String) procDefId_obj; - if(StringUtils.isBlank(procDefId)){ - resultBean.fail().setData(new FlowTask()).setMsg("procDefId 不能为空"); - return resultBean; - } - } - if(userSid_obj==null){ - resultBean.fail().setData(new FlowTask()).setMsg("userSid 不能为空"); - return resultBean; - }else{ - userSid = (String)userSid_obj; - if(StringUtils.isBlank(userSid)){ - resultBean.fail().setData(new FlowTask()).setMsg("userSid 不能为空"); - return resultBean; - } - } - resultBean = flowDefinitionService.businessStartProcessInstanceById(procDefId, userSid, variables); - return resultBean; + return flowDefinitionService.businessStart(dto); } } diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java index d0880c0520..32067a430c 100644 --- a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowdefinition/FlowDefinitionService.java @@ -15,10 +15,12 @@ import com.yxt.anrui.flowable.biz.sysdeployform.SysDeployFormService; import com.yxt.anrui.flowable.common.FlowComment; import com.yxt.anrui.flowable.common.ProcessConstants; import com.yxt.anrui.flowable.factory.FlowServiceFactory; +import com.yxt.anrui.flowable.sqloperationsymbol.BusinessVariables; import com.yxt.anrui.portal.api.sysuser.SysUser; import com.yxt.anrui.portal.api.sysuser.SysUserFeign; import com.yxt.anrui.portal.api.sysuser.SysUserVo; import com.yxt.common.base.utils.JPushServer; +import com.yxt.common.base.utils.StringUtils; import com.yxt.common.core.result.ResultBean; import org.apache.commons.io.IOUtils; import org.flowable.engine.repository.Deployment; @@ -34,7 +36,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.stream.Collectors; @Service public class FlowDefinitionService extends FlowServiceFactory { @@ -43,7 +44,8 @@ public class FlowDefinitionService extends FlowServiceFactory { @Autowired private SysDeployFormService sysDeployFormService; @Autowired - private SysUserFeign sysUserFeign; + private SysUserFeign sysUserFeign; + /** * 导入流程文件 * @@ -63,7 +65,7 @@ public class FlowDefinitionService extends FlowServiceFactory { ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery() .orderByProcessDefinitionKey().asc(); page.setTotal(processDefinitionQuery.count()); - List processDefinitionList = processDefinitionQuery.listPage((pageNum - 1)*pageSize, pageSize); + List processDefinitionList = processDefinitionQuery.listPage((pageNum - 1) * pageSize, pageSize); List dataList = new ArrayList<>(); for (ProcessDefinition processDefinition : processDefinitionList) { @@ -118,6 +120,7 @@ public class FlowDefinitionService extends FlowServiceFactory { String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); return ResultBean.fireSuccess().setData(result); } + /** * 根据流程定义ID启动流程实例 * @@ -145,7 +148,7 @@ public class FlowDefinitionService extends FlowServiceFactory { if (Objects.nonNull(task)) { taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), sysUser.getUserName() + "发起流程申请"); // taskService.setAssignee(task.getId(), sysUser.getUserId().toString()); - taskService.complete(task.getId(), variables,true); + taskService.complete(task.getId(), variables, true); } return ResultBean.fireSuccess().setMsg("流程启动成功"); } catch (Exception e) { @@ -161,11 +164,11 @@ public class FlowDefinitionService extends FlowServiceFactory { * 根据流程定义ID启动流程实例 * * @param procDefId 流程定义Id - * @param userSid 发起人sid + * @param userSid 发起人sid * @param variables 流程变量 * @return */ - public ResultBean businessStartProcessInstanceById(String procDefId,String userSid, Map variables) { + public ResultBean businessStartProcessInstanceById(String procDefId, String userSid, Map variables) { try { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId) .latestVersion().singleResult(); @@ -190,7 +193,7 @@ public class FlowDefinitionService extends FlowServiceFactory { } ResultBean rb = new ResultBean<>(); - FlowTask flowTask=new FlowTask(); + FlowTask flowTask = new FlowTask(); flowTask.setTaskId(task.getId()); flowTask.setTaskName(task.getName()); flowTask.setProcInsId(task.getProcessInstanceId()); @@ -204,6 +207,7 @@ public class FlowDefinitionService extends FlowServiceFactory { /** * 向下一环节待办人发出推送 + * * @param taskId */ private void sendPush(String taskId) { @@ -211,10 +215,47 @@ public class FlowDefinitionService extends FlowServiceFactory { System.out.println(nextTasks.getData()); String assignee = ((HashMap) ((ArrayList) nextTasks.getData()).get(0)).get("assignee").toString(); String name = ((HashMap) ((ArrayList) nextTasks.getData()).get(0)).get("name").toString(); - System.out.println("assignee:"+assignee); + System.out.println("assignee:" + assignee); Integer id = sysUserFeign.fetchBySid(assignee).getData().getId(); - System.out.println("id:"+id); + System.out.println("id:" + id); JPushServer.sendPushAlias(name, name, "msg_type", "系统消息", id.toString()); } + public ResultBean businessStart(BusinessVariables dto) { + ResultBean resultBean = new ResultBean<>(); + Map variables = dto.getFormVariables(); + variables.put("handleUrl", dto.getHandleUrl()); + variables.put("detailUrl", dto.getDetailUrl()); + Object procDefId_obj = variables.get("procDefId"); + Object userSid_obj = variables.get("userSid"); + String procDefId = null; + String userSid = null; + if (procDefId_obj == null) { + return resultBean.fail().setData(new FlowTask()).setMsg("procDefId 不能为空"); + } else { + procDefId = (String) procDefId_obj; + if (StringUtils.isBlank(procDefId)) { + resultBean.fail().setData(new FlowTask()).setMsg("procDefId 不能为空"); + return resultBean; + } + } + if (userSid_obj == null) { + resultBean.fail().setData(new FlowTask()).setMsg("userSid 不能为空"); + return resultBean; + } else { + userSid = (String) userSid_obj; + if (StringUtils.isBlank(userSid)) { + resultBean.fail().setData(new FlowTask()).setMsg("userSid 不能为空"); + return resultBean; + } + } + resultBean = businessStartProcessInstanceById(procDefId, userSid, variables); + return resultBean; + } + + public ResultBean pagerListNew(Integer pageNum, Integer pageSize) { + Page pageList = list(pageNum, pageSize); + return ResultBean.fireSuccess().setData(pageList); + } + } diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java index b0c115cc9c..7fa850e71e 100644 --- a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskController.java @@ -56,8 +56,8 @@ public class FlowTaskController implements FlowTaskFeign { protected RepositoryService repositoryService; @Resource protected TaskService taskService; - @Resource - private ProcessService processService; + @Resource + private ProcessService processService; @Override public ResultBean startProcessInstanceByKey(StartProcessInstanceQuery startProcessInstanceQuery) { @@ -66,7 +66,7 @@ public class FlowTaskController implements FlowTaskFeign { @Override public ResultBean businessComplete(@RequestBody BusinessVariables dto) { - return flowTaskService. businessComplete(dto); + return flowTaskService.businessComplete(dto); } @Override @@ -87,7 +87,7 @@ public class FlowTaskController implements FlowTaskFeign { int size = Integer.valueOf(businessTaskQuery.getSize() + ""); int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); List fields = businessTaskQuery.getParams().getFields(); - ResultBean> resultBean = flowTaskService.businessTodoList(userSid, fields, current, size); + ResultBean> resultBean = flowTaskService.businessTodoList(userSid, fields, current, size); return resultBean; } @@ -105,10 +105,7 @@ public class FlowTaskController implements FlowTaskFeign { @Override public ResultBean businessDoneList(String userSid, PagerQuery taskQueryPagerQuery) { - int size = Integer.valueOf(taskQueryPagerQuery.getSize() + ""); - int current = Integer.valueOf(taskQueryPagerQuery.getCurrent() + ""); - List fields = taskQueryPagerQuery.getParams().getFields(); - return flowTaskService.businessFinishedList(userSid, fields, current, size); + return flowTaskService.businessDoneListNew(userSid, taskQueryPagerQuery); } @Override @@ -117,12 +114,10 @@ public class FlowTaskController implements FlowTaskFeign { String procInsId = recordQuery.getProcInsId(); return flowTaskService.flowRecord(procInsId, deployId); } - @Override - public ResultBean stopProcess(String userSid,FlowTaskVo flowTaskVo) { - flowTaskService.stopProcess(userSid,flowTaskVo); - - return ResultBean.fireSuccess(); + @Override + public ResultBean stopProcess(String userSid, FlowTaskVo flowTaskVo) { + return flowTaskService.stopProcessNew(userSid, flowTaskVo); } @Override @@ -138,7 +133,7 @@ public class FlowTaskController implements FlowTaskFeign { .startedBy(userSid) .orderByProcessInstanceStartTime() .desc(); - List historicProcessInstances =query + List historicProcessInstances = query .listPage(currentPage, 10); page.setTotal(query.count()); List flowList = new ArrayList<>(); @@ -182,10 +177,7 @@ public class FlowTaskController implements FlowTaskFeign { @Override public ResultBean businessMyprocess(String userSid, PagerQuery businessTaskQuery) { - int size = Integer.valueOf(businessTaskQuery.getSize() + ""); - int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); - List fields = businessTaskQuery.getParams().getFields(); - return flowTaskService.businessMyprocess(userSid, fields, current, size); + return flowTaskService.businessMyprocessNew(userSid, businessTaskQuery); } @Override @@ -218,6 +210,7 @@ public class FlowTaskController implements FlowTaskFeign { public ResultBean> taskReject(FlowTaskVo flowTaskVo) { return flowTaskService.taskReject(flowTaskVo); } + @Override public ResultBean> revokeProcess(@RequestBody FlowTaskVo flowTaskVo) { return flowTaskService.revokeProcess(flowTaskVo); @@ -230,17 +223,19 @@ public class FlowTaskController implements FlowTaskFeign { @Override public ResultBean flowRecord(String procInsId, String deployId) { - return flowTaskService.flowRecord(procInsId,deployId); + return flowTaskService.flowRecord(procInsId, deployId); } + @Override public ResultBean businessFlowRecord(String procInsId, String deployId) { - return flowTaskService.businessFlowRecord(procInsId,deployId); + return flowTaskService.businessFlowRecord(procInsId, deployId); } + @Override public ResultBean deleteProcess(String procInsId) { - flowTaskService.deleteProcess(procInsId,"删除"); - return ResultBean.fireSuccess(); + return flowTaskService.deleteProcessNew(procInsId); } + @Override public ResultBean getNextTasks(String taskId) { return flowTaskService.getNextTasks(taskId); @@ -248,43 +243,42 @@ public class FlowTaskController implements FlowTaskFeign { @Override public ResultBean> getLatestTasks(String procId) { - List latestTasks = flowTaskService.getLatestTasks(procId); - return new ResultBean>().success().setData(latestTasks); + return flowTaskService.getLatestTasksNew(procId); } @Override public ResultBean> getProcessCirculationNodes(String procId, - String modelId, - String k, - String v,String outcome) { - Map map=new HashMap<>(); - map.put(k,v); - map.put("outcome",outcome); + String modelId, + String k, + String v, String outcome) { + Map map = new HashMap<>(); + map.put(k, v); + map.put("outcome", outcome); List flowElements = processService.calApprovePath(procId, modelId, map); - List> list=new ArrayList<>(); + List> list = new ArrayList<>(); List collect = flowElements.stream().filter(item -> item.getId().length() > 0).collect(Collectors.toList()); - for (int i=0;i0){ - log.info("candidateGroups_sid:{}",candidateGroups_arr.get(0)); + if (candidateGroups_arr.size() > 0) { + log.info("candidateGroups_sid:{}", candidateGroups_arr.get(0)); } - log.info("candidateGroups:{}",candidateGroups_arr); + log.info("candidateGroups:{}", candidateGroups_arr); } } - ResultBean> rb=new ResultBean>(); + ResultBean> rb = new ResultBean>(); return rb.setData(flowElements); } } diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java index 9bcbdd0c45..1786daa7db 100644 --- a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java @@ -14,6 +14,7 @@ import com.yxt.anrui.flowable.biz.sysprourl.SysProUrlService; import com.yxt.anrui.flowable.common.FlowComment; import com.yxt.anrui.flowable.exception.CustomException; 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.anrui.flowable.utils.FlowableUtils; @@ -27,6 +28,7 @@ import com.yxt.common.base.config.component.FileUploadComponent; import com.yxt.common.base.service.MybatisBaseService; import com.yxt.common.base.utils.DateUtils; import com.yxt.common.base.utils.StringUtils; +import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -92,6 +94,7 @@ public class FlowTaskService extends MybatisBaseService sysUserVoResultBean = sysUserFeign.fetchBySid(histIns.getAssignee());// sysUserService.selectUserById(Long.parseLong(histIns.getAssignee())); SysUserVo data = sysUserVoResultBean.getData(); - // flowTask.setAssigneeId(data.getSid()); + // flowTask.setAssigneeId(data.getSid()); flowTask.setAssigneeName(data.getName()); - flowTask.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix()+data.getHeadImage()); + flowTask.setAssigneeHeadImage(fileUploadComponent.getUrlPrefix() + data.getHeadImage()); //flowTask.setDeptName(sysUser.getDept().getDeptName()); } // 展示审批人员 @@ -216,7 +220,7 @@ public class FlowTaskService extends MybatisBaseService commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId()); - commentList.forEach(comment -> { + commentList.forEach(comment -> { if (histIns.getTaskId().equals(comment.getTaskId())) { String type = comment.getType(); FlowCommentDto build = FlowCommentDto.builder().type(type).comment(comment.getFullMessage()).build(); @@ -230,6 +234,7 @@ public class FlowTaskService extends MybatisBaseService> todoList(Integer pageNum, Integer pageSize) { Page page = new Page<>(); - // Long userId = SecurityUtils.getLoginUser().getUser().getUserId(); + // Long userId = SecurityUtils.getLoginUser().getUser().getUserId(); TaskQuery taskQuery = taskService.createTaskQuery() .active() .includeProcessVariables() @@ -302,20 +307,21 @@ public class FlowTaskService extends MybatisBaseService> rb=new ResultBean>().fireFail(); + ResultBean> rb = new ResultBean>().fireFail(); return rb.setData(page); } + /** * 代办任务列表 * * @param userSid 参数 - * @param params 参数 + * @param params 参数 * @param pageNum 当前页码 * @param pageSize 每页条数 * @return */ public ResultBean> businessTodoList(String userSid, List params, Integer pageNum, - Integer pageSize) { + Integer pageSize) { Page page = new Page<>(); TaskQuery taskQuery = taskService.createTaskQuery(); @@ -323,7 +329,7 @@ public class FlowTaskService extends MybatisBaseService paramMap = new HashMap<>(); // 挂载表单参数 - for(BusinessTaskParam btq:params){ + for (BusinessTaskParam btq : params) { paramMap.put(btq.getField(), btq.getValue()); // if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){ // taskQuery.processVariableValueEquals(btq.getField(),btq.getValue()); @@ -336,15 +342,15 @@ public class FlowTaskService extends MybatisBaseService taskList = taskQuery.listPage(p, pageSize); List flowList = new ArrayList<>(); for (Task task : taskList) { @@ -421,12 +427,13 @@ public class FlowTaskService extends MybatisBaseService> rb=new ResultBean>(); - return rb .success().setData(page); + ResultBean> rb = new ResultBean>(); + return rb.success().setData(page); } /** * 业务系统查询待办任务列表数量 + * * @param userSid * @return */ @@ -437,6 +444,7 @@ public class FlowTaskService extends MybatisBaseService result = new HashMap<>(); // result.put("result",page); // result.put("finished",true); - ResultBean> rb=new ResultBean>().fireFail(); + ResultBean> rb = new ResultBean>().fireFail(); return rb.setData(page); } + /** * 已办任务列表 * @@ -598,24 +607,24 @@ public class FlowTaskService extends MybatisBaseService> businessFinishedList(String userSid, List params,Integer pageNum, Integer pageSize) { + public ResultBean> businessFinishedList(String userSid, List params, Integer pageNum, Integer pageSize) { Page page = new Page<>(); Map paraMap = new HashMap<>(); - List< Map> ll=new ArrayList<>(); - for(BusinessTaskParam btq:params){ + List> ll = new ArrayList<>(); + for (BusinessTaskParam btq : params) { paraMap.put(btq.getField(), btq.getValue()); - Map mapss=new HashMap<>(); - if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){ - mapss.put("symbol","="); - mapss.put("value",btq.getValue()); - mapss.put("filed",btq.getField()); + Map mapss = new HashMap<>(); + if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)) { + mapss.put("symbol", "="); + mapss.put("value", btq.getValue()); + mapss.put("filed", btq.getField()); } - if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)){ - mapss.put("symbol","like"); - mapss.put("value","%"+btq.getValue()+"%"); - mapss.put("filed",btq.getField()); + if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)) { + mapss.put("symbol", "like"); + mapss.put("value", "%" + btq.getValue() + "%"); + mapss.put("filed", btq.getField()); } /* if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.NONE)){ if("processDefinitionId".equals(btq.getField())){ @@ -627,13 +636,13 @@ public class FlowTaskService extends MybatisBaseService> maps = baseMapper.finishedList(userSid, ll ,(pageNum-1)*pageSize,pageSize); List> maps = baseMapper.finishedList1(paraMap); int count = baseMapper.finishedListCount(paraMap); - List hisTaskList=new ArrayList(); + List hisTaskList = new ArrayList(); for (Map histTask : maps) { FlowTaskDto flowTask = new FlowTaskDto(); // 当前流程信息 @@ -675,14 +684,14 @@ public class FlowTaskService extends MybatisBaseService> rb=new ResultBean>(); + ResultBean> rb = new ResultBean>(); return rb.success().setData(page); } + /** * 完成任务 * @@ -706,7 +716,7 @@ public class FlowTaskService extends MybatisBaseService businessComplete(BusinessVariables dto) { ResultBean rb = new ResultBean<>(); Map formVariables = dto.getFormVariables(); - formVariables.put("handleUrl",dto.getHandleUrl()); - formVariables.put("detailUrl",dto.getDetailUrl()); + formVariables.put("handleUrl", dto.getHandleUrl()); + formVariables.put("detailUrl", dto.getDetailUrl()); Object taskId_obj = formVariables.get("taskId"); - String taskId=null; - if(taskId_obj==null){ + String taskId = null; + if (taskId_obj == null) { return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); - }else{ - taskId=(String) taskId_obj; - if(StringUtils.isBlank(taskId)){ + } else { + taskId = (String) taskId_obj; + if (StringUtils.isBlank(taskId)) { return rb.fail().setMsg("taskId 不能为空!").setData(new FlowTask()); } } Object comment_obj = formVariables.get("comment"); - String comment=null; - if(comment_obj==null){ + String comment = null; + if (comment_obj == null) { return rb.fail().setMsg("comment 不能为空!").setData(new FlowTask()); - }else{ - comment=(String) comment_obj; - if(StringUtils.isBlank(comment)){ + } else { + comment = (String) comment_obj; + if (StringUtils.isBlank(comment)) { return rb.fail().setMsg("comment 不能为空!").setData(new FlowTask()); } } Object instanceId_obj = formVariables.get("instanceId"); - String instanceId=null; - if(instanceId_obj==null){ + String instanceId = null; + if (instanceId_obj == null) { return rb.fail().setMsg("instanceId 不能为空!").setData(new FlowTask()); - }else{ - instanceId=(String) instanceId_obj; - if(StringUtils.isBlank(instanceId)){ + } else { + instanceId = (String) instanceId_obj; + if (StringUtils.isBlank(instanceId)) { return rb.fail().setMsg("instanceId 不能为空!").setData(new FlowTask()); } } Object userSid_obj = formVariables.get("userSid"); - String userSid=null; - if(userSid_obj==null){ + String userSid = null; + if (userSid_obj == null) { return rb.fail().setMsg("userSid 不能为空!").setData(new FlowTask()); - }else{ - userSid=(String) userSid_obj; - if(StringUtils.isBlank(userSid)){ + } else { + userSid = (String) userSid_obj; + if (StringUtils.isBlank(userSid)) { return rb.fail().setMsg("userSid 不能为空!").setData(new FlowTask()); } } Object businessSid_obj = formVariables.get("businessSid"); - String businessSid=null; - if(businessSid_obj==null){ + String businessSid = null; + if (businessSid_obj == null) { return rb.fail().setMsg("业务sid 不能为空!").setData(new FlowTask()); - }else{ - businessSid=(String) businessSid_obj; - if(StringUtils.isBlank(businessSid)){ + } else { + businessSid = (String) businessSid_obj; + if (StringUtils.isBlank(businessSid)) { return rb.fail().setMsg("业务sid 不能为空!").setData(new FlowTask()); } } Task task = taskService.createTaskQuery().taskId(taskId).singleResult(); - if (Objects.isNull(task)){ + if (Objects.isNull(task)) { return rb.fail().setMsg("任务不存在").setData(new FlowTask()); } if (DelegationState.PENDING.equals(task.getDelegationState())) { @@ -796,14 +807,15 @@ public class FlowTaskService extends MybatisBaseService>().success().setData(latestTaskList); } + public ResultBean businessMyprocessNew(String userSid, PagerQuery businessTaskQuery) { + int size = Integer.valueOf(businessTaskQuery.getSize() + ""); + int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); + List fields = businessTaskQuery.getParams().getFields(); + return businessMyprocess(userSid, fields, current, size); + } + public ResultBean businessMyprocess(String userSid, List params, int current, int size) { Page page = new Page<>(); HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery(); - for(BusinessTaskParam btq:params){ - if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)){ - historicProcessInstanceQuery.variableValueEquals(btq.getField(),btq.getValue()); + for (BusinessTaskParam btq : params) { + if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.EQUAL)) { + historicProcessInstanceQuery.variableValueEquals(btq.getField(), btq.getValue()); } - if(btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)){ - historicProcessInstanceQuery.variableValueLike(btq.getField(),"%"+btq.getValue()+"%"); + if (btq.getSqlOperationSymbol().equals(SQLOperationSymbol.LIKE)) { + historicProcessInstanceQuery.variableValueLike(btq.getField(), "%" + btq.getValue() + "%"); } } historicProcessInstanceQuery.startedBy(userSid).notDeleted() .orderByProcessInstanceStartTime() .desc(); - List historicProcessInstances =historicProcessInstanceQuery .listPage((current - 1) * size, size); + List historicProcessInstances = historicProcessInstanceQuery.listPage((current - 1) * size, size); long count = historicProcessInstanceQuery.count(); page.setTotal(count); List flowList = new ArrayList<>(); @@ -1108,9 +1128,10 @@ public class FlowTaskService extends MybatisBaseService> revokeProcess(FlowTaskVo flowTaskVo) { HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(flowTaskVo.getTaskId()).singleResult(); Execution execution = runtimeService.createExecutionQuery().executionId(historicTaskInstance.getExecutionId()).singleResult(); - DelegateExecution delegateExecution=(DelegateExecution)execution; + DelegateExecution delegateExecution = (DelegateExecution) execution; // 获取当前节点的activityId,即xml中每个标签的ID String currentActivityId = delegateExecution.getCurrentActivityId(); // List list1 = taskService.createTaskQuery().processInstanceId(historicTaskInstance.getProcessInstanceId()).list(); // taskService.addComment(currentTask.getId(), execution.getProcessInstanceId(), body.get("msg").toString()); - // FlowNode flowNode2 = (FlowNode)bpmnModel.getFlowElement(sourceRef); - String taskId = getTaskId(currentActivityId, historicTaskInstance.getProcessInstanceId(),historicTaskInstance.getProcessDefinitionId()); + // FlowNode flowNode2 = (FlowNode)bpmnModel.getFlowElement(sourceRef); + String taskId = getTaskId(currentActivityId, historicTaskInstance.getProcessInstanceId(), historicTaskInstance.getProcessDefinitionId()); HistoricTaskInstance historicTaskInstance1 = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult(); String assignee = historicTaskInstance1.getAssignee(); String userSid = flowTaskVo.getUserSid(); - if(!assignee.equals(userSid)){ + if (!assignee.equals(userSid)) { return new ResultBean>().fail().setMsg("您不是上一环节处理人,不能进行撤回操作!").setData(new ArrayList<>()); } // 流程回退到上一个节点,审批人继续审批 @@ -1158,12 +1179,12 @@ public class FlowTaskService extends MybatisBaseService parentUserTaskList = FlowableUtils.iteratorFindParentUserTasks(source, null, null); - if(parentUserTaskList==null || parentUserTaskList.size()==0){ + if (parentUserTaskList == null || parentUserTaskList.size() == 0) { // throw new CustomException("当前节点为"); return new ResultBean>().fail().setMsg("当前节点为").setData(new ArrayList<>()); } // 如果流程已经结束,则得到结束节点 - if(historyService.createHistoricProcessInstanceQuery().finished() - .processInstanceId(task.getProcessInstanceId()).count() > 0){ - return new ResultBean>().fail().setMsg("当前已经结束不能撤回").setData(new ArrayList<>()); - } + if (historyService.createHistoricProcessInstanceQuery().finished() + .processInstanceId(task.getProcessInstanceId()).count() > 0) { + return new ResultBean>().fail().setMsg("当前已经结束不能撤回").setData(new ArrayList<>()); + } // 获取活动 ID 即节点 Key List parentUserTaskKeyList = new ArrayList<>(); parentUserTaskList.forEach(item -> parentUserTaskKeyList.add(item.getId())); // 获取全部历史节点活动实例,即已经走过的节点历史,数据采用开始时间升序 List historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery() - .processInstanceId(task.getProcessInstanceId()) - .orderByHistoricTaskInstanceStartTime().asc().list(); + .processInstanceId(task.getProcessInstanceId()) + .orderByHistoricTaskInstanceStartTime().asc().list(); // 数据清洗,将回滚导致的脏数据清洗掉 List lastHistoricTaskInstanceList = FlowableUtils.historicTaskInstanceClean(allElements, historicTaskInstanceList); // 此时历史任务实例为倒序,获取最后走的节点 @@ -1284,6 +1305,7 @@ public class FlowTaskService extends MybatisBaseService f instanceof EndEvent).collect(Collectors.toList()); } - public void stopProcess(String userSid,FlowTaskVo flowTaskVo) { + public void stopProcess(String userSid, FlowTaskVo flowTaskVo) { List task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list(); if (CollectionUtils.isEmpty(task)) { throw new CustomException("流程未启动或已执行完成,取消申请失败"); @@ -1353,45 +1375,49 @@ public class FlowTaskService extends MybatisBaseService outFlows = flowNode.getOutgoingFlows(); - Map nodeMap=new HashMap<>(); - List< Map> lists=new ArrayList<>(); - getNodes(outFlows, node,lists); + Map nodeMap = new HashMap<>(); + List> lists = new ArrayList<>(); + getNodes(outFlows, node, lists); System.out.println(JSON.toJSONString(lists)); return ResultBean.fireSuccess().setData(lists); } /** * 根据流程实例的id查询最新的待办环节 + * * @param procId * @return */ - public List getLatestTasks(String procId){ + public List getLatestTasks(String procId) { return baseMapper.getLatestTasks(procId); } - public void getNodes( List outFlows,String node, List> lists){ + + public void getNodes(List outFlows, String node, List> lists) { for (SequenceFlow sequenceFlow : outFlows) { //当前审批节点 if ("now".equals(node)) { @@ -1402,26 +1428,56 @@ public class FlowTaskService extends MybatisBaseService map = new HashMap<>(); + map.put("id", targetFlow.getId()); + map.put("name", targetFlow.getName()); map.put("assignee", ((UserTask) targetFlow).getAssignee()); lists.add(map); } if (targetFlow instanceof EndEvent) {// 如果下个审批节点为结束节点 System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); - Map map=new HashMap<>(); - map.put("id",targetFlow.getId()); - map.put("name",targetFlow.getName()); + Map map = new HashMap<>(); + map.put("id", targetFlow.getId()); + map.put("name", targetFlow.getName()); map.put("assignee", ((UserTask) targetFlow).getAssignee()); lists.add(map); } if (targetFlow instanceof Gateway) {// 如果下个审批节点为结束节点 List outgoingFlows = ((Gateway) targetFlow).getOutgoingFlows(); - getNodes(outgoingFlows,node,lists); + getNodes(outgoingFlows, node, lists); System.out.println("下一节点为结束节点:id=" + targetFlow.getId() + ",name=" + targetFlow.getName()); } } } } + + public ResultBean> getLatestTasksNew(String procId) { + List latestTasks = getLatestTasks(procId); + return new ResultBean>().success().setData(latestTasks); + } + + public ResultBean businessTodoListNew(String userSid, PagerQuery businessTaskQuery) { + int size = Integer.valueOf(businessTaskQuery.getSize() + ""); + int current = Integer.valueOf(businessTaskQuery.getCurrent() + ""); + List fields = businessTaskQuery.getParams().getFields(); + ResultBean> resultBean = businessTodoList(userSid, fields, current, size); + return resultBean; + } + + public ResultBean businessDoneListNew(String userSid, PagerQuery taskQueryPagerQuery) { + int size = Integer.valueOf(taskQueryPagerQuery.getSize() + ""); + int current = Integer.valueOf(taskQueryPagerQuery.getCurrent() + ""); + List fields = taskQueryPagerQuery.getParams().getFields(); + return businessFinishedList(userSid, fields, current, size); + } + + public ResultBean stopProcessNew(String userSid, FlowTaskVo flowTaskVo) { + stopProcess(userSid, flowTaskVo); + return ResultBean.fireSuccess(); + } + + public ResultBean deleteProcessNew(String procInsId) { + deleteProcess(procInsId, "删除"); + return ResultBean.fireSuccess(); + } } \ No newline at end of file