Browse Source

页面设计调整

master
郑根木 2 years ago
parent
commit
98ecace018
11 changed files with 109 additions and 111 deletions
  1. +28
    -70
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  2. +0
    -4
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java
  3. +9
    -6
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java
  4. +1
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java
  5. +42
    -0
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java
  6. +9
    -11
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java
  7. +2
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageAddHandler.java
  8. +5
    -5
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java
  9. +6
    -6
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  10. +2
    -2
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadOneHandler.java
  11. +5
    -5
      smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java

+ 28
- 70
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java View File

@@ -3,7 +3,6 @@ package cc.smtweb.system.bpm.web.design.form;
import cc.smtweb.framework.core.common.SwException;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelField;
@@ -13,16 +12,8 @@ import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.framework.core.util.MapUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetField;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter;
import cc.smtweb.system.bpm.web.design.form.define.PageModel;
import cc.smtweb.system.bpm.web.design.form.define.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.PropertyWriter;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import org.apache.commons.lang3.StringUtils;

import java.util.*;
@@ -44,21 +35,16 @@ public class ModelFormHelper {
return cache.get(formId);
}

public static Map<String, PageDataSet> parsePageDataset(long formId) {
public static PageDatasets parsePageDataset(long formId) {
ModelForm form = getFromCache(formId);
if (form == null) return null;
return parsePageDataset(form.getDataset());
}

public static Map<String, PageDataSet> parsePageDataset(String jsonStr) {
public static PageDatasets parsePageDataset(String jsonStr) {
if (StringUtils.isEmpty(jsonStr)) return null;
PageDataSet[] list = JsonUtil.parse(jsonStr, PageDataSet[].class);
Map<String, PageDataSet> map = new LinkedHashMap<>(list.length);
for (PageDataSet ds : list) {
map.put(ds.id, ds);
ds.resetFields();
}
return map;
PageDataset[] list = JsonUtil.parse(jsonStr, PageDataset[].class);
return new PageDatasets(list);
}

/**
@@ -87,23 +73,22 @@ public class ModelFormHelper {
* @return
*/
public static String buildSaveModel(ModelForm form) {
Map<String, PageDataSet> mapDataset = parsePageDataset(form.getDataset());
PageDatasets datasets = parsePageDataset(form.getDataset());
PageModel pageInfo = parsePageInfo(form.getContent());
if (pageInfo == null) return "";
for (Map<String, Object> model : pageInfo.model) {

buildSaveModelFields(mapDataset, pageInfo, model, true);
buildSaveModelFields(mapDataset, pageInfo, model, false);
buildSaveModelFields(datasets, pageInfo, model, true);
buildSaveModelFields(datasets, pageInfo, model, false);
}
return JsonUtil.encodeString(pageInfo);
}

//处理model的fields和filters
private static void buildSaveModelFields(Map<String, PageDataSet> mapDataset, PageModel pageInfo, Map<String, Object> model, boolean isField) {
private static void buildSaveModelFields(PageDatasets datasets, PageModel pageInfo, Map<String, Object> model, boolean isField) {
String db = (String) model.get("dataset");
//没有配置db,配置有误,不处理
if (StringUtils.isEmpty(db)) throw new SwException("model未配置数据集db,无法解析!");
PageDataSet pds = mapDataset.get(db);
PageDataset pds = datasets.findById(db);
String key = isField ? "fields" : "filters";
List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get(key);
if (fields == null || fields.isEmpty()) return;
@@ -130,13 +115,13 @@ public class ModelFormHelper {
* @return
*/
public static String buildSaveDataset(String jsonStr) {
Map<String, PageDataSet> map = parsePageDataset(jsonStr);
if (map == null) return null;
for (PageDataSet dataSet: map.values()) {
PageDatasets datasets = parsePageDataset(jsonStr);
if (datasets == null || datasets.list == null) return "";
for (PageDataset dataSet: datasets.list) {
buildSaveDataSetFields(dataSet.fields);
buildSaveDataSetFields(dataSet.filters);
}
return JsonUtil.encodeString(map.values());
return JsonUtil.encodeString(datasets.list);
}

/**
@@ -155,6 +140,7 @@ public class ModelFormHelper {
if (table == null) continue;
ModelField tf = table.findFieldByName(field.field);
if (tf == null) continue;
field.table_text = null;
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;
@@ -169,39 +155,11 @@ public class ModelFormHelper {
* @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());
PageDatasets datasets = parsePageDataset(jsonStr);
if (datasets == null || datasets.list == null) return "";
return JsonUtil.encodeString(datasets.list);
}

/**
* 构建请求的数据集,补充表定义信息
*
* @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);
}
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();
}
}

/**
* 根据数据库存储的信息,加工处理成页面要的,与buildsave逆向
@@ -210,14 +168,14 @@ public class ModelFormHelper {
* @return
*/
public static String buildReqModel(ModelForm form) {
Map<String, PageDataSet> mapDataset = parsePageDataset(form.getDataset());
PageDatasets datasets = parsePageDataset(form.getDataset());
PageModel pageInfo = parsePageInfo(form.getContent());
if (pageInfo == null) return "";
for (Map<String, Object> model : pageInfo.model) {
String db = (String) model.get("dataset");
//没有配置db,配置有误,不处理
if (StringUtils.isEmpty(db)) continue;
PageDataSet dataSet = mapDataset.get(db);
PageDataset dataSet = datasets.findById(db);
if (dataSet == null) continue;
buildReqModelFields(dataSet, model, true);
buildReqModelFields(dataSet, model, false);
@@ -226,7 +184,7 @@ public class ModelFormHelper {
}

//处理model的fields和filters
private static void buildReqModelFields(PageDataSet dataSet, Map<String, Object> model, boolean isField) {
private static void buildReqModelFields(PageDataset dataSet, Map<String, Object> model, boolean isField) {
String key = isField ? "fields" : "filters";
List<Map<String, Object>> fields = (List<Map<String, Object>>) model.get(key);
if (fields == null || fields.isEmpty()) return;
@@ -254,8 +212,8 @@ public class ModelFormHelper {
* @return
*/
public static String buildEngineModel(ModelForm form, SwMap params, UserSession us) {
Map<String, PageDataSet> mapDataset = parsePageDataset(form.getDataset());
if (mapDataset == null) return "";
PageDatasets datasets = parsePageDataset(form.getDataset());
if (datasets == null || datasets.list == null) return "";

SwMap ret = new SwMap();
PageModel pageInfo = parsePageInfo(form.getContent());
@@ -267,7 +225,7 @@ public class ModelFormHelper {
//构建Model
for (Map<String, Object> model : pageInfo.model) {
String db = (String) model.get("dataset");
PageDataSet dataSet = mapDataset.get(db);
PageDataset dataSet = datasets.findById(db);
if (dataSet == null) throw new SwException("未找到指定的数据集定义!" + db);

listModel.add(buildEngineModelMap(dataSet, model));
@@ -277,7 +235,7 @@ public class ModelFormHelper {
}

//构建model部分
private static SwMap buildEngineModelMap(PageDataSet dataSet, Map<String, Object> model) {
private static SwMap buildEngineModelMap(PageDataset dataSet, Map<String, Object> model) {
SwMap ret = new SwMap();

ret.put("name", dataSet.name);
@@ -328,9 +286,9 @@ public class ModelFormHelper {
//获取控件的filter信息
public static List<SwMap> buildWidgetFilter(ModelForm bean) {
List<SwMap> listRet = new ArrayList<>();
Map<String, PageDataSet> map = ModelFormHelper.parsePageDataset(bean.getDataset());
if (map == null) return listRet;
for (PageDataSet ds: map.values()) {
PageDatasets datasets = ModelFormHelper.parsePageDataset(bean.getDataset());
if (datasets == null || datasets.list == null) return listRet;
for (PageDataset ds: datasets.list) {
for (PageDatasetFilter filter: ds.filters) {
if (SwEnum.FilterType.INPUT.value.equals(filter.type) || SwEnum.FilterType.PARAM.value.equals(filter.type)) {
SwMap fret = new SwMap();


+ 0
- 4
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormLoadHandler.java View File

@@ -3,10 +3,6 @@ package cc.smtweb.system.bpm.web.design.form;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwException;
import cc.smtweb.framework.core.mvc.service.DefaultLoadHandler;
import cc.smtweb.framework.core.util.JsonUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;

import java.util.Map;

/**
* Created by Akmm at 2022/5/9 16:17


smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataSet.java → smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDataset.java View File

@@ -15,7 +15,8 @@ import java.util.Map;
* Created by Akmm at 2022/4/18 14:20
* 数据集定义
*/
public class PageDataSet {
public class PageDataset {
//唯一标识
public String id;
//名称
public String name;
@@ -79,16 +80,18 @@ public class PageDataSet {
if (table == null || table.getId() != field.table) {
table = cache.get(field.table);
}
if (table == null) throw new SwException("未找到表的定义信息(id=" + field.table + ")");
if (table == null) continue;
ModelField mf = table.findField(field.field);
if (mf == null) throw new SwException("未找到表字段的定义信息(" + table.getName() + "." + field.field + ")");
field.dataType = mf.getDataType();
field.editor = mf.getEditor();
field.table_text = table.getTitle();
field.fieldType = mf.getFieldType();
field.notNull = mf.getNotNull();
field.label = mf.getTitle();
field.link = mf.getLink();
field.remark = mf.getRemark();

if (StringUtils.isEmpty(field.label)) field.label = mf.getTitle();
if (StringUtils.isEmpty(field.dataType)) field.dataType = mf.getDataType();
if (StringUtils.isEmpty(field.remark)) field.remark = mf.getRemark();
if (StringUtils.isEmpty(field.editor)) field.editor = mf.getEditor();
}
}


+ 1
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasetField.java View File

@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
* Created by Akmm at 2022/4/20 18:15
*/ //字段要素
public class PageDatasetField {
public String id;
//表
public long table;
public String table_text;


+ 42
- 0
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/define/PageDatasets.java View File

@@ -0,0 +1,42 @@
package cc.smtweb.system.bpm.web.design.form.define;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sun.istack.internal.NotNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by Akmm at 2022/5/25 15:53
* 数据集集合
*/
public class PageDatasets {
public List<PageDataset> list;

@JsonIgnore
private Map<String, PageDataset> mapId = null;
@JsonIgnore
private Map<String, PageDataset> mapName = null;

public PageDatasets(@NotNull PageDataset[] datasets) {
this.list = new ArrayList<>(datasets.length);
this.mapId = new HashMap<>(datasets.length);
this.mapName = new HashMap<>(datasets.length);
for (PageDataset ds : datasets) {
this.list.add(ds);
mapId.put(ds.id, ds);
mapName.put(ds.name, ds);
ds.resetFields();
}
}

public PageDataset findById(String id) {
return mapId.get(id);
}

public PageDataset findByName(String name) {
return mapName.get(name);
}
}

+ 9
- 11
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/AbstractDynPageHandler.java View File

@@ -5,7 +5,8 @@ import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasets;

import java.util.Map;

@@ -15,26 +16,23 @@ import java.util.Map;
public abstract class AbstractDynPageHandler extends AbstractHandler {
//页面定义id
protected long pageId;
protected Map<String, PageDataSet> mapDataset;
protected PageDatasets datasets;

@Override
public void init(SwMap params, UserSession us) {
super.init(params, us);
pageId = params.readLong("pageId");

mapDataset = ModelFormHelper.parsePageDataset(pageId);
if (mapDataset == null) throw new SwException("没有找到页面定义数据!");
datasets = ModelFormHelper.parsePageDataset(pageId);
if (datasets == null || datasets.list == null) throw new SwException("没有找到页面定义数据!");
}

protected PageDataSet findDataset(String name) {
return mapDataset.get(name);
protected PageDataset findDataset(String name) {
return datasets.findByName(name);
}

//获取第一个,主数据集
protected PageDataSet findMasterDataset() {
for (PageDataSet dataSet: mapDataset.values()) {
return dataSet;
}
return null;
protected PageDataset findMasterDataset() {
return datasets.list.get(0);
}
}

+ 2
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageAddHandler.java View File

@@ -4,7 +4,7 @@ import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.common.SwEnum;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

import java.util.HashMap;
import java.util.Map;
@@ -19,7 +19,7 @@ public class DynPageAddHandler extends AbstractDynPageHandler {
public R doWork() throws Exception {
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value
Map<String, Object> mapRet = new HashMap<>();
for (PageDataSet dataSet : mapDataset.values()) {
for (PageDataset dataSet : datasets.list) {
if (!dataSet.canEdit) {
continue;
}


+ 5
- 5
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageDelHandler.java View File

@@ -11,7 +11,7 @@ import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.AbsDbWorker;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter;
import org.apache.commons.lang3.StringUtils;

@@ -40,7 +40,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
//数据集
String dbName = params.readString("dataset");
//对应的数据集定义
PageDataSet pageDataSet = findDataset(dbName);
PageDataset pageDataSet = findDataset(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");

long id = params.readLong("id");
@@ -73,13 +73,13 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
long id = params.readLong("id");
if (id == 0) throw new SwException("没有收到待删除记录Id!");
//校验主表即可
PageDataSet masterDs = findMasterDataset();
PageDataset masterDs = findMasterDataset();
if (masterDs == null || !masterDs.canEdit || !SwEnum.DatasetType.FORM.value.equals(masterDs.type))
throw new SwException("主表不允许删除!");
checkBean(masterDs, id);

Map<String, RemovableInfo> mapRemovableInfo = new HashMap<>();
for (PageDataSet pageDataSet : mapDataset.values()) {
for (PageDataset pageDataSet : datasets.list) {
//非表单编辑,不管
if (!pageDataSet.canEdit || !SwEnum.DatasetType.FORM.value.equals(pageDataSet.type)) continue;
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
@@ -139,7 +139,7 @@ public class DynPageDelHandler extends AbstractDynPageHandler {
* @param pageDataSet
* @param id
*/
protected void checkBean(PageDataSet pageDataSet, long id) {
protected void checkBean(PageDataset pageDataSet, long id) {
//校验外键引用关系
}



+ 6
- 6
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java View File

@@ -32,7 +32,7 @@ public class DynPageHelper {
* @param dataSet
* @return
*/
public static SwMap createBean(PageDataSet dataSet) {
public static SwMap createBean(PageDataset dataSet) {
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable);
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(masterTable.getTableName());
@@ -50,7 +50,7 @@ public class DynPageHelper {
* @param dataSet
* @return
*/
public static SqlNamedPara buildSelectSql(PageDataSet dataSet, Map<String, Object> params) {
public static SqlNamedPara buildSelectSql(PageDataset dataSet, Map<String, Object> params) {
StringBuilder sql = new StringBuilder(512);

SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
@@ -74,7 +74,7 @@ public class DynPageHelper {
return sqlNamedPara;
}

public static SqlNamedPara buildSumSql(PageDataSet dataSet, Map<String, Object> params) {
public static SqlNamedPara buildSumSql(PageDataset dataSet, Map<String, Object> params) {
SqlNamedPara sqlNamedPara = buildSelectSql(dataSet, params);
StringBuilder sql = new StringBuilder(256);
sql.append("select count(1) " + TOTAL_KEY);
@@ -91,7 +91,7 @@ public class DynPageHelper {
return sqlNamedPara;
}

private static String buildSelFieldsSql(PageDataSet dataSet, SqlNamedPara sqlNamedPara) {
private static String buildSelFieldsSql(PageDataset dataSet, SqlNamedPara sqlNamedPara) {
StringBuilder sql = new StringBuilder(512);
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable);
@@ -122,7 +122,7 @@ public class DynPageHelper {
* @param params
* @return
*/
public static SqlNamedPara buildWhereSql(PageDataSet dataSet, Map<String, Object> params) {
public static SqlNamedPara buildWhereSql(PageDataset dataSet, Map<String, Object> params) {
StringBuilder sql = new StringBuilder(512);
SwMap args = new SwMap();

@@ -157,7 +157,7 @@ public class DynPageHelper {
* @param setFixedFilter
* @return
*/
private static String buildDynCondSql(PageDataSet dataSet, PageDatasetDynCond dynCond, Map<String, Object> params, SwMap args, Set<String> setFixedFilter) {
private static String buildDynCondSql(PageDataset dataSet, PageDatasetDynCond dynCond, Map<String, Object> params, SwMap args, Set<String> setFixedFilter) {
if (dynCond.isOpt()) {//是and/or
StringBuilder sql = new StringBuilder(256);
boolean b = false;


+ 2
- 2
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageLoadOneHandler.java View File

@@ -10,7 +10,7 @@ import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.framework.core.mvc.service.SwListData;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

import java.util.List;

@@ -26,7 +26,7 @@ public class DynPageLoadOneHandler extends AbstractDynPageHandler {
private SwMap filter = new SwMap();

//对应的数据集定义
private PageDataSet pageDataSet;
private PageDataset pageDataSet;

@Override
public R doWork() throws Exception {


+ 5
- 5
smtweb-system/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageSaveHandler.java View File

@@ -16,7 +16,7 @@ import cc.smtweb.framework.core.db.vo.ModelIndex;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataSet;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter;
import org.apache.commons.lang3.StringUtils;

@@ -46,7 +46,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
SwMap data = params.readMap("data");
if (data == null) throw new SwException("没有收到待保存的的数据:" + dbName + "!");
//对应的数据集定义
PageDataSet pageDataSet = findDataset(dbName);
PageDataset pageDataSet = findDataset(dbName);
if (pageDataSet == null) throw new SwException("没有找到指定的的数据集定义:" + dbName + "!");
//读取待保存的bean
DefaultEntity bean = readBeanFromPage(pageDataSet, data);
@@ -85,7 +85,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
SwMap filter = (SwMap) params.get("filter");

Map<String, DefaultEntity> map = new LinkedHashMap<>();
for (PageDataSet pageDataSet : mapDataset.values()) {
for (PageDataset pageDataSet : datasets.list) {
//非表单编辑,不管
if (!pageDataSet.canEdit || !SwEnum.DatasetType.FORM.value.equals(pageDataSet.type)) continue;
SwMap dsData = (SwMap) data.get(pageDataSet.name);
@@ -138,7 +138,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
* @param data
* @return
*/
protected DefaultEntity readBeanFromPage(PageDataSet pageDataSet, SwMap data) {
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap data) {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
if (table == null) throw new SwException("没有找到待保存的表定义:" + pageDataSet.name);
long id = data.readLong(table.getIdField());
@@ -237,7 +237,7 @@ public class DynPageSaveHandler extends AbstractDynPageHandler {
}

//将关联的值设上
protected void setLinkValue(PageDataSet pageDataSet, DefaultEntity bean, IGetValue iGetValue) {
protected void setLinkValue(PageDataset pageDataSet, DefaultEntity bean, IGetValue iGetValue) {
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName());
for (PageDatasetFilter f : pageDataSet.filters) {
String v = bean.getStr(f.field);


Loading…
Cancel
Save