提交 4be78d7f 编写于 作者: sq3536's avatar sq3536

提交

上级 b457b716
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
<dependency> <dependency>
<groupId>net.ibizsys.model</groupId> <groupId>net.ibizsys.model</groupId>
<artifactId>ibizlab-model</artifactId> <artifactId>ibizlab-model</artifactId>
<version>1.2.4</version> <version>1.2.5</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -281,9 +281,13 @@ public class DOModel extends EntityBase implements Serializable { ...@@ -281,9 +281,13 @@ public class DOModel extends EntityBase implements Serializable {
} }
public DOModel addPOSchema(String name,POSchema poSchema) public DOModel addPOSchema(String name,POSchema poSchema)
{ {
if(poSchemas==null) if(poSchema!=null)
poSchemas=new LinkedHashMap<>(); {
poSchemas.put(name,poSchema); if(poSchemas==null)
poSchemas=new LinkedHashMap<>();
poSchemas.put(name,poSchema.build());
}
return this; return this;
} }
public POSchema getPOSchema(String name) public POSchema getPOSchema(String name)
......
...@@ -4,6 +4,7 @@ import cn.ibizlab.util.errors.BadRequestAlertException; ...@@ -4,6 +4,7 @@ import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import net.ibizsys.model.IPSSystem; import net.ibizsys.model.IPSSystem;
import net.ibizsys.model.PSModelServiceImpl; import net.ibizsys.model.PSModelServiceImpl;
import net.ibizsys.model.database.IPSDEFDTColumn;
import net.ibizsys.model.database.IPSSysDBTable; import net.ibizsys.model.database.IPSSysDBTable;
import net.ibizsys.model.dataentity.IPSDataEntity; import net.ibizsys.model.dataentity.IPSDataEntity;
import net.ibizsys.model.dataentity.defield.IPSDEField; import net.ibizsys.model.dataentity.defield.IPSDEField;
...@@ -58,7 +59,7 @@ public class DynamicModelService { ...@@ -58,7 +59,7 @@ public class DynamicModelService {
IPSSystem iPSSystem = null; 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","PSSYSTEM.json").toString(); strPSModelFolderPath=Paths.get(getModelPath(),system,"model").toString();
} }
else else
{ {
...@@ -183,10 +184,24 @@ public class DynamicModelService { ...@@ -183,10 +184,24 @@ public class DynamicModelService {
} }
entityModel.setEntity(metaEntityModel); entityModel.setEntity(metaEntityModel);
List<String> dsTypes=new ArrayList<>();
if(dataEntity.getAllPSDEDBConfigs()!=null)
{
dataEntity.getAllPSDEDBConfigs().forEach(item->{
dsTypes.add(item.getDBType().toLowerCase());
if(!entityModel.getTableName().equalsIgnoreCase(item.getTableName()))
entityModel.getEntity().set("table-"+item.getDBType().toLowerCase(),item.getTableName());
});
}
if(dsTypes.size()>0)
entityModel.getEntity().set("ds_types",String.join(",",dsTypes));
Map<String,FieldModel> fieldMaps=new LinkedHashMap<>(); Map<String,FieldModel> fieldMaps=new LinkedHashMap<>();
for(IPSDEField defield:dataEntity.getAllPSDEFields()) for(IPSDEField defield:dataEntity.getAllPSDEFields())
{ {
FieldModel fieldModel=new FieldModel(); FieldModel fieldModel=new FieldModel();
MetaFieldModel metaFieldModel=new MetaFieldModel(); MetaFieldModel metaFieldModel=new MetaFieldModel();
metaFieldModel.setFieldId(defield.getId()).setFieldName(defield.getName()).setCodeName(defield.getCodeName()).setFieldLogicName(defield.getLogicName()) metaFieldModel.setFieldId(defield.getId()).setFieldName(defield.getName()).setCodeName(defield.getCodeName()).setFieldLogicName(defield.getLogicName())
...@@ -203,7 +218,7 @@ public class DynamicModelService { ...@@ -203,7 +218,7 @@ public class DynamicModelService {
if(!metaFieldModel.getFieldName().equalsIgnoreCase(col.getColumnName())) if(!metaFieldModel.getFieldName().equalsIgnoreCase(col.getColumnName()))
metaFieldModel.set("column-"+col.getDBType().toLowerCase(),col.getColumnName()); metaFieldModel.set("column-"+col.getDBType().toLowerCase(),col.getColumnName());
if(StringUtils.isEmpty(metaFieldModel)&&defield.isFormulaDEField()&&(!StringUtils.isEmpty(col.getQueryCodeExp()))) if(StringUtils.isEmpty(metaFieldModel)&&defield.isFormulaDEField()&&(!StringUtils.isEmpty(col.getQueryCodeExp())))
metaFieldModel.setExpression(col.getQueryCodeExp().replace("`","")); metaFieldModel.setExpression(col.getQueryCodeExp().replace("`","").replace("[","").replace("]",""));
}); });
} }
...@@ -233,7 +248,7 @@ public class DynamicModelService { ...@@ -233,7 +248,7 @@ public class DynamicModelService {
MetaRelationshipModel metaRel=new MetaRelationshipModel(); MetaRelationshipModel metaRel=new MetaRelationshipModel();
metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId()) metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setName(dataEntity.getName()).setNestedName(der.getMinorCodeName()) .setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setEntityName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setSystemId(iPSSystem.getCodeName()); .setSystemId(iPSSystem.getCodeName());
if(der instanceof IPSDER1N) if(der instanceof IPSDER1N)
...@@ -263,7 +278,7 @@ public class DynamicModelService { ...@@ -263,7 +278,7 @@ public class DynamicModelService {
MetaRelationshipModel metaRel=new MetaRelationshipModel(); MetaRelationshipModel metaRel=new MetaRelationshipModel();
metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId()) metaRel.setId(der.getId()).setName(der.getName()).setRelationType(der.getDERType()).setCodeName(der.getCodeName()).setRefEntityId(der.getMajorPSDataEntity().getId())
.setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setName(dataEntity.getName()).setNestedName(der.getMinorCodeName()) .setRefEntityName(der.getMajorPSDataEntity().getName()).setEntityId(dataEntity.getId()).setEntityName(dataEntity.getName()).setNestedName(der.getMinorCodeName())
.setSystemId(iPSSystem.getCodeName()); .setSystemId(iPSSystem.getCodeName());
if(der instanceof IPSDER1N) if(der instanceof IPSDER1N)
...@@ -287,7 +302,7 @@ public class DynamicModelService { ...@@ -287,7 +302,7 @@ public class DynamicModelService {
if(dataQuery.getAllPSDEDataQueryCodes()!=null) if(dataQuery.getAllPSDEDataQueryCodes()!=null)
{ {
dataQuery.getAllPSDEDataQueryCodes().forEach(dq->{ dataQuery.getAllPSDEDataQueryCodes().forEach(dq->{
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId("dq-"+dataQuery.getCodeName()+"-"+dq.getDBType().toLowerCase()) MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId(entityModel.getEntityName().toLowerCase()+"-dq-"+dataQuery.getCodeName()+"-"+dq.getDBType().toLowerCase())
.setDatasetName(dataQuery.getLogicName()).setCodeName(dataQuery.getCodeName()) .setDatasetName(dataQuery.getLogicName()).setCodeName(dataQuery.getCodeName())
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(dq.getQueryCode()); .setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(dq.getQueryCode());
entityModel.addDataSet(dsModel); entityModel.addDataSet(dsModel);
...@@ -306,8 +321,12 @@ public class DynamicModelService { ...@@ -306,8 +321,12 @@ public class DynamicModelService {
try { try {
if(dataSet.getPSDEDataQueries()!=null) if(dataSet.getPSDEDataQueries()!=null)
{ {
Map<String,String> map =new HashMap<>(); Map<String,String> map =new HashMap<>();
dataSet.getPSDEDataQueries().forEach(dataQuery->{ dataSet.getPSDEDataQueries().forEach(dataQuery->{
...@@ -324,7 +343,7 @@ public class DynamicModelService { ...@@ -324,7 +343,7 @@ public class DynamicModelService {
code = map.get(dq.getDBType()); code = map.get(dq.getDBType());
code = code+"\r\n union all \r\n"; code = code+"\r\n union all \r\n";
} }
code = code+dq.getQueryCode(); code = code+"<include refid=\""+entityModel.getEntityName().toLowerCase()+"_dq_"+dataQuery.getCodeName()+"_"+dq.getDBType().toLowerCase()+"\"/>";
map.put(dq.getDBType(),code); map.put(dq.getDBType(),code);
}); });
} }
...@@ -336,9 +355,27 @@ public class DynamicModelService { ...@@ -336,9 +355,27 @@ public class DynamicModelService {
for(Map.Entry<String,String> entry:map.entrySet()) for(Map.Entry<String,String> entry:map.entrySet())
{ {
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId("ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase()) String sql="select t1.* from (\r\n".concat(entry.getValue()).concat("\r\n) t1");
if(dataSet.getMajorSortPSDEField()!=null)
{
IPSDEFDTColumn column = dataSet.getMajorSortPSDEField().getPSDEFDTColumn(entry.getKey(),false);
sql=sql.concat(" order by ").concat(column==null?dataSet.getMajorSortPSDEField().getName():column.getColumnName());
if(!StringUtils.isEmpty(dataSet.getMajorSortDir()))
sql=sql.concat(" ").concat(dataSet.getMajorSortDir());
if(dataSet.getMinorSortPSDEField()!=null)
{
IPSDEFDTColumn subCol = dataSet.getMinorSortPSDEField().getPSDEFDTColumn(entry.getKey(),false);
sql=sql.concat(",").concat(subCol==null?dataSet.getMinorSortPSDEField().getName():subCol.getColumnName());
if(!StringUtils.isEmpty(dataSet.getMinorSortDir()))
sql=sql.concat(" ").concat(dataSet.getMinorSortDir());
}
}
MetaDataSetModel dsModel=new MetaDataSetModel().setDatasetId(entityModel.getEntityName().toLowerCase()+"-ds-"+dataSet.getCodeName()+"-"+entry.getKey().toLowerCase())
.setDatasetName(dataSet.getLogicName()).setCodeName(dataSet.getCodeName()) .setDatasetName(dataSet.getLogicName()).setCodeName(dataSet.getCodeName())
.setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(entry.getValue()); .setEntityId(entityModel.getEntityId()).setEntityName(entityModel.getEntityName()).setDsCode(sql);
entityModel.addDataSet(dsModel); entityModel.addDataSet(dsModel);
} }
...@@ -348,6 +385,8 @@ public class DynamicModelService { ...@@ -348,6 +385,8 @@ public class DynamicModelService {
} }
}); });
} }
......
...@@ -277,6 +277,35 @@ public class EntityModel { ...@@ -277,6 +277,35 @@ public class EntityModel {
return null; return null;
} }
@JsonIgnore
@JSONField(serialize = false)
public String getDefaultQueryScript()
{
if(this.getDataSets()!=null)
{
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if("view".equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().startsWith("dq-view-")||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-view-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if("default".equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().startsWith("dq-default-")||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-default-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
}
return "";
}
public String getSqlSegment(String dataSet) public String getSqlSegment(String dataSet)
{ {
...@@ -298,6 +327,35 @@ public class EntityModel { ...@@ -298,6 +327,35 @@ public class EntityModel {
{ {
return "select count(1) from "+this.getTableName()+" "; return "select count(1) from "+this.getTableName()+" ";
} }
else if(this.getDataSets()!=null)
{
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if(dataSet.equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().indexOf("ds-"+dataSet.toLowerCase()+"-")>=0||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-ds-"+dataSet.toLowerCase()+"-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
for(MetaDataSetModel set:this.getDataSets()){
if(StringUtils.isEmpty(set.getDsCode()))
continue;
if(dataSet.equalsIgnoreCase(set.getDatasetId())||
set.getDatasetId().indexOf("dq-"+dataSet.toLowerCase()+"-")>=0||
set.getDatasetId().startsWith(getEntityName().toLowerCase()+"-dq-"+dataSet.toLowerCase()+"-"))
{
return set.getDsCode().replace("`","").replace("[","").replace("]","");
}
}
}
if(dataSet.equalsIgnoreCase("VIEW")||dataSet.equalsIgnoreCase("DEFAULT"))
{
return "";
}
else else
{ {
String columnSet=""; String columnSet="";
...@@ -417,8 +475,24 @@ public class EntityModel { ...@@ -417,8 +475,24 @@ public class EntityModel {
public String getExtParams(String key) public String getExtParams(String key)
{ {
return Setting.getValue(this.getEntity().getExtParams(),key); return DataObject.getStringValue(entity.get(key),"");
} }
public String getTableName(String dsType)
{
return DataObject.getStringValue(entity.get("table-"+dsType.toLowerCase()),getTableName());
}
@JsonIgnore
@JSONField(serialize = false)
public List<String> getDsTypes()
{
List<String> dsTypes=new ArrayList<>();
String strDsTypes=DataObject.getStringValue(entity.get("ds_types"),"");
for(String dsType:strDsTypes.split(","))
dsTypes.add(dsType);
return dsTypes;
}
} }
package cn.ibizlab.core.data.lite; package cn.ibizlab.core.data.lite;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
...@@ -103,5 +104,9 @@ public class FieldModel { ...@@ -103,5 +104,9 @@ public class FieldModel {
return "string"; return "string";
} }
public String getColumnName(String dsType)
{
return DataObject.getStringValue(field.get("column-"+dsType.toLowerCase()),getColumnName());
}
} }
...@@ -142,8 +142,10 @@ public class MetaEntityModel{ ...@@ -142,8 +142,10 @@ public class MetaEntityModel{
extensionparams.put(key,value); extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>(); List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet()) for(Map.Entry<String,Object> entry:extensionparams.entrySet()) {
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,""))); if(!entry.getKey().equalsIgnoreCase("param"))
settingList.add(new Setting().setProperty(entry.getKey()).setValue(DataObject.getStringValue(entry.getValue(), "")));
}
return setExtParams(JSON.toJSONString(settingList)); return setExtParams(JSON.toJSONString(settingList));
} }
......
...@@ -293,8 +293,10 @@ public class MetaFieldModel { ...@@ -293,8 +293,10 @@ public class MetaFieldModel {
extensionparams.put(key,value); extensionparams.put(key,value);
List<Setting> settingList=new ArrayList<>(); List<Setting> settingList=new ArrayList<>();
for(Map.Entry<String,Object> entry:extensionparams.entrySet()) for(Map.Entry<String,Object> entry:extensionparams.entrySet()) {
settingList.add(new Setting().setProperty(key).setValue(DataObject.getStringValue(value,""))); if(!entry.getKey().equalsIgnoreCase("param"))
settingList.add(new Setting().setProperty(entry.getKey()).setValue(DataObject.getStringValue(entry.getValue(), "")));
}
return setExtParams(JSON.toJSONString(settingList)); return setExtParams(JSON.toJSONString(settingList));
} }
......
package cn.ibizlab.core.data.model; package cn.ibizlab.core.data.model;
import cn.ibizlab.core.data.dto.BaseData; import cn.ibizlab.core.data.dto.BaseData;
import cn.ibizlab.util.errors.BadRequestAlertException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
...@@ -12,6 +15,10 @@ import lombok.experimental.Accessors; ...@@ -12,6 +15,10 @@ import lombok.experimental.Accessors;
import org.apache.ibatis.mapping.VendorDatabaseIdProvider; import org.apache.ibatis.mapping.VendorDatabaseIdProvider;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.*; import java.util.*;
@Getter @Getter
...@@ -22,15 +29,21 @@ import java.util.*; ...@@ -22,15 +29,21 @@ import java.util.*;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class POSchema { public class POSchema {
@JSONField(ordinal = 1)
private String name; private String name;
@JSONField(ordinal = 2)
private String remarks; private String remarks;
@JSONField(ordinal = 3)
private String dsType; private String dsType;
@JSONField(ordinal = 4)
private String defaultDataSource; private String defaultDataSource;
@JSONField(ordinal = 5)
private String logicVal; private String logicVal;
@JSONField(ordinal = 6)
private String logicDelVal; private String logicDelVal;
public String getLogicVal() { public String getLogicVal() {
...@@ -45,8 +58,10 @@ public class POSchema { ...@@ -45,8 +58,10 @@ public class POSchema {
return logicDelVal; return logicDelVal;
} }
@JSONField(ordinal = 7)
private List<Column> columns; private List<Column> columns;
@JSONField(ordinal = 8)
private List<Column> transients; private List<Column> transients;
public POSchema setColumns(List<Column> columns) public POSchema setColumns(List<Column> columns)
...@@ -81,6 +96,7 @@ public class POSchema { ...@@ -81,6 +96,7 @@ public class POSchema {
return this; return this;
} }
@JSONField(ordinal = 9)
private List<ForeignKeyConstraint> foreignKeyConstraints; private List<ForeignKeyConstraint> foreignKeyConstraints;
public POSchema addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint) public POSchema addForeignKeyConstraint(ForeignKeyConstraint foreignKeyConstraint)
...@@ -120,6 +136,7 @@ public class POSchema { ...@@ -120,6 +136,7 @@ public class POSchema {
return columnMaps; return columnMaps;
} }
@JSONField(ordinal = 10)
public boolean needTrans = false; public boolean needTrans = false;
public void refreshColumnMaps() public void refreshColumnMaps()
...@@ -174,7 +191,7 @@ public class POSchema { ...@@ -174,7 +191,7 @@ public class POSchema {
if(column.isLastModify()) if(column.isLastModify())
this.setLastModifyColumn(column); this.setLastModifyColumn(column);
} }
if((!StringUtils.isEmpty(column.getAlias()))&&column.getAlias().equalsIgnoreCase(column.getName())) if((!StringUtils.isEmpty(column.getAlias()))&&(!column.getAlias().equalsIgnoreCase(column.getName())))
{ {
needTrans=true; needTrans=true;
columnMaps.put(column.getAlias().toLowerCase(), column); columnMaps.put(column.getAlias().toLowerCase(), column);
...@@ -300,6 +317,12 @@ public class POSchema { ...@@ -300,6 +317,12 @@ public class POSchema {
private String alias; private String alias;
private String predefined; private String predefined;
public Column setAlias(String alias)
{
if((!StringUtils.isEmpty(name))&&(!name.equalsIgnoreCase(alias)))
this.alias=alias;
return this;
}
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
...@@ -447,21 +470,38 @@ public class POSchema { ...@@ -447,21 +470,38 @@ public class POSchema {
@Accessors(chain = true) @Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public static class Script{ public static class Segment{
private String name; private String name;
private String vendorProvider; private String vendorProvider;
private String declare; private String declare;
private String body; private String body;
private Map params; private Map params;
public Segment setVendorProvider(String vendorProvider)
{
if(!StringUtils.isEmpty(vendorProvider))
this.vendorProvider=provider.get(vendorProvider.toLowerCase());
return this;
}
} }
public List<Script> scripts; @JSONField(ordinal = 11)
public List<Segment> segments;
public POSchema addSegment(Segment segment)
{
if(segments==null)
segments=new ArrayList<>();
segments.add(segment);
return this;
}
private static Map<String, String> provider = new HashMap<String, String>(){{ private static Map<String, String> provider = new HashMap<String, String>(){{
put("oracle", "oracle"); put("oracle", "oracle");
put("mysql", "mysql"); put("mysql", "mysql");
put("mysql5", "mysql");
put("postgresql", "postgresql"); put("postgresql", "postgresql");
put("mppdb", "postgresql"); put("mppdb", "postgresql");
put("dm", "oracle"); put("dm", "oracle");
...@@ -472,39 +512,60 @@ public class POSchema { ...@@ -472,39 +512,60 @@ public class POSchema {
public Script getScript(String name,String type) public Segment getSegment(String name,String type)
{ {
if(scripts!=null) if(segments!=null)
{ {
String vendorProvider="mysql"; String vendorProvider=StringUtils.isEmpty(type)?"":provider.get(type.toLowerCase());
if((!StringUtils.isEmpty(type))&&provider.containsKey(type.toLowerCase())) for(Segment script:segments)
vendorProvider=provider.get(type.toLowerCase());
for(Script script:scripts)
{ {
if(name.equalsIgnoreCase(script.getName())&&((script.getVendorProvider().indexOf(vendorProvider)>=0)||StringUtils.isEmpty(script.getVendorProvider()))) if(script.getName().toLowerCase().indexOf(name.toLowerCase())>=0&&(StringUtils.isEmpty(vendorProvider)||script.getVendorProvider().indexOf(vendorProvider)>=0||StringUtils.isEmpty(script.getVendorProvider())))
return script; return script;
} }
} }
else else
{ {
scripts=new ArrayList<>(); segments=new ArrayList<>();
} }
return getDefaultQueryScript(); return null;
} }
@JsonIgnore @JSONField(ordinal = 12)
@JSONField(serialize = false) public Segment defaultQueryScript;
public Script defaultQueryScript;
@JsonIgnore public POSchema setDefaultQueryScript(String sql)
@JSONField(serialize = false) {
public Script getDefaultQueryScript() defaultQueryScript=new Segment().setName("default_query_script").setVendorProvider("").setBody(sql);
return this;
}
public Segment getDefaultQueryScript()
{ {
if(defaultQueryScript==null) if(defaultQueryScript==null)
{ {
defaultQueryScript=new Script(); Segment segment=this.getSegment("dq-view-",this.getDsType());
defaultQueryScript.setName("default"); if(segment==null)
defaultQueryScript.setVendorProvider("mysql,oracle,postgresql"); segment=this.getSegment("dq-default-",this.getDsType());
if(segment!=null)
{
setDefaultQueryScript(segment.getBody());
return defaultQueryScript;
}
else if(!StringUtils.isEmpty(this.getDsType()))
{
segment=this.getSegment("dq-view-","");
if(segment==null)
segment=this.getSegment("dq-default-","");
if(segment!=null)
{
setDefaultQueryScript(segment.getBody().replace("`","").replace("[","").replace("]",""));
return defaultQueryScript;
}
}
defaultQueryScript=new Segment();
defaultQueryScript.setName("default_query_script");
defaultQueryScript.setVendorProvider("");
String sql="select "; String sql="select ";
String cols=""; String cols="";
...@@ -514,18 +575,18 @@ public class POSchema { ...@@ -514,18 +575,18 @@ public class POSchema {
{ {
if(!StringUtils.isEmpty(cols)) if(!StringUtils.isEmpty(cols))
cols+=","; cols+=",";
cols+=("t."+key+" as "+baseColumnMap.get(key)); cols+=("t1."+key+" as "+baseColumnMap.get(key));
} }
} }
else else
cols="*"; cols="t1.*";
sql += (cols+" from "+name+" t "); sql += (cols+" from "+name+" t1 ");
if(isLogicValid()) if(isLogicValid())
{ {
sql += " where t."+this.getLogicValidCond(); sql += " where t1."+this.getLogicValidCond();
} }
defaultQueryScript.setBody(sql); defaultQueryScript.setBody(sql);
...@@ -574,4 +635,36 @@ public class POSchema { ...@@ -574,4 +635,36 @@ public class POSchema {
} }
} }
public POSchema writeTo(Path path)
{
return writeTo(this,path);
}
public static POSchema fromPath(Path path)
{
try {
if(!Files.exists(path))
throw new BadRequestAlertException("读取文件失败","POSchema",path.toString());
return JSON.parseObject(Files.readAllBytes(path),POSchema.class);
} catch (Exception e) {
throw new BadRequestAlertException("解析文件失败","POSchema",path.toString());
}
}
public static POSchema writeTo(POSchema poSchema,Path path)
{
try {
File dir=path.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(path, JSON.toJSONBytes(poSchema), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","POSchema",path.toString());
}
return poSchema;
}
} }
package cn.ibizlab.core.data.model; package cn.ibizlab.core.data.model;
import cn.ibizlab.core.data.dto.DataObj; import cn.ibizlab.core.data.dto.DataObj;
import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
...@@ -55,12 +58,28 @@ public class PojoOption extends DataObj ...@@ -55,12 +58,28 @@ public class PojoOption extends DataObj
return this.getStringValue("ds_name",this.getSystem()+"-master"); return this.getStringValue("ds_name",this.getSystem()+"-master");
} }
public List<String> getDsTypes(){
List<String> dsTypes=new ArrayList<>();
String strDsTypes= this.getStringValue("ds_types");
for(String dsType:strDsTypes.split(","))
dsTypes.add(dsType);
return dsTypes;
}
public PojoOption setDsTypes(String dsTypes){
return this.set("ds_types",dsTypes);
}
public String getDefaultQueryScript()
{
return this.getStringValue("default_query_script");
}
public Boolean isLogicValid() { public Boolean isLogicValid() {
return this.getBooleanValue("logicValid"); return this.getBooleanValue("logic_valid");
} }
public PojoOption setLogicValid(Boolean logicValid) { public PojoOption setLogicValid(Boolean logicValid) {
return this.set("logicValid",logicValid); return this.set("logic_valid",logicValid);
} }
public String getLogicVal() public String getLogicVal()
......
...@@ -13,6 +13,7 @@ import lombok.Setter; ...@@ -13,6 +13,7 @@ import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Files; import java.nio.file.Files;
...@@ -326,6 +327,10 @@ public class PojoSchema { ...@@ -326,6 +327,10 @@ public class PojoSchema {
public static PojoSchema writeTo(PojoSchema pojoSchema,Path path) public static PojoSchema writeTo(PojoSchema pojoSchema,Path path)
{ {
try { try {
File dir=path.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(path, JSON.toJSONBytes(pojoSchema), StandardOpenOption.CREATE); Files.write(path, JSON.toJSONBytes(pojoSchema), StandardOpenOption.CREATE);
} catch (Exception e) { } catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","PojoSchema",path.toString()); throw new BadRequestAlertException("保存文件失败","PojoSchema",path.toString());
......
package cn.ibizlab.core.data.model; package cn.ibizlab.core.data.model;
import cn.ibizlab.core.data.lite.EntityModel; import cn.ibizlab.core.data.domain.POModel;
import cn.ibizlab.core.data.lite.FieldModel; import cn.ibizlab.core.data.lite.*;
import cn.ibizlab.core.data.lite.MetaRelationshipModel;
import cn.ibizlab.core.data.lite.RelationshipModel;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.LinkedHashMap;
import java.util.Map;
public class TransUtils { public class TransUtils {
...@@ -119,8 +120,9 @@ public class TransUtils { ...@@ -119,8 +120,9 @@ public class TransUtils {
public static PojoSchema EntityModelModel2Schema(EntityModel entityModel) public static PojoSchema EntityModelModel2Schema(EntityModel entityModel)
{ {
PojoSchema pojoSchema=new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId()) PojoSchema pojoSchema=new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
.setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal())); .setOptions(new PojoOption().setDsTypes(String.join(",",entityModel.getDsTypes())).setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity()))); pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity()))).remove("ext_params");
int order=1; int order=1;
...@@ -134,7 +136,9 @@ public class TransUtils { ...@@ -134,7 +136,9 @@ public class TransUtils {
sub=new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time"); sub=new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time");
else else
sub=new PojoSchema().setType(propType); sub=new PojoSchema().setType(propType);
sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order).setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField())))); sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order)
.setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField()))));
sub.getOptions().remove("ext_params");
if("PICKUP".equals(fieldModel.getField().getFieldType())&&fieldModel.isPhysicalField()) if("PICKUP".equals(fieldModel.getField().getFieldType())&&fieldModel.isPhysicalField())
{ {
if(!StringUtils.isEmpty(sub.getOptions().getRelationCodeName())) if(!StringUtils.isEmpty(sub.getOptions().getRelationCodeName()))
...@@ -162,7 +166,7 @@ public class TransUtils { ...@@ -162,7 +166,7 @@ public class TransUtils {
.set("table_name",rel.getTableName()).set("ds_name",rel.getDataSourceName()).set("relation",JSONObject.parseObject(JSON.toJSONString(rel.getRelation()), MetaRelationshipModel.class)) .set("table_name",rel.getTableName()).set("ds_name",rel.getDataSourceName()).set("relation",JSONObject.parseObject(JSON.toJSONString(rel.getRelation()), MetaRelationshipModel.class))
) )
.setRef((StringUtils.isEmpty(rel.getSystemId())?entityModel.getSystemId():rel.getSystemId())+".domain."+rel.getEntityName()); .setRef("domain."+rel.getEntityName());
pojoSchema.addProperty(sub.getName(),sub); pojoSchema.addProperty(sub.getName(),sub);
order++; order++;
} }
...@@ -182,7 +186,7 @@ public class TransUtils { ...@@ -182,7 +186,7 @@ public class TransUtils {
.set("table_name",nest.getTableName()).set("ds_name",nest.getDataSourceName()).set("relation",JSONObject.parseObject(JSON.toJSONString(nest.getRelation()), MetaRelationshipModel.class)) .set("table_name",nest.getTableName()).set("ds_name",nest.getDataSourceName()).set("relation",JSONObject.parseObject(JSON.toJSONString(nest.getRelation()), MetaRelationshipModel.class))
) )
.setItems(new PojoSchema().setType(PojoSchema.Type.object.getCode()).setName(nest.getEntityName()).setTitle(nest.getEntityLogicName()) .setItems(new PojoSchema().setType(PojoSchema.Type.object.getCode()).setName(nest.getEntityName()).setTitle(nest.getEntityLogicName())
.setRef((StringUtils.isEmpty(nest.getSystemId())?entityModel.getSystemId():nest.getSystemId())+".domain."+nest.getEntityName()) .setRef("domain."+nest.getEntityName())
.setOptions(new PojoOption() .setOptions(new PojoOption()
.set("logic_name",nest.getEntityLogicName()) .set("logic_name",nest.getEntityLogicName())
.set("entity_name",nest.getEntityName()) .set("entity_name",nest.getEntityName())
...@@ -204,7 +208,8 @@ public class TransUtils { ...@@ -204,7 +208,8 @@ public class TransUtils {
public static POSchema PojoSchema2PO(PojoSchema pojoSchema) public static POSchema PojoSchema2PO(PojoSchema pojoSchema)
{ {
POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()).setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal()); POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce())
.setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal());
...@@ -217,7 +222,7 @@ public class TransUtils { ...@@ -217,7 +222,7 @@ public class TransUtils {
Integer length=sub.getOptions().getDataLength(); Integer length=sub.getOptions().getDataLength();
Integer precision=sub.getOptions().getDataPreci(); Integer precision=sub.getOptions().getDataPreci();
POSchema.Column column=new POSchema.Column().setAlias(name).setName(sub.getOptions().getFieldName()).setRemarks(sub.getTitle()).setDefaultValue(sub.getOptions().getDefaultValue()).setPredefined(sub.getOptions().getPredefined()).setLength(length); POSchema.Column column=new POSchema.Column().setName(sub.getOptions().getFieldName()).setAlias(name).setRemarks(sub.getTitle()).setDefaultValue(sub.getOptions().getDefaultValue()).setPredefined(sub.getOptions().getPredefined()).setLength(length);
if(PojoSchema.Type.object.getCode().equals(sub.getType())||PojoSchema.Type.array.getCode().equals(sub.getType())) if(PojoSchema.Type.object.getCode().equals(sub.getType())||PojoSchema.Type.array.getCode().equals(sub.getType()))
{ {
...@@ -289,46 +294,104 @@ public class TransUtils { ...@@ -289,46 +294,104 @@ public class TransUtils {
poSchema.addColumn(column); poSchema.addColumn(column);
} }
String defaultQueryScript=pojoSchema.getOptions().getDefaultQueryScript();
if(!StringUtils.isEmpty(defaultQueryScript))
poSchema.setDefaultQueryScript(defaultQueryScript);
return poSchema; return poSchema;
} }
//
// public static PojoSchema EntityModelModel2PO(EntityModel entityModel,String dbType) { public static POSchema EntityModelModel2PO(EntityModel entityModel,String dsType) {
//
// POSchema poSchema=new POSchema().setName(pojoSchema.getDefaultTableName()).setDefaultDataSource(pojoSchema.getDefaultDataSoruce()).setRemarks(pojoSchema.getTitle()).setLogicVal(pojoSchema.getOptions().getLogicVal()).setLogicDelVal(pojoSchema.getOptions().getLogicDelVal()); final String dataSourceType=dsType.toLowerCase();
// POSchema poSchema=new POSchema().setDsType(dsType).setName(entityModel.getTableName(dsType)).setDefaultDataSource(entityModel.getDsName())
// .setRemarks(entityModel.getLogicName()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal());
// PojoSchema pojoSchema = new PojoSchema().setName(entityModel.getEntityName()).setType("object").setTitle(entityModel.getLogicName()).setId(entityModel.getEntityId())
// .setOptions(new PojoOption().setLogicValid(entityModel.isLogicValid()).setLogicVal(entityModel.getLogicVal()).setLogicDelVal(entityModel.getLogicDelVal()));
// pojoSchema.getOptions().setAll(JSONObject.parseObject(JSON.toJSONString(entityModel.getEntity()))); Map<String,FieldModel> keyMap=new LinkedHashMap<>();
// Map<String,RelationshipModel> relationshipModelMap = new LinkedHashMap<>();
// int order = 1; if(entityModel.getKeyFields()!=null)entityModel.getKeyFields().forEach(model->keyMap.put(model.getColumnName(),model));
// if(entityModel.getReferences()!=null)entityModel.getReferences().forEach(model->relationshipModelMap.put(model.getRelation().getName(),model));
// for (FieldModel fieldModel : entityModel.getFields()) {
// String propType = fieldModel.getPropType(); int order = 1;
// PojoSchema sub = null; for (FieldModel fieldModel : entityModel.getFields()) {
// if ("date".equals(propType)) MetaFieldModel sub=fieldModel.getField();
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date");
// else if ("date-time".equals(propType)) String colName=fieldModel.getColumnName(dataSourceType);
// sub = new PojoSchema().setType(PojoSchema.Type.string.getCode()).setFormat("date-time");
// else String dataType=sub.getDataType();
// sub = new PojoSchema().setType(propType); Integer length=sub.getDataLength();
// sub.setName(fieldModel.getCodeName()).setTitle(fieldModel.getField().getFieldLogicName()).setPropertyOrder(order).setOptions(new PojoOption().setAll(JSONObject.parseObject(JSON.toJSONString(fieldModel.getField())))); Integer precision=sub.getDataPreci();
// if ("PICKUP".equals(fieldModel.getField().getFieldType()) && fieldModel.isPhysicalField()) {
// if (!StringUtils.isEmpty(sub.getOptions().getRelationCodeName())) { POSchema.Column column=new POSchema.Column().setName(colName).setAlias(sub.getCodeName()).setRemarks(sub.getFieldLogicName()).setPredefined(sub.getPredefined()).setLength(length).setType(sub.getDataType());
// RelationshipModel relationshipModel = entityModel.getRefMaps().get(sub.getOptions().getRelationCodeName());
// if (relationshipModel != null && (!StringUtils.isEmpty(relationshipModel.getTableName()))) if(column.isNumber())
// sub.getOptions().setRefTableName(relationshipModel.getTableName()); column.setPrecision(precision);
// }
// if(sub.getNullable()!=null&&sub.getNullable()==0)
// } column.getConstraints(true).setNullable(false);
// pojoSchema.addProperty(sub.getName(), sub);
// order++; if(keyMap.containsKey(column.getName())) {
// } String primaryKeyName="PK_"+poSchema.getName().toUpperCase()+"_"+ column.getName().toUpperCase();
// if(primaryKeyName.length()>30)
// } primaryKeyName=primaryKeyName.substring(0,30);
column.getConstraints(true).setPrimaryKey(true).setPrimaryKeyName(primaryKeyName);
}
if(fieldModel.isLogicValidField())
{
if(!StringUtils.isEmpty(entityModel.getLogicVal()))
column.setDefaultValue(entityModel.getLogicVal());
else
column.setDefaultValue("1");
}
if("PICKUP".equals(sub.getFieldType())&&fieldModel.isPhysicalField())
{
RelationshipModel relationshipModel=relationshipModelMap.get(sub.getRelationName());
String fkName=sub.getRelationName().toUpperCase();
if(relationshipModel!=null&&(!StringUtils.isEmpty(relationshipModel.getTableName()))&&(!StringUtils.isEmpty(fkName))) {
if(fkName.length()>30)
fkName=fkName.substring(0,30);
column.getConstraints(true).setReferencedTableName(relationshipModel.getTableName())
.setReferencedColumnNames(sub.getRefFieldName()).setForeignKeyName(fkName);
poSchema.addForeignKeyConstraint(new POSchema.ForeignKeyConstraint().setConstraintName(fkName)
.setBaseTableName(poSchema.getName()).setBaseColumnNames(column.getName())
.setReferencedTableName(relationshipModel.getTableName()).setReferencedColumnNames(sub.getRefFieldName()));
}
}
if(!fieldModel.isPhysicalField())
poSchema.addTransient(column.setComputed(true));
else
poSchema.addColumn(column);
order++;
}
if(entityModel.getDataSets()!=null)
{
entityModel.getDataSets().forEach(dataSet->{
if(dataSet.getDatasetId().startsWith(entityModel.getEntityName().toLowerCase()+"-")&&dataSet.getDatasetId().endsWith(dataSourceType))
{
POSchema.Segment segment=new POSchema.Segment().setName(dataSet.getDatasetId()).setVendorProvider(dataSourceType).setBody(dataSet.getDsCode());
poSchema.addSegment(segment);
}
else if(!dataSet.getDatasetId().startsWith(entityModel.getEntityName().toLowerCase()+"-"))
{
POSchema.Segment segment=new POSchema.Segment().setName(dataSet.getCodeName()).setVendorProvider(dataSourceType).setBody(dataSet.getDsCode());
poSchema.addSegment(segment);
}
});
}
return poSchema;
}
public static void main(String[] args) { public static void main(String[] args) {
String str="{\"code\":\"CaseInfo\",\"name\":\"案件基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_id\",\"name\":\"请求ID标识\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"req_type\",\"name\":\"业务请求类型\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajbh\",\"name\":\"公共案件编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajmc\",\"name\":\"公共案件名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ab\",\"name\":\"案由代码\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"案由\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"gajgysrdh\",\"name\":\"移送人电话\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"case_status\",\"name\":\"案件状态\",\"required\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"CaseSuspect_List\",\"name\":\"嫌疑人自然人信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSuspect\",\"name\":\"嫌疑人自然人信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"rybh\",\"name\":\"人员编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"rybs\",\"name\":\"公安人员标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"xm\",\"name\":\"姓名\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"SuspectCoercive_List\",\"name\":\"嫌疑人强制措施信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCoercive\",\"name\":\"嫌疑人强制措施信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"cslb\",\"name\":\"强制措施种类代码\",\"required\":false,\"uniqueKeys\":true,\"dict\":\"强制措施种类\",\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}],\"extensions\":{}}},{\"code\":\"SuspectCompany_List\",\"name\":\"涉案单位信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCompany\",\"name\":\"涉案人单位信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"dwmc\",\"name\":\"单位名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSHR_List\",\"name\":\"受害人列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSHR\",\"name\":\"受害人基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"xm\",\"name\":\"姓名\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSAWP_List\",\"name\":\"涉案物品列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSAWP\",\"name\":\"涉案物品信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"sawpmc\",\"name\":\"名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseStatus_List\",\"name\":\"案件移送记录列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"object\",\"model\":{\"code\":\"CaseStatus\",\"name\":\"提请逮捕移送记录\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_dept\",\"name\":\"发送部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_deptname\",\"name\":\"发送部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_dept\",\"name\":\"接收部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_deptname\",\"name\":\"接收部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_time\",\"name\":\"发送时间\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"date\"},{\"code\":\"send_type\",\"name\":\"移送状态\",\"required\":true,\"uniqueKeys\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_type_zh\",\"name\":\"移送状态名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh_zh\",\"name\":\"文书名称\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh\",\"name\":\"移送文书文号\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}]}"; String str="{\"code\":\"CaseInfo\",\"name\":\"案件基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_id\",\"name\":\"请求ID标识\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"req_type\",\"name\":\"业务请求类型\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajbh\",\"name\":\"公共案件编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ajmc\",\"name\":\"公共案件名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"ab\",\"name\":\"案由代码\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"案由\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"gajgysrdh\",\"name\":\"移送人电话\",\"required\":false,\"uniqueKeys\":false,\"dict\":\"\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"case_status\",\"name\":\"案件状态\",\"required\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"CaseSuspect_List\",\"name\":\"嫌疑人自然人信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSuspect\",\"name\":\"嫌疑人自然人信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"rybh\",\"name\":\"人员编号\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"rybs\",\"name\":\"公安人员标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"xm\",\"name\":\"姓名\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"SuspectCoercive_List\",\"name\":\"嫌疑人强制措施信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCoercive\",\"name\":\"嫌疑人强制措施信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"cslb\",\"name\":\"强制措施种类代码\",\"required\":false,\"uniqueKeys\":true,\"dict\":\"强制措施种类\",\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}],\"extensions\":{}}},{\"code\":\"SuspectCompany_List\",\"name\":\"涉案单位信息列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"SuspectCompany\",\"name\":\"涉案人单位信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"gabs\",\"name\":\"公安唯一标识\",\"required\":true,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"dwmc\",\"name\":\"单位名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSHR_List\",\"name\":\"受害人列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSHR\",\"name\":\"受害人基本信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"xm\",\"name\":\"姓名\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseSAWP_List\",\"name\":\"涉案物品列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"nested\",\"model\":{\"code\":\"CaseSAWP\",\"name\":\"涉案物品信息\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"sawpmc\",\"name\":\"名称\",\"required\":false,\"uniqueKeys\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}},{\"code\":\"CaseStatus_List\",\"name\":\"案件移送记录列表\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"object\",\"model\":{\"code\":\"CaseStatus\",\"name\":\"提请逮捕移送记录\",\"group\":\"0预处理/2.预处理接口\",\"propertyList\":[{\"code\":\"send_dept\",\"name\":\"发送部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_deptname\",\"name\":\"发送部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_dept\",\"name\":\"接收部门代码\",\"required\":true,\"dict\":\"单位\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"receive_deptname\",\"name\":\"接收部门名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_time\",\"name\":\"发送时间\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"date\"},{\"code\":\"send_type\",\"name\":\"移送状态\",\"required\":true,\"uniqueKeys\":true,\"dict\":\"案件类型\",\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"send_type_zh\",\"name\":\"移送状态名称\",\"required\":true,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh_zh\",\"name\":\"文书名称\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"},{\"code\":\"wh\",\"name\":\"移送文书文号\",\"required\":false,\"defaultValue\":\"\",\"propertyType\":\"string\"}],\"extensions\":{}}}]}";
......
package cn.ibizlab.core.data.service.impl; package cn.ibizlab.core.data.service.impl;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.nio.file.StandardOpenOption;
import java.util.List; import java.util.*;
import java.util.Collection;
import cn.ibizlab.core.data.lite.EntityModel; import cn.ibizlab.core.data.lite.EntityModel;
import cn.ibizlab.core.data.lite.LiteStorage; import cn.ibizlab.core.data.lite.LiteStorage;
import cn.ibizlab.core.data.model.POSchema;
import cn.ibizlab.core.data.model.PojoSchema; import cn.ibizlab.core.data.model.PojoSchema;
import cn.ibizlab.core.data.model.TransUtils; import cn.ibizlab.core.data.model.TransUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -71,18 +74,56 @@ public class DOModelServiceImpl implements IDOModelService { ...@@ -71,18 +74,56 @@ public class DOModelServiceImpl implements IDOModelService {
String entity=args[2]; String entity=args[2];
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","domain",entity+".json"); Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"domain",entity+".json");
if(!Files.exists(storePath)) if(!Files.exists(storePath))
{ {
EntityModel entityModel= LiteStorage.getEntityModel(system,entity); EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) { if(entityModel!=null) {
schema=TransUtils.EntityModelModel2Schema(entityModel); schema=TransUtils.EntityModelModel2Schema(entityModel);
if(schema!=null) if(schema!=null)
{
for(String dsType:entityModel.getDsTypes())
{
POSchema poSchema=TransUtils.EntityModelModel2PO(entityModel,dsType);
if(poSchema!=null)
{
doModel.addPOSchema(dsType,poSchema);
}
}
if(doModel.getPoSchemas()!=null)
{
Path poPath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"repository",entity+".json");
try {
File dir=poPath.getParent().toFile();
if(!dir.exists())
dir.mkdirs();
Files.write(poPath, JSON.toJSONBytes(doModel.getPoSchemas()), StandardOpenOption.CREATE);
} catch (Exception e) {
throw new BadRequestAlertException("保存文件失败","POSchemas",poPath.toString());
}
}
schema.writeTo(storePath); schema.writeTo(storePath);
}
}
}
else {
schema = PojoSchema.fromPath(storePath);
Path poPath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"repository",entity+".json");
if(Files.exists(poPath))
{
try {
LinkedHashMap map=JSON.parseObject(Files.readAllBytes(poPath), LinkedHashMap.class);
map.keySet().forEach(dsType->{
doModel.addPOSchema(dsType.toString(),JSON.parseObject(JSON.toJSONString(map.get(dsType)),POSchema.class));
});
} catch (IOException e) {
}
} }
} }
else
schema=PojoSchema.fromPath(storePath);
if(schema!=null) if(schema!=null)
......
...@@ -68,12 +68,14 @@ public class DTOModelServiceImpl implements IDTOModelService { ...@@ -68,12 +68,14 @@ public class DTOModelServiceImpl implements IDTOModelService {
String system=args[0]; String system=args[0];
String dto=args[2]; String dto=args[2];
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo","dto",dto+".json"); String entity=dto;
if(entity.endsWith("DTO"))
entity=entity.substring(0,entity.length()-3);
Path storePath = Paths.get(LiteStorage.MODEL_PATH,system,"repo",entity,"dto",dto+".json");
if(!Files.exists(storePath)) if(!Files.exists(storePath))
{ {
String entity=dto;
if(entity.endsWith("DTO"))
entity=entity.substring(0,entity.length()-3);
EntityModel entityModel= LiteStorage.getEntityModel(system,entity); EntityModel entityModel= LiteStorage.getEntityModel(system,entity);
if(entityModel!=null) { if(entityModel!=null) {
schema= TransUtils.EntityModelModel2Schema(entityModel); schema= TransUtils.EntityModelModel2Schema(entityModel);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册