提交 5ad47856 编写于 作者: sq3536's avatar sq3536

tableschema

上级 7e478f0b
...@@ -18,7 +18,9 @@ import net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam; ...@@ -18,7 +18,9 @@ import net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam;
import net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl; import net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl;
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;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -58,12 +60,9 @@ public class DynamicModelService { ...@@ -58,12 +60,9 @@ public class DynamicModelService {
return initDynamicSystem(system); return initDynamicSystem(system);
} }
private IPSSystem initDynamicSystem(String system) private IPSSystem initDynamicSystem(String system)
{ {
if(dynamicSystems==null)
dynamicSystems=new HashMap<>();
IPSSystem iPSSystem = null;
String strPSModelFolderPath=null; String strPSModelFolderPath=null;
if(Files.exists(Paths.get(getModelPath(),system,"model","PSSYSTEM.json"))) { if(Files.exists(Paths.get(getModelPath(),system,"model","PSSYSTEM.json"))) {
strPSModelFolderPath=Paths.get(getModelPath(),system,"model").toString(); strPSModelFolderPath=Paths.get(getModelPath(),system,"model").toString();
...@@ -74,6 +73,14 @@ public class DynamicModelService { ...@@ -74,6 +73,14 @@ public class DynamicModelService {
if(allDynamicModel.containsKey(system)) if(allDynamicModel.containsKey(system))
strPSModelFolderPath = allDynamicModel.get(system).getDynamicModelPath(); strPSModelFolderPath = allDynamicModel.get(system).getDynamicModelPath();
} }
return initDynamicSystem(system,strPSModelFolderPath);
}
private IPSSystem initDynamicSystem(String system, String strPSModelFolderPath)
{
if(dynamicSystems==null)
dynamicSystems=new HashMap<>();
IPSSystem iPSSystem = null;
if(StringUtils.isEmpty(strPSModelFolderPath)) if(StringUtils.isEmpty(strPSModelFolderPath))
throw new BadRequestAlertException("加载系统模型错误,未找到对应模型目录", "DynamicSystem", system); throw new BadRequestAlertException("加载系统模型错误,未找到对应模型目录", "DynamicSystem", system);
...@@ -647,4 +654,52 @@ public class DynamicModelService { ...@@ -647,4 +654,52 @@ public class DynamicModelService {
} }
private Map<String,Long> systemModifyMap=new HashMap<>();
@Caching( evict = {
@CacheEvict( value="syspssystem",allEntries = true),
@CacheEvict( value="meta-entities", key = "'system:'+#p0"),
@CacheEvict( value="meta-entities", key = "'system:keymap-'+#p0")
})
public void resetSystem(String system)
{
}
private IPSSystem reloadDynamicSystem(DstSystemModel system)
{
return initDynamicSystem(system.getPssystemid(),system.getDynamicModelPath());
}
public Map<String,Map<String,Long>> getAllDynamicModelVersion()
{
Map<String,Map<String,Long>> ret=new LinkedHashMap<>();
this.findAllDynamicModel().values().forEach(dstSystemModel -> {
if(ret.containsKey(dstSystemModel.getPssystemid()))
return;
if((!systemModifyMap.containsKey(dstSystemModel.getPssystemid()))||systemModifyMap.get(dstSystemModel.getPssystemid())<dstSystemModel.getLastModify())
{
reloadDynamicSystem(dstSystemModel);
this.getProxy().resetSystem(dstSystemModel.getPssystemid());
if(!dstSystemModel.getPssystemid().equals(dstSystemModel.getPssystemid().toLowerCase()))
this.getProxy().resetSystem(dstSystemModel.getPssystemid().toLowerCase());
}
systemModifyMap.put(dstSystemModel.getPssystemid(),dstSystemModel.getLastModify());
Map<String,Long> entities=new LinkedHashMap<>();
ret.put(dstSystemModel.getPssystemid(),entities);
try {
this.getEntities(dstSystemModel.getPssystemid()).values().forEach(metaEntityModel -> {
if(entities.containsKey(metaEntityModel.getEntityName()))
return;
entities.put(metaEntityModel.getEntityName(),dstSystemModel.getLastModify());
});
} catch (Exception exception) {
}
});
return ret;
}
} }
...@@ -113,6 +113,19 @@ public class POSchema { ...@@ -113,6 +113,19 @@ public class POSchema {
return this; return this;
} }
@JsonIgnore
@JSONField(serialize = false)
public Set<String> getForeignKey()
{
Set<String> fks=new HashSet<>();
if(foreignKeyConstraints!=null)
{
foreignKeyConstraints.forEach(fk->fks.add(fk.getConstraintName()));
}
return fks;
}
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
private Map<String,Column> columnMaps; private Map<String,Column> columnMaps;
...@@ -633,7 +646,19 @@ public class POSchema { ...@@ -633,7 +646,19 @@ public class POSchema {
put("h2", "mysql"); put("h2", "mysql");
}}; }};
public Segment getSegment(String tag)
{
if(segments!=null)
{
for(Segment script:segments)
{
String key=DataObject.getStringValue(script.getName(),"").concat(".").concat(DataObject.getStringValue(script.getVendorProvider(),""));
if(key.equals(tag))
return script;
}
}
return null;
}
public Segment getSegment(String name,String type) public Segment getSegment(String name,String type)
{ {
......
...@@ -41,7 +41,11 @@ public class PojoOption extends DataObj ...@@ -41,7 +41,11 @@ public class PojoOption extends DataObj
} }
public String getSystem(){ public String getSystem(){
return this.getStringValue("system_id",this.getStringValue("system_name",this.getStringValue("system"))); return this.getStringValue("system_id",this.getStringValue("system",this.getStringValue("system_name")));
}
public String getSystemName(){
return this.getStringValue("system_name",this.getStringValue("system",this.getStringValue("system_id")));
} }
public String getPackage(){ public String getPackage(){
......
...@@ -55,126 +55,126 @@ public interface IPersistentService { ...@@ -55,126 +55,126 @@ public interface IPersistentService {
default BaseData create(String datasource,String table,BaseData et,boolean bGet) default BaseData create(String system,String table,String datasource,BaseData et,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return create(link,getSchema(link,table),et,bGet); return create(link,getSchema(link,system,table),et,bGet);
} }
default List<BaseData> createBatch(String datasource,String table,List<BaseData> list,boolean bGet) default List<BaseData> createBatch(String system,String table,String datasource,List<BaseData> list,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return createBatch(link,getSchema(link,table),list,bGet); return createBatch(link,getSchema(link,system,table),list,bGet);
} }
default BaseData update(String datasource,String table,BaseData et,boolean bGet) default BaseData update(String system,String table,String datasource,BaseData et,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return update(link,getSchema(link,table),et,bGet); return update(link,getSchema(link,system,table),et,bGet);
} }
default List<BaseData> updateBatch(String datasource,String table,List<BaseData> list,boolean bGet) default List<BaseData> updateBatch(String system,String table,String datasource,List<BaseData> list,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return updateBatch(link,getSchema(link,table),list,bGet); return updateBatch(link,getSchema(link,system,table),list,bGet);
} }
default boolean remove(String datasource,String table,Serializable key) default boolean remove(String system,String table,String datasource,Serializable key)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return remove(link,getSchema(link,table),key); return remove(link,getSchema(link,system,table),key);
} }
default boolean removeBatch(String datasource,String table,List<Serializable> idList) default boolean removeBatch(String system,String table,String datasource,List<Serializable> idList)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return removeBatch(link,getSchema(link,table),idList); return removeBatch(link,getSchema(link,system,table),idList);
} }
default boolean removeByMap(String datasource,String table,BaseData et) default boolean removeByMap(String system,String table,String datasource,BaseData et)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return removeByMap(link,getSchema(link,table),et); return removeByMap(link,getSchema(link,system,table),et);
} }
default boolean removeByMapBatch(String datasource,String table,List<BaseData> list) default boolean removeByMapBatch(String system,String table,String datasource,List<BaseData> list)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return removeByMapBatch(link,getSchema(link,table),list); return removeByMapBatch(link,getSchema(link,system,table),list);
} }
default BaseData get(String datasource,String table,Serializable key) default BaseData get(String system,String table,String datasource,Serializable key)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return get(link,getSchema(link,table),key); return get(link,getSchema(link,system,table),key);
} }
default List<BaseData> getBatch(String datasource,String table,List<Serializable> idList) default List<BaseData> getBatch(String system,String table,String datasource,List<Serializable> idList)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return getBatch(link,getSchema(link,table),idList); return getBatch(link,getSchema(link,system,table),idList);
} }
default BaseData getByMap(String datasource,String table,BaseData et) default BaseData getByMap(String system,String table,String datasource,BaseData et)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return getByMap(link,getSchema(link,table),et); return getByMap(link,getSchema(link,system,table),et);
} }
default List<BaseData> getByMapBatch(String datasource,String table,List<BaseData> list) default List<BaseData> getByMapBatch(String system,String table,String datasource,List<BaseData> list)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return getByMapBatch(link,getSchema(link,table),list); return getByMapBatch(link,getSchema(link,system,table),list);
} }
default List<BaseData> getBatchKey(String datasource,String table,List<BaseData> list) default List<BaseData> getBatchKey(String system,String table,String datasource,List<BaseData> list)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return getBatchKey(link,getSchema(link,table),list); return getBatchKey(link,getSchema(link,system,table),list);
} }
default Long count(String datasource,String table,BaseData et) default Long count(String system,String table,String datasource,BaseData et)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return count(link,getSchema(link,table),et); return count(link,getSchema(link,system,table),et);
} }
default boolean checkKey(String datasource,String table,BaseData et) default boolean checkKey(String system,String table,String datasource,BaseData et)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return checkKey(link,getSchema(link,table),et); return checkKey(link,getSchema(link,system,table),et);
} }
default BaseData save(String datasource,String table,BaseData et,boolean bGet) default BaseData save(String system,String table,String datasource,BaseData et,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return save(link,getSchema(link,table),et,bGet); return save(link,getSchema(link,system,table),et,bGet);
} }
default List<BaseData> saveBatch(String datasource,String table,List<BaseData> list,boolean bGet) default List<BaseData> saveBatch(String system,String table,String datasource,List<BaseData> list,boolean bGet)
{ {
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return saveBatch(link,getSchema(link,table),list,bGet); return saveBatch(link,getSchema(link,system,table),list,bGet);
} }
default List<BaseData> select(String datasource,String table,BaseData et){ default List<BaseData> select(String system,String table,String datasource,BaseData et){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return select(link,getSchema(link,table),et); return select(link,getSchema(link,system,table),et);
} }
default Page<BaseData> select(String datasource,String table,BaseData et,Pageable pageable){ default Page<BaseData> select(String system,String table,String datasource,BaseData et,Pageable pageable){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return select(link,getSchema(link,table),et,pageable); return select(link,getSchema(link,system,table),et,pageable);
} }
default List<BaseData> query(String datasource,String table,String dataQuery,FilterData context){ default List<BaseData> query(String system,String table,String datasource,String dataQuery,FilterData context){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return query(link,getSchema(link,table),dataQuery,context); return query(link,getSchema(link,system,table),dataQuery,context);
} }
default Page<BaseData> query(String datasource,String table,String dataQuery,FilterData context,Pageable pageable){ default Page<BaseData> query(String system,String table,String datasource,String dataQuery,FilterData context,Pageable pageable){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return query(link,getSchema(link,table),dataQuery,context,pageable); return query(link,getSchema(link,system,table),dataQuery,context,pageable);
} }
default List<BaseData> selectRaw(String datasource,String table,String sql,FilterData context){ default List<BaseData> selectRaw(String system,String table,String datasource,String sql,FilterData context){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return selectRaw(link,getSchema(link,table),sql,context); return selectRaw(link,getSchema(link,system,table),sql,context);
} }
default boolean execRaw(String datasource,String table,String sql,BaseData param){ default boolean execRaw(String system,String table,String datasource,String sql,BaseData param){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return execRaw(link,getSchema(link,table),sql,param); return execRaw(link,getSchema(link,system,table),sql,param);
} }
default List<BaseData> fetch(String datasource,String table,String dataSet,FilterData context){ default List<BaseData> fetch(String system,String table,String datasource,String dataSet,FilterData context){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return fetch(link,getSchema(link,table),dataSet,context); return fetch(link,getSchema(link,system,table),dataSet,context);
} }
default Page<BaseData> fetch(String datasource,String table,String dataSet,FilterData context,Pageable pageable){ default Page<BaseData> fetch(String system,String table,String datasource,String dataSet,FilterData context,Pageable pageable){
DSLink link=getDSLink(datasource); DSLink link=getDSLink(datasource);
return fetch(link,getSchema(link,table),dataSet,context,pageable); return fetch(link,getSchema(link,system,table),dataSet,context,pageable);
} }
DSLink getDSLink(String datasource); DSLink getDSLink(String datasource);
POSchema getSchema(DSLink link,String table); POSchema getSchema(DSLink link,String system,String table);
} }
...@@ -344,7 +344,7 @@ public class DbPersistentServiceImpl implements IPersistentService { ...@@ -344,7 +344,7 @@ public class DbPersistentServiceImpl implements IPersistentService {
} }
@Override @Override
public POSchema getSchema(DSLink link, String table) { public POSchema getSchema(DSLink link, String system, String table) {
return null; return null;
} }
} }
...@@ -250,7 +250,7 @@ public class MongoPersistentServiceImpl implements IPersistentService { ...@@ -250,7 +250,7 @@ public class MongoPersistentServiceImpl implements IPersistentService {
} }
@Override @Override
public POSchema getSchema(DSLink link, String table) { public POSchema getSchema(DSLink link, String system, String table) {
return null; return null;
} }
} }
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册