提交 24237821 编写于 作者: tangyaolong's avatar tangyaolong

【dst模型初始化导入导出】修改细节

上级 2fc4f0e7
......@@ -313,8 +313,8 @@ public class MetaModelExService extends MetaModelServiceImpl {
*/
protected String getFileName(String fileName) {
try {
//防止中文乱码
return new String(fileName.getBytes("utf-8"), "iso8859-1");
// 防止中文乱码
return new String(fileName.getBytes(StandardCharsets.UTF_8), "iso8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
......
package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.extensions.domain.AssembleModel;
import cn.ibizlab.core.extensions.service.MetaModelExService;
import cn.ibizlab.core.lite.domain.DstApp;
import cn.ibizlab.core.lite.domain.DstSystem;
import cn.ibizlab.core.lite.domain.MetaEntity;
......@@ -14,10 +13,8 @@ import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.errors.InternalServerErrorException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -32,7 +29,10 @@ import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct;
import java.io.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.*;
......@@ -63,11 +63,6 @@ public class LiteModelService {
@Lazy
private IMetaRelationshipService metaRelationshipService;
@Autowired
@Lazy
private IDstDataSourceService dstDataSourceService;
@Autowired
@Lazy
private IMetaDataSetService metaDataSetService;
......@@ -99,10 +94,11 @@ public class LiteModelService {
EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity);
entityModel.setDataSets(metaDataSetService.selectByEntityId(entity != null ? entity.getEntityId() : null));
Map<String, RelationshipModel> parentSet = new LinkedHashMap();
List<RelationshipModel> references = new ArrayList<>();
if (entity != null) {
entityModel.setDataSets(metaDataSetService.selectByEntityId(entity.getEntityId()));
metaRelationshipService.selectByEntityId(entity.getEntityId()).forEach(item->
{
RelationshipModel model = new RelationshipModel();
......@@ -121,6 +117,7 @@ public class LiteModelService {
references.add(model);
}
});
}
entityModel.setReferences(references);
List<RelationshipModel> nesteds = new ArrayList<>();
......@@ -176,9 +173,7 @@ public class LiteModelService {
public void initMetaEntity()
{
metaEntityService.list().forEach(metaEntity -> {
LiteStorage.putMetaEntity(metaEntity);
});
metaEntityService.list().forEach(LiteStorage::putMetaEntity);
}
@Autowired
......@@ -208,9 +203,6 @@ public class LiteModelService {
@Value("${ibiz.filePath:/app/file/}")
private String fileRoot;
@Autowired
private MetaModelExService metaModelExService;
@Cacheable( value="syspssystem",key = "'row:all-dst-apps'")
public LinkedHashMap<String, DstApp> getApps() {
LinkedHashMap<String,DstApp> appNode=new LinkedHashMap<>();
......@@ -224,9 +216,7 @@ public class LiteModelService {
system.setApps(system.getSysstructure().getSysApps(true));
dstSystemService.update(system);
}
system.getApps().forEach(app-> {
appNode.put(app.getId(),app);
});
system.getApps().forEach(app-> appNode.put(app.getId(),app));
});
return appNode;
}
......@@ -263,7 +253,7 @@ public class LiteModelService {
}
public FileItem uploadFile(MultipartFile multipartFile) {
FileItem item = null;
FileItem item;
// 获取文件名
String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀
......@@ -324,7 +314,7 @@ public class LiteModelService {
public String exportFile(List<MetaModel> model){
List<AssembleModel> temp = new ArrayList<>();
for (MetaModel metaModel : model) {
for (MetaModel ignored : model) {
temp.add(null);
}
String json = JSON.toJSONString(temp);
......@@ -332,33 +322,4 @@ public class LiteModelService {
return fileName;
}
public List<AssembleModel> translateFile(MultipartFile file){
BufferedReader reader = null;
String ans = "";
try{
Reader read = new InputStreamReader(file.getInputStream(), "utf-8");
reader = new BufferedReader(read);
String tmpString = null;
while((tmpString = reader.readLine()) != null){
ans += tmpString ;
}
if(StringUtils.isEmpty(ans)){
throw new BadRequestAlertException("文件内容为空","","");
}
List<AssembleModel> assembleModel = JSONObject.parseArray(ans, AssembleModel.class);
return assembleModel;
}catch (Exception e){
return null;
}finally{
if(reader != null){
try{
reader.close();
}catch(IOException ee){
ee.printStackTrace();
}
}
}
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册