浏览代码

Merge remote-tracking branch 'origin/4.0' into 4.0

4.0
lip 2 年前
父节点
当前提交
a118c2d925
共有 7 个文件被更改,包括 115 次插入23 次删除
  1. +5
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java
  2. +1
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java
  3. +32
    -21
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java
  4. +16
    -2
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageListHandler.java
  5. +17
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/IBuildSqlListener.java
  6. +37
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java
  7. +7
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java

+ 5
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/db/ModelCatalogTreeHandler.java 查看文件

@@ -36,6 +36,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
private int type;//查询类型:0-目录;1-表定义;2-页面定义
private boolean exc_empty;//排除空目录,type非目录时有效
private boolean exc_depend;//排除依赖项目的目录
private boolean only_bill;//仅限单据页面(billType>0)
private ModelCatalogTreeHelper mcTreeHelper = null;

//模块子页面,暂存
@@ -48,6 +49,7 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
prj_id = params.readLong("prj_id");
exc_empty = params.readBool("exc_empty");
exc_depend = params.readBool("exc_depend");
only_bill = params.readBool("only_bill");
mcTreeHelper = (ModelCatalogTreeHelper) TreeHelper.getTreeHelper(ModelCatalog.ENTITY_NAME);
}

@@ -185,6 +187,9 @@ public class ModelCatalogTreeHandler extends AbstractTreeHandler<DefaultEntity>
private void addForm(List<DefaultEntity> listRet, List<ModelForm> lf, boolean exc_widget) {
for (ModelForm mf : lf) {
if (exc_widget && mf.getType() == SwEnum.FormType.WIDGET.value) continue;
if (only_bill && mf.getBillType() <= 0L) {//清除非单据页面
continue;
}
if (mf.getParent() > 0) {
List<DefaultEntity> ch = mapFormChild.computeIfAbsent(mf.getParent(), k -> new ArrayList<>());
ch.add(mf);


+ 1
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/form/ModelFormHelper.java 查看文件

@@ -284,6 +284,7 @@ public class ModelFormHelper {
PageModel pageInfo = parsePageInfo(form.getContent());
if (pageInfo == null) return "";
ret.put("pageId", form.getEntityId());
ret.put("pageName", getPageName(form));
ret.put("label", form.getTitle());
ret.put("service", service);
ret.put("module", ModelProjectCache.getInstance().getModule(form.getPrjId()));


+ 32
- 21
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageHelper.java 查看文件

@@ -17,6 +17,7 @@ import cc.smtweb.framework.core.util.NumberUtil;
import cc.smtweb.framework.core.util.PubUtil;
import cc.smtweb.system.bpm.web.design.form.define.*;
import org.apache.commons.lang3.StringUtils;
import reactor.util.annotation.Nullable;

import java.util.HashMap;
import java.util.HashSet;
@@ -47,21 +48,9 @@ public class DynPageHelper {
return bean.getData();
}

/**
* 构建select fields from table
*
* @param dataSet
* @return
*/
public static SqlNamedPara buildSelectSql(PageDataset dataSet, Map<String, Object> params) {
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
buildSelectSql(dataSet, params, sqlNamedPara);
return sqlNamedPara;
}

public static void buildSelectSql(PageDataset dataSet, Map<String, Object> params, SqlNamedPara sqlNamedPara) {
private static void buildSelectSql(PageDataset dataSet, Map<String, Object> params, SqlNamedPara sqlNamedPara, IBuildSqlListener listener) {
StringBuilder sql = new StringBuilder(512);
sql.append(buildSelFieldsSql(dataSet, sqlNamedPara));
sql.append(buildSelFieldsSql(dataSet, sqlNamedPara, listener));
if (StringUtils.isNotEmpty(sqlNamedPara.sql)) {
sql.append(" where ").append(sqlNamedPara.sql);
}
@@ -79,11 +68,27 @@ public class DynPageHelper {
sqlNamedPara.rows = MapUtil.readInt(params, SwConsts.PARAM_ROWS);
}

/**
* 构建select fields from table
*
* @param dataSet
* @return
*/
public static SqlNamedPara buildSelectSql(PageDataset dataSet, Map<String, Object> params) {
return buildSelectSqlEx(dataSet, params, null);
}

public static SqlNamedPara buildSelectSqlEx(PageDataset dataSet, Map<String, Object> params, IBuildSqlListener listener) {
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params, listener);
buildSelectSql(dataSet, params, sqlNamedPara, listener);
return sqlNamedPara;
}

//构建树型查询语句,插入parent_id=?
public static SqlNamedPara buildTreeSelectSql(PageDataset dataSet, SwMap params, long parentId) {
ModelTable table = ModelTableCache.getInstance().get(dataSet.masterTable);
if (table == null) throw new SwException("没有找到指定的表:" + dataSet.masterTable);
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params, null);
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) {//是树型结构,才做处理
ModelField field = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value);
if (field == null) throw new SwException("树型表(" + table.getName() + ")未定义上级id字段!");
@@ -96,7 +101,7 @@ public class DynPageHelper {
sqlNamedPara.addParas("parent_id", parentId);
}

buildSelectSql(dataSet, params, sqlNamedPara);
buildSelectSql(dataSet, params, sqlNamedPara, null);
return sqlNamedPara;
}

@@ -104,7 +109,7 @@ public class DynPageHelper {
public static SqlNamedPara buildFilterSelectSql(PageDataset dataSet, SwMap params, String text) {
ModelTable table = ModelTableCache.getInstance().get(dataSet.masterTable);
if (table == null) throw new SwException("没有找到指定的表:" + dataSet.masterTable);
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params);
SqlNamedPara sqlNamedPara = buildWhereSql(dataSet, params, null);
if (StringUtils.isNotEmpty(text)) {//有文本信息
StringBuilder sql = new StringBuilder(128);
ModelField field = table.findFieldByType(SwEnum.FieldType.CODE.value);
@@ -127,7 +132,7 @@ public class DynPageHelper {
}
}

buildSelectSql(dataSet, params, sqlNamedPara);
buildSelectSql(dataSet, params, sqlNamedPara, null);
return sqlNamedPara;
}

@@ -139,7 +144,11 @@ public class DynPageHelper {
* @return
*/
public static SqlNamedPara buildSumSql(PageDataset dataSet, Map<String, Object> params) {
SqlNamedPara sqlNamedPara = buildSelectSql(dataSet, params);
return buildSumSqlEx(dataSet, params, null);
}

public static SqlNamedPara buildSumSqlEx(PageDataset dataSet, Map<String, Object> params, IBuildSqlListener listener) {
SqlNamedPara sqlNamedPara = buildSelectSqlEx(dataSet, params, listener);
StringBuilder sql = new StringBuilder(256);
sql.append("select count(1) " + TOTAL_KEY);
for (PageDatasetField field : dataSet.fields) {
@@ -156,7 +165,7 @@ public class DynPageHelper {
return sqlNamedPara;
}

private static String buildSelFieldsSql(PageDataset dataSet, SqlNamedPara sqlNamedPara) {
private static String buildSelFieldsSql(PageDataset dataSet, SqlNamedPara sqlNamedPara, IBuildSqlListener listener) {
StringBuilder sql = new StringBuilder(512);
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(dataSet.masterTable);
@@ -175,6 +184,7 @@ public class DynPageHelper {
}
sql.setCharAt(sql.length() - 1, ' ');
sql.append(" from ").append(masterTable.getSchemaTableName());
if (listener != null) listener.buildSelect(dataSet, sql);
return sql.toString();
} else {
return dataSet.sql;
@@ -188,7 +198,7 @@ public class DynPageHelper {
* @param params
* @return
*/
public static SqlNamedPara buildWhereSql(PageDataset dataSet, Map<String, Object> params) {
private static SqlNamedPara buildWhereSql(PageDataset dataSet, Map<String, Object> params, IBuildSqlListener listener) {
StringBuilder sql = new StringBuilder(512);
SwMap args = new SwMap();

@@ -210,6 +220,7 @@ public class DynPageHelper {
for (String s : setFixedFilter) {
args.put(s, MapUtil.readString(params, s, ""));
}
if (listener != null) listener.buildWhere(dataSet, sql, args);
return new SqlNamedPara(sql.toString(), args);
}



+ 16
- 2
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/DynPageListHandler.java 查看文件

@@ -12,6 +12,7 @@ import cc.smtweb.framework.core.mvc.service.SqlPara;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

import java.util.List;
import java.util.Map;

import static cc.smtweb.framework.core.common.SwConsts.TOTAL_KEY;

@@ -68,11 +69,24 @@ public class DynPageListHandler extends AbstractListHandler {
return list;
}


@Override
protected SqlNamedPara buildSumSqlPara() {
return DynPageHelper.buildSumSql(pageDataSet, filter);
}

@Override
public R getTotal() {
SqlNamedPara sqlPara = DynPageHelper.buildSumSql(pageDataSet, filter);
SqlNamedPara sqlParaSum = getCache(KEY_SQLPARA_SUM);
if (sqlParaSum == null) {
Map<String, Object> map = getCache(KEY_PARAMS);
if (map != null) params.putAll(map);
sqlParaSum = buildSumSqlPara();
}
if (sqlParaSum == null) return R.success();
setCache(KEY_SQLPARA_SUM, sqlParaSum);

SwMap mapFooter = DbEngine.getInstance().queryEntityN(sqlPara.sql, sqlPara.mapParas, SwMap.class);
SwMap mapFooter = DbEngine.getInstance().queryEntityN(sqlParaSum.sql, sqlParaSum.mapParas, SwMap.class);

SwMap r = new SwMap();
r.put("total", mapFooter.get(TOTAL_KEY));


+ 17
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/dynPage/IBuildSqlListener.java 查看文件

@@ -0,0 +1,17 @@
package cc.smtweb.system.bpm.web.engine.dynPage;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

/**
* Created by Akmm at 2022-08-29 12:24
* 动态构建sql时的监听
*/
public interface IBuildSqlListener {
default void buildWhere(PageDataset dataSet, StringBuilder sql, SwMap args) {
}

default void buildSelect(PageDataset dataSet, StringBuilder sql) {
}
}

+ 37
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java 查看文件

@@ -0,0 +1,37 @@
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.EntityHelper;
import cc.smtweb.framework.core.mvc.service.SqlNamedPara;
import cc.smtweb.framework.core.mvc.service.SqlPara;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageHelper;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.IBuildSqlListener;
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;

/**
* Created by Akmm at 2022-08-29 11:41
*/
public class FlowListHandler extends DynPageListHandler {
static IBuildSqlListener sqlListener = new IBuildSqlListener(){
@Override
public void buildSelect(PageDataset dataSet, StringBuilder sql) {
sql.append("\ninner join " + EntityHelper.getSchemaTableName(ProcInst.ENTITY_NAME) + " on pri_id=" + dataSet.getModelTable().getIdField());
}
};

public FlowListHandler(long pageId, SwMap filter, PageDataset pageDataSet) {
super(pageId, filter, pageDataSet);
}

@Override
protected SqlPara buildSqlPara() {
return DynPageHelper.buildSelectSqlEx(pageDataSet, filter, sqlListener);
}

@Override
protected SqlNamedPara buildSumSqlPara() {
return DynPageHelper.buildSumSqlEx(pageDataSet, filter, sqlListener);
}
}

+ 7
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java 查看文件

@@ -11,6 +11,7 @@ import cc.smtweb.system.bpm.web.design.flow.FlowConst;
import cc.smtweb.system.bpm.web.design.form.ModelForm;
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.engine.dynPage.DynPageListHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
import cc.smtweb.system.bpm.web.engine.flow.FlowHelper;
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance;
@@ -66,4 +67,10 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoad
return R.success(ret);
}

@Override
protected DynPageListHandler getListWorker(SwMap filter, PageDataset pageDataSet) {
FlowListHandler listHandler = new FlowListHandler(form.getId(), filter, pageDataSet);
listHandler.init(params, us);
return listHandler;
}
}

正在加载...
取消
保存