Procházet zdrojové kódy

loadProcInstFields

4.0
郑根木 před 2 roky
rodič
revize
2d260a5940
7 změnil soubory, kde provedl 195 přidání a 20 odebrání
  1. +23
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcService.java
  2. +17
    -17
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java
  3. +15
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java
  4. +55
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillType.java
  5. +34
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeCache.java
  6. +21
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java
  7. +30
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java

+ 23
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/design/flow/ModelProcService.java Zobrazit soubor

@@ -4,11 +4,19 @@ import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
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.service.AbstractCompService;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.DefaultDelHandler;
import cc.smtweb.framework.core.mvc.service.DefaultListHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.design.form.ModelFormHelper;
import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Akmm at 2022/3/22 9:12
@@ -40,5 +48,20 @@ public class ModelProcService extends AbstractCompService {
public R loadModel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_LOAD, handler -> ((ModelProcLoadHandler)handler).loadModel());
}

//加载工作流的列表字段
public R loadProcInstFields(@SwBody SwMap params, UserSession us) {
ModelTable table = ModelTableCache.getInstance().get(ProcInst.ENTITY_NAME);
if (table == null) return R.error("没有找到表定义信息(table=" + ProcInst.ENTITY_NAME + ")!");

List<SwMap> ret = new ArrayList<>();
for (ModelField field : table.getFields()) {
SwMap col = new SwMap(2);
ModelFormHelper.buildFieldInfo(table, field, col);
ret.add(col);
}
return R.success(ret);
}
}

+ 17
- 17
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleSaveHandler.java Zobrazit soubor

@@ -32,10 +32,10 @@ import java.util.Map;
* 保存操作
* 入参:{pageId, data:}
*/
public class LCSingleSaveHandler extends AbstractDynPageHandler {
private Map<String, List<DefaultEntity>> mapTreeBean = new HashMap<>();
public class LCSingleSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
private Map<String, List<T>> mapTreeBean = new HashMap<>();

protected void setNewId(DefaultEntity bean) {
protected void setNewId(T bean) {
bean.setEntityId(DbEngine.getInstance().nextId());
}

@@ -52,7 +52,7 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
//对应的数据集定义
PageDataset pageDataSet = LCSingleHelper.findCardDataset(datasets);
//读取待保存的bean
DefaultEntity bean = readBeanFromPage(pageDataSet, data);
T bean = readBeanFromPage(pageDataSet, data);
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上
setLinkValue(pageDataSet, bean, f -> filter.get(f.name));
}
@@ -84,7 +84,7 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
* @param data
* @return
*/
protected DefaultEntity readBeanFromPage(PageDataset pageDataSet, SwMap pageData) {
protected T readBeanFromPage(PageDataset pageDataSet, SwMap pageData) {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name);
@@ -95,8 +95,8 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {

long id = data.readLong(table.getIdField());

EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(table.getName());
DefaultEntity bean;
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName());
T bean;
if (id <= 0L) {
bean = dao.createBean();
bean.setIsNew(true);
@@ -121,7 +121,7 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
*
* @param bean
*/
protected void checkBean(DefaultEntity bean) {
protected void checkBean(T bean) {
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName());
for (ModelField field : table.getFields()) {
String value = bean.getStr(field.getName());
@@ -139,7 +139,7 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
}
}
//唯一键校验
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(bean.getTableName());
EntityDao<T> dao = DbEngine.getInstance().findDao(bean.getTableName());
for (ModelIndex mi : table.getIndexes()) {
if (mi.isUnique()) {
dao.checkUnique(bean, mi.getFields().split(","));
@@ -147,9 +147,9 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
}
}

protected void saveBean(DefaultEntity bean) {
protected void saveBean(T bean) {
final String tableName = bean.getTableName();
EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(tableName);
EntityDao<T> dao = DbEngine.getInstance().findDao(tableName);
if (bean.isNew()) {
dao.insertEntity(bean);
} else {
@@ -159,18 +159,18 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {

dao.updateEntity(bean);
if (table.getType() == SwEnum.TableType.TYPE_TREE.value) {
List<DefaultEntity> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);
List<T> listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean);
mapTreeBean.put(tableName, listTreeBean);
}
}
}

protected void afterCommit(DefaultEntity bean) {
protected void afterCommit(T bean) {
final String tableName = bean.getTableName();
ModelTable table = ModelTableCache.getInstance().getByName(tableName);
if (table.isNeedCache()) {
AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName);
List<DefaultEntity> listTreeBean = mapTreeBean.get(tableName);
List<T> listTreeBean = mapTreeBean.get(tableName);
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码
if (listTreeBean != null && !listTreeBean.isEmpty()) {
for (DefaultEntity b : listTreeBean) {
@@ -182,17 +182,17 @@ public class LCSingleSaveHandler extends AbstractDynPageHandler {
}
}

protected void afterRollback(DefaultEntity bean) {
protected void afterRollback(T bean) {
final String tableName = bean.getTableName();
ModelTable table = ModelTableCache.getInstance().getByName(tableName);
if (table.isNeedCache()) {
AbstractCache<DefaultEntity> cache = CacheManager.getIntance().getCache(tableName);
AbstractCache<T> cache = CacheManager.getIntance().getCache(tableName);
cache.reset(bean);
}
}

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


+ 15
- 3
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java Zobrazit soubor

@@ -27,15 +27,27 @@ public class LCSingleService extends DynPageService {
case TYPE_MODEL_LIST:
case TYPE_MODEL_LOAD:
case TYPE_MODEL_ADD:
return new LCSingleLoadHandler();
return getLoadHandler();
case TYPE_MODEL_SAVE:
return new LCSingleSaveHandler();
return getSaveHandler();
case TYPE_MODEL_DEL:
return new LCSingleDelHandler();
return getDelHandler();
}
return super.createHandler(type);
}

protected LCSingleSaveHandler getSaveHandler() {
return new LCSingleSaveHandler();
}

protected LCSingleLoadHandler getLoadHandler() {
return new LCSingleLoadHandler();
}

protected LCSingleDelHandler getDelHandler() {
return new LCSingleDelHandler();
}

//保存
public R modelSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCSingleSaveHandler)handler).save());


+ 55
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillType.java Zobrazit soubor

@@ -0,0 +1,55 @@
package cc.smtweb.system.bpm.web.sys.base.billType;

import cc.smtweb.framework.core.annotation.SwTable;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
* Created by 1 at 2022-08-25 18:13:32
* 实体【[单据类型](SYS_BILL_TYPE)】的Entity类
*/
@SwTable("SYS_BILL_TYPE")
public class BillType extends DefaultEntity {
public static final String ENTITY_NAME = "SYS_BILL_TYPE";

public BillType() {
super(ENTITY_NAME);
}

/** 主键 */
public long getId() {
return getLong("sbtp_id");
}

/** 主键 */
public void setId(long sbtp_id) {
put("sbtp_id", sbtp_id);
}
/** 编码 */
public String getCode() {
return getStr("sbtp_code");
}

/** 编码 */
public void setCode(String sbtp_code) {
put("sbtp_code", sbtp_code);
}
/** 名称 */
public String getName() {
return getStr("sbtp_name");
}

/** 名称 */
public void setName(String sbtp_name) {
put("sbtp_name", sbtp_name);
}
/** 备注 */
public String getRemark() {
return getStr("sbtp_remark");
}

/** 备注 */
public void setRemark(String sbtp_remark) {
put("sbtp_remark", sbtp_remark);
}
}

+ 34
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeCache.java Zobrazit soubor

@@ -0,0 +1,34 @@
package cc.smtweb.system.bpm.web.sys.base.billType;

import cc.smtweb.framework.core.annotation.SwCache;
import cc.smtweb.framework.core.cache.AbstractEntityCache;
import cc.smtweb.framework.core.cache.CacheManager;

/**
* Created by 1 at 2022-08-25 18:13:32
* 实体【[单据类型](SYS_BILL_TYPE)】的缓存类
*/
@SwCache(ident = "SYS_BILL_TYPE", title = "单据类型")
public class BillTypeCache extends AbstractEntityCache<BillType> {
//缓存key:按编码
public final static String mk_code = "code";

public static BillTypeCache getInstance() {
return CacheManager.getIntance().getCache(BillTypeCache.class);
}

public BillTypeCache() {
//缓存key:按编码
regMap(mk_code, "sbtp_code");
}

//缓存key:按编码
public final BillType getByCode(String key) {
return getByKey(mk_code, key);
}

public String getName(long id) {
BillType bean = get(id);
return bean != null ? bean.getName() : String.valueOf(id);
}
}

+ 21
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java Zobrazit soubor

@@ -0,0 +1,21 @@
package cc.smtweb.system.bpm.web.sys.base.billType;

import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler;
import org.apache.commons.lang3.StringUtils;

/**
* Created by Akmm at 2022-08-25 19:11
*/
public class BillTypeSaveHandler extends LCSingleSaveHandler<BillType> {
//id=code
@Override
protected void setNewId(BillType bean) {
if (StringUtils.isEmpty(bean.getCode())) {
throw new BizException("编码不能为空!");
}

bean.setId(Long.parseLong(bean.getCode()));
}
}

+ 30
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java Zobrazit soubor

@@ -0,0 +1,30 @@
package cc.smtweb.system.bpm.web.sys.base.billType;

import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.DefaultComboHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;

/**
* Created by 1 at 2022-08-25 18:44:57
* 页面【[单据类型列表]的服务类
*/
@SwService
public class BillTypeService extends LCSingleService {
@Override
protected AbstractHandler createHandler(String type) {
if (TYPE_COMBO.equals(type)) return new DefaultComboHandler<BillType>(BillType.ENTITY_NAME);
return super.createHandler(type);
}

@Override
protected LCSingleSaveHandler getSaveHandler() {
return new BillTypeSaveHandler();
}
}

Načítá se…
Zrušit
Uložit