package com.vci.client.oq.ui.export;
|
|
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.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Set;
|
import java.util.Map.Entry;
|
|
import javax.swing.JLabel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTable;
|
import javax.swing.table.DefaultTableModel;
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
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;
|
import com.vci.corba.omd.btm.BtmItem;
|
import com.vci.corba.omd.qtm.QTD;
|
import com.vci.corba.omd.qtm.QTInfo;
|
|
/**
|
* 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 QTExpQTStep2Panel 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;
|
//xls
|
HSSFWorkbook workbook;
|
HSSFSheet sheet_QTD;
|
HSSFSheet sheet_QTWrapper;
|
HSSFSheet sheet_selectedBtmAttrs;
|
HSSFSheet sheet_selectedBtmItems;
|
int qtqindex =0;
|
int qtwindex =0;
|
int saindex =0;
|
int sbindex =0;
|
public QTExpQTStep2Panel() {
|
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 QTExpQTStep1Panel getPreStepUI() {
|
if (super.getPreStepUI() != null) {
|
return (QTExpQTStep1Panel) super.getPreStepUI();
|
} else {
|
return null;
|
}
|
}
|
|
public Map<String,Object> getCommonMap(){
|
return this.getGuidCommonShareData();
|
}
|
|
@Override
|
public void initUI() {
|
// 可不用处理,默认加载即可
|
// ExpActionStep1Panel preUI = (ExpActionStep1Panel)
|
// this.getPreStepUI();
|
// String filePath = preUI.getExportFilePath();
|
exportTree = (VCIExportTree) getCommonMap().get("exportTree");
|
String filePath = (String) getCommonMap().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);
|
}
|
ObjectOutputStream vciamfFileStream = null;
|
PrintWriter logFileWriter = null;
|
try {
|
qtqindex =0;
|
qtwindex =0;
|
saindex =0;
|
sbindex =0;
|
File vciqtmfFile = new File(vciqtmfFileName); //模版文件
|
File logFile = new File(logFileName); //日志文件
|
logFileWriter = new PrintWriter(logFile);
|
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));
|
}
|
QTExportData exportData = (QTExportData) getCommonMap().get("exportData");;// 获得导出Bean同时,记录log
|
Map<String, QTD[]> allQTDs = exportData.getAllQTDs();
|
Map<String, QTInfo> allQTs = exportData.getAllQTs();
|
workbook = new HSSFWorkbook();
|
sheet_QTD = workbook.createSheet();
|
workbook.setSheetName(0, "QTD");
|
Set<Entry<String, QTD[]>> pLActions = allQTDs.entrySet();
|
for (Entry<String, QTD[]> entry : pLActions) {
|
String key = entry.getKey();
|
QTD[] value = entry.getValue();
|
for (QTD qtd : value) {
|
HSSFRow row = sheet_QTD.createRow(qtwindex++);
|
HSSFCell cell = row.createCell(0);
|
cell.setCellValue(key);
|
cell = row.createCell(1);
|
cell.setCellValue(qtd.btmName);
|
cell = row.createCell(2);
|
cell.setCellValue(qtd.createTime);
|
cell = row.createCell(3);
|
cell.setCellValue(qtd.creator);
|
cell = row.createCell(4);
|
cell.setCellValue(qtd.linkTypeName);
|
cell = row.createCell(5);
|
cell.setCellValue(qtd.name);
|
cell = row.createCell(6);
|
StringBuffer abNames = new StringBuffer();
|
for (int i = 0; i < qtd.abNames.length; i++) {
|
abNames.append(qtd.abNames[i]).append("#");
|
}
|
cell.setCellValue(abNames.toString());
|
|
}
|
}
|
sheet_QTWrapper = workbook.createSheet();
|
workbook.setSheetName(1, "QTInfo");
|
Set<Entry<String, QTInfo>> pLQts = allQTs.entrySet();
|
for (Entry<String, QTInfo> entry : pLQts) {
|
String key = entry.getKey();
|
HSSFRow row = sheet_QTWrapper.createRow(qtqindex++);
|
HSSFCell cell = row.createCell(0);
|
cell.setCellValue(key);
|
QTInfo value = entry.getValue();
|
cell=row.createCell(1);
|
cell.setCellValue(value.btmName);
|
cell=row.createCell(2);
|
cell.setCellValue(value.createTime);
|
cell=row.createCell(3);
|
cell.setCellValue(value.creator);
|
cell=row.createCell(4);
|
cell.setCellValue(value.qtName);
|
cell=row.createCell(5);
|
cell.setCellValue(value.qtText);
|
cell=row.createCell(6);
|
cell.setCellValue(value.levelFlag);
|
cell=row.createCell(7);
|
cell.setCellValue(value.qtUIText);
|
|
}
|
sheet_selectedBtmAttrs = workbook.createSheet();
|
workbook.setSheetName(2, "SelectedBtmAttrs");
|
Map<String, String[]> selectedBtmAttrs = exportData.getSelectedBtmAttrs();
|
Iterator<Entry<String, String[]>> it = selectedBtmAttrs.entrySet().iterator();
|
while (it.hasNext()) {
|
Entry<String, String[]> entry = it.next();
|
HSSFRow row = sheet_selectedBtmAttrs.createRow(saindex++);
|
HSSFCell cell = row.createCell(0);
|
String key = entry.getKey();
|
cell.setCellValue(key);
|
String[] value = entry.getValue();
|
StringBuffer sb = new StringBuffer();
|
cell = row.createCell(1);
|
for (int i = 0; i < value.length; i++) {
|
sb.append(value[i]).append("#");
|
}
|
cell.setCellValue(sb.toString());
|
}
|
|
sheet_selectedBtmItems = workbook.createSheet();
|
workbook.setSheetName(3, "SelectedBtmItems");
|
Map<String, BtmItem> selectedBtmItems = exportData.getSelectedBtmItems();
|
Iterator<Entry<String, BtmItem>> iterator = selectedBtmItems.entrySet().iterator();
|
while (iterator.hasNext()) {
|
Entry<String, BtmItem> entry = iterator.next();
|
HSSFRow row = sheet_selectedBtmItems.createRow(sbindex++);
|
String key = entry.getKey();
|
HSSFCell cell = row.createCell(0);
|
cell.setCellValue(key);
|
BtmItem value = entry.getValue();
|
cell = row.createCell(1);
|
cell.setCellValue(value.createTime);
|
cell = row.createCell(2);
|
cell.setCellValue(value.creator);
|
cell = row.createCell(3);
|
cell.setCellValue(value.delimiter);
|
cell = row.createCell(4);
|
cell.setCellValue(value.description);
|
cell = row.createCell(5);
|
cell.setCellValue(value.fName);
|
cell = row.createCell(6);
|
cell.setCellValue(value.imageName);
|
cell = row.createCell(7);
|
cell.setCellValue(value.implClass);
|
cell = row.createCell(8);
|
cell.setCellValue(value.isAbstract);
|
cell = row.createCell(9);
|
cell.setCellValue(value.label);
|
cell = row.createCell(10);
|
cell.setCellValue(value.lifeCycle);
|
cell = row.createCell(11);
|
cell.setCellValue(value.modifier);
|
cell = row.createCell(12);
|
cell.setCellValue(value.modifyTime);
|
cell = row.createCell(13);
|
cell.setCellValue(value.name);
|
cell = row.createCell(14);
|
cell.setCellValue(value.oid);
|
cell = row.createCell(15);
|
cell.setCellValue(value.revInput);
|
cell = row.createCell(16);
|
cell.setCellValue(value.revRuleName);
|
cell = row.createCell(17);
|
cell.setCellValue(value.shape);
|
cell = row.createCell(18);
|
cell.setCellValue(value.ts);
|
cell = row.createCell(19);
|
cell.setCellValue(value.revLevel);
|
cell = row.createCell(20);
|
cell.setCellValue(value.verRuleName);
|
cell = row.createCell(21);
|
StringBuffer apName = new StringBuffer();
|
for (int i = 0; i < value.apNameArray.length; i++) {
|
apName.append(value.apNameArray[i]).append("#");
|
}
|
cell.setCellValue(apName.toString());
|
cell = row.createCell(22);
|
StringBuffer lifCs = new StringBuffer();
|
for (int i = 0; i < value.lifeCycles.length; i++) {
|
lifCs.append(value.lifeCycles[i]).append("#");
|
}
|
cell.setCellValue(lifCs.toString());
|
}
|
|
FileOutputStream ou = new FileOutputStream(vciqtmfFile);
|
workbook.write(ou);
|
ou.close();
|
// 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;
|
}
|
}
|