田源
2025-01-09 8a166a60cfd1a2e593ffa103d10c0dc224fc8628
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.vci.client.uif.actions.client;
 
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
 
import com.vci.client.LogonApplication;
import com.vci.client.common.objects.UserEntityObject;
import com.vci.client.common.objects.UserObject;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.uif.engine.common.IDataNode;
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
import com.vci.client.workflow.task.ResetTaskUserByPlatformDialog;
import com.vci.corba.common.VCIError;
import com.vci.mw.ClientContextVariable;
 
/**
 * 执行流程 Action
 * <p>执行流程</p>
 * @author liudi
 *
 */
public class ResetTaskUserWorkFlowAction extends AbstractBusionessOperationAction {
 
    @Override
    public String getKey() {
        return "resettaskuser";
    }
    
    @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("");
        ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate(userEntityObject);
        String[] taskOids = new String[objs.length];
        String[] executionIds = new String[objs.length];
        String[] taskNames = new String[objs.length];
        String[] taskStatuss = 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;
            int k=0;
            for(Entry<String, String> entrySet : valueMap.entrySet()){
                if(entrySet.getKey()!=null&&entrySet.getKey().equals("Executionid".toLowerCase())){
                    executionIds[j] = entrySet.getValue();
                    j++;
                }
                if(entrySet.getKey()!=null&&entrySet.getKey().equals("Name".toLowerCase())){
                    taskNames[k] = entrySet.getValue().substring(entrySet.getValue().lastIndexOf("-")+1);
                    k++;
                }
            }
        }
        ResetTaskUserByPlatformDialog dialog = new ResetTaskUserByPlatformDialog(executionIds[0],taskOids[0], taskNames[0],taskStatuss[0]);
        dialog.setVisible(true);
        try {
            if(dialog.isSaveFlag()){
                Map<String, List<String>> taskAndUserMap = dialog
                        .getTaskAndUserMap();
                int taskIndex = 0;
                // 任务名称数组
                String[] tasknames = new String[taskAndUserMap.size()];
                // 任务对应的用户数组
                String[][] taskUserNames = new String[taskAndUserMap.size()][];
                for (Entry<String, List<String>> entrySet : taskAndUserMap
                        .entrySet()) {
                    tasknames[taskIndex] = entrySet.getKey();
                    List<String> list = entrySet.getValue();
                    String[] array = list.toArray(new String[] {});
                    String[] userNames = new String[array.length];
                    for (int userIndex = 0; userIndex < array.length; userIndex++) {
                        userNames[userIndex] = array[userIndex];
                    }
                    taskUserNames[taskIndex] = userNames;
                    taskIndex++;
                }
                delegate.setTaskAndUserForComplete(executionIds[0],  tasknames, taskUserNames);
            }
            return true;
        } catch (VCIError e) {
            e.printStackTrace();
            VCIOptionPane.showMessageDialog(LogonApplication.frame,e.code);
            return false;
        }
    }
}