Commit 32809d38 authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.修改第三方日累计数据推送表表结构,增加日累计储能放电量字段,同时修改代码对应实体及mapper文件,修改相关接口增加储能日累计放电量接收逻辑;
2.修改首页井场收益分析模块接口,修改获取储能累计放电量逻辑;
3.设计并创建井口日用电趋势表,生成对应实体类及mapper文件;
4.统计分析模块,新增本月累计节电经济效益查询接口,添加线上接口文档并完成接口冒烟测试;
5.统计分析模块,新增本月累计减碳量查询接口,添加线上接口文档并完成接口冒烟测试;
6.统计分析模块,新增光伏发电趋势查询接口,添加线上接口文档并完成接口冒烟测试;
7.统计分析模块,新增月度总览查询接口,添加线上接口文档并完成接口冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 5533ed77
......@@ -5,6 +5,10 @@ package pps.core.common.constant;
* @date 2023/2/17 0017 13:04
*/
public class LoginConstant {
public static final Long LOGIN_FLAG_SIMULATE = 1000000L; //模拟登陆
/**
* 模拟登陆
*/
public static final Long LOGIN_FLAG_SIMULATE = 1000000L;
}
package pps.core.common.pdf;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.tool.xml.XMLWorkerFontProvider;
//这里重写字体
public class FontProviderUtil extends XMLWorkerFontProvider {
@Override
public Font getFont(final String fontname, final String encoding,
final boolean embedded, final float size, final int style,
final BaseColor color) {
BaseFont bf = null;
try {
bf = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
} catch (Exception e) {
e.printStackTrace();
}
Font font = new Font(bf, size, style, color);
font.setColor(color);
return font;
}
}
\ No newline at end of file
package pps.core.common.pdf;
import gui.ava.html.parser.HtmlParser;
import gui.ava.html.parser.HtmlParserImpl;
import gui.ava.html.renderer.ImageRenderer;
import gui.ava.html.renderer.ImageRendererImpl;
public class HtmlToPng {
public static void main(String[] args) {
HtmlParser htmlParser = new HtmlParserImpl();
//加载html模版
htmlParser.loadHtml("<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
" <head>\n" +
" <meta charset=\"utf-8\" />\n" +
" <title>PPS</title>\n" +
"\t\t<style>\n" +
"\t\t\ttable{\n" +
"\t\t\t\twidth: 100%;\n" +
"\t\t\t\tborder-collapse: collapse;\n" +
"\t\t\t\tborder-spacing: 0;\n" +
"\t\t\t}\n" +
"\t\t\ttable, th, td{\n" +
"\t\t\t\tborder: 1px solid #000000;\n" +
"\t\t\t\ttext-align: center;\n" +
"\t\t\t}\n" +
"\t\t\tth{\n" +
"\t\t\t\twidth: auto;\n" +
"\t\t\t\tline-height: 3;\n" +
"\t\t\t\tfont-weight: bold;\n" +
"\t\t\t\tcolor: red;\n" +
"\t\t\t}\n" +
"\t\t\ttd{\n" +
"\t\t\t\twidth: auto;\n" +
"\t\t\t\tline-height: 2;\n" +
"\t\t\t}\n" +
"\t\t</style>\n" +
" </head>\n" +
" <body>\n" +
"\t<div style=\"padding: 16px;box-sizing: border-box;background-color: #ffffff\">\n" +
"\t\t<div style=\"text-align: center\">@mOuName</div>\n" +
"\t\t<div style=\"text-align: center\">天然气计量交接凭证(中卫首站)</div>\n" +
"\t\t<div style=\"border-bottom: 1px solid #999;margin: 10px 0;\"></div>\n" +
"\t\t<div style=\"margin-bottom: 10px\">\n" +
"\t\t\t<div style=\"display:inline-block;width: 50%;\">填写日期:2022-07-07</div>\n" +
"\t\t\t<div style=\"display:inline-block;width: 50%;\">凭证编号:@voucherCode</div>\n" +
"\t\t</div>\n" +
"\t\t<table border=\"1\">\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>承运单位:</td>\n" +
"\t\t\t\t<td colspan=\"6\">@mOuName</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>托运单位:</td>\n" +
"\t\t\t\t<td colspan=\"6\"></td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>接收单位:</td>\n" +
"\t\t\t\t<td colspan=\"6\">@cOuName</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>计量时间:</td>\n" +
"\t\t\t\t<td colspan=\"6\">2022年7月5日 08:00 至 2022年7月6日 08:00</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<th>计量交接地点</th>\n" +
"\t\t\t\t<th>流量计位号</th>\n" +
"\t\t\t\t<th>前日日累(体积量)Nm3</th>\n" +
"\t\t\t\t<th>前日日累(能量)MJ</th>\n" +
"\t\t\t\t<th>平均高位发热量MJ/m3</th>\n" +
"\t\t\t\t<th>计量气量Nm3</th>\n" +
"\t\t\t\t<th>计量能量MJ</th>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>@detailStationName0</td>\n" +
"\t\t\t\t<td>@detailEquipmentName0</td>\n" +
"\t\t\t\t<td>@detailGasVolumeYesterday0</td>\n" +
"\t\t\t\t<td>156140210</td>\n" +
"\t\t\t\t<td>6436881280</td>\n" +
"\t\t\t\t<td>11009989685</td>\n" +
"\t\t\t\t<td>13242421311</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>@detailStationName1</td>\n" +
"\t\t\t\t<td>@detailEquipmentName1</td>\n" +
"\t\t\t\t<td>@detailGasVolumeYesterday1</td>\n" +
"\t\t\t\t<td>156140210</td>\n" +
"\t\t\t\t<td>6436881280</td>\n" +
"\t\t\t\t<td>11009989685</td>\n" +
"\t\t\t\t<td>13242421311</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>@detailStationName2</td>\n" +
"\t\t\t\t<td>@detailEquipmentName2</td>\n" +
"\t\t\t\t<td>@detailGasVolumeYesterday2</td>\n" +
"\t\t\t\t<td>156140210</td>\n" +
"\t\t\t\t<td>6436881280</td>\n" +
"\t\t\t\t<td>11009989685</td>\n" +
"\t\t\t\t<td>13242421311</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>@detailStationName3</td>\n" +
"\t\t\t\t<td>@detailEquipmentName3</td>\n" +
"\t\t\t\t<td>@detailGasVolumeYesterday3</td>\n" +
"\t\t\t\t<td>156140210</td>\n" +
"\t\t\t\t<td>6436881280</td>\n" +
"\t\t\t\t<td>11009989685</td>\n" +
"\t\t\t\t<td>13242421311</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td colspan=\"2\">合计交接气量(小写)Nm3</td>\n" +
"\t\t\t\t<td colspan=\"2\">94010</td>\n" +
"\t\t\t\t<td>合计交接能量(小写)MJ</td>\n" +
"\t\t\t\t<td colspan=\"2\">94010</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td colspan=\"2\">合计交接气量(大写)Nm3</td>\n" +
"\t\t\t\t<td colspan=\"2\">玖万肆仟零壹拾标方</td>\n" +
"\t\t\t\t<td>合计交接能量(大写)MJ</td>\n" +
"\t\t\t\t<td colspan=\"2\">玖万肆仟零壹拾标方</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>备注:</td>\n" +
"\t\t\t\t<td colspan=\"6\">@remarks</td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td colspan=\"2\">供气单位(盖章)</td>\n" +
"\t\t\t\t<td colspan=\"2\" style=\"opacity: 0;\">供气</td>\n" +
"\t\t\t\t<td>接气单位(盖章)</td>\n" +
"\t\t\t\t<td colspan=\"2\"></td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td colspan=\"2\">供气方计量员(签字)</td>\n" +
"\t\t\t\t<td colspan=\"2\"></td>\n" +
"\t\t\t\t<td>接气方计量员(签字)</td>\n" +
"\t\t\t\t<td colspan=\"2\"></td>\n" +
"\t\t\t</tr>\n" +
"\t\t\t<tr>\n" +
"\t\t\t\t<td>争议量(+/-):</td>\n" +
"\t\t\t\t<td colspan=\"6\"></td>\n" +
"\t\t\t</tr>\n" +
"\t\t</table>\n" +
"\t</div>\n" +
" </body>\n" +
"</html>\n");
//把html写入到图片
ImageRenderer imageRenderer = new ImageRendererImpl(htmlParser);
imageRenderer.saveImage("D:\\pdf\\hello-world.png");
}
}
package pps.core.common.pdf;
import gui.ava.html.exception.RenderException;
import gui.ava.html.parser.DocumentHolder;
import gui.ava.html.renderer.FormatNameUtil;
import gui.ava.html.renderer.ImageRendererImpl;
import org.xhtmlrenderer.util.FSImageWriter;
import java.awt.image.BufferedImage;
import java.io.*;
public class ImageRendererSubImpl extends ImageRendererImpl {
public ImageRendererSubImpl(DocumentHolder documentHolder) {
super(documentHolder);
}
private String getImageFormat(String filename) {
if (this.getImageFormat() != null) {
return this.getImageFormat();
} else {
return filename != null ? FormatNameUtil.formatForFilename(filename) : FormatNameUtil.getDefaultFormat();
}
}
private FSImageWriter getImageWriter(String imageFormat) {
FSImageWriter imageWriter = new FSImageWriter(imageFormat);
imageWriter.setWriteCompressionMode(this.getWriteCompressionMode());
imageWriter.setWriteCompressionQuality(this.getWriteCompressionQuality());
imageWriter.setWriteCompressionType(this.getWriteCompressionType());
return imageWriter;
}
public void saveImage(File file) {
try {
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file));
this.save(outputStream, file.getName(), true);
} catch (IOException var3) {
throw new RenderException("IOException while rendering image to " + file.getAbsolutePath(), var3);
}
}
public void saveImage(String filename) {
this.saveImage(new File(filename));
}
private void save(OutputStream outputStream, String filename, boolean closeStream) {
try {
String imageFormat = this.getImageFormat(filename);
FSImageWriter imageWriter = this.getImageWriter(imageFormat);
BufferedImage bufferedImage = this.getBufferedImage(getImageType(imageFormat));
imageWriter.write(bufferedImage, outputStream);
} catch (IOException var15) {
throw new RenderException("IOException while rendering image", var15);
} finally {
if (closeStream) {
try {
outputStream.close();
} catch (IOException var14) {
;
}
}
}
}
/**
* 获取图像类型
* 根据图像的格式
*/
public int getImageType(String imageFormat) {
if ("jpg".equalsIgnoreCase(imageFormat)) {
return BufferedImage.TYPE_3BYTE_BGR;
}
if ("bmp".equalsIgnoreCase(imageFormat)) {
return BufferedImage.TYPE_INT_RGB;
}
return BufferedImage.BITMASK;
}
}
package pps.core.common.pdf;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
/**
* 使用时,需要修改 ImageTransformPDF()函数中的输入图片和输出pdf
*/
public class ImageTransformPDF {
public static void main(String[] args) {
ImageTransformPDF();
}
public static String ImageTransformPDF() {
new ImageTransformPDF().imgOfPdf("D:\\pdf\\png2.pdf", "D:\\pdf\\hello-world.png");
return "200!ok";
}
//为终极函数做铺垫
public static File Pdf(ArrayList<String> imageUrllist, String mOutputPdfFileName) {
Document doc = new Document(PageSize.A4, 0, 0, 0, 0); //new一个pdf文档
try {
PdfWriter.getInstance(doc, new FileOutputStream(mOutputPdfFileName)); //pdf写入
doc.open();//打开文档
for (int i = 0; i < imageUrllist.size(); i++) { //循环图片List,将图片加入到pdf中
doc.newPage(); //在pdf创建一页
Image png1 = Image.getInstance(imageUrllist.get(i)); //通过文件路径获取image
float heigth = png1.getHeight();
float width = png1.getWidth();
int percent = getPercent2(heigth, width);
png1.setAlignment(Image.MIDDLE);
png1.scalePercent(percent + 3);// 表示是原来图像的比例;
doc.add(png1);
}
doc.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
File mOutputPdfFile = new File(mOutputPdfFileName); //输出流
if (!mOutputPdfFile.exists()) {
mOutputPdfFile.deleteOnExit();
return null;
}
return mOutputPdfFile; //反回文件输出流
}
public static int getPercent(float h, float w) {
int p = 0;
float p2 = 0.0f;
if (h > w) {
p2 = 297 / h * 100;
} else {
p2 = 210 / w * 100;
}
p = Math.round(p2);
return p;
}
public static int getPercent2(float h, float w) {
int p = 0;
float p2 = 0.0f;
p2 = 530 / w * 100;
p = Math.round(p2);
return p;
}
/**
* @Description: 通过图片路径及生成pdf路径,将图片转成pdf
* @Author: zd
* @Date: 2019/9/29
*/
public void imgOfPdf(String filepath, String imgUrl) {
try {
ArrayList<String> imageUrllist = new ArrayList<String>(); //图片list集合
String[] imgUrls = imgUrl.split(",");
for (int i = 0; i < imgUrls.length; i++) {
imageUrllist.add(imgUrls[i]);
}
String pdfUrl = filepath; //输出pdf文件路径
File file = this.Pdf(imageUrllist, pdfUrl);//生成pdf
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
package pps.core.common.pdf;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Image;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
public class ItextPDFRepalceUtil {
//输入的模版路径
public static String inputFilePath = "D:\\pdf\\合同2.pdf";
//插入的文件路径
public static String imgFilePath = "D:\\pdf\\签名.png";
//输出路径
public static String out = "D:\\pdf\\out6.pdf";
public static String keyword = "${甲方盖章}";//测试标记
public static String keyword2 = "${乙方盖章}";//测试标记
public static void main(String[] args) throws IOException, DocumentException {
//replaceImg();
//replaceText();
addImg("D:\\pdf\\1111.pdf", "D:\\pdf\\2222.pdf", "D:\\pdf\\4444.png");
}
//插入图片的例子
public static void replaceImg() throws IOException, DocumentException {
//查找位置
float[] position = ItextPDFUtil.getAddImagePositionXY(inputFilePath, keyword);
if (position.length == 0)
return;
//Read file using PdfReader
PdfReader pdfReader = new PdfReader(inputFilePath);
//Modify file using PdfReader
PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream(out));
Image image = Image.getInstance(imgFilePath);
//Fixed Positioning
// image.scaleToFit(100, 50);
image.scaleAbsolute(100, 20);
//Scale to new height and new width of image
image.setAbsolutePosition(position[1] - 50, position[2] + 25);
PdfContentByte content = pdfStamper.getUnderContent((int) position[0]);
content.addImage(image);
pdfStamper.close();
}
//修改文字的示例
public static void replaceText() {
//1.给定文件
File pdfFile = new File(inputFilePath);
//2.定义一个byte数组,长度为文件的长度
byte[] pdfData = new byte[(int) pdfFile.length()];
//3.IO流读取文件内容到byte数组
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(pdfFile);
inputStream.read(pdfData);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
//4.指定关键字
String replace = " 王文博 先生";
//5.调用方法,给定关键字和文件
List<float[]> positions = null;
try {
positions = ItextPDFUtil.findKeywordPostions(pdfData, keyword2);
} catch (IOException e) {
e.printStackTrace();
}
PdfReader pdfReader = null;
PdfStamper stamper = null;
try {
pdfReader = new PdfReader(pdfData);
stamper = new PdfStamper(pdfReader, new FileOutputStream(out));
if (positions != null) {
for (int i = 0; i < positions.size(); i++) {
float[] position = positions.get(i);
PdfContentByte canvas = stamper.getOverContent((int) position[0]);
//修改背景色
canvas.saveState();
canvas.setColorFill(BaseColor.WHITE);
canvas.rectangle(position[1], position[2], position[3] + 10, position[4] - 1);
canvas.fill();
canvas.restoreState();
//替换关键字
canvas.beginText();
BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
canvas.setFontAndSize(bf, 13);
canvas.setTextMatrix(position[1] + 3, position[2]);/*修正背景与文本的相对位置*/
canvas.showText(replace);
canvas.endText();
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} finally {
if (stamper != null)
try {
stamper.close();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (pdfReader != null) {
pdfReader.close();
}
}
}
public static void addImg(String inPdfFile, String outPdfFile, String imgPath) {
try {
PdfReader reader = new PdfReader(inPdfFile, "PDF".getBytes());
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outPdfFile));
int pages = reader.getNumberOfPages();
// 设置透明度
PdfGState gs = new PdfGState();
gs.setStrokeOpacity(0.9f);
gs.setFillOpacity(0.9f);
for (int i = 1; i <= pages; i++) {
Rectangle cropBox = reader.getCropBox(i);
Image img = Image.getInstance(imgPath);// 插入业务章
//设置缩放比例
img.scaleAbsolute(115, 115);
//设置业务章的位置
img.setAbsolutePosition((float) (cropBox.getWidth() * 0.7), (float) (cropBox.getHeight() * 0.65));
PdfContentByte over = stamp.getOverContent(i);
over.setGState(gs);
over.addImage(img);
}
stamp.close();// 关闭
File tempfile = new File(inPdfFile);
if (tempfile.exists()) {
tempfile.delete();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package pps.core.common.pdf;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontProvider;
import com.itextpdf.text.pdf.BaseFont;
public class MyFontProvider implements FontProvider {
private BaseColor bc;
private String fontname;
private String encoding;
private boolean embedded;
private boolean cached;
private float size;
private int style;
private BaseFont baseFont;
public MyFontProvider() {
}
public MyFontProvider(BaseColor bc, String fontname, String encoding, boolean embedded, boolean cached, float size,
int style, BaseFont baseFont) {
super();
this.bc = bc;
this.fontname = fontname;
this.encoding = encoding;
this.embedded = embedded;
this.cached = cached;
this.size = size;
this.style = style;
this.baseFont = baseFont;
}
public BaseColor getBc() {
return bc;
}
public void setBc(BaseColor bc) {
this.bc = bc;
}
public String getFontname() {
return fontname;
}
public void setFontname(String fontname) {
this.fontname = fontname;
}
public String getEncoding() {
return encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public boolean isEmbedded() {
return embedded;
}
public void setEmbedded(boolean embedded) {
this.embedded = embedded;
}
public boolean isCached() {
return cached;
}
public void setCached(boolean cached) {
this.cached = cached;
}
public float getSize() {
return size;
}
public void setSize(float size) {
this.size = size;
}
public int getStyle() {
return style;
}
public void setStyle(int style) {
this.style = style;
}
public BaseFont getBaseFont() {
return baseFont;
}
public void setBaseFont(BaseFont baseFont) {
this.baseFont = baseFont;
}
public Font getFont(String arg0, String arg1, boolean arg2, float arg3, int arg4, BaseColor arg5) {
Font font = null;
if (baseFont == null) {
font = new Font();
} else {
font = new Font(baseFont);
}
font.setColor(arg5);
font.setFamily(fontname);
font.setSize(size);
font.setStyle(arg4);
return font;
}
public boolean isRegistered(String arg0) {
// TODO Auto-generated method stub
return true;
}
}
package pps.core.common.pdf;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PatternUtils {
public static final String fangkuohao = "(\\[[^\\]]*\\])";
public static final String specialList = "([\\s\\S]*)";
private static final String xiaokuohao = "(?<=\\()(.+?)(?=\\))";
public static void main(String[] args) {
}
public static List<String> patternData(String data, String p) {
List<String> list = new ArrayList<>();
Pattern pattern = Pattern.compile(p);
Matcher matcher = pattern.matcher(data);
while ((matcher.find()))
list.add(matcher.group());
return list;
}
}
package pps.core.common.pdf;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import java.io.*;
public class UpdatePdfUtil {
/**
* @param bytes 数组
* @param contentText 添加的文字
* @return
* @throws Exception
*/
public static InputStream addText(byte[] bytes, String contentText)
throws Exception {
ByteArrayOutputStream byteArrayOutputStream = null;
PdfReader pdfReader = null;
PdfStamper stamper = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
pdfReader = new PdfReader(bytes);
Rectangle rectangle = pdfReader.getPageSize(1);
stamper = new PdfStamper(pdfReader, byteArrayOutputStream);
PdfContentByte canvas = stamper.getUnderContent(1);
//替换关键字
canvas.beginText();
BaseFont bf = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
canvas.setFontAndSize(bf, 13);
canvas.showTextAligned(Element.ALIGN_CENTER, contentText, rectangle.getWidth() - 50, rectangle.getHeight() - 20, 0);/*修正背景与文本的相对位置*/
canvas.endText();
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
} finally {
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
} catch (IOException e) {
}
}
if (stamper != null)
try {
stamper.close();
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (pdfReader != null) {
pdfReader.close();
}
}
return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
}
public static void main(String[] args) throws Exception {
File pdfFile = new File("D:\\pdf\\test1664334027252.pdf");
//2.定义一个byte数组,长度为文件的长度
byte[] pdfData = new byte[(int) pdfFile.length()];
//3.IO流读取文件内容到byte数组
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(pdfFile);
inputStream.read(pdfData);
addText(pdfData, "dasfad");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
}
}
}
}
}
......@@ -119,45 +119,6 @@
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-all.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -44,34 +44,6 @@
<env>test</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>sit</id>
<properties>
<env>sit</env>
</properties>
</profile>
<!--xcd测试环境 -->
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
<!--vpn连接开发环境 -->
<profile>
<id>vpn</id>
<properties>
<env>vpn</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>stg</id>
<properties>
<env>stg</env>
</properties>
</profile>
</profiles>
<build>
<filters>
......@@ -79,44 +51,6 @@
</filters>
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-gateway.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -79,81 +79,14 @@
<env>test</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>sit</id>
<properties>
<env>sit</env>
</properties>
</profile>
<!--xcd测试环境 -->
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
<!--vpn连接开发环境 -->
<profile>
<id>vpn</id>
<properties>
<env>vpn</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>stg</id>
<properties>
<env>stg</env>
</properties>
</profile>
</profiles>
<build>
<filters>
<filter>../filters/filter-${env}.properties</filter>
</filters>
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-task.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -40,11 +40,6 @@
<artifactId>huawei-gauss-db</artifactId>
<version>1.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>pps</groupId>-->
<!-- <artifactId>pps-core-framedata</artifactId>-->
<!-- <version>${pps.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>xstartup</groupId>
<artifactId>xstartup-toolkit-kafka</artifactId>
......@@ -80,81 +75,14 @@
<env>test</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>sit</id>
<properties>
<env>sit</env>
</properties>
</profile>
<!--xcd测试环境 -->
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
<!--vpn连接开发环境 -->
<profile>
<id>vpn</id>
<properties>
<env>vpn</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>stg</id>
<properties>
<env>stg</env>
</properties>
</profile>
</profiles>
<build>
<filters>
<filter>../filters/filter-${env}.properties</filter>
</filters>
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-task.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -98,34 +98,6 @@
<env>test</env>
</properties>
</profile>
<!--sit -->
<profile>
<id>sit</id>
<properties>
<env>sit</env>
</properties>
</profile>
<!--vpn连接开发环境 -->
<profile>
<id>vpn</id>
<properties>
<env>vpn</env>
</properties>
</profile>
<!--uat -->
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>stg</id>
<properties>
<env>stg</env>
</properties>
</profile>
</profiles>
<build>
......@@ -135,44 +107,6 @@
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-system.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
......@@ -80,81 +80,14 @@
<env>test</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>sit</id>
<properties>
<env>sit</env>
</properties>
</profile>
<!--xcd测试环境 -->
<profile>
<id>uat</id>
<properties>
<env>uat</env>
</properties>
</profile>
<!--vpn连接开发环境 -->
<profile>
<id>vpn</id>
<properties>
<env>vpn</env>
</properties>
</profile>
<!--xcd开发环境 -->
<profile>
<id>stg</id>
<properties>
<env>stg</env>
</properties>
</profile>
</profiles>
<build>
<filters>
<filter>../filters/filter-${env}.properties</filter>
</filters>
<finalName>${project.artifactId}</finalName>
<plugins>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<configuration>
<target>
<copy todir="../lib" overwrite="true">
<fileset dir="${project.build.directory}/current/lib/"
erroronmissingdir="false">
<include name="*.jar" />
</fileset>
</copy>
&lt;!&ndash;<move file="${project.build.directory}/current/lib/deploy-pps-analysis.jar"
tofile="../lib/deploy-pps-analysis.jar" />&ndash;&gt;
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<configuration>
<target>
<delete file="../lib/deploy-pps-task.jar" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment