瀏覽代碼

优化候选人设置

zhouhao 6 年之前
父節點
當前提交
4077daf611

+ 1 - 1
hsweb-system/hsweb-system-dynamic-form/hsweb-system-dynamic-form-local/src/main/java/org/hswebframework/web/service/form/simple/cluster/ClusterDatabaseInit.java

@@ -33,7 +33,7 @@ public class ClusterDatabaseInit {
                 if (formId != null) {
                     DynamicFormColumnBindEntity entity = dynamicFormService.selectLatestDeployed(formId);
                     if (null != entity) {
-                        formDeployService.deploy(entity.getForm(), entity.getColumns(), true);
+                        formDeployService.deploy(entity.getForm(), entity.getColumns(), false);
                     }
                 }
             });

+ 39 - 20
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/DefaultCandidateDimensionParser.java

@@ -1,6 +1,7 @@
 package org.hswebframework.web.workflow.dimension;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import io.vavr.Lazy;
 import org.apache.commons.collections.CollectionUtils;
@@ -10,6 +11,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -19,32 +21,49 @@ public class DefaultCandidateDimensionParser implements CandidateDimensionParser
     @Autowired(required = false)
     private List<CandidateDimensionParserStrategy> strategies;
 
-    @Override
-    public CandidateDimension parse(DimensionContext context, String jsonConfig) {
-        JSONObject jsonObject = JSON.parseObject(jsonConfig);
-        String type = jsonObject.getString("dimension");
-        CandidateDimensionParserStrategy.StrategyConfig config = jsonObject
-                .toJavaObject(CandidateDimensionParserStrategy.StrategyConfig.class);
-        if (config.getConfig() == null) {
-            config.setConfig(jsonObject);
-        }
+    private CandidateDimension parse(DimensionContext context, JSONArray jsonConfig) {
+        List<CandidateDimensionParserStrategy.StrategyConfig> configList = jsonConfig.stream()
+                .filter(json -> json instanceof JSONObject)
+                .map(JSONObject.class::cast)
+                .filter(json -> json.get("dimension") != null && CollectionUtils.isNotEmpty(json.getJSONArray("idList")))
+                .map(json -> {
+                    CandidateDimensionParserStrategy.StrategyConfig config = json.toJavaObject(CandidateDimensionParserStrategy.StrategyConfig.class);
+                    if (config.getConfig() == null) {
+                        config.setConfig(json);
+                    }
+                    return config;
+                }).collect(Collectors.toList());
 
-        if (StringUtils.isEmpty(type)
-                || CollectionUtils.isEmpty(strategies)
-                || CollectionUtils.isEmpty(config.getIdList())) {
+        if (configList.isEmpty()) {
             return CandidateDimension.empty;
         }
-
         return Lazy.val(() -> {
-            List<String> list = strategies
-                    .stream()
-                    .filter(strategy -> strategy.support(type))
-                    .map(strategy -> strategy.parse(context, config))
-                    .filter(CollectionUtils::isNotEmpty)
-                    .flatMap(Collection::stream)
-                    .collect(Collectors.toList());
+            List<String> list = configList.stream()
+                    .flatMap(config ->
+                            strategies
+                                    .stream()
+                                    .filter(strategy -> strategy.support(config.getDimension()))
+                                    .map(strategy -> strategy.parse(context, config))
+                                    .filter(CollectionUtils::isNotEmpty)
+                                    .flatMap(Collection::stream)
+                    ).collect(Collectors.toList());
+
             return (CandidateDimension) () -> list;
         }, CandidateDimension.class);
 
     }
+
+    @Override
+    public CandidateDimension parse(DimensionContext context, String jsonConfig) {
+        JSONArray jsonArray;
+        if (jsonConfig.startsWith("[")) {
+            jsonArray = JSON.parseArray(jsonConfig);
+        } else {
+            JSONObject jsonObject = JSON.parseObject(jsonConfig);
+            jsonArray = new JSONArray();
+            jsonArray.add(jsonObject);
+        }
+        return parse(context, jsonArray);
+
+    }
 }

+ 1 - 0
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/dimension/parser/CandidateDimensionParserStrategy.java

@@ -23,6 +23,7 @@ public interface CandidateDimensionParserStrategy {
     @Getter
     @Setter
     class StrategyConfig {
+        private String       dimension;
 
         private List<String> idList;
 

+ 2 - 4
hsweb-system/hsweb-system-workflow/hsweb-system-workflow-local/src/main/java/org/hswebframework/web/workflow/flowable/FlowableAutoConfiguration.java

@@ -17,12 +17,10 @@ import org.springframework.context.annotation.Configuration;
 
 import java.util.List;
 
-/**
- * Created by Administrator on 2017/7/26.
- */
 @Configuration
 @AutoConfigureAfter(FlowableAutoConfiguration.CustomEntityManagerAutoConfiguration.class)
-@MapperScan(value = "org.hswebframework.web.workflow.dao", markerInterface = Dao.class)
+@MapperScan(value = "org.hswebframework.web.workflow.dao", markerInterface = Dao.class
+        ,sqlSessionFactoryRef = "sqlSessionFactory")
 public class FlowableAutoConfiguration {
 
     @Autowired(required = false)