@@ -1,11 +1,14 @@ | |||||
package cc.smtweb.system.bpm.web.engine.dynPage; | package cc.smtweb.system.bpm.web.engine.dynPage; | ||||
import cc.smtweb.framework.core.db.EntityDao; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.common.SwMap; | import cc.smtweb.framework.core.common.SwMap; | ||||
import cc.smtweb.framework.core.db.DbEngine; | import cc.smtweb.framework.core.db.DbEngine; | ||||
import cc.smtweb.framework.core.db.EntityHelper; | import cc.smtweb.framework.core.db.EntityHelper; | ||||
import cc.smtweb.framework.core.db.cache.ModelTableCache; | import cc.smtweb.framework.core.db.cache.ModelTableCache; | ||||
import cc.smtweb.framework.core.db.vo.ModelTable; | import cc.smtweb.framework.core.db.vo.ModelTable; | ||||
import cc.smtweb.framework.core.exception.SwException; | |||||
import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | import cc.smtweb.framework.core.mvc.service.AbstractCompProvider; | ||||
import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | import cc.smtweb.framework.core.mvc.service.SqlNamedPara; | ||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
@@ -34,5 +37,20 @@ public class DynPageProvider extends AbstractCompProvider { | |||||
}); | }); | ||||
} | } | ||||
public <T extends DefaultEntity> T loadBean(String tableName, long id) { | |||||
return doGetData(tableName + "." + id, () -> { | |||||
EntityDao<T> bdao = (EntityDao<T>) DbEngine.getInstance().findDao(tableName); | |||||
T bean = bdao.queryEntity(id); | |||||
if (bean == null) throw new BizException("没有找到指定数据(" + tableName + ".id=" + id + ")"); | |||||
EntityHelper.loadBeanText(bean.getTableName(), bean.getData(), null); | |||||
return bean; | |||||
}); | |||||
} | |||||
public <T extends DefaultEntity> T loadBean(PageDataset dataset, long id) { | |||||
ModelTable table = dataset.getModelTable(); | |||||
if (table == null) throw new SwException("数据集主表未找到(" + dataset.name + ")!"); | |||||
return loadBean(table.getName(), id); | |||||
} | |||||
} | } |
@@ -151,6 +151,7 @@ public class FlowInstance { | |||||
actInst.setRetake(false); | actInst.setRetake(false); | ||||
procInst.setTaskId(actInst.getEntityId()); | procInst.setTaskId(actInst.getEntityId()); | ||||
procInst.setActName(actInst.getActName()); | |||||
} | } | ||||
/** | /** | ||||
@@ -171,6 +172,7 @@ public class FlowInstance { | |||||
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); | actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); | ||||
procInst.setTaskId(actInst.getEntityId()); | procInst.setTaskId(actInst.getEntityId()); | ||||
procInst.setActName(actInst.getActName()); | |||||
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); | procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); | ||||
getTaskDao().updateEntity(actInst); | getTaskDao().updateEntity(actInst); | ||||
@@ -197,8 +199,9 @@ public class FlowInstance { | |||||
public void load(long bill_id, long task_id) { | public void load(long bill_id, long task_id) { | ||||
procInst = provider.findProcInst(bill_id); | procInst = provider.findProcInst(bill_id); | ||||
procDef = ModelProcHelper.getFromCache(procInst.getPrcId()); | procDef = ModelProcHelper.getFromCache(procInst.getPrcId()); | ||||
actInst = null; | |||||
task_id = getTaskId(task_id); | task_id = getTaskId(task_id); | ||||
if (task_id > 0L) { | |||||
if (task_id > 0L && actInst == null) { | |||||
actInst = provider.findTask(task_id); | actInst = provider.findTask(task_id); | ||||
} | } | ||||
} | } | ||||
@@ -217,12 +220,22 @@ public class FlowInstance { | |||||
*/ | */ | ||||
private long getTaskId(long task_id) { | private long getTaskId(long task_id) { | ||||
if (task_id > 0L) return task_id; | if (task_id > 0L) return task_id; | ||||
task_id = procInst.getTaskId(); | |||||
Task curTask = provider.findTask(task_id); | Task curTask = provider.findTask(task_id); | ||||
if (EntityHelper.isEmpty(curTask) || curTask.getStatu() != FlowConst.ActivityStatu.WAIT.value) return task_id; | |||||
if (EntityHelper.isEmpty(curTask)) throw new SwException("单据任务缺失(" + procInst.getId() + ":::" + task_id + ")!"); | |||||
actInst = curTask; | |||||
if (curTask.getStatu() != FlowConst.ActivityStatu.WAIT.value) return task_id; | |||||
//是自己的待办任务 | |||||
if (curTask.getStatu() == FlowConst.ActivityStatu.WAIT.value && FlowHelper.isMyWaitedTask(curTask.getId(), us.getUserId())) { | |||||
return task_id; | |||||
} | |||||
//待办任务不是自己的,则去找前一个自己提交的任务 | |||||
List<Task> preActs = provider.findBeforeTasks(task_id); | List<Task> preActs = provider.findBeforeTasks(task_id); | ||||
if (CommUtil.isEmpty(preActs)) return task_id; | if (CommUtil.isEmpty(preActs)) return task_id; | ||||
for (Task act : preActs) { | for (Task act : preActs) { | ||||
if (act.getHandler() == us.getUserId()) { | if (act.getHandler() == us.getUserId()) { | ||||
actInst = act; | |||||
return act.getId(); | return act.getId(); | ||||
} | } | ||||
} | } | ||||
@@ -293,18 +306,6 @@ public class FlowInstance { | |||||
return listTask; | return listTask; | ||||
} | } | ||||
/** | |||||
* 设置单据描述及链接地址,待办中展示 | |||||
* | |||||
* @param bill_info | |||||
* @param bill_url | |||||
*/ | |||||
public void setBillInfo(String bill_code, String bill_info, String bill_url) { | |||||
procInst.setBillInfo(bill_info); | |||||
procInst.setBillCode(bill_code); | |||||
procInst.setUrl(bill_url); | |||||
} | |||||
//启动流程 | //启动流程 | ||||
public void save() { | public void save() { | ||||
if (procInst.isNew()) { | if (procInst.isNew()) { | ||||
@@ -567,8 +568,10 @@ public class FlowInstance { | |||||
if (listInsertTask.size() > 0) { | if (listInsertTask.size() > 0) { | ||||
procInst.setTaskId(listInsertTask.get(0).getEntityId()); | procInst.setTaskId(listInsertTask.get(0).getEntityId()); | ||||
procInst.setActName(listInsertTask.get(0).getActName()); | |||||
} else { | } else { | ||||
procInst.setTaskId(actInst.getEntityId()); | procInst.setTaskId(actInst.getEntityId()); | ||||
procInst.setActName(actInst.getActName()); | |||||
} | } | ||||
if (new_acts.size() == 1 && new_acts.get(0).getType() == FlowConst.ActivityType.END.value) { | if (new_acts.size() == 1 && new_acts.get(0).getType() == FlowConst.ActivityType.END.value) { | ||||
@@ -641,7 +644,7 @@ public class FlowInstance { | |||||
task.init(); | task.init(); | ||||
task.setEntityId(DbEngine.getInstance().nextId()); | task.setEntityId(DbEngine.getInstance().nextId()); | ||||
task.setPriId(procInst.getId()); | task.setPriId(procInst.getId()); | ||||
task.setPriId(procDef.getId()); | |||||
task.setPrcId(procDef.getId()); | |||||
task.setActId(act.getId()); | task.setActId(act.getId()); | ||||
task.setActName(act.getLabel()); | task.setActName(act.getLabel()); | ||||
task.setStartTime(DateUtil.nowDateTimeLong()); | task.setStartTime(DateUtil.nowDateTimeLong()); | ||||
@@ -723,6 +726,7 @@ public class FlowInstance { | |||||
} | } | ||||
procInst.setTaskId(actInst.getEntityId()); | procInst.setTaskId(actInst.getEntityId()); | ||||
procInst.setActName(actInst.getActName()); | |||||
procInst.setStatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value: FlowConst.InstanceStatu.RUNING.value); | procInst.setStatu(actInst.isMake() ? FlowConst.InstanceStatu.BEGIN.value: FlowConst.InstanceStatu.RUNING.value); | ||||
taskDao.updateEntity(actInst); | taskDao.updateEntity(actInst); | ||||
@@ -748,6 +752,7 @@ public class FlowInstance { | |||||
actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); | actInst.setStatu(FlowConst.ActivityStatu.HANDLE.value); | ||||
procInst.setTaskId(actInst.getEntityId()); | procInst.setTaskId(actInst.getEntityId()); | ||||
procInst.setActName(actInst.getActName()); | |||||
procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); | procInst.setStatu(FlowConst.InstanceStatu.RUNING.value); | ||||
if (actInst.isMake()) procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | if (actInst.isMake()) procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | ||||
@@ -793,6 +798,7 @@ public class FlowInstance { | |||||
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); | actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); | ||||
procInst.setTaskId(new_acts.get(0).getEntityId()); | procInst.setTaskId(new_acts.get(0).getEntityId()); | ||||
procInst.setActName(new_acts.get(0).getActName()); | |||||
if (new_acts.size() == 1 && new_acts.get(0).isMake()) { | if (new_acts.size() == 1 && new_acts.get(0).isMake()) { | ||||
procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | ||||
} else { | } else { | ||||
@@ -836,6 +842,7 @@ public class FlowInstance { | |||||
actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); | actInst.setStatu(FlowConst.ActivityStatu.REJECT.value); | ||||
procInst.setTaskId(make_act.getEntityId()); | procInst.setTaskId(make_act.getEntityId()); | ||||
procInst.setActName(make_act.getActName()); | |||||
procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | procInst.setStatu(FlowConst.InstanceStatu.BEGIN.value); | ||||
EntityDao<Task> taskDao = getTaskDao(); | EntityDao<Task> taskDao = getTaskDao(); | ||||
@@ -923,6 +930,10 @@ public class FlowInstance { | |||||
bean.setHandler(us.getUserId()); | bean.setHandler(us.getUserId()); | ||||
bean.setHandlerTime(DateUtil.nowDateTimeLong()); | bean.setHandlerTime(DateUtil.nowDateTimeLong()); | ||||
} else if (FlowConst.Button.SUBMIT.value.equals(optType)) { | } else if (FlowConst.Button.SUBMIT.value.equals(optType)) { | ||||
if (bean.getHandlerTime() <= 0L) { | |||||
bean.setHandler(us.getUserId()); | |||||
bean.setHandlerTime(DateUtil.nowDateTimeLong()); | |||||
} | |||||
bean.setStatu(FlowConst.ActivityStatu.SUBMIT.value); | bean.setStatu(FlowConst.ActivityStatu.SUBMIT.value); | ||||
bean.setEndTime(DateUtil.nowDateTimeLong()); | bean.setEndTime(DateUtil.nowDateTimeLong()); | ||||
bean.setComment(comment); | bean.setComment(comment); | ||||
@@ -123,6 +123,15 @@ public class ProcInst extends DefaultEntity { | |||||
public void setTaskId(long pri_task_id) { | public void setTaskId(long pri_task_id) { | ||||
put("pri_task_id", pri_task_id); | put("pri_task_id", pri_task_id); | ||||
} | } | ||||
public String getActName() { | |||||
return getStr("pri_act_name"); | |||||
} | |||||
public void setActName(String priActName) { | |||||
put("pri_act_name", priActName); | |||||
} | |||||
/** 单据状态 */ | /** 单据状态 */ | ||||
public int getStatu() { | public int getStatu() { | ||||
return getInt("pri_statu"); | return getInt("pri_statu"); | ||||
@@ -7,43 +7,48 @@ import cc.smtweb.framework.core.db.impl.DefaultEntity; | |||||
* Created by Akmm at 2022/5/23 14:25 | * Created by Akmm at 2022/5/23 14:25 | ||||
* 活动之间的关系 | * 活动之间的关系 | ||||
*/ | */ | ||||
@SwTable("WF_CARE") | |||||
@SwTable("WF_TASK_REL") | |||||
public class TaskRel extends DefaultEntity { | public class TaskRel extends DefaultEntity { | ||||
public static final String ENTITY_NAME = "WF_CARE"; | |||||
public static final String ENTITY_NAME = "WF_TASK_REL"; | |||||
public TaskRel() { | public TaskRel() { | ||||
super(ENTITY_NAME); | super(ENTITY_NAME); | ||||
} | } | ||||
/** 主键 */ | |||||
public long getId() { | public long getId() { | ||||
return getLong("trl_id"); | return getLong("trl_id"); | ||||
} | } | ||||
public void setId(long trlId) { | |||||
put("trl_id", trlId); | |||||
/** 主键 */ | |||||
public void setId(long trl_id) { | |||||
put("trl_id", trl_id); | |||||
} | } | ||||
/** 流程实例id */ | |||||
public long getPriId() { | public long getPriId() { | ||||
return getLong("trl_pri_id"); | return getLong("trl_pri_id"); | ||||
} | } | ||||
public void setPriId(long trlPriId) { | |||||
put("trl_pri_id", trlPriId); | |||||
/** 流程实例id */ | |||||
public void setPriId(long trl_pri_id) { | |||||
put("trl_pri_id", trl_pri_id); | |||||
} | } | ||||
/** 前任务id */ | |||||
public long getSrcTaskId() { | public long getSrcTaskId() { | ||||
return getLong("trl_src_task_id"); | return getLong("trl_src_task_id"); | ||||
} | } | ||||
public void setSrcTaskId(long trlSrcTaskId) { | |||||
put("trl_src_task_id", trlSrcTaskId); | |||||
/** 前任务id */ | |||||
public void setSrcTaskId(long trl_src_task_id) { | |||||
put("trl_src_task_id", trl_src_task_id); | |||||
} | } | ||||
/** 目标任务id */ | |||||
public long getDstTaskId() { | public long getDstTaskId() { | ||||
return getLong("trl_dst_task_id"); | return getLong("trl_dst_task_id"); | ||||
} | } | ||||
public void setDstTaskId(long trlDstTaskId) { | |||||
put("trl_dst_task_id", trlDstTaskId); | |||||
/** 目标任务id */ | |||||
public void setDstTaskId(long trl_dst_task_id) { | |||||
put("trl_dst_task_id", trl_dst_task_id); | |||||
} | } | ||||
} | |||||
} |
@@ -25,16 +25,15 @@ import java.util.ArrayList; | |||||
/** | /** | ||||
* Created by Akmm at 2022-08-26 17:15 | * Created by Akmm at 2022-08-26 17:15 | ||||
*/ | */ | ||||
public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowListener { | |||||
public class FlowSingleLoadHandler<T extends DefaultEntity> extends LCSingleLoadHandler<T> implements FlowListener { | |||||
protected FlowInstance flowInstance; | protected FlowInstance flowInstance; | ||||
@Override | @Override | ||||
protected void afterAdd(SwMap ret, SwMap bean) { | |||||
protected void afterAdd(SwMap ret, T bean) { | |||||
flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | flowInstance = FlowInstance.createByBillType(us, this, form.getBillType()); | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | ||||
ModelTable table = cardDataset.getModelTable(); | |||||
bean.put(table.getIdField(), flowInstance.getProcInst().getId()); | |||||
bean.setEntityId(flowInstance.getProcInst().getId()); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | ret.put(cardDataset.name, DynRetBean.createBean(bean)); | ||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
@@ -47,14 +46,10 @@ public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowLi | |||||
//过滤条件 | //过滤条件 | ||||
long id = params.readLong("id"); | long id = params.readLong("id"); | ||||
long taskId = params.readLong("taskId"); | long taskId = params.readLong("taskId"); | ||||
// SwMap filter = params.readMap("filter"); | |||||
SwMap filter = new SwMap(); | |||||
filter.put(SwConsts.NAME_ID, id); | |||||
//对应的数据集定义 | |||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
SwMap data = provider.loadData(filter, cardDataset); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(data)); | |||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
T bean = provider.loadBean(cardDataset, id); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | |||||
//加载流程信息 | //加载流程信息 | ||||
flowInstance = FlowInstance.createById(us,this, id, taskId); | flowInstance = FlowInstance.createById(us,this, id, taskId); | ||||
@@ -62,7 +57,7 @@ public class FlowSingleLoadHandler extends LCSingleLoadHandler implements FlowLi | |||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | ||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.create(flowInstance.loadComment(), 0))); | ||||
afterLoad(ret, data); | |||||
afterLoad(ret, bean); | |||||
return R.success(ret); | return R.success(ret); | ||||
} | } | ||||
@@ -5,6 +5,7 @@ import cc.smtweb.framework.core.common.SwMap; | |||||
import cc.smtweb.framework.core.db.impl.DefaultEntity; | import cc.smtweb.framework.core.db.impl.DefaultEntity; | ||||
import cc.smtweb.framework.core.exception.BizException; | import cc.smtweb.framework.core.exception.BizException; | ||||
import cc.smtweb.framework.core.mvc.service.SwListData; | import cc.smtweb.framework.core.mvc.service.SwListData; | ||||
import cc.smtweb.framework.core.util.DateUtil; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; | 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.FlowHelper; | ||||
@@ -38,7 +39,11 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave | |||||
} | } | ||||
flowInstance.readFromPage(data); | flowInstance.readFromPage(data); | ||||
flowInstance.getProcInst().setIsNew(bean.isNew()); | flowInstance.getProcInst().setIsNew(bean.isNew()); | ||||
flowInstance.setBillInfo(getBillCode(), getBillInfo(), getBillUrl()); | |||||
if (bean.isNew()) { | |||||
flowInstance.getProcInst().setBillCode(getBillCode()); | |||||
flowInstance.getProcInst().setUrl(getBillUrl()); | |||||
} | |||||
flowInstance.getProcInst().setBillInfo(getBillInfo()); | |||||
return bean; | return bean; | ||||
} | } | ||||
@@ -55,14 +60,14 @@ public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSave | |||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | ||||
} | } | ||||
//单据编号 | |||||
//单据编号,新增保存时调用 | |||||
protected String getBillCode() { | protected String getBillCode() { | ||||
return ""; | |||||
return flowInstance.getProcInst().getBillCode(); | |||||
} | } | ||||
//单据信息,在待办中显示 | |||||
//单据信息,在待办中显示,每次保存均计算 | |||||
protected String getBillInfo() { | protected String getBillInfo() { | ||||
return ""; | |||||
return flowInstance.getProcInst().getBillCode() + "-" + DateUtil.nowDate(); | |||||
} | } | ||||
//单据url,待办中跳链 | //单据url,待办中跳链 | ||||
@@ -2,13 +2,16 @@ package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; | |||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwMap; | 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.framework.core.mvc.service.SwListData; | ||||
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.AbstractDynPageHandler; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; | 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.FlowHelper; | ||||
import cc.smtweb.system.bpm.web.engine.flow.FlowInstance; | 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.flow.FlowListener; | ||||
import cc.smtweb.system.bpm.web.engine.flow.entity.Task; | import cc.smtweb.system.bpm.web.engine.flow.entity.Task; | ||||
import cc.smtweb.system.bpm.web.engine.model.listcard.single.LCSingleHelper; | |||||
import java.util.List; | import java.util.List; | ||||
@@ -16,30 +19,40 @@ import java.util.List; | |||||
* Created by Akmm at 2022-09-01 15:03 | * Created by Akmm at 2022-09-01 15:03 | ||||
* 流程流转 | * 流程流转 | ||||
*/ | */ | ||||
public class FlowTransHandler extends AbstractDynPageHandler implements FlowListener{ | |||||
public class FlowTransHandler<T extends DefaultEntity> extends AbstractDynPageHandler implements FlowListener{ | |||||
//流程id | //流程id | ||||
protected long billId; | protected long billId; | ||||
//任务id | //任务id | ||||
protected long taskId; | protected long taskId; | ||||
protected FlowInstance flowInstance; | protected FlowInstance flowInstance; | ||||
private void loadFlowInstance() { | |||||
protected T bean; | |||||
private SwMap buildRetData() { | |||||
SwMap ret = new SwMap(); | |||||
ret.put(LCSingleHelper.DATASET_NAME_CARD, DynRetBean.createBean(bean)); | |||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | |||||
return ret; | |||||
} | |||||
protected void load() { | |||||
if (flowInstance == null) { | if (flowInstance == null) { | ||||
billId = params.readLong("id"); | billId = params.readLong("id"); | ||||
taskId = params.readLong("taskId"); | taskId = params.readLong("taskId"); | ||||
flowInstance = FlowInstance.createById(us, this, billId, taskId); | flowInstance = FlowInstance.createById(us, this, billId, taskId); | ||||
loadBean(); | |||||
} | } | ||||
} | } | ||||
private SwMap buildRetData() { | |||||
SwMap ret = new SwMap(); | |||||
ret.put(FlowHelper.DATASET_NAME_FLOW, DynRetBean.createBean(flowInstance.getProcInst())); | |||||
ret.put(FlowHelper.DATASET_NAME_COMMENT, DynRetBean.createList(SwListData.EMPTY)); | |||||
return ret; | |||||
protected void loadBean() { | |||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | |||||
bean = provider.loadBean(cardDataset, billId); | |||||
} | } | ||||
public R submit() { | public R submit() { | ||||
loadFlowInstance(); | |||||
load(); | |||||
flowInstance.submit(params.readString("comment")); | flowInstance.submit(params.readString("comment")); | ||||
return R.success(buildRetData()); | return R.success(buildRetData()); | ||||
} | } | ||||
@@ -1,7 +1,14 @@ | |||||
package cc.smtweb.system.bpm.web.engine.model.listcard.single; | package cc.smtweb.system.bpm.web.engine.model.listcard.single; | ||||
import cc.smtweb.framework.core.common.R; | import cc.smtweb.framework.core.common.R; | ||||
import cc.smtweb.framework.core.common.SwConsts; | |||||
import cc.smtweb.framework.core.common.SwMap; | 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.SwException; | |||||
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | import cc.smtweb.system.bpm.web.design.form.define.PageDataset; | ||||
import cc.smtweb.system.bpm.web.engine.dynPage.AbstractDynPageHandler; | 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.DynPageHelper; | ||||
@@ -11,28 +18,33 @@ import cc.smtweb.system.bpm.web.engine.dynPage.DynRetBean; | |||||
/** | /** | ||||
* Created by Akmm at 2022-08-16 15:43 | * Created by Akmm at 2022-08-16 15:43 | ||||
*/ | */ | ||||
public class LCSingleLoadHandler extends AbstractDynPageHandler { | |||||
public class LCSingleLoadHandler<T extends DefaultEntity> extends AbstractDynPageHandler { | |||||
//新增卡片操作,初始化定义的数据集 | //新增卡片操作,初始化定义的数据集 | ||||
public R add() { | public R add() { | ||||
SwMap ret = new SwMap(); | SwMap ret = new SwMap(); | ||||
//返回的数据,以dataset.name为key,查出的结果(bean或list)为value | //返回的数据,以dataset.name为key,查出的结果(bean或list)为value | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | ||||
SwMap data = DynPageHelper.createBean(cardDataset); | |||||
ModelTable table = cardDataset.getModelTable(); | |||||
if (table == null) throw new SwException("卡片主表未找到!"); | |||||
final EntityDao<T> dao = DbEngine.getInstance().findDao(table.getName()); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(data)); | |||||
T bean = dao.createBean(us.getUserId()); | |||||
bean.setEntityId(DbEngine.getInstance().nextId()); | |||||
afterAdd(ret, data); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | |||||
afterAdd(ret, bean); | |||||
return R.success(ret); | return R.success(ret); | ||||
} | } | ||||
//新增初始化 - bean | //新增初始化 - bean | ||||
protected void afterAdd(SwMap ret, SwMap bean) { | |||||
protected void afterAdd(SwMap ret, T bean) { | |||||
} | } | ||||
//加载之后 | //加载之后 | ||||
protected void afterLoad(SwMap ret, SwMap bean) { | |||||
protected void afterLoad(SwMap ret, T bean) { | |||||
} | } | ||||
public R load() { | public R load() { | ||||
@@ -42,10 +54,10 @@ public class LCSingleLoadHandler extends AbstractDynPageHandler { | |||||
//对应的数据集定义 | //对应的数据集定义 | ||||
PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | PageDataset cardDataset = LCSingleHelper.findCardDataset(datasets); | ||||
SwMap data = provider.loadData(filter, cardDataset); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(data)); | |||||
T bean = provider.loadBean(cardDataset, filter.readLong(SwConsts.NAME_ID)); | |||||
ret.put(cardDataset.name, DynRetBean.createBean(bean)); | |||||
afterLoad(ret, data); | |||||
afterLoad(ret, bean); | |||||
return R.success(ret); | return R.success(ret); | ||||
} | } | ||||