|
@@ -1,6 +1,7 @@
|
|
package org.springblade.meter.controller;
|
|
package org.springblade.meter.controller;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.log.StaticLog;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.aspose.cells.SaveFormat;
|
|
import com.aspose.cells.SaveFormat;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -16,6 +17,7 @@ import com.itextpdf.text.pdf.PdfCopy;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import com.itextpdf.text.pdf.PdfReader;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import io.swagger.models.auth.In;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -54,6 +56,7 @@ import org.springblade.manager.entity.ContractRelationJlyz;
|
|
import org.springblade.manager.entity.TextdictInfo;
|
|
import org.springblade.manager.entity.TextdictInfo;
|
|
import org.springblade.manager.feign.FormulaClient;
|
|
import org.springblade.manager.feign.FormulaClient;
|
|
import org.springblade.manager.vo.MeterInfo;
|
|
import org.springblade.manager.vo.MeterInfo;
|
|
|
|
+import org.springblade.manager.vo.ReportMergeCellsConfig;
|
|
import org.springblade.manager.vo.ReportResult;
|
|
import org.springblade.manager.vo.ReportResult;
|
|
import org.springblade.meter.dto.*;
|
|
import org.springblade.meter.dto.*;
|
|
import org.springblade.meter.entity.*;
|
|
import org.springblade.meter.entity.*;
|
|
@@ -2763,6 +2766,8 @@ public class TaskController extends BladeController {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ /*写死合并*/
|
|
|
|
+ List<ReportMergeCellsConfig> configList = ReportMergeCellsConfig.bulider();
|
|
/*每种表生成一份pdf*/
|
|
/*每种表生成一份pdf*/
|
|
StringBuffer sb = new StringBuffer();
|
|
StringBuffer sb = new StringBuffer();
|
|
reportResults.parallelStream().forEach(rs -> {
|
|
reportResults.parallelStream().forEach(rs -> {
|
|
@@ -2789,26 +2794,22 @@ public class TaskController extends BladeController {
|
|
int x1 = Func.toInt(keys.split("_")[1]);
|
|
int x1 = Func.toInt(keys.split("_")[1]);
|
|
Row row = sheet.getRow(y1 - 1);
|
|
Row row = sheet.getRow(y1 - 1);
|
|
if (row != null) {
|
|
if (row != null) {
|
|
- Cell cell = row.getCell(x1 - 1);
|
|
|
|
- if (cell != null) {
|
|
|
|
- String value = dataMap.getOrDefault(keys, StringPool.EMPTY).toString();
|
|
|
|
- if (value.startsWith("http")&&RegexUtil.find("(?i)[.](jpeg|png|jpg)",value)) {
|
|
|
|
- InputStream imageIn = CommonUtil.getOSSInputStream(value);
|
|
|
|
- if (imageIn != null) {
|
|
|
|
- byte[] bytes = CommonUtil.compressImage(IOUtils.toByteArray(imageIn));
|
|
|
|
- CreationHelper helper = workbook.getCreationHelper();
|
|
|
|
- ClientAnchor anchor = helper.createClientAnchor();
|
|
|
|
- Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
|
- anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
|
|
|
- Picture pict = drawing.createPicture(anchor, workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG)); // 调整图片占单元格百分比的大小,1.0就是100%
|
|
|
|
- pict.resize(1, 1);
|
|
|
|
- CollectionUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- cell.setCellValue(value);
|
|
|
|
|
|
+ Cell cell = row.getCell(x1 - 1, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
|
|
+ String value = dataMap.getOrDefault(keys, StringPool.EMPTY).toString();
|
|
|
|
+ if (value.startsWith("http")&&RegexUtil.find("(?i)[.](jpeg|png|jpg)",value)) {
|
|
|
|
+ InputStream imageIn = CommonUtil.getOSSInputStream(value);
|
|
|
|
+ if (imageIn != null) {
|
|
|
|
+ byte[] bytes = CommonUtil.compressImage(IOUtils.toByteArray(imageIn));
|
|
|
|
+ CreationHelper helper = workbook.getCreationHelper();
|
|
|
|
+ ClientAnchor anchor = helper.createClientAnchor();
|
|
|
|
+ Drawing<?> drawing = sheet.createDrawingPatriarch();
|
|
|
|
+ anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
|
|
|
|
+ Picture pict = drawing.createPicture(anchor, workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG)); // 调整图片占单元格百分比的大小,1.0就是100%
|
|
|
|
+ pict.resize(1, 1);
|
|
|
|
+ CollectionUtils.imageOrientation(sheet, anchor, new DataVO(x1 - 1, y1 - 1));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- System.out.println(keys + "不存在");
|
|
|
|
|
|
+ cell.setCellValue(value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2824,7 +2825,7 @@ public class TaskController extends BladeController {
|
|
sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
|
|
sheet.getPrintSetup().setPaperSize(PrintSetup.A4_PAPERSIZE);
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
workbook.write(out);
|
|
workbook.write(out);
|
|
- //workbook.write(new FileOutputStream(rs.getExcelPath()));
|
|
|
|
|
|
+ workbook.write(new FileOutputStream(rs.getExcelPath()));
|
|
com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(new ByteArrayInputStream(out.toByteArray()));
|
|
com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook(new ByteArrayInputStream(out.toByteArray()));
|
|
out.reset();
|
|
out.reset();
|
|
wb.save(out, SaveFormat.PDF);
|
|
wb.save(out, SaveFormat.PDF);
|
|
@@ -2871,6 +2872,22 @@ public class TaskController extends BladeController {
|
|
return R.data(fileUrl);
|
|
return R.data(fileUrl);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*固定合并*/
|
|
|
|
+ private void mergeCells(Sheet sheet, List<ReportMergeCellsConfig> configList){
|
|
|
|
+ if(configList.size()>0){
|
|
|
|
+ configList.forEach(c->{
|
|
|
|
+ List<Integer> list = BaseUtils.coords2Int(c.getMergeRange());
|
|
|
|
+ if(list.size()>0) {
|
|
|
|
+ try {
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(list.get(1), list.get(3),list.get(0),list.get(2)));
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ StaticLog.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
// 添加电签任务列表
|
|
// 添加电签任务列表
|