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

实体、属性、关系注册

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