Explorar el Código

优化:模型代码

4.0
FLYPHT hace 2 años
padre
commit
55a850e24e
Se han modificado 34 ficheros con 509 adiciones y 1048 borrados
  1. +2
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelDelHandler.java
  2. +3
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelListHandler.java
  3. +2
    -14
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelLoadHandler.java
  4. +2
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelSaveHandler.java
  5. +67
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelService.java
  6. +2
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowTransHandler.java
  7. +19
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/IModelDetailReadIntf.java
  8. +13
    -6
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelDelHandler.java
  9. +147
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelDetail.java
  10. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelHelper.java
  11. +5
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelListHandler.java
  12. +10
    -46
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelLoadHandler.java
  13. +10
    -4
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelSaveHandler.java
  14. +10
    -23
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelService.java
  15. +2
    -66
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java
  16. +0
    -84
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java
  17. +0
    -87
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java
  18. +0
    -205
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java
  19. +3
    -3
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Config.java
  20. +0
    -31
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java
  21. +0
    -87
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java
  22. +0
    -31
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java
  23. +31
    -61
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java
  24. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclt2/LCLT2Service.java
  25. +47
    -0
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsConfig.java
  26. +0
    -14
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsDefine.java
  27. +28
    -69
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsDelHandler.java
  28. +6
    -62
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsLoadHandler.java
  29. +53
    -81
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsSaveHandler.java
  30. +35
    -41
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsService.java
  31. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java
  32. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java
  33. +1
    -1
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java
  34. +7
    -7
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowDelHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelDelHandler.java Ver fichero

@@ -1,17 +1,15 @@
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance;
import cc.smtweb.system.bpm.web.engine.flow.FlowListener;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;

/**
* Created by Akmm at 2022-09-01 15:03
* 流程删除
*/
public class FlowDelHandler extends ModelDelHandler implements FlowListener {
public class FlowModelDelHandler extends ModelDelHandler implements FlowListener {
protected FlowInstance flowInstance;

@Override
protected void localDel(long id, ModelTable table) {
long taskId = params.readLong("taskId");

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowListHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelListHandler.java Ver fichero

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

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.EntityHelper;
@@ -12,19 +12,15 @@ import cc.smtweb.system.bpm.web.engine.flow.entity.ProcInst;

/**
* Created by Akmm at 2022-08-29 11:41
* 流程列表handler
*/
public class FlowListHandler extends DynPageListHandler {
public class FlowModelListHandler extends ModelListHandler {
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);

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleLoadHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelLoadHandler.java Ver fichero

@@ -1,25 +1,20 @@
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.SwListData;
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;
import cc.smtweb.system.bpm.web.engine.flow.FlowListener;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;

/**
* Created by Akmm at 2022-08-26 17:15
* 流程加载
*/
public class FlowSingleLoadHandler<T extends DefaultEntity> extends ModelLoadHandler<T> implements FlowListener {
public class FlowModelLoadHandler<T extends DefaultEntity> extends ModelLoadHandler<T> implements FlowListener {
protected FlowInstance flowInstance;

@Override
protected void afterAdd(SwMap ret) {
super.afterAdd(ret);
@@ -51,11 +46,4 @@ public class FlowSingleLoadHandler<T extends DefaultEntity> extends ModelLoadHan
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst()));
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0)));
}

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

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleSaveHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelSaveHandler.java Ver fichero

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

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
@@ -9,15 +9,13 @@ 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;
import cc.smtweb.system.bpm.web.engine.flow.FlowListener;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;

/**
* Created by Akmm at 2022-08-26 16:47
* 带流程的简单卡片之保存
*/
public class FlowSingleSaveHandler<T extends DefaultEntity> extends ModelSaveHandler<T> implements FlowListener {
public class FlowModelSaveHandler<T extends DefaultEntity> extends ModelSaveHandler<T> implements FlowListener {
protected FlowInstance flowInstance;

@Override
protected void readFromPage(SwMap pageData, SwMap filter) {
super.readFromPage(pageData, filter);

+ 67
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowModelService.java Ver fichero

@@ -0,0 +1,67 @@
package cc.smtweb.system.bpm.web.engine.model.common;

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.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.IWorker;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;

/**
* Created by Akmm at 2022-08-26 16:35
* 带工作流的简单列表+卡片
*/
@SwService
public class FlowModelService extends LCSingleService {
public static final String TYPE_FLOW = "flow";

@Override
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_LIST:
return new FlowModelListHandler();
case TYPE_MODEL_LOAD:
return new FlowModelLoadHandler<DefaultEntity>();
case TYPE_MODEL_SAVE:
return new FlowModelSaveHandler<DefaultEntity>();
case TYPE_MODEL_DEL:
return new FlowModelDelHandler();
}
return super.createHandler(type);
}
protected R flowHandler(SwMap params, UserSession us, IWorker<FlowTransHandler> worker) {
try {
FlowTransHandler handler = (FlowTransHandler) getHandler(params, us, TYPE_FLOW);
return worker.doWork(handler);
} catch (Exception e) {
return R.error("操作失败!", e);
}
}

public R submit(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::submit);
}

public R retake(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::retake);
}

public R reject(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::reject);
}

public R disuse(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::disuse);
}

public R handle(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::handle);
}

public R interrupt(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::interrupt);
}
}

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowTransHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/FlowTransHandler.java Ver fichero

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

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
@@ -11,7 +11,6 @@ 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;
import cc.smtweb.system.bpm.web.engine.flow.FlowListener;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper;

/**
* Created by Akmm at 2022-09-01 15:03
@@ -34,7 +33,7 @@ public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHa
private SwMap buildRetData() {
SwMap ret = new SwMap();
ret.put(ModelHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean));
flowInstance.setPageRetExtra(ret);
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst()));
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY));

+ 19
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/IModelDetailReadIntf.java Ver fichero

@@ -0,0 +1,19 @@
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.db.impl.DefaultEntity;

/**
* Created by Zhenggm at 11-9-26 下午3:00
* 单据明细变动接口
*/
public interface IModelDetailReadIntf<T extends DefaultEntity> {
/**
* 构造返回新的明细对象
*/
T getNewInstance();

/**
* 读取后设置
*/
void doAfterRead(boolean isNew, T bean);
}

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelDelHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelDelHandler.java Ver fichero

@@ -1,4 +1,4 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
@@ -15,10 +15,18 @@ import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;

/**
* Created by Akmm at 2022/4/21 17:53
* 删除操作
* 模型删除handler
*/
public class ModelDelHandler extends AbstractDynPageHandler {
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;
private String cardDsName = ModelHelper.DATASET_NAME_CARD;

public ModelDelHandler() {
}

public ModelDelHandler(String cardDsName) {
this.cardDsName = cardDsName;
}

/**
* 删除指定数据集,入参{pageId, dataset, id}
*
@@ -29,8 +37,7 @@ public class ModelDelHandler extends AbstractDynPageHandler {
if (id == 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//数据集
PageDataset pageDataSet = findCardDataset(cardDsName);

checkBean(pageDataSet, id);
checkDel(pageDataSet,id);

DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
@@ -79,7 +86,7 @@ public class ModelDelHandler extends AbstractDynPageHandler {
* @param pageDataSet
* @param id
*/
protected void checkBean(PageDataset pageDataSet, long id) {
protected void checkDel(PageDataset pageDataSet, long id) {
//校验外键引用关系
EntityHelper.checkExists(pageDataSet.masterTable, id);
}

+ 147
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelDetail.java Ver fichero

@@ -0,0 +1,147 @@
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.util.CommUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

/**
* @Author: tanghp
* @Date: 2022-09-15 17:27
* @Desc: 模型明细处理类
*/
public class ModelDetail<T extends DefaultEntity> {
//页面上新增的行
protected List<T> insertList = new ArrayList<T>();
//页面上修改的行
protected List<T> updateList = new ArrayList<T>();
//页面上删除的行Id
protected List<Long> deleteList = new ArrayList<Long>();

public List<T> getInsertList() {
return insertList;
}

public List<T> getUpdateList() {
return updateList;
}

public List<Long> getDeleteList() {
return deleteList;
}

public void setInsertList(List<T> insertList) {
this.insertList = insertList;
}

public void setUpdateList(List<T> updateList) {
this.updateList = updateList;
}

public void setDeleteList(List<Long> deleteList) {
this.deleteList = deleteList;
}

public void addInsert(T t) {
insertList.add(t);
}

public void addUpdate(T t) {
updateList.add(t);
}

public void addDelete(long id) {
deleteList.add(id);
}

//从页面对象读取
public void readFromMap(String key, SwMap pageData, IModelDetailReadIntf<T> intf){
SwMap details = pageData.readMap(key);
List<Map<String,Object>> inserted = details.readListMap("inserted");
if(!CommUtil.isEmpty(inserted)){
inserted.forEach((row)-> {
T bean = intf.getNewInstance();
bean.init();
bean.getData().putAll(row);
intf.doAfterRead(true,bean);
});
}
List<Map<String,Object>> updated = details.readListMap("updated");
if(!CommUtil.isEmpty(updated)){
updated.forEach((row)-> {
T bean = intf.getNewInstance();
bean.init();
bean.getData().putAll(row);
intf.doAfterRead(false,bean);
});
}
Set<Long> deleted = details.readLongSet("deleted");
if(!CommUtil.isEmpty(deleted)){
deleteList.addAll(deleted);
}
}

public void batchSave(EntityDao<T> dao) {
if (!CommUtil.isEmpty(this.deleteList)) {
dao.deleteEntity(this.deleteList);
}
if (!CommUtil.isEmpty(this.updateList)) {
dao.batchUpdateEntity(this.updateList);
}
if (!CommUtil.isEmpty(this.insertList)) {
dao.batchInsertEntity(this.insertList);
}
}

public void readFromMap(PageDataset pageDataset, SwMap pageData, BiConsumer<Boolean,T> consumer){
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable);
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataset.name);
SwMap details = pageData.readMap(pageDataset.name);
if (details == null) throw new BizException("没有找到待保存的表数据:" + pageDataset.name);
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getTableName());
List<Map<String,Object>> inserted = details.readListMap("inserted");
if(!CommUtil.isEmpty(inserted)){
inserted.forEach((row)-> {
T bean = dao.createBean();
bean.init();
bean.getData().putAll(row);
if(consumer!=null){
consumer.accept(true,bean);
}
});
}
List<Map<String,Object>> updated = details.readListMap("updated");
if(!CommUtil.isEmpty(updated)){
updated.forEach((row)-> {
T bean = dao.createBean();
bean.init();
bean.getData().putAll(row);
if(consumer!=null){
consumer.accept(false,bean);
}
});
}
Set<Long> deleted = details.readLongSet("deleted");
if(!CommUtil.isEmpty(deleted)){
deleteList.addAll(deleted);
}
}

public void batchSave(PageDataset pageDataset) {
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable);
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataset.name);
EntityDao<T> dao = DbEngine.getInstance().findDao(table.getTableName());
batchSave(dao);
}
}

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelHelper.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelHelper.java Ver fichero

@@ -1,4 +1,4 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelListHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelListHandler.java Ver fichero

@@ -1,4 +1,4 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
@@ -13,10 +13,10 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;

/**
* Created by Akmm at 2022-09-15 15:01
* 列表类服务handler
* 模型列表handler
*/
public class ModelListHandler extends DynPageListHandler {
protected String dsName;
protected String dsName = ModelHelper.DATASET_NAME_LIST;
private ModelListHandler(long pageId, SwMap filter, PageDataset pageDataSet) {
super(pageId, filter, pageDataSet);
}
@@ -24,7 +24,9 @@ public class ModelListHandler extends DynPageListHandler {
public ModelListHandler(String dsName) {
this.dsName = dsName;
}
public ModelListHandler() {

}
@Override
public void init(SwMap params, UserSession us) {
super.init(params, us);

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelLoadHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelLoadHandler.java Ver fichero

@@ -1,4 +1,4 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwConsts;
@@ -10,15 +10,22 @@ import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.SwException;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageListHandler;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;

/**
* Created by Akmm at 2022-08-16 15:43
* 模型卡片加载handler
*/
public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
protected T bean;
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;
private String cardDsName = ModelHelper.DATASET_NAME_CARD;

public ModelLoadHandler() {
}

public ModelLoadHandler(String cardDsName) {
this.cardDsName = cardDsName;
}

//新增卡片操作,初始化定义的数据集
public R add() {
@@ -70,47 +77,4 @@ public class ModelLoadHandler<T extends DefaultEntity> extends AbstractDynPageHa
ret.put(dsName, DynRetBean.createBean(bean));
return bean;
}


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

/**
* 列表数据
*
* @return
*/
protected R list(String dsName) {
//过滤条件
SwMap filter = params.readMap("filter");
//对应的数据集定义
PageDataset pageDataSet = findListDataset(dsName);
DynRetBean bean = DynRetBean.createList(getListWorker(filter, pageDataSet).buildListData());
return R.success(bean);
}

protected R getTotal(String dsName) {
//数据集
PageDataset pageDataSet = findListDataset(dsName);
//过滤条件
SwMap filter = params.readMap("filter");

return getListWorker(filter, pageDataSet).getTotal();
}

public R list() {
return list(ModelHelper.DATASET_NAME_LIST);
}

/**
* 计算分页数据
*
* @return
*/
public R getTotal() {
return getTotal(ModelHelper.DATASET_NAME_LIST);
}
}

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelSaveHandler.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelSaveHandler.java Ver fichero

@@ -1,4 +1,4 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
@@ -27,13 +27,20 @@ import java.util.Map;

/**
* Created by Akmm at 2022/4/21 17:53
* 模型保存操作
* 模型保存handler
* 入参:{pageId, data:}
*/
public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
private Map<String, List<? extends DefaultEntity>> mapTreeBean = new HashMap<>();
protected T bean;
protected String cardDsName = ModelHelper.DATASET_NAME_CARD;
private String cardDsName = ModelHelper.DATASET_NAME_CARD;

public ModelSaveHandler() {
}

public ModelSaveHandler(String cardDsName) {
this.cardDsName = cardDsName;
}

/**
* 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}}
@@ -118,7 +125,6 @@ public class ModelSaveHandler<T extends DefaultEntity> extends AbstractDynPageHa
}
return vo;
}

/**
* 保存校验
*

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/ModelService.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/common/ModelService.java Ver fichero

@@ -1,19 +1,19 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;
package cc.smtweb.system.bpm.web.engine.model.common;

import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;

/**
* Created by Akmm at 2022-08-12 15:37
* 单页面简单列表卡片服务类
* 模型通用服务类
*/
public class ModelService extends DynPageService {
public final static String TYPE_MODEL_LIST = "modelList";
public final static String TYPE_MODEL_ADD = "modelAdd";
public final static String TYPE_MODEL_LOAD = "modelLoad";
public final static String TYPE_MODEL_SAVE = "modelSave";
public final static String TYPE_MODEL_DEL = "modelDel";
@@ -22,29 +22,16 @@ public class ModelService extends DynPageService {
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_LIST:
return new ModelListHandler();
case TYPE_MODEL_LOAD:
case TYPE_MODEL_ADD:
return getLoadHandler();
return new ModelLoadHandler<DefaultEntity>();
case TYPE_MODEL_SAVE:
return getSaveHandler();
return new ModelSaveHandler<DefaultEntity>();
case TYPE_MODEL_DEL:
return getDelHandler();
return new ModelDelHandler();
}
return super.createHandler(type);
}

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

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

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

//保存
public R modelSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((ModelSaveHandler) handler).save());
@@ -57,7 +44,7 @@ public class ModelService extends DynPageService {

//读取
public R modelAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((ModelLoadHandler) handler).add());
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((ModelLoadHandler) handler).add());
}

//删除
@@ -67,11 +54,11 @@ public class ModelService extends DynPageService {

//列表数据
public R modelList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelLoadHandler) handler).list());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelListHandler) handler).data());
}

//列表总记录数及合计栏
public R modelListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelLoadHandler) handler).getTotal());
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((ModelListHandler) handler).getTotal());
}
}

+ 2
- 66
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/flow/listcard/single/FlowSingleService.java Ver fichero

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

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.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.IWorker;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;
import cc.smtweb.system.bpm.web.engine.model.common.FlowModelService;

/**
* Created by Akmm at 2022-08-26 16:35
* 带工作流的简单列表+卡片
*/
@SwService
public class FlowSingleService extends LCSingleService {
public static final String TYPE_FLOW = "flow";

@Override
protected AbstractHandler createHandler(String type) {
if (TYPE_FLOW.equals(type)) return new FlowTransHandler();
return super.createHandler(type);
}

@Override
protected ModelSaveHandler getSaveHandler() {
return new FlowSingleSaveHandler();
}

@Override
protected ModelLoadHandler getLoadHandler() {
return new FlowSingleLoadHandler();
}

@Override
protected ModelDelHandler getDelHandler() {
return new FlowDelHandler();
}

protected R flowHandler(SwMap params, UserSession us, IWorker<FlowTransHandler> worker) {
try {
FlowTransHandler handler = (FlowTransHandler) getHandler(params, us, TYPE_FLOW);
return worker.doWork(handler);
} catch (Exception e) {
return R.error("操作失败!", e);
}
}

public R submit(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::submit);
}

public R retake(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::retake);
}

public R reject(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::reject);
}

public R disuse(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::disuse);
}

public R handle(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::handle);
}

public R interrupt(@SwBody SwMap params, UserSession us) {
return flowHandler(params, us, FlowTransHandler::interrupt);
}
public class FlowSingleService extends FlowModelService {
}

+ 0
- 84
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsDelHandler.java Ver fichero

@@ -1,84 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;

import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils;

/**
* @Author:lip
* @Date : 2022/9/2 15:03
*/
public abstract class AbsDelHandler extends AbstractDynPageHandler {
/**
* 删除指定数据集,入参{pageId, dataset, id}
*
* @return
*/
protected void doDel(String dsName) {
long id = params.readLong("id");
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
//数据集
PageDataset pageDataset = ModelUtils.findPageDatasetByName(this.datasets, dsName);
//
checkBean(pageDataset, id);
//
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
public void work() {
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable);
if (table == null) throw new BizException("没有找到指定的的表定义:" + pageDataset.name + "!");
EntityDao dao = DbEngine.getInstance().findDao(table.getName());
dao.deleteEntity(id);
localDel(id, table);
}

@Override
public void doAfterDbCommit() {
ModelTable table = ModelTableCache.getInstance().get(pageDataset.masterTable);
if (table.isNeedCache()) {
AbstractCache cache = CacheManager.getIntance().getCache(table.getName());
cache.remove(id);
}
afterCommit(id, table);
}

@Override
public void doAfterDbRollback() {
afterRollback(id);
}
});
}

//回调:::删除之后
protected void localDel(long id, ModelTable table) {
}

//回调:::提交成功后
protected void afterCommit(long id, ModelTable table) {
}

//回调:::提交失败,事务回滚后
protected void afterRollback(long id) {

}

/**
* 删除校验
*
* @param pageDataSet
* @param id
*/
protected void checkBean(PageDataset pageDataSet, long id) {
//校验外键引用关系
EntityHelper.checkExists(pageDataSet.masterTable, id);
}
}

+ 0
- 87
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsLoadHandler.java Ver fichero

@@ -1,87 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
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.DynRetBean;
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils;
import org.springframework.util.Assert;

/**
* @Author:lip
* @Date : 2022/9/2 15:03
*/
public abstract class AbsLoadHandler extends AbstractDynPageHandler {

/**
* 新增初始化
*
* @param dsName
* @return
*/
protected SwMap doAdd(String dsName) {
PageDataset addDataSet = this.datasets.findByName(dsName);
Assert.notNull(addDataSet, "未获取到数据集:" + dsName);
SwMap data;
//懒加载,给个空对象
if (addDataSet.lazy) {
data = new SwMap();
} else {
data = DynPageHelper.createBean(addDataSet);
}
return data;
}

/**
* 加载卡片数据
*
* @param dsName
* @return
*/
protected SwMap doLoadCard(String dsName) {
//过滤条件
SwMap filter = params.readMap("filter");
//对应的数据集定义
PageDataset loadDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);
return provider.loadData(filter, loadDataSet);
}

/**
* 列表数据
*
* @return
*/
protected DynRetBean doList(String dsName) {
//过滤条件
SwMap filter = params.readMap("filter");

//对应的数据集定义
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);

return DynRetBean.createList(getListWorker(filter, listDataSet).buildListData());
}

/**
* 计算分页数据
*
* @return
*/
protected R doTotal(String dsName) {
//过滤条件
SwMap filter = params.readMap("filter");

//对应的数据集定义
PageDataset listDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);

return getListWorker(filter, listDataSet).getTotal();
}

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

+ 0
- 205
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/abshandler/AbsSaveHandler.java Ver fichero

@@ -1,205 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.abshandler;

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.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelField;
import cc.smtweb.framework.core.db.vo.ModelIndex;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.mvc.service.TreeHelper;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.design.form.define.PageDatasetFilter;
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils;
import org.apache.commons.lang3.StringUtils;

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

/**
* @Author:lip
* @Date : 2022/9/2 15:02
*/
public abstract class AbsSaveHandler<T extends DefaultEntity> extends AbstractDynPageHandler {
private Map<String, List<T>> mapTreeBean = new HashMap<>();

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

protected T doSave(String dsName) {
//数据集
SwMap filter = params.readMap("filter");
//待保存数据
SwMap data = params.readMap("data");
if (data == null) throw new BizException("没有收到待保存的的数据:" + dsName + "!");
//对应的数据集定义
PageDataset pageDataSet = ModelUtils.findPageDatasetByName(this.datasets, dsName);
//读取待保存的bean
T bean = readBeanFromPage(pageDataSet, data.readMap(dsName).readMap("form"));
if (filter != null && bean.isNew()) {//有过滤条件,将关联的值设上
setLinkValue(pageDataSet, bean, f -> filter.get(f.name));
}
checkBean(bean);

DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
public void work() {
saveBean(bean);
}

@Override
public void doAfterDbCommit() {
afterCommit(bean);
}

@Override
public void doAfterDbRollback() {
afterRollback(bean);
}
});
return bean;
}

/**
* 从页面获取待保存的bean
*
* @param pageDataSet
* @param data
* @return
*/
protected T readBeanFromPage(PageDataset pageDataSet, SwMap data) {
ModelTable table = ModelTableCache.getInstance().get(pageDataSet.masterTable);
if (table == null) throw new BizException("没有找到待保存的表定义:" + pageDataSet.name);

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

EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName());
T bean;
if (id <= 0L) {
bean = dao.createBean();
bean.setIsNew(true);
//暂时不考虑list保存的情况
bean.getData().putAll(data);
bean.setEntityId(DbEngine.getInstance().nextId());
} else {
bean = dao.queryEntity(id);
if (bean == null) {
throw new BizException("没有找到待保存的记录:" + table.getName() + "." + id);
}
//暂时不考虑list保存的情况
bean.getData().putAll(data);
bean.setIsNew(false);
}
return bean;
}

/**
* 保存校验
*
* @param bean
*/
protected void checkBean(T bean) {
ModelTable table = ModelTableCache.getInstance().getByName(bean.getTableName());
for (ModelField field : table.getFields()) {
String value = bean.getStr(field.getName());
//非空校验
if (field.isNotNull() && StringUtils.isEmpty(value)) {
throw new BizException("字段不允许为空:" + field.getTitle());
}

//长度校验
if (StringUtils.isNotEmpty(value)) {
int len = SwEnum.DataType.instance.getByValue(field.getDataType()).dataLength;
if (len > 0 && StringUtil.getStrLenB(value) > len) {
throw new BizException("字段值超长:" + field.getTitle());
}
}
}
//唯一键校验
EntityDao<T> dao = DbEngine.getInstance().findDao(bean.getTableName());
for (ModelIndex mi : table.getIndexes()) {
if (mi.isUnique()) {
dao.checkUnique(bean, mi.getFields().split(","));
}
}
}

protected void saveBean(T bean) {
final String tableName = bean.getTableName();
EntityDao<T> dao = DbEngine.getInstance().findDao(tableName);
if (bean.isNew()) {
dao.insertEntity(bean);
} else {
ModelTable table = ModelTableCache.getInstance().getByName(tableName);
ModelField field = table.findFieldByType(SwEnum.FieldType.UPDATE_USER.value);
if (field != null) bean.put(field.getName(), us.getUserId());

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

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<T> listTreeBean = mapTreeBean.get(tableName);
//树型表,父亲改变了,要多处理下缓存;还有个东东:级次码
if (listTreeBean != null && !listTreeBean.isEmpty()) {
for (DefaultEntity b : listTreeBean) {
cache.put(b);
}
} else {
cache.put(bean);
}
}
}

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

//将关联的值设上
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);
//有值,就不管
if (v != null && !v.equals(table.findField(f.field).getDefaultValue())) continue;

if (SwEnum.FilterType.CONST.value.equals(f.type)) {//常量
bean.put(f.field, f.value);
} else if (SwEnum.FilterType.PARAM.value.equals(f.type)) {//参数
bean.put(f.field, f.value);
} else if (SwEnum.FilterType.LINK.value.equals(f.type)) {//参数
Object value = iGetValue.getValue(f);
if (value != null) {
bean.put(f.field, value);
}
}
}
}

public interface IGetValue {
Object getValue(PageDatasetFilter f);
}
}

smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Define.java → smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Config.java Ver fichero

@@ -4,9 +4,9 @@ package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;
* @Author:lip
* @Date : 2022/9/2 12:00
*/
public class LCLC1Define {
public class LCLC1Config {
public static final String dsLList = "lList";
public static final String dsLCard = "lCard";
public static final String dsRList = "rList";
public static final String dsRCard = "rCard";
public static final String dsRList = "list";
public static final String dsRCard = "card";
}

+ 0
- 31
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1DelHandler.java Ver fichero

@@ -1,31 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;

/**
* @Author:lip
* @Date : 2022/9/2 11:44
*/
public class LCLC1DelHandler extends ModelDelHandler {

/**
* 左列表删除
*
* @return
*/
public R lDel() {
cardDsName = LCLC1Define.dsLCard;
return super.del();
}

/**
* 右列表删除
*
* @return
*/
public R rDel() {
cardDsName = LCLC1Define.dsRCard;
return super.del();
}
}

+ 0
- 87
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1LoadHandler.java Ver fichero

@@ -1,87 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;

/**
* @Author:lip
* @Date : 2022/9/2 11:44
*/
public class LCLC1LoadHandler extends ModelLoadHandler<DefaultEntity> {
/**
* 左表新增
*
* @return
*/
public R lAdd() {
cardDsName = LCLC1Define.dsLCard;
return super.add();
}

/**
* 右表新增
*
* @return
*/
public R rAdd() {
cardDsName = LCLC1Define.dsRCard;
return super.add();
}

/**
* 左表编辑
*
* @return
*/
public R lLoad() {
cardDsName = LCLC1Define.dsLCard;
return super.load();
}

/**
* 右表编辑
*
* @return
*/
public R rLoad() {
cardDsName = LCLC1Define.dsRCard;
return super.load();
}

/**
* 左列表加载
*
* @return
*/
public R lList() {
return super.list(LCLC1Define.dsLList);
}

/**
* 右列表加载
*
* @return
*/
public R rList() {
return super.list(LCLC1Define.dsRList);
}

/**
* 左列表分页数据
*
* @return
*/
public R getLTotal() {
return super.getTotal(LCLC1Define.dsLList);
}

/**
* 右列表分页数据
*
* @return
*/
public R getRTotal() {
return super.getTotal(LCLC1Define.dsRList);
}
}

+ 0
- 31
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1SaveHandler.java Ver fichero

@@ -1,31 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lclc1;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;

/**
* @Author:lip
* @Date : 2022/9/2 11:44
*/
public class LCLC1SaveHandler extends ModelSaveHandler<DefaultEntity> {
/**
* 左表保存
*
* @return
*/
public R lSave() {
cardDsName = LCLC1Define.dsLCard;
return super.save();
}

/**
* 右表保存
*
* @return
*/
public R rSave() {
cardDsName = LCLC1Define.dsRCard;
return super.save();
}
}

+ 31
- 61
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclc1/LCLC1Service.java Ver fichero

@@ -4,11 +4,10 @@ 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.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelDelHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelLoadHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;
import cc.smtweb.system.bpm.web.engine.model.common.*;

/**
* @Author:lip
@@ -16,80 +15,51 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;
*/
@SwService
public class LCLC1Service extends ModelService {
@Override
protected ModelSaveHandler getSaveHandler() {
return new LCLC1SaveHandler();
}

@Override
protected ModelLoadHandler getLoadHandler() {
return new LCLC1LoadHandler();
}
public final static String TYPE_MODEL_LEFT_LIST = "modelLList";
public final static String TYPE_MODEL_LEFT_LOAD = "modelLLoad";
public final static String TYPE_MODEL_LEFT_SAVE = "modelLSave";
public final static String TYPE_MODEL_LEFT_DEL = "modelLDel";

@Override
protected ModelDelHandler getDelHandler() {
return new LCLC1DelHandler();
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_LEFT_LIST:
return new ModelListHandler(LCLC1Config.dsLList);
case TYPE_MODEL_LEFT_LOAD:
return new ModelLoadHandler<DefaultEntity>(LCLC1Config.dsLCard);
case TYPE_MODEL_LEFT_SAVE:
return new ModelSaveHandler<DefaultEntity>(LCLC1Config.dsLCard);
case TYPE_MODEL_LEFT_DEL:
return new ModelDelHandler(LCLC1Config.dsLCard);
}
return super.createHandler(type);
}

//保存
//左表保存
public R modelLSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler) handler).lSave());
return pageHandler(params, us, TYPE_MODEL_LEFT_SAVE, handler -> ((ModelSaveHandler) handler).save());
}

//读取
//左表读取
public R modelLLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler) handler).lLoad());
return pageHandler(params, us, TYPE_MODEL_LEFT_LOAD, handler -> ((ModelLoadHandler) handler).load());
}

//读取
//左表读取
public R modelLAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler) handler).lAdd());
return pageHandler(params, us, TYPE_MODEL_LEFT_LOAD, handler -> ((ModelLoadHandler) handler).add());
}

//删除
//左表删除
public R modelLDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).lDel());
return pageHandler(params, us, TYPE_MODEL_LEFT_DEL, handler -> ((ModelDelHandler) handler).del());
}

//列表数据
//左表列表数据
public R modelLList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).lList());
return pageHandler(params, us, TYPE_MODEL_LEFT_LIST, handler -> ((ModelListHandler) handler).data());
}

//列表总记录数及合计栏
//左表列表总记录数及合计栏
public R modelLListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).getLTotal());
}

//右表
//保存
public R modelRSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SAVE, handler -> ((LCLC1SaveHandler) handler).rSave());
}

//读取
public R modelRLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCLC1LoadHandler) handler).rLoad());
}

//读取
public R modelRAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCLC1LoadHandler) handler).rAdd());
}

//删除
public R modelRDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCLC1DelHandler) handler).rDel());
return pageHandler(params, us, TYPE_MODEL_LEFT_LIST, handler -> ((ModelListHandler) handler).getTotal());
}

//列表数据
public R modelRList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).rList());
}

//列表总记录数及合计栏
public R modelRListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCLC1LoadHandler) handler).getRTotal());
}

}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lclt2/LCLT2Service.java Ver fichero

@@ -1,7 +1,7 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lclt2;

import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;
import cc.smtweb.system.bpm.web.engine.model.common.ModelService;

/**
* @Author:lip


+ 47
- 0
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsConfig.java Ver fichero

@@ -0,0 +1,47 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lcms;

import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.framework.core.util.StringUtil;
import cc.smtweb.system.bpm.web.design.form.ModelForm;

/**
* @Author:lip
* @Date : 2022/9/2 17:06
* 主子表配置信息类
*/
public class LCMsConfig {
//列表主表数据集
public static final String dsList = "list";
//卡片主表数据集
public static final String dsCard = "card";
//卡片子表列表数据集
public static final String dsSList = "listSub";
//卡片子表卡片数据集
public static final String dsSCard = "cardSub";
// 模型的配置信息类
static class Config{
private final ModelForm modelForm;

public Config(ModelForm modelForm) {
this.modelForm = modelForm;
}

// 获取子表的主表外键字段
public String getSubFKField(){
String subFKField = modelForm.getOpts().readMap("config").readMap("props").readString("subForeignKey", "");;
if(StringUtil.isEmpty(subFKField)){
throw new BizException("未获取到子表外键配置");
}
return subFKField;
}
// 获取子表ID
public long getSubTableId(){
long subTableId = modelForm.getOpts().readMap("config").readMap("props").readLong("subTable");;
if(subTableId<=0L){
throw new BizException("未获取到子表配置");
}
return subTableId;
}
}

}

+ 0
- 14
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsDefine.java Ver fichero

@@ -1,14 +0,0 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lcms;

/**
* @Author:lip
* @Date : 2022/9/2 17:06
*/
public class LCMsDefine {
//列表主表数据集
public static final String dsMList = "list";
//卡片主表数据集
public static final String dsMCard = "cardMaster";
//卡片子表模型数据集
public static final String dsSList = "listSub";
}

+ 28
- 69
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsDelHandler.java Ver fichero

@@ -1,87 +1,46 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lcms;

import cc.smtweb.framework.core.cache.AbstractCache;
import cc.smtweb.framework.core.cache.CacheManager;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.EntityHelper;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsDelHandler;
import org.springframework.util.Assert;

import java.util.List;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.model.common.ModelDelHandler;

/**
* @Author:lip
* @Date : 2022/8/28 20:40
* 主子表删除handler
*/
public class LCMsDelHandler extends AbsDelHandler {
public class LCMsDelHandler extends ModelDelHandler {
@Override
protected void checkDel(PageDataset pageDataSet, long id) {
super.checkDel(pageDataSet, id);
// 子表删除校验
}

/**
* 列表删除
*
* @return
*/
public R del() {
return doDel();
@Override
protected void localDel(long id, ModelTable table) {
super.localDel(id, table);
// 获取主子表模型配置
LCMsConfig.Config config = new LCMsConfig.Config(form);
// 子表删除
batchDelDetail(config.getSubTableId(),config.getSubFKField(),id);
}

/**
* 删除指定数据集,入参{pageId, dataset, id}
*
* @return
* 批量删除明细 供子类调用
* @param tableId 表定义ID
* @param fk 关联字段
* @param id 主表ID
*/
private R doDel() {
long id = params.readLong("id");
if (id <= 0L) throw new BizException("没有收到待删除记录Id(" + id + ")!");
SwMap props = form.getOpts().readMap("config").readMap("props");
//主表
ModelTable masterTable = ModelTableCache.getInstance().get(props.readLong("masterTable", -1L));
Assert.notNull(masterTable, "未获取到主表配置");

//获取子表
ModelTable subTable = ModelTableCache.getInstance().get(props.readLong("subTable", -1L));
String subForeignKey = props.readString("subForeignKey", "-1");
Assert.isTrue(subTable != null && !subForeignKey.equals("-1"), "未获取到子表配置");

//
DbEngine engine = DbEngine.getInstance();
EntityDao<? extends DefaultEntity> masterDao = engine.findDao(masterTable.getName());
EntityDao<? extends DefaultEntity> subDao = engine.findDao(subTable.getName());
//
List<? extends DefaultEntity> delDetails = subDao.queryWhere(subForeignKey + " = ?", id);
checkDetails(delDetails);
DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
public void work() {
subDao.batchDelete(delDetails);
//
EntityHelper.checkExists(masterTable.getId(), id);
masterDao.deleteEntity(id);
}

@Override
public void doAfterDbCommit() {
if (masterTable.isNeedCache()) {
AbstractCache cache = CacheManager.getIntance().getCache(masterTable.getName());
cache.remove(id);
}
if (subTable.isNeedCache()) {
AbstractCache cache = CacheManager.getIntance().getCache(masterTable.getName());
cache.remove(id);
}
}
});
return R.success();
}

protected void checkDetails(List<? extends DefaultEntity> details) {
details.forEach(item -> EntityHelper.checkExists(item.getModelTable().getId(), item.getEntityId()));
protected void batchDelDetail(long tableId,String fk,long id){
if(tableId<=0L)return;
ModelTable table = ModelTableCache.getInstance().get(tableId);
if(table == null) return;
EntityDao dao =DbEngine.getInstance().findDao(table.getTableName());
if(dao!=null){
dao.deleteEntity(String.format(" where %s = ? ",fk),id);
}
}
}

+ 6
- 62
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsLoadHandler.java Ver fichero

@@ -1,70 +1,14 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lcms;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean;
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsLoadHandler;

import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.system.bpm.web.engine.model.common.ModelLoadHandler;

/**
* @Author:lip
* @Date : 2022/8/28 21:44
* 主子表表单数据加载Handler
*/
public class LCMsLoadHandler extends AbsLoadHandler {
/**
* 主表新增
*
* @return
*/
public R mAdd() {
SwMap data = doAdd(LCMsDefine.dsMCard);
return R.success(ModelUtils.buildRetData(LCMsDefine.dsMCard, data));
}

/**
* 主表编辑
*
* @return
*/
public R mLoad() {
SwMap bean = doLoadCard(LCMsDefine.dsMCard);
return R.success(ModelUtils.buildRetData(LCMsDefine.dsMCard, bean));
}

/**
* 主表列表加载
*
* @return
*/
public R mList() {
DynRetBean list = doList(LCMsDefine.dsMList);
return R.success(list);
}

/**
* 子列表加载
*
* @return
*/
public R sList() {
DynRetBean list = doList(LCMsDefine.dsSList);
return R.success(list);
}

/**
* 主列表分页数据
*
* @return
*/
public R getMTotal() {
return doTotal(LCMsDefine.dsMList);
}
public class LCMsLoadHandler<T extends DefaultEntity> extends ModelLoadHandler<T> {

/**
* 子列表分页数据
*
* @return
*/
public R getSTotal() {
return doTotal(LCMsDefine.dsSList);
}
}

+ 53
- 81
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsSaveHandler.java Ver fichero

@@ -1,101 +1,73 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.lcms;

import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
import cc.smtweb.framework.core.db.cache.ModelTableCache;
import cc.smtweb.framework.core.db.impl.DefaultEntity;
import cc.smtweb.framework.core.db.jdbc.IDbWorker;
import cc.smtweb.framework.core.db.vo.ModelTable;
import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.system.bpm.web.design.form.define.PageDataset;
import cc.smtweb.system.bpm.web.engine.model.listcard.ModelUtils;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.AbsSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelHelper;
import org.springframework.util.Assert;
import cc.smtweb.system.bpm.web.engine.model.common.ModelDetail;
import cc.smtweb.system.bpm.web.engine.model.common.ModelSaveHandler;

import java.util.ArrayList;
import java.util.Set;
import java.util.function.BiConsumer;

/**
* @Author:lip
* @Date : 2022/8/28 21:03
* 主子表保存handler
*/
public class LCMsSaveHandler extends AbsSaveHandler<DefaultEntity> {
/**
* 保存指定数据集操作,入参:{pageId,dataset:"", data:{form:{},list: {total:0,rows:[]}}, filter:{}}
*/
public R save() {
//对应的数据集定义
PageDataset masterDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsMCard);
PageDataset subDataSet = ModelUtils.findPageDatasetByName(this.datasets, LCMsDefine.dsSList);
//
SwMap filter = params.readMap("filter");

//待保存数据
SwMap data = params.readMap("data");
if (data == null) throw new BizException("没有收到待保存的的数据:" + LCMsDefine.dsMCard + "!");
public class LCMsSaveHandler<T extends DefaultEntity> extends ModelSaveHandler<T> {
// 子表明细
protected ModelDetail subDetail;

//获取子表关联字段
String subForeignKey = form.getOpts().readMap("config").readMap("props").readString("subForeignKey", "-1");
Assert.isTrue(!subForeignKey.equals("-1"), "未获取到子表外键配置");

//读取待保存的bean
DefaultEntity masterBean = readBeanFromPage(masterDataSet, data.readMap(LCMsDefine.dsMCard).readMap("form"));
if (filter != null && masterBean.isNew()) {
//有过滤条件,将关联的值设上
setLinkValue(masterDataSet, masterBean, f -> filter.get(f.name));
}
// 读取子表数据
SwMap details = params.readMap("details");
Assert.notNull(details, "没有收到待保存的明细数据");
//
ArrayList<DefaultEntity> inserted = new ArrayList<>();
ArrayList<DefaultEntity> updated = new ArrayList<>();
details.readListMap("inserted").forEach(row -> {
SwMap rowData = new SwMap();
rowData.putAll(row);
DefaultEntity insertBean = readBeanFromPage(subDataSet, rowData);
insertBean.put(subForeignKey, masterBean.getEntityId());
inserted.add(insertBean);
});
details.readListMap("updated").forEach(row -> {
SwMap rowData = new SwMap();
rowData.putAll(row);
DefaultEntity updateBean = readBeanFromPage(subDataSet, rowData);
updated.add(updateBean);
@Override
protected void readFromPage(SwMap pageData, SwMap filter) {
super.readFromPage(pageData, filter);
LCMsConfig.Config config = new LCMsConfig.Config(form);
// 读取子表
subDetail = readDetailFromPage(LCMsConfig.dsSList,pageData,filter,(isNew,item) -> {
if(isNew){
item.setEntityId(DbEngine.getInstance().nextId());
item.put(config.getSubFKField(),bean.getEntityId());
}
});
Set<Long> deleted = details.readLongSet("deleted");

//
checkBean(masterBean);
}

DbEngine.getInstance().doTrans(new IDbWorker() {
@Override
public void work() {
saveBean(masterBean);
ModelTable subTable = ModelTableCache.getInstance().get(subDataSet.masterTable);
Assert.notNull(subTable, "未获取到子表");
@Override
protected void checkValid() {
super.checkValid();
// 校验子表明细
}

EntityDao<DefaultEntity> dao = DbEngine.getInstance().findDao(subTable.getName());
dao.batchInsertEntity(inserted);
dao.batchUpdateEntity(updated);
if (deleted != null) {
dao.deleteEntity(deleted);
}
}
@Override
protected void doSave() {
super.doSave();
// 保存子表
saveDetail(LCMsConfig.dsSList,subDetail);
}

@Override
public void doAfterDbCommit() {
afterCommit(masterBean);
}
/**
* 读取明细 供子类调用
* @param dsName 数据集名称
* @param pageData 数据对象
* @param filter 数据集的filter参数
* @param afterReadBean 读取明细之后的接口
* @return
* @param <E>
*/
protected <E extends DefaultEntity> ModelDetail<E> readDetailFromPage(String dsName, SwMap pageData, SwMap filter, BiConsumer<Boolean,E> afterReadBean) {
ModelDetail<E> modelDetail = new ModelDetail<E>();
PageDataset pageDataset = findDataset(dsName);
modelDetail.readFromMap(pageDataset,pageData,afterReadBean);
return modelDetail;
}

@Override
public void doAfterDbRollback() {
afterRollback(masterBean);
}
});
return R.success(ModelHelper.buildRetData(masterDataSet.name, masterBean.getData()));
/**
* 保存明细 供子类调用
* @param dsName
* @param modelDetail
* @param <E>
*/
protected <E extends DefaultEntity> void saveDetail(String dsName, ModelDetail<E> modelDetail){
PageDataset pageDataset = findDataset(dsName);
modelDetail.batchSave(pageDataset);
}
}

+ 35
- 41
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/lcms/LCMsService.java Ver fichero

@@ -4,74 +4,68 @@ 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.impl.DefaultEntity;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;
import cc.smtweb.system.bpm.web.engine.model.common.*;

/**
* @Author:lip
* @Date : 2022/8/28 20:38
* 卡片列表(主子表)接口服务类
*/
@SwService
public class LCMsService extends DynPageService {
private final static String TYPE_MODEL_LIST = "modelList";
private final static String TYPE_MODEL_ADD = "modelAdd";
private final static String TYPE_MODEL_LOAD = "modelLoad";
private final static String TYPE_MODEL_SAVE = "modelSave";
private final static String TYPE_MODEL_DEL = "modelDel";

@Override
public class LCMsService extends ModelService {
public final static String TYPE_MODEL_SUB_LIST = "modelSubList";
public final static String TYPE_MODEL_SUB_LOAD = "modelSubLoad";
public final static String TYPE_MODEL_SUB_SAVE = "modelSubSave";
public final static String TYPE_MODEL_SUB_DEL = "modelSubDel";
protected AbstractHandler createHandler(String type) {
switch (type) {
case TYPE_MODEL_LIST:
case TYPE_MODEL_LOAD:
case TYPE_MODEL_ADD:
return new LCMsLoadHandler();
return new LCMsLoadHandler<DefaultEntity>();
case TYPE_MODEL_SAVE:
return new LCMsSaveHandler();
return new LCMsSaveHandler<DefaultEntity>();
case TYPE_MODEL_DEL:
return new LCMsDelHandler();
case TYPE_MODEL_SUB_LIST:
return new ModelListHandler(LCMsConfig.dsSList);
case TYPE_MODEL_SUB_LOAD:
return new ModelLoadHandler<DefaultEntity>(LCMsConfig.dsSCard);
case TYPE_MODEL_SUB_SAVE:
return new ModelSaveHandler<DefaultEntity>(LCMsConfig.dsSCard);
case TYPE_MODEL_SUB_DEL:
return new ModelDelHandler(LCMsConfig.dsSCard);
}
return super.createHandler(type);
}

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

//读取
public R modelLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LOAD, handler -> ((LCMsLoadHandler) handler).mLoad());
}

//新增
public R modelAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_ADD, handler -> ((LCMsLoadHandler) handler).mAdd());
//子表单独保存
public R modelSubSave(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_SAVE, handler -> ((ModelSaveHandler) handler).save());
}

//删除
public R modelDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_DEL, handler -> ((LCMsDelHandler) handler).del());
//子表读取
public R modelSubLoad(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_LOAD, handler -> ((ModelLoadHandler) handler).load());
}

//主表列表数据
public R modelMList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).mList());
//子表新增初始化
public R modelSubAdd(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_LOAD, handler -> ((ModelLoadHandler) handler).add());
}

//主表列表总记录数及合计栏
public R modelMListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).getMTotal());
//子表删除
public R modelSubDel(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_DEL, handler -> ((ModelDelHandler) handler).del());
}

//子表列表数据
public R modelSList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).sList());
public R modelSubList(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_LIST, handler -> ((ModelListHandler) handler).data());
}

//子表表总记录数及合计栏
public R modelSListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_LIST, handler -> ((LCMsLoadHandler) handler).getSTotal());
//子表表总记录数及合计栏
public R modelSubListTotal(@SwBody SwMap params, UserSession us) {
return pageHandler(params, us, TYPE_MODEL_SUB_LIST, handler -> ((ModelListHandler) handler).getTotal());
}
}

+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/normal/LCNormalService.java Ver fichero

@@ -1,7 +1,7 @@
package cc.smtweb.system.bpm.web.engine.model.listcard.normal;

import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;
import cc.smtweb.system.bpm.web.engine.model.common.ModelService;

/**
* @Author:lip


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/model/listcard/single/LCSingleService.java Ver fichero

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

import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelService;
import cc.smtweb.system.bpm.web.engine.model.common.ModelService;

/**
* Created by Akmm at 2022-08-12 15:37


+ 1
- 1
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeSaveHandler.java Ver fichero

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

import cc.smtweb.framework.core.exception.BizException;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.common.ModelSaveHandler;
import org.apache.commons.lang3.StringUtils;

/**


+ 7
- 7
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/sys/base/billType/BillTypeService.java Ver fichero

@@ -3,7 +3,6 @@ package cc.smtweb.system.bpm.web.sys.base.billType;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.mvc.service.DefaultComboHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.abshandler.ModelSaveHandler;
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;

/**
@@ -14,12 +13,13 @@ import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleService;
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);
}
switch (type) {
case TYPE_COMBO:
return new DefaultComboHandler<BillType>(BillType.ENTITY_NAME);
case TYPE_MODEL_SAVE:
return new BillTypeSaveHandler();

@Override
protected ModelSaveHandler<BillType> getSaveHandler() {
return new BillTypeSaveHandler();
}
return super.createHandler(type);
}
}

Cargando…
Cancelar
Guardar