zhou-hao 7 anni fa
parent
commit
d1eabfe0f8

+ 8 - 1
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-flowable/src/main/java/org/hswebframework/web/workflow/flowable/controller/FlowableCoreController.java

@@ -15,6 +15,7 @@ import org.hswebframework.web.workflow.flowable.service.BpmActivityService;
 import org.hswebframework.web.workflow.flowable.service.BpmProcessService;
 import org.hswebframework.web.workflow.flowable.service.BpmTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.HashMap;
@@ -38,9 +39,12 @@ public class FlowableCoreController {
     BpmActivityService bpmActivityService;
     @Autowired
     ActDefService actDefService;
-    @Autowired
+    @Autowired(required = false)
     DynamicFormOperationService dynamicFormOperationService;
 
+    private void assertDynamicFormReady(){
+        Assert.notNull(dynamicFormOperationService,"未引入动态表单依赖");
+    }
     /**
      * 获取所有可用流程(流程配置与流程启动都可用该方法获取)
      * @return
@@ -62,6 +66,7 @@ public class FlowableCoreController {
      */
     @GetMapping("open-form/{id}")
     public ResponseMessage<Map<String,PagerResult<Object>>> openForm(@PathVariable("id") String procDefId){
+        assertDynamicFormReady();
         Map<String,PagerResult<Object>> map = new HashMap<>();
         ActivityImpl activity = bpmActivityService.getStartEvent(procDefId);
         ActDefEntity actDefEntity = actDefService.selectSingle(single(ActDefEntity.actId,activity.getId()));
@@ -79,6 +84,7 @@ public class FlowableCoreController {
      */
     @PostMapping("start/{formId}-{defId}")
     public ResponseMessage<Map<String, Object>> startProc(@PathVariable String formId,@PathVariable String defId, @RequestBody Map<String, Object> data) {
+        assertDynamicFormReady();
         PersonnelAuthorization authorization = PersonnelAuthorization
                 .current()
                 .orElseThrow(NotFoundException::new);
@@ -113,6 +119,7 @@ public class FlowableCoreController {
      */
     @PutMapping("complete/{formId}-{taskId}")
     public ResponseMessage<Map<String,Object>> complete(@PathVariable String formId,@PathVariable String taskId, @RequestBody UpdateParamEntity<Map<String, Object>> paramEntity){
+        assertDynamicFormReady();
         PersonnelAuthorization authorization = PersonnelAuthorization
                 .current()
                 .orElseThrow(NotFoundException::new);

+ 10 - 2
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-flowable/src/main/java/org/hswebframework/web/workflow/flowable/service/imp/BpmUtilsServiceImp.java

@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -25,13 +26,20 @@ public class BpmUtilsServiceImp implements BpmUtilsService {
 
     protected Logger logger = LoggerFactory.getLogger(this.getClass());
 
-    @Autowired
+    @Autowired(required = false)
     PersonService personService;
-    @Autowired
+    @Autowired(required = false)
     RelationInfoService relationInfoService;
 
+    public void assertOrgModuleReady(){
+        Assert.notNull(personService,"未引入组织架构模块依赖");
+        Assert.notNull(relationInfoService,"未引入组织架构模块依赖");
+
+    }
+
     @Override
     public List<String> selectUserIdsBy(String userId, ActDefEntity actDefEntity) {
+        assertOrgModuleReady();
         List<String> list = new ArrayList<>();
         // 根据配置类型  获取人员信息 设置待办人
         if ("person".equals(actDefEntity.getType())) { // 矩阵

+ 36 - 0
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/pom.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>hsweb-system-workflow</artifactId>
+        <groupId>org.hswebframework.web</groupId>
+        <version>3.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>hsweb-system-workflow-starter</artifactId>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-workflow-dao-mybatis</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-workflow-flowable</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hswebframework.web</groupId>
+            <artifactId>hsweb-system-workflow-service-simple</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+        </dependency>
+    </dependencies>
+</project>

+ 19 - 0
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/java/org/hswebframework/web/workflow/starter/WorkFlowAutoConfiguration.java

@@ -0,0 +1,19 @@
+package org.hswebframework.web.workflow.starter;
+
+import org.hswebframework.web.service.workflow.ActDefService;
+import org.hswebframework.web.service.workflow.simple.SimpleActDefService;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ComponentScan("org.hswebframework.web.workflow")
+public class WorkFlowAutoConfiguration {
+
+    @Bean
+    @ConditionalOnMissingBean(ActDefService.class)
+    public SimpleActDefService simpleActDefService(){
+        return new SimpleActDefService();
+    }
+}

+ 3 - 0
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-starter/src/main/resources/META-INF/spring.factories

@@ -0,0 +1,3 @@
+# Auto Configure
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.hswebframework.web.workflow.starter.WorkFlowAutoConfiguration

+ 1 - 0
hsweb-system/hsweb-system-workflow/pom.xml

@@ -20,6 +20,7 @@
         <module>hsweb-system-workflow-dao</module>
         <module>hsweb-system-workflow-entity</module>
         <module>hsweb-system-workflow-service</module>
+        <module>hsweb-system-workflow-starter</module>
     </modules>