2 커밋 7847b858f2 ... f09e9ca7b2

작성자 SHA1 메시지 날짜
  chenr f09e9ca7b2 复制表出现两次 3 주 전
  chenr d266b4c10b 复制名称没有编号 3 주 전

+ 12 - 0
blade-service/blade-manager/src/main/java/com/mixsmart/utils/FormulaUtils.java

@@ -1015,8 +1015,18 @@ public class FormulaUtils {
     public static List<Object> slice(List<LocalVariable>  local, String formula){
         int min =0;
         List<Object> result = new ArrayList<>();
+
         try {
             pretreatment(local,formula);
+//            List<Object>  r=new ArrayList<>();
+//            for (LocalVariable l : local) {
+//                if(!l.hasEmptyElementValue()){
+//                    String string = Expression.parse(l.getFormula()).calculate(l.getCurrentMap()).toString();
+//                    r.add(string);
+//                }else {
+//                    r.add("");
+//                }
+//            }
             List<Object>  r= local.stream().map(e-> {
                 /*所有依赖元素的内容必须非空才进行计算,否则返回空值*/
                 return e.hasEmptyElementValue()?"": Expression.parse(e.getFormula()).calculate(e.getCurrentMap()).toString();
@@ -1024,7 +1034,9 @@ public class FormulaUtils {
             if(CollectionUtil.isNotEmpty(r)&&r.stream().anyMatch(StringUtils::isNotEmpty)){
                 result.addAll(r);
             }
+
         }catch (Exception e){
+            e.printStackTrace();
             StaticLog.error("公式:{},执行出错",formula);
         }
         return  result;

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

@@ -1849,7 +1849,6 @@ public class ExcelTabController extends BladeController {
                     if (tabpdf2.exists()) {
                         tabpdf2.delete();
                     }
-
                     FileUtils.mergePdfPublicMethods(datainfo, listPdf);
                     String netUrl = "";
                     if(sys_isonline.equals("20")){

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

@@ -2300,7 +2300,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                         }
                     }
                 }
-//                }
+//               }
             }
         }
 

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

@@ -1990,6 +1990,20 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         return null;
     }
 
+    public Boolean isWorkNode(Long pKeyId){
+        String sql="SELECT * from m_wbs_tree_contract WHERE id=(SELECT parent_id from m_wbs_tree_contract WHERE is_deleted=0 and p_key_id="+pKeyId+")";
+        WbsTreeContract wbsTreeContract= jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
+        if(ObjectUtil.isNotEmpty(wbsTreeContract.getNodeType())){
+            if (wbsTreeContract.getNodeType().equals(6)) {
+                if(ObjectUtil.isNotEmpty(wbsTreeContract.getMajorDataType())){
+                    if(wbsTreeContract.getMajorDataType().equals(4)){
+                        return true;
+                    }
+                }
+            }
+        }
+       return false;
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -2005,7 +2019,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         if(list.size()>0){
             for (WbsTreeContract wbsTreeContract1 : list) {
                 if(wbsTreeContract1.getNodeName().indexOf("JS107")>=0){
-                    target.add(wbsTreeContract1);
+                        target.add(wbsTreeContract1);
                 }
             }
         }
@@ -2020,19 +2034,22 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
             for (WbsTreeContract treeContract : list2) {
                 if(treeContract.getNodeName().indexOf("JS107")>=0){
                     if(!Objects.equals(treeContract.getParentId(), wbsTreeContract2.getId())){
+                        if(isWorkNode(treeContract.getPKeyId())){
                         source.add(treeContract);
                     }
+                  }
                 }
             }
         }
         List<WbsTreeContract>updateList=new ArrayList<>();
-
         for (WbsTreeContract wbsTreeContract : source) {
             Map<String,Object>maps=new HashMap<>();
             for (WbsTreeContract treeContract : target) {
                 //名称相同就复制
                 if(wbsTreeContract.getNodeName().equals(treeContract.getNodeName())){
+                //查出元素
                 List<Map<String, Object>> mapsList = jdbcTemplate.queryForList("select * from " + treeContract.getInitTableName() + " where p_key_id = " + wbsTreeContract.getPKeyId());
+                //不为空的元素
                 if(mapsList.size()>0){
                     for (Map<String, Object> stringObjectMap : mapsList) {
                         for (String s : stringObjectMap.keySet()) {
@@ -2041,12 +2058,54 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
                             }
                         }
                     }
+                 try{
+                     //没保存的新增,保存了就更新
+                     String sql1= "SELECT id FROM `" + treeContract.getInitTableName() + "` WHERE p_key_id = "+treeContract.getPKeyId();
+                      Long id= jdbcTemplate.queryForObject(sql1,Long.class);
+                      //更新
+                     updateRecord(id,maps,treeContract.getInitTableName());
+                 }catch (EmptyResultDataAccessException e){
+                     //新增
+                     String tabName = wbsTreeContract.getInitTableName();
+                     // 字段查询 并去掉公式字段
+                     String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='" + tabName + "' and COLUMN_NAME not in('id','p_key_id')";
+                     Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
+                     colkeys = stringObjectMap.get("colkeys") + "";
+                     String querySql = "insert into " + tabName + " (id,p_key_id," + colkeys + ") select '" + treeContract.getPKeyId() + "','" + treeContract.getPKeyId() + "'," + colkeys + " from " + tabName + " where p_key_id=" + wbsTreeContract.getPKeyId();
+                     jdbcTemplate.execute(querySql);
+                 }
                 }
-
+                updateList.add(wbsTreeContract);
+                b=true;
                 }
             }
         }
-
+        source.removeAll(updateList);
+        for (WbsTreeContract wbsTreeContract : source) {
+            //新增
+            long tabGroupId = SnowFlakeUtil.getId();
+            long newPkId = SnowFlakeUtil.getId();
+            WbsTreeContract wbsTreeContract1 = new WbsTreeContract();
+            BeanUtil.copy(wbsTreeContract, wbsTreeContract1);
+            wbsTreeContract1.setParentId(wbsTreeContract2.getId());
+            wbsTreeContract1.setPKeyId(newPkId);
+            wbsTreeContract1.setTabGroupId(tabGroupId);
+            wbsTreeContract1.setIsCopeTab(2);
+            wbsTreeContract1.setIsTabPdf(1); // pdf 不能预览
+            wbsTreeContract1.setIsBussShow(1); // 是否隐藏表
+            wbsTreeContract1.setTabFileType(1);//没有上传附件
+            wbsTreeContract1.setPdfUrl("");
+            String tabName = wbsTreeContract1.getInitTableName();
+            // 字段查询 并去掉公式字段
+            String colkeys = "SELECT GROUP_CONCAT(COLUMN_NAME) as colkeys from information_schema.COLUMNS c where c.table_name='" + tabName + "' and COLUMN_NAME not in('id','p_key_id')";
+            Map<String, Object> stringObjectMap = jdbcTemplate.queryForMap(colkeys);
+            colkeys = stringObjectMap.get("colkeys") + "";
+            // 复制表数据
+            String querySql = "insert into " + tabName + " (id,p_key_id," + colkeys + ") select '" + newPkId + "','" + newPkId + "'," + colkeys + " from " + tabName + " where p_key_id=" + wbsTreeContract.getPKeyId();
+            jdbcTemplate.execute(querySql);
+            wbsTreeContractService.save(wbsTreeContract1);
+            b=true;
+        }
         if(!b){
             return R.data("请检查工序节点中是否包含JS107表");
         }else {
@@ -2054,6 +2113,28 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
         }
     }
 
+    public void updateRecord(Long id, Map<String, Object> fieldValues,String tableName) {
+        StringBuilder sqlBuilder = new StringBuilder("UPDATE "+tableName+" SET ");
+        StringBuilder paramsBuilder = new StringBuilder();
+        Object[] params = new Object[fieldValues.size() + 1];
+        int paramIndex = 0;
+
+        for (Map.Entry<String, Object> entry : fieldValues.entrySet()) {
+            if (paramIndex > 0) {
+                paramsBuilder.append(", ");
+            }
+            paramsBuilder.append(entry.getKey()).append(" = ?");
+            params[paramIndex++] = entry.getValue();
+        }
+
+        sqlBuilder.append(paramsBuilder.toString());
+        sqlBuilder.append(" WHERE id = ?");
+        params[paramIndex] = id;
+
+        String sql = sqlBuilder.toString();
+        jdbcTemplate.update(sql, params);
+    }
+
     @Override
     public void formulaInto(List<FormData> curFormDatas, String projectId, String nodeId, ExecuteType executeType) {
         if(executeType.equals(ExecuteType.INSPECTION)){

+ 13 - 6
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -539,15 +539,21 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                         wbsTreeContract.getContractIdRelation());
             }else{
                 resultTabs = new ArrayList<>();
+
             }
         }
-        if (Optional.ofNullable(wbsTreeContract.getIsUseSort()).orElse(0) == 0) {
-            //表单排序
-            if (resultTabs.size() > 0) {
-                List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
-                return this.sortTabs(resultTabsToCopy, "_PL_"); //频率表排序
-            }
+        if(ObjectUtil.isNotEmpty(wbsTreeContract.getMajorDataType())&&wbsTreeContract.getMajorDataType().equals(2)){
+         resultTabs.sort(Comparator.comparing((WbsTreeContract contract) -> contract.getNodeName().contains("JS107"))
+                .thenComparing(WbsTreeContract::getNodeName));
         }
+
+//        if (Optional.ofNullable(wbsTreeContract.getIsUseSort()).orElse(0) == 0) {
+//            //表单排序
+//            if (resultTabs.size() > 0) {
+//               List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
+//                return this.sortTabs(resultTabs, "_PL_"); //频率表排序
+//            }
+//        }
         return resultTabs;
     }
 
@@ -589,6 +595,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 }
             }
         }
+
         return sortedTabs;
     }