Bläddra i källkod

Merge branch 'master' of http://47.110.251.215:3000/java_org/bladex

huangtf 2 år sedan
förälder
incheckning
738d790070

+ 10 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/FormulaOption.java

@@ -9,7 +9,15 @@ import lombok.Data;
  */
 @Data
 public class FormulaOption {
+    private Long id;
+    private Long parentId;
+    private String ekey;
+    private Long contractId;
+    private String value;
     private Long pKeyId;
-    private Integer value;
-    private String key;
+    private Integer scope;
+
+    public String toSql(){
+        return ","+parentId+",'"+ekey+"',"+contractId+",'"+value+"',"+pKeyId+","+scope;
+    }
 }

+ 0 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/WbsTreeContractDTO.java

@@ -1,6 +1,5 @@
 package org.springblade.manager.dto;
 
-import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;

+ 28 - 13
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -541,7 +541,7 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/abolishOne-sj")
     @ApiOperationSupport(order = 24)
     @ApiOperation(value = "单个废除-首件")
-    public R<Boolean> abolishOneSJ(@RequestParam String primaryKeyId,@RequestParam String id) {
+    public R<Boolean> abolishOneSJ(@RequestParam String primaryKeyId, @RequestParam String id) {
         //查询填报状态
         InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery()
                 .eq(InformationQuery::getId, id));
@@ -682,13 +682,13 @@ public class InformationWriteQueryController extends BladeController {
     @PostMapping("/queryNodeStatus-sj")
     @ApiOperationSupport(order = 23)
     @ApiOperation(value = "/查询节点状态-首件")
-    @ApiModelProperty(value = "id",notes = "当前该条首件的记录id")
-    public R<String> queryNodeStatusSj(@RequestParam String primaryKeyId, @RequestParam String classify,String id) {
+    @ApiModelProperty(value = "id", notes = "当前该条首件的记录id")
+    public R<String> queryNodeStatusSj(@RequestParam String primaryKeyId, @RequestParam String classify, String id) {
         //记录状态
         String status = "1";
         //查询填报状态,type=3首件
         InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery()
-                .eq(InformationQuery::getId,id)
+                .eq(InformationQuery::getId, id)
                 .eq(InformationQuery::getType, 3)
         );
         if (businessData != null) {
@@ -1309,8 +1309,13 @@ public class InformationWriteQueryController extends BladeController {
                     //获取当前所有复制的节点的最大sort
                     String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";
                     List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                    List<Integer> collect = query.stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
-                    Integer max = collect.stream().reduce(collect.get(0), Integer::max);
+                    List<Integer> collect = query.stream().filter(f -> ObjectUtils.isNotEmpty(f.getSort())).collect(Collectors.toList()).stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
+                    Integer max;
+                    if (collect.size() > 0) {
+                        max = collect.stream().reduce(collect.get(0), Integer::max);
+                    } else {
+                        max = 1;
+                    }
                     //设置sort
                     newData.setSort(max);
 
@@ -1385,8 +1390,13 @@ public class InformationWriteQueryController extends BladeController {
                         //获取当前所有复制的节点的最大sort
                         String sql = "select sort from m_wbs_tree_contract where contract_id = '" + node.getContractId() + "' and (id = '" + node.getId() + "' or old_id = '" + node.getId() + "')";
                         List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                        List<Integer> collect = query.stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
-                        Integer max = collect.stream().reduce(collect.get(0), Integer::max);
+                        List<Integer> collect = query.stream().filter(f -> ObjectUtils.isNotEmpty(f.getSort())).collect(Collectors.toList()).stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
+                        Integer max;
+                        if (collect.size() > 0) {
+                            max = collect.stream().reduce(collect.get(0), Integer::max);
+                        } else {
+                            max = 1;
+                        }
                         //设置sort
                         newData.setSort(max);
 
@@ -1822,8 +1832,13 @@ public class InformationWriteQueryController extends BladeController {
                 //获取当前所有复制的节点的最大sort
                 String sql = "select sort from m_wbs_tree_contract where contract_id = '" + treeContract.getContractId() + "' and (id = '" + half.getId() + "' or old_id = '" + half.getId() + "')";
                 List<WbsTreeContract> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
-                List<Integer> collect = query.stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
-                Integer max = collect.stream().reduce(collect.get(0), Integer::max);
+                List<Integer> collect = query.stream().filter(f -> ObjectUtils.isNotEmpty(f.getSort())).collect(Collectors.toList()).stream().map(WbsTreeContract::getSort).collect(Collectors.toList());
+                Integer max;
+                if (collect.size() > 0) {
+                    max = collect.stream().reduce(collect.get(0), Integer::max);
+                } else {
+                    max = 1;
+                }
                 //设置sort
                 newData.setSort(max);
 
@@ -1897,7 +1912,7 @@ public class InformationWriteQueryController extends BladeController {
         if (saveList.size() > 0) {
             //保存施工日志
             if (saveLedger.size() > 0) {
-                this.constructionLedgerService.saveBatch(saveLedger,1000);
+                this.constructionLedgerService.saveBatch(saveLedger, 1000);
             }
 
             try {
@@ -2137,8 +2152,8 @@ public class InformationWriteQueryController extends BladeController {
                     List<String> treeIds = queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
                     //通过合同段主键在首件关联表中查询出所有数据
                     List<TreeContractFirst> firstList = treeContractFirstService.list(new LambdaQueryWrapper<TreeContractFirst>().in(TreeContractFirst::getWbsNodeId, treeIds));
-                    List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId()+"")).collect(Collectors.toList());
-                    queryDataResult = queryDataResult.stream().filter(qdr->list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
+                    List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId() + "")).collect(Collectors.toList());
+                    queryDataResult = queryDataResult.stream().filter(qdr -> list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
 //                    for (QueryProcessDataVO queryProcessDataVO : queryDataResult) {
 //                        TreeContractFirst first = treeContractFirstService.getOne(new LambdaQueryWrapper<TreeContractFirst>()
 //                                .eq(TreeContractFirst::getWbsNodeId, queryProcessDataVO.getPrimaryKeyId()));

+ 25 - 0
blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java

@@ -1801,6 +1801,12 @@ public class CustomFunction {
 	public static Object gfn(Object ob1,Object ob2){
 		return _gfn(ob1,ob2);
 	}
+	public static Object gfn(List<Object> list){
+		if(ListUtils.isNotEmpty(list)){
+			return _gfn(list.toArray());
+		}
+		return "";
+	}
 	/**
 	 * @Description  返回第一个不为空的对象
 	 * @Param
@@ -1830,6 +1836,23 @@ public class CustomFunction {
 	}
 
 
+	public Object checkItemName(List<Object> data,List<Object> names){
+		if(ListUtils.isNotEmpty(data)&&ListUtils.isNotEmpty(names)&&data.size()!=names.size()){
+			StringBuilder sb = new StringBuilder();
+			for(int i=0;i< data.size();i++){
+				List<Object> datas= obj2ListNe(data.get(i));
+				if(datas.stream().anyMatch(e->StringUtils.isNotEmpty(e)&&StringUtils.isNotEquals("/",e))){
+					sb.append(names.get(i)).append(",");
+				}
+			}
+			if(sb.length()>1){
+				sb.deleteCharAt(sb.length()-1);
+			}
+			return sb.toString();
+		}
+		return "";
+	}
+
 	/**
 	 * @Description 三元运算 bool?o1:o2 ,默认返回空字符串
 	 * @Param [bool, o1, o2]
@@ -2595,6 +2618,8 @@ public class CustomFunction {
 
 
 
+
+
 	/**
 	 * @Description String 转List
 	 * @Param [o, separator]

+ 9 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -3,6 +3,7 @@ package org.springblade.manager.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -131,6 +132,8 @@ public class ExcelTabController extends BladeController {
     // 项目信息
     private final IProjectInfoService projectInfoService;
 
+    private final ITableInfoService tableInfoService;
+
     /**
      * 详情
      */
@@ -489,6 +492,12 @@ public class ExcelTabController extends BladeController {
         //解析
         Element table = doc.select("table").first();
         Elements trs = table.select("tr");
+        if (aPrivate.getInitTableId() == null){
+            org.springblade.manager.entity.TableInfo tableInfo = tableInfoService.getOne(new LambdaQueryWrapper<org.springblade.manager.entity.TableInfo>()
+                    .eq(org.springblade.manager.entity.TableInfo::getTabEnName, aPrivate.getInitTableName()));
+            aPrivate.setInitTableId(tableInfo.getId()+"");
+            updateWrapper.set("init_table_id", tableInfo.getId()+"");
+        }
 
         List<WbsFormElement> elementList = wbsFormElementService.selectElementListByFid(aPrivate.getInitTableId() + "");
 

+ 53 - 20
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -21,15 +21,9 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.RegexUtil;
 import org.springblade.core.tool.utils.StringPool;
 import org.springblade.manager.dto.*;
-import org.springblade.manager.entity.ElementFormulaMapping;
-import org.springblade.manager.entity.Formula;
-import org.springblade.manager.entity.TextdictInfo;
-import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.entity.*;
 import org.springblade.manager.formula.KeyMapper;
-import org.springblade.manager.service.IElementFormulaMappingService;
-import org.springblade.manager.service.IExcelTabService;
-import org.springblade.manager.service.ITextdictInfoService;
-import org.springblade.manager.service.IWbsTreeContractService;
+import org.springblade.manager.service.*;
 import org.springblade.manager.service.impl.FormulaServiceImpl;
 import org.springblade.manager.wrapper.FormulaWrapper;
 import org.springframework.dao.EmptyResultDataAccessException;
@@ -56,6 +50,7 @@ public class FormulaController {
     private final IExcelTabService tabService;
     private final IElementFormulaMappingService elementFormulaMappingService;
     private final JdbcTemplate jdbcTemplate;
+    private final IContractInfoService contractInfoService;
     private final ITextdictInfoService textdictInfoService;
     /**
      * 新增或修改
@@ -315,14 +310,24 @@ public class FormulaController {
     @GetMapping("/panel")
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "公式交互面板", notes = "公式交互面板")
-    public R<Object> panel(Long pkeyId ,String key,String projectId)  {
+    public R<Object> panel(FormulaOption fo)  {
              Map<String,Object> result = new LinkedHashMap<>();
-              key=key.replaceAll("__[\\d_]+","");
-              List<KeyMapper> kms =  this.service.getKeyMapperList(Collections.singletonList(pkeyId),projectId);
-              if(Func.isNotEmpty(kms)&&Func.isNotEmpty(kms.get(0).getFormulaId())){
-                   Formula formula = this.service.getById(kms.get(0).getFormulaId());
+             String  key=fo.getEkey().replaceAll("__[\\d_]+","");;
+              ContractInfo contract = this.contractInfoService.getById(fo.getContractId());
+              List<KeyMapper> kms =  this.service.getKeyMapperList(Collections.singletonList(fo.getPKeyId()),contract.getPId());
+              KeyMapper keyMapper=null;
+              if(Func.isNotEmpty(kms)){
+                Optional<KeyMapper> optionalKeyMapper=  kms.stream().filter(e->StringUtils.isEquals(e.getField(),key)).findFirst();
+                if(optionalKeyMapper.isPresent()){
+                    keyMapper=optionalKeyMapper.get();
+                }
+              }
+              if(keyMapper!=null&&Func.isNotEmpty(keyMapper.getFormulaId())){
+                   Formula formula = this.service.getById(keyMapper.getFormulaId());
+                   /*临时处理,等确定数据结构在优化*/
                    if(formula.getFormula().contains(".option")){
                        result.put("type","radio");
+                       result.put("scope",0);
                        Map<String,Object> info = new LinkedHashMap<>();
                        result.put("info",info);
                        info.put("label","是否引用公式数据");
@@ -334,9 +339,38 @@ public class FormulaController {
                         value.add(n);
                         y.put("label","是");
                         y.put("value",1);
-                        n.put("label","是");
-                        n.put("value",1);
-                   }
+                        n.put("label","否");
+                        n.put("value",0);
+                       /*针对元素级别*/
+                       List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pKeyId,val value,e_key ekey,contract_id contractId,scope from m_formula_option where scope=0 and parent_id ="+fo.getParentId()+" and e_key='"+key+"' and contract_id="+fo.getContractId());
+                       if(Func.isNotEmpty(mapList)){
+                           result.put("data",mapList.get(0));
+                       }
+                   }else if (StringUtils.isEquals("MILE",formula.getNumber())){
+                      if(StringUtils.isEquals(key,formula.getRelyList().get(0).split(StringPool.COLON)[1])){
+                          result.put("type","radio");
+                          result.put("scope",1);
+                          Map<String,Object> info = new LinkedHashMap<>();
+                          result.put("info",info);
+                          info.put("label","竖直方向");
+                          List<Map<String,Object>> value = new ArrayList<>();
+                          info.put("value",value);
+                          Map<String,Object> y=new LinkedHashMap<>();
+                          Map<String,Object> n=new LinkedHashMap<>();
+                          value.add(y);
+                          value.add(n);
+                          y.put("label","是");
+                          y.put("value",1);
+                          n.put("label","否");
+                          n.put("value",0);
+                          List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pKeyId,val value,e_key ekey,contract_id contractId,scope from m_formula_option where scope=1 and table_id="+fo.getPKeyId()+" and parent_id ="+fo.getParentId()+" and e_key='"+key+"' and contract_id="+fo.getContractId());
+                          if(Func.isNotEmpty(mapList)){
+                              result.put("data",mapList.get(0));
+                          }
+                      }
+                  }
+              }else{
+                  R.success("暂无公式控件");
               }
              return R.data(result);
     }
@@ -345,11 +379,10 @@ public class FormulaController {
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "公式交互面板参数保存", notes = "公式交互面板参数保存")
     public R<Object> panelSave( @RequestBody FormulaOption fo){
-            List<Map<String,Object>> mapList = this.jdbcTemplate.queryForList("select parent_id pid,contract_id cid from m_wbs_tree_contract where p_key_id="+fo.getPKeyId());
-            if(Func.isNotEmpty(mapList)){
-                  Map<String,Object> map = mapList.get(0);
-                   this.jdbcTemplate.execute("");
+            if(Func.isNotEmpty(fo.getId())){
+                this.jdbcTemplate.execute("delete from m_formula_option where id="+fo.getId());
             }
+            this.jdbcTemplate.execute("insert into m_formula_option values ("+SnowFlakeUtil.getId()+fo.toSql()+")");
            return    R.success("保存成功");
     }
 

+ 10 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -482,6 +482,16 @@ public class WbsTreePrivateController extends BladeController {
         return R.status(wbsTreePrivateService.syncNodeParam(projectId));
     }
 
+    /**
+     * 同步项目下所有节点的电签默认信息
+     */
+    @ApiOperationSupport(order = 14)
+    @ApiOperation(value = "同步项目下所有节点的电签默认信息", notes = "传入项目projectId")
+    @RequestMapping(value = "/sync-project-eVisa", method = RequestMethod.POST)
+    public R syncProjectEVisa(@RequestParam String projectId) {
+        return R.status(wbsTreePrivateService.syncProjectEVisa(projectId));
+    }
+
     /**
      * 同步项目下节点的元素表
      */

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

@@ -73,4 +73,7 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
     List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id);
 
     Object getExcelHtml(String primaryKeyId) throws IOException;
+
+    boolean syncProjectEVisa(String projectId);
+
 }

+ 9 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaServiceImpl.java

@@ -248,9 +248,6 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
 
     public Map<String, String> getTableCols(AppWbsTreeContractVO wbsTreeContract) throws FileNotFoundException {
         Map<String, String> dataMap = new HashMap<>();
-        if (Func.isEmpty(wbsTreeContract.getHtmlUrl())) {
-            return dataMap;
-        }
         File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
         FileInputStream fileInputStream = new FileInputStream(file1);
         String htmlString = IoUtil.readToString(fileInputStream);
@@ -759,10 +756,13 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                              data.put(eNames.get(i),values.get(i));
                          }
                          f=f.replace(m.group(),putDataWithKey(data));
+                         if(f.contains("ENAME")){
+                             f=f.replace("ENAME",putDataWithKey(target.stream().map(FormData::getEName).collect(Collectors.toList())));
+                         }
                      }
                  }
                  if(f.contains(".option")){
-                     Matcher m = RegexUtils.matcher("T\\(com.mixsmart.utils.CustomFunction\\)\\.(option)\\(([^]]+)\\)",f);
+                     Matcher m = RegexUtils.matcher("T\\(com.mixsmart.utils.CustomFunction\\)\\.(optionC?)\\(([^]]+)\\)",f);
                      while (m.find()){
                        String[] args= m.group(2).split(",");
                        String flag=args[0];
@@ -774,6 +774,11 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                                Map<String,Object> dictMap = (Map<String, Object>) this.constantMap.computeIfAbsent("OPTION",k->new HashMap<>());
                                flag=StringUtils.handleNull(dictMap.get(findStr));
                            }
+                       }else if(flag.contains("E[")){
+                           List<FormData> target = getFormDataByCode(flag);
+                           if(target.size()>1){
+                              flag= target.get(0).getValues().stream().map(ElementData::stringValue).filter(StringUtils::isNotEmpty).findFirst().orElse("0");
+                           }
                        }
                        if(Func.isBlank(flag)){
                            /*默认0*/

+ 94 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -57,6 +57,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     private final ProjectInfoMapper projectInfoMapper;
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
     private final JdbcTemplate jdbcTemplate;
+    private final TextdictInfoServiceImpl textDictInfoService;
 
     @Override
     public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
@@ -1617,6 +1618,99 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         return R.data(table + "");
     }
 
+    @Override
+    public boolean syncProjectEVisa(String projectId) {
+        if (StringUtils.isNotEmpty(projectId)) {
+            ProjectInfo projectInfo = projectInfoMapper.selectById(projectId);
+            if (projectInfo != null && ("private").equals(projectInfo.getReferenceWbsTemplateType()) && ObjectUtils.isNotEmpty(projectInfo.getReferenceWbsTemplateId())) {
+                //构造参数集合
+                List<TextdictInfo> insertData = new ArrayList<>();
+                Map<String, List<TextdictInfo>> textDictInfoData = new HashMap<>();
+
+                //获取当前引用的项目节点树的根节点信息
+                WbsTreePrivate oneRecordRoot = this.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, projectInfo.getReferenceWbsTemplateId()));
+
+                //获取当前项目下节点树所有节点、表、独立表
+                List<WbsTreePrivate> wbsTreePrivatesNodeAndTabNow = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, projectId).eq(WbsTreePrivate::getWbsType, 1).eq(WbsTreePrivate::getStatus, 1).and(obj -> obj.eq(WbsTreePrivate::getType, 1).or().eq(WbsTreePrivate::getType, 2)));
+                List<WbsTreePrivate> wbsTreePrivatesTableDL = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, projectId).eq(WbsTreePrivate::getType, 10).eq(WbsTreePrivate::getParentId, -10).eq(WbsTreePrivate::getStatus, 1));
+                wbsTreePrivatesNodeAndTabNow.addAll(wbsTreePrivatesTableDL);
+                //获取当前项目节点树的所有id
+                List<Long> saveIds = wbsTreePrivatesNodeAndTabNow.stream().filter(f -> f.getType().equals(1)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
+
+                //获取当前引用的节点树下所有节点、表、独立表
+                List<WbsTreePrivate> wbsTreePrivatesNodeAndTab = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, oneRecordRoot.getProjectId()).eq(WbsTreePrivate::getWbsId, oneRecordRoot.getWbsId()).eq(WbsTreePrivate::getStatus, 1).and(obj -> obj.eq(WbsTreePrivate::getType, 1).or().eq(WbsTreePrivate::getType, 2)));
+                List<WbsTreePrivate> wbsTreePrivatesTableDLOld = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, oneRecordRoot.getProjectId()).eq(WbsTreePrivate::getType, 10).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getParentId, -10).isNull(WbsTreePrivate::getWbsId));
+                wbsTreePrivatesNodeAndTab.addAll(wbsTreePrivatesTableDLOld);
+
+                //获取当前对应电签位置配置信息
+                List<Long> pIdsDL = wbsTreePrivatesNodeAndTab.stream().filter(f -> f.getType().equals(10) || f.getType().equals(2)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
+                String sql = "select * from m_textdict_info where tab_id in (" + org.apache.commons.lang.StringUtils.join(pIdsDL, ",") + ") and is_deleted = 0";
+                List<TextdictInfo> textDictInfosAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
+
+                //构造原始电签信息
+                for (WbsTreePrivate wbsTreePrivate : wbsTreePrivatesNodeAndTab) {
+                    if (wbsTreePrivate.getType() == 2) {
+                        for (Long id : saveIds) {
+                            if (id.equals(wbsTreePrivate.getParentId())) {
+                                //根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
+                                List<TextdictInfo> textDictInfos = textDictInfosAll.stream().filter(f ->
+                                        ObjectUtils.isNotEmpty(f.getTabId()) && f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
+                                if (textDictInfos.size() > 0) {
+                                    textDictInfoData.put(wbsTreePrivate.getPKeyId() + "," + wbsTreePrivate.getId(), textDictInfos);
+                                }
+                            }
+                        }
+                    }
+
+                    if (wbsTreePrivate.getType() == 10 && wbsTreePrivate.getParentId() == -10) { //type=10,parentId=-10 独立库
+                        //判断是否存在独立表单,存在则不新增
+                        List<WbsTreePrivate> collect = wbsTreePrivatesTableDL.stream().filter(f -> f.getId().equals(wbsTreePrivate.getId())).collect(Collectors.toList());
+                        if (collect.size() == 0) {
+                            //根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
+                            List<TextdictInfo> textDictInfos = textDictInfosAll.stream().filter(f -> ObjectUtils.isNotEmpty(f.getTabId())
+                                    && f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
+                            if (textDictInfos.size() > 0) {
+                                textDictInfoData.put(wbsTreePrivate.getPKeyId() + "," + wbsTreePrivate.getId(), textDictInfos);
+                            }
+                        }
+                    }
+                }
+
+                //只同步独立库中有关联过清表的元素表type=10,以及原始方式的元素表type=2
+                List<WbsTreePrivate> collect = wbsTreePrivatesNodeAndTabNow.stream().filter(f -> f.getType().equals(2) || (f.getHtmlUrl() != null && f.getType().equals(10))).collect(Collectors.toList());
+
+                collect.forEach(tree -> {
+                    textDictInfoData.forEach((k, v) -> {
+                        String nodeId = k.split(",")[1];
+                        if (tree.getId().equals(Long.parseLong(nodeId))) {
+                            for (TextdictInfo textdictInfo : v) {
+                                TextdictInfo obj = BeanUtil.copyProperties(textdictInfo, TextdictInfo.class);
+                                assert obj != null;
+                                obj.setTabId(String.valueOf(tree.getPKeyId()));
+                                obj.setId(SnowFlakeUtil.getId());
+                                insertData.add(obj);
+                            }
+                        }
+                    });
+                });
+
+                //去重,删除当前表的电签信息
+                for (TextdictInfo insertDatum : insertData) {
+                    String delSql = "delete from m_textdict_info where tab_id = " + insertDatum.getTabId();
+                    jdbcTemplate.execute(delSql);
+                }
+
+                //新增
+                textDictInfoService.insertBatch(insertData, 1000);
+
+                return true;
+            } else {
+                throw new ServiceException("未获取到项目的关联的私有wbs树信息");
+            }
+        }
+        return false;
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public boolean insertBatch(Collection<WbsTreePrivate> entityList, int batchSize) {
         try {

+ 11 - 61
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeServiceImpl.java

@@ -550,12 +550,12 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             List<String> idList2 = new ArrayList<>();
 
             if (pawDTO.getReferenceType().equals("public")) {
-                //当前公有引用ids
+                //当前公有引用
                 List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId()).eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId()).eq(WbsTreePrivate::getType, 1));
                 List<String> collect = wbsTreePrivates.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
                 idList2.addAll(collect);
             } else if (pawDTO.getReferenceType().equals("private")) {
-                //当前私有引用ids
+                //当前私有引用
                 List<WbsTreePrivate> wbsTreePrivates2 = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getWbsId, pawDTO.getPrimaryKeyId()).eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId()).eq(WbsTreePrivate::getType, 1));
                 List<String> collect = wbsTreePrivates2.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
                 idList2.addAll(collect);
@@ -564,14 +564,13 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
             List<String> saveIds = idList1.stream().filter(f -> !idList2.contains(f)).collect(Collectors.toList());
             List<String> delIds = idList2.stream().filter(f -> !idList1.contains(f)).collect(Collectors.toList());
 
-            //1.同步私有电签默认信息
+            //TODO -------同步私有电签默认信息--------
             if (saveIds.size() == 0 && delIds.size() == 0) {
                 if (pawDTO.getReferenceType().equals("private")) {
-
-                    //新增独立表单库数据
+                    //新增独立表单
                     this.insertDLTabAsync(pawDTO);
 
-                    //获取私有引用项目的wbs树的所有节点、元素表、独立表(type=10)
+                    /*//获取私有引用项目的wbs树的所有节点、元素表、独立表(type=10)
                     WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getPKeyId, pawDTO.getPrimaryKeyId()));
                     List<WbsTreePrivate> wbsTreePrivateAllOld = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
                             .eq(WbsTreePrivate::getProjectId, Long.parseLong(wbsTreePrivate.getProjectId()))
@@ -588,11 +587,11 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     List<WbsTreePrivate> wbsTreePrivateNowTables = wbsTreePrivatesAllNow.stream().filter(f -> f.getType() == 2 || f.getType() == 10).collect(Collectors.toList());
 
                     //同步私有-电签匹配数据、默认信息数据
-                    this.insertTextDictInfoAsync(WbsTreePrivateTables, wbsTreePrivateNowTables);
+                    this.insertTextDictInfoAsync(WbsTreePrivateTables, wbsTreePrivateNowTables);*/
                 }
 
             } else {
-                //2.删除
+                //TODO ------------删除------------
                 if (delIds.size() > 0) {
                     if (pawDTO.getReferenceType().equals("public")) {
                         List<Long> ids1 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
@@ -652,26 +651,22 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     }
                 }
 
-                //3.新增
+                //TODO ------------新增------------
                 if (saveIds.size() > 0) {
                     if (saveIds.size() >= 1000) {
-                        //加锁
                         String redisValue = bladeRedis.get("submit-wbs-project:" + pawDTO.getProjectId());
                         if (StringUtils.isNotEmpty(redisValue) && redisValue.equals("1")) {
                             throw new ServiceException("请勿重复提交,请60秒后再尝试");
                         }
                     }
 
-                    //公有-数据初始化节点
+                    //构造入参集合
                     List<WbsTreePrivate> insertData1 = new ArrayList<>();
-                    //私有-数据初始化节点
                     List<WbsTreePrivate> insertData2 = new ArrayList<>();
-                    //私有-电签匹配数据、默认信息数据
-                    List<TextdictInfo> insertData3 = new ArrayList<>();
 
                     if (pawDTO.getReferenceType().equals("public")) {
                         List<WbsTree> addListData = new ArrayList<>();
-                        //获取当前wbs树下所有节点、表信息
+                        //获取当前树下所有节点、表信息
                         List<WbsTree> treesAll = baseMapper.selectList(Wrappers.<WbsTree>lambdaQuery().eq(WbsTree::getWbsId, pawDTO.getWbsId()).eq(WbsTree::getStatus, 1));
                         for (WbsTree wbsTree : treesAll) {
                             for (String id : saveIds) {
@@ -698,29 +693,19 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                     } else if (pawDTO.getReferenceType().equals("private")) {
                         List<WbsTreePrivate> addListData = new ArrayList<>();
 
-                        //私有引用-电签匹配数据、默认信息数据
-                        Map<Long, List<TextdictInfo>> textDictInfoData = new HashMap<>();
-
-                        //查询出当前wbs树下所有节点、表信息(type=10独立表)
+                        //获取当前树下所有节点、表信息(type=10独立表)
                         List<WbsTreePrivate> wbsTreePrivatesNodeAndTab = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
                                 .eq(WbsTreePrivate::getStatus, 1)
                                 .eq(WbsTreePrivate::getProjectId, pawDTO.getReferencePrivateWbsProjectId())
                                 .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
                                 .and(obj -> obj.eq(WbsTreePrivate::getType, 1).or().eq(WbsTreePrivate::getType,2))
                         );
-
                         List<WbsTreePrivate> wbsTreePrivatesTableDLOld = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, pawDTO.getReferencePrivateWbsProjectId()).eq(WbsTreePrivate::getType, 10).eq(WbsTreePrivate::getStatus, 1).eq(WbsTreePrivate::getParentId, -10).isNull(WbsTreePrivate::getWbsId));
                         wbsTreePrivatesNodeAndTab.addAll(wbsTreePrivatesTableDLOld);
 
                         //获取当前项目下的所有独立表
                         List<WbsTreePrivate> wbsTreePrivatesTableDL = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId()).eq(WbsTreePrivate::getType, 10).eq(WbsTreePrivate::getParentId, -10).eq(WbsTreePrivate::getStatus, 1));
 
-                        //查询对应电签位置配置信息的pKeyIds
-                        List<Long> pIdsDL = wbsTreePrivatesNodeAndTab.stream().filter(f -> f.getType().equals(10) || f.getType().equals(2)).collect(Collectors.toList()).stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList());
-                        String pKeyIds = StringUtils.join(pIdsDL, ",");
-                        String sql = "select `id`,`name`,`type`,tab_id,col_key,sig_role_id,is_deleted,sig_role_name,col_name,pyzbx,pyzby from m_textdict_info where tab_id in (" + pKeyIds + ") and is_deleted = 0";
-                        List<TextdictInfo> textDictInfosAll = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TextdictInfo.class));
-
                         for (WbsTreePrivate wbsTreePrivate : wbsTreePrivatesNodeAndTab) {
                             if (wbsTreePrivate.getType() == 1 || wbsTreePrivate.getType() == 2) {
                                 for (String id : saveIds) {
@@ -729,13 +714,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
 
                                     } else if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
                                         addListData.add(wbsTreePrivate);
-
-                                        //根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
-                                        List<TextdictInfo> textDictInfos = textDictInfosAll.stream().filter(f -> ObjectUtils.isNotEmpty(f.getTabId())
-                                                && f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
-                                        if (textDictInfos.size() > 0) {
-                                            textDictInfoData.put(wbsTreePrivate.getPKeyId(), textDictInfos);
-                                        }
                                     }
                                 }
                             }
@@ -745,13 +723,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                                 List<WbsTreePrivate> collect = wbsTreePrivatesTableDL.stream().filter(f -> f.getId().equals(wbsTreePrivate.getId())).collect(Collectors.toList());
                                 if (collect.size() == 0) {
                                     addListData.add(wbsTreePrivate);
-
-                                    //根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
-                                    List<TextdictInfo> textDictInfos = textDictInfosAll.stream().filter(f -> ObjectUtils.isNotEmpty(f.getTabId())
-                                            && f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
-                                    if (textDictInfos.size() > 0) {
-                                        textDictInfoData.put(wbsTreePrivate.getPKeyId(), textDictInfos);
-                                    }
                                 }
                             }
                         }
@@ -777,23 +748,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                                     wbsTreePrivate.setWbsType(String.valueOf(pawDTO.getWbsType()));
                                 }
                                 insertData2.add(wbsTreePrivate);
-
-                                //电签
-                                if (wbsTreePrivate.getType() == 2 || (wbsTreePrivate.getType() == 10 && wbsTreePrivate.getParentId() == -10)) { //type=10,parentId=-10 独立库引用元素库
-                                    if (textDictInfoData.size() > 0) {
-                                        textDictInfoData.forEach((k, v) -> {
-                                            if (tree.getPKeyId().equals(k)) {
-                                                for (TextdictInfo textdictInfo : v) {
-                                                    TextdictInfo obj = BeanUtil.copyProperties(textdictInfo, TextdictInfo.class);
-                                                    assert obj != null;
-                                                    obj.setTabId(String.valueOf(wbsTreePrivate.getPKeyId()));
-                                                    obj.setId(SnowFlakeUtil.getId());
-                                                    insertData3.add(obj);
-                                                }
-                                            }
-                                        });
-                                    }
-                                }
                             }
                         });
                     }
@@ -813,9 +767,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
 
                         this.insertBatch(insertData2, 1000);
 
-                        //电签
-                        textDictInfoService.insertBatch(insertData3, 1000);
-
                         if (pawDTO.getWbsType() == 1) {
                             projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
                         }
@@ -824,7 +775,6 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
                         }
                     }
                     if (saveIds.size() >= 1000) {
-                        //解锁
                         bladeRedis.set("submit-wbs-project:" + pawDTO.getProjectId(), "1");
                         bladeRedis.expire("submit-wbs-project:" + pawDTO.getProjectId(), 60);
                     }