소스 검색

优化OA流程

Your Name 3 년 전
부모
커밋
eaf1d101d0

+ 11 - 0
java110-bean/src/main/java/com/java110/entity/audit/AuditUser.java

@@ -3,6 +3,7 @@ package com.java110.entity.audit;
 import com.java110.dto.PageDto;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * 审核用户
@@ -29,6 +30,8 @@ public class AuditUser extends PageDto implements Serializable {
 
     private String processDefinitionKey;
 
+    private List<String> processDefinitionKeys;
+
     private String flowId;
 
     public String getObjCode() {
@@ -102,4 +105,12 @@ public class AuditUser extends PageDto implements Serializable {
     public void setFlowId(String flowId) {
         this.flowId = flowId;
     }
+
+    public List<String> getProcessDefinitionKeys() {
+        return processDefinitionKeys;
+    }
+
+    public void setProcessDefinitionKeys(List<String> processDefinitionKeys) {
+        this.processDefinitionKeys = processDefinitionKeys;
+    }
 }

+ 36 - 0
java110-interface/src/main/java/com/java110/intf/common/IOaWorkflowUserInnerServiceSMO.java

@@ -2,6 +2,7 @@ package com.java110.intf.common;
 
 import com.alibaba.fastjson.JSONObject;
 import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.PageDto;
 import com.java110.dto.auditMessage.AuditMessageDto;
 import com.java110.dto.oaWorkflow.OaWorkflowDto;
 import com.java110.dto.oaWorkflowXml.OaWorkflowXmlDto;
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 
+import java.util.ArrayList;
 import java.util.List;
 
 
@@ -62,6 +64,40 @@ public interface IOaWorkflowUserInnerServiceSMO {
     @RequestMapping(value = "/getUserHistoryTasks", method = RequestMethod.POST)
     List<JSONObject> getUserHistoryTasks(@RequestBody AuditUser user);
 
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    @RequestMapping(value = "/getDefinitionKeysUserTaskCount", method = RequestMethod.POST)
+     long getDefinitionKeysUserTaskCount(@RequestBody AuditUser user) ;
+
+    /**
+     * 获取用户任务
+     *
+     * @param user 用户信息
+     */
+    @RequestMapping(value = "/getDefinitionKeysUserTasks", method = RequestMethod.POST)
+    List<JSONObject> getDefinitionKeysUserTasks(@RequestBody AuditUser user) ;
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    @RequestMapping(value = "/getDefinitionKeysUserHistoryTaskCount", method = RequestMethod.POST)
+    long getDefinitionKeysUserHistoryTaskCount(@RequestBody AuditUser user) ;
+
+    /**
+     * 获取用户审批的任务
+     *
+     * @param user 用户信息
+     */
+    @RequestMapping(value = "/getDefinitionKeysUserHistoryTasks", method = RequestMethod.POST)
+    List<JSONObject> getDefinitionKeysUserHistoryTasks(@RequestBody AuditUser user) ;
+
 
     /**
      * 处理任务

+ 39 - 1
service-api/src/main/java/com/java110/api/smo/undo/impl/UndoSMOImpl.java

@@ -5,7 +5,12 @@ import com.java110.api.smo.AppAbstractComponentSMO;
 import com.java110.api.smo.DefaultAbstractComponentSMO;
 import com.java110.api.smo.undo.IUndoSMO;
 import com.java110.core.context.IPageData;
+import com.java110.dto.oaWorkflow.OaWorkflowDto;
+import com.java110.dto.workflow.WorkflowDto;
+import com.java110.entity.audit.AuditUser;
 import com.java110.entity.component.ComponentValidateResult;
+import com.java110.intf.common.IOaWorkflowUserInnerServiceSMO;
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
 import com.java110.utils.exception.SMOException;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,6 +20,8 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -26,6 +33,13 @@ public class UndoSMOImpl extends DefaultAbstractComponentSMO implements IUndoSMO
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private IOaWorkflowUserInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
+
+
+    @Autowired
+    private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl;
+
     @Override
     public ResponseEntity<String> listUndos(IPageData pd) throws SMOException {
         return businessProcess(pd);
@@ -135,10 +149,34 @@ public class UndoSMOImpl extends DefaultAbstractComponentSMO implements IUndoSMO
         } else {
             doing.put("allocation", "0");
         }
+        getItemReleaseCount(result, doing);
 
         return ResultVo.createResponseEntity(doing);
     }
 
+    private void getItemReleaseCount(ComponentValidateResult result, JSONObject data) {
+        OaWorkflowDto oaWorkflowDto = new OaWorkflowDto();
+        oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT);
+        oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_ITEM_RELEASE);
+        List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto);
+
+        if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) {
+            data.put("itemReleaseCount", "0");
+            return ;
+        }
+        List<String> flowIds = new ArrayList<>();
+        for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) {
+            flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId());
+        }
+
+        AuditUser auditUser = new AuditUser();
+        auditUser.setUserId(result.getUserId());
+        auditUser.setProcessDefinitionKeys(flowIds);
+
+        long itemReleaseCount = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserTaskCount(auditUser);
+        data.put("itemReleaseCount", itemReleaseCount);
+    }
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }
@@ -146,4 +184,4 @@ public class UndoSMOImpl extends DefaultAbstractComponentSMO implements IUndoSMO
     public void setRestTemplate(RestTemplate restTemplate) {
         this.restTemplate = restTemplate;
     }
-}
+}

+ 126 - 0
service-common/src/main/java/com/java110/common/smo/impl/OaWorkflowUserInnerServiceSMOImpl.java

@@ -159,6 +159,9 @@ public class OaWorkflowUserInnerServiceSMOImpl extends BaseServiceSMO implements
         return query.count();
     }
 
+
+
+
     /**
      * 获取用户任务
      *
@@ -194,6 +197,8 @@ public class OaWorkflowUserInnerServiceSMOImpl extends BaseServiceSMO implements
     }
 
 
+
+
     /**
      * 查询用户任务数
      *
@@ -266,6 +271,127 @@ public class OaWorkflowUserInnerServiceSMOImpl extends BaseServiceSMO implements
         return tasks;
     }
 
+    /**
+     * 查询用户任务数
+     *
+     * @param user{
+     *            userId:''
+     *            processDefinitionkeys
+     * }
+     * @return
+     */
+    public long getDefinitionKeysUserTaskCount(@RequestBody AuditUser user) {
+        TaskService taskService = processEngine.getTaskService();
+        TaskQuery query = taskService.createTaskQuery().processDefinitionKeyIn(user.getProcessDefinitionKeys());
+        query.taskAssignee(user.getUserId());
+        return query.count();
+    }
+
+    /**
+     * 获取用户任务
+     *
+     * @param user 用户信息
+     */
+    public List<JSONObject> getDefinitionKeysUserTasks(@RequestBody AuditUser user) {
+        TaskService taskService = processEngine.getTaskService();
+        TaskQuery query = taskService.createTaskQuery().processDefinitionKeyIn(user.getProcessDefinitionKeys());
+
+        query.taskAssignee(user.getUserId());
+        query.orderByTaskCreateTime().desc();
+        List<Task> list = null;
+        if (user.getPage() != PageDto.DEFAULT_PAGE) {
+            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
+        } else {
+            list = query.list();
+        }
+        JSONObject taskBusinessKeyMap = null;
+        List<JSONObject> tasks = new ArrayList<>();
+        for (Task task : list) {
+            taskBusinessKeyMap = new JSONObject();
+            String processInstanceId = task.getProcessInstanceId();
+            //3.使用流程实例,查询
+            ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+            //4.使用流程实例对象获取BusinessKey
+            String business_key = pi.getBusinessKey();
+            taskBusinessKeyMap.put(business_key, task.getId());
+            taskBusinessKeyMap.put("taskId", task.getId());
+            taskBusinessKeyMap.put("id", business_key);
+            tasks.add(taskBusinessKeyMap);
+        }
+        return tasks;
+    }
+
+    /**
+     * 查询用户任务数
+     *
+     * @param user
+     * @return
+     */
+    public long getDefinitionKeysUserHistoryTaskCount(@RequestBody AuditUser user) {
+        HistoryService historyService = processEngine.getHistoryService();
+//        Query query = historyService.createHistoricTaskInstanceQuery()
+//                .processDefinitionKey("complaint")
+//                .taskAssignee(user.getUserId());
+
+        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
+                .processDefinitionKeyIn(user.getProcessDefinitionKeys())
+                .taskAssignee(user.getUserId())
+                .finished();
+        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
+            historicTaskInstanceQuery.taskName("complaint");
+        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
+            historicTaskInstanceQuery.taskName("complaitDealUser");
+        }
+
+        Query query = historicTaskInstanceQuery;
+
+        return query.count();
+    }
+
+    /**
+     * 获取用户审批的任务
+     *
+     * @param user 用户信息
+     */
+    public List<JSONObject> getDefinitionKeysUserHistoryTasks(@RequestBody AuditUser user) {
+        HistoryService historyService = processEngine.getHistoryService();
+
+        HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
+                .processDefinitionKeyIn(user.getProcessDefinitionKeys())
+                .taskAssignee(user.getUserId())
+                .finished();
+        if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) {
+            historicTaskInstanceQuery.taskName("complaint");
+        } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) {
+            historicTaskInstanceQuery.taskName("complaitDealUser");
+        }
+
+        Query query = historicTaskInstanceQuery.orderByHistoricTaskInstanceStartTime().desc();
+
+        List<HistoricTaskInstance> list = null;
+        if (user.getPage() != PageDto.DEFAULT_PAGE) {
+            list = query.listPage((user.getPage() - 1) * user.getRow(), user.getRow());
+        } else {
+            list = query.list();
+        }
+        JSONObject taskBusinessKeyMap = null;
+        List<JSONObject> tasks = new ArrayList<>();
+        List<String> complaintIds = new ArrayList<>();
+        for (HistoricTaskInstance task : list) {
+            taskBusinessKeyMap = new JSONObject();
+            String processInstanceId = task.getProcessInstanceId();
+            //3.使用流程实例,查询
+            HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+            //4.使用流程实例对象获取BusinessKey
+            String business_key = pi.getBusinessKey();
+            taskBusinessKeyMap.put(business_key, task.getId());
+            taskBusinessKeyMap.put("taskId", task.getId());
+            taskBusinessKeyMap.put("id", business_key);
+            tasks.add(taskBusinessKeyMap);
+        }
+
+        return tasks;
+    }
 
     @Java110Transactional
     public boolean completeTask(@RequestBody JSONObject reqJson) {

+ 41 - 0
springboot/src/main/java/com/java110/boot/smo/undo/impl/UndoSMOImpl.java

@@ -4,7 +4,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.java110.boot.smo.DefaultAbstractComponentSMO;
 import com.java110.boot.smo.undo.IUndoSMO;
 import com.java110.core.context.IPageData;
+import com.java110.dto.itemReleaseType.ItemReleaseTypeDto;
+import com.java110.dto.oaWorkflow.OaWorkflowDto;
+import com.java110.dto.user.UserDto;
+import com.java110.dto.workflow.WorkflowDto;
+import com.java110.entity.audit.AuditUser;
 import com.java110.entity.component.ComponentValidateResult;
+import com.java110.intf.common.IItemReleaseTypeV1InnerServiceSMO;
+import com.java110.intf.common.IOaWorkflowUserInnerServiceSMO;
+import com.java110.intf.oa.IOaWorkflowInnerServiceSMO;
 import com.java110.utils.exception.SMOException;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +22,8 @@ import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -25,6 +35,13 @@ public class UndoSMOImpl extends DefaultAbstractComponentSMO implements IUndoSMO
     @Autowired
     private RestTemplate restTemplate;
 
+    @Autowired
+    private IOaWorkflowUserInnerServiceSMO oaWorkflowUserInnerServiceSMOImpl;
+
+
+    @Autowired
+    private IOaWorkflowInnerServiceSMO oaWorkflowInnerServiceSMOImpl;
+
     @Override
     public ResponseEntity<String> listUndos(IPageData pd) throws SMOException {
         return businessProcess(pd);
@@ -134,10 +151,34 @@ public class UndoSMOImpl extends DefaultAbstractComponentSMO implements IUndoSMO
         } else {
             doing.put("allocation", "0");
         }
+        getItemReleaseCount(result, doing);
 
         return ResultVo.createResponseEntity(doing);
     }
 
+    private void getItemReleaseCount(ComponentValidateResult result, JSONObject data) {
+        OaWorkflowDto oaWorkflowDto = new OaWorkflowDto();
+        oaWorkflowDto.setState(OaWorkflowDto.STATE_COMPLAINT);
+        oaWorkflowDto.setFlowType(OaWorkflowDto.FLOW_TYPE_ITEM_RELEASE);
+        List<OaWorkflowDto> oaWorkflowDtos = oaWorkflowInnerServiceSMOImpl.queryOaWorkflows(oaWorkflowDto);
+
+        if (oaWorkflowDtos == null || oaWorkflowDtos.size() < 1) {
+            data.put("itemReleaseCount", "0");
+            return ;
+        }
+        List<String> flowIds = new ArrayList<>();
+        for (OaWorkflowDto tmpOaWorkflowDto : oaWorkflowDtos) {
+            flowIds.add(WorkflowDto.DEFAULT_PROCESS + tmpOaWorkflowDto.getFlowId());
+        }
+
+        AuditUser auditUser = new AuditUser();
+        auditUser.setUserId(result.getUserId());
+        auditUser.setProcessDefinitionKeys(flowIds);
+
+        long itemReleaseCount = oaWorkflowUserInnerServiceSMOImpl.getDefinitionKeysUserTaskCount(auditUser);
+        data.put("itemReleaseCount", itemReleaseCount);
+    }
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }