|
@@ -82,6 +82,7 @@ import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -788,6 +789,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
private void processElements(Elements elements) {
|
|
private void processElements(Elements elements) {
|
|
elements.stream().map(this::findParentTd).filter(Objects::nonNull).forEach(element -> element.attr("gscolor", "11"));
|
|
elements.stream().map(this::findParentTd).filter(Objects::nonNull).forEach(element -> element.attr("gscolor", "11"));
|
|
}
|
|
}
|
|
@@ -1480,8 +1483,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
Document doc = Jsoup.parse(htmlString);
|
|
Document doc = Jsoup.parse(htmlString);
|
|
Element table = doc.select("table").first();
|
|
Element table = doc.select("table").first();
|
|
Elements trs = table.select("tr");
|
|
Elements trs = table.select("tr");
|
|
- //Elements cols = table.select("col");
|
|
|
|
-
|
|
|
|
if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
if (ObjectUtil.isNotEmpty(DataInfo)) {
|
|
for (String val : DataInfo.keySet()) {
|
|
for (String val : DataInfo.keySet()) {
|
|
Elements datas = doc.getElementsByAttributeValue("keyname", val);
|
|
Elements datas = doc.getElementsByAttributeValue("keyname", val);
|
|
@@ -1556,7 +1557,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //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) {
|
|
if ((myData.indexOf("https") >= 0 || myData.indexOf("http") >= 0) && myData.indexOf("aliyuncs") >= 0) {
|
|
|
|
|
|
InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
InputStream imageIn = CommonUtil.getOSSInputStream(myData);
|
|
@@ -1636,7 +1636,6 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
// 组装电签设置
|
|
// 组装电签设置
|
|
|
|
|
|
Elements dqids = table.getElementsByAttribute("dqid");
|
|
Elements dqids = table.getElementsByAttribute("dqid");
|
|
-
|
|
|
|
for (Element element : dqids){
|
|
for (Element element : dqids){
|
|
String dqid = element.attr("dqid");
|
|
String dqid = element.attr("dqid");
|
|
Elements x11 = element.getElementsByAttribute("x1");
|
|
Elements x11 = element.getElementsByAttribute("x1");
|
|
@@ -1657,18 +1656,12 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
String CellValue = cell.getStringCellValue().trim();
|
|
String CellValue = cell.getStringCellValue().trim();
|
|
|
|
|
|
- /* if(CellValue!=null && StringUtils.isNotEmpty(CellValue)){
|
|
|
|
- RichTextString ts= new HSSFRichTextString(CellValue + "--"+dqid);
|
|
|
|
- // ts.applyFont(0,CellValue.length(),oldfontAt);
|
|
|
|
- // ts.applyFont(10,ts.length(),redFont);
|
|
|
|
- cell.setCellValue(ts);
|
|
|
|
- }else{*/
|
|
|
|
- CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
- newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
- newStyle.setFont(redFont);
|
|
|
|
- newStyle.setShrinkToFit(true);
|
|
|
|
- cell.setCellStyle(newStyle);
|
|
|
|
- cell.setCellValue(dqid);
|
|
|
|
|
|
+ CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
+ newStyle.setFont(redFont);
|
|
|
|
+ newStyle.setShrinkToFit(true);
|
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
|
+ cell.setCellValue(dqid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2791,4 +2784,369 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public R saveBussData(JSONArray dataArray) throws Exception {
|
|
|
|
+ JSONObject tableInfo1 = dataArray.getJSONObject(0);
|
|
|
|
+ String nodeId = tableInfo1.getString("nodeId");
|
|
|
|
+ String contractId = tableInfo1.getString("contractId");
|
|
|
|
+ String projectId = tableInfo1.getString("projectId");
|
|
|
|
+ String classify = tableInfo1.getString("classify");
|
|
|
|
+ //构造阻塞器
|
|
|
|
+ CountDownLatch cdl = new CountDownLatch(dataArray.size());
|
|
|
|
+ // 构造多线程保存用户数据到表中 并生成excel
|
|
|
|
+ for (int i=0; i<dataArray.size();i++){
|
|
|
|
+ JSONObject jsonObject = dataArray.getJSONObject(i);
|
|
|
|
+ Thread countUserThread = new Thread(() -> {
|
|
|
|
+ try {
|
|
|
|
+ SaveOneTabInfo(jsonObject);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ cdl.countDown();//标记已经完成一个任务
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ countUserThread.start();
|
|
|
|
+ }
|
|
|
|
+ //合并pdf加载
|
|
|
|
+ this.getBussPdfs(nodeId, classify, contractId, projectId);
|
|
|
|
+ //更新缓存
|
|
|
|
+ informationQueryClient.delAsyncWbsTree(contractId);
|
|
|
|
+ return R.data("操作成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 保存单表
|
|
|
|
+ public void SaveOneTabInfo(JSONObject tableInfo) throws Exception {
|
|
|
|
+ System.out.println("---------="+new Date().toLocaleString());
|
|
|
|
+ String pKeyId = tableInfo.getString("pkeyId");
|
|
|
|
+
|
|
|
|
+ tableInfo.fluentRemove("contractId")
|
|
|
|
+ .fluentRemove("pkeyId")
|
|
|
|
+ .fluentRemove("p_key_id")
|
|
|
|
+ .fluentRemove("projectId")
|
|
|
|
+ .fluentRemove("classify")
|
|
|
|
+ .fluentRemove("pickerKey")
|
|
|
|
+ .fluentRemove("id")
|
|
|
|
+ .fluentRemove("isFirst")
|
|
|
|
+ .fluentRemove("firstNodeId")
|
|
|
|
+ .fluentRemove("isTheLog")
|
|
|
|
+ .fluentRemove("theLogId")
|
|
|
|
+ .fluentRemove("linkTabIds")
|
|
|
|
+ .fluentRemove("recordTime")
|
|
|
|
+ .fluentRemove("businessId")
|
|
|
|
+ .fluentRemove("sourceUrl")
|
|
|
|
+ .fluentRemove("pdfUrl")
|
|
|
|
+ .fluentRemove("firstFileName")
|
|
|
|
+ .fluentRemove("");
|
|
|
|
+
|
|
|
|
+ // 获取excel 对象形象
|
|
|
|
+ WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
|
+ .eq(WbsTreeContract::getPKeyId, pKeyId));
|
|
|
|
+
|
|
|
|
+ ExcelTab excelTab = this.getById(wbsTreeContract.getExcelId());
|
|
|
|
+
|
|
|
|
+ //获取excel流 和 html流
|
|
|
|
+ InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());
|
|
|
|
+
|
|
|
|
+ System.out.println("---------2="+new Date().toLocaleString());
|
|
|
|
+ Workbook workbook=null;
|
|
|
|
+ int index = excelTab.getFileUrl().lastIndexOf(".");
|
|
|
|
+ String suffix = excelTab.getFileUrl().substring(index);
|
|
|
|
+
|
|
|
|
+ if (".xls".equals(suffix)) {
|
|
|
|
+ workbook = new HSSFWorkbook(exceInp);
|
|
|
|
+ } else if (".xlsx".equals(suffix)) {
|
|
|
|
+ workbook = new XSSFWorkbook(exceInp);
|
|
|
|
+ }
|
|
|
|
+ //获取工作表
|
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
+ sheet.setForceFormulaRecalculation(true);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String sqll = " insert into table_data_info (id, p_key_id, tab_key,key_val) values (?, ?, ?,?) ";
|
|
|
|
+ String delSql = "delete from table_data_info where p_key_id=" + pKeyId;
|
|
|
|
+ List<Object[]> list = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(wbsTreeContract.getHtmlUrl())) {
|
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(wbsTreeContract.getHtmlUrl());
|
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
|
+ Element table = doc.select("table").first();
|
|
|
|
+ if (ObjectUtil.isNotEmpty(tableInfo)) {
|
|
|
|
+ for(String key : tableInfo.keySet()){
|
|
|
|
+ if(key.contains("key")&&key.contains("__")){
|
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
|
+ list.add(new Object[]{id,pKeyId,key,tableInfo.getString(key)});
|
|
|
|
+
|
|
|
|
+ Elements datas = doc.getElementsByAttributeValue("keyname", key);
|
|
|
|
+ Element data = null;
|
|
|
|
+ if (datas.size() >= 1) {
|
|
|
|
+ data = datas.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (data != null) {
|
|
|
|
+ if (data.hasAttr("x1") && data.hasAttr("y1")) {
|
|
|
|
+ int x1 = 0;
|
|
|
|
+ int x2 = 0;
|
|
|
|
+ int y1 = 0;
|
|
|
|
+ int y2 = 0;
|
|
|
|
+
|
|
|
|
+ x1 = Integer.parseInt(data.attr("x1"));
|
|
|
|
+ y1 = Integer.parseInt(data.attr("y1"));
|
|
|
|
+
|
|
|
|
+ if (x1 == 0) {
|
|
|
|
+ x1 = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String myData = tableInfo.get(key) + "";
|
|
|
|
+ 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 = new Date();
|
|
|
|
+ Date end_dataStr = new Date();
|
|
|
|
+ try {
|
|
|
|
+ if(myData.indexOf("T") >= 0 && myData.indexOf("-") >= 0){
|
|
|
|
+ Start_dataStr = sdf.parse(dataVal[0]);
|
|
|
|
+ end_dataStr = sdf.parse(dataVal[1]);
|
|
|
|
+ }else{
|
|
|
|
+ Start_dataStr = formatStr.parse(dataVal[0]);
|
|
|
|
+ end_dataStr = formatStr.parse(dataVal[1]);
|
|
|
|
+ }
|
|
|
|
+ }catch (ParseException e){
|
|
|
|
+ throw new ServiceException("日期绑定错误");
|
|
|
|
+ }
|
|
|
|
+ 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("-");
|
|
|
|
+ if (dataStr.length == 3) {
|
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (myData.indexOf("lang.String") >= 0) {
|
|
|
|
+ Object obj = tableInfo.get(key);
|
|
|
|
+ if (obj instanceof String[]) {
|
|
|
|
+ String[] dataDate = (String[]) obj;
|
|
|
|
+ if ((dataDate[0].trim()).equals((dataDate[1].trim()))) {
|
|
|
|
+ myData = dataDate[0];
|
|
|
|
+ } else {
|
|
|
|
+ myData = dataDate[0] + "-" + dataDate[1].trim();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 (data.tagName().equals("hc-form-checkbox-group")) {
|
|
|
|
+ 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(" ", "");
|
|
|
|
+ //如果有□ 代表 自动生成 如果没有 代表后期添加 需要显示html 中的值
|
|
|
|
+ if (exceVal.indexOf("□") >= 0) {
|
|
|
|
+ if (myData.equals("1")) {
|
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
|
+ cell.setCellValue(exceVal.replace("□", "\u2611"));
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String dataJson = data.attr(":objs");
|
|
|
|
+ if (StringUtils.isNotEmpty(dataJson)) {
|
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(dataJson);
|
|
|
|
+ List<Integer> idList = Func.toIntList(myData);
|
|
|
|
+ int indexx = 0;
|
|
|
|
+ if (idList.get(0) >= 1) {
|
|
|
|
+ indexx = idList.get(0) - 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String dataInfo = jsonArray.getJSONObject(indexx).getString("name");
|
|
|
|
+ for (int inx = 1; inx < idList.size(); inx++) {
|
|
|
|
+ int valIndex = idList.get(inx) - 1;
|
|
|
|
+ dataInfo = dataInfo + "," + jsonArray.getJSONObject(valIndex).getString("name");
|
|
|
|
+ }
|
|
|
|
+ cell.setCellValue(dataInfo);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
|
+ if (row != null) {
|
|
|
|
+ Cell cell = row.getCell(x1 - 1);
|
|
|
|
+ if (cell != null || ObjectUtils.isNotEmpty(cell)) {
|
|
|
|
+ short fontIndex = cell.getCellStyle().getFontIndex();
|
|
|
|
+ Font fontAt = workbook.getFontAt(fontIndex);
|
|
|
|
+ fontAt.setFontName("EUDC");
|
|
|
|
+ cell.setCellValue(myData);
|
|
|
|
+ }
|
|
|
|
+ boolean wrap = Optional.ofNullable(cell).map(Cell::getCellStyle).map(CellStyle::getWrapText).orElse(true);
|
|
|
|
+ if (!wrap) {
|
|
|
|
+ cell.getCellStyle().setShrinkToFit(true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 组装电签设置
|
|
|
|
+ Elements dqids = table.getElementsByAttribute("dqid");
|
|
|
|
+ for (Element element : dqids){
|
|
|
|
+ String dqid = element.attr("dqid");
|
|
|
|
+ Elements x11 = element.getElementsByAttribute("x1");
|
|
|
|
+ if(x11!=null && x11.size()>=1){
|
|
|
|
+ Element element1 = x11.get(x11.size()-1);
|
|
|
|
+ int x1 = Func.toInt(element1.attr("x1"));
|
|
|
|
+ int y1 = Func.toInt(element1.attr("y1"));
|
|
|
|
+
|
|
|
|
+ Row row = sheet.getRow(y1 - 1);
|
|
|
|
+ if (row != null) {
|
|
|
|
+ Cell cell = row.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(Short.valueOf("1"));//设置字体大小
|
|
|
|
+ redFont.setFontName(oldfontAt.getFontName());//设置字体
|
|
|
|
+ String CellValue = cell.getStringCellValue().trim();
|
|
|
|
+
|
|
|
|
+ CellStyle newStyle = workbook.createCellStyle(); //创建单元格样式
|
|
|
|
+ newStyle.cloneStyleFrom(cell.getCellStyle());
|
|
|
|
+ newStyle.setFont(redFont);
|
|
|
|
+ newStyle.setShrinkToFit(true);
|
|
|
|
+ cell.setCellStyle(newStyle);
|
|
|
|
+ cell.setCellValue(dqid);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TransactionStatus transactionStatus = this.beginTransaction(transactionManager1);
|
|
|
|
+ try {
|
|
|
|
+ //删除
|
|
|
|
+ jdbcTemplate.execute(delSql);
|
|
|
|
+ //新增
|
|
|
|
+ jdbcTemplate.batchUpdate(sqll, list);
|
|
|
|
+ //提交事务
|
|
|
|
+ transactionManager1.commit(transactionStatus);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ //回滚
|
|
|
|
+ transactionManager1.rollback(transactionStatus);
|
|
|
|
+ throw new RuntimeException("字段过长,新增失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
|
+
|
|
|
|
+ String pdfPath = file_path + "/pdf//" + pKeyId + ".pdf";
|
|
|
|
+ String excelPath = file_path + "/pdf//" + pKeyId + ".xlsx";
|
|
|
|
+
|
|
|
|
+ File tabPdf = ResourceUtil.getFile(pdfPath);
|
|
|
|
+ if (tabPdf.exists()) {
|
|
|
|
+ tabPdf.delete();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //输出流
|
|
|
|
+ FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
|
+ workbook.write(outputStream);
|
|
|
|
+
|
|
|
|
+ com.spire.xls.Workbook workbook2 = new com.spire.xls.Workbook();
|
|
|
|
+ workbook2.loadFromFile(excelPath);
|
|
|
|
+
|
|
|
|
+ //设置转换后的PDF页面高宽适应工作表的内容大小
|
|
|
|
+ workbook2.getConverterSetting().setSheetFitToPage(true);
|
|
|
|
+ workbook2.saveToFile(pdfPath, FileFormat.PDF);
|
|
|
|
+
|
|
|
|
+ BladeFile bladeFile = newIOSSClient.uploadFile(pKeyId + ".pdf", pdfPath);
|
|
|
|
+
|
|
|
|
+ //附件
|
|
|
|
+
|
|
|
|
+ TableFile tableFile1 = tableFileService.getBaseMapper().selectList(Wrappers.<TableFile>query().lambda().eq(TableFile::getTabId, pKeyId + "").eq(TableFile::getType, 1)).stream().findAny().orElse(null);
|
|
|
|
+ if (tableFile1 != null) {
|
|
|
|
+ tableFileService.update(Wrappers.<TableFile>lambdaUpdate().set(TableFile::getDomainPdfUrl, bladeFile.getLink()).eq(TableFile::getId, tableFile1.getId()));
|
|
|
|
+ } else {
|
|
|
|
+ TableFile tableFile = new TableFile();
|
|
|
|
+ String fileExtension = FileUtil.getFileExtension(wbsTreeContract.getFullName() + ".pdf");
|
|
|
|
+ tableFile.setTabId(pKeyId + "");
|
|
|
|
+ tableFile.setName(wbsTreeContract.getFullName() + ".pdf");
|
|
|
|
+ tableFile.setType(1);
|
|
|
|
+ tableFile.setDomainUrl(bladeFile.getLink());
|
|
|
|
+ tableFile.setIsDeleted(0);
|
|
|
|
+ tableFile.setExtension(fileExtension);
|
|
|
|
+ tableFile.setDomainPdfUrl(bladeFile.getLink());
|
|
|
|
+ tableFileService.saveOrUpdate(tableFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ 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 = new ArrayList<>();
|
|
|
|
+ if (wbsTreeContract.getIsBussShow() == null || wbsTreeContract.getIsBussShow() == 1) {
|
|
|
|
+ dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && (tableFile.getType() == 1 || tableFile.getType() == 2)).map(TableFile::getDomainPdfUrl).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ dataListPdf = tableFileList.stream().filter(tableFile -> tableFile.getDomainPdfUrl() != null && 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();
|
|
|
|
+ }
|
|
|
|
+ String fileUrl = "";
|
|
|
|
+ if (dataListPdf.size() > 0) {
|
|
|
|
+ FileUtils.mergePdfPublicMethods(dataListPdf, pdfPath2);
|
|
|
|
+ BladeFile bladeFile2 = newIOSSClient.uploadFile(pKeyId + "2.pdf", pdfPath2);
|
|
|
|
+ fileUrl = bladeFile2.getLink();
|
|
|
|
+ }
|
|
|
|
+ UpdateWrapper<WbsTreeContract> updateWrapper = new UpdateWrapper<>();
|
|
|
|
+ updateWrapper.in("p_key_id", pKeyId + "");
|
|
|
|
+ updateWrapper.set("pdf_url", fileUrl);
|
|
|
|
+ wbsTreeContractService.update(updateWrapper);
|
|
|
|
+ tabPdf2.delete();
|
|
|
|
+ tabPdf.delete();
|
|
|
|
+ ResourceUtil.getFile(excelPath).delete();
|
|
|
|
+ //关闭流
|
|
|
|
+ IoUtil.closeQuietly(outputStream);
|
|
|
|
+ IoUtil.closeQuietly(exceInp);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|