Commit 95612579 authored by ZWT's avatar ZWT

feat(能源管理系统): 修改架构

1.修改架构添加cse;
2.修改各微服务服务名,启动验证,完成cse注册;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent f58bfbf8
package pps.core.common.pdf;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.Map;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.pdf.BaseFont;
import org.apache.commons.codec.binary.Base64;
import org.xhtmlrenderer.pdf.ITextFontResolver;
import org.xhtmlrenderer.pdf.ITextRenderer;
import sun.misc.BASE64Decoder;
import java.io.*;
import java.util.Map;
public class Html2Pdf {
public static String htmlTopdf(String htmlContent ,String fontPath) throws Exception {
public static String htmlTopdf(String htmlContent, String fontPath) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = null;
InputStream sbs = null;
try{
try {
byteArrayOutputStream = new ByteArrayOutputStream();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver font = renderer.getFontResolver();
......@@ -28,12 +22,12 @@ public class Html2Pdf {
renderer.layout();
renderer.createPDF(byteArrayOutputStream);
renderer.finishPDF();
byte[] buffer =byteArrayOutputStream.toByteArray();
byte[] buffer = byteArrayOutputStream.toByteArray();
sbs = new ByteArrayInputStream(buffer);
return getBase64FromInputStream(sbs);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
......@@ -49,7 +43,8 @@ public class Html2Pdf {
}
return null;
}
public static byte[] htmlToPdfByte(String htmlContent ,String fontPath){
public static byte[] htmlToPdfByte(String htmlContent, String fontPath) {
ByteArrayOutputStream byteArrayOutputStream = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
......@@ -60,9 +55,9 @@ public class Html2Pdf {
renderer.layout();
renderer.createPDF(byteArrayOutputStream);
renderer.finishPDF();
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
......@@ -72,6 +67,7 @@ public class Html2Pdf {
}
return byteArrayOutputStream.toByteArray();
}
public static String getBase64FromInputStream(InputStream in) {
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
byte[] data = null;
......@@ -99,37 +95,35 @@ public class Html2Pdf {
}
public static void saveBase64strToFile(String base64str , String outPath){
public static void saveBase64strToFile(String base64str, String outPath) {
createFile(new File(outPath));
if (base64str == null){
return ;
if (base64str == null) {
return;
}
BASE64Decoder decoder = new BASE64Decoder();
try
{
try {
byte[] b = decoder.decodeBuffer(base64str);
for(int i=0;i<b.length;++i)
{
if(b[i]<0){
b[i]+=256;
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
OutputStream out = new FileOutputStream(outPath);
out.write(b);
out.flush();
out.close();
}
catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
}
public static String replaceContent(String htmlContent , Map<String,String> map){
public static String replaceContent(String htmlContent, Map<String, String> map) {
for (Map.Entry<String, String> entry : map.entrySet()) {
htmlContent = htmlContent.replaceAll(entry.getKey() , entry.getValue());
htmlContent = htmlContent.replaceAll(entry.getKey(), entry.getValue());
}
return htmlContent;
}
public static void createFile(File file) {
if (file.exists()) {
System.out.println("File exists");
......@@ -150,21 +144,21 @@ public class Html2Pdf {
}
}
public static void outFile(InputStream input , String outPath){
public static void outFile(InputStream input, String outPath) {
createFile(new File(outPath));
BufferedInputStream in=null;
BufferedOutputStream out=null;
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
in=new BufferedInputStream(input);
out=new BufferedOutputStream(new FileOutputStream(outPath));
int len=-1;
byte[] b=new byte[1024];
while((len=in.read(b))!=-1){
out.write(b,0,len);
in = new BufferedInputStream(input);
out = new BufferedOutputStream(new FileOutputStream(outPath));
int len = -1;
byte[] b = new byte[1024];
while ((len = in.read(b)) != -1) {
out.write(b, 0, len);
}
in.close();
out.close();
}catch (Exception e){
} catch (Exception e) {
}
}
......
......@@ -54,15 +54,15 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.70</version>
<version>2.0.32</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>gf</groupId>-->
<!-- <artifactId>fiybook-cloud</artifactId>-->
<!-- <version>1.0.0-pps</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>gf</groupId>-->
<!-- <artifactId>fiybook-cloud</artifactId>-->
<!-- <version>1.0.0-pps</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
</dependencies>
<build>
<plugins>
......@@ -112,5 +112,10 @@
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>maven_central</id>
<name>Maven Central</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
</repositories>
</project>
......@@ -33,8 +33,8 @@ public class DeployPpsPredictionApplication {
startup.enable(XRpcFeature.class);
startup.enable(XCloudHuaweiCseFeature.class)
.config(XCloudBundlesConf.with(
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-system").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-space").addModule("pps", "cloud", "space")
));
startup.run(args);
......
......@@ -33,8 +33,8 @@ public class DeployPpsSpaceApplication {
startup.enable(XRpcFeature.class);
startup.enable(XCloudHuaweiCseFeature.class)
.config(XCloudBundlesConf.with(
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-system").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-prediction").addModule("pps", "cloud", "prediction")
)
);
......
......@@ -24,7 +24,7 @@ public class DeployPpsSystemApplication {
public static void main(String... args) {
CounterBuilder.globalCounterBuilder.setFieldValue(CounterBuilder.DEPLOY_KEY, DeployPpsSystemApplication.class.getSimpleName());
XStartup startup = new XStartupApplication("pps");
startup.config(new XServerConf(22061).naming("pps-base-info"))
startup.config(new XServerConf(22061).naming("pps-system"))
.config(new XServiceConf("pps"));
startup.enable(XApiFeature.class)
.config(new XApiCookieConf("%4bH8s9&", 43200));
......
......@@ -43,8 +43,8 @@ public class DeployPpsTaskApplication {
startup.enable(XRpcFeature.class);
startup.enable(XCloudHuaweiCseFeature.class)
.config(XCloudBundlesConf.with(
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base-info").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-system").addModule("pps", "cloud", "system"),
XCloudBundle.naming("pps-base").addModule("pps", "cloud", "base"),
XCloudBundle.naming("pps-prediction").addModule("pps", "cloud", "prediction"),
XCloudBundle.naming("pps-space").addModule("pps", "cloud", "space")
));
......
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