Переглянути джерело

工作流部分代码提交

user5 2 роки тому
батько
коміт
97c1efba30
15 змінених файлів з 269 додано та 13 видалено
  1. 7 2
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableProcessController.java
  2. 20 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableTaskController.java
  3. 2 2
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/MyNoticeController.java
  4. 8 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/FlowMapper.java
  5. 12 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/MyNoticeListMapper.java
  6. 38 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/xml/FlowMapper.xml
  7. 25 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/xml/MyNoticeListMapper.xml
  8. 46 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/ActRuTaskInfo.java
  9. 3 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/Flow.java
  10. 5 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/MyNoticeList.java
  11. 44 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowProcessService.java
  12. 42 0
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowTaskService.java
  13. 15 7
      jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/MyNoticeService.java
  14. 1 1
      jeeplus-web/src/main/resources/application-development.yml
  15. 1 1
      jeeplus-web/src/main/resources/application-production.yml

+ 7 - 2
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableProcessController.java

@@ -8,6 +8,7 @@ import com.jeeplus.aop.demo.annotation.DemoMode;
 import com.jeeplus.flowable.service.FlowProcessService;
 import com.jeeplus.flowable.vo.ProcessStatus;
 import com.jeeplus.flowable.vo.ProcessVo;
+import com.jeeplus.sys.utils.StringUtils;
 import org.flowable.common.engine.api.FlowableObjectNotFoundException;
 import org.flowable.engine.repository.ProcessDefinition;
 import org.flowable.engine.runtime.ProcessInstance;
@@ -244,8 +245,12 @@ public class FlowableProcessController {
     @RequestMapping("stop")
     public ResponseEntity stopProcIns(String id, String message) {
         try {
-            flowProcessService.stopProcessInstanceById (id, ProcessStatus.STOP, message);
-            return ResponseEntity.ok ("终止流程成功!");
+            if(StringUtils.isNotBlank(id)){
+                flowProcessService.stopProcessInstanceById (id, ProcessStatus.STOP, message);
+                return ResponseEntity.ok ("终止流程成功!");
+            }else{
+                return ResponseEntity.ok ("操作失败,流程已经结束!");
+            }
         } catch (FlowableObjectNotFoundException e) {
             return ResponseEntity.ok ("操作失败,流程已经结束!");
         }

+ 20 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/FlowableTaskController.java

@@ -10,6 +10,7 @@ import com.google.common.collect.Maps;
 import com.jeeplus.common.utils.Collections3;
 import com.jeeplus.extension.domain.NodeSetting;
 import com.jeeplus.extension.service.NodeSettingService;
+import com.jeeplus.flowable.model.ActRuTaskInfo;
 import com.jeeplus.flowable.model.Flow;
 import com.jeeplus.flowable.model.TaskComment;
 import com.jeeplus.flowable.service.FlowTaskService;
@@ -126,6 +127,15 @@ public class FlowableTaskController {
      */
     @GetMapping("getTaskDef")
     public ResponseEntity getTaskDef(Flow flow) {
+        if(StringUtils.isBlank(flow.getTaskId()) && StringUtils.isNotBlank(flow.getProcDefId())){
+            ActRuTaskInfo taskInfoByProcDefId = flowTaskService.getTaskInfoByProcDefId(flow.getProcDefId());
+            if(null != taskInfoByProcDefId){
+                flow.setTaskId(taskInfoByProcDefId.getId());
+                flow.setProcInsId(taskInfoByProcDefId.getProcInstId());
+                flow.setTaskName(taskInfoByProcDefId.getName());
+                flow.setTaskDefKey(taskInfoByProcDefId.getTaskDefKey());
+            }
+        }
         // 获取流程XML上的表单KEY
         String formKey = flowTaskService.getFormKey(flow.getProcDefId(), flow.getTaskDefKey());
 
@@ -247,6 +257,16 @@ public class FlowableTaskController {
      */
     @PostMapping("audit")
     public ResponseEntity auditTask(HttpServletRequest request, Flow flow) {
+
+        if(StringUtils.isBlank(flow.getTaskId()) && StringUtils.isNotBlank(flow.getProcDefId())){
+            ActRuTaskInfo taskInfoByProcDefId = flowTaskService.getTaskInfoByProcDefId(flow.getProcDefId());
+            if(null != taskInfoByProcDefId){
+                flow.setTaskId(taskInfoByProcDefId.getId());
+                flow.setProcInsId(taskInfoByProcDefId.getProcInstId());
+                flow.setTaskName(taskInfoByProcDefId.getName());
+                flow.setTaskDefKey(taskInfoByProcDefId.getTaskDefKey());
+            }
+        }
         Map<String, Object> vars = Maps.newHashMap();
         Map<String, String[]> map = request.getParameterMap();
         for (Map.Entry<String, String[]> entry : map.entrySet()) {

+ 2 - 2
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/controller/MyNoticeController.java

@@ -33,8 +33,8 @@ public class MyNoticeController {
 
     @ApiOperation(value = "新增")
     @GetMapping("/add")
-    public String add(String taskId, String title, String defId, String taskName, String createUser, String createTime, String noticeName) throws Exception{
-        return service.add(taskId, title, defId, taskName, createUser, createTime, noticeName);
+    public String add(String taskId, String title, String defId, String taskName, String createUser, String createTime, String noticeName, String noticeId) throws Exception{
+        return service.add(taskId, title, defId, taskName, createUser, createTime, noticeName, noticeId);
     }
 
     @ApiOperation(value = "修改已读状态")

+ 8 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/FlowMapper.java

@@ -5,6 +5,7 @@ package com.jeeplus.flowable.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.jeeplus.flowable.model.ActHiIdentitylink;
+import com.jeeplus.flowable.model.ActRuTaskInfo;
 import com.jeeplus.flowable.model.Flow;
 
 import java.util.List;
@@ -25,4 +26,11 @@ public interface FlowMapper extends BaseMapper <Flow> {
      * @return
      */
     List<ActHiIdentitylink> getActHiIdentitylinkList(String processInstanceId);
+
+    /**
+     * 根据流程id查询流程信息
+     * @param procDefId
+     * @return
+     */
+    ActRuTaskInfo getTaskInfoByProcDefId(String procDefId);
 }

+ 12 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/MyNoticeListMapper.java

@@ -1,6 +1,10 @@
 package com.jeeplus.flowable.mapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.flowable.model.MyNoticeList;
 import org.apache.ibatis.annotations.Param;
 
@@ -8,4 +12,12 @@ public interface MyNoticeListMapper extends BaseMapper<MyNoticeList> {
 
     void readAll(@Param("name") String name);
 
+    /**
+     * 查询通知信息
+     *
+     * @param myNotice
+     * @return
+     */
+    public IPage<MyNoticeList> selectPage(Page<MyNoticeList> page, @Param("myNotice") MyNoticeList myNotice);
+
 }

+ 38 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/xml/FlowMapper.xml

@@ -29,4 +29,42 @@
 		where PROC_INST_ID_= #{processInstanceId}
 	</select>
 
+	<select id="getTaskInfoByProcDefId" resultType="com.jeeplus.flowable.model.ActRuTaskInfo">
+		select
+		  ID_ as "id",
+		  REV_ as "rev",
+		  EXECUTION_ID_ as "executionId",
+		  PROC_INST_ID_ as "procInstId",
+		  PROC_DEF_ID_ as "procDefId",
+		  TASK_DEF_ID_ as "taskDefId",
+		  SCOPE_ID_ as "scopeId",
+		  SUB_SCOPE_ID_ as "subScopeId",
+		  SCOPE_TYPE_ as "scopeType",
+		  SCOPE_DEFINITION_ID_ as "scopeDefinitionId",
+		  NAME_ as "name",
+		  PARENT_TASK_ID_ as "parentTaskId",
+		  DESCRIPTION_ as "description",
+		  TASK_DEF_KEY_ as "taskDefKey",
+		  OWNER_ as "owner",
+		  ASSIGNEE_ as "assignee",
+		  DELEGATION_ as "delegation",
+		  PRIORITY_ as "priority",
+		  CREATE_TIME_ as "createTime",
+		  DUE_DATE_ as "dueDate",
+		  CATEGORY_ as "category",
+		  SUSPENSION_STATE_ as "suspensionState",
+		  TENANT_ID_ as "tenantId",
+		  FORM_KEY_ as "formKey",
+		  CLAIM_TIME_ as "claimTime",
+		  IS_COUNT_ENABLED_ as "isCountEnabled",
+		  VAR_COUNT_ as "varCount",
+		  ID_LINK_COUNT_ as "idLinkCount",
+		  SUB_TASK_COUNT_  as "subTaskCount"
+		from
+		  act_ru_task
+		where PROC_DEF_ID_= #{procDefId}
+		order by CREATE_TIME_ desc
+		limit 1
+	</select>
+
 </mapper>

+ 25 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/mapper/xml/MyNoticeListMapper.xml

@@ -10,4 +10,29 @@
 			AND create_user = #{name}
 	</update>
 
+	<select id="selectPage" resultType="com.jeeplus.flowable.model.MyNoticeList">
+		select
+		  a.id,
+		  a.create_by,
+		  a.create_date,
+		  a.update_by,
+		  a.update_date,
+		  a.del_flag,
+		  a.task_id,
+		  a.title,
+		  a.def_id,
+		  a.task_name,
+		  a.link,
+		  a.create_user,
+		  a.create_time,
+		  a.type,
+		  a.repetition_count,
+		  a.notice_id,
+		  su.name as "noticeName"
+		from
+		  my_notice_list a
+		left join sys_user su on a.notice_id = su.id
+		${ew.customSqlSegment}
+	</select>
+
 </mapper>

+ 46 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/ActRuTaskInfo.java

@@ -0,0 +1,46 @@
+package com.jeeplus.flowable.model;
+
+import cn.hutool.core.util.StrUtil;
+import com.jeeplus.flowable.constant.FlowableConstant;
+import com.jeeplus.flowable.vo.ActionType;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * act_ru_task 表数据
+ */
+@Data
+public class ActRuTaskInfo implements Serializable {
+
+    private String id;
+    private Integer rev;
+    private String executionId;
+    private String procInstId;
+    private String procDefId;
+    private String taskDefId;
+    private String scopeId;
+    private String subScopeId;
+    private String scopeType;
+    private String scopeDefinitionId;
+    private String name;
+    private String parentTaskId;
+    private String description;
+    private String taskDefKey;
+    private String owner;
+    private String assignee;
+    private String delegation;
+    private Integer priority;
+    private Date createTime;
+    private Date dueDate;
+    private String category;
+    private Integer suspensionState;
+    private String tenantId;
+    private String formKey;
+    private Date claimTime;
+    private Integer isCountEnabled;
+    private Integer varCount;
+    private Integer idLinkCount;
+    private Integer subTaskCount;
+}

+ 3 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/Flow.java

@@ -57,6 +57,7 @@ public class Flow  {
 
 	private String assignee; // 任务执行人编号
 	private String assigneeName; // 任务执行人名称
+	private String assigneeId; // 任务执行人Id
 
 	private Variable vars;        // 流程变量
 
@@ -70,6 +71,8 @@ public class Flow  {
 
 	private String processInstanceId;//流程实例id
 
+	private Boolean commentFlag = false; // 查看评论判定条件
+
 
 	public Flow() {
 		super();

+ 5 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/model/MyNoticeList.java

@@ -53,6 +53,11 @@ public class MyNoticeList extends BaseEntity {
     private String noticeName;
 
     /**
+     * 通知人id
+     */
+    private String noticeId;
+
+    /**
      * 读取状态
      */
     private String type;

+ 44 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowProcessService.java

@@ -432,6 +432,50 @@ public class FlowProcessService {
     }
 
     /**
+     * 驳回流程实例信息调整
+     *
+     * @param procInsId    流程实例ID
+     * @param processStatus    流程状态
+     */
+    @Transactional(readOnly = false)
+    public void rejectProcessInstanceById(String procInsId, ProcessStatus processStatus, String comment) {
+        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(procInsId).singleResult();
+        if (processInstance != null) {
+            Task currentTask = taskService.createTaskQuery ().processInstanceId (procInsId).list ().get (0);
+            //1、添加审批记录
+            TaskComment taskComment = new TaskComment ();
+            if(processStatus == ProcessStatus.AGREE){
+                taskComment.setType ( ActionType.AGREE.getType ());
+                taskComment.setStatus (ActionType.AGREE.getStatus ());
+                taskComment.setMessage (comment);
+            }else if(processStatus == ProcessStatus.REVOKE){
+                taskComment.setType ( ActionType.REVOKE.getType ());
+                taskComment.setStatus (ActionType.REVOKE.getStatus ());
+                taskComment.setMessage (comment);
+            }else if(processStatus == ProcessStatus.STOP){
+                taskComment.setType (ActionType.STOP.getType ());
+                taskComment.setStatus (ActionType.STOP.getStatus ());
+                taskComment.setMessage (comment);
+            }else if(processStatus == ProcessStatus.REJECT){
+                taskComment.setType (ActionType.REJECT.getType ());
+                taskComment.setStatus (ActionType.REJECT.getStatus ());
+                taskComment.setMessage (comment);
+            }else if(processStatus == ProcessStatus.DELETED){
+                taskComment.setType (ActionType.DELETED.getType ());
+                taskComment.setStatus (ActionType.DELETED.getStatus ());
+                taskComment.setMessage (comment);
+            }
+
+
+
+            taskService.addComment (currentTask.getId (),procInsId, taskComment.getCommentType (), taskComment.getFullMessage ());
+            if(StrUtil.isBlank (currentTask.getAssignee ()))  { // 未签收任务
+                taskService.claim (currentTask.getId (), UserUtils.getCurrentUserDTO ().getId ());
+            }
+        }
+    }
+
+    /**
      * 删除运行中的流程实例
      *
      * @param procInsId    流程实例ID

+ 42 - 0
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/FlowTaskService.java

@@ -12,6 +12,7 @@ import com.google.common.collect.Maps;
 import com.jeeplus.common.utils.Collections3;
 import com.jeeplus.flowable.constant.FlowableConstant;
 import com.jeeplus.flowable.model.ActHiIdentitylink;
+import com.jeeplus.flowable.model.ActRuTaskInfo;
 import com.jeeplus.flowable.vo.*;
 import com.jeeplus.flowable.common.cmd.BackUserTaskCmd;
 import com.jeeplus.flowable.model.Flow;
@@ -254,6 +255,26 @@ public class FlowTaskService {
                 actList.add (e);
             }
         }
+
+        //获取当前登录人信息
+        /*UserDTO userDTO = UserUtils.getCurrentUserDTO();
+        if(null != userDTO && StringUtils.isNotBlank(userDTO.getId())){
+            Integer actSubscript = 0;
+            //获取当前登陆人节点下标
+            for (int i = 0; i < actList.size (); i++) {
+                Flow act = actList.get(i);
+                if(act.getAssigneeId().equals(userDTO.getId())){
+                    actSubscript = i;
+                    break;
+                }
+            }
+            //判断 当前登陆人节点下标是否大于0
+            if(actSubscript>0){
+                Flow flow = actList.get(actSubscript - 1);
+                flow.setCommentFlag(true);
+            }
+
+        }*/
         return actList;
     }
 
@@ -571,6 +592,21 @@ public class FlowTaskService {
 
 
         Task task = taskService.createTaskQuery ().taskId (flow.getTaskId ()).singleResult ();
+
+        Object agree = vars.get("agree");
+        Boolean flagAgree = null;
+        if(null != agree && StringUtils.isNotBlank(String.valueOf(agree))){
+            flagAgree = (Boolean) agree;
+        }
+        if(null != flagAgree){
+            if(flagAgree){
+                flowProcessService.rejectProcessInstanceById (task.getProcessInstanceId (), ProcessStatus.AGREE, flow.getComment ().getMessage ());
+            }else{
+                flowProcessService.rejectProcessInstanceById (task.getProcessInstanceId (), ProcessStatus.REJECT, flow.getComment ().getMessage ());
+            }
+        }
+
+
         // owner不为空说明可能存在委托任务
         if (StrUtil.isNotBlank (task.getOwner ())) {
             DelegationState delegationState = task.getDelegationState ();
@@ -616,6 +652,7 @@ public class FlowTaskService {
                     if (user != null) {
                         e.setAssignee (histIns.getAssignee ());
                         e.setAssigneeName (user.getName ());
+                        e.setAssigneeId (user.getId ());
                     }
                 }
             }
@@ -639,6 +676,7 @@ public class FlowTaskService {
             if (user != null) {
                 e.setAssignee (histIns.getAssignee ());
                 e.setAssigneeName (user.getName ());
+                e.setAssigneeId (user.getId ());
             }
         }
         // 获取意见评论内容
@@ -932,4 +970,8 @@ public class FlowTaskService {
         return task;
     }
 
+    public ActRuTaskInfo getTaskInfoByProcDefId(String procDefId){
+        return flowMapper.getTaskInfoByProcDefId(procDefId);
+    }
+
 }

+ 15 - 7
jeeplus-plugins/jeeplus-flowable/src/main/java/com/jeeplus/flowable/service/MyNoticeService.java

@@ -1,8 +1,10 @@
 package com.jeeplus.flowable.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.flowable.mapper.MyNoticeListMapper;
 import com.jeeplus.flowable.model.Flow;
 import com.jeeplus.flowable.model.MyNoticeList;
@@ -41,18 +43,19 @@ public class MyNoticeService {
     public Page<MyNoticeList> noticeList(Page<MyNoticeList> page, String type, String title, String taskName){
         // 获取当前登录人名称查询出未查看通知列表
         String userName = UserUtils.getCurrentUserDTO ().getName ();
-        LambdaQueryWrapper<MyNoticeList> wrapper = new LambdaQueryWrapper<MyNoticeList>();
-        wrapper.eq(MyNoticeList::getNoticeName, userName).orderByDesc(BaseEntity::getCreateDate);
+        QueryWrapper<MyNoticeList> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("a.notice_id", UserUtils.getCurrentUserDTO ().getId());
+        queryWrapper.orderByDesc("a.create_date");
         if (StringUtils.isNotEmpty(type)) {
-            wrapper.eq(MyNoticeList::getType, Integer.parseInt(type));
+            queryWrapper.eq("a.type", Integer.parseInt(type));
         }
         if (StringUtils.isNotEmpty(title)) {
-            wrapper.like(MyNoticeList::getTitle, title);
+            queryWrapper.like("a.title", title);
         }
         if (StringUtils.isNotEmpty(taskName)) {
-            wrapper.eq(MyNoticeList::getTaskName, taskName);
+            queryWrapper.eq("a.task_name", taskName);
         }
-        Page<MyNoticeList> listPage = mapper.selectPage(page, wrapper);
+        Page<MyNoticeList> listPage = mapper.selectPage(page, queryWrapper);
         if (CollectionUtils.isNotEmpty(listPage.getRecords())) {
             for (MyNoticeList notice : listPage.getRecords()) {
                 notice.setType("0".equals(notice.getType())? "未读":"已读");
@@ -61,7 +64,7 @@ public class MyNoticeService {
         return listPage;
     }
 
-    public String add(String taskId, String title, String defId, String taskName, String createName, String createDate, String noticeName) throws Exception{
+    public String add(String taskId, String title, String defId, String taskName, String createName, String createDate, String noticeName, String noticeId) throws Exception{
         MyNoticeList notice = new MyNoticeList();
         //是否已保存
         LambdaQueryWrapper<MyNoticeList> wrapper = new LambdaQueryWrapper<>();
@@ -107,6 +110,11 @@ public class MyNoticeService {
         } else {
             notice.setNoticeName(userDTO.getName());
         }
+        if (StringUtils.isNotBlank(noticeId)) {
+            notice.setNoticeId(noticeId);
+        } else {
+            notice.setNoticeId(userDTO.getId());
+        }
         // 创建时间格式化处理
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         notice.setCreateTime(format.parse(createDate));

+ 1 - 1
jeeplus-web/src/main/resources/application-development.yml

@@ -259,7 +259,7 @@ company_round_seal_id_vertical: 2898043523878957918
 #公司方章
 company_parties_seal_id: 2894163220106129636
 #审定单用印流程id
-approval_category_id: 3032139783803457567
+approval_category_id: 3032955004099797473
 #报告用印流程id
 report_category_id: 2895618951099527314
 ##审定内用印流程id

+ 1 - 1
jeeplus-web/src/main/resources/application-production.yml

@@ -261,7 +261,7 @@ company_round_seal_id_vertical: 2898043523878957918
 #公司方章
 company_parties_seal_id: 2894163220106129636
 #审定单用印流程id
-approval_category_id: 3032139783803457567
+approval_category_id: 3032955004099797473
 #报告用印流程id
 report_category_id: 2895618951099527314
 ##审定内用印流程id