Action-工作流提交通用
阿新 • • 發佈:2019-01-03
package com.jiuqi.dna.prcd.jzzsb.action; import com.jiuqi.dna.bap.bill.common.model.BillModel; import com.jiuqi.dna.bap.bill.common.workflow.actions.BillWorkflowUtil; import com.jiuqi.dna.bap.bill.intf.model.BillConst; import com.jiuqi.dna.bap.model.common.define.base.BaseBusinessAction; import com.jiuqi.dna.bap.model.common.define.intf.ActionConst;import com.jiuqi.dna.bap.model.common.define.intf.IAction; import com.jiuqi.dna.bap.model.common.message.ModelChangedMsg; import com.jiuqi.dna.bap.model.common.runtime.base.BusinessModel; import com.jiuqi.dna.bap.model.common.type.ModelState; import com.jiuqi.dna.bap.workflowmanager.execute.common.BusinessProcessManager;import com.jiuqi.dna.bap.workflowmanager.execute.common.util.WorkflowRunUtil; import com.jiuqi.dna.bap.workflowmanager.execute.intf.message.B0501_RefreshMonitor; import com.jiuqi.dna.bap.workflowmanager.execute.intf.message.B0501_RefreshTaskList; import com.jiuqi.dna.core.type.GUID; import com.jiuqi.dna.prcd.billmgr.common.CommonUtils;import com.jiuqi.dna.ui.common.constants.JWT; import com.jiuqi.dna.ui.wt.events.SelectionEvent; import com.jiuqi.dna.ui.wt.events.SelectionListener; import com.jiuqi.dna.ui.wt.widgets.MessageDialog; import com.jiuqi.dna.workflow.engine.EnumWorkItemState; import com.jiuqi.dna.workflow.intf.facade.IWorkItem; /** * * @author Clover * 工作流提交通用Action */ @SuppressWarnings("restriction") public class CurrencyCommitAction extends BaseBusinessAction{ /** * 提交到工作流中 * * @return boolean */ @SuppressWarnings("unused") private boolean commitToWorkflow(BillModel model, IAction action) { BillWorkflowUtil billWorkflow = new BillWorkflowUtil(action, model); return billWorkflow.commitToWorkflow(true); } @Override public String getGroup() { return "記者證擴充套件"; } @Override public String getName() { return "CurrencyCommit"; } @Override public String getTitle() { return "提交"; } @Override public String getDescription() { return null; } @Override public String getIcon() { return ActionConst.ico_submit; } @Override public String getShortcut() { return null; } public boolean executeAction(final BusinessModel model, String param) { @SuppressWarnings("deprecation") final MessageDialog confirm = MessageDialog.confirm("確認操作", "是否提交?"); confirm.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { if(confirm.getReturnCode()==JWT.OK) { doCommitToWorkFlow(model); } } }); return true; } @SuppressWarnings("deprecation") private void doCommitToWorkFlow(BusinessModel model) { boolean commitSuccess = ((BillModel)model).commitToWorkflow(); if(commitSuccess) { IWorkItem workItem = BusinessProcessManager.getFirstWorkItem(model.getContext(), model.getModelData().getMaster().getRECID()); if (workItem != null) { ((BillModel) model).setWorkItem(workItem); if (null != model.getUI()) { model.getUI().getContext().getRoot().broadcastMessage(new B0501_RefreshTaskList()); model.getUI().getContext().getRoot().broadcastMessage(new B0501_RefreshMonitor()); model.getUI().getContext().getRoot().broadcastMessage(new ModelChangedMsg()); } } model.load(model.getModelData().getMaster().getRECID()); // ======擴充套件,同步到歷史表=== CommonUtils.SynJzzToHis(model.getContext(), model.getModelData().getMaster().getRECID()); MessageDialog.alert("提示", "操作成功!"); } } @Override public boolean isEnabled(BusinessModel model) { ModelState ms = model.getModelState(); if (ms == ModelState.NEW || ms == ModelState.EDIT || ms == ModelState.NONE) { return false; } int workflowState = model.getModelData().getMaster().getValueAsInt(BillConst.f_workflowState); boolean isConmmit = false; GUID dataID = model.getModelData().getMaster().getRECID(); @SuppressWarnings("deprecation") IWorkItem workItem = BusinessProcessManager.getFirstWorkItem(model.getContext(), dataID); if (workItem != null && workItem.getState() == EnumWorkItemState.ACTIVE) { if (!WorkflowRunUtil.isCurrentWorkItemUser(model.getContext(), workItem, model.getContext().getLogin().getUser().getID())) { return false; } isConmmit = true; } return ((BillConst.WORKFLOWSTATE_NONE == workflowState || BillConst.WORKFLOWSTATE_BACK_COMMIT == workflowState || (isConmmit && BillConst.WORKFLOWSTATE_PROGRESS == workflowState))); } }