package com.vci.client.uif.actions.client;
|
|
import java.text.MessageFormat;
|
import java.util.Map;
|
import java.util.Map.Entry;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.bof.ClientBusinessObject;
|
import com.vci.client.bof.ClientLinkObject;
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.process.QANProcessBar;
|
import com.vci.client.ui.process.QANProcessBarFrame;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.uif.engine.common.IDataNode;
|
import com.vci.client.workflow.delegate.FlowInstanceClientDelegate;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.client.workflow.task.TodoTaskByPlatformDialog;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.workflow.data.MapTransfersInfo;
|
import com.vci.mw.ClientContextVariable;
|
|
/**
|
* 执行流程 Action
|
* <p>执行流程</p>
|
* @author liudi
|
*
|
*/
|
public class EndWorkFlowAction extends AbstractBusionessOperationAction {
|
|
@Override
|
public String getKey() {
|
return "endprocess";
|
}
|
|
@Override
|
public boolean checkHasRight(){
|
// 按BO进行数据权限检查
|
setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B);
|
return super.checkHasRight();
|
}
|
|
/* (non-Javadoc)
|
* @see plm.uif.actions.client.BusinessOperationAction#doPost()
|
*/
|
@Override
|
public boolean doPost() {
|
// 获取选择的数据
|
// 数据的实际类型一般为 IDataNode
|
Object[] objs = getDataModel().getSelectObjects();
|
// paramsMap = getButtonParams();
|
|
UserEntityObject userEntityObject = new UserEntityObject();
|
String ip = ClientContextVariable.getInvocationInfo().clientIPInfo;
|
String loginUserName = ClientContextVariable.getInvocationInfo().userName;
|
userEntityObject.setIp(ip);
|
userEntityObject.setUserName(loginUserName);
|
userEntityObject.setModules("");
|
final FlowInstanceClientDelegate delegate = new FlowInstanceClientDelegate(userEntityObject);
|
ProcessCustomClientDelegate processDelegate = new ProcessCustomClientDelegate(userEntityObject);
|
String boLcstatus = "";
|
String[] executionIds = new String[objs.length];
|
for(int objectIndex=0;objectIndex<objs.length;objectIndex++){
|
IDataNode idn = (IDataNode) objs[objectIndex];
|
Map<String, String> valueMap = idn.getValueMap();
|
int j=0;
|
for(Entry<String, String> entrySet : valueMap.entrySet()){
|
if(entrySet.getKey()!=null&&entrySet.getKey().equals("Executionid".toLowerCase())){
|
executionIds[j] = entrySet.getValue();
|
j++;
|
}
|
}
|
boLcstatus = getBoLcStatus(boLcstatus, idn);
|
// if(!boLcstatus.toLowerCase().equals("Completed".toLowerCase())){
|
// String pattern = LocaleDisplay.getI18nString(
|
// "plm617.action.endworkflow.message", "UIFModelAction", LogonApplication.frame.getLocale());
|
// pattern = MessageFormat.format(pattern, "");
|
// VCIOptionPane.showMessage(LogonApplication.frame, pattern);
|
// return false;
|
// }
|
}
|
try {
|
if(VCIOptionPane.showQuestion(LogonApplication.frame, "确定要中止该流程吗?")==0){
|
String deploymentIdByExecutionId = processDelegate.getDeploymentIdByExecutionId(executionIds[0]);
|
final String exeId = executionIds[0];
|
if(deploymentIdByExecutionId==null||"".equals(deploymentIdByExecutionId)){
|
VCIOptionPane.showMessage(LogonApplication.frame, "流程已经完成,不能取消");
|
}else{
|
final QANProcessBarFrame frame = new QANProcessBarFrame();
|
QANProcessBar bar = new QANProcessBar(new Thread() {
|
public void run() {
|
boolean b = false;
|
frame.setContent("正在进行处理数据,请稍等......");
|
try {
|
delegate.endProcessInstanceByplatform(exeId);
|
} catch (Exception e) {
|
frame.setProcessBarCancel(true);
|
UIFUtils.showErrorMessage(ClientContextVariable.getFrame(),e);
|
} finally {
|
frame.setProcessBarCancel(true);
|
}
|
}
|
}, frame, frame, "中止流程......",
|
false);
|
bar.setVisible(true);
|
UIFUtils.showMessage(ClientContextVariable.getFrame(), "流程取消成功!");
|
}
|
return true;
|
}else{
|
return false;
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
return false;
|
}
|
}
|
private String getBoLcStatus(String boLcstatus, IDataNode idn) {
|
if (idn.getMaterObject() instanceof ClientBusinessObject) {
|
boLcstatus = ((ClientBusinessObject)idn.getMaterObject()).getLcStatus();
|
} else if (idn.getMaterObject() instanceof ClientLinkObject) {
|
if (idn.isForward()) {
|
boLcstatus = ((ClientLinkObject)idn.getMaterObject()).getAttributeValue("lcstatus");
|
} else {
|
boLcstatus = ((ClientLinkObject)idn.getMaterObject()).getAttributeValue("lcstatus");
|
}
|
}
|
return boLcstatus;
|
}
|
}
|