田源
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
package com.vci.client.uif.actions.client;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
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.uif.engine.common.IDataNode;
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
import com.vci.client.workflow.task.ViewWorkfolwHistoryByPlatformDialog;
import com.vci.corba.workflow.data.FlowTaskInfo;
import com.vci.mw.ClientContextVariable;
 
/**
 * 执行流程 Action
 * <p>
 * 执行流程
 * </p>
 * 
 * @author liudi
 * 
 */
public class ViewWorkFlowHistoryAction extends AbstractBusionessOperationAction {
 
    @Override
    public String getKey() {
        return "workflowhistory";
    }
 
    @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();
        IDataNode idn = (IDataNode) objs[0];
        // 对象id
        String boOid = "";
        String boType = "";
        boOid = getBoOid(boOid, idn);
        boType = getBoType(boType, idn);
 
        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);
        Map<String, String> valueMap = new HashMap<String, String>();
 
        try {
            FlowTaskInfo[] flowTaskInfos = delegate.getFlowTaskInfoByDataId(
                    boOid, boType);
            String[] executionIds = new String[flowTaskInfos.length];
            List<FlowTaskInfo> flowTaskInfoList = new ArrayList<FlowTaskInfo>();
            for (FlowTaskInfo flowTaskInfo : flowTaskInfos) {
                flowTaskInfoList.add(flowTaskInfo);
            }
            ComparatorBo comparatorBo = new ComparatorBo();
            Collections.sort(flowTaskInfoList, comparatorBo);
            for(int j=0;j<flowTaskInfoList.size();j++){
                executionIds[j] = flowTaskInfoList.get(j).executionId;
            }
            ViewWorkfolwHistoryByPlatformDialog dialog = new ViewWorkfolwHistoryByPlatformDialog(
                    executionIds);
            dialog.setVisible(true);
 
            return true;
        } catch (VCIException e) {
            e.printStackTrace();
            return false;
        }
    }
 
    private String getBoType(String boType, IDataNode idn) {
        if (idn.getMaterObject() instanceof ClientBusinessObject) {
            boType = ((ClientBusinessObject) idn.getMaterObject()).getBtmName();
        } else if (idn.getMaterObject() instanceof ClientLinkObject) {
            if (idn.isForward()) {
                boType = ((ClientLinkObject) idn.getMaterObject())
                        .getToBTMName();
            } else {
                boType = ((ClientLinkObject) idn.getMaterObject())
                        .getFromBTMName();
            }
        }
        return boType;
    }
 
    private String getBoOid(String boOid, IDataNode idn) {
        if (idn.getMaterObject() instanceof ClientBusinessObject) {
            boOid = ((ClientBusinessObject) idn.getMaterObject()).getOid();
        } else if (idn.getMaterObject() instanceof ClientLinkObject) {
            if (idn.isForward()) {
                boOid = ((ClientLinkObject) idn.getMaterObject()).getToOid();
            } else {
                boOid = ((ClientLinkObject) idn.getMaterObject()).getFromOid();
            }
        }
        return boOid;
    }
 
    public class ComparatorBo implements Comparator {
 
 
        @Override
        public int compare(Object o1, Object o2) {
            FlowTaskInfo bO0 = (FlowTaskInfo) o1;
            FlowTaskInfo bO1 = (FlowTaskInfo) o2;
 
            // 比较创建时间
            //升序排列
            int flag = Long.compare(bO0.createTime, bO1.createTime);
            return flag;
        }
 
    }
    
    // private BusinessObject[] getBusinessObjectsByQuery(String boOid)
    // throws VCIError {
    // QueryTemplate taskidqtl = new QueryTemplate();
    // List<String> list1 = new ArrayList<String>();
    // list1.add("*");
    // taskidqtl.setBtmType("WorkItem".toLowerCase());
    // taskidqtl.setClauseList(list1);
    // taskidqtl.setId("p");
    // taskidqtl.setType(QTConstants.TYPE_BTM);
    // Map<String, String> map1 = new HashMap<String, String>();
    // map1.put("BusinessType".toLowerCase(), "5");
    // map1.put("oid".toLowerCase(), boOid);
    // Condition condition1 = Tool.getCondition(map1);
    // taskidqtl.setCondition(condition1);
    // HashMap<String, String> datamapBytask = new HashMap<String, String>();
    // BusinessObject[] findBTMObjectsbyTask = QTClient.getService()
    // .findBTMObjects(taskidqtl.getId(),
    // Tool.qtTOXMl(taskidqtl).asXML());
    // return findBTMObjectsbyTask;
    // }
    //
    // private LinkObject[] getLinkObjectsByQuery(String toOid) throws VCIError
    // {
    // QueryTemplate qtlLink = new QueryTemplate();
    // List<String> listLink = new ArrayList<String>();
    // listLink.add("*");
    // qtlLink.setLinkType("input".toLowerCase());
    // qtlLink.setClauseList(listLink);
    // qtlLink.setId("p");
    // qtlLink.setType(QTConstants.TYPE_LINK);
    // qtlLink.setDirection(QTConstants.DIRECTION_POSITIVE);
    // Map<String, String> linkMap = new HashMap<String, String>();
    // linkMap.put("t_oid".toLowerCase(), toOid);
    // Condition conditionLink = Tool.getCondition(linkMap);
    // qtlLink.setCondition(conditionLink);
    // LinkObject[] findLTObjects = QTClient.getService().findLTObjects(
    // qtlLink.getId(), Tool.qtTOXMl(qtlLink).asXML());
    // return findLTObjects;
    // }
 
}