ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.server.bof.server.transfer;
 
import com.vci.corba.common.data.VCIInvocationInfo;
import com.vci.corba.omd.data.BusinessObject;
import com.vci.corba.omd.lcm.LifeCycle;
import com.vci.corba.omd.lcm.TransitionVO;
import com.vci.server.base.persistence.dao.HibernateSessionFactory;
import com.vci.server.base.utility.LogRecordUtil;
import com.vci.server.base.utility.ServerServiceProvider;
import com.vci.server.bof.server.ServiceFacadeExecuteHelper;
import com.vci.server.bof.service.BOFactoryServices;
import com.vci.server.cache.OMCacheProvider;
 
import java.util.Map;
import java.util.HashMap;
 
import com.vci.corba.common.VCIError;
 
public class BatchTransferBO extends ServiceFacadeExecuteHelper {
 
    private static ServiceFacadeExecuteHelper instance = null;
 
    public static ServiceFacadeExecuteHelper getInstance() {
        if (instance == null) {
            instance = new BatchTransferBO();
        }
        return instance;
    }
 
    @Override
    protected Object doAction() throws Throwable {
        boolean rs = false;
        BusinessObject[] bos = params.getBos();
        TransitionVO[] vos = params.getVos();
        Map<String, LifeCycle> mapLifeCycle = new HashMap<String, LifeCycle>();
        try {
            for (int i = 0; i < bos.length; i++) {
                TransitionVO vo2 = null;
                String boLcStatus = bos[i].lcStatus;
                if (boLcStatus == null || boLcStatus == "") {
                    throw getLocalString("", new VCIError("P0010SOF-00023", new String[] { bos[i].name }));
                    // throw getLocalString("", new
                    // VCIError("当前所选的业务对象\"{0}\"的生命周期状态值为空,不用有效执行跃迁操作。",new
                    // String[]{bos[i].name}));
                }
                LifeCycle curLC = null;
                if (mapLifeCycle.containsKey(bos[i].lctId))
                    curLC = mapLifeCycle.get(bos[i].lctId);
                else {
                    curLC = OMCacheProvider.getLifeCycle(bos[i].lctId);
                    mapLifeCycle.put(curLC.id, curLC);
                }
                if (curLC == null) {
                    // TODO:提示出来
                    throw getLocalString("", new VCIError("P0010SOF-00024", new String[] { bos[i].name }));
                }
                if (!vos[i].destination.equals("") && !vos[i].connect.equals("")) {
                    for (int l = 0; l < curLC.routes.length; ++l) {
                        TransitionVO route = curLC.routes[l];
                        if (route.source.equals(boLcStatus)) {
                            if (vos[i].destination.equals(route.destination) && vos[i].connect.equals(route.connect)) {
                                vo2 = route;
                                break;
                            }
                        }
                    }
                    if (vo2 == null) {
                        throw getLocalString("", new VCIError("P0010SOF-00027", new String[] { vos[i].destination }));
                    }
                } else if (!vos[i].destination.equals("")) {
                    for (int l = 0; l < curLC.routes.length; ++l) {
                        TransitionVO route = curLC.routes[l];
                        if (route.source.equals(boLcStatus)) {
                            if (vos[i].destination.equals(route.destination)) {
                                vo2 = route;
                                break;
                            }
                        }
                    }
                    if (vo2 == null) {
                        throw getLocalString("", new VCIError("P0010SOF-00027", new String[] { vos[i].destination }));
                    }
                } else if (!vos[i].connect.equals("")) {
                    for (int l = 0; l < curLC.routes.length; ++l) {
                        TransitionVO route = curLC.routes[l];
                        if (route.source.equals(boLcStatus)) {
                            if (vos[i].connect.equals(route.connect)) {
                                vo2 = route;
                                break;
                            }
                        }
                    }
                    if (vo2 == null) {
                        throw getLocalString("", new VCIError("P0010SOF-00025", new String[] { vos[i].connect }));
                    }
                } else {
                    throw getLocalString("", new VCIError("P0010SOF-00026", new String[] {}));
                }
                // 执行跃迁事件
                TransitionEventsExcuter excuter = new TransitionEventsExcuter();
                excuter.excute(vo2, bos[i]);
            }
            BOFactoryServices services = BOFactoryServices.getInstance();
            rs = services.batchTransferBusinessObject(bos, vos, params.getReleaseStatuss());
            if (!rs) {
                return rs;
            }
            // 日志记录
//            VCIInvocationInfo info = HibernateSessionFactory.getVciSessionInfo();
//            String ip = "127.0.0.1";
//            if (info != null) {
//                ip = info.clientIPInfo == null || "".equals(info.clientIPInfo) ? "127.0.0.1" : info.clientIPInfo;
//            }
            //batchRecordLog(bos, ip, "跃迁");
            LogRecordUtil.batchWriteLog(bos, "跃迁");
        } catch (Exception e) {
            e.printStackTrace();
 
            throw this.getLocalString("P0010SOF-00008", e);
        } catch (Throwable t) {
 
            t.printStackTrace();
            throw this.getLocalString("P0010SOF-00008", t);
        }
        return rs;
    }
 
}