|
|
@@ -1,16 +1,54 @@ |
|
|
|
package cc.smtweb.system.bpm.web.engine.model.flow.listcard.single; |
|
|
|
|
|
|
|
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.exception.BizException; |
|
|
|
import cc.smtweb.system.bpm.web.design.form.define.PageDataset; |
|
|
|
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.single.LCSingleSaveHandler; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by Akmm at 2022-08-26 16:47 |
|
|
|
* 带流程的简单卡片之保存 |
|
|
|
*/ |
|
|
|
public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSaveHandler<T> { |
|
|
|
public class FlowSingleSaveHandler<T extends DefaultEntity> extends LCSingleSaveHandler<T> implements FlowListener { |
|
|
|
protected FlowInstance flowInstance; |
|
|
|
|
|
|
|
@Override |
|
|
|
public R save() { |
|
|
|
|
|
|
|
return super.save(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected T readBeanFromPage(PageDataset pageDataSet, SwMap pageData) { |
|
|
|
T bean = super.readBeanFromPage(pageDataSet, pageData); |
|
|
|
|
|
|
|
long id = params.readLong("id"); |
|
|
|
long taskId = params.readLong("taskId"); |
|
|
|
|
|
|
|
SwMap data = pageData.readMap(FlowHelper.DATASET_NAME_FLOW); |
|
|
|
if (data == null) throw new BizException("没有找到待保存的流程数据!"); |
|
|
|
data = data.readMap("form"); |
|
|
|
if (data == null) throw new BizException("没有找到待保存的流程数据!"); |
|
|
|
|
|
|
|
FlowInstance flowInstance = new FlowInstance(this, us); |
|
|
|
if (bean.isNew()) { |
|
|
|
flowInstance.create(form.getBillType()); |
|
|
|
} else { |
|
|
|
flowInstance.load(id, taskId); |
|
|
|
} |
|
|
|
flowInstance.readFromPage(data); |
|
|
|
|
|
|
|
return bean; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void saveBean(T bean) { |
|
|
|
super.saveBean(bean); |
|
|
|
flowInstance.save(); |
|
|
|
} |
|
|
|
} |