gongdecai 3 лет назад
Родитель
Сommit
d5650d2d7f

+ 73 - 8
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/CommonUserController.java

@@ -16,6 +16,9 @@ import com.winsea.svc.base.security.exception.AuthException;
 import com.winsea.svc.base.security.service.IAccountService;
 import com.winsea.svc.base.security.util.AuthSecurityUtils;
 import com.winsea.svc.base.security.vo.command.AuthUserCommand;
+import com.winsea.svc.base.workflow.entity.Workflow;
+import com.winsea.svc.base.workflow.entity.WorkflowHistoricTask;
+import com.winsea.svc.base.workflow.entity.WorkflowStep;
 import com.winsea.svc.notice.entity.NoticeTaskInfo;
 import com.yh.saas.common.support.util.IdGenerator;
 import com.yh.saas.common.support.util.StringUtils;
@@ -23,7 +26,10 @@ import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
 import com.yh.saas.plugin.yiliangyiyun.entity.UnimallMessage;
 import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
 import com.yh.saas.plugin.yiliangyiyun.service.ICommonUserService;
+import com.yh.saas.plugin.yiliangyiyun.service.INewWorkflowService;
 import com.yh.saas.plugin.yiliangyiyun.util.WebSocket;
+import com.yh.saas.toolkit.workflow.service.IWorkflowHistoryService;
+import org.activiti.engine.impl.util.CollectionUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -33,7 +39,7 @@ import java.util.List;
 
 /**
  * <p>
- *  前端控制器
+ * 前端控制器
  * </p>
  *
  * @author Gongdc
@@ -54,56 +60,110 @@ public class CommonUserController {
 
     @Autowired
     private ICommonStaffService staffService;
-
+    @Autowired
+    private IWorkflowHistoryService workflowHistoryService;
+    @Autowired
+    private INewWorkflowService workflowService;
     @Autowired
     private ICommonCompanyService companyService;
     @Autowired
     private WebSocket webSocket;
 
+    /**
+     * 查询历史
+     *
+     * @param businessKey
+     * @return
+     */
+    @GetMapping("/getHis")
+    public List<WorkflowHistoricTask> getHis(String businessKey, String workflowId) throws ServiceException {
+        List<WorkflowHistoricTask> workflowHistoricTasks = workflowHistoryService.getInstanceHistories(businessKey);
+        Workflow workflow = workflowService.getWorkflowDetail(workflowId);
+        if (CollectionUtil.isNotEmpty(workflowHistoricTasks) && workflow != null) {
+            List<WorkflowStep> workflowSteps = workflow.getSteps();
+            WorkflowHistoricTask workflowHistoricTask = workflowHistoricTasks.get(workflowHistoricTasks.size() - 1);
+            int a = 0;
+            for (int i = 0; i < workflowSteps.size(); i++) {
+                if ((workflowSteps.get(i).getAuditRoles().equals(AuthSecurityUtils.getStaffById(workflowHistoricTask.getOperatorId()).getMajorRoleId()))
+                        || (workflowSteps.get(i).getAuditUsers().equals(workflowHistoricTask.getOperatorId()))) {
+                    break;
+                } else {
+                    a = a + 1;
+                    continue;
+                }
+
+
+            }
+            if (a < workflowSteps.size()) {
+                for (int i = a+1; i < workflowSteps.size(); i++) {
+                    WorkflowHistoricTask workflowHistoricTask1 = new WorkflowHistoricTask();
+                    workflowHistoricTask1.setOperatorMajorRoleName(workflowSteps.get(i).getDesc());
+                    workflowHistoricTasks.add(workflowHistoricTask1);
+                }
+
+            }
+
+        }
+        else{
+            List<WorkflowStep> workflowSteps = workflow.getSteps();
+            for (int i = 0; i < workflowSteps.size(); i++) {
+                WorkflowHistoricTask workflowHistoricTask1 = new WorkflowHistoricTask();
+                workflowHistoricTask1.setOperatorMajorRoleName(workflowSteps.get(i).getDesc());
+                workflowHistoricTasks.add(workflowHistoricTask1);
+            }
+        }
+        return workflowHistoricTasks;
+    }
+
     /**
      * 注册
+     *
      * @param commonUser
      * @return
      */
     @PostMapping("/register")
-    public  String register(@RequestBody CommonUser commonUser) throws ServiceException {
+    public String register(@RequestBody CommonUser commonUser) throws ServiceException {
         return commonUserService.register(commonUser);
     }
 
     /**
      * 重置密码
+     *
      * @param commonUser
      * @return
      */
     @PostMapping("/resetPassword")
-    public  String resetPassword(@RequestBody CommonUser commonUser) throws ServiceException {
+    public String resetPassword(@RequestBody CommonUser commonUser) throws ServiceException {
         return commonUserService.resetPassword(commonUser);
     }
 
 
     /**
      * 修改用户信息
+     *
      * @param commonUser
      * @return
      */
     @PostMapping("/editUserInfo")
-    public  String editUserInfo(@RequestBody CommonUser commonUser) throws ServiceException {
+    public String editUserInfo(@RequestBody CommonUser commonUser) throws ServiceException {
         return commonUserService.editUserInfo(commonUser);
     }
 
     /**
      * 发送验证码
+     *
      * @param phone
      * @return
      * @throws ServiceException
      */
     @GetMapping("/sendVerifyCode")
-    public  String sendVerifyCode(String phone) throws ServiceException {
+    public String sendVerifyCode(String phone) throws ServiceException {
         return commonUserService.sendVerifyCode(phone);
     }
 
     /**
      * 登录
+     *
      * @param commonUser
      * @return
      * @throws ServiceException
@@ -115,6 +175,7 @@ public class CommonUserController {
 
     /**
      * 快捷登录
+     *
      * @param commonUser
      * @return
      * @throws ServiceException
@@ -123,8 +184,10 @@ public class CommonUserController {
     public CommonUser loginVerifyCode(CommonUser commonUser) throws ServiceException {
         return commonUserService.loginVerifyCode(commonUser);
     }
+
     /**
      * 校验验证码
+     *
      * @param commonUser
      * @return
      * @throws ServiceException
@@ -146,7 +209,6 @@ public class CommonUserController {
     }
 
 
-
     /**
      * 创建登录用户
      *
@@ -181,7 +243,7 @@ public class CommonUserController {
                 compId = companyService.getCompanyIdByDomainName(authUser.getCompanyId(), authUser.getDomainName(),
                         request.getServerName());
 
-                if (StringUtils.isEmpty(compId)){
+                if (StringUtils.isEmpty(compId)) {
                     compId = userService.findPhoneCompId(authUser.getMobilePhone());
                 }
             }
@@ -223,6 +285,7 @@ public class CommonUserController {
     public String checkApp(@RequestBody CommonUser commonUser) throws ServiceException {
         return commonUserService.checkApp(commonUser);
     }
+
     /**
      * Session检测
      *
@@ -243,6 +306,7 @@ public class CommonUserController {
     public List<CommonCompany> getComp() {
         return commonUserService.getComp();
     }
+
     /**
      * 公司
      *
@@ -252,6 +316,7 @@ public class CommonUserController {
     public List<CommonCompany> getCompOwn(String phone) {
         return commonUserService.getCompOwn(phone);
     }
+
     /**
      * 首页公司下拉列表
      *