提交 481cf7cf 编写于 作者: zhouweidong's avatar zhouweidong

动态系统逻辑优化

上级 3433df0e
......@@ -3,6 +3,7 @@ TARGET=PSSYSTEM
</#ibiztemplate>
<#if sys.getCodeName()=='Sample'>
package ${pub.getPKGCodeName()}.util.service;
package ${pub.getPKGCodeName()}.util.service;
import lombok.extern.slf4j.Slf4j;
import ${pub.getPKGCodeName()}.util.client.IBZLiteFeignClient;
......@@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import java.io.*;
import java.util.List;
......@@ -37,7 +39,7 @@ public class DynamicModelService {
long start = System.currentTimeMillis();
List<Map<String, Object>> dynamicModels = liteClient.getDynamicModel(systemId);
if (!ObjectUtils.isEmpty(dynamicModels)) {
File dynamicFolder = new File(dynamicPath + File.separator + systemId);
File dynamicFolder = new File(getDynamicPath() + systemId);
if (dynamicFolder.exists()) {
deleteDir(dynamicFolder.getPath());
}
......@@ -57,19 +59,15 @@ public class DynamicModelService {
}
File file = new File(fullPath);
file.createNewFile();
// 文件输入流并进行缓冲
inputStream = new ByteArrayInputStream(String.valueOf(strFileContent).getBytes());
bufferedInputStream = new BufferedInputStream(inputStream);
// 文件输出流并进行缓冲
outputStream = new FileOutputStream(file);
bufferedOutputStream = new BufferedOutputStream(outputStream);
// 缓冲数组,大文件 可将 1024 * 2 改大一些,但是 并不是越大就越快
byte[] bytes = new byte[1024 * 2];
int len = 0;
while ((len = inputStream.read(bytes)) != -1) {
bufferedOutputStream.write(bytes, 0, len);
}
// 刷新输出缓冲流
bufferedOutputStream.flush();
log.debug(fullPath);
} catch (IOException e) {
......@@ -118,5 +116,19 @@ public class DynamicModelService {
}
}
}
/**
* 动态模型目录
* @return
*/
public String getDynamicPath() {
if(!StringUtils.isEmpty(dynamicPath)){
dynamicPath = dynamicPath.replace("\\\\",File.separator).replace("\\",File.separator).replace("/",File.separator);
if(!dynamicPath.endsWith(File.separator)){
dynamicPath = dynamicPath+ File.separator;
}
}
return dynamicPath;
}
}
</#if>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册