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

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

上级 2fc4f0e7
...@@ -313,8 +313,8 @@ public class MetaModelExService extends MetaModelServiceImpl { ...@@ -313,8 +313,8 @@ public class MetaModelExService extends MetaModelServiceImpl {
*/ */
protected String getFileName(String fileName) { protected String getFileName(String fileName) {
try { try {
//防止中文乱码 // 防止中文乱码
return new String(fileName.getBytes("utf-8"), "iso8859-1"); return new String(fileName.getBytes(StandardCharsets.UTF_8), "iso8859-1");
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
package cn.ibizlab.core.lite.extensions.service; package cn.ibizlab.core.lite.extensions.service;
import cn.ibizlab.core.extensions.domain.AssembleModel; 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.DstApp;
import cn.ibizlab.core.lite.domain.DstSystem; import cn.ibizlab.core.lite.domain.DstSystem;
import cn.ibizlab.core.lite.domain.MetaEntity; import cn.ibizlab.core.lite.domain.MetaEntity;
...@@ -14,10 +13,8 @@ import cn.ibizlab.core.lite.extensions.util.LiteStorage; ...@@ -14,10 +13,8 @@ import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext; import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.*; import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.util.domain.FileItem; import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.errors.InternalServerErrorException; import cn.ibizlab.util.errors.InternalServerErrorException;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -32,7 +29,10 @@ import org.springframework.util.StringUtils; ...@@ -32,7 +29,10 @@ import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.PostConstruct; 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.nio.file.Files;
import java.util.*; import java.util.*;
...@@ -63,11 +63,6 @@ public class LiteModelService { ...@@ -63,11 +63,6 @@ public class LiteModelService {
@Lazy @Lazy
private IMetaRelationshipService metaRelationshipService; private IMetaRelationshipService metaRelationshipService;
@Autowired
@Lazy
private IDstDataSourceService dstDataSourceService;
@Autowired @Autowired
@Lazy @Lazy
private IMetaDataSetService metaDataSetService; private IMetaDataSetService metaDataSetService;
...@@ -99,28 +94,30 @@ public class LiteModelService { ...@@ -99,28 +94,30 @@ public class LiteModelService {
EntityModel entityModel = new EntityModel(); EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity); entityModel.setEntity(entity);
entityModel.setDataSets(metaDataSetService.selectByEntityId(entity != null ? entity.getEntityId() : null));
Map<String, RelationshipModel> parentSet = new LinkedHashMap(); Map<String, RelationshipModel> parentSet = new LinkedHashMap();
List<RelationshipModel> references = new ArrayList<>(); List<RelationshipModel> references = new ArrayList<>();
metaRelationshipService.selectByEntityId(entity.getEntityId()).forEach(item-> if (entity != null) {
{ entityModel.setDataSets(metaDataSetService.selectByEntityId(entity.getEntityId()));
RelationshipModel model = new RelationshipModel(); metaRelationshipService.selectByEntityId(entity.getEntityId()).forEach(item->
MetaEntity parentEntity = LiteStorage.getMetaEntity(item.getRefEntityId()); {
if(parentEntity!=null){ RelationshipModel model = new RelationshipModel();
model.setRelation(item); MetaEntity parentEntity = LiteStorage.getMetaEntity(item.getRefEntityId());
model.setCodeName(item.getCodeName()); if(parentEntity!=null){
model.setDataSourceName(parentEntity.getDsName()); model.setRelation(item);
model.setEntityCodeName(parentEntity.getCodeName()); model.setCodeName(item.getCodeName());
model.setEntityId(parentEntity.getEntityId()); model.setDataSourceName(parentEntity.getDsName());
model.setEntityLogicName(parentEntity.getLogicName()); model.setEntityCodeName(parentEntity.getCodeName());
model.setEntityName(parentEntity.getEntityName()); model.setEntityId(parentEntity.getEntityId());
model.setSystemId(parentEntity.getSystemId()); model.setEntityLogicName(parentEntity.getLogicName());
model.setTableName(parentEntity.getTableName()); model.setEntityName(parentEntity.getEntityName());
parentSet.put(item.getId(),model); model.setSystemId(parentEntity.getSystemId());
references.add(model); model.setTableName(parentEntity.getTableName());
} parentSet.put(item.getId(),model);
}); references.add(model);
}
});
}
entityModel.setReferences(references); entityModel.setReferences(references);
List<RelationshipModel> nesteds = new ArrayList<>(); List<RelationshipModel> nesteds = new ArrayList<>();
...@@ -176,9 +173,7 @@ public class LiteModelService { ...@@ -176,9 +173,7 @@ public class LiteModelService {
public void initMetaEntity() public void initMetaEntity()
{ {
metaEntityService.list().forEach(metaEntity -> { metaEntityService.list().forEach(LiteStorage::putMetaEntity);
LiteStorage.putMetaEntity(metaEntity);
});
} }
@Autowired @Autowired
...@@ -208,9 +203,6 @@ public class LiteModelService { ...@@ -208,9 +203,6 @@ public class LiteModelService {
@Value("${ibiz.filePath:/app/file/}") @Value("${ibiz.filePath:/app/file/}")
private String fileRoot; private String fileRoot;
@Autowired
private MetaModelExService metaModelExService;
@Cacheable( value="syspssystem",key = "'row:all-dst-apps'") @Cacheable( value="syspssystem",key = "'row:all-dst-apps'")
public LinkedHashMap<String, DstApp> getApps() { public LinkedHashMap<String, DstApp> getApps() {
LinkedHashMap<String,DstApp> appNode=new LinkedHashMap<>(); LinkedHashMap<String,DstApp> appNode=new LinkedHashMap<>();
...@@ -224,9 +216,7 @@ public class LiteModelService { ...@@ -224,9 +216,7 @@ public class LiteModelService {
system.setApps(system.getSysstructure().getSysApps(true)); system.setApps(system.getSysstructure().getSysApps(true));
dstSystemService.update(system); dstSystemService.update(system);
} }
system.getApps().forEach(app-> { system.getApps().forEach(app-> appNode.put(app.getId(),app));
appNode.put(app.getId(),app);
});
}); });
return appNode; return appNode;
} }
...@@ -263,7 +253,7 @@ public class LiteModelService { ...@@ -263,7 +253,7 @@ public class LiteModelService {
} }
public FileItem uploadFile(MultipartFile multipartFile) { public FileItem uploadFile(MultipartFile multipartFile) {
FileItem item = null; FileItem item;
// 获取文件名 // 获取文件名
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
// 获取文件后缀 // 获取文件后缀
...@@ -324,7 +314,7 @@ public class LiteModelService { ...@@ -324,7 +314,7 @@ public class LiteModelService {
public String exportFile(List<MetaModel> model){ public String exportFile(List<MetaModel> model){
List<AssembleModel> temp = new ArrayList<>(); List<AssembleModel> temp = new ArrayList<>();
for (MetaModel metaModel : model) { for (MetaModel ignored : model) {
temp.add(null); temp.add(null);
} }
String json = JSON.toJSONString(temp); String json = JSON.toJSONString(temp);
...@@ -332,33 +322,4 @@ public class LiteModelService { ...@@ -332,33 +322,4 @@ public class LiteModelService {
return fileName; 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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册