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
package com.vci.client.uif.actions.client.changestatus;
 
import java.util.List;
import java.util.Map;
 
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.actions.client.AbstractBatchBusionessOperationAction;
import com.vci.client.uif.actions.client.UIFUtils;
import com.vci.client.uif.engine.common.IDataNode;
import com.vci.mw.ClientContextVariable;
 
public abstract class AbstractSelectDataAction extends AbstractBatchBusionessOperationAction{
 
    protected UIFUtils operation = new UIFUtils();
 
    /**
     * 从选择的对象中构建对应的BO
     * @param objs,选择对象
     * @param cboList,构建结果
     * @return
     */
    public boolean getSelectData(Object[] objs, List<ClientBusinessObject> cboList) {
        for(int i = 0; i < objs.length; i++){
            if(objs[i] instanceof Map){
                //做一个特殊处理,当选择值是一个Map时,获得Map中的OID和BtmName属性
                String oid = (String) ((Map)objs[i]).get("OID");
                String btmName = (String) ((Map)objs[i]).get("BTMNAME");
                String ts = (String)((Map)objs[i]).get("TS");
                String lcId = (String)((Map)objs[i]).get("LCTID");
                String lcStatus = (String)((Map)objs[i]).get("LCSTATUS");
                if(oid != null && !oid.equals("")
                        && btmName != null && !btmName.equals("")
                        && ts != null && !ts.equals("")
                        && lcId != null && !lcId.equals("")
                        && lcStatus != null && !lcStatus.equals("")){
                    ClientBusinessObject cbo = new ClientBusinessObject();
                    cbo.setOid(oid);
                    cbo.setBtmName(btmName);
                    cbo.setTs(Long.valueOf(ts));
                    cbo.setLastModifier(ClientContextVariable.getInvocationInfo().userName);
                    cbo.setLctId(lcId);
                    cbo.setLcStatus(lcStatus);
                    cboList.add(cbo);
                }
            } else if(objs[i] instanceof IDataNode){
                IDataNode dtn = (IDataNode) 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, "name", i)
                                +"”不存在或者已经被删除.", "系统提示",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);
                        //对象不存在或者已经被删除
                        if(cbo.getBusinessObject().oid == null || cbo.getBusinessObject().oid.equals("")){
                            int confirm = VCIOptionPane.showConfirmDialog(
                                    ClientContextVariable.getFrame(), "“" + this.getParameterValue(ValueType.RuntimeData, "t_oid.name", i) 
                                    +"”不存在或者已经被删除.", "系统提示",JOptionPane.YES_NO_OPTION);
                            if(confirm == JOptionPane.NO_OPTION){
                                return false;
                            } 
                        } else {
                            cboList.add(cbo);
                        }                    
                    } else if (dtn.getMaterObject() instanceof String){
                        UIFUtils.showMessage(ClientContextVariable.getFrame(),
                                "uifmodel.plm.uif.engine.folder.root.delete", "");
                        return false;
                    } 
                    
                } catch (Exception e){
                    UIFUtils.showErrorMessage(
                    ClientContextVariable.getFrame(), "uifmodel.plm.uif.actions.editboerror", e);
                    int confirm = VCIOptionPane.showConfirmDialog(ClientContextVariable.getFrame(),"系统加载对象“" 
                                + dtn.getValueMap().get("name") +"”时发生异常.“" + this.getParameterValue(ValueType.RuntimeData, "name", i) 
                                + "”当前操作可能会失败\n是否继续执行操作?", "系统提示",JOptionPane.YES_NO_OPTION);
                    if(confirm == JOptionPane.NO_OPTION){
                        return false;
                    }                
                }
            }
        }
        return true;
    }
}