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

提交

上级 83aaef7c
...@@ -3,6 +3,7 @@ package cn.ibizlab.core.lite.extensions.domain; ...@@ -3,6 +3,7 @@ package cn.ibizlab.core.lite.extensions.domain;
import cn.ibizlab.util.domain.DTOBase; import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.EntityBase; import cn.ibizlab.util.domain.EntityBase;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.util.helper.DataObject;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -61,6 +62,17 @@ public class DataObj<K,V> extends HashMap<K,V> { ...@@ -61,6 +62,17 @@ public class DataObj<K,V> extends HashMap<K,V> {
return DataObject.getJSONObjectValue(this.get(strParamName),jDefault); return DataObject.getJSONObjectValue(this.get(strParamName),jDefault);
} }
public <T> List<T> getListValue(String strParamName,Class<T> clazz)
{
List<T> list= new ArrayList<>();
Object val=this.get(strParamName);
if(val != null && val instanceof List)
{
list=JSONArray.parseArray(JSON.toJSONString(val),clazz);
}
return list;
}
public List<String> getListValue( String strParamName) { public List<String> getListValue( String strParamName) {
return DataObject.getListValue(strParamName); return DataObject.getListValue(strParamName);
} }
......
...@@ -58,7 +58,7 @@ public class EntityModel { ...@@ -58,7 +58,7 @@ public class EntityModel {
return getEntity().getSystemId(); return getEntity().getSystemId();
} }
private MetaEntity entity; private MetaEntityModel entity;
private List<MetaDataSet> dataSets; private List<MetaDataSet> dataSets;
......
...@@ -179,8 +179,24 @@ public class EntityObj extends DataObj<String,Object> { ...@@ -179,8 +179,24 @@ public class EntityObj extends DataObj<String,Object> {
} }
} }
@JsonIgnore
@JSONField(serialize = false)
public boolean isEmpty()
{
int cnt=0;
for(String key:keySet())
{
if(!key.startsWith("_"))
cnt++;
}
return cnt==0;
}
public boolean isDelete() public boolean isDelete()
{ {
if(this.getEntityModel()==null)
return false;
if(!this.getEntityModel().isLogicValid()) if(!this.getEntityModel().isLogicValid())
return false; return false;
if(this.getEntityModel().getLogicValidField()==null) if(this.getEntityModel().getLogicValidField()==null)
......
...@@ -25,7 +25,7 @@ public class FieldModel { ...@@ -25,7 +25,7 @@ public class FieldModel {
private String comment; private String comment;
private MetaField field; private MetaFieldModel field;
private RelationshipModel reference; private RelationshipModel reference;
......
package cn.ibizlab.core.lite.extensions.domain; package cn.ibizlab.core.lite.extensions.domain;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
/** /**
...@@ -85,6 +87,32 @@ public class MetaEntityModel{ ...@@ -85,6 +87,32 @@ public class MetaEntityModel{
@JSONField(name = "module_name") @JSONField(name = "module_name")
@JsonProperty("module_name") @JsonProperty("module_name")
private String moduleName; private String moduleName;
/**
* 扩展参数
*/
@JSONField(name = "ext_params")
@JsonProperty("ext_params")
private String extParams;
/**
* 排序
*/
@JSONField(name = "show_order")
@JsonProperty("show_order")
private Integer showOrder;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "createdate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
private Timestamp createdate;
/**
* 最后修改时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
@JSONField(name = "updatedate", format = "yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
private Timestamp updatedate;
/** /**
* 数据集 * 数据集
......
...@@ -4,6 +4,7 @@ import cn.ibizlab.core.lite.extensions.model.DataModel; ...@@ -4,6 +4,7 @@ import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property; import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.util.helper.DataObject; import cn.ibizlab.util.helper.DataObject;
import cn.ibizlab.util.helper.RuleUtils; import cn.ibizlab.util.helper.RuleUtils;
import com.alibaba.fastjson.JSON;
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 org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -11,13 +12,97 @@ import org.springframework.util.StringUtils; ...@@ -11,13 +12,97 @@ import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.*;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
public class ModelObj extends DataObj<String,Object> { public class ModelObj extends DataObj<String,Object> {
public ModelObj(ModelObj modelObj)
{
if(modelObj.dataModel!=null)
this.setDataModel(modelObj.dataModel);
if(this.getDataModel()!=null)
{
this.getDataModel().getObjectProperties().forEach(property -> {
Object obj=modelObj.get(property.getPropertyName());
if(obj!=null&&obj instanceof EntityObj)
{
this.setEntity(property.getPropertyName(),((EntityObj)obj).copy());
}
});
this.getDataModel().getNestedDataModels().forEach(dm -> {
Object list=modelObj.get(dm.getDataModelName());
if(list!=null&&list instanceof NestedArray)
{
NestedArray nestedArray=(NestedArray) list;
nestedArray.forEach(sub->{
sub.copy().setParent(this);
});
}
});
}
if(!StringUtils.isEmpty(modelObj.getRowKey()))
this.setRowKey(modelObj.getRowKey());
}
public ModelObj()
{
}
public ModelObj build(DataModel dataModel)
{
this.setDataModel(dataModel);
if(this.getDataModel()!=null)
{
this.getDataModel().getObjectProperties().forEach(property -> {
Object obj=this.get(property.getPropertyName());
if(obj!=null&&obj instanceof EntityObj)
{
}
else if(obj!=null&&obj instanceof Map)
{
this.setEntity(property.getPropertyName(), JSON.parseObject(JSON.toJSONString(obj),EntityObj.class));
}
});
this.getDataModel().getNestedDataModels().forEach(dm -> {
Object list=this.get(dm.getDataModelName());
if(list!=null&&list instanceof NestedArray)
{
}
else if(list!=null&&list instanceof List)
{
NestedArray nestedArray=new NestedArray().setParent(this);
this.set(dm.getDataModelName(),nestedArray);
((List)list).forEach(sub->{
if(sub instanceof ModelObj)
{
nestedArray.add((ModelObj)sub);
}
else if(sub instanceof Map)
{
ModelObj subObj=JSON.parseObject(JSON.toJSONString(sub),ModelObj.class);
subObj.build(dm).setParent(this);
}
});
}
});
}
return this;
}
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
...@@ -155,6 +240,40 @@ public class ModelObj extends DataObj<String,Object> { ...@@ -155,6 +240,40 @@ public class ModelObj extends DataObj<String,Object> {
return this; return this;
} }
public ModelObj setEntityValue(String name, Object value)
{
if(name.indexOf(".")>0) {
String[] epair = name.split("[.]");
if (epair.length >= 2) {
String propertyName = epair[0];
String columnName = epair[1];
return this.setEntityValue(propertyName,columnName,value);
}
}
return this;
}
public ModelObj setEntityValue(String propertyName,String columnName, Object value)
{
EntityObj entityObj=null;
Object obj=this.get(propertyName);
if(obj!=null&&obj instanceof EntityObj)
entityObj = (EntityObj) obj;
else
{
Property property=this.getDataModel().getObjectProperty(propertyName);
if(property!=null) {
entityObj = new EntityObj().setProperty(property).setRowKey(this.getRowKey());
this.setEntity(property.getPropertyName(),entityObj);
}
else
return this;
}
entityObj.put(columnName,value);
return this;
}
public ModelObj setFactEntity(EntityObj entityObj) public ModelObj setFactEntity(EntityObj entityObj)
{ {
this.setEntity(this.getDataModel().getFactPorperty().getPropertyName(),entityObj); this.setEntity(this.getDataModel().getFactPorperty().getPropertyName(),entityObj);
...@@ -474,6 +593,26 @@ public class ModelObj extends DataObj<String,Object> { ...@@ -474,6 +593,26 @@ public class ModelObj extends DataObj<String,Object> {
return null; return null;
} }
@JsonIgnore
@JSONField(serialize = false)
public boolean isEmpty()
{
int cnt=0;
for(String key:keySet())
{
if(key.startsWith("_"))
continue;
Object obj=this.get(key);
if(obj!=null && obj instanceof EntityObj &&((EntityObj)obj).isEmpty())
continue;
cnt++;
}
if(this.get("_IGNO")!=null)
return true;
return cnt==0;
}
@JsonIgnore @JsonIgnore
@JSONField(serialize = false) @JSONField(serialize = false)
public Boolean isDelete() public Boolean isDelete()
......
...@@ -56,6 +56,12 @@ public class LiteDataService { ...@@ -56,6 +56,12 @@ public class LiteDataService {
return dbEntityService; return dbEntityService;
} }
public boolean saveBatch(EntityModel entityModel, String dsName, List<EntityObj> list) {
splitList(list, 500).forEach(objs->{
getEntityService(StringUtils.isEmpty(dsName)?entityModel.getDsName():dsName).saveBatch(dsName,entityModel,objs);
});
return true;
}
public boolean saveBatch(String systemId, String entityName, String dsName, List<EntityObj> list) { public boolean saveBatch(String systemId, String entityName, String dsName, List<EntityObj> list) {
EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName); EntityModel entityModel = liteModelService.getEntityModel(systemId,entityName);
......
...@@ -7,6 +7,8 @@ import cn.ibizlab.core.lite.domain.MetaModel; ...@@ -7,6 +7,8 @@ import cn.ibizlab.core.lite.domain.MetaModel;
import cn.ibizlab.core.lite.extensions.domain.EntityModel; import cn.ibizlab.core.lite.extensions.domain.EntityModel;
import cn.ibizlab.core.lite.extensions.domain.FieldModel; import cn.ibizlab.core.lite.extensions.domain.FieldModel;
import cn.ibizlab.core.lite.extensions.domain.RelationshipModel; import cn.ibizlab.core.lite.extensions.domain.RelationshipModel;
import cn.ibizlab.core.lite.extensions.mapping.MetaEntityMapping;
import cn.ibizlab.core.lite.extensions.mapping.MetaFieldMapping;
import cn.ibizlab.core.lite.extensions.model.DataModel; import cn.ibizlab.core.lite.extensions.model.DataModel;
import cn.ibizlab.core.lite.extensions.model.Property; import cn.ibizlab.core.lite.extensions.model.Property;
import cn.ibizlab.core.lite.extensions.model.PropertyMapping; import cn.ibizlab.core.lite.extensions.model.PropertyMapping;
...@@ -48,6 +50,13 @@ public class LiteModelService { ...@@ -48,6 +50,13 @@ public class LiteModelService {
public void init(){ public void init(){
LiteStorage.setLiteModelService(this); LiteStorage.setLiteModelService(this);
} }
@Autowired
@Lazy
MetaEntityMapping entityMapping;
@Autowired
@Lazy
MetaFieldMapping fieldMapping;
@Autowired @Autowired
@Lazy @Lazy
...@@ -79,7 +88,7 @@ public class LiteModelService { ...@@ -79,7 +88,7 @@ public class LiteModelService {
List<EntityModel> list = new ArrayList<>(); List<EntityModel> list = new ArrayList<>();
metaEntityService.list(Wrappers.<MetaEntity>lambdaQuery().eq(MetaEntity::getSystemId,systemId).orderByAsc(MetaEntity::getEntityName)).forEach(entity -> { metaEntityService.list(Wrappers.<MetaEntity>lambdaQuery().eq(MetaEntity::getSystemId,systemId).orderByAsc(MetaEntity::getEntityName)).forEach(entity -> {
EntityModel entityModel = new EntityModel(); EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity); entityModel.setEntity(entityMapping.toDto(entity));
list.add(entityModel); list.add(entityModel);
}); });
return list; return list;
...@@ -96,7 +105,7 @@ public class LiteModelService { ...@@ -96,7 +105,7 @@ public class LiteModelService {
MetaEntity entity = LiteStorage.getMetaEntity(String.format("%1$s.%2$s",systemId,name)); MetaEntity entity = LiteStorage.getMetaEntity(String.format("%1$s.%2$s",systemId,name));
EntityModel entityModel = new EntityModel(); EntityModel entityModel = new EntityModel();
entityModel.setEntity(entity); entityModel.setEntity(entityMapping.toDto(entity));
Map<String, RelationshipModel> parentSet = new LinkedHashMap(); Map<String, RelationshipModel> parentSet = new LinkedHashMap();
List<RelationshipModel> references = new ArrayList<>(); List<RelationshipModel> references = new ArrayList<>();
...@@ -151,7 +160,7 @@ public class LiteModelService { ...@@ -151,7 +160,7 @@ public class LiteModelService {
metaFieldService.searchDefault(searchContext).getContent().forEach(item-> metaFieldService.searchDefault(searchContext).getContent().forEach(item->
{ {
FieldModel model = new FieldModel(); FieldModel model = new FieldModel();
model.setField(item); model.setField(fieldMapping.toDto(item));
model.setCodeName(item.getCodeName()); model.setCodeName(item.getCodeName());
model.setColumnName(item.getFieldName()); model.setColumnName(item.getFieldName());
model.setComment(item.getFieldLogicName()); model.setComment(item.getFieldLogicName());
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册