|
@@ -1284,8 +1284,8 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
@Override
|
|
|
public R getBussPdfInfo(Long pkeyId) throws Exception {
|
|
|
- String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
- String sys_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+
|
|
|
WbsTreeContract wbsTreeContract = wbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
.eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
|
|
@@ -1298,6 +1298,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();
|
|
@@ -1364,23 +1365,23 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
|
|
|
//数据不为空
|
|
|
if (StringUtils.isNotEmpty(wbsTreeContract.getHtmlUrl())) {
|
|
|
- File htmlFile = ResourceUtil.getFile(wbsTreeContract.getHtmlUrl());
|
|
|
- if (htmlFile.exists()) {
|
|
|
- String htmlString = IoUtil.readToString(new FileInputStream(htmlFile));
|
|
|
- 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()) {
|
|
|
- if (val.indexOf("__") >= 0) {
|
|
|
- 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");
|
|
|
+ InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(wbsTreeContract.getHtmlUrl());
|
|
|
+ String htmlString = IoUtil.readToString(inputStreamByUrl);
|
|
|
+
|
|
|
+ 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()) {
|
|
|
+ if (val.indexOf("__") >= 0) {
|
|
|
+ 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) {
|
|
@@ -1422,13 +1423,13 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
} else {
|
|
|
String[] dataStr = myData.split("T")[0].split("-");
|
|
|
- myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ if (dataStr.length == 3) {
|
|
|
+ myData = StringUtil.format("{}年{}月{}日", dataStr[0], dataStr[1], Integer.parseInt(dataStr[2]));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (myData.indexOf("lang.String") >= 0) {
|
|
|
- /*String[] dataDate = (String[]) DataInfo.get(val);
|
|
|
- myData = dataDate[0]+" - "+dataDate[1].trim();*/
|
|
|
Object obj = DataInfo.get(val);
|
|
|
if (obj instanceof String[]) {
|
|
|
String[] dataDate = (String[]) obj;
|
|
@@ -1440,14 +1441,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
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是列号
|
|
@@ -1543,11 +1540,9 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
//输出流
|
|
|
|
|
|
-
|
|
|
FileOutputStream outputStream = new FileOutputStream(excelPath);
|
|
|
workbook.write(outputStream);
|
|
|
FileUtils.setExcelScaleToPdf(excelPath, pdfPath);
|