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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
package com.vci.client.oq.ui.linkqtexport;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
 
import com.vci.client.LogonApplication;
import com.vci.client.portal.NewNewUI.Export.VCIExportTree;
import com.vci.client.portal.UI.dialog.VCIGuideStepPanel;
import com.vci.client.ui.swing.VCIOptionPane;
 
/**
 * Action导出第二步界面
 * 
 * @Title :ExpActionStep2Panel.java
 * @Description :
 * @Copyright :宏博远达科技有限公司
 * @Author :平台与规划部/ZhongGY/E-mail:zhonggy@vci-tech.com
 * @Date :2015-6-5
 * @Version :1
 * @Other :产生注释:Alt+Shift+J
 */
public class LinkQTExpQTStep2Panel extends VCIGuideStepPanel {
 
    private static final long serialVersionUID = 1L;
 
    /**
     * 导出模型文件全路径显示
     */
    private JLabel lblModelFileFullPath;
    /**
     * 导出日志文件全路径显示
     */
    private JLabel lblLogFileFullPath;
    /**
     * 导出日志清单列表
     */
    private JScrollPane scrollPane = new JScrollPane();
    /*private JTable tblExportLog;*/
    /**
     * 导出文件名
     */
    private String logFileName = "...";
    private String vciqtmfFileName = "...";
    private VCIExportTree exportTree = null;
    
    public LinkQTExpQTStep2Panel() {
        GridBagLayout gridBagLayout = new GridBagLayout();
        gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0, 0 };
        gridBagLayout.rowHeights = new int[] { 25, 25, 0, 0 };
        gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0,
                Double.MIN_VALUE };
        gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 1.0,
                Double.MIN_VALUE };
        setLayout(gridBagLayout);
 
        JLabel label = new JLabel(" ");
        GridBagConstraints gbc_label = new GridBagConstraints();
        gbc_label.insets = new Insets(0, 0, 5, 5);
        gbc_label.gridx = 0;
        gbc_label.gridy = 0;
        add(label, gbc_label);
 
        JLabel label_1 = new JLabel("导出模型文件:");
        GridBagConstraints gbc_label_1 = new GridBagConstraints();
        gbc_label_1.insets = new Insets(0, 0, 5, 5);
        gbc_label_1.gridx = 1;
        gbc_label_1.gridy = 0;
        add(label_1, gbc_label_1);
 
        lblModelFileFullPath = new JLabel("...");
        GridBagConstraints gbc_lblModelFileFullPath = new GridBagConstraints();
        gbc_lblModelFileFullPath.anchor = GridBagConstraints.WEST;
        gbc_lblModelFileFullPath.insets = new Insets(0, 0, 5, 5);
        gbc_lblModelFileFullPath.gridx = 2;
        gbc_lblModelFileFullPath.gridy = 0;
        add(lblModelFileFullPath, gbc_lblModelFileFullPath);
 
        JLabel label_2 = new JLabel(" ");
        GridBagConstraints gbc_label_2 = new GridBagConstraints();
        gbc_label_2.insets = new Insets(0, 0, 5, 0);
        gbc_label_2.gridx = 3;
        gbc_label_2.gridy = 0;
        add(label_2, gbc_label_2);
 
        JLabel label_4 = new JLabel("导出日志文件:");
        GridBagConstraints gbc_label_4 = new GridBagConstraints();
        gbc_label_4.insets = new Insets(0, 0, 5, 5);
        gbc_label_4.gridx = 1;
        gbc_label_4.gridy = 1;
        add(label_4, gbc_label_4);
        lblLogFileFullPath = new JLabel("...");
        GridBagConstraints gbc_lblLogFileFullPath = new GridBagConstraints();
        gbc_lblLogFileFullPath.anchor = GridBagConstraints.WEST;
        gbc_lblLogFileFullPath.insets = new Insets(0, 0, 5, 5);
        gbc_lblLogFileFullPath.gridx = 2;
        gbc_lblLogFileFullPath.gridy = 1;
        add(lblLogFileFullPath, gbc_lblLogFileFullPath);
 
        
        GridBagConstraints gbc_scrollPane = new GridBagConstraints();
        gbc_scrollPane.gridwidth = 2;
        gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
        gbc_scrollPane.fill = GridBagConstraints.BOTH;
        gbc_scrollPane.gridx = 1;
        gbc_scrollPane.gridy = 2;
        add(scrollPane, gbc_scrollPane);
        
        table = new JTable();
        table.setModel(new DefaultTableModel(
            new Object[][] {
                {null, null, null, null},
            },
            new String[] {
                "\u5E8F\u53F7", "\u5BFC\u51FA\u72B6\u6001", "\u67E5\u8BE2\u65B9\u6848\u540D\u79F0", "\u6240\u5C5E\u7C7B\u578B\u540D\u79F0"
            }
        ) {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;
            boolean[] columnEditables = new boolean[] {
                false, false, false, false
            };
            public boolean isCellEditable(int row, int column) {
                return columnEditables[column];
            }
        });
        table.getColumnModel().getColumn(0).setResizable(false);
        table.getColumnModel().getColumn(0).setPreferredWidth(35);
        table.getColumnModel().getColumn(1).setPreferredWidth(85);
        table.getColumnModel().getColumn(2).setPreferredWidth(158);
        table.getColumnModel().getColumn(3).setPreferredWidth(173);
        scrollPane.setViewportView(table);
 
        /*tblExportLog = new JTable();*/
        
        
    }
 
    public LinkQTExpQTStep1Panel getPreStepUI() {
        if (super.getPreStepUI() != null) {
            return (LinkQTExpQTStep1Panel) super.getPreStepUI();
        } else {
            return null;
        }
    }
    
    @Override
    public void initUI() {
        // 可不用处理,默认加载即可
        // ExpActionStep1Panel preUI = (ExpActionStep1Panel)
        // this.getPreStepUI();
        // String filePath = preUI.getExportFilePath();
        exportTree = (VCIExportTree) getGuidCommonShareData().get("exportTree");        
        String filePath = (String) getGuidCommonShareData().get("exportFilePath");
        Long currentTimes = System.currentTimeMillis();
         logFileName= exportTree.getExportLogFileName(filePath,currentTimes);
         vciqtmfFileName = exportTree.getExportDataFileName(filePath,currentTimes);
        lblModelFileFullPath.setText(vciqtmfFileName);
        lblLogFileFullPath.setText(logFileName);        
        initData();
    }
 
    @SuppressWarnings("unchecked")
    @Override
    public void initData() {
        //1、两个文件路径(共享 )加载显示
        
        //加载table数据
        DefaultTableModel tblModel = (DefaultTableModel)table.getModel();
        while(tblModel.getRowCount() > 0 ){
            tblModel.removeRow(0);
        }        
//        List<Object[]> selectedQTs = (List<Object[]>)this.getCommonMap().get("selectedQTs");
//        for (int i = 0; i < selectedQTs.size(); i++) {
//            logFileWriter.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date())+" [序号=" + selectedQTs.get(i)[0] + ", 导出状态=" + selectedQTs.get(i)[1]
//                    + ", 查询方案名称=" + selectedQTs.get(i)[2] + ", 所属类型名称=" + selectedQTs.get(i)[3] + "]"); 
//            tblModel.addRow(selectedQTs.get(i)); 
//        }
        /*TreePath[] treePath = ((QTExportTree)exportTree).getTreeManager().getSelectionModel().getSelectionPaths();
        //循环填充列表数据
        if (treePath != null) {
               try {                
                int index = 1;
                for (int i = 0; i < treePath.length; i++) {
                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath[i]
                            .getLastPathComponent();
                    Object obj = node.getUserObject();
                    if (obj instanceof String) {// 如果是root节点,则保存所有模块 返回
                        String nodeName = (String) obj;
                        if ("业务类型".equals(nodeName)) {
                            QTInfo[] qts = QTClient.getService().getAllQTS();                            
                            for (QTInfo qtWrapper : qts) {
                                Object obj2 []= {"","","",""};
                                obj2[0] = index;
                                obj2[1] = "成功";
                                obj2[2] = qtWrapper.qtName;
                                obj2[3] = qtWrapper.btmName;
                                tblModel.addRow(obj2); 
                                index++;
                            }
 
                        }
                    }
                    
                    if (obj instanceof QTExportQTNode) {
                        //递归所有父节点添加到exportBeans中                                        
                            Object obj2 []= {"","","",""};
                            obj2[0] = index;
                            obj2[1] = "成功";
                            obj2[2] = ((QTExportQTNode) obj).getBean().qtName;
                            obj2[3] = ((QTExportQTNode) obj).getBean().btmName;
                            tblModel.addRow(obj2); 
                            index++;                                                
//                        this.tableLog.addRow(bean.getLogRowObjcets()); 
                        
                    }else if (obj instanceof QTExportBTMNode) {
                        QTInfo[] qtWrappers = QTClient.getService().getQTS(((QTExportBTMNode) obj).getBean().name);
                        for (QTInfo qtWrapper : qtWrappers) {
                            Object obj2 []= {"","","",""};
                            obj2[0] = index;
                            obj2[1] = "成功";
                            obj2[2] = qtWrapper.qtName;
                            obj2[3] = qtWrapper.btmName;
                            tblModel.addRow(obj2); 
                            index++;
                        }
                    }
                    
                    }
                    
               } catch (Exception e) {
                    e.printStackTrace();
                }
               }*/
    //    Object obj []= {"","","",""};
    //    tblModel.addRow(obj); 
        
        ObjectOutputStream vciamfFileStream = null;
 
        PrintWriter logFileWriter = null;
 
        try {
            File vciqtmfFile = new File(vciqtmfFileName);        //模版文件 
            File logFile = new File(logFileName);                //日志文件
            logFileWriter = new PrintWriter(logFile);
            List<Object[]> selectedQTs = (List<Object[]>)this.getGuidCommonShareData().get("selectedQTs");
            for (int i = 0; i < selectedQTs.size(); i++) {
                logFileWriter.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ").format(new Date())+" [序号=" + selectedQTs.get(i)[0] + ", 导出状态=" + selectedQTs.get(i)[1]
                        + ", 查询方案名称=" + selectedQTs.get(i)[2] + ", 所属类型名称=" + selectedQTs.get(i)[3] + "]"); 
                tblModel.addRow(selectedQTs.get(i)); 
            }
 
            LinkQTExportData exportData = (LinkQTExportData) getGuidCommonShareData().get("exportData");;// 获得导出Bean同时,记录log
            vciamfFileStream = new ObjectOutputStream(new FileOutputStream(
                    vciqtmfFile));
            vciamfFileStream.writeObject(exportData);
        } catch (FileNotFoundException e) {
            VCIOptionPane.showMessage(LogonApplication.frame, "导出文件创建失败!");
            e.printStackTrace();
        } catch (IOException e) {
            VCIOptionPane.showMessage(LogonApplication.frame, "导出流异常!");
            e.printStackTrace();
        } finally {
 
            try {
                if (vciamfFileStream != null) {
                    vciamfFileStream.flush();
                    vciamfFileStream.close();
                }
                if (logFileWriter != null) {
                    logFileWriter.flush();
                    logFileWriter.close();
                }
            } catch (Exception e) {
                VCIOptionPane.showMessage(LogonApplication.frame, "导出流关闭异常!");
                e.printStackTrace();
 
            }
        }
 
        // TODO: 加载日志清单数据(tblExportLog/lblModelFileFullPath/lblLogFileFullPath)
 
    }
 
 
    @Override
    public String getStepName() {
/*        String secondStepName = null;
        if((secondStepName = (String)this.getCommonMap().get("secondStepName") )!= null){
            return secondStepName;
        }*/
        return "第二步:查询模板导出结果";
    }
 
    @Override
    public boolean isPreBtnVisible() {
        return true;
    }
 
    @Override
    public String getPreBtnText() {
        return "上一步";
    }
 
    @Override
    public boolean doPreBtnAction() {
        // TODO:上一步操作处理
 
        return true;
    }
 
    @Override
    public boolean isNextBtnVisible() {
        // 最后一步不显示“下一步”
        return false;
    }
 
    @Override
    public String getNextBtnText() {
        return null;
    }
 
    @Override
    public boolean doNextBtnAction() {
        return true;
    }
 
    @Override
    public boolean isCancelBtnVisible() {
        return true;
    }
 
    @Override
    public String getcancelBtnText() {
        return "完成";
    }
 
    String dialogProcess = ""; // [第X步/共X步]
    private JTable table;
 
    public String getDialogProcess() {
        dialogProcess = "[第2步/共2步]";
        return dialogProcess;
    }
}