提交 6372da78 编写于 作者: zhouweidong's avatar zhouweidong

实体、属性、关系注册

上级 1518c818
......@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.core.lite.domain.DstSystem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Primary;
......@@ -41,6 +42,10 @@ public class DstSystemExService extends DstSystemServiceImpl {
@Lazy
IMetaRelationshipService relationService;
@Autowired
@Lazy
DstSystemExService proxyService;
@Override
protected Class currentModelClass() {
return com.baomidou.mybatisplus.core.toolkit.ReflectionKit.getSuperClassGenericType(this.getClass().getSuperclass(), 1);
......@@ -52,8 +57,7 @@ public class DstSystemExService extends DstSystemServiceImpl {
if(!super.create(et))
return false;
et.setSysstructure(structure);
syncSysModel(et);
proxyService.syncSysModel(et);
return true;
}
......@@ -65,7 +69,7 @@ public class DstSystemExService extends DstSystemServiceImpl {
return false;
if(ignoreSyncSysModel==null||ignoreSyncSysModel.equals(false)){
et.setSysstructure(structure);
syncSysModel(et);
proxyService.syncSysModel(et);
}
return true;
}
......@@ -77,6 +81,7 @@ public class DstSystemExService extends DstSystemServiceImpl {
*/
@Override
@Transactional
@Async("asyncExecutor")
public DstSystem syncSysModel(DstSystem system) {
if(StringUtils.isEmpty(system.getPssystemid())||system.getSysstructure()==null)
return system;
......@@ -84,9 +89,13 @@ public class DstSystemExService extends DstSystemServiceImpl {
if(ignoreSyncSysModel!=null&&ignoreSyncSysModel.equals(true))
return system;
long start = System.currentTimeMillis();
log.info("开始同步[{}]系统模型",system.getPssystemid());
syncDE(system);
syncDEField(system);
syncDERelation(system);
long end = System.currentTimeMillis();
log.info("完成[{}]系统同步模型任务,总耗时[{}]秒",system.getPssystemid(),(end-start)/1000);
return super.syncSysModel(system);
}
......@@ -145,7 +154,7 @@ public class DstSystemExService extends DstSystemServiceImpl {
for(JSONObject relation: oldRelation){
delRelation.put(relation.getString("RELATIONID"),1);
}
Set<MetaRelationship> list = system.getSysstructure().getRelation();
Collection<MetaRelationship> list = system.getSysstructure().getRelation();
list.forEach(relation -> {
delRelation.remove(relation.getId());
});
......
......@@ -134,24 +134,23 @@ public class MetaEntity extends EntityMP implements Serializable {
/**
* 属性
*/
@JsonIgnore
@JSONField(serialize = false)
// @JsonIgnore
@TableField(exist = false)
private List<cn.ibizlab.core.lite.domain.MetaField> fields;
/**
* 实体关系
*/
@JsonIgnore
@JSONField(serialize = false)
// @JsonIgnore
// @JSONField(serialize = false)
@TableField(exist = false)
private List<cn.ibizlab.core.lite.domain.MetaRelationship> parentEntitys;
/**
* 实体关系
*/
@JsonIgnore
@JSONField(serialize = false)
// @JsonIgnore
// @JSONField(serialize = false)
@TableField(exist = false)
private List<cn.ibizlab.core.lite.domain.MetaRelationship> subEntitys;
......
......@@ -7,9 +7,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.util.StringUtils;
import java.util.*;
@Data
public class SysModel {
......@@ -54,8 +54,8 @@ public class SysModel {
* 获取实体关系
* @return
*/
public Set<MetaRelationship> getRelation(){
Set<MetaRelationship> relations=new HashSet<>();
public Collection<MetaRelationship> getRelation(){
Map<String,MetaRelationship> relations =new HashMap<>();
this.entities.forEach(entityNode->{
List<MetaRelationship> parentRelation= entityNode.getParentEntitys();
List<MetaRelationship> subRelation= entityNode.getSubEntitys();
......@@ -66,82 +66,17 @@ public class SysModel {
addToRelations(relations,subRelation);
}
});
return relations;
return relations.values();
}
private void addToRelations(Set<MetaRelationship> relations, List<MetaRelationship> entityRelations){
private void addToRelations(Map<String,MetaRelationship> relations, List<MetaRelationship> entityRelations){
entityRelations.forEach(entityRelation->{
entityRelation.setEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entityRelation.getEntityName()).getBytes()));
entityRelation.setRefEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entityRelation.getRefEntityName()).getBytes()));
String relationId = entityRelation.getId();
if( !StringUtils.isEmpty(relationId) && !relations.containsKey(relationId)){
relations.put(relationId,entityRelation);
}
});
relations.addAll(entityRelations);
}
// private List<EntityModel> entities;
//
// /**
// * 获取实体
// * @return
// */
// public Set<MetaEntity> getEntity(){
// Set<MetaEntity> entities=new HashSet<>();
// this.entities.forEach(entity->{
// MetaEntity metaEntity=new MetaEntity();
// metaEntity.setEntityName(entity.getEntityName());
// metaEntity.setCodeName(entity.getCodeName());
// metaEntity.setLogicName(entity.getLogicName());
// metaEntity.setSystemId(entity.getSystemId());
// metaEntity.setSystemName(entity.getSystemId());
// metaEntity.setTableName(entity.getTableName());
// entities.add(metaEntity);
// }
// );
// return entities;
// }
//
// /**
// * 获取实体属性
// * @return
// */
// public Set<MetaField> getField(){
// Set<MetaField> fields=new HashSet<>();
// this.entities.forEach(entity->{
// entity.getFields().forEach(fieldModel->{
// MetaField metaField=new MetaField();
// metaField.setCodeName(fieldModel.getCodeName());
// metaField.setFieldName(fieldModel.getColumnName());
// metaField.setFieldLogicName(fieldModel.getComment());
// metaField.setFieldShowName(fieldModel.getShowName());
// metaField.setEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,entity.getEntityName()).getBytes()));
// fields.add(metaField);
// }
// );
// }
// );
// return fields;
// }
//
// /**
// * 获取实体关系
// * @return
// */
// public Set<MetaRelationship> getRelation(){
// Set<MetaRelationship> relations=new HashSet<>();
// this.entities.forEach(entity->{
// entity.getNesteds().forEach(relation->{
// MetaRelationship metaRelationship=new MetaRelationship();
//// metaRelationship.setName();
// metaRelationship.setCodeName(relation.getCodeName());
// metaRelationship.setEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,relation.getEntityName()).getBytes()));
// metaRelationship.setEntityName(relation.getEntityName());
//// metaRelationship.setRefEntityName();
// metaRelationship.setRefEntityId(DigestUtils.md5DigestAsHex(String.format("%s||%s" ,systemid,relation.getEntityName()).getBytes()));
// }
// );
// }
// );
// return relations;
// }
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册