ソースを参照

Merge branch 'master' of http://121.41.40.202:3000/zhuwei/bladex

huangtf 1 年間 前
コミット
97aa36ba77

+ 3 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.java

@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.TableInfo;
+import org.springblade.manager.entity.TextdictInfo;
 import org.springblade.manager.entity.WbsTree;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.injector.EasyBaseMapper;
@@ -98,4 +99,6 @@ public interface WbsTreePrivateMapper extends EasyBaseMapper<WbsTreePrivate> {
     void syncCurrentFormInProject(@Param("wbsTreePrivate") WbsTreePrivate wbsTreePrivate);
 
     Set<Long> getAllPrivateTableByIds(@Param("projectId") Long projectId,@Param("ids") List<Long> ids);
+
+    List<TextdictInfo> getALLTableConfig(@Param("ids") Set<Long> ids);
 }

+ 6 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.xml

@@ -792,6 +792,12 @@
             #{id}
         </foreach>
     </select>
+    <select id="getALLTableConfig" resultType="org.springblade.manager.entity.TextdictInfo">
+        select * from m_textdict_info where is_deleted = 0 and tab_id in
+        <foreach collection="ids" item="id"  open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
 
     <delete id="delTabProjectById">
         delete

+ 2 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreePrivateService.java

@@ -86,6 +86,8 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
     //批量重新保存文件htmlUrl
     void batchResetHtmlUrl(List<WbsTreePrivate> wbsTreePrivateList) throws IOException, InterruptedException;
 
+    void batchSynTableConfig(Map<Long,Long> mapList);
+
     List<WbsTreePrivateVO> getMixRatioTestTree(String pKeyId);
 
     Map<String, List<Object>> treeRecordTrial(String wbsId, String projectId, String pKeyId);

+ 16 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -80,6 +80,7 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
 
 import java.io.*;
 import java.net.URL;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.*;
@@ -1507,16 +1508,28 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
                             String myData = DataInfo.get(val) + "";
                             if ((myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
+
                                 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                                 sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
                                 SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
+
                                 if (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
 
                                     myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
                                     String[] dataVal = myData.split(",");
-
-                                    Date Start_dataStr = sdf.parse(dataVal[0]);
-                                    Date end_dataStr = sdf.parse(dataVal[1]);
+                                    Date Start_dataStr = new Date();
+                                    Date end_dataStr = new Date();
+                                    try {
+                                        if(myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0){
+                                            Start_dataStr = sdf.parse(dataVal[0]);
+                                            end_dataStr = sdf.parse(dataVal[1]);
+                                        }else{
+                                            Start_dataStr = formatStr.parse(dataVal[0]);
+                                            end_dataStr = formatStr.parse(dataVal[1]);
+                                        }
+                                    }catch (ParseException e){
+                                        throw new ServiceException("日期绑定错误");
+                                    }
                                     String StartDate = formatStr.format(Start_dataStr);
                                     String endDate = formatStr.format(end_dataStr);
                                     if (StartDate.equals(endDate)) {

+ 181 - 127
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -57,6 +57,7 @@ import java.sql.Types;
 import java.time.LocalDateTime;
 import java.io.*;
 import java.util.*;
+import java.util.function.BiPredicate;
 import java.util.function.BinaryOperator;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -899,144 +900,167 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
             if (selectNodeNow == null) {
                 throw new ServiceException("未获取到当前选择同步的节点信息,请联系管理员");
             }
-            if (("private").equals(projectInfo.getReferenceWbsTemplateType())) {
-                // ---------私有才需要引用同步---------节点参数nodeId绑定的是m_wbs_private 的p_key_id  ;同节点下mapping scope=35 共用一个formula;也就是说同一个节点下的同一个element都指向同一个公式
-                /*全部查出来,pkeyId-id-paramId  source:key  最后比较;同节点相同k的参数都指向同一个公式,mapping 对象除了elementId不一样其它都一样*/
-                /*同步的范围不一定是整棵树,可以是局部分支*/
-                //获取当前私有引用模板的根节点信息
-                WbsTreePrivate sourceRootNode = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda().select(WbsTreePrivate::getWbsId, WbsTreePrivate::getProjectId)
-                        .eq(WbsTreePrivate::getPKeyId, selectNodeNow.getWbsId()).eq(WbsTreePrivate::getParentId, 0L).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1));
+            List<WbsTreePrivate> selectNodeAndChildNodes = Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
+            selectNodeAndChildNodes.add(selectNodeNow);
+            List<Long> distNodeIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+            /*源配置sourceListMap,目标配置distListMap*/
+            List<Map<String, Object>> distListMap = this.jdbcTemplate.queryForList("select a.id,a.name,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
+                    "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + distNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(projectId));
+            List<Map<String, Object>> sourceListMap =this.getSourceListMap(projectInfo,selectNodeNow,selectNodeAndChildNodes);
+            compareAndSync(sourceListMap,distListMap,projectId);
+            return true;
+        }
+        return false;
+    }
 
-                List<WbsTreePrivate> selectNodeAndChildNodes = Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
-                selectNodeAndChildNodes.add(selectNodeNow);
-                List<Long> sourceNodeIds = jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_private where id in(" + selectNodeAndChildNodes.stream().map(WbsTreePrivate::getId).map(Object::toString).collect(Collectors.joining(",")) + ") and  is_deleted=0 and project_id =" + sourceRootNode.getProjectId(), Long.class);
-                List<Long> distNodeIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
-                List<Map<String, Object>> sourceListMap = this.jdbcTemplate.queryForList("select a.id,a.name ,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
-                        "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + sourceNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(sourceRootNode.getProjectId()));
-                List<Map<String, Object>> distListMap = this.jdbcTemplate.queryForList("select a.id,a.name,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
-                        "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + distNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(projectId));
-
-                /*存在多个同名参数;保留日期最新那个参数*/
-                BinaryOperator<Map<String, Object>> mapBinaryOperator = (m1, m2) -> {
-                    LocalDateTime sldt = ((Timestamp) m1.get("updateTime")).toLocalDateTime();
-                    LocalDateTime tldt = ((Timestamp) m2.get("updateTime")).toLocalDateTime();
-                    return sldt.isAfter(tldt) ? m1 : m2;
-                };
-                Map<String, Map<String, Object>> sourceMap = sourceListMap.stream().collect(Collectors.toMap(m -> m.get("privateId").toString() + m.get("k"), m -> m, mapBinaryOperator));
-                Map<String, Map<String, Object>> distMap = distListMap.stream().collect(Collectors.toMap(m -> m.get("privateId").toString() + m.get("k"), m -> m, mapBinaryOperator));
-                /*比较的结果*/
-                Map<String, Map<String, Object>> updateMap = new HashMap<>();
-                List<Map<String, Object>> insertMapList = new ArrayList<>();
-                sourceMap.forEach((k, v) -> {
-                    if (distMap.containsKey(k)) {
-                        String s = Func.toStr(v.get("v"));
-                        Map<String, Object> u = distMap.get(k);
-                        String t = Func.toStr(u.get("v"));
-                        if (!s.equals(t)) {
-                            LocalDateTime sldt = ((Timestamp) v.get("updateTime")).toLocalDateTime();
-                            LocalDateTime tldt = ((Timestamp) u.get("updateTime")).toLocalDateTime();
-                            /*假如内容不一样,且模版最后更新时间更晚,则覆盖*/
-                            if (sldt.isAfter(tldt)) {
-                                u.put("v", s);
-                                updateMap.put(u.get("id").toString(), u);
-                            }
-                        }
-                    } else {
-                        /*假如对应节点不存在,则把节点内容添加到待新增列表*/
-                        //  insertMap.put(v.get("privateId").toString() + v.get("k"), v);
-                        insertMapList.add(v);
-                    }
-                });
-                List<WbsParam> updateList;
-                if (!updateMap.isEmpty()) {
-                    updateList = Optional.ofNullable(this.wbsParamServiceImpl.list(Wrappers.<WbsParam>lambdaQuery().in(WbsParam::getId, new ArrayList<>(updateMap.keySet())))).orElse(new ArrayList<>());
-                    updateList.forEach(e -> {
-                        e.setV(updateMap.get(e.getId().toString()).get("v").toString());
-                    });
-                    if (!updateList.isEmpty()) {
-                        this.wbsParamServiceImpl.saveOrUpdateBatch(updateList, 1000);
+    private List<Map<String, Object>> getSourceListMap(ProjectInfo projectInfo, WbsTreePrivate selectNodeNow,List<WbsTreePrivate> selectNodeAndChildNodes){
+        List<Map<String, Object>> sourceListMap = new ArrayList<>();
+        if (("private").equals(projectInfo.getReferenceWbsTemplateType())) {
+            // 节点参数nodeId绑定的是m_wbs_private 的p_key_id
+            /*全部查出来,pkeyId-id-paramId  source:key  最后比较;同节点相同k的参数都指向同一个公式,mapping 对象除了elementId不一样其它都一样*/
+            /*同步的范围不一定是整棵树,可以是局部分支*/
+            //获取当前私有引用模板的根节点信息
+            WbsTreePrivate sourceRootNode = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda().select(WbsTreePrivate::getWbsId, WbsTreePrivate::getProjectId)
+                    .eq(WbsTreePrivate::getPKeyId, selectNodeNow.getWbsId()).eq(WbsTreePrivate::getParentId, 0L).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getType, 1));
+/*                List<WbsTreePrivate> selectNodeAndChildNodes = Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
+                selectNodeAndChildNodes.add(selectNodeNow);*/
+            List<Long> sourceNodeIds = jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_private where id in(" + selectNodeAndChildNodes.stream().map(WbsTreePrivate::getId).map(Object::toString).collect(Collectors.joining(",")) + ") and  is_deleted=0 and project_id =" + sourceRootNode.getProjectId(), Long.class);
+            /*List<Long> distNodeIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());*/
+             sourceListMap = this.jdbcTemplate.queryForList("select a.id,a.name ,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
+                    "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + sourceNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(sourceRootNode.getProjectId()));
+                /*List<Map<String, Object>> distListMap = this.jdbcTemplate.queryForList("select a.id,a.name,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
+                        "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + distNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(projectId));*/
+           /* compareAndSync(sourceListMap,distListMap,projectId);*/
+        }else{
+            /*WBS同步到public*/
+               /* List<WbsTreePrivate> selectNodeAndChildNodes = Optional.ofNullable(this.getChildNodes(selectNodeNow)).orElse(new ArrayList<>());
+                selectNodeAndChildNodes.add(selectNodeNow);*/
+            List<Long> sourceNodeIds = jdbcTemplate.queryForList("select id from m_wbs_tree where id in ("+selectNodeAndChildNodes.stream().map(WbsTreePrivate::getId).map(Objects::toString).collect(Collectors.joining(","))+")",Long.class);
+            /* List<Long> distNodeIds = selectNodeAndChildNodes.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());*/
+             sourceListMap = this.jdbcTemplate.queryForList("select  a.id,a.name ,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  from m_wbs_param a join m_wbs_tree b on a.node_id = b.id where b.id in(" + sourceNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1");
+                /*List<Map<String, Object>> distListMap = this.jdbcTemplate.queryForList("select a.id,a.name,a.k,a.v,a.remark,a.node_id nodeId ,b.id privateId,a.update_time updateTime  " +
+                        "from m_wbs_param a join m_wbs_tree_private b on a.node_id = b.p_key_id   where  b.project_id in(?) and b.p_key_id in(" + distNodeIds.stream().map(Object::toString).collect(Collectors.joining(",")) + ") and a.is_deleted=0  and a.type=1 ", Long.parseLong(projectId));*/
+           /* compareAndSync(sourceListMap,distListMap,projectId);*/
+        }
+        return sourceListMap;
+    }
+
+    public void compareAndSync( List<Map<String, Object>> sourceListMap,List<Map<String, Object>> distListMap,String projectId){
+        /*存在多个同名参数;保留日期最新那个参数*/
+        BinaryOperator<Map<String, Object>> mapBinaryOperator = (m1, m2) -> {
+            Object sts = m1.get("updateTime");
+            Object dts = m2.get("updateTime");
+            if (Func.isNotEmpty(sts) && Func.isNotEmpty(dts)) {
+                LocalDateTime sldt = ((Timestamp) sts).toLocalDateTime();
+                LocalDateTime tldt = ((Timestamp)dts).toLocalDateTime();
+                return sldt.isAfter(tldt) ? m1 : m2;
+            }
+            return m2;
+        };
+        BiPredicate<Map<String, Object>, Map<String, Object>> timeComparison = (m1, m2) -> mapBinaryOperator.apply(m1,m2).equals(m1);
+        /*id+k 就是匹配码*/
+        /*用匹配码链接源节点和目标节点的参数*/
+        /*源无目标有不复制,源有目标无,则复制*/
+        /*源有目标有,源的日期更新则复制*/
+        Map<String, Map<String, Object>> sourceMap = sourceListMap.stream().collect(Collectors.toMap(m -> m.get("privateId").toString() + m.get("k"), m -> m, mapBinaryOperator));
+        Map<String, Map<String, Object>> distMap = distListMap.stream().collect(Collectors.toMap(m -> m.get("privateId").toString() + m.get("k"), m -> m, mapBinaryOperator));
+        /*比较的结果*/
+        Map<String, Map<String, Object>> updateMap = new HashMap<>();
+        List<Map<String, Object>> insertMapList = new ArrayList<>();
+        sourceMap.forEach((k, v) -> {
+            if (distMap.containsKey(k)) {
+                String s = Func.toStr(v.get("v"));
+                Map<String, Object> u = distMap.get(k);
+                String t = Func.toStr(u.get("v"));
+                if (!s.equals(t)) {
+                    if(timeComparison.test(v,u)){
+                        u.put("v", s);
+                        updateMap.put(u.get("id").toString(), u);
                     }
+                   /* Object sts=v.get("updateTime");
+                    Object dts=u.get("updateTime");
+                    if(Func.isNotEmpty(sts)&&Func.isNotEmpty(dts)) {
+                        LocalDateTime sldt = ((Timestamp)sts).toLocalDateTime();
+                        LocalDateTime tldt = ((Timestamp)dts).toLocalDateTime();
+                        *//*假如内容不一样,且模版最后更新时间更晚,则覆盖*//*
+                        if (sldt.isAfter(tldt)) {
+                            u.put("v", s);
+                            updateMap.put(u.get("id").toString(), u);
+                        }
+                    }*/
                 }
-                List<WbsParam> insertList = new ArrayList<>();
-                if (!insertMapList.isEmpty()) {
-                    List<WbsTreePrivate> targetList = Optional.ofNullable(this.list(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, projectId).in(WbsTreePrivate::getId, insertMapList.stream().map(m -> m.get("privateId")).collect(Collectors.toList())))).orElse(new ArrayList<>());
-                    Map<String, List<Map<String, Object>>> insertGroup = insertMapList.stream().collect(Collectors.groupingBy(m -> m.get("privateId").toString()));
-                    targetList.forEach(e -> {
-                        List<Map<String, Object>> nodeParamList = insertGroup.get(e.getId().toString());
-                        if (Func.isNotEmpty(nodeParamList)) {
-                            nodeParamList.forEach(kmp -> {
-                                if (kmp != null) {
-                                    WbsParam one = BeanUtil.toBean(kmp, WbsParam.class);
-                                    one.setNodeId(e.getPKeyId());
-                                    insertList.add(one);
-                                }
-                            });
+            } else {
+                /*假如对应节点不存在,则把节点内容添加到待新增列表*/
+                //  insertMap.put(v.get("privateId").toString() + v.get("k"), v);
+                insertMapList.add(v);
+            }
+        });
+/*        if(true){
+            return;
+        }*/
+        List<WbsParam> updateList;
+        if (!updateMap.isEmpty()) {
+            updateList = Optional.ofNullable(this.wbsParamServiceImpl.list(Wrappers.<WbsParam>lambdaQuery().in(WbsParam::getId, new ArrayList<>(updateMap.keySet())))).orElse(new ArrayList<>());
+            updateList.forEach(e -> {
+                e.setV(updateMap.get(e.getId().toString()).get("v").toString());
+            });
+            if (!updateList.isEmpty()) {
+                this.wbsParamServiceImpl.saveOrUpdateBatch(updateList, 1000);
+            }
+        }
+        List<WbsParam> insertList = new ArrayList<>();
+        if (!insertMapList.isEmpty()) {
+            List<WbsTreePrivate> targetList = Optional.ofNullable(this.list(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, projectId).in(WbsTreePrivate::getId, insertMapList.stream().map(m -> m.get("privateId")).collect(Collectors.toList())))).orElse(new ArrayList<>());
+            Map<String, List<Map<String, Object>>> insertGroup = insertMapList.stream().collect(Collectors.groupingBy(m -> m.get("privateId").toString()));
+            targetList.forEach(e -> {
+                List<Map<String, Object>> nodeParamList = insertGroup.get(e.getId().toString());
+                if (Func.isNotEmpty(nodeParamList)) {
+                    nodeParamList.forEach(kmp -> {
+                        if (kmp != null) {
+                            WbsParam one = BeanUtil.toBean(kmp, WbsParam.class);
+                            one.setNodeId(e.getPKeyId());
+                            insertList.add(one);
                         }
                     });
-                    if (!insertList.isEmpty()) {
-                        insertList.forEach(i -> i.setId(SnowFlakeUtil.getId()));
-                        this.wbsParamServiceImpl.saveOrUpdateBatch(insertList, 1000);
-                        /*生成公式,并自动绑定元素,同key复用一个公式*/
-                        Map<String, Long> formulaIdeyMap = this.wbsParamServiceImpl.formulaIdKeyMap(insertList.stream().map(WbsParam::getK).collect(Collectors.toList()));
-                      /*  Map<Long, Formula> insertFormulaMap = insertList.stream().map(e -> {
-                            Map<String, Object> tmpMap = new HashMap<>();
-                            Formula formula = new Formula();
-                            formula.setOutm(Formula.FULL);
-                            formula.setParamId(e.getId());
-                            Map<String, String> keyMap = new HashMap<>();
-                            keyMap.put("name", e.getName());
-                            keyMap.put("id", e.getId().toString());
-                            tmpMap.put(e.getK(), keyMap);
-                            if (RegexUtil.match(ParamElements.LEVEL_REG, e.getV().trim())) {
-                                *//*取层级*//*
-                                formula.setFormula("FC.tree(trees,WP[" + e.getK() + "])");
-                            } else {
-                                *//*直接取数*//*
-                                formula.setFormula("WP[" + e.getK() + "]");
-                            }
-                            formula.setMap(JSON.toJSONString(tmpMap));
-                            formula.setId(SnowFlakeUtil.getId());
-                            return formula;
-                        }).collect(Collectors.toMap(Formula::getParamId, f -> f));*/
-                        List<String> nodeIds = insertList.stream().map(WbsParam::getNodeId).distinct().map(Objects::toString).collect(Collectors.toList());
-                        /*每道工序下包含的元素集合*/
-                        List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList(
-                                "select c.e_name as name ,c.id,a.p_key_id pKeyId from m_wbs_tree_private a " +
-                                        "inner join m_wbs_tree_private b on (a.id=b.parent_id and a.wbs_id=b.wbs_id) " +
-                                        "inner join m_wbs_form_element c on  b.init_table_id=c.f_id " +
-                                        "where  b.project_id=" + projectId + " and a.p_key_id in(" + String.join(",", nodeIds) + ")  and b.is_deleted=0 and c.is_deleted=0 ");
-
-                        Map<String, List<Map<String, Object>>> groupElementNode = listMaps.stream().collect(Collectors.groupingBy(e -> Func.toStr(e.get("pKeyId"))));
-                        List<ElementFormulaMapping> insertEfm = new ArrayList<>();
-                        insertList.forEach(p -> {
-                            List<Map<String, Object>> elementMap = groupElementNode.get(p.getNodeId().toString());
-                            // Formula formula = insertFormulaMap.get(p.getId());
-                            if (Func.isNotEmpty(elementMap)) {
-                                elementMap.forEach(m -> {
-                                    if (com.mixsmart.utils.StringUtils.handleNull(m.get("name")).contains(p.getName())) {
-                                        /*匹配名称,且该元素没有绑定任何节点参数公式*/
-                                        ElementFormulaMapping efm = new ElementFormulaMapping();
-                                        efm.setScope(FormulaBean.PARAM);
-                                        efm.setParamId(p.getId());
-                                        efm.setElementId(Long.parseLong(m.get("id").toString()));
-                                        efm.setFormulaId(formulaIdeyMap.get(p.getK()));
-                                        insertEfm.add(efm);
-                                    }
-                                });
+                }
+            });
+            if (!insertList.isEmpty()) {
+                insertList.forEach(i -> i.setId(SnowFlakeUtil.getId()));
+                this.wbsParamServiceImpl.saveOrUpdateBatch(insertList, 1000);
+                /*生成公式,并自动绑定元素,同key复用一个公式*/
+                Map<String, Long> formulaIdeyMap = this.wbsParamServiceImpl.formulaIdKeyMap(insertList.stream().map(WbsParam::getK).collect(Collectors.toList()));
+
+                List<String> nodeIds = insertList.stream().map(WbsParam::getNodeId).distinct().map(Objects::toString).collect(Collectors.toList());
+                /*每道工序下包含的元素集合*/
+                List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList(
+                        "select c.e_name as name ,c.id,a.p_key_id pKeyId from m_wbs_tree_private a " +
+                                "inner join m_wbs_tree_private b on (a.id=b.parent_id and a.wbs_id=b.wbs_id) " +
+                                "inner join m_wbs_form_element c on  b.init_table_id=c.f_id " +
+                                "where  b.project_id=" + projectId + " and a.p_key_id in(" + String.join(",", nodeIds) + ")  and b.is_deleted=0 and c.is_deleted=0 ");
+
+                Map<String, List<Map<String, Object>>> groupElementNode = listMaps.stream().collect(Collectors.groupingBy(e -> Func.toStr(e.get("pKeyId"))));
+                List<ElementFormulaMapping> insertEfm = new ArrayList<>();
+                insertList.forEach(p -> {
+                    List<Map<String, Object>> elementMap = groupElementNode.get(p.getNodeId().toString());
+                    if (Func.isNotEmpty(elementMap)) {
+                        elementMap.forEach(m -> {
+                            if (com.mixsmart.utils.StringUtils.handleNull(m.get("name")).contains(p.getName())) {
+                                /*匹配名称,且该元素没有绑定任何节点参数公式*/
+                                ElementFormulaMapping efm = new ElementFormulaMapping();
+                                efm.setScope(FormulaBean.PARAM);
+                                efm.setParamId(p.getId());
+                                efm.setElementId(Long.parseLong(m.get("id").toString()));
+                                efm.setFormulaId(formulaIdeyMap.get(p.getK()));
+                                insertEfm.add(efm);
                             }
                         });
-/*                        if (insertFormulaMap.size() > 0) {
-                            this.formulaService.saveBatch(insertFormulaMap.values(), 1000);
-                        }*/
-                        if (insertEfm.size() > 0) {
-                            this.elementFormulaMappingService.saveBatch(insertEfm, 1000);
-                        }
                     }
+                });
+                if (insertEfm.size() > 0) {
+                    this.elementFormulaMappingService.saveBatch(insertEfm, 1000);
                 }
             }
-            return true;
         }
-        return false;
     }
 
 
@@ -1737,6 +1761,36 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         }
     }
 
+    /**
+     * 批量同步表单配置信息
+     * @param map
+     */
+    @Async
+    @Override
+    public void batchSynTableConfig(Map<Long,Long> map) {
+        System.out.println("异步同步表单配置:map大小:"+map.size());
+        //获取所有表单配置
+        List<TextdictInfo> list = baseMapper.getALLTableConfig(map.keySet());
+        if (list != null && list.size() > 0){
+            System.out.println("异步同步表单配置:配置总条数:"+list.size());
+            //id设置为null,替换调tableId
+            for (TextdictInfo info : list) {
+                info.setId(null);
+                info.setTabId(map.get(Long.parseLong(info.getTabId()))+"");
+            }
+            //批量保存
+            if (list.size() > 1000) {
+                List<List<TextdictInfo>> splitList = CommonUtil.splitList(list, 800);
+                for (List<TextdictInfo> infos : splitList) {
+                    textDictInfoService.saveBatch(infos);
+                }
+            } else if (list.size() > 0) {
+                textDictInfoService.saveBatch(list);
+            }
+        }
+
+    }
+
     @Override
     public List<WbsTreePrivateVO> getMixRatioTestTree(String pKeyId) {
         WbsTreePrivate wbsTreePrivate = baseMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pKeyId));