瀏覽代碼

Merge branch 'refs/heads/feature-lihb-20251103-htmlError' into dev

# Conflicts:
#	blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java
LHB 3 天之前
父節點
當前提交
605f92a1db

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

@@ -1047,6 +1047,50 @@ public class ExcelTabController extends BladeController {
 
         // 远程搜索配置
         Document doc = Jsoup.parse(htmlString);
+
+        //获取所有input标签
+        String[] tagNames = {"el-input", "el-date-picker", "el-time-picker", "hc-form-select-search",
+                "hc-table-form-upload", "hc-form-checkbox-group", "el-radio-group", "el-select"};
+        Elements inputs = new Elements();
+        for (String tagName : tagNames) {
+            inputs.addAll(doc.select(tagName));
+        }
+
+        //获取元素表数据
+        List<WbsFormElement> wbsFormElements = wbsFormElementService.getBaseMapper().selectList(Wrappers.<WbsFormElement>lambdaQuery()
+                .eq(WbsFormElement::getFId, wbsTreePrivate.getInitTableId())
+                .eq(WbsFormElement::getIsDeleted, 0)
+        );
+        List<String> keys = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
+
+        //判断标签是否存在id属性
+        inputs.forEach(input -> {
+            String id = input.attr("id");
+            if(com.mixsmart.utils.StringUtils.isEmpty(id)){
+                input.attr("htmlElementError", "1");
+            } else {
+                /**
+                 * 判断当前元素是否符合格式
+                 * 1、是否存在key_
+                 * 2、是否存在__
+                 * 3、key_后面是否为数字
+                 * 4、__后面是否为坐标
+                 * 5、key是否在元素库中存在
+                 */
+                if(!id.contains("key_")
+                        || !id.contains("__")
+                        || !com.mixsmart.utils.StringUtils.isNumber(id.split("__")[0].replace("key_",""))
+                        || !id.split("__")[1].contains("_")
+                        || !com.mixsmart.utils.StringUtils.isNumber(id.split("__")[1].split("_")[0])
+                        || !com.mixsmart.utils.StringUtils.isNumber(id.split("__")[1].split("_")[1])
+                        || !keys.contains(id.split("__")[0])
+                ){
+                    input.attr("htmlElementError", "1");
+                }
+            }
+        });
+
+
         Element table = doc.select("table").first();
         Elements col = doc.select("Col");
         doc.select("Col").remove();

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

@@ -309,6 +309,8 @@ public class LinkdataInfoController extends BladeController {
                     element1.removeAttr("weighing");
                     element1.removeAttr("v-model");
                     element1.removeAttr("@focus");
+                    //删除html错误标识
+                    element1.removeAttr("htmlElementError");
                     keyId = element1.attr("keyName");
                     if (element.html().indexOf("hc-form-checkbox-group") >= 0) {
                         element1.removeAttr(":val");

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

@@ -46,6 +46,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -66,6 +67,7 @@ public class WbsTreePrivateController extends BladeController {
     private final IExcelTabService iExcelTabService;
     private final JdbcTemplate jdbcTemplate;
     private final IWbsParamService iWbsParamService;
+    private final ExcelTabController excelTabController;
 
     /**
      * 保存项目日志划分
@@ -403,6 +405,72 @@ public class WbsTreePrivateController extends BladeController {
                                                             @RequestParam("projectId") String projectId) {
         R<List<WbsNodeTableVO>> r = findNodeTableByCondition(parentId, wbsId, projectId);
         List<WbsNodeTableVO> data = r.getData();
+        //解析html
+        data.forEach(f -> {
+            String htmlUrl = f.getHtmlUrl();
+            String initTableId = f.getInitTableId();
+            if(StringUtil.isNotBlank(htmlUrl) && StringUtils.isNotEmpty(initTableId)){
+                //获取元素表数据
+                List<WbsFormElement> wbsFormElements = wbsFormElementService.getBaseMapper().selectList(Wrappers.<WbsFormElement>lambdaQuery()
+                        .eq(WbsFormElement::getFId, initTableId)
+                        .eq(WbsFormElement::getIsDeleted, 0)
+                );
+
+                List<String> keys = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
+
+
+                // 读取html页面信息
+                String htmlString = "";
+                //解析html
+                try {
+                    R excelHtml = excelTabController.getExcelHtml(f.getPKeyId());
+                    htmlString = excelHtml.getData().toString();
+                } catch (Exception e) {
+                }
+                if(StringUtil.isEmpty(htmlString)){
+                    return;
+                }
+                // 样式集合
+                Document doc = Jsoup.parse(htmlString);
+                //获取所有input标签
+                //获取所有input标签
+                String[] tagNames = {"el-input", "el-date-picker", "el-time-picker", "hc-form-select-search",
+                        "hc-table-form-upload", "hc-form-checkbox-group", "el-radio-group", "el-select"};
+                Elements inputs = new Elements();
+                for (String tagName : tagNames) {
+                    inputs.addAll(doc.select(tagName));
+                }
+                //判断标签是否存在id属性
+                inputs.forEach(input -> {
+                    String id = input.attr("id");
+                    if(StringUtils.isEmpty(id)){
+                        f.setHtmlElementError(1);
+                        input.attr("htmlElementError", "1");
+                    } else {
+                        /**
+                         * 判断当前元素是否符合格式
+                         * 1、是否存在key_
+                         * 2、是否存在__
+                         * 3、key_后面是否为数字
+                         * 4、__后面是否为坐标
+                         * 5、key是否在元素库中存在
+                         */
+                        if(!id.contains("key_")
+                                || !id.contains("__")
+                                || !StringUtils.isNumber(id.split("__")[0].replace("key_",""))
+                                || !id.split("__")[1].contains("_")
+                                || !StringUtils.isNumber(id.split("__")[1].split("_")[0])
+                                || !StringUtils.isNumber(id.split("__")[1].split("_")[1])
+                                || !keys.contains(id.split("__")[0])
+                        ){
+                            f.setHtmlElementError(1);
+                            input.attr("htmlElementError", "1");
+                        }
+                    }
+                });
+            }
+        });
+
         List<WbsTreePrivateTableVO> list = new ArrayList<>();
         if (data != null && !data.isEmpty()) {
             Integer wbsType = data.get(0).getWbsType();
@@ -449,6 +517,80 @@ public class WbsTreePrivateController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
+    /**
+     * 根据pkeyid检验html是否存在错误细腻些
+     * @param pKeyId
+     * @return
+     */
+    @GetMapping("/getHtmlErrorByPKeyId")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "根据pkeyid检验html是否存在错误细腻些", notes = "传入pKeyId")
+    public R<Boolean> getHtmlErrorByPKeyId(Long pKeyId){
+        AtomicBoolean htmlError = new AtomicBoolean(false);
+
+        WbsTreePrivate f = wbsTreePrivateService.getById(pKeyId);
+        String htmlUrl = f.getHtmlUrl();
+        String initTableId = f.getInitTableId();
+        if(StringUtil.isNotBlank(htmlUrl) && StringUtils.isNotEmpty(initTableId)){
+            //获取元素表数据
+            List<WbsFormElement> wbsFormElements = wbsFormElementService.getBaseMapper().selectList(Wrappers.<WbsFormElement>lambdaQuery()
+                    .eq(WbsFormElement::getFId, initTableId)
+                    .eq(WbsFormElement::getIsDeleted, 0)
+            );
+
+            List<String> keys = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
+
+
+            // 读取html页面信息
+            String htmlString = "";
+            //解析html
+            try {
+                R excelHtml = excelTabController.getExcelHtml(f.getPKeyId());
+                htmlString = excelHtml.getData().toString();
+            } catch (Exception e) {
+            }
+            if(StringUtil.isEmpty(htmlString)){
+                return R.data(htmlError.get());
+            }
+            // 样式集合
+            Document doc = Jsoup.parse(htmlString);
+            //获取所有input标签
+            String[] tagNames = {"el-input", "el-date-picker", "el-time-picker", "hc-form-select-search",
+                    "hc-table-form-upload", "hc-form-checkbox-group", "el-radio-group", "el-select"};
+            Elements inputs = new Elements();
+            for (String tagName : tagNames) {
+                inputs.addAll(doc.select(tagName));
+            }
+            //判断标签是否存在id属性
+            inputs.forEach(input -> {
+                String id = input.attr("id");
+                if(StringUtils.isEmpty(id)){
+                    htmlError.set(true);
+                } else {
+                    /**
+                     * 判断当前元素是否符合格式
+                     * 1、是否存在key_
+                     * 2、是否存在__
+                     * 3、key_后面是否为数字
+                     * 4、__后面是否为坐标
+                     * 5、key是否在元素库中存在
+                     */
+                    if(!id.contains("key_")
+                            || !id.contains("__")
+                            || !StringUtils.isNumber(id.split("__")[0].replace("key_",""))
+                            || !id.split("__")[1].contains("_")
+                            || !StringUtils.isNumber(id.split("__")[1].split("_")[0])
+                            || !StringUtils.isNumber(id.split("__")[1].split("_")[1])
+                            || !keys.contains(id.split("__")[0])
+                    ){
+                        htmlError.set(true);
+                    }
+                }
+            });
+        }
+        return R.data(htmlError.get());
+    }
+
     @GetMapping("/remove-table")
     @ApiOperationSupport(order = 4)
     @ApiOperation(value = "删除节点下的元素表", notes = "传入表单id、wbsId、projectId")

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

@@ -104,6 +104,7 @@
         <result column="fillRate" property="fillRate"/>
         <result column="initTableId" property="initTableId"/>
         <result column="initTableName" property="initTableName"/>
+        <result column="html_url" property="htmlUrl"/>
         <result column="excelIds" property="excelIds"/>
         <result column="excelId" property="excelId"/>
         <result column="table_type" property="tableType"/>