|
@@ -12,13 +12,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
|
import com.mixsmart.utils.ListUtils;
|
|
|
import com.mixsmart.utils.RegexUtils;
|
|
|
-import com.spire.xls.CellRange;
|
|
|
-import com.spire.xls.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
@@ -74,14 +71,12 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.net.URL;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* 清表基础数据表 服务实现类
|
|
@@ -346,19 +341,19 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
CurrentNode currentNode = null;
|
|
|
Long pKeyId = null;
|
|
|
- Long contractId=null;
|
|
|
- Long projectId=null;
|
|
|
+ Long contractId = null;
|
|
|
+ Long projectId = null;
|
|
|
if (type.equals(ExecuteType.INSPECTION)) {
|
|
|
WbsTreeContract wtc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, nodeId));
|
|
|
pKeyId = wtc.getPKeyId();
|
|
|
currentNode = createCurrentNode(wtc);
|
|
|
- contractId=Long.parseLong(wtc.getContractId());
|
|
|
- projectId=Long.parseLong(wtc.getProjectId());
|
|
|
+ contractId = Long.parseLong(wtc.getContractId());
|
|
|
+ projectId = Long.parseLong(wtc.getProjectId());
|
|
|
} else if (type.equals(ExecuteType.TESTING)) {
|
|
|
WbsTreePrivate wtp = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, nodeId));
|
|
|
pKeyId = wtp.getPKeyId();
|
|
|
currentNode = createCurrentNode(wtp);
|
|
|
- projectId=Long.parseLong(wtp.getProjectId());
|
|
|
+ projectId = Long.parseLong(wtp.getProjectId());
|
|
|
}
|
|
|
if (currentNode != null) {
|
|
|
TableElementConverter tec = new TableElementConverter(tableInfoList, keyMappers, formulas, coordinateMap, currentNode, tableAll);
|
|
@@ -1389,102 +1384,101 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
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().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
- int x1 = 0;
|
|
|
- int x2 = 0;
|
|
|
- int y1 = 0;
|
|
|
- int y2 = 0;
|
|
|
-
|
|
|
- if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
- 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.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
|
|
|
- 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.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
-
|
|
|
- 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;
|
|
|
- }
|
|
|
+ if (Integer.parseInt(xy[1]) < tdsx.size()) {
|
|
|
+ Element data = ytzData.select("td").get(Integer.parseInt(xy[1]));
|
|
|
+ if (data != null) {
|
|
|
+ if (data.html().indexOf("x1") >= 0 && data.html().indexOf("y1") >= 0) {
|
|
|
+ int x1 = 0;
|
|
|
+ int x2 = 0;
|
|
|
+ int y1 = 0;
|
|
|
+ int y2 = 0;
|
|
|
+
|
|
|
+ if (data.html().indexOf("el-tooltip") >= 0) {
|
|
|
+ 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.indexOf("T") >= 0 && myData.indexOf("-") >= 0) || (myData.indexOf(",") >= 0 && myData.indexOf("]") >= 0)) {
|
|
|
+ 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.indexOf(",") >= 0 && myData.indexOf("]") >= 0) {
|
|
|
+
|
|
|
+ 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 {
|
|
|
- String[] dataStr = myData.split("T")[0].split("-");
|
|
|
- if (dataStr.length == 3) {
|
|
|
- myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
- }
|
|
|
+ myData = StartDate + "-" + endDate;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String[] dataStr = myData.split("T")[0].split("-");
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- if (myData.indexOf("lang.String") >= 0) {
|
|
|
- Object obj = DataInfo.get(val);
|
|
|
- if (obj instanceof String[]) {
|
|
|
- String[] dataDate = (String[]) obj;
|
|
|
- myData = dataDate[0] + "-" + dataDate[1].trim();
|
|
|
- }
|
|
|
+ if (myData.indexOf("lang.String") >= 0) {
|
|
|
+ Object obj = DataInfo.get(val);
|
|
|
+ if (obj instanceof String[]) {
|
|
|
+ String[] dataDate = (String[]) obj;
|
|
|
+ myData = dataDate[0] + "-" + dataDate[1].trim();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
- if ((myData.indexOf("https") >= 0 || myData.indexOf("http") >= 0) && myData.indexOf("aliyuncs") >= 0) {
|
|
|
-
|
|
|
- InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
- byte[] byteNew = IOUtils.toByteArray(imageIn);
|
|
|
- byte[] bytes = CommonUtil.compressImage(byteNew);
|
|
|
- // 这里根据实际需求选择图片类型
|
|
|
- int pictureIdx = workbook.addPicture(bytes, 6);
|
|
|
- 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));
|
|
|
-
|
|
|
- } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
|
|
|
- Row row = sheet.getRow(y1 - 1);
|
|
|
- if (row != null) {
|
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
- if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
- String exceVal = cell.getStringCellValue().replaceAll(" ", "");
|
|
|
- short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
- Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
- fontAt.setFontName("EUDC");
|
|
|
- cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
- }
|
|
|
+ //https:bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20220819/b53cb6700db369381e3b03d7737bcdec.jpg__16_1
|
|
|
+ if ((myData.indexOf("https") >= 0 || myData.indexOf("http") >= 0) && myData.indexOf("aliyuncs") >= 0) {
|
|
|
+
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
|
+ byte[] byteNew = IOUtils.toByteArray(imageIn);
|
|
|
+ byte[] bytes = CommonUtil.compressImage(byteNew);
|
|
|
+ // 这里根据实际需求选择图片类型
|
|
|
+ int pictureIdx = workbook.addPicture(bytes, 6);
|
|
|
+ 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));
|
|
|
+
|
|
|
+ } else if (myData.equals("1") && data.html().indexOf("hc-form-checkbox-group") >= 0) {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ String exceVal = cell.getStringCellValue().replaceAll(" ", "");
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
+ cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
}
|
|
|
- } else {
|
|
|
- Row row = sheet.getRow(y1 - 1);
|
|
|
- if (row != null) {
|
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
- if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
- cell.setCellValue(myData);
|
|
|
- }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
+ if (row != null) {
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
+ cell.setCellValue(myData);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1495,58 +1489,59 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- // 组装电签设置
|
|
|
- QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.in("type", 2, 6);
|
|
|
- queryWrapper.eq("tab_id", wbsTreeContract.getIsTypePrivatePid());
|
|
|
-
|
|
|
- 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("_");
|
|
|
- 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);
|
|
|
-
|
|
|
- Font redFont = workbook.createFont();
|
|
|
- redFont.setColor(IndexedColors.WHITE.getIndex()); //设置字体颜色
|
|
|
- redFont.setFontHeightInPoints(oldfontAt.getFontHeightInPoints());//设置字体大小
|
|
|
- redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
|
+ // 组装电签设置
|
|
|
+ QueryWrapper<TextdictInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.in("type", 2, 6);
|
|
|
+ queryWrapper.eq("tab_id", wbsTreeContract.getIsTypePrivatePid());
|
|
|
+
|
|
|
+ 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("_");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
|
|
|
- CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
- newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
- newStyle.setFont(redFont);
|
|
|
- cell.setCellStyle(newStyle);
|
|
|
- cell.setCellValue(e.getId() + "");
|
|
|
- }
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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() + "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
//输出流
|
|
|
|
|
@@ -2137,6 +2132,7 @@ 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();
|
|
@@ -2171,7 +2167,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
ProjectInfo projectInfo = projectInfoService.getById(wbsTreePrivate.getProjectId());
|
|
|
int all = sheet.getRow(0).getLastCellNum();
|
|
|
int mergedCellCnt = sheet.getNumMergedRegions();
|
|
|
- for (int i = 0; i < mergedCellCnt - 1; i++) {
|
|
|
+ for (
|
|
|
+ int i = 0;
|
|
|
+ i < mergedCellCnt - 1; i++) {
|
|
|
CellRangeAddress mergedCell = sheet.getMergedRegion(i);
|
|
|
int xx = mergedCell.getNumberOfCells();
|
|
|
if (xx <= all) {
|