@@ -104,7 +104,7 @@ public class DatabaseUtil { | |||||
"实体定义:[" + modelFieldType.sqlType + "]!"; | "实体定义:[" + modelFieldType.sqlType + "]!"; | ||||
log.error(message, MODULE); | log.error(message, MODULE); | ||||
} | } | ||||
if (modelFieldType.dataLength != -1 && ccInfo.columnSize != -1 && modelFieldType.dataLength != ccInfo.columnSize) { | |||||
if (modelFieldType.dataLength != 0 && ccInfo.columnSize != -1 && modelFieldType.dataLength != ccInfo.columnSize) { | |||||
String message = "警告: 表[" + entity.getName() + "]字段[" + ccInfo.columnName + "] 字段长度不一致:::数据库:[" + ccInfo.columnSize + "], " + | String message = "警告: 表[" + entity.getName() + "]字段[" + ccInfo.columnName + "] 字段长度不一致:::数据库:[" + ccInfo.columnSize + "], " + | ||||
"实体定义:[" + modelFieldType.dataLength + "]!"; | "实体定义:[" + modelFieldType.dataLength + "]!"; | ||||
log.debug(message, MODULE); | log.debug(message, MODULE); | ||||
@@ -1,5 +1,6 @@ | |||||
package cc.smtweb.framework.core.db.vo; | package cc.smtweb.framework.core.db.vo; | ||||
import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
import lombok.Data; | import lombok.Data; | ||||
@@ -29,10 +30,10 @@ public class ModelField { | |||||
@JsonProperty("default") | @JsonProperty("default") | ||||
private String defaultValue; | private String defaultValue; | ||||
//外键关联表 | //外键关联表 | ||||
private String link; | |||||
private long link; | |||||
//控件类型:TEXT/TextArea/NUMBER/COMBO | //控件类型:TEXT/TextArea/NUMBER/COMBO | ||||
private String editor; | private String editor; | ||||
@JsonIgnore | |||||
public boolean isNotNull() { | public boolean isNotNull() { | ||||
return notNull == 1; | return notNull == 1; | ||||
} | } | ||||
@@ -247,7 +247,7 @@ public class ModelTable extends DefaultEntity { | |||||
public List<ModelLinkName> findLinkeNames() { | public List<ModelLinkName> findLinkeNames() { | ||||
List<ModelLinkName> list = new ArrayList<>(); | List<ModelLinkName> list = new ArrayList<>(); | ||||
for (ModelField field : fields) { | for (ModelField field : fields) { | ||||
if (StringUtils.isEmpty(field.getLink())) { | |||||
if (field.getLink()<=0) { | |||||
continue; | continue; | ||||
} | } | ||||
ModelTable linkTable = ModelTableCache.getInstance().get(field.getLink()); | ModelTable linkTable = ModelTableCache.getInstance().get(field.getLink()); | ||||
@@ -121,6 +121,16 @@ public class CommUtil { | |||||
public static int chineseCompare(String s1, String s2) { | public static int chineseCompare(String s1, String s2) { | ||||
return chineseCollator.compare(s1, s2); | return chineseCollator.compare(s1, s2); | ||||
} | } | ||||
public static int compareStr(String s1, String s2) { | |||||
if (StringUtils.isEmpty(s1) && StringUtils.isEmpty(s2)) return 0; | |||||
if (StringUtils.isEmpty(s1)) return -1; | |||||
if (StringUtils.isEmpty(s2)) return 1; | |||||
return chineseCollator.compare(s1, s2); | |||||
} | |||||
public static boolean isStrEquals(String s1, String s2) { | |||||
return compareStr(s1, s2) == 0; | |||||
} | |||||
//获取字段字符串长度 | //获取字段字符串长度 | ||||
public static int getStrLenB(String s) { | public static int getStrLenB(String s) { | ||||
@@ -12,6 +12,9 @@ import com.fasterxml.jackson.databind.JsonNode; | |||||
import com.fasterxml.jackson.databind.ObjectMapper; | import com.fasterxml.jackson.databind.ObjectMapper; | ||||
import com.fasterxml.jackson.databind.module.SimpleModule; | import com.fasterxml.jackson.databind.module.SimpleModule; | ||||
import com.fasterxml.jackson.databind.node.ObjectNode; | import com.fasterxml.jackson.databind.node.ObjectNode; | ||||
import com.fasterxml.jackson.databind.ser.FilterProvider; | |||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; | |||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; | |||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.beans.BeanUtils; | import org.springframework.beans.BeanUtils; | ||||
@@ -22,6 +25,7 @@ import java.io.InputStream; | |||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
import java.sql.Timestamp; | import java.sql.Timestamp; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashSet; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -46,6 +50,8 @@ public class JsonUtil { | |||||
init(API_OBJECT_MAPPER); | init(API_OBJECT_MAPPER); | ||||
API_OBJECT_MAPPER.getSerializerProvider().setNullValueSerializer(new NullSerializer()); | API_OBJECT_MAPPER.getSerializerProvider().setNullValueSerializer(new NullSerializer()); | ||||
FilterProvider filters = new SimpleFilterProvider().addFilter("apiFilter", SimpleBeanPropertyFilter.serializeAllExcept(new HashSet<>())); | |||||
} | } | ||||
private static void init(ObjectMapper mapper) { | private static void init(ObjectMapper mapper) { | ||||
@@ -5,6 +5,9 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.cache.AbstractCache; | import cc.smtweb.framework.core.cache.AbstractCache; | ||||
import cc.smtweb.framework.core.cache.CacheManager; | import cc.smtweb.framework.core.cache.CacheManager; | ||||
import cc.smtweb.framework.core.common.SwEnum; | import cc.smtweb.framework.core.common.SwEnum; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | |||||
import cc.smtweb.framework.core.db.vo.ModelField; | |||||
import cc.smtweb.framework.core.db.vo.ModelTable; | |||||
import cc.smtweb.framework.core.mvc.variable.SwVariableFactory; | import cc.smtweb.framework.core.mvc.variable.SwVariableFactory; | ||||
import cc.smtweb.framework.core.session.UserSession; | import cc.smtweb.framework.core.session.UserSession; | ||||
import cc.smtweb.framework.core.util.CommUtil; | import cc.smtweb.framework.core.util.CommUtil; | ||||
@@ -52,7 +55,7 @@ public class ModelFormHelper { | |||||
PageDataSet[] list = JsonUtil.parse(jsonStr, PageDataSet[].class); | PageDataSet[] list = JsonUtil.parse(jsonStr, PageDataSet[].class); | ||||
Map<String, PageDataSet> map = new LinkedHashMap<>(list.length); | Map<String, PageDataSet> map = new LinkedHashMap<>(list.length); | ||||
for (PageDataSet ds : list) { | for (PageDataSet ds : list) { | ||||
map.put(ds.name, ds); | |||||
map.put(ds.id, ds); | |||||
ds.resetFields(); | ds.resetFields(); | ||||
} | } | ||||
return map; | return map; | ||||
@@ -121,43 +124,83 @@ public class ModelFormHelper { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* 保存的数据集,删除掉一些不必要的字段信息 | |||||
* @param jsonStr | |||||
* @return | |||||
*/ | |||||
public static String buildSaveDataset(String jsonStr) { | public static String buildSaveDataset(String jsonStr) { | ||||
Map<String, PageDataSet> map = parsePageDataset(jsonStr); | Map<String, PageDataSet> map = parsePageDataset(jsonStr); | ||||
if (map == null) return null; | if (map == null) return null; | ||||
try { | |||||
return buildSaveDataset(map.values()); | |||||
} catch (JsonProcessingException e) { | |||||
throw new SwException(e); | |||||
for (PageDataSet dataSet: map.values()) { | |||||
buildSaveDataSetFields(dataSet.fields); | |||||
buildSaveDataSetFields(dataSet.filters); | |||||
} | } | ||||
return JsonUtil.encodeString(map.values()); | |||||
} | } | ||||
/** | /** | ||||
* 构建待保存的数据集 | * 构建待保存的数据集 | ||||
* | * | ||||
* @param datasets | |||||
* @return | * @return | ||||
* @throws JsonProcessingException | * @throws JsonProcessingException | ||||
*/ | */ | ||||
public static String buildSaveDataset(Collection<PageDataSet> datasets) throws JsonProcessingException { | |||||
ObjectMapper mapper = new ObjectMapper(); | |||||
FilterProvider filters = new SimpleFilterProvider().addFilter("datasetField", new SimpleBeanPropertyFilter() { | |||||
private final String includes = "name,label,field,table"; | |||||
@Override | |||||
protected boolean include(PropertyWriter writer) { | |||||
return includes.contains(writer.getName()); | |||||
public static void buildSaveDataSetFields(List<? extends PageDatasetField> fields) { | |||||
ModelTable table = null; | |||||
for (PageDatasetField field: fields) { | |||||
if (field.table <= 0) continue; | |||||
if (table == null || table.getEntityId() != field.table) { | |||||
table = ModelTableCache.getInstance().get(field.table); | |||||
} | } | ||||
}).addFilter("datasetFilter", new SimpleBeanPropertyFilter() { | |||||
private final String includes = ",name,label,field,table,dataType,type,linkDb,linkField,value"; | |||||
if (table == null) continue; | |||||
ModelField tf = table.findFieldByName(field.field); | |||||
if (tf == null) continue; | |||||
if (CommUtil.isStrEquals(tf.getTitle(), field.label)) field.label = null; | |||||
if (CommUtil.isStrEquals(tf.getDataType(),field.dataType)) field.dataType = null; | |||||
if (CommUtil.isStrEquals(tf.getRemark(), field.remark)) field.remark = null; | |||||
if (CommUtil.isStrEquals(tf.getEditor(), field.editor)) field.editor = null; | |||||
} | |||||
} | |||||
/** | |||||
* 构建请求的数据集,补充表定义信息 | |||||
* | |||||
* @return | |||||
* @throws JsonProcessingException | |||||
*/ | |||||
public static String buildReqDataset(String jsonStr) { | |||||
Map<String, PageDataSet> map = parsePageDataset(jsonStr); | |||||
if (map == null) return ""; | |||||
for (PageDataSet dataSet: map.values()) { | |||||
buildReqDataSetFields(dataSet.fields); | |||||
buildReqDataSetFields(dataSet.filters); | |||||
} | |||||
return JsonUtil.encodeString(map.values()); | |||||
} | |||||
@Override | |||||
protected boolean include(PropertyWriter writer) { | |||||
return includes.contains("," + writer.getName()); | |||||
/** | |||||
* 构建请求的数据集,补充表定义信息 | |||||
* | |||||
* @return | |||||
* @throws JsonProcessingException | |||||
*/ | |||||
public static void buildReqDataSetFields(List<? extends PageDatasetField> fields) { | |||||
ModelTable table = null; | |||||
for (PageDatasetField field: fields) { | |||||
if (field.table <= 0) continue; | |||||
if (table == null || table.getEntityId() != field.table) { | |||||
table = ModelTableCache.getInstance().get(field.table); | |||||
} | } | ||||
}); | |||||
return mapper.writer(filters).writeValueAsString(datasets); | |||||
if (table == null) continue; | |||||
ModelField tf = table.findFieldByName(field.field); | |||||
if (tf == null) continue; | |||||
if (StringUtils.isEmpty(field.label)) field.label = tf.getTitle(); | |||||
if (StringUtils.isEmpty(field.dataType)) field.dataType = tf.getDataType(); | |||||
if (StringUtils.isEmpty(field.remark)) field.remark = tf.getRemark(); | |||||
if (StringUtils.isEmpty(field.editor)) field.editor = tf.getEditor(); | |||||
field.notNull = tf.getNotNull(); | |||||
field.link = tf.getLink(); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
@@ -30,9 +30,7 @@ public class ModelFormLoadHandler extends DefaultLoadHandler<ModelForm> { | |||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
ModelForm bean = super.loadComp(id); | ModelForm bean = super.loadComp(id); | ||||
if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id); | if (bean == null) throw new SwException("没有找到指定定义信息!id=" + id); | ||||
Map<String, PageDataSet> map = ModelFormHelper.parsePageDataset(bean.getDataset()); | |||||
if (map == null) return R.success(""); | |||||
return R.success(JsonUtil.encodeString(map.values())); | |||||
return R.success(ModelFormHelper.buildReqDataset(bean.getDataset())); | |||||
} | } | ||||
//页面设计 - 加载页面model定义 | //页面设计 - 加载页面model定义 | ||||
@@ -16,6 +16,7 @@ import java.util.Map; | |||||
* 数据集定义 | * 数据集定义 | ||||
*/ | */ | ||||
public class PageDataSet { | public class PageDataSet { | ||||
public String id; | |||||
//名称 | //名称 | ||||
public String name; | public String name; | ||||
//中文名 | //中文名 | ||||
@@ -1,14 +1,15 @@ | |||||
package cc.smtweb.system.bpm.web.design.form.define; | package cc.smtweb.system.bpm.web.design.form.define; | ||||
import com.fasterxml.jackson.annotation.JsonFilter; | import com.fasterxml.jackson.annotation.JsonFilter; | ||||
import com.fasterxml.jackson.annotation.JsonIgnore; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/20 18:15 | * Created by Akmm at 2022/4/20 18:15 | ||||
*/ //字段要素 | */ //字段要素 | ||||
@JsonFilter("datasetField") | |||||
public class PageDatasetField { | public class PageDatasetField { | ||||
//表 | //表 | ||||
public long table; | public long table; | ||||
public String table_text; | |||||
//字段 | //字段 | ||||
public String field; | public String field; | ||||
//有别名取别名,无别名同字段名 | //有别名取别名,无别名同字段名 | ||||
@@ -29,10 +30,11 @@ public class PageDatasetField { | |||||
*/ | */ | ||||
public int notNull; | public int notNull; | ||||
//外键关联表 | //外键关联表 | ||||
public String link; | |||||
public long link; | |||||
//控件类型:TEXT/TextArea/NUMBER/COMBO | //控件类型:TEXT/TextArea/NUMBER/COMBO | ||||
public String editor; | public String editor; | ||||
@JsonIgnore | |||||
public boolean isNotNull() { | public boolean isNotNull() { | ||||
return notNull == 1; | return notNull == 1; | ||||
} | } | ||||
@@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonFilter; | |||||
/** | /** | ||||
* Created by Akmm at 2022/4/20 18:15 | * Created by Akmm at 2022/4/20 18:15 | ||||
*/ //过滤条件信息 | */ //过滤条件信息 | ||||
@JsonFilter("datasetFilter") | |||||
public class PageDatasetFilter extends PageDatasetField { | public class PageDatasetFilter extends PageDatasetField { | ||||
//param-参数/link/const | //param-参数/link/const | ||||
public String type; | public String type; | ||||
@@ -1,6 +1,8 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | package cc.smtweb.system.bpm.web.engine.flow; | ||||
import cc.smtweb.system.bpm.web.design.flow.ModelProc; | import cc.smtweb.system.bpm.web.design.flow.ModelProc; | ||||
import cc.smtweb.system.bpm.web.engine.flow.define.ProcinstEntity; | |||||
import cc.smtweb.system.bpm.web.engine.flow.define.TaskEntity; | |||||
import java.util.*; | import java.util.*; | ||||
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |
@@ -1,4 +1,4 @@ | |||||
package cc.smtweb.system.bpm.web.engine.flow; | |||||
package cc.smtweb.system.bpm.web.engine.flow.define; | |||||
import cc.smtweb.framework.core.annotation.SwTable; | import cc.smtweb.framework.core.annotation.SwTable; | ||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; |