wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
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
package com.vci.client.uif.actions.client;
 
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
 
import com.vci.client.bof.ClientBusinessObject;
import com.vci.client.bof.ClientLinkObject;
import com.vci.client.ui.swing.VCIOptionPane;
import com.vci.client.uif.engine.common.DefaultTableNode;
import com.vci.mw.ClientContextVariable;
 
/**
 * 升级版次事件
 * 参数信息:
 *     oid(升级版次对象的oid)
 *     btmname(升级版次对象的类型)
 *     name(升级版次对象的名称、用于显示信息)
 * @author VCI-STGK006
 *
 */
public class VersionAction extends AbstractBatchBusionessOperationAction {
    
    /**
     * 方法集合
     */
    UIFUtils operation =
            new UIFUtils();
 
    public VersionAction(){
        super();
    }
    
    @Override
    public String getKey() {
        return VERSION;
    }
    
    @Override
    public boolean checkHasRight(){
        // 按BO进行数据权限检查
        setDataRightCheckType(RightCheckConstants.RIGHT_CHECK_TYPE_B);
        return super.checkHasRight();
    }
 
    @Override
    public boolean doPost() {
        //获得业务对象数据
        Object[] objs = getDataModel().getSelectObjects();
        if(objs == null || objs.length < 1){
            return false;
        }
        //modify 2014.03.09 start
        List<ClientBusinessObject> cboList = new ArrayList<ClientBusinessObject>();
        for(int i = 0; i < objs.length; i++){
            DefaultTableNode dtn = (DefaultTableNode) objs[i];
            try {
                //判断主对象类型
                if(dtn.getMaterObject() instanceof ClientBusinessObject){
                    //如果是业务类型
                    ClientBusinessObject cbo = (ClientBusinessObject) dtn.getMaterObject();
                    if(cbo == null){
                        int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), "“" 
                                    + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) 
                                    + "”不存在或者已经被删除,继续执行升版操作系统将会忽略“"
                                    + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i)
                                    +"”.\n是否继续执行升版操作?", "系统提示",JOptionPane.YES_NO_OPTION);
                        if(confirm == JOptionPane.NO_OPTION){
                            return false;
                        } 
                    }
                    cboList.add(cbo);
                } else if (dtn.getMaterObject() instanceof ClientLinkObject){
                    //如果是link类型
                    String oid = this.getParameterValue(ValueType.RuntimeData, "t_oid", i);
                    String btmName = this.getParameterValue(ValueType.RuntimeData, "t_btwname", i);
                    //如果操作所需参数不存在则直接停止操作
                    if(oid == null || oid.equals("") ||btmName == null || btmName.equals("")){
                        UIFUtils.showMessage(ClientContextVariable.getFrame(),
                                "uifmodel.plm.uif.actions.syserror.parmerror.bo");
                        return false;
                    }
                    //需要重新下载cbo对象
                    ClientBusinessObject cbo = operation
                            .reloadClientBusinessObject(ClientContextVariable.getFrame(), oid, btmName);
                    System.out.println("** TS:" + cbo.getBusinessObject().ts);
                    //对象不存在或者已经被删除
                    if(cbo.getBusinessObject().oid == null || cbo.getBusinessObject().oid.equals("")){
                        int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(), "“" 
                                + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) 
                                + "”不存在或者已经被删除,继续执行升版操作系统将会忽略“"
                                + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i)
                                +"”.\n是否继续执行升版操作?", "系统提示",JOptionPane.YES_NO_OPTION);
                        if(confirm == JOptionPane.NO_OPTION){
                            return false;
                        } 
                    } else {
                        cboList.add(cbo);
                    }                    
                }
                
            } catch (Exception e){
                UIFUtils.showErrorMessage(
                ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.editboerror", e);
                int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(),
                        "系统在加载对象时发生异常,升版操作可能会失败\n是否继续执行升版操作?",
                        "系统提示",JOptionPane.YES_NO_OPTION);
                if(confirm == JOptionPane.NO_OPTION){
                    return false;
                }                
            }
        }
        //modify 2014.03.09 end
        
        //得到需要升版的业务对象 当为多个时 有升级成功的就算成功
        boolean success = false;
        if(!cboList.isEmpty()){
            for(int j = 0; j < cboList.size(); j++){
                ClientBusinessObject cbo = cboList.get(j);
                //升级版次
                try {
                    if(operation.upBusinessObjectVersion(ClientContextVariable.getFrame(), cbo)){
                        success = true;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    int confirm = VCIOptionPane.showConfirmDialog(
                            ClientContextVariable.getFrame(), "“" + cbo.getBusinessObject().name 
                            +"”升级版次失败.\n是否继续执行升级版次操作?", "系统提示",JOptionPane.YES_NO_OPTION);
                    if(confirm == JOptionPane.NO_OPTION){
                        return false;
                    }
                    //XXX 需要增加是否继续还有文件需要继续升级版次的判断
                    //if(j < cboList.size() - 1){
                    //}
                }
            }
        }
        if(success){
            UIFUtils.showMessage(ClientContextVariable.getFrame(), 
                    "uifmodel.plm.uif.actions.versionsuccessmsg");
        }
        return success;
    }
}