Ver Fonte

Merge branch 'test-merge' of http://219.151.181.73:3000/zhuwei/bladex into test-merge

lvy há 4 dias atrás
pai
commit
9812e39e46

+ 27 - 1
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -975,15 +975,41 @@ public class CommonUtil {
      * @param keepAspectRatio 是否保持原比例
      */
     public static void rotateAndScaleImageByThumbnails(InputStream is, OutputStream os, double rotate, String format, double quality, int width, int height, boolean keepAspectRatio) throws IOException {
+        // 标准化输出格式
+        String outputFormat = normalizeFormat(format);
+
         Thumbnails.of(is)
                 .size(width, height)
                 .keepAspectRatio(keepAspectRatio)
                 .rotate(rotate)
-                .outputFormat(format)
+                .outputFormat(outputFormat)
                 .outputQuality(quality)
                 .toOutputStream(os);
     }
 
+    /**
+     * 标准化图像格式名称
+     */
+    private static String normalizeFormat(String format) {
+        if (format == null) {
+            return "JPEG"; // 默认格式
+        }
+
+        switch (format.toUpperCase()) {
+            case "JFIF":
+            case "JPEG":
+            case "JPG":
+                return "JPEG";
+            case "PNG":
+            case "GIF":
+            case "BMP":
+                return format.toUpperCase();
+            default:
+                // 对于不支持的格式,返回默认的JPEG格式
+                return "JPEG";
+        }
+    }
+
     /**
      * 根据起止日期获取工作日
      *

+ 0 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ExceTabTreVO.java

@@ -89,5 +89,4 @@ public class ExceTabTreVO extends ExcelTab implements INode<ExceTabTreVO> {
      * 元素表名称
      */
     private String tabChName;
-
 }

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsNodeTableVO.java

@@ -113,5 +113,7 @@ public class WbsNodeTableVO implements Serializable {
 
     @ApiModelProperty("是否隐藏:1显示 其他 代表隐藏")
     private Integer isBussShow;
+    @ApiModelProperty("是否匹配:1-代表匹配,0-不匹配")
+    private Integer isMatch;
 
 }

+ 8 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -63,6 +63,7 @@ public class TrialDetectionController extends BladeController {
     private final ITrialDetectionDataService iTrialDetectionDataService;
     private final ITrialSampleInfoService iTrialSampleInfoService;
     private final ITrialSelfInspectionRecordService iTrialSelfInspectionRecordService;
+    private final IEntrustInfoService entrustInfoService;
     private final WbsTreePrivateClient wbsTreePrivateClient;
     private final JdbcTemplate jdbcTemplate;
     private final NewIOSSClient newIOSSClient;
@@ -171,6 +172,13 @@ public class TrialDetectionController extends BladeController {
         if (recordList.size() > 0) {
             return R.fail("只能删除未上报或已废除的试验记录信息,操作失败");
         }
+        List<TrialSelfInspectionRecord> trialSelfInspectionRecords = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery()
+                .isNotNull(TrialSelfInspectionRecord::getEntrustId)
+                .in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)));
+        trialSelfInspectionRecords.forEach(f->{
+            entrustInfoService.update(Wrappers.<EntrustInfo>lambdaUpdate().eq(EntrustInfo::getId, f.getEntrustId()).set(EntrustInfo::getExpCount, 0));
+        });
+
         String sql1 = "delete from u_trial_self_data_record where record_id in(" + ids + ")";
         jdbcTemplate.execute(sql1);
         String sql2 = "delete from u_trial_self_sample where self_id in(" + ids + ")";

+ 5 - 0
blade-service/blade-manager/pom.xml

@@ -229,6 +229,11 @@
             <artifactId>jsoup</artifactId>
             <version>1.16.1</version>
         </dependency>
+        <dependency>
+            <groupId>com.github.ben-manes.caffeine</groupId>
+            <artifactId>caffeine</artifactId>
+            <version>2.9.3</version> <!-- 2.x版本适配Java 8,3.x仅支持Java 11+ -->
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 291 - 66
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -3,15 +3,22 @@ package org.springblade.manager.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.mixsmart.utils.StringUtils;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.vo.SaveLogContractVO;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.cache.utils.CacheUtil;
@@ -27,22 +34,27 @@ import org.springblade.manager.dto.NameRuleDto;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
+import org.springblade.manager.mapper.ExcelTabMapper;
 import org.springblade.manager.mapper.WbsTreeContractMapper;
 import org.springblade.manager.mapper.WbsTreePrivateMapper;
 import org.springblade.manager.service.*;
 import org.springblade.manager.vo.*;
 import org.springblade.manager.wrapper.WbsTreePrivateWrapper;
+import org.springblade.system.cache.ParamCache;
 import org.springblade.system.user.entity.User;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.PreDestroy;
 import javax.validation.Valid;
-import java.io.FileNotFoundException;
-import java.io.IOException;
+import java.io.*;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -63,7 +75,9 @@ public class WbsTreePrivateController extends BladeController {
     private final IExcelTabService iExcelTabService;
     private final JdbcTemplate jdbcTemplate;
     private final IWbsParamService iWbsParamService;
-    private final ExcelTabController excelTabController;
+    @Autowired
+    private  ExcelTabController excelTabController;
+    private final ExcelTabMapper excelTabMapper;
 
     /**
      * 保存项目日志划分
@@ -317,7 +331,6 @@ public class WbsTreePrivateController extends BladeController {
         return R.fail("操作失败");
     }
 
-//
     /**
      * 查询当前节点下所有表单(根据节点ID查询当前表单)
      */
@@ -391,85 +404,156 @@ public class WbsTreePrivateController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
+    // ========== 1. 自定义线程池(核心:可控并发,避免资源耗尽) ==========
+    private final ExecutorService parseExecutor = new ThreadPoolExecutor(
+            8,          // 核心线程数(根据CPU/接口性能调整)
+            16,         // 最大线程数
+            30,         // 空闲线程30秒回收
+            TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>(100), // 任务队列
+            new ThreadFactory() {           // 命名线程,便于排查
+                private final AtomicInteger count = new AtomicInteger(1);
+                @Override
+                public Thread newThread(Runnable r) {
+                    Thread t = new Thread(r, "html-parse-thread-" + count.getAndIncrement());
+                    t.setDaemon(true); // 守护线程,不阻塞应用关闭
+                    return t;
+                }
+            },
+            new ThreadPoolExecutor.CallerRunsPolicy() // 队列满时,调用线程兜底执行
+    );
     /**
      * 查询当前节点下所有表单(根据节点ID查询当前表单)
      */
     @GetMapping("/get-group-node-tables")
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "查询当前节点下所有元素表并分类", notes = "传入父节点id、wbsId、projectId")
-    public R<List<WbsTreePrivateTableVO>> findAndGroupNodeTableByCondition(@RequestParam("parentId") String parentId,
-                                                                           @RequestParam("wbsId") String wbsId,
-                                                                           @RequestParam("projectId") String projectId) {
+    public R<List<WbsTreePrivateTableVO>> findAndGroupNodeTableByCondition(
+            @RequestParam("parentId") String parentId,
+            @RequestParam("wbsId") String wbsId,
+            @RequestParam("projectId") String projectId) {
+
         R<List<WbsNodeTableVO>> r = findNodeTableByCondition(parentId, wbsId, projectId);
         List<WbsNodeTableVO> data = r.getData();
         List<WbsTreePrivateTableVO> list = new ArrayList<>();
+
         if (data != null && !data.isEmpty()) {
-            //解析html
-            data.forEach(f -> {
+            // ========== 2. 批量预处理:收集参数+批量查询,避免N+1 ==========
+            // 2.1 收集需要处理的VO、initTableId、pKeyId
+            Map<String, WbsNodeTableVO> initTableId2Vo = new HashMap<>();
+            Set<String> needProcessInitTableIds = new HashSet<>();
+            Set<Long> needProcessPKeyIds = new HashSet<>();
+            for (WbsNodeTableVO f : data) {
                 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)
-                    );
+                if (StringUtil.isNotBlank(htmlUrl) && StringUtils.isNotEmpty(initTableId)) {
+                    initTableId2Vo.put(initTableId, f);
+                    needProcessInitTableIds.add(initTableId);
+                    if (f.getPKeyId() != null) {
+                        needProcessPKeyIds.add(f.getPKeyId());
+                    }
+                }
+            }
+
+            // 2.2 批量查询所有WbsFormElement,替代循环内查询
+            Map<String, List<String>> initTableId2Keys;
+            if (!needProcessInitTableIds.isEmpty()) {
+                List<WbsFormElement> allFormElements = wbsFormElementService.getBaseMapper().selectList(
+                        Wrappers.<WbsFormElement>lambdaQuery()
+                                .in(WbsFormElement::getFId, needProcessInitTableIds)
+                                .eq(WbsFormElement::getIsDeleted, 0)
+                );
+                // 构建initTableId -> 对应的eKey列表
+                initTableId2Keys = allFormElements.stream()
+                        .collect(Collectors.groupingBy(
+                                e -> String.valueOf(e.getFId()),
+                                Collectors.mapping(WbsFormElement::getEKey, Collectors.toList())
+                        ));
+            } else {
+                initTableId2Keys = new HashMap<>();
+            }
 
-                    List<String> keys = wbsFormElements.stream().map(WbsFormElement::getEKey).collect(Collectors.toList());
+            // ========== 3. 多线程异步解析HTML ==========
+            List<CompletableFuture<Void>> futures = new ArrayList<>();
+            for (WbsNodeTableVO f : data) {
+                String htmlUrl = f.getHtmlUrl();
+                String initTableId = f.getInitTableId();
+                if (StringUtil.isBlank(htmlUrl) || StringUtils.isEmpty(initTableId)) {
+                    continue; // 无需处理的VO直接跳过
+                }
 
+                // 捕获循环变量,避免lambda引用异常
+                final WbsNodeTableVO finalF = f;
+                final String finalInitTableId = initTableId;
 
-                    // 读取html页面信息
-                    String htmlString = "";
-                    //解析html
+                // 提交异步解析任务
+                CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
                     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);
+                        // 3.1 获取当前initTableId对应的eKey列表(批量查询的结果)
+                        List<String> keys = initTableId2Keys.getOrDefault(finalInitTableId, new ArrayList<>());
+
+                        // 3.2 异步获取HTML内容
+                        String htmlString = "";
+                        R excelHtml = this.getExcelHtml(finalF.getPKeyId());
+                        if (excelHtml != null && excelHtml.isSuccess() && excelHtml.getData() != null) {
+                            htmlString = excelHtml.getData().toString();
+                        }
+                        if (StringUtil.isEmpty(htmlString)) {
+                            return;
+                        }
+
+                        // 3.3 Jsoup解析HTML标签
+                        Document doc = Jsoup.parse(htmlString);
+                        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));
+                        }
+
+                        // 3.4 校验标签ID,设置错误标记(线程安全:仅修改当前VO的字段)
+                        inputs.forEach(input -> {
+                            String id = input.attr("id");
+                            if (StringUtils.isEmpty(id)) {
+                                finalF.setHtmlElementError(1);
                                 input.attr("htmlElementError", "1");
+                            } else {
+                                // 格式校验(和你原有逻辑一致)
+                                boolean isError = !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]);
+                                if (isError) {
+                                    finalF.setHtmlElementError(1);
+                                    input.attr("htmlElementError", "1");
+                                }
                             }
-                        }
-                    });
-                }
-            });
+                        });
+                    } catch (Exception e) {
+                        // 捕获所有异常,避免单个任务失败影响整体
+                        System.err.println("解析HTML异常:VO.id=" + finalF.getId() + ",错误:" + e.getMessage());
+                        e.printStackTrace();
+                    }
+                }, parseExecutor); // 提交到自定义线程池
+                futures.add(future);
+            }
 
+            // ========== 4. 等待所有异步解析完成(核心:确保数据完整) ==========
+            try {
+                // 总超时控制(根据实际情况调整,如30秒)
+                CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
+                        .get(30, TimeUnit.SECONDS);
+            } catch (TimeoutException e) {
+                System.err.println("部分HTML解析任务超时,强制终止");
+                futures.forEach(f -> f.cancel(true)); // 取消未完成任务
+            } catch (Exception e) {
+                System.err.println("等待解析任务异常:" + e.getMessage());
+            }
+
+            // ========== 5. 原有分组逻辑(无需修改) ==========
             Integer wbsType = data.get(0).getWbsType();
             Map<Integer, List<WbsNodeTableVO>> groupMap;
             if (wbsType != null && wbsType == 1) {
@@ -490,9 +574,9 @@ public class WbsTreePrivateController extends BladeController {
                     String tableType = vo.getTableType();
                     if (StringUtil.isNumeric(tableType)) {
                         int i = Integer.parseInt(tableType);
-                        if (i == 1 ) {
+                        if (i == 1) {
                             return 2;
-                        } else if (i == 2 ) {
+                        } else if (i == 2) {
                             return 1;
                         }
                     }
@@ -514,6 +598,147 @@ public class WbsTreePrivateController extends BladeController {
         return R.fail(200, "未查询到数据");
     }
 
+
+    // ========== 5. 销毁线程池(避免内存泄漏) ==========
+    @PreDestroy
+    public void destroyExecutor() {
+        parseExecutor.shutdown();
+        try {
+            if (!parseExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
+                parseExecutor.shutdownNow();
+            }
+        } catch (InterruptedException e) {
+            parseExecutor.shutdownNow();
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    public R getExcelHtml(Long pkeyId) throws Exception {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
+        Thread.sleep(200);
+        WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(pkeyId);
+        if (wbsTreePrivate == null) {
+            return R.fail("该数据下无此节点!");
+        }
+        if (wbsTreePrivate.getHtmlUrl() == null) {
+            return R.fail("请上传清表!");
+        }
+
+        String fileUrl = wbsTreePrivate.getHtmlUrl();
+        File file1 = ResourceUtil.getFile(fileUrl);
+        InputStream fileInputStream;
+        if (file1.exists()) {
+            fileInputStream = new FileInputStream(file1);
+        } else {
+            String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+            fileInputStream = CommonUtil.getOSSInputStream(path);
+        }
+
+        String htmlString = IoUtil.readToString(fileInputStream);
+
+        // 远程搜索配置
+        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();
+        ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
+        Boolean isWater = false;
+        ExcelTab tab = excelTabMapper.getWaterByTableId(wbsTreePrivate.getExcelId());
+        if (tab != null) {
+            isWater = true;
+        }
+        ExcelTab dataInfo = excelTabMapper.selectById(wbsTreePrivate.getExcelId());
+        // 添加标题显示
+        Elements trs = table.select("tr");
+        //这句代码在正式环境要加上
+
+        if (Func.isNotEmpty(dataInfo) && dataInfo.getTabType() != null && dataInfo.getTabType() != 100L) {
+            int x=0;
+            for (int i = 1; i < 6; i++) {
+                Element tr = trs.get(i);
+                Elements tds = tr.select("td");
+                for (int j = 0; j < tds.size(); j++) {
+                    Element data = tds.get(j);
+                    String style = data.attr("style");
+                    if (style.indexOf("font-size") >= 0) {
+                        int fontsize = Integer.parseInt(style.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt")));
+                        if (isWater) {
+                            if (org.apache.commons.lang.StringUtils.isNotEmpty(data.text()) && fontsize >= 12&&x<=0) {
+                                trs.get(i - 1).select("td").get(0).text(projectInfo.getProjectName());
+                                x=x+1;
+                            }
+                        } else {
+                            if (org.apache.commons.lang.StringUtils.isNotEmpty(data.text()) && fontsize >= 14) {
+                                Elements td = trs.get(i - 1).select("td");
+                                if (td != null && td.size() >= 1) {
+                                    for (Element element : td) {
+                                        String style2 = element.attr("style");
+                                        String sizeinfo = style2.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt"));
+                                        if (sizeinfo.length() >= 2 && sizeinfo.indexOf(".") < 0) {
+                                            int fontsize2 = Func.toInt(sizeinfo);
+                                            if (org.apache.commons.lang.StringUtils.isEmpty(element.text()) && fontsize2 >= 14) {
+                                                element.text(projectInfo.getProjectName());
+                                                break;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        fileInputStream.close();
+        return R.data(table + "");
+    }
+
     /**
      * 根据pkeyid检验html是否存在错误细腻些
      * @param pKeyId

+ 2 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreeMapper.xml

@@ -559,7 +559,8 @@
                (SELECT CASE WHEN count(1) > 0 THEN 2 ELSE 1 END
                 FROM m_wbs_tab_relation_excel_tab b
                 WHERE wt.id = b.wbs_tab_id
-                  AND b.excel_tab_id = #{excelId})                          AS "isLinkTable"
+                  AND b.excel_tab_id = #{excelId})                          AS "isLinkTable",
+            (select IFNULL(wt.init_table_name = b.tab_en_name,1) from m_excel_tab a left join m_table_info b on a.tab_id = b.id where a.id = #{excelId}) isMatch
         FROM m_wbs_tree AS wt
         WHERE wt.type = 2
           AND wt.is_deleted = 0

+ 11 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsFormElementServiceImpl.java

@@ -1129,16 +1129,18 @@ public class WbsFormElementServiceImpl extends BaseServiceImpl<WbsFormElementMap
     @Override
     public WbsFormElementDetailVO elementDetail(Long id) {
         WbsFormElementDetailVO vo = baseMapper.elementDetail(id);
-        vo.setIsExistData(false);
-        try {
-            //获取实体表是否存储数据
-            vo.setIsExistData(jdbcTemplate.queryForObject("select count(0) > 0 from " + vo.getTabEnName(), Boolean.class));
-        } catch (Exception ignored) {
-            ignored.printStackTrace();
+        if(vo!=null){
+            vo.setIsExistData(false);
+            try {
+                //获取实体表是否存储数据
+                vo.setIsExistData(jdbcTemplate.queryForObject("select count(0) > 0 from " + vo.getTabEnName(), Boolean.class));
+            } catch (Exception ignored) {
+                ignored.printStackTrace();
+            }
+            //获取项目列表
+            List<String> list = baseMapper.selectProjectList(id);
+            vo.setProjectList(list);
         }
-        //获取项目列表
-        List<String> list = baseMapper.selectProjectList(id);
-        vo.setProjectList(list);
         return vo;
     }