Browse Source

试验自检相关

liuyc 2 years ago
parent
commit
5132df2bc4

+ 1 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/feign/WbsTreePrivateClient.java

@@ -4,7 +4,6 @@ import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.vo.WbsTreeContractTreeVOS;
 import org.springblade.manager.vo.WbsTreePrivateVO;
 import org.springframework.cloud.openfeign.FeignClient;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -40,7 +39,7 @@ public interface WbsTreePrivateClient {
     List<WbsTreeContractTreeVOS> queryWbsTreePrivateByProjectIdAndId(@RequestParam String projectId, @RequestParam Long id);
 
     @PostMapping(API_PREFIX + "/showBussTab")
-    boolean showBussTab(@RequestParam Long pkeyId,@RequestParam Integer status);
+    boolean showBussTab(@RequestParam Long pkeyId, @RequestParam Integer status);
 
     @PostMapping(API_PREFIX + "/copyBussTab")
     boolean copyBussTab(@RequestParam Long pKeyId);

+ 13 - 0
blade-service/blade-business/pom.xml

@@ -101,6 +101,19 @@
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>e-iceblue</groupId>
+            <artifactId>spire.office.free</artifactId>
+            <version>5.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.aspose</groupId>
+            <artifactId>aspose-cells</artifactId>
+            <version>20.4</version>
+            <scope>compile</scope>
+        </dependency>
+
     </dependencies>
 
 </project>

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

@@ -198,4 +198,18 @@ public class TrialDetectionController extends BladeController {
         return R.status(iTrialSelfInspectionRecordService.rawMaterialSubmitRelation(dto));
     }
 
+    @PostMapping("/self/print-pdf")
+    @ApiOperationSupport(order = 22)
+    @ApiOperation(value = "自检记录pdf批量打印", notes = "传入记录ids")
+    public R<String> selfPrintPdf(@RequestParam String ids) throws FileNotFoundException {
+        return R.data(iTrialSelfInspectionRecordService.selfPrintPdf(ids));
+    }
+
+    @PostMapping("/self/print-null-pdf")
+    @ApiOperationSupport(order = 23)
+    @ApiOperation(value = "自检记录pdf批量打印空表", notes = "传入记录ids")
+    public R<String> selfPrintNullPdf(@RequestParam String ids) throws Exception {
+        return R.data(iTrialSelfInspectionRecordService.selfPrintNullPdf(ids));
+    }
+
 }

+ 4 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -32,4 +32,8 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
     boolean rawMaterialSubmitRelation(RawMaterialSubmitRelationDTO dto) throws FileNotFoundException;
 
+    String selfPrintPdf(String ids) throws FileNotFoundException;
+
+    String selfPrintNullPdf(String ids) throws Exception;
+
 }

+ 107 - 3
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.spire.xls.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.time.DateUtils;
 import org.springblade.business.dto.RawMaterialSubmitRelationDTO;
@@ -22,6 +22,7 @@ import org.springblade.business.mapper.TrialSampleInfoMapper;
 import org.springblade.business.mapper.TrialSelfInspectionRecordMapper;
 import org.springblade.business.service.ITrialSelfInspectionRecordService;
 import org.springblade.business.utils.FileUtils;
+import org.springblade.business.utils.FileUtils2;
 import org.springblade.business.utils.StringSPUtils;
 import org.springblade.business.vo.SampleAncillaryDocumentsVO;
 import org.springblade.business.vo.TrialSampleInfoVO;
@@ -29,14 +30,14 @@ import org.springblade.business.vo.TrialSelfInspectionRecordVO;
 import org.springblade.business.vo.TrialSelfInspectionRecordVO2;
 import org.springblade.business.wrapper.TrialSelfInspectionRecordWarpper;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.utils.*;
-import org.springblade.manager.entity.ContractInfo;
-import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.manager.entity.*;
 import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.feign.ExcelTabClient;
 import org.springblade.manager.feign.WbsTreePrivateClient;
@@ -53,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.util.*;
+import java.util.List;
 import java.util.stream.Collectors;
 
 @Service
@@ -234,6 +236,108 @@ public class TrialSelfInspectionRecordServiceImpl
         }
     }
 
+    @Override
+    public String selfPrintPdf(String ids) throws FileNotFoundException {
+        List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
+        List<String> listPdfUrl = recordList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+        //合并PDF
+        Long id = SnowFlakeUtil.getId();
+        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        String listPdf = filePath + "/pdf/" + id + ".pdf";
+        File tabPDF = ResourceUtil.getFile(listPdf);
+        if (tabPDF.exists()) {
+            tabPDF.delete();
+        }
+        FileUtils.mergePdfPublicMethods(listPdfUrl, listPdf);
+        BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", listPdf);
+        if (bladeFile != null) {
+            return bladeFile.getLink();
+        }
+        return null;
+    }
+
+    @Override
+    public String selfPrintNullPdf(String ids) throws Exception {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        List<TrialSelfInspectionRecord> recordList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, Func.toLongList(ids)).eq(TrialSelfInspectionRecord::getStatus, 1));
+        List<String> tabIdsAll = recordList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTableIds())).map(TrialSelfInspectionRecord::getTableIds).collect(Collectors.toList());
+        List<String> tabIds = new ArrayList<>();
+        for (String tabId : tabIdsAll) {
+            List<String> strings = Func.toStrList(tabId);
+            tabIds.addAll(strings);
+        }
+        List<String> tableIds = tabIds.stream().distinct().collect(Collectors.toList());
+        //获取excel
+        List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateClient.queryByPKeyIds(tableIds);
+        List<String> dataListPdf = new ArrayList<>();
+        for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
+            String trialPdfUrl = this.getTrialPdfUrl(wbsTreePrivate);
+            if (StringUtils.isNotEmpty(trialPdfUrl)) {
+                dataListPdf.add(trialPdfUrl);
+            }
+        }
+
+        //合并pdf
+        Long id = SnowFlakeUtil.getId();
+        String pdfPath2 = file_path + "/pdf//" + id + "_2.pdf";
+        File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+        if (tabPdf2.exists()) {
+            tabPdf2.delete();
+        }
+        FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
+
+        BladeFile bladeFile = newIOSSClient.uploadFile(id + "2.pdf", pdfPath2);
+        if (bladeFile != null) {
+            return bladeFile.getLink();
+        }
+        return null;
+    }
+
+    private String getTrialPdfUrl(WbsTreePrivate wbsTreePrivate) throws Exception {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        if (wbsTreePrivate == null) {
+            throw new ServiceException("该数据下无此节点!");
+        }
+        if (wbsTreePrivate.getHtmlUrl() == null) {
+            throw new ServiceException("请关联清表!");
+        }
+
+        String pdfPath = file_path + "/pdf//" + wbsTreePrivate.getPKeyId() + ".pdf";
+        String excelPath = file_path + "/pdf//" + wbsTreePrivate.getPKeyId() + ".xlsx";
+        File tabPdf = ResourceUtil.getFile(pdfPath);
+        if (tabPdf.exists()) {
+            tabPdf.delete();
+        }
+
+        //获取清表信息
+        ExcelTab excelTab = excelTabClient.getById(String.valueOf(wbsTreePrivate.getExcelId()));
+        if (excelTab == null) {
+            throw new ServiceException("操作失败!");
+        }
+
+        // 获取excel流 和 html流
+        Workbook wb = new Workbook();
+        wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
+        //获取工作表
+        Worksheet sheet = wb.getWorksheets().get(0);
+        //标题添加
+        CellRange[] columns = sheet.getMergedCells();
+        for (CellRange cellRange : columns) {
+            if (cellRange.getStyle().getFont().getSize() >= 17) {
+                cellRange.getStyle().getFont().setSize(20);
+                break;
+            }
+        }
+
+        wb.saveToFile(excelPath, ExcelVersion.Version2010);
+        FileUtils2.excelToPdf(excelPath, pdfPath);
+        BladeFile bladeFile = newIOSSClient.uploadFile(wbsTreePrivate.getPKeyId() + ".pdf", pdfPath);
+
+        wb.dispose();
+
+        return bladeFile.getLink();
+    }
+
     @Override
     public List<TrialSampleInfoVO> selfSampleList(String id) {
         List<String> sampleIds = baseMapper.selectSelfSampleRecord(id);

+ 287 - 0
blade-service/blade-business/src/main/java/org/springblade/business/utils/FileUtils2.java

@@ -0,0 +1,287 @@
+package org.springblade.business.utils;
+
+import com.aspose.cells.SaveFormat;
+import com.itextpdf.text.Document;
+import com.itextpdf.text.pdf.PdfCopy;
+import com.itextpdf.text.pdf.PdfReader;
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
+import org.apache.commons.lang.StringUtils;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.util.Units;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.vo.DataVO;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class FileUtils2 {
+
+    public static void batchDownloadFileToZip(List<String> urls, HttpServletResponse response){
+        // 设置压缩流:直接写入response,实现边压缩边下载
+        ZipOutputStream zipos = null;
+        // 循环将文件写入压缩流
+        DataOutputStream os = null;
+        try{
+
+            // 响应头的设置
+            response.reset();
+            response.setCharacterEncoding("utf-8");
+            response.setContentType("multipart/form-data");
+            // 设置压缩包的名字
+            // 解决不同浏览器压缩包名字含有中文时乱码的问题
+            String downloadName = "附件-" + System.currentTimeMillis() + ".zip";
+            response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(downloadName, "UTF-8"));
+
+            try {
+                zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
+                // 设置压缩方法
+                zipos.setMethod(ZipOutputStream.DEFLATED);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            if(zipos == null){
+                return;
+            }
+
+            InputStream inputStream = null;
+
+            for(String url : urls){
+                if(StringUtils.isNotEmpty(url)){
+                    try{
+                        String fileName = null, symbol = "";
+                        if(url.contains("@@@")){
+                            String[] array = url.split("@@@");
+                            url = array[0];
+                            fileName = array[1];
+                            symbol = url.substring(url.lastIndexOf("."));
+                        }
+
+                        //获取文件流
+                        inputStream = CommonUtil.getOSSInputStream(url);
+                        //转换
+                        byte[] bytes = CommonUtil.InputStreamToBytes(inputStream);
+
+                        if(StringUtils.isEmpty(fileName)){
+                            fileName = url.substring(url.lastIndexOf("/") + 1);
+                            symbol = "";
+                        }
+                        zipos.putNextEntry(new ZipEntry(fileName + symbol));
+
+                        os = new DataOutputStream(zipos);
+                        os.write(bytes);
+                        zipos.closeEntry();
+
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    } finally {
+                        IoUtil.closeQuietly(inputStream);
+                    }
+                }
+            }
+
+        }catch (Exception e){
+            e.printStackTrace();
+        } finally {
+            IoUtil.closeQuietly(os);
+            IoUtil.closeQuietly(zipos);
+        }
+    }
+
+    /**
+     * 图片定位
+     */
+    public static void imageOrientation(Sheet sheet, ClientAnchor anchor, DataVO dataVO) {
+        anchor.setDx1(Units.pixelToEMU(5));
+        anchor.setDy1(Units.pixelToEMU(5));
+        anchor.setCol2(anchor.getCol1());
+        anchor.setRow2(anchor.getRow1());
+        int k = getMergedRegionIndex(sheet, CommonUtil.join(dataVO.getX(), dataVO.getY(), dataVO.getX(), dataVO.getY(),","));
+        if(k>-1){
+            /*如果是合并单元格,则锚点第二坐标设置为合并区右下角单元格坐标*/
+            CellRangeAddress ca = sheet.getMergedRegion(k);
+            anchor.setCol1(ca.getFirstColumn());
+            anchor.setRow1(ca.getFirstRow());
+            anchor.setCol2(ca.getLastColumn());
+            anchor.setRow2(ca.getLastRow());
+        }
+        int dx=(int)(sheet.getColumnWidthInPixels(anchor.getCol2())+3);
+        int dy=Units.pointsToPixel(sheet.getRow(anchor.getRow2()).getHeightInPoints())-5;
+        anchor.setDx2(Units.pixelToEMU(dx));
+        anchor.setDy2(Units.pixelToEMU(dy));
+    }
+
+    public static int getMergedRegionIndex(Sheet sheet, String coords) {
+        for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
+            CellRangeAddress ca = sheet.getMergedRegion(i);
+            int firstColumn = ca.getFirstColumn();
+            int lastColumn = ca.getLastColumn();
+            int firstRow = ca.getFirstRow();
+            int lastRow = ca.getLastRow();
+            Matcher mu = CommonUtil.matcher("(\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})",coords);
+            /*合并单元格四个角坐标,只要任意一个在落在将要合并的区域里面意味着两者重合,就必须拆分前者*/
+            List<Integer[]> corners = Arrays.asList(new Integer[]{firstColumn,firstRow},new Integer[]{lastColumn,firstRow},new Integer[]{firstColumn,lastRow},new Integer[]{lastColumn,lastRow});
+            if(mu.find()){
+                int firstColumn2 = mu.group(1) == null ? 0 : Integer.parseInt(mu.group(1));
+                int lastColumn2 = mu.group(3) == null ? 0 : Integer.parseInt(mu.group(3));
+                int firstRow2 = mu.group(2) == null ? 0 : Integer.parseInt(mu.group(2));
+                int lastRow2 = mu.group(4) == null ? 0 : Integer.parseInt(mu.group(4));
+                for(Integer[] corner:corners){
+                    if(firstColumn2<=corner[0]&&corner[0]<=lastColumn2&&firstRow2<=corner[1]&&corner[1]<=lastRow2){
+                        return i;
+                    }
+                }
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * 合并方法
+     */
+    public static void mergePdfPublicMethods(List<String> urlList, String localImgUrl){
+        PdfReader reader = null;
+
+        Document doc = new Document();
+        PdfCopy pdfCopy = null;
+        try{
+            pdfCopy = new PdfCopy(doc, new FileOutputStream(localImgUrl));
+            int pageCount;
+            doc.open();
+
+            for(String urlStr : urlList){
+                try{
+                    //获取OSS文件输入流
+                    reader = new PdfReader(CommonUtil.getOSSInputStream(urlStr));
+
+                    pageCount = reader.getNumberOfPages();
+
+                    for(int i = 0; i < pageCount; ++i){
+                        int is = i + 1;
+                        pdfCopy.addPage(pdfCopy.getImportedPage(reader,is));
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
+                } finally {
+                    if(reader != null){
+                        reader.close();
+                    }
+                }
+            }
+
+        }catch (Exception e){
+            e.printStackTrace();
+        } finally {
+            if(pdfCopy != null){
+                pdfCopy.flush();
+                pdfCopy.close();
+            }
+            doc.close();
+        }
+    }
+
+    /**
+     * excel 转pdf
+     * @param exUrl
+     * @param pdfUrl
+     */
+    public static void excelToPdf(String exUrl,String pdfUrl){
+
+        org.apache.poi.ss.usermodel.Workbook ss = null;
+        ByteArrayInputStream byteArrayInputStream = null;
+        InputStream pdfInput = null;
+        ByteArrayOutputStream outReport = null, bos = null;
+        try{
+            File file1 = ResourceUtil.getFile(exUrl);
+            InputStream inputStream = new FileInputStream(file1);
+            ss = WorkbookFactory.create(inputStream);
+            for(int i = 0, l = ss.getNumberOfSheets(); i < l; i ++){
+                Sheet sheet = ss.getSheetAt(i);
+                //去掉表格虚线
+                sheet.setPrintGridlines(false);
+                //设置 整个工作表为一页
+                sheet.setFitToPage(true);
+            }
+            outReport = new ByteArrayOutputStream();
+            ss.write(outReport);
+            byteArrayInputStream = new ByteArrayInputStream(outReport.toByteArray());
+            com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(byteArrayInputStream);
+            File pdfFile = new File(pdfUrl);
+            if(!pdfFile.exists()){
+                pdfFile.mkdir();
+            }
+            wb.save(pdfUrl, SaveFormat.PDF);
+
+        }catch (Exception e){
+            e.printStackTrace();
+        } finally {
+            if(bos != null){
+                IoUtil.closeQuietly(bos);
+            }
+            if(outReport != null){
+                IoUtil.closeQuietly(outReport);
+            }
+            if(pdfInput != null){
+                IoUtil.closeQuietly(pdfInput);
+            }
+            if(byteArrayInputStream != null){
+                IoUtil.closeQuietly(byteArrayInputStream);
+            }
+            if(ss != null){
+                IoUtil.closeQuietly(ss);
+            }
+        }
+    }
+
+    /**
+     * 图片压缩
+     * @param imgUrl
+     */
+    public static void CompressImage(String imgUrl,InputStream img){
+        try {
+            //图片所在路径
+            BufferedImage templateImage = ImageIO.read(img);
+            //原始图片的长度和宽度
+            int height = templateImage.getHeight();
+            int width = templateImage.getWidth();
+
+            //通过比例压缩
+            float scale = 0.5f;
+
+            //通过固定长度压缩
+            /*int doWithHeight = 100;
+            int dowithWidth = 300;*/
+
+            //压缩之后的长度和宽度
+            int doWithHeight = (int) (scale * height);
+            int dowithWidth = (int) (scale * width);
+
+            BufferedImage finalImage = new BufferedImage(dowithWidth, doWithHeight, BufferedImage.TYPE_INT_RGB);
+
+            finalImage.getGraphics().drawImage(templateImage.getScaledInstance(dowithWidth, doWithHeight, java.awt.Image.SCALE_SMOOTH), 0, 0, null);
+
+
+            //图片输出路径,以及图片名
+            FileOutputStream  fileOutputStream = new FileOutputStream(imgUrl);
+            JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fileOutputStream);
+            encoder.encode(finalImage);
+            fileOutputStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 35 - 19
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -482,10 +482,6 @@ public class WbsTreePrivateController extends BladeController {
         return R.status(wbsTreePrivateService.syncNodeTable(primaryKeyId));
     }
 
-
-
-
-
     /**
      * wbs私有树懒加载获取项目私有节点树形结构--(表单类型划分树)
      */
@@ -499,7 +495,7 @@ public class WbsTreePrivateController extends BladeController {
     })
     public R<IPage<TreeNodeVOByTabType>> tabTypeLazyTree(Long parentId, String projectId, BladeUser bladeUser, String titleName, Query query) {
 
-        IPage<TreeNodeVOByTabType> page= wbsTreePrivateService.tabTypeLazyTree(Condition.getPage(query),parentId, projectId,titleName);
+        IPage<TreeNodeVOByTabType> page = wbsTreePrivateService.tabTypeLazyTree(Condition.getPage(query), parentId, projectId, titleName);
         return R.data(page);
     }
 
@@ -511,8 +507,8 @@ public class WbsTreePrivateController extends BladeController {
             @ApiImplicitParam(name = "primaryKeyIds", value = "表的注解ids(多个以,隔开)", required = true),
             @ApiImplicitParam(name = "contractId", value = "合同段Id", required = true),
     })
-    public R addWbsTreeContractInfo(String nodeId,String primaryKeyIds,long contractId){
-        return wbsTreePrivateService.addWbsTreeContractInfo(nodeId,primaryKeyIds,contractId);
+    public R addWbsTreeContractInfo(String nodeId, String primaryKeyIds, long contractId) {
+        return wbsTreePrivateService.addWbsTreeContractInfo(nodeId, primaryKeyIds, contractId);
     }
 
     /**
@@ -525,8 +521,8 @@ public class WbsTreePrivateController extends BladeController {
             @ApiImplicitParam(name = "parentId", value = "父级id", required = true),
             @ApiImplicitParam(name = "titleName", value = "搜索关键字", required = true)
     })
-    public R<IPage<TreeNodeVOByTabType>> tabTypeLazyTreeAll(Long parentId,BladeUser bladeUser, String titleName, Query query) {
-        IPage<TreeNodeVOByTabType> page= wbsTreePrivateService.tabTypeLazyTreeAll(Condition.getPage(query),parentId,titleName);
+    public R<IPage<TreeNodeVOByTabType>> tabTypeLazyTreeAll(Long parentId, BladeUser bladeUser, String titleName, Query query) {
+        IPage<TreeNodeVOByTabType> page = wbsTreePrivateService.tabTypeLazyTreeAll(Condition.getPage(query), parentId, titleName);
         return R.data(page);
     }
 
@@ -537,8 +533,8 @@ public class WbsTreePrivateController extends BladeController {
             @ApiImplicitParam(name = "primaryKeyIds", value = "表的注解ids(多个以,隔开)", required = true),
             @ApiImplicitParam(name = "projectId", value = "合同段Id", required = true),
     })
-    public R addProjectTabInfo(String primaryKeyIds,String projectId){
-        return wbsTreePrivateService.addWbsTreeProjectInfo(primaryKeyIds,projectId);
+    public R addProjectTabInfo(String primaryKeyIds, String projectId) {
+        return wbsTreePrivateService.addWbsTreeProjectInfo(primaryKeyIds, projectId);
     }
 
     @PostMapping("/del-aprojecttab-info")
@@ -548,29 +544,49 @@ public class WbsTreePrivateController extends BladeController {
             @ApiImplicitParam(name = "primaryKeyIds", value = "表的注解ids(多个以,隔开)", required = true),
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
     })
-    public R delTabProjectById(String primaryKeyIds,String projectId){
-        return wbsTreePrivateService.delTabProjectById(primaryKeyIds,projectId);
+    public R delTabProjectById(String primaryKeyIds, String projectId) {
+        return wbsTreePrivateService.delTabProjectById(primaryKeyIds, projectId);
     }
 
+
     @PostMapping("/del-tab-info-all")
     @ApiOperationSupport(order = 21)
     @ApiOperation(value = "后管-删除元素表", notes = "primaryKeyIds")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "pKeyId", value = "表的注解ids(多个以,隔开)", required = true)
     })
-    public R delTabInfoAll(String pKeyId){
+    public R delTabInfoAll(String pKeyId) {
         return wbsTreePrivateService.delTableById(pKeyId);
     }
 
+    /**
+     * 试验-根据所属方查询当前节点表信息
+     *
+     * @param primaryKeyId
+     * @param type
+     * @param tableType
+     * @param contractId
+     * @param projectId
+     * @return
+     */
     @GetMapping("/search-node-tables")
     @ApiOperationSupport(order = 22)
     @ApiOperation(value = "试验-根据所属方查询当前节点表信息", notes = "传入节点primaryKeyId、所属方type=1施工,=2监理 ;表单类型tableType=1记录表,=2报告单; 合同段id、项目id")
     public R<List<WbsTreePrivate>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId) {
-        List<WbsTreePrivate> list = wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId);
-        if (list.size() > 0) {
-            return R.data(list);
-        }
-        return R.fail(200, "未查询到数据");
+        return R.data(wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId));
+    }
+
+    /**
+     * 试验-客户端试验获取表的HTML
+     *
+     * @param primaryKeyId
+     * @return
+     */
+    @GetMapping("/get-excel-html")
+    @ApiOperationSupport(order = 23)
+    @ApiOperation(value = "试验-客户端获取表的HTML", notes = "传入节点primaryKeyId")
+    public R<Object> getExcelHtml(@RequestParam String primaryKeyId) throws IOException {
+        return R.data(wbsTreePrivateService.getExcelHtml(primaryKeyId));
     }
 
 

+ 10 - 10
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/WbsTreePrivateClientImpl.java

@@ -52,7 +52,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
     @Override
     public List<WbsTreeContractTreeVOS> queryWbsTreePrivateByProjectIdAndId(String projectId, Long id) {
         List<WbsTreePrivate> result = this.wbsTreePrivateService.list(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getProjectId, projectId).eq(WbsTreePrivate::getType, 1).like(WbsTreePrivate::getAncestors, id));
-        if(result != null && result.size() > 0){
+        if (result != null && result.size() > 0) {
             //转换实体
             List<WbsTreePrivateVO> voList = ForestNodeMerger.merge(JSONArray.parseArray(JSONObject.toJSONString(result), WbsTreePrivateVO.class));
             List<WbsTreeContractTreeVOS> vosResult = new ArrayList<>();
@@ -66,7 +66,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
     public boolean showBussTab(Long pkeyId, Integer status) {
         WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
                 .eq(WbsTreePrivate::getPKeyId, pkeyId));
-        if (wbsTreePrivate == null){
+        if (wbsTreePrivate == null) {
             throw new ServiceException("未找到当前表单");
         }
         UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
@@ -115,7 +115,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
         //复制表数据
         String querySql = "select " + colkeys + " from " + tabName + " where p_key_id=" + pKeyId;
         List<Map<String, Object>> dataList = jdbcTemplate.queryForList(querySql);
-        if (dataList != null && dataList.size()>=1) {
+        if (dataList != null && dataList.size() >= 1) {
             Map<String, Object> dataMap2 = dataList.get(0);
 
             dataMap2.remove("p_key_id");
@@ -150,7 +150,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
 
     @Override
     public boolean removeBussTabInfoById(Long pKeyId) {
-        String sql = "delete from m_wbs_tree_private where p_key_id = '"+pKeyId+"'";
+        String sql = "delete from m_wbs_tree_private where p_key_id = '" + pKeyId + "'";
         jdbcTemplate.execute(sql);
         return true;
     }
@@ -161,16 +161,16 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
         List<Long> ids = Func.toLongList(wbsTreePrivate.getMixRatioTestIds());
         List<WbsTreePrivate> result = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
                 .in(WbsTreePrivate::getId, ids)
-                .eq(WbsTreePrivate::getProjectId,wbsTreePrivate.getProjectId())
-                .eq(WbsTreePrivate::getWbsId,wbsTreePrivate.getWbsId())
-                .eq(WbsTreePrivate::getWbsType,wbsTreePrivate.getWbsType())
-                .eq(WbsTreePrivate::getStatus,1)
+                .eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
+                .eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
+                .eq(WbsTreePrivate::getWbsType, wbsTreePrivate.getWbsType())
+                .eq(WbsTreePrivate::getStatus, 1)
         );
         List<WbsTreePrivateVO> wbsTreePrivateVOS = BeanUtil.copyProperties(result, WbsTreePrivateVO.class);
         return ForestNodeMerger.merge(wbsTreePrivateVOS);
     }
 
-    private void foreachSetChildList(List<WbsTreeContractTreeVOS> vosResult, List<WbsTreePrivateVO> voList){
+    private void foreachSetChildList(List<WbsTreeContractTreeVOS> vosResult, List<WbsTreePrivateVO> voList) {
         voList.forEach(wbsTreePrivateVO -> {
             WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
             vos.setId(wbsTreePrivateVO.getId());
@@ -182,7 +182,7 @@ public class WbsTreePrivateClientImpl implements WbsTreePrivateClient {
             vos.setWbsType(Integer.parseInt(wbsTreePrivateVO.getWbsType()));
             vos.setNotExsitChild(vos.getChildren().size() == 0);
 
-            if(wbsTreePrivateVO.getChildren().size() > 0){
+            if (wbsTreePrivateVO.getChildren().size() > 0) {
                 List<WbsTreeContractTreeVOS> child = new ArrayList<>();
                 this.foreachSetChildList(child, wbsTreePrivateVO.getChildren());
                 vos.setChildren(child);

+ 4 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IWbsTreePrivateService.java

@@ -9,7 +9,7 @@ import org.springblade.manager.entity.WbsTree;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.vo.*;
 
-
+import java.io.IOException;
 import java.util.List;
 
 public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
@@ -67,4 +67,7 @@ public interface IWbsTreePrivateService extends BaseService<WbsTreePrivate> {
     R delTableById(String primaryKeyIds);
 
     List<WbsTreePrivate> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId);
+
+    Object getExcelHtml(String primaryKeyId) throws IOException;
+
 }

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

@@ -20,7 +20,6 @@ import cn.hutool.core.date.StopWatch;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.aliyun.oss.ServiceException;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -40,6 +39,7 @@ import org.springblade.business.vo.SaveContractLogVO;
 import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
@@ -342,7 +342,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 });
                 stopWatch.start("公式处理");
                 List<Formula> formulas = this.formulaService.getFormulaList(keyMappers);
-                WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,nodeId));
+                WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
                 TableElementConverter tec = new TableElementConverter(tableInfoList, keyMappers, formulas, coordinateMap, wtc);
                 if (tec.isPresent()) {
                     tec.before();
@@ -530,11 +530,11 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
     @Override
     @Transactional
-    public R saveOrUpdateInfo(List<TableInfo> tableInfoList){
+    public R saveOrUpdateInfo(List<TableInfo> tableInfoList) {
 
         if (ListUtils.isNotEmpty(tableInfoList)) {
             //施工资料填报
-            String pkids="";
+            String pkids = "";
             try {
                 for (TableInfo tableInfo : tableInfoList) {
                     WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
@@ -542,7 +542,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     if (wbsTreeContract == null) {
                         continue;
                     }
-                    pkids+=tableInfo.getPkeyId()+",";
+                    pkids += tableInfo.getPkeyId() + ",";
                     String tabName = wbsTreeContract.getInitTableName();
                     // 判读修改还是 添加
                     String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
@@ -594,7 +594,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
                 JSONObject json = new JSONObject();
                 json.put("operationObjIds", Func.toStrList(pkids));
-                json.put("operationObjName", wbsTreeContractByP.getNodeName()+"节点数据操作");
+                json.put("operationObjName", wbsTreeContractByP.getNodeName() + "节点数据操作");
 
                 //保存操作记录
                 this.operationLogClient.saveUserOperationLog(1, "资料填报", "工序填报页面", json);
@@ -606,50 +606,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return R.fail("操作成功");
     }
 
-    @Override
-    @Transactional
-    public void saveOrUpdateInfoTrial(List<TableInfo> tableInfoList) throws SQLException {
-        //试验填报
-        if (ListUtils.isNotEmpty(tableInfoList)) {
-            try {
-                for (TableInfo tableInfo : tableInfoList) {
-                    WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
-                            .eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
-                    if (wbsTreePrivate == null) {
-                        continue;
-                    }
-
-                    String tabName = wbsTreePrivate.getInitTableName();
-                    // 判读修改还是 添加
-                    String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
-                    jdbcTemplate.execute(delSql);
-
-                    String sqlInfo = "";
-                    LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
-                    sqlInfo = "INSERT INTO " + tabName + " ( ";
-                    String keyStr = "id,";
-                    String valStr = SnowFlakeUtil.getId() + ",";
-                    for (String keys : dataMap2.keySet()) {
-                        keyStr += keys + ",";
-                        valStr += "'" + dataMap2.get(keys) + "',";
-                    }
-                    keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
-                    valStr = valStr.substring(0, valStr.lastIndexOf(","));
-                    sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
-
-                    UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
-                    updateWrapper.in("p_key_id", tableInfo.getPkeyId());
-                    updateWrapper.set("is_tab_pdf", 2);
-                    wbsTreePrivateService.update(updateWrapper);
-                    jdbcTemplate.execute(sqlInfo);
-                }
-
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
     // 获取用户
     @Override
     public Map<String, String> getTablbCols(String pkeyid, String colkey) throws FileNotFoundException {
@@ -707,9 +663,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
 
         String pdfPath = file_path + "/pdf//" + pkeyId + ".pdf";
         String excelPath = file_path + "/pdf//" + pkeyId + ".xlsx";
-        File tabpdf = ResourceUtil.getFile(pdfPath);
-        if (tabpdf.exists()) {
-            tabpdf.delete();
+        File tabPdf = ResourceUtil.getFile(pdfPath);
+        if (tabPdf.exists()) {
+            tabPdf.delete();
         }
 
         // 获取清表信息
@@ -905,16 +861,15 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         List<TableFile> tableFileList = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getIsDeleted, 0));
         tableFileList.sort(Comparator.comparing(TableFile::getType));
 
-
         List<String> dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
 
         String pdfPath2 = file_path + "/pdf//" + pkeyId + "_2.pdf";
 
-        File tabpdf2 = ResourceUtil.getFile(pdfPath2);
-        if (tabpdf2.exists()) {
-            tabpdf2.delete();
-
+        File tabPdf2 = ResourceUtil.getFile(pdfPath2);
+        if (tabPdf2.exists()) {
+            tabPdf2.delete();
         }
+
         FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
 
         BladeFile bladeFile2 = newIOSSClient.uploadFile(pkeyId + "2.pdf", pdfPath2);
@@ -927,7 +882,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return R.data(bladeFile2.getLink());
     }
 
-
     @Override
     public R getBussDataInfo(Long pkeyId) {
 
@@ -939,9 +893,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             return R.data(reData);
         }
 
-        if (wbsTreeContract == null) {
-            return R.data(reData);
-        }
         if (wbsTreeContract.getHtmlUrl() == null) {
             return R.data(reData);
         }
@@ -949,17 +900,15 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         //表单是否存储在
         String tabName = wbsTreeContract.getInitTableName();
         String isExitSql = " select * from information_schema.TABLES where TABLE_NAME='" + tabName + "'";
-        List<Map<String, Object>> tablist = jdbcTemplate.queryForList(isExitSql);
-        if (tablist == null || tablist.size() <= 0) {
+        List<Map<String, Object>> tabList = jdbcTemplate.queryForList(isExitSql);
+        if (tabList == null || tabList.size() <= 0) {
             return R.fail("无实体表对应");
         }
 
         String querySql = "select * from " + wbsTreeContract.getInitTableName() + " where p_key_id=" + pkeyId;
         List<Map<String, Object>> dataIn = jdbcTemplate.queryForList(querySql);
 
-
         // 匹配关联
-
         try {
             File file1 = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
             String htmlString = IoUtil.readToString(new FileInputStream(file1));
@@ -1010,7 +959,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             e.printStackTrace();
         }
 
-
         if (dataIn != null && dataIn.size() >= 1) {
             Map<String, Object> mysqlData = dataIn.get(0);
             for (String key : mysqlData.keySet()) {
@@ -1132,6 +1080,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         jdbcTemplate.execute(sql);
     }
 
+    /**
+     * 试验 单pdf
+     */
     @Override
     public String getBussPDFTrial(TableInfo tableInfo, Long pkeyId, String contractId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
@@ -1155,7 +1106,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         ExcelTab excelTab = this.getById(wbsTreePrivate.getExcelId());
 
         if (excelTab == null) {
-            throw new ServiceException("操作失败");
+            throw new ServiceException("操作失败!");
         }
 
         Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(pkeyId).getData();
@@ -1359,6 +1310,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return bladeFile2.getLink();
     }
 
+    /**
+     * 试验 多pdf
+     */
     @Override
     public String getBussPDFSTrial(String nodeId, Integer tableType, String classify, String contractId, String projectId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
@@ -1401,4 +1355,51 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return bladeFile.getLink();
     }
 
+    /**
+     * 试验 修改信息
+     */
+    @Override
+    @Transactional
+    public void saveOrUpdateInfoTrial(List<TableInfo> tableInfoList) throws SQLException {
+        //试验填报
+        if (ListUtils.isNotEmpty(tableInfoList)) {
+            try {
+                for (TableInfo tableInfo : tableInfoList) {
+                    WbsTreePrivate wbsTreePrivate = wbsTreePrivateService.getBaseMapper().selectOne(Wrappers.<WbsTreePrivate>query().lambda()
+                            .eq(WbsTreePrivate::getPKeyId, tableInfo.getPkeyId()));
+                    if (wbsTreePrivate == null) {
+                        continue;
+                    }
+
+                    String tabName = wbsTreePrivate.getInitTableName();
+                    // 判读修改还是 添加
+                    String delSql = "delete from " + tabName + " where p_key_id=" + tableInfo.getPkeyId();
+                    jdbcTemplate.execute(delSql);
+
+                    String sqlInfo = "";
+                    LinkedHashMap<String, String> dataMap2 = tableInfo.getDataMap();
+                    sqlInfo = "INSERT INTO " + tabName + " ( ";
+                    String keyStr = "id,";
+                    String valStr = SnowFlakeUtil.getId() + ",";
+                    for (String keys : dataMap2.keySet()) {
+                        keyStr += keys + ",";
+                        valStr += "'" + dataMap2.get(keys) + "',";
+                    }
+                    keyStr = keyStr.substring(0, keyStr.lastIndexOf(","));
+                    valStr = valStr.substring(0, valStr.lastIndexOf(","));
+                    sqlInfo = sqlInfo + keyStr + ") VALUES (" + valStr + ")";
+
+                    UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
+                    updateWrapper.in("p_key_id", tableInfo.getPkeyId());
+                    updateWrapper.set("is_tab_pdf", 2);
+                    wbsTreePrivateService.update(updateWrapper);
+                    jdbcTemplate.execute(sqlInfo);
+                }
+
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
 }

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

@@ -7,6 +7,10 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 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.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -15,6 +19,8 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.node.ForestNodeMerger;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
 import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
@@ -22,9 +28,13 @@ import org.springblade.manager.entity.*;
 import org.springblade.manager.mapper.*;
 import org.springblade.manager.service.IWbsTreePrivateService;
 import org.springblade.manager.vo.*;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -41,6 +51,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
     private final WbsParamMapper wbsParamMapper;
     private final ProjectInfoMapper projectInfoMapper;
     private final WbsTreePrivateMapper wbsTreePrivateMapper;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
@@ -1276,6 +1287,83 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         return baseMapper.selectWbsTreeContractList(tableOwnerNumbers, tableType, wbsTreePrivate.getProjectId(), wbsTreePrivate.getWbsId(), wbsTreePrivate.getId(), tableOwnerList);
     }
 
+    @Override
+    public Object getExcelHtml(String primaryKeyId) throws IOException {
+        WbsTreePrivate wbsTreePrivate = baseMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda()
+                .eq(WbsTreePrivate::getPKeyId, primaryKeyId));
+        if (wbsTreePrivate == null) {
+            throw new ServiceException("该数据下无此节点!");
+        }
+        if (wbsTreePrivate.getHtmlUrl() == null) {
+            throw new ServiceException("暂无表单!");
+        }
+        File file1 = ResourceUtil.getFile(wbsTreePrivate.getHtmlUrl());
+        FileInputStream fileInputStream = new FileInputStream(file1);
+
+        String htmlString = IoUtil.readToString(fileInputStream);
+        htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
+        htmlString = htmlString.replaceAll("title", "titlexx");
+
+        //远程搜索配置
+        Document doc = Jsoup.parse(htmlString);
+        Element table = doc.select("table").first();
+
+        /*int maxCol = doc.select("Col").size();
+        Elements hc = doc.select("hc-form-select-search");
+        if (hc.size() >= 1) {
+            for (int i = 0; i < hc.size(); i++) {
+                Element dataX = hc.get(i);
+                dataX.removeAttr("pkeyId");
+                dataX.removeAttr("contractId");
+                dataX.attr("pkeyId", primaryKeyId + "");
+                dataX.attr("contractId", wbsTreePrivate.getContractId());
+            }
+        }*/
+
+        //标题解决
+        /*ProjectInfo projectInfo = projectInfoMapper.selectById(wbsTreePrivate.getProjectId());
+        //添加标题显示
+        Elements trs = table.select("tr");
+        for (int i = 0; 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);
+                //int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
+                String style = data.attr("style");
+                if (style.contains("font-size")) {
+                    int fontsize = Integer.parseInt(style.substring(style.indexOf("font-size:") + 10, style.indexOf(".0pt")));
+                    if (org.apache.commons.lang.StringUtils.isNotEmpty(data.text()) && fontsize >= 12) {
+                        trs.get(i - 1).select("td").get(0).text(projectInfo.getProjectName());
+                    }
+                }
+            }
+        }*/
+
+        //获取公式颜色
+        String tabName = wbsTreePrivate.getInitTableName();
+        //字段查询 获取公式字段
+        String colKeys = "SELECT e_key from m_wbs_tree a ,m_wbs_form_element b WHERE a.init_table_name = '" + tabName + "' and a.id=b.f_id and b.id  in(SELECT element_id from m_formula c where c.is_deleted=0) ";
+        List<Map<String, Object>> maps = jdbcTemplate.queryForList(colKeys);
+        for (Map<String, Object> keys : maps) {
+            String key = keys.get("e_key") + "__";
+            Elements gsColor = doc.select("el-input[keyname~=^" + key + "]");
+            for (Element element : gsColor) {
+                //System.out.println(element.parent());
+                element.parent().attr("gscolor", "11");
+            }
+            Elements dateColor = doc.select("el-date-picker[keyname~=^" + key + "]");
+            for (Element element : dateColor) {
+                //System.out.println(element.parent());
+                element.parent().attr("gscolor", "11");
+            }
+        }
+
+        doc.select("Col").remove();
+        fileInputStream.close();
+        return R.data(table + "");
+    }
+
 
     @Transactional(rollbackFor = Exception.class)
     public boolean insertBatch(Collection<WbsTreePrivate> entityList, int batchSize) {