liuyc 2 年之前
父節點
當前提交
628a76a9e7

+ 10 - 9
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -835,6 +835,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public String selfSubmit(TrialSelfInspectionRecordDTO dto) throws FileNotFoundException {
         //------初始当前填报的表pKeyIds------
         this.initTrialTabIds(dto);
@@ -853,7 +854,11 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             this.reBuildNumber(obj, dto);
 
             //------保存实体表数据、试验记录信息、生成PDF------
-            this.submitTrialData(obj, dto);
+            try {
+                this.submitTrialData(obj, dto);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
 
             //------关联原材料检测报告------
             this.rawMaterialSubmitRelation(dto, obj);
@@ -898,14 +903,10 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @Async
-    public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
-        try {
-            String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
-            if (StringUtils.isNotEmpty(pdfURL)) {
-                this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
+    public void submitTrialData(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) throws Exception {
+        String pdfURL = excelTabClient.saveTabData(dto, dto.getIsBatchSave(), dto.getType(), dto.getTableType(), dto.getId(), obj.getTableIds());
+        if (StringUtils.isNotEmpty(pdfURL)) {
+            this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate().set(TrialSelfInspectionRecord::getPdfUrl, pdfURL).eq(TrialSelfInspectionRecord::getId, dto.getId()));
         }
     }
 

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

@@ -18,7 +18,6 @@ package org.springblade.manager.service.impl;
 
 import cn.hutool.core.date.StopWatch;
 import cn.hutool.log.StaticLog;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -27,9 +26,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.mixsmart.utils.ListUtils;
 import com.mixsmart.utils.RegexUtils;
-import com.spire.xls.CellRange;
-import com.spire.xls.Workbook;
-import com.spire.xls.*;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
@@ -82,9 +78,6 @@ import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.support.DefaultTransactionDefinition;
 
-import javax.imageio.ImageIO;
-import java.awt.Color;
-import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URL;
 import java.text.SimpleDateFormat;
@@ -93,7 +86,6 @@ import java.util.*;
 import java.util.function.Function;
 import java.util.regex.Matcher;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * 清表基础数据表 服务实现类
@@ -387,7 +379,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             currentNode.setPkId(wtc.getPKeyId());
             currentNode.setParentId(wtc.getParentId());
             currentNode.setWbsId(Long.parseLong(wtc.getWbsId()));
-            currentNode.setId(StringUtils.isNotEmpty(wtc.getOldId())? Long.valueOf(wtc.getOldId()) :wtc.getId());
+            currentNode.setId(StringUtils.isNotEmpty(wtc.getOldId()) ? Long.valueOf(wtc.getOldId()) : wtc.getId());
             currentNode.setRelateId(wtc.getId());
             List<Long> privateIds = this.jdbcTemplate.queryForList("select p_key_id from m_wbs_tree_private where id=" + currentNode.getRelateId() + " and  project_id=" + wtc.getProjectId() + " and wbs_id=" + wtc.getWbsId(), Long.class);
             if (Func.isNotEmpty(privateIds)) {
@@ -571,21 +563,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 .eq(WbsTreeContract::getIsDeleted, 0));
 
         // 数据维数据
-        Map<String , List<WbsTreeContract> > Data = new HashMap<>();
-        if(wbsTreeContractList!=null && wbsTreeContractList.size()>=1){
-            for(WbsTreeContract dataInfo : wbsTreeContractList){
-                String dataId = dataInfo.getId()+"";
-                String parentId = dataInfo.getParentId()+"";
+        Map<String, List<WbsTreeContract>> Data = new HashMap<>();
+        if (wbsTreeContractList != null && wbsTreeContractList.size() >= 1) {
+            for (WbsTreeContract dataInfo : wbsTreeContractList) {
+                String dataId = dataInfo.getId() + "";
+                String parentId = dataInfo.getParentId() + "";
 
-                if(!Data.containsKey(dataId)){
+                if (!Data.containsKey(dataId)) {
                     List<WbsTreeContract> newData = new ArrayList<>();
-                    Data.put(dataId,newData);
+                    Data.put(dataId, newData);
                 }
                 // 添加数据
-                if(Data.containsKey(parentId)){
+                if (Data.containsKey(parentId)) {
                     List<WbsTreeContract> newData = Data.get(parentId);
                     newData.add(dataInfo);
-                    Data.put(parentId,newData);
+                    Data.put(parentId, newData);
                 }
             }
         }
@@ -594,21 +586,21 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         List<WbsTreeContract> lastList = new ArrayList<>();
         List<WbsTreeContract> collect = wbsTreeContractList.stream().filter(wbsTreeContract -> "0".equals(wbsTreeContract.getParentId().toString())).collect(Collectors.toList());
 
-        this.dataInfo(collect,lastList,Data);
+        this.dataInfo(collect, lastList, Data);
 
-        if(lastList!=null && lastList.size()>=1){
-            for(WbsTreeContract data : lastList){
+        if (lastList != null && lastList.size() >= 1) {
+            for (WbsTreeContract data : lastList) {
                 UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
                 updateWrapper.eq("p_key_id", data.getPKeyId() + "");
                 updateWrapper.set("ancestors", data.getAncestors());
-                wbsTreeContractService.getBaseMapper().update(data,updateWrapper);
+                wbsTreeContractService.getBaseMapper().update(data, updateWrapper);
             }
         }
         return R.data("成功");
     }
 
 
-    public void dataInfo(List<WbsTreeContract> collect,List<WbsTreeContract> lastList,Map<String , List<WbsTreeContract> > Data){
+    public void dataInfo(List<WbsTreeContract> collect, List<WbsTreeContract> lastList, Map<String, List<WbsTreeContract>> Data) {
 
         /*List<WbsTreeContract> redata = new ArrayList<>();
         if (collect!=null && collect.size()==1){
@@ -635,12 +627,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         collect.forEach(queue::offer);
         while (!queue.isEmpty()) {
             //每次循环出列一个对象 一直到队列为空
-            WbsTreeContract tree= queue.poll();
-            String dataId = tree.getId()+"";
+            WbsTreeContract tree = queue.poll();
+            String dataId = tree.getId() + "";
             List<WbsTreeContract> er = Data.get(dataId);
-            if(er!=null && er.size()>=1){
-                for(WbsTreeContract erData : er){
-                    erData.setAncestors(tree.getAncestors()+","+erData.getParentId());
+            if (er != null && er.size() >= 1) {
+                for (WbsTreeContract erData : er) {
+                    erData.setAncestors(tree.getAncestors() + "," + erData.getParentId());
                     lastList.add(erData);
                 }
             }
@@ -653,7 +645,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     }
 
 
-
     /**
      * 保存首件
      */
@@ -883,7 +874,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 //保存操作记录
                 this.operationLogClient.saveUserOperationLog(1, "资料填报", "工序填报页面", json);
                 // 更新redis
-                informationQueryClient.AsyncWbsTree(wbsTreeContractByP.getParentId()+"",wbsTreeContractByP.getParentId()+"",wbsTreeContractByP.getContractId(),"","1");
+                informationQueryClient.AsyncWbsTree(wbsTreeContractByP.getParentId() + "", wbsTreeContractByP.getParentId() + "", wbsTreeContractByP.getContractId(), "", "1");
             } catch (Exception e) {
                 e.printStackTrace();
                 return R.fail("操作失败");
@@ -902,12 +893,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         for (String p : part) {
             Matcher m = RegexUtils.matcher("(m_\\d{14}_\\d{19})\\((.+)\\)VALUES\\(([^)]+)\\).+column'(key_\\d{0,2})'", p.replaceAll("[\\n\\s]*", ""));
             if (m.find()) {
-                if(p.contains("Data too long for column")){
+                if (p.contains("Data too long for column")) {
                     List<Map<String, Object>> result = this.jdbcTemplate.queryForList("select CONCAT(a.tab_ch_name,'&',b.e_name) tf from m_table_info a join m_wbs_form_element b on b.f_id=a.id where a.tab_en_name='" + m.group(1) + "' and  b.e_key='" + m.group(4) + "'");
                     if (result.size() > 0) {
                         sb.append("【").append(result.get(0).values().stream().map(String::valueOf).collect(Collectors.joining(","))).append("数据库字段太短】");
                     }
-                }else if(p.contains("Unknown column")){
+                } else if (p.contains("Unknown column")) {
                     sb.append("【").append(m.group(1)).append(":").append(m.group(4)).append("关联错误】");
                 }
 
@@ -1998,46 +1989,35 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         List<Map<String, Object>> bussDataInfoTrial = this.getBussDataInfoTrial(id, pkeyId, Long.parseLong(contractId));
         Map<String, Object> DataInfo = bussDataInfoTrial.stream().findAny().orElse(null);
 
-        //获取excel流 和 html流
-        Workbook wb = new Workbook();
-        wb.loadFromMHtml(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
-        //获取工作表
-        Worksheet sheet = wb.getWorksheets().get(0);
-
-        //页码
-        PageSetup pageSetup = sheet.getPageSetup();
+        org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(CommonUtil.getOSSInputStream(excelTab.getFileUrl()));
+        Sheet sheet = workbook.getSheetAt(0);
+        sheet.setForceFormulaRecalculation(true);
+        Header header = sheet.getHeader();
+        //页眉
         if (pageNumber != 0 && pageNumberCount != 0) {
-            pageSetup.setRightHeader("第" + pageNumber + "页,共" + pageNumberCount + "页");
+            header.setRight("第" + pageNumber + "页,共" + pageNumberCount + "页");
         }
 
-        /*// 标题添加
+        //标题Title
         ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
-
         int all = sheet.getRow(0).getLastCellNum();
         int mergedCellCnt = sheet.getNumMergedRegions();
         for (int i = 0; i < mergedCellCnt - 1; i++) {
             CellRangeAddress mergedCell = sheet.getMergedRegion(i);
             int xx = mergedCell.getNumberOfCells();
-            if (xx == all) {
+            if (xx <= all) {
                 int fisRow = mergedCell.getFirstRow();
-                int firsrCol = mergedCell.getFirstColumn();
-
-                Cell cell = sheet.getRow(fisRow).getCell(firsrCol);
+                int firstCol = mergedCell.getFirstColumn();
+                Cell cell = sheet.getRow(fisRow).getCell(firstCol);
                 short fontIndex = cell.getCellStyle().getFontIndex();
-
-                Font oldfontAt = workbook.getFontAt(fontIndex);
-
+                Font oldFontAt = workbook.getFontAt(fontIndex);
                 Font redFont = workbook.createFont();
-                redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
-                redFont.setFontName(oldfontAt.getFontName());//设置字体
-
-                CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                redFont.setFontHeightInPoints(oldFontAt.getFontHeightInPoints());//设置字体大小
+                redFont.setFontName(oldFontAt.getFontName());//设置字体
+                CellStyle newStyle = workbook.createCellStyle();//创建单元格样式
                 newStyle.cloneStyleFrom(cell.getCellStyle());
-
-
                 short fontHeightInPoints = redFont.getFontHeightInPoints();
                 if (fontHeightInPoints >= 14 && StringUtils.isEmpty(cell.getStringCellValue()) && fisRow <= 8) {
-
                     String title = projectInfo.getProjectName();
                     if (title.length() >= 30) {
                         sheet.getRow(fisRow).setHeight((short) 900);
@@ -2050,8 +2030,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     break;
                 }
             }
-        }*/
-
+        }
 
         //数据不为空
         if (StringUtils.isNotEmpty(wbsTreePrivate.getHtmlUrl())) {
@@ -2061,134 +2040,173 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 Document doc = Jsoup.parse(htmlString);
                 Element table = doc.select("table").first();
                 Elements trs = table.select("tr");
-                Elements cols = table.select("col");
                 if (ObjectUtil.isNotEmpty(DataInfo)) {
-                    for (String val : DataInfo.keySet()) {
+                    for (String val : Objects.requireNonNull(DataInfo).keySet()) {
                         if (val.contains("__")) {
                             String[] DataVal = val.split("__");
                             String[] xy = DataVal[1].split("_");
+                            if (Integer.parseInt(xy[0]) < trs.size()) {
+                                Element ytzData = trs.get(Integer.parseInt(xy[0]));
+                                if (ytzData != null) {
+                                    Elements tdsx = ytzData.select("td");
+                                    if (Integer.parseInt(xy[1]) < tdsx.size()) {
+                                        Element data = ytzData.select("td").get(Integer.parseInt(xy[1]));
+                                        if (data != null) {
+                                            if (data.html().contains("x1") && data.html().contains("y1")) {
+                                                int x1 = 0;
+                                                int x2 = 0;
+                                                int y1 = 0;
+                                                int y2 = 0;
+                                                if (data.html().contains("el-tooltip")) {
+                                                    x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
+                                                    x2 = Integer.parseInt(data.children().get(0).children().get(0).attr("x2"));
+                                                    y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
+                                                } else {
+                                                    x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                                    y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+                                                }
+                                                if (x1 == 0) {
+                                                    x1 = 1;
+                                                }
+                                                String myData = DataInfo.get(val) + "";
+                                                if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
+                                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+                                                    sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
+                                                    SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
+                                                    if (myData.contains(",") && myData.contains("]")) {
 
-                            Element data = trs.get(Integer.parseInt(xy[0])).select("td").get(Integer.parseInt(xy[1]));
+                                                        myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
+                                                        String[] dataVal = myData.split(",");
 
-                            if (data.html().contains("x1") && data.html().contains("y1")) {
-                                int x1 = 0;
-                                int y1 = 0;
-                                if (data.html().contains("el-tooltip")) {
-                                    x1 = Integer.parseInt(data.children().get(0).children().get(0).attr("x1"));
-                                    y1 = Integer.parseInt(data.children().get(0).children().get(0).attr("y1"));
+                                                        Date Start_dataStr = sdf.parse(dataVal[0]);
+                                                        Date end_dataStr = sdf.parse(dataVal[1]);
+                                                        String StartDate = formatStr.format(Start_dataStr);
+                                                        String endDate = formatStr.format(end_dataStr);
+                                                        if (StartDate.equals(endDate)) {
+                                                            myData = StartDate;
+                                                        } else {
+                                                            myData = StartDate + "-" + endDate;
+                                                        }
+                                                    } else {
+                                                        String[] dataStr = myData.split("T")[0].split("-");
+                                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
+                                                    }
+                                                }
+                                                //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
+                                                if (myData.contains("https") && myData.contains("aliyuncs")) {
+                                                    InputStream imageIn = CommonUtil.getOSSInputStream(myData);
+                                                    byte[] bytes = IOUtils.toByteArray(imageIn);
+                                                    // 这里根据实际需求选择图片类型
+                                                    int pictureIdx = workbook.addPicture(bytes, 6);
 
-                                } else {
-                                    x1 = Integer.parseInt(data.children().get(0).attr("x1"));
-                                    y1 = Integer.parseInt(data.children().get(0).attr("y1"));
-                                }
-                                if (x1 == 0) {
-                                    x1 = 1;
-                                }
-                                String myData = DataInfo.get(val) + "";
-
-                                if (myData.contains("T") && myData.contains("-") && myData.contains(":")) {
-                                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-                                    sdf.setTimeZone(TimeZone.getTimeZone("GTM+8"));
-                                    SimpleDateFormat formatStr = new SimpleDateFormat("yyyy年MM月dd日");
-                                    if (myData.contains(",") && myData.contains("]")) {
-                                        myData = myData.replace("[", "").replace("]", "").replaceAll("'", "");
-                                        String[] dataVal = myData.split(",");
-
-                                        Date Start_dataStr = sdf.parse(dataVal[0]);
-                                        Date end_dataStr = sdf.parse(dataVal[1]);
-                                        String StartDate = formatStr.format(Start_dataStr);
-                                        String endDate = formatStr.format(end_dataStr);
-                                        if (StartDate.equals(endDate)) {
-                                            myData = StartDate;
-                                        } else {
-                                            myData = StartDate + "-" + endDate;
-                                        }
-                                    } else {
-                                        String[] dataStr = myData.split("T")[0].split("-");
-                                        myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]) + 1);
-                                    }
-                                }
+                                                    CreationHelper helper = workbook.getCreationHelper();
+                                                    ClientAnchor anchor = helper.createClientAnchor();
+                                                    anchor.setCol1(x1); // param1是列号
+                                                    anchor.setCol2(x2);
+                                                    anchor.setRow1(y1); // param2是行号
+                                                    anchor.setRow2(y2); // param2是行号
+                                                    //
+                                                    Drawing<?> drawing = sheet.createDrawingPatriarch();
+                                                    anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
+                                                    // 插入图片
+                                                    Picture pict = drawing.createPicture(anchor, pictureIdx); // 调整图片占单元格百分比的大小,1.0就是100%
+                                                    pict.resize(1, 1);
+                                                    FileUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
 
-                                if (myData.contains("https") && myData.contains("aliyuncs")) {
-                                    BufferedImage image = ImageIO.read(CommonUtil.getOSSInputStream(myData));
-                                    int colspan = data.attr("COLSPAN").equals("") ? 0 : Integer.parseInt(data.attr("COLSPAN"));
-                                    int rowspan = data.attr("ROWSPAN").equals("") ? 0 : Integer.parseInt(data.attr("ROWSPAN"));
-                                    int picHeight = 0;
-                                    int picWidth = 0;
-
-                                    if (rowspan == 0) {
-                                        String dataInfo = trs.get(y1).attr("height");
-                                        if (StringUtils.isEmpty(dataInfo)) {
-                                            Element firstTd = trs.get(y1 - 1).children().get(0);
-                                            String[] heg = firstTd.attr("style").split(";");
-                                            for (String str : heg) {
-                                                if (str.contains("height:")) {
-                                                    picHeight = Integer.parseInt(str.split(":")[1].replaceAll("px", ""));
+                                                } else if (myData.equals("1") && data.html().contains("hc-form-checkbox-group")) {
+                                                    Row row = sheet.getRow(y1 - 1);
+                                                    if (row != null) {
+                                                        Cell cell = row.getCell(x1 - 1);
+                                                        if (cell != null) {
+                                                            String exceVal = cell.getStringCellValue().replaceAll(" ", "");
+                                                            short fontIndex = cell.getCellStyle().getFontIndex();
+                                                            Font fontAt = workbook.getFontAt(fontIndex);
+                                                            fontAt.setFontName("EUDC");
+                                                            cell.setCellValue(exceVal.replace("□", "\u2611"));
+                                                        } else {
+                                                            ObjectUtils.isNotEmpty(cell);
+                                                        }
+                                                    }
+                                                } else {
+                                                    Row row = sheet.getRow(y1 - 1);
+                                                    if (row != null) {
+                                                        Cell cell = row.getCell(x1 - 1);
+                                                        if (cell != null) {
+                                                            cell.setCellValue(myData);
+                                                        } else {
+                                                            ObjectUtils.isNotEmpty(cell);
+                                                        }
+                                                    }
                                                 }
                                             }
-                                        } else {
-                                            picHeight = Integer.parseInt(dataInfo);
-                                        }
-                                    } else {
-                                        for (int i = y1; i <= (y1 + rowspan); i++) { // 跨列处理
-                                            String dataInfo = trs.get(i).attr("height");
-                                            if (StringUtils.isNotEmpty(dataInfo)) {
-                                                picHeight += Integer.parseInt(dataInfo);
-                                            }
-                                        }
-                                    }
-
-                                    if (colspan >= 1) {
-                                        for (int i = x1 - 1; i < x1 + colspan - 1; i++) {
-                                            String dataInfo = cols.get(i).attr("width").replaceAll("px", "");
-                                            if (StringUtils.isNotEmpty(dataInfo)) {
-                                                picWidth += Integer.parseInt(dataInfo);
-                                            }
                                         }
                                     }
-
-                                    ExcelPicture pic = sheet.getPictures().add(y1, x1, image);
-                                    pic.setAutoSize(true);
-                                    pic.setWidth(picWidth - 10);
-                                    pic.setHeight(picHeight);
-                                    pic.setLeft(5);
-                                } else {
-                                    CellRange cellRange = sheet.getCellRange(y1, x1);
-                                    cellRange.getCellStyle().getExcelFont().setFontName("EUDC");
-                                    cellRange.setText(myData);
                                 }
                             }
                         }
                     }
                 }
+
                 // 组装电签设置
                 QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
                 queryWrapper.select("col_key", "id");
-                queryWrapper.eq("type", 2);
+                queryWrapper.in("type", 2);
                 queryWrapper.eq("tab_id", wbsTreePrivate.getPKeyId());
-                List<TextdictInfo> textDictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
-                if (textDictInfos != null && !textDictInfos.isEmpty()) {
-                    for (TextdictInfo e : textDictInfos) {
+
+                List<TextdictInfo> textdictInfos = textdictInfoService.getBaseMapper().selectList(queryWrapper);
+                if (textdictInfos != null && !textdictInfos.isEmpty()) {
+                    for (TextdictInfo e : textdictInfos) {
                         String key = e.getColKey();
                         String[] keys = key.split("__");
-                        String[] trTd = keys[1].split("_");
-                        Element data = trs.get(Integer.parseInt(trTd[0])).select("td").get(Integer.parseInt(trTd[1]));
-                        int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
-                        if (x1 == 0) {
-                            x1 = 1;
-                        }
-                        int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+                        String[] trtd = keys[1].split("_");
+                        if (Integer.parseInt(trtd[0]) < trs.size()) {
+                            Element ytzData = trs.get(Integer.parseInt(trtd[0]));
+                            if (ytzData != null) {
+                                Elements tdsx = ytzData.select("td");
+                                if (Integer.parseInt(trtd[1]) < tdsx.size()) {
+                                    Element data = ytzData.select("td").get(Integer.parseInt(trtd[1]));
+                                    if (data.html().indexOf("el-tooltip") >= 0) {
+                                        data = data.children().get(0);
+                                    }
+
+                                    int x1 = Integer.parseInt(data.children().get(0).attr("x1"));
+                                    if (x1 == 0) {
+                                        x1 = 1;
+                                    }
+                                    int y1 = Integer.parseInt(data.children().get(0).attr("y1"));
+
+                                    Row row = sheet.getRow(y1 - 1);
+                                    if (row != null) {
+                                        Cell cell = sheet.getRow(y1 - 1).getCell(x1 - 1);
+                                        if (cell != null || ObjectUtils.isNotEmpty(cell)) {
+                                            short fontIndex = cell.getCellStyle().getFontIndex();
+                                            Font oldfontAt = workbook.getFontAt(fontIndex);
 
-                        final CellRange cellRange = sheet.getCellRange(y1, x1);
-                        cellRange.setText(e.getId() + "");
-                        cellRange.getCellStyle().getFont().setColor(Color.white);
+                                            Font redFont = workbook.createFont();
+                                            redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
+                                            redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
+                                            redFont.setFontName(oldfontAt.getFontName());//设置字体
+
+                                            CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
+                                            newStyle.cloneStyleFrom(cell.getCellStyle());
+                                            newStyle.setFont(redFont);
+                                            cell.setCellStyle(newStyle);
+                                            cell.setCellValue(e.getId() + "");
+                                        }
+                                    }
+                                }
+                            }
+                        }
                     }
                 }
             }
         }
 
-        wb.saveToFile(excelPath, ExcelVersion.Version2010);
-        FileUtils.excelToPdf(excelPath, pdfPath);
+        //输出流
+        FileOutputStream outputStream = new FileOutputStream(excelPath);
+        workbook.write(outputStream);
+        FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
+
         BladeFile bladeFile = newIOSSClient.uploadFile(pkeyId + ".pdf", pdfPath);
         TableFile tableFile1 = tableFileService.getBaseMapper().selectOne(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pkeyId + "").eq(TableFile::getType, 1).eq(TableFile::getTrialRecordId, id));
         if (tableFile1 != null) {
@@ -2242,10 +2260,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             }
             jdbcTemplate.execute(sql);
 
-            wb.dispose();
             return bladeFile2.getLink();
         }
-
         return "";
     }
 
@@ -2312,10 +2328,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         String querySql = "select id from u_information_query where classify ='" + classify + "' and wbs_id ='" + id + "' and contract_id ='" + contractId + "'";
         List<InformationQuery> query = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(InformationQuery.class));
         if (query.size() > 0) {
-            String updateSql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + trialProjectName + "'  where classify='" + classify + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
+            String updateSql = "update u_information_query set pdf_url ='" + bladeFile.getLink() + "', name ='" + (StringUtils.isNotEmpty(trialProjectName) ? trialProjectName : "") + "'  where classify='" + classify + "' and  wbs_id='" + id + "' and contract_id ='" + contractId + "'";
             jdbcTemplate.execute(updateSql);
         } else {
-            informationQueryClient.saveData(id.toString(), projectId, contractId, classify, bladeFile.getLink(), trialProjectName);
+            informationQueryClient.saveData(id.toString(), projectId, contractId, classify, bladeFile.getLink(), StringUtils.isNotEmpty(trialProjectName) ? trialProjectName : "");
         }
 
         return bladeFile.getLink();

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

@@ -97,8 +97,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
         //当前合同段所有节点ids
         List<String> collect2 = new ArrayList<>();
         if (list.size() > 0) {
-            collect1 = list.stream().filter(f -> f.getType() == 2).collect(Collectors.toList()).stream().map(WbsTreeContract::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
-            collect2 = list.stream().filter(f -> f.getType() == 1).collect(Collectors.toList()).stream().map(WbsTreeContract::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
+            collect1 = list.stream().filter(f -> f.getType() == 2).collect(Collectors.toList()).stream().map(WbsTreeContract::getId).map(String::valueOf).collect(Collectors.toList());
+            collect2 = list.stream().filter(f -> f.getType() == 1).collect(Collectors.toList()).stream().map(WbsTreeContract::getId).map(String::valueOf).collect(Collectors.toList());
         }
 
         List<String> collect3 = collect2;
@@ -122,7 +122,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
                 });
             });
 
-            List<String> collect = wbsTreePrivateList2.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
+            List<String> collect = wbsTreePrivateList2.stream().map(WbsTreePrivate::getId).map(String::valueOf).collect(Collectors.toList());
 
             List<String> diffRent1 = DiffListUtil.getDiffRent(collect, collect1);
 

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

@@ -1857,10 +1857,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
         }*/
 
         //标题解决
-        /*ProjectInfo projectInfo = projectInfoMapper.selectById(wbsTreePrivate.getProjectId());
+        ProjectInfo projectInfo = projectInfoMapper.selectById(wbsTreePrivate.getProjectId());
         //添加标题显示
         Elements trs = table.select("tr");
-        for (int i = 0; i < 6; i++) {
+        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++) {
@@ -1874,7 +1874,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                     }
                 }
             }
-        }*/
+        }
 
         //获取公式颜色
         String tabName = wbsTreePrivate.getInitTableName();