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

提交

上级 7e114063
package cn.ibizlab.core.extensions.mapper;
import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.EntityObj;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -12,4 +14,20 @@ public interface DbEntityMapper extends BaseMapper<EntityObj>{
List<EntityObj> search(@Param("sql") String sql, @Param("ew") Wrapper<EntityObj> wrapper);
Integer searchCount(@Param("sql") String sql, @Param("ew") Wrapper<EntityObj> wrapper);
@Insert({"<script> "+" MERGE INTO ${model.tableName} T1\n" +
" USING (\n" +
"<foreach collection=\"list\" item=\"item\" index=\"index\" separator=\"UNION ALL\">\n" +
" SELECT ${model.mergeColumnSegment} FROM dual\n" +
"</foreach>\n" +
" ) T2 \n ${model.mergeSegment}"+
"</script>"})
boolean saveBatch(@Param("model") EntityModel model, @Param("list") List<EntityObj> list);
@Insert({"<script> "+" MERGE INTO ${model.tableName} T1\n" +
" USING (\n" +
" SELECT ${model.mergeColumnSegment} FROM dual\n" +
" ) T2 \n ${model.mergeSegment}"+
"</script>"})
boolean save(@Param("model") EntityModel model, @Param("entity") EntityObj entity);
}
\ No newline at end of file
......@@ -106,6 +106,24 @@ public class EntityModel {
@JsonIgnore
@JSONField(serialize = false)
private boolean isLogicValid=true;
@JsonIgnore
@JSONField(serialize = false)
public boolean isLogicValid()
{
if(isLogicValid&&logicValidField==null) {
if (fields != null) {
for (FieldModel fieldModel : fields) {
if (fieldModel.isLogicValidField()) {
logicValidField = fieldModel;
return isLogicValid;
}
}
}
isLogicValid = false;
}
return isLogicValid;
}
@JsonIgnore
@JSONField(serialize = false)
private FieldModel logicValidField;
......@@ -182,6 +200,18 @@ public class EntityModel {
return unionKeyFields;
}
@JsonIgnore
@JSONField(serialize = false)
public List<FieldModel> getKeyFields() {
if(this.getKeyField()!=null&&this.getKeyField().isPhysicalField()) {
List<FieldModel> keyFields = new ArrayList<>();
keyFields.add(getKeyField());
return keyFields;
}
else
return getUnionKeyFields();
}
public FieldModel getField(String name)
{
if(StringUtils.isEmpty(name))
......@@ -239,6 +269,91 @@ public class EntityModel {
return "";
}
@JsonIgnore
@JSONField(serialize = false)
public String getMergeColumnSegment()
{
String sql="";
boolean first=true;
for(FieldModel fieldModel:this.getFields())
{
if(!fieldModel.isPhysicalField())
continue;
if(first)
first=false;
else
sql+=",";
sql+=("#{item."+fieldModel.getColumnName().toUpperCase()+"} "+fieldModel.getColumnName().toUpperCase());
}
return sql;
}
@JsonIgnore
@JSONField(serialize = false)
public String getMergeSegment()
{
String sql="";
sql+= " ON (";
boolean first=true;
for(FieldModel fieldModel:this.getKeyFields())
{
if(!fieldModel.isPhysicalField())
continue;
if(first)
first=false;
else
sql+=" and ";
sql+=("T1."+fieldModel.getColumnName().toUpperCase()+"=T2."+fieldModel.getColumnName().toUpperCase());
}
sql+=")\n" +
" WHEN NOT MATCHED THEN INSERT(";
first=true;
for(FieldModel fieldModel:this.getFields())
{
if(!fieldModel.isPhysicalField())
continue;
if(first)
first=false;
else
sql+=",";
sql+=(fieldModel.getColumnName().toUpperCase());
}
sql+=") VALUES (" ;
first=true;
for(FieldModel fieldModel:this.getFields())
{
if(!fieldModel.isPhysicalField())
continue;
if(first)
first=false;
else
sql+=",";
sql+=("T2."+fieldModel.getColumnName().toUpperCase());
}
sql+=")\n" +
" WHEN MATCHED THEN UPDATE SET " ;
first=true;
for(FieldModel fieldModel:this.getFields())
{
if(!fieldModel.isPhysicalField())
continue;
if(fieldModel.isKeyField())
continue;
if(fieldModel.isUnionKeyField())
continue;
if(first)
first=false;
else
sql+=",";
sql+=("T1."+fieldModel.getColumnName().toUpperCase()+"=T2."+fieldModel.getColumnName().toUpperCase());
}
return sql;
}
@JsonIgnore
@JSONField(serialize = false)
public String getDsName()
......
......@@ -14,6 +14,15 @@ import java.util.List;
public class EntityObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField(serialize = false)
public EntityObj copy() {
EntityObj copy=new EntityObj();
this.copyTo(copy,true);
if(this.property!=null)
copy.setProperty(this.property);
return copy;
}
@JsonIgnore
@JSONField(serialize = false)
......@@ -158,11 +167,14 @@ public class EntityObj extends DataObj<String,Object> {
tmps.remove(modelObj.getRowKey());
});
});
if(tmps.size()>0)
if(tmps.size()==1)
{
tmps.values().iterator().next().setEntity(this.getProperty().getPropertyName(),this);
}
else if(tmps.size()>1)
{
tmps.values().forEach(obj->{
EntityObj copy=this.copyTo(new EntityObj(),true).setProperty(this.getProperty());
obj.setEntity(this.getProperty().getPropertyName(),copy);
obj.setEntity(this.getProperty().getPropertyName(),this.copy());
});
}
}
......@@ -171,6 +183,8 @@ public class EntityObj extends DataObj<String,Object> {
{
if(!this.getEntityModel().isLogicValid())
return false;
if(this.getEntityModel().getLogicValidField()==null)
return false;
if(this.getEntityModel().getLogicVal().equals(this.get(this.getEntityModel().getLogicValidField().getColumnName())))
return false;
return true;
......
......@@ -33,7 +33,7 @@ public class FieldModel {
@JSONField(serialize = false)
public String getColumnExp()
{
if(1==field.getPhysicalField())
if(field.getPhysicalField()!=null && 1==field.getPhysicalField())
{
return columnName+" as \""+columnName.toUpperCase()+"\"";
}
......@@ -48,14 +48,14 @@ public class FieldModel {
@JSONField(serialize = false)
public boolean isPhysicalField()
{
return 1==this.getField().getPhysicalField();
return this.getField().getPhysicalField()!=null && 1==this.getField().getPhysicalField();
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isKeyField()
{
return 1==this.getField().getKeyField();
return this.getField().getKeyField()!=null && 1==this.getField().getKeyField();
}
@JsonIgnore
......@@ -72,6 +72,13 @@ public class FieldModel {
return "UPDATEDATE".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isCreateTimeField()
{
return "CREATEDATE".equals(this.getField().getPredefined());
}
@JsonIgnore
@JSONField(serialize = false)
public boolean isUnionKeyField()
......
package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.helper.RuleUtils;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.List;
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class FieldObj {
public DataModel getDataModel()
{
if(property!=null)
return property.getOwnerDataModel();
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public String getDataModelName()
{
if(getDataModel()!=null&&getDataModel().getDataModelName()!=null)
return getDataModel().getDataModelName();
else
return "";
}
@JsonIgnore
@JSONField(serialize = false)
private Property property;
public FieldObj setProperty(Property property)
{
this.property=property;
return this;
}
private String columnName;
private Object value;
public <T> T getValue(T defaultVal)
{
return getValue(null,defaultVal);
}
public <T> T getValue(Class<T> type,T defaultVal)
{
T ret=defaultVal;
if(value==null)
return ret;
Object obj=null;
if((!(defaultVal instanceof List))&&(value instanceof List))
{
for(Object item:(List)value){
if(item!=null) {
if(obj==null|| RuleUtils.gt(obj,item))
obj = item;
}
}
if(obj==null)
return defaultVal;
}
else
{
obj=value;
}
if(type == null && defaultVal != null)
type = (Class<T>) defaultVal.getClass();
ret = DataObject.valueOf(type,obj);
if(ret==null)
return defaultVal;
return ret;
}
public <T> T getItemValue(int idx,Class<T> type,T defaultVal)
{
if(value instanceof List)
{
List list=(List)value;
if(list.size()>idx)
{
T ret=DataObject.valueOf(type,list.get(idx));
if(ret==null)
return defaultVal;
return ret;
}
return defaultVal;
}
else
return getValue(type,defaultVal);
}
@JsonIgnore
@JSONField(serialize = false)
public String getValues()
{
String rt="";
if(value!=null && value instanceof List)
{
for(Object item:(List)value){
if(item!=null) {
if((!StringUtils.isEmpty(rt))&&(!rt.endsWith(",")))
rt=rt+",";
rt = rt+DataObject.getStringValue(item,"");
}
}
}
else
{
rt=DataObject.getStringValue(value,"");
}
return rt;
}
@JsonIgnore
@JSONField(serialize = false)
public Integer getCount()
{
return getCount(true);
}
@JsonIgnore
@JSONField(serialize = false)
public Integer getCount(boolean includeNull)
{
if(includeNull)
{
if(value instanceof List)
return ((List) value).size()==0?1:((List) value).size();
else
return 1;
}
if(value==null)
return 0;
else if(value instanceof List)
{
List list = (List)value;
int cnt=0;
for(Object item:list)
cnt+=StringUtils.isEmpty(DataObject.getStringValue(list.get(0),null))?0:1;
return cnt;
}
else
return StringUtils.isEmpty(value.toString())?0:1;
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isEmpty()
{
return getCount(false)==0;
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isNotEmpty()
{
return !isEmpty();
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isMultiple()
{
return getCount()>1;
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isSingle()
{
return !isMultiple();
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isSingleAndNotEmpty()
{
return isSingle()&&isNotEmpty();
}
@JsonIgnore
@JSONField(serialize = false)
public BigDecimal getDecimal()
{
BigDecimal decimal = new BigDecimal(1);
Object val = this.getValue(Object.class,null);
if(val == null)
decimal=(new BigDecimal(1));
else if ( (val instanceof BigDecimal))
decimal=(((BigDecimal) val));
else if (val instanceof Double)
decimal=(new BigDecimal((Double) val));
else if (val instanceof Float)
decimal=(new BigDecimal(((Float) val).doubleValue()));
else if (val instanceof Integer)
decimal=(new BigDecimal((int)val));
else if (val instanceof Long)
decimal=(new BigDecimal((Long)val));
if(decimal.intValue()>Integer.MAX_VALUE)
decimal=(new BigDecimal(1));
return decimal;
}
public BigDecimal getItemDecimal(int idx)
{
BigDecimal decimal = new BigDecimal(1);
Object val = this.getItemValue(idx,Object.class,null);
if(val == null)
decimal=(new BigDecimal(1));
else if ( (val instanceof BigDecimal))
decimal=(((BigDecimal) val));
else if (val instanceof Double)
decimal=(new BigDecimal((Double) val));
else if (val instanceof Float)
decimal=(new BigDecimal(((Float) val).doubleValue()));
else if (val instanceof Integer)
decimal=(new BigDecimal((int)val));
else if (val instanceof Long)
decimal=(new BigDecimal((Long)val));
if(decimal.intValue()>Integer.MAX_VALUE)
decimal=(new BigDecimal(1));
return decimal;
}
@Override
public String toString()
{
return getValues();
}
public static void main(String[] args)
{
FieldObj fieldObj=new FieldObj();
fieldObj.setValue(new BigDecimal(1));
Object t=fieldObj.getValue(Object.class,null);
System.out.println(t);
}
}
......@@ -19,6 +19,45 @@ import java.util.List;
public class ModelObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField(serialize = false)
public ModelObj copy() {
ModelObj copy=new ModelObj();
if(this.dataModel!=null)
copy.setDataModel(this.dataModel);
if(copy.getDataModel()!=null)
{
copy.getDataModel().getObjectProperties().forEach(property -> {
Object obj=this.get(property.getPropertyName());
if(obj!=null&&obj instanceof EntityObj)
{
copy.setEntity(property.getPropertyName(),((EntityObj)obj).copy());
}
});
copy.getDataModel().getNestedDataModels().forEach(dm -> {
Object list=this.get(dm.getDataModelName());
if(list!=null&&list instanceof NestedArray)
{
NestedArray nestedArray=(NestedArray) list;
nestedArray.forEach(sub->{
sub.copy().setParent(copy);
});
}
});
}
if(!StringUtils.isEmpty(this.getRowKey()))
copy.setRowKey(this.getRowKey());
return copy;
}
@JsonIgnore
@JSONField(serialize = false)
private DataModel dataModel;
......@@ -270,12 +309,19 @@ public class ModelObj extends DataObj<String,Object> {
{
this.setParent(tmps.values().iterator().next());
}
else if(tmps.size()>1)
{
tmps.values().forEach(parent -> {
ModelObj copy = this.copy().setTimestamp(this.getTimestamp());
copy.setParent(parent);
});
}
return this;
}
public Object $(String key)
public FieldObj $(String key)
{
if(key.toString().indexOf(".")>0)
{
......@@ -285,13 +331,16 @@ public class ModelObj extends DataObj<String,Object> {
String name=epair[0];
String column=epair[1];
Property property=this.getDataModel().findObjectProperty(name,"UP");
if(property!=null)
return this.getEntity(name).get(column);
if(property!=null) {
Object val=this.getEntity(name).get(column);
return new FieldObj().setValue(val).setProperty(property);
}
property=this.getDataModel().findObjectProperty(name,"DOWN");
if(property!=null)
{
return this.getNested(property.getOwnerDataModel().getDataModelName()).get(key);
Object val=this.getNested(property.getOwnerDataModel().getDataModelName()).get(key);
return new FieldObj().setValue(val).setProperty(property);
}
if(this.getParent()!=null)
......@@ -300,21 +349,33 @@ public class ModelObj extends DataObj<String,Object> {
}
}
return get(key);
return new FieldObj().setValue(get(key)).setProperty(this.getDataModel().getFactPorperty());
}
public Double $D(String key)
@JsonIgnore
@JSONField(serialize = false)
private FieldObj empty;
@JsonIgnore
@JSONField(serialize = false)
public FieldObj getEmpty()
{
Object val=this.get(key);
if(val==null)
return 0d;
else if((val instanceof Integer)||(val instanceof Double)||(val instanceof Long)||(val instanceof BigDecimal)||(val instanceof BigInteger)||(val instanceof Float))
return (double)val;
if(empty==null)
empty=new FieldObj().setValue(null).setProperty(this.getDataModel().getFactPorperty());
return empty;
}
return 1d;
public FieldObj $S(String val)
{
return new FieldObj().setValue(val).setProperty(this.getDataModel().getFactPorperty());
}
@JsonIgnore
@JSONField(serialize = false)
public FieldObj $K()
{
return new FieldObj().setValue(this.getRowKey()).setProperty(this.getDataModel().getFactPorperty());
}
public boolean IF(String cond)
......@@ -413,6 +474,17 @@ public class ModelObj extends DataObj<String,Object> {
return null;
}
@JsonIgnore
@JSONField(serialize = false)
public Boolean isDelete()
{
if(dataModel!=null&&dataModel.getFactPorperty()!=null)
{
return getFactEntity().isDelete();
}
return false;
}
}
......@@ -12,6 +12,7 @@ import java.util.List;
public class NestedArray extends ArrayList<ModelObj> {
@JsonIgnore
@JSONField(serialize = false)
private DataModel dataModel;
......
......@@ -18,6 +18,10 @@ public interface CommonEntityService {
List<EntityObj> search(String dsName, String sql, QueryFilter filter);
boolean saveBatch(EntityModel entityModel, List<EntityObj> list);
boolean save(EntityModel entityModel, EntityObj entityObj);
EntityObj get(EntityModel entityModel, EntityObj entityObj);
void processList(DataModel dataModel, Timestamp lastModify, LiteDataCallback callback);
......
......@@ -146,8 +146,64 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
}
}
@Override
public boolean saveBatch(EntityModel entityModel, List<EntityObj> list) {
try {
dstDataSourceService.initDataSource(entityModel.getDsName());
DynamicDataSourceContextHolder.push(entityModel.getDsName());
list.forEach(entityObj -> {
entityObj.keySet().forEach(key -> {
if(!key.toUpperCase().equals(key))
entityObj.put(key.toUpperCase(),entityObj.get(key));
});
});
return baseMapper.saveBatch(entityModel, list);
} catch (Exception ex) {
log.error("详细错误信息:" + ex.getMessage() + ", 执行sql:" + entityModel.getTableName());
return false;
} finally {
DynamicDataSourceContextHolder.poll();
}
}
@Override
public boolean save(EntityModel entityModel, EntityObj entityObj) {
try {
dstDataSourceService.initDataSource(entityModel.getDsName());
DynamicDataSourceContextHolder.push(entityModel.getDsName());
entityObj.keySet().forEach(key -> {
if(!key.toUpperCase().equals(key))
entityObj.put(key.toUpperCase(),entityObj.get(key));
});
return baseMapper.save(entityModel, entityObj);
} catch (Exception ex) {
log.error("详细错误信息:" + ex.getMessage() + ", 执行sql:" + entityModel.getTableName());
return false;
} finally {
DynamicDataSourceContextHolder.poll();
}
}
@Override
public EntityObj get(EntityModel entityModel, EntityObj entityObj) {
QueryFilter filter=QueryFilter.createQuery();
entityModel.getKeyFields().forEach(item->{
Object val=entityObj.get(item.getColumnName());
if(val!=null)
{
filter.eq(item.getColumnName().toUpperCase(),val);
}
});
List<EntityObj> list=this.selectBase(entityModel,filter);
if(list.size()==1)
entityObj.putAll(list.get(0));
return entityObj;
}
@Autowired
......@@ -169,6 +225,11 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
callback.total(total);
//没有业务数据时,不进行后续操作
if(total == 0){
return;
}
MyBatisCursorItemReader myMyBatisCursorItemReader =new MyBatisCursorItemReader();
try{
......@@ -189,7 +250,7 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
dstDataSourceService.initDataSource(entityModel.getDsName());
DynamicDataSourceContextHolder.push(entityModel.getDsName());
myMyBatisCursorItemReader.open(new ExecutionContext()); // 开启游标
DynamicDataSourceContextHolder.poll();
//DynamicDataSourceContextHolder.poll();
List<EntityObj> datas = new ArrayList<>();
EntityObj rowdata;
while ((rowdata = (EntityObj) myMyBatisCursorItemReader.read()) != null) {
......
......@@ -56,12 +56,37 @@ public class LiteDataService {
}
public boolean saveBatch(String systemId, String entityName, List<EntityObj> list) {
EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName);
splitList(list, 500).forEach(objs->{
getEntityService(entityModel.getDsName()).saveBatch(entityModel,objs);
});
return true;
}
public boolean save(String systemId, String entityName, EntityObj entityObj) {
EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName);
return getEntityService(entityModel.getDsName()).save(entityModel,entityObj);
}
public EntityObj get(String systemId, String entityName, EntityObj entityObj) {
EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName);
return getEntityService(entityModel.getDsName()).get(entityModel,entityObj);
}
public List<EntityObj> search(String systemId, String entityName, QueryFilter filter) {
return search(systemId,entityName,"BASE",filter);
}
public List<EntityObj> search(String systemId, String entityName, String dataset,QueryFilter filter) {
EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName);
return getEntityService(entityModel.getDsName()).search(dataset,entityModel,filter);
}
public void processDataModel(String metaModelId,Timestamp lastModify,LiteDataCallback callback)
{
DataModel dataModel= JSON.toJavaObject(JSON.parseObject(metaModelService.get(metaModelId).getConfig()), DataModel.class);
DataModel dataModel= liteModelService.getDataModel(metaModelId);
EntityModel entityModel = dataModel.getFactEntityModel();
getEntityService(entityModel.getDsName()).processList(dataModel,lastModify,callback);
}
......
......@@ -8,12 +8,16 @@ import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import cn.ibizlab.core.lite.extensions.domain.RelationshipModel;
import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.core.lite.extensions.model.PropertyMapping;
import cn.ibizlab.core.lite.extensions.util.LiteStorage;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.util.domain.FileItem;
import cn.ibizlab.util.errors.InternalServerErrorException;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -182,8 +186,40 @@ public class LiteModelService {
public DataModel getDataModel(String dataModelId)
{
String cfg=metaModelService.get(dataModelId).getConfig();
DataModel dataModel = JSON.toJavaObject(JSON.parseObject(metaModelService.get(dataModelId).getConfig()),DataModel.class);
dataModel.setModelString(cfg);
JSONObject model=JSON.parseObject(metaModelService.get(dataModelId).getConfig());
String factPropertyName="";
String factSystem="";
if(model.containsKey("objectProperties"))
{
JSONArray objProps=model.getJSONArray("objectProperties");
if(objProps.size()>0)
{
JSONObject factObject=objProps.getJSONObject(0);
factPropertyName=factObject.getString("propertyName");
factSystem=factObject.getString("system");
if("tyyw2plus".equals(factSystem))
{
String aj="{\"propertyName\":\"DL_GG_AJXX2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJXX2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"T_TYYW_XJ_YSGS_AJ\",\"joinPropertyColumn\":\"BMSAH\"}]}";
String blry="{\"dataModelName\":\"AJBLRY\",\"objectProperties\":[{\"propertyName\":\"DL_GG_AJBLRY2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJBLRY2\"}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}";
String wshz="{\"dataModelName\":\"AJWSHZ\",\"objectProperties\":[{\"propertyName\":\"JCNJ_YX_AJJZWJ\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"JCNJ_YX_AJJZWJ\"},{\"propertyName\":\"YX_WS_NR2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"YX_WS_NR2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"JCNJ_YX_AJJZWJ\",\"joinPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"WSBH\",\"joinPropertyName\":\"JCNJ_YX_AJJZWJ\",\"joinPropertyColumn\":\"JZWJH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}";
String jzhz="{\"dataModelName\":\"AJDZJZJBXX\",\"objectProperties\":[{\"propertyName\":\"DZJZ_YX_JZML\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DZJZ_YX_JZML\"},{\"propertyName\":\"YX_DZJZ_NR2\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"YX_DZJZ_NR2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"DZJZ_YX_JZML\",\"joinPropertyColumn\":\"BMSAH\"},{\"selfPropertyColumn\":\"MLBH\",\"joinPropertyName\":\"DZJZ_YX_JZML\",\"joinPropertyColumn\":\"MLBH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}";
String glaj="{\"dataModelName\":\"AJGLHZ\",\"objectProperties\":[{\"propertyName\":\"AJ_YX_GLAJJL\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"AJ_YX_GLAJJL\"},{\"propertyName\":\"YAJ_XX\",\"system\":\"tyyw2plus\",\"propertyEntity\":\"DL_GG_AJXX2\",\"propertyMappings\":[{\"selfPropertyColumn\":\"BMSAH\",\"joinPropertyName\":\"AJ_YX_GLAJJL\",\"joinPropertyColumn\":\"YAJ_BMSAH\"}]}],\"layerMappings\":[{\"selfPropertyColumn\":\"GLAJ_BMSAH\",\"parentPropertyColumn\":\"BMSAH\"}]}";
objProps.add(JSON.parseObject(aj));
if(!model.containsKey("nestedDataModels"))
model.put("nestedDataModels",new JSONArray());
JSONArray nested=model.getJSONArray("nestedDataModels");
nested.add(JSON.parseObject(blry));
nested.add(JSON.parseObject(wshz));
nested.add(JSON.parseObject(jzhz));
nested.add(JSON.parseObject(glaj));
}
}
}
DataModel dataModel = JSON.toJavaObject(model,DataModel.class);
dataModel.setModelString(JSON.toJSONString(model));
return dataModel;
}
......
......@@ -39,6 +39,20 @@ public class MongoEntityService implements CommonEntityService{
return null;
}
@Override
public boolean saveBatch(EntityModel entityModel, List<EntityObj> list) {
return false;
}
@Override
public boolean save(EntityModel entityModel, EntityObj entityObj) {
return false;
}
@Override
public EntityObj get(EntityModel entityModel, EntityObj entityObj) {
return null;
}
@Override
......
......@@ -10,13 +10,18 @@ import cn.ibizlab.core.lite.extensions.service.LiteCoreService;
import cn.ibizlab.core.lite.extensions.service.LiteDataService;
import cn.ibizlab.core.lite.extensions.service.LiteModelService;
import cn.ibizlab.core.lite.filter.MetaFieldSearchContext;
import cn.ibizlab.core.lite.service.*;
import cn.ibizlab.core.lite.service.IDstComponentService;
import cn.ibizlab.core.lite.service.IDstConfigService;
import cn.ibizlab.core.lite.service.IMetaEntityService;
import cn.ibizlab.core.lite.service.IMetaFieldService;
import cn.ibizlab.util.client.IBZDictFeignClient;
import cn.ibizlab.util.dict.CodeItem;
import cn.ibizlab.util.dict.CodeList;
import cn.ibizlab.util.dict.Option;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.filter.QueryFilter;
import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.security.AuthenticationUser;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -33,7 +38,11 @@ import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.sql.Wrapper;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
......@@ -62,8 +71,8 @@ public class LiteCoreResource {
@Autowired
private DbEntityService dbEntityService;
@RequestMapping(method = RequestMethod.GET, value = "/dst/test/{modelid}/data/{key}")
public ResponseEntity<ModelObj> getstr(@PathVariable(name="modelid",required = false) String modelid,@PathVariable(name="key",required = false) String key)
@RequestMapping(method = RequestMethod.GET, value = "/lite/datamodels/{modelid}/data/{key}")
public ResponseEntity<ModelObj> getModelObj(@PathVariable(name="modelid",required = false) String modelid,@PathVariable(name="key",required = false) String key)
{
if(StringUtils.isEmpty(modelid))
......@@ -189,6 +198,31 @@ public class LiteCoreResource {
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = {"/lite/datamodels/{modelid}/allpropertys"})
public ResponseEntity<List<Option>> getDataModelParentProperty(@PathVariable(name="modelid",required = false) String modelid)
{
List<Option> list = new ArrayList<>();
liteModelService.getDataModel(modelid).getAllProperty().forEach(property -> {
Option option = new Option().setId(property.getPropertyName()).setLabel(property.getEntityModel().getLogicName()+"["+property.getPropertyName()+"]");
list.add(option);
});
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = {"/lite/datamodels/{modelid}/allpropertys/{propertyname}/fields"})
public ResponseEntity<List<Option>> getDataModelField(@PathVariable(name="modelid",required = false) String modelid,
@PathVariable(name="propertyname",required = false) String propertyname,
@PathVariable(name="fieldname",required = false) String fieldname)
{
List<Option> list = new ArrayList<>();
Property property=liteModelService.getDataModel(modelid).findObjectProperty(propertyname,"ALL");
property.getEntityModel().getFields().forEach(field -> {
Option option = new Option().setId(property.getPropertyName()+"."+field.getColumnName()).setLabel(field.getComment()+"["+field.getColumnName()+"]");
list.add(option);
});
return ResponseEntity.ok(list);
}
@Autowired
private IBZDictFeignClient dictFeignClient;
......@@ -259,6 +293,34 @@ public class LiteCoreResource {
return ResponseEntity.status(HttpStatus.OK).body(liteModelService.getEntityModel(system,entity).getNesteds());
}
@RequestMapping(method = RequestMethod.POST, value = "/lite/{system}/entitys/{entity}/get")
public ResponseEntity<EntityObj> getEntity(@PathVariable("system") String system, @PathVariable("entity") String entity, HttpServletRequest request) {
Map<String, String[]> params = request.getParameterMap();
EntityObj entityObj = new EntityObj();
for (String key : params.keySet()) {
entityObj.set(key.toUpperCase(),params.get(key)[0]);
}
return ResponseEntity.status(HttpStatus.OK).body(liteDataService.get(system,entity,entityObj));
}
@RequestMapping(method = RequestMethod.POST, value = "/lite/{system}/entitys/{entity}/search{dataset}")
public ResponseEntity<List<EntityObj>> searchEntity(@PathVariable("system") String system, @PathVariable("entity") String entity, @PathVariable(value = "dataset",required = false) String dataset,@RequestBody QueryFilter filter) {
if(StringUtils.isEmpty(dataset))
dataset="BASE";
return ResponseEntity.status(HttpStatus.OK).body(liteDataService.search(system,entity,filter));
}
@RequestMapping(method = RequestMethod.POST, value = "/lite/{system}/entitys/{entity}/save")
public ResponseEntity<Boolean> saveEntity(@PathVariable("system") String system, @PathVariable("entity") String entity,@RequestBody EntityObj entityObj) {
return ResponseEntity.status(HttpStatus.OK).body(liteDataService.save(system,entity,entityObj));
}
@RequestMapping(method = RequestMethod.POST, value = "/lite/{system}/entitys/{entity}/batch")
public ResponseEntity<Boolean> saveEntity(@PathVariable("system") String system, @PathVariable("entity") String entity,@RequestBody List<EntityObj> list) {
return ResponseEntity.status(HttpStatus.OK).body(liteDataService.saveBatch(system,entity,list));
}
@RequestMapping(method = RequestMethod.GET, value = "/lite/{app}/components/{component}")
public ResponseEntity<JSON> getComponent(@PathVariable("app") String app, @PathVariable("component") String component) {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册