田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
package com.vci.server.workflow.server.interfaceImpl;
 
import java.util.ArrayList;
import java.util.List;
 
 
import com.vci.corba.bofactory.BOFactoryServicePrx;
import com.vci.corba.omd.data.AttributeValue;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.data.LinkObject;
import com.vci.server.base.utility.ServerServiceProvider;
import com.vci.server.workflow.server.interfaces.IWorkflowUserService;
import com.vci.common.log.ServerWithLog4j;
 
public class WorkFlowUserParserNewImpl implements IWorkflowUserService {
    
    private BOFactoryServicePrx bofService = null;
    
    public String[] getAllUsers2Task(String[] paramArrayOfString,
            String userName) throws Exception {
        
        List<String> canditates = new ArrayList<String>();
        ServerWithLog4j.logger.debug("用户解析类:WorkFlowUserParserNewImpl----------------------------------------");
        List<String> index = new ArrayList<String>();
        for(String s : paramArrayOfString) {
            String[] strs = s.split(",");
            for(String str : strs) {
                index.add(str);
            }
        }
        
        if (bofService == null)
            bofService = ServerServiceProvider.getBOFService();
        
        paramArrayOfString = index.toArray(new String[0]);
        for (int i = 0; i < paramArrayOfString.length; i++) {
            int indexOf = paramArrayOfString[i].indexOf(":");
            String flag = paramArrayOfString[i].substring(0, indexOf).toLowerCase().trim();
            String substring = paramArrayOfString[i]
                    .substring(indexOf + 1);
            if ("user".equals(flag)) {
                ServerWithLog4j.logger.debug(flag + "----------------------------------------");
                if(!canditates.contains(substring)){
                    canditates.add(substring);
                }
                ServerWithLog4j.logger.debug("user:"+substring);
            }
            if ("role".equals(flag)) {
                BusinessObject bo = bofService.readBusinessObject(substring, "role");
                if(bo != null && bo.oid != null && bo.oid.length() > 0) {
                    LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "roleperson");
                    for(LinkObject lo : los) {
                        addToList(flag, canditates, lo.toOid);
                    }
                }
            }
            if ("dept".equals(flag)) {
                BusinessObject bo = bofService.readBusinessObject(substring, "department");
                if(bo != null && bo.oid != null && bo.oid.length() > 0) {
                    LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "deptperson");
                    for(LinkObject lo : los) {
                        addToList(flag, canditates, lo.toOid);
                    }
                }
            }
            if ("org".equals(flag)) {
                BusinessObject bo = bofService.readBusinessObject(substring, "organization");
                if(bo != null && bo.oid != null && bo.oid.length() > 0) {
                    LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "orgperson");
                    for(LinkObject lo : los) {
                        addToList(flag, canditates, lo.toOid);
                    }
                }
            }
            if ("dept1".equals(flag)) {
                String[] strs = substring.split(":");
                if(strs != null && strs.length > 1) {
                    BusinessObject bo = bofService.readBusinessObject(strs[0], "department");
                    if(bo != null && bo.oid != null && bo.oid.length() > 0) {
                        LinkObject[] los = bofService.readLinkObjectByFromBO(bo, "deptperson");
                        for(LinkObject lo : los) {
                            for(AttributeValue av : lo.hisAttrValList) {
                                if("refpost".equals(av.attrName) && 
                                        strs[1].equals(av.attrVal)) {                                    
                                    addToList(flag, canditates, lo.toOid);
                                }
                            }
                        }
                    }
                }
            }
        }
        return canditates.toArray(new String[0]);
    }
    
    private void addToList(String flag, List<String> list , String oid) throws Exception {
        BusinessObject obj = bofService.readBusinessObject(oid, "person");
        if(obj != null && obj.oid != null && obj.oid.length() > 0) {            
            String userName = obj.id;
            ServerWithLog4j.logger.debug(flag + "----------------------------------------");
            if(!list.contains(userName)){
                list.add(userName);
            }
            ServerWithLog4j.logger.debug("user:"+userName);
        }
    }
    
}