|
|
|
@ -0,0 +1,875 @@
|
|
|
|
|
|
|
|
package com.connor.mdbksplm.ProblemReport;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
|
|
|
|
import java.awt.Color;
|
|
|
|
|
|
|
|
import java.awt.Component;
|
|
|
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
|
|
|
import java.awt.FlowLayout;
|
|
|
|
|
|
|
|
import java.awt.Font;
|
|
|
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
|
|
|
import java.awt.event.MouseAdapter;
|
|
|
|
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.JButton;
|
|
|
|
|
|
|
|
import javax.swing.JComboBox;
|
|
|
|
|
|
|
|
import javax.swing.JFileChooser;
|
|
|
|
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
|
|
|
|
import javax.swing.JMenuItem;
|
|
|
|
|
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
import javax.swing.JPopupMenu;
|
|
|
|
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
|
|
|
|
import javax.swing.JTable;
|
|
|
|
|
|
|
|
import javax.swing.JTextField;
|
|
|
|
|
|
|
|
import javax.swing.filechooser.FileSystemView;
|
|
|
|
|
|
|
|
import javax.swing.table.DefaultTableCellRenderer;
|
|
|
|
|
|
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
|
|
|
|
import javax.swing.table.JTableHeader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.connor.mdbksplm.treamlist.CNProperty;
|
|
|
|
|
|
|
|
import com.connor.mdbksplm.util.ProgressBarDemo;
|
|
|
|
|
|
|
|
import com.connor.mdbksplm.util.WaitingDialog;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFCommand;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.aifrcp.AIFUtility;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.commands.open.OpenCommand;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCAccessControlService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponent;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItem;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentItemRevision;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentProject;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCComponentUser;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCException;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCPreferenceService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCSession;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.kernel.TCUserService;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.util.DateButton;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.util.MessageBox;
|
|
|
|
|
|
|
|
import com.teamcenter.rac.util.PropertyLayout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class NewProblemReportFrame extends JFrame{
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
private TCSession session;
|
|
|
|
|
|
|
|
private AbstractAIFUIApplication app;
|
|
|
|
|
|
|
|
protected TCUserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private JPanel leftPanel = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
private JButton okButton;
|
|
|
|
|
|
|
|
private JButton exButton;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String SearchName = null;
|
|
|
|
|
|
|
|
// string:问题来源:prosource
|
|
|
|
|
|
|
|
// date:创建日期: creation_date01| creation_date02
|
|
|
|
|
|
|
|
private List<List<String>> searchList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 问题来源:Form.mt8_prosource:15
|
|
|
|
|
|
|
|
private List<List<String>> colList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer cur = new Integer(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HashMap<JTextField, String> fMap = new HashMap<>();
|
|
|
|
|
|
|
|
HashMap<DateButton, String> dMap = new HashMap<>();
|
|
|
|
|
|
|
|
HashMap<JComboBox<String>, String> boxMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<String>> allSj = new ArrayList<>();
|
|
|
|
|
|
|
|
private Integer num = new Integer(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 序号:问题报告
|
|
|
|
|
|
|
|
HashMap<String, TCComponent> baogao = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SimpleDateFormat formatter= new SimpleDateFormat("dd-M 月-yyyy");
|
|
|
|
|
|
|
|
private SimpleDateFormat formatter2= new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
private SimpleDateFormat formatter3= new SimpleDateFormat("yyyy-M-d");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String[] columns;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ProgressBarDemo wait = new ProgressBarDemo();
|
|
|
|
|
|
|
|
private WaitingDialog waiting;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public NewProblemReportFrame(AbstractAIFUIApplication app) {
|
|
|
|
|
|
|
|
// super(false);
|
|
|
|
|
|
|
|
this.app = app;
|
|
|
|
|
|
|
|
this.session = (TCSession) app.getSession();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void initUI() {
|
|
|
|
|
|
|
|
FindData();
|
|
|
|
|
|
|
|
this.setTitle("问题报告看板");
|
|
|
|
|
|
|
|
this.setPreferredSize(new Dimension(1500, 600));
|
|
|
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Font font = new Font("宋体", Font.PLAIN, 12);//创建1个字体实例
|
|
|
|
|
|
|
|
Font font2 = new Font("宋体", Font.PLAIN, 10);//创建1个字体实例
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel leftTJPanel = new JPanel(new PropertyLayout(2,10,5,20,5,5));
|
|
|
|
|
|
|
|
cur = 0;
|
|
|
|
|
|
|
|
for(int i=0;i<searchList.size();i++) {
|
|
|
|
|
|
|
|
List<String> list = searchList.get(i);
|
|
|
|
|
|
|
|
if("string".equals(list.get(0))) { // 是String类型控件
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
JLabel label = new JLabel(list.get(1)); //控件名称
|
|
|
|
|
|
|
|
label.setPreferredSize(new Dimension(100, 22));
|
|
|
|
|
|
|
|
label.setFont(font);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",label);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
if(list.size() > 3) {
|
|
|
|
|
|
|
|
JComboBox<String> field = new JComboBox<String>();
|
|
|
|
|
|
|
|
field.setPreferredSize(new Dimension(140, 22));
|
|
|
|
|
|
|
|
field.setFont(font);
|
|
|
|
|
|
|
|
CNProperty cn1 = new CNProperty();
|
|
|
|
|
|
|
|
cn1.setLovName(list.get(3));
|
|
|
|
|
|
|
|
cn1.initProperty();
|
|
|
|
|
|
|
|
field.addItem(" ");
|
|
|
|
|
|
|
|
for(int k=0;k<cn1.lovValueList.size();k++) {
|
|
|
|
|
|
|
|
field.addItem(cn1.lovDisplayValueList.get(k));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",field);
|
|
|
|
|
|
|
|
boxMap.put(field, list.get(2));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
JTextField field = new JTextField();
|
|
|
|
|
|
|
|
field.setPreferredSize(new Dimension(140, 22));
|
|
|
|
|
|
|
|
field.setFont(font);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",field);
|
|
|
|
|
|
|
|
// 将控件和查询条件绑定
|
|
|
|
|
|
|
|
fMap.put(field, list.get(2));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if("date".equals(list.get(0))) {
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
JLabel label = new JLabel(list.get(1) + "早于"); //控件名称
|
|
|
|
|
|
|
|
label.setPreferredSize(new Dimension(100, 22));
|
|
|
|
|
|
|
|
label.setFont(font);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",label);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
DateButton field = new DateButton();
|
|
|
|
|
|
|
|
Date date = null;
|
|
|
|
|
|
|
|
field.setPreferredSize(new Dimension(140, 22));
|
|
|
|
|
|
|
|
field.setFont(font);
|
|
|
|
|
|
|
|
field.setDate(date);
|
|
|
|
|
|
|
|
field.setDisplayFormatter(formatter);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",field);
|
|
|
|
|
|
|
|
// 将控件和查询条件绑定
|
|
|
|
|
|
|
|
dMap.put(field, list.get(2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
JLabel label2 = new JLabel(list.get(1) + "晚于"); //控件名称
|
|
|
|
|
|
|
|
label2.setPreferredSize(new Dimension(100, 22));
|
|
|
|
|
|
|
|
label2.setFont(font);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",label2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur++;
|
|
|
|
|
|
|
|
DateButton field2 = new DateButton();
|
|
|
|
|
|
|
|
field2.setDate(date);
|
|
|
|
|
|
|
|
field2.setDisplayFormatter(formatter);
|
|
|
|
|
|
|
|
field2.setPreferredSize(new Dimension(140, 22));
|
|
|
|
|
|
|
|
field2.setFont(font);
|
|
|
|
|
|
|
|
leftTJPanel.add(cur + ".1.left",field2);
|
|
|
|
|
|
|
|
// 将控件和查询条件绑定
|
|
|
|
|
|
|
|
dMap.put(field2, list.get(3));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JScrollPane scroll = new JScrollPane(leftTJPanel);
|
|
|
|
|
|
|
|
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
|
|
|
|
|
|
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel buttonPanel = new JPanel(new FlowLayout());
|
|
|
|
|
|
|
|
okButton = new JButton("确定");
|
|
|
|
|
|
|
|
okButton.setPreferredSize(new Dimension(60, 22));
|
|
|
|
|
|
|
|
okButton.setFont(font2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exButton = new JButton("导出");
|
|
|
|
|
|
|
|
exButton.setPreferredSize(new Dimension(60, 22));
|
|
|
|
|
|
|
|
exButton.setFont(font2);
|
|
|
|
|
|
|
|
exportData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttonPanel.add(okButton);
|
|
|
|
|
|
|
|
buttonPanel.add(exButton);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leftPanel.add(scroll, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
leftPanel.add(buttonPanel, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> columnsList = new ArrayList<>();
|
|
|
|
|
|
|
|
for(int i=0; i<colList.size(); i++) {
|
|
|
|
|
|
|
|
columnsList.add(colList.get(i).get(0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 将ArrayList转换为数组
|
|
|
|
|
|
|
|
String[] array = columnsList.toArray(new String[0]);
|
|
|
|
|
|
|
|
columns = new String[array.length + 1];
|
|
|
|
|
|
|
|
columns[0] = "序号";
|
|
|
|
|
|
|
|
// 添加ArrayList的内容到数组中间位置
|
|
|
|
|
|
|
|
System.arraycopy(array, 0, columns, 1, array.length);
|
|
|
|
|
|
|
|
DefaultTableModel tableModel = new DefaultTableModel(null, columns);
|
|
|
|
|
|
|
|
JTable createTable = new JTable(tableModel){
|
|
|
|
|
|
|
|
public boolean isCellEditable(int row, int column) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
createTable.setRowHeight(40);
|
|
|
|
|
|
|
|
DefaultTableModel m = (DefaultTableModel) createTable.getModel();
|
|
|
|
|
|
|
|
createTable.getTableHeader().setReorderingAllowed(false); // 设置不可拖拽
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
createTable.getColumnModel().getColumn(0).setPreferredWidth(10);
|
|
|
|
|
|
|
|
System.out.println("给第1列设置初始列宽:10");
|
|
|
|
|
|
|
|
// 从第2列开始,给每一列设置初始列宽
|
|
|
|
|
|
|
|
for(int i=0; i<colList.size(); i++) {
|
|
|
|
|
|
|
|
if(colList.get(i).size() > 2) { // 大于2,代表get(3)为列宽
|
|
|
|
|
|
|
|
Integer valueOf = Integer.valueOf(colList.get(i).get(2));
|
|
|
|
|
|
|
|
createTable.getColumnModel().getColumn(i+1).setPreferredWidth(valueOf);
|
|
|
|
|
|
|
|
System.out.println("给第" + (i+2) + "列设置初始列宽:" + valueOf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// createTable.getColumnModel().getColumn(createTable.getColumnCount()-2).setPreferredWidth(10);
|
|
|
|
|
|
|
|
// createTable.getColumnModel().getColumn(createTable.getColumnCount()-1).setPreferredWidth(10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doubleAdd(createTable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加表头点击事件监听器
|
|
|
|
|
|
|
|
JTableHeader header = createTable.getTableHeader();
|
|
|
|
|
|
|
|
header.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
|
|
|
|
|
int column = createTable.columnAtPoint(e.getPoint());
|
|
|
|
|
|
|
|
System.out.println("Clicked column header " + (column + 1));
|
|
|
|
|
|
|
|
allSj = sortByIndexAndUpdateMap(allSj,(column + 1),null,baogao);
|
|
|
|
|
|
|
|
clearTable(createTable);
|
|
|
|
|
|
|
|
createTable.updateUI();
|
|
|
|
|
|
|
|
num = 0;
|
|
|
|
|
|
|
|
DefaultTableModel m = (DefaultTableModel) createTable.getModel();
|
|
|
|
|
|
|
|
for(List<String> list : allSj) {
|
|
|
|
|
|
|
|
m.addRow(list.toArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//setTableCellBackgroundByLastColumn(createTable);
|
|
|
|
|
|
|
|
createTable.updateUI();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JScrollPane scrollRight = new JScrollPane(createTable);
|
|
|
|
|
|
|
|
scrollRight.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //设置水平滚动条需要时可见
|
|
|
|
|
|
|
|
scrollRight.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); //设置竖向滚动条需要时可见
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel endP = new JPanel(new BorderLayout());
|
|
|
|
|
|
|
|
endP.add(scroll, BorderLayout.WEST);
|
|
|
|
|
|
|
|
endP.add(scrollRight, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
// this.add(scroll, BorderLayout.WEST);
|
|
|
|
|
|
|
|
this.add(endP, BorderLayout.CENTER);
|
|
|
|
|
|
|
|
this.add(buttonPanel, BorderLayout.SOUTH);
|
|
|
|
|
|
|
|
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
|
|
|
|
|
|
|
this.pack();
|
|
|
|
|
|
|
|
this.setResizable(true);
|
|
|
|
|
|
|
|
this.setLocationRelativeTo(null);
|
|
|
|
|
|
|
|
// this.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
|
|
|
|
|
|
|
this.setExtendedState(JFrame.NORMAL);
|
|
|
|
|
|
|
|
// this.setUndecorated(false);
|
|
|
|
|
|
|
|
this.setVisible(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
okButton.addActionListener(new ActionListener() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wait.showProgressBar();// 开启进度条
|
|
|
|
|
|
|
|
// waiting = new WaitingDialog(AIFUtility.getCurrentApplication().getDesktop(), "等待提示", "正在加载,请稍侯 ...");
|
|
|
|
|
|
|
|
waiting = new WaitingDialog(null,"等待提示", "正在加载,请稍侯 ...");
|
|
|
|
|
|
|
|
waiting.SetDialogMessage("正在加载,请稍侯 ...");
|
|
|
|
|
|
|
|
waiting.setVisible(true);// 开启进度条
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> textList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<String> tjList = new ArrayList<>();
|
|
|
|
|
|
|
|
fMap.forEach((k,v) -> {
|
|
|
|
|
|
|
|
if(k != null && !"".equals(k.getText())) {
|
|
|
|
|
|
|
|
textList.add(k.getText());
|
|
|
|
|
|
|
|
tjList.add(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
boxMap.forEach((k,v) -> {
|
|
|
|
|
|
|
|
if(k != null && !"".equals(k.getSelectedItem().toString()) &&
|
|
|
|
|
|
|
|
!" ".equals(k.getSelectedItem().toString())) {
|
|
|
|
|
|
|
|
textList.add(k.getSelectedItem().toString());
|
|
|
|
|
|
|
|
tjList.add(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
dMap.forEach((k,v) -> {
|
|
|
|
|
|
|
|
if(k != null && k.getDate() != null) {
|
|
|
|
|
|
|
|
textList.add(formatter3.format(k.getDate())+" 00:00");
|
|
|
|
|
|
|
|
tjList.add(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
System.out.println("查询名称:" + SearchName);
|
|
|
|
|
|
|
|
if(tjList == null || tjList.size() == 0) {
|
|
|
|
|
|
|
|
tjList.add("id01");
|
|
|
|
|
|
|
|
textList.add("*");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for(int i=0; i<tjList.size(); i++) {
|
|
|
|
|
|
|
|
System.out.println("查询条件:" + tjList.get(i) + ";查询值:" + textList.get(i));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tjList.size() == 0) {
|
|
|
|
|
|
|
|
MessageBox.post("请输入查询条件","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
TCComponent[] dxComponents = session.search(SearchName,
|
|
|
|
|
|
|
|
tjList.toArray(new String[tjList.size()]),
|
|
|
|
|
|
|
|
textList.toArray(new String[textList.size()]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(dxComponents==null || dxComponents.length==0) {
|
|
|
|
|
|
|
|
MessageBox.post("没有符合条件的数据","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
if (waiting != null)
|
|
|
|
|
|
|
|
waiting.setVisible(false);// 关闭进度条
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
num = 0;
|
|
|
|
|
|
|
|
allSj = new ArrayList<>();
|
|
|
|
|
|
|
|
for(int i=0; i<dxComponents.length; i++) {
|
|
|
|
|
|
|
|
System.out.println("查询结果" + (i+1) + ":" + dxComponents[i].getStringProperty("object_string"));
|
|
|
|
|
|
|
|
TCComponentItemRevision rev = (TCComponentItemRevision)dxComponents[i]; //版本
|
|
|
|
|
|
|
|
TCComponent[] referenceListProperty = rev.getReferenceListProperty("IMAN_master_form_rev");
|
|
|
|
|
|
|
|
if (referenceListProperty == null || referenceListProperty.length == 0) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TCComponent[] proList = rev.getReferenceListProperty("project_list");
|
|
|
|
|
|
|
|
TCComponent project = null; // 版本关联的项目
|
|
|
|
|
|
|
|
if (proList != null && proList.length > 0) {
|
|
|
|
|
|
|
|
project = proList[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
TCComponent form = referenceListProperty[0]; // 版本表单
|
|
|
|
|
|
|
|
TCComponentItem item = rev.getItem(); // 版本父对象
|
|
|
|
|
|
|
|
//colList
|
|
|
|
|
|
|
|
List<String> sj = new ArrayList<>();
|
|
|
|
|
|
|
|
num ++;
|
|
|
|
|
|
|
|
sj.add(num.toString());
|
|
|
|
|
|
|
|
for(int j=0; j<colList.size(); j++) {
|
|
|
|
|
|
|
|
String string = colList.get(j).get(1);
|
|
|
|
|
|
|
|
String[] split = string.split("\\.");
|
|
|
|
|
|
|
|
if(split != null && split.length > 1) {
|
|
|
|
|
|
|
|
String dx = split[0]; // 属性在什么对象上面
|
|
|
|
|
|
|
|
String shux = split[1]; // 属性真实名称
|
|
|
|
|
|
|
|
if("Item".equals(dx)) {
|
|
|
|
|
|
|
|
String property = item.getProperty(shux);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Date dateProperty = item.getDateProperty(shux);
|
|
|
|
|
|
|
|
if(dateProperty != null) {
|
|
|
|
|
|
|
|
property = formatter2.format(dateProperty);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception eee) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(property == null ? "" : property);
|
|
|
|
|
|
|
|
} else if("Rev".equals(dx)) {
|
|
|
|
|
|
|
|
String property = rev.getProperty(shux);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Date dateProperty = rev.getDateProperty(shux);
|
|
|
|
|
|
|
|
if(dateProperty != null) {
|
|
|
|
|
|
|
|
property = formatter2.format(dateProperty);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception eee) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(property == null ? "" : property);
|
|
|
|
|
|
|
|
} else if("Form".equals(dx)) {
|
|
|
|
|
|
|
|
String property = form.getProperty(shux);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Date dateProperty = form.getDateProperty(shux);
|
|
|
|
|
|
|
|
if(dateProperty != null) {
|
|
|
|
|
|
|
|
property = formatter2.format(dateProperty);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception eee) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// TCComponent relatedComponent = form.getRelatedComponent(shux);
|
|
|
|
|
|
|
|
// if(relatedComponent != null) {
|
|
|
|
|
|
|
|
// property = relatedComponent.toString();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (Exception ee) {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(property == null ? "" : property);
|
|
|
|
|
|
|
|
} else if("Proj".equals(dx)) {
|
|
|
|
|
|
|
|
if(project == null) {
|
|
|
|
|
|
|
|
sj.add("");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
String property = project.getProperty(shux);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Date dateProperty = project.getDateProperty(shux);
|
|
|
|
|
|
|
|
if(dateProperty != null) {
|
|
|
|
|
|
|
|
property = formatter2.format(dateProperty);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch(Exception eee) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(property == null ? "" : property);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
sj.add("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
if(string.equals("ECRID")) {
|
|
|
|
|
|
|
|
String ids = "";
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECRID=============="+relatedComponents.length);
|
|
|
|
|
|
|
|
for (int k = 0; k < relatedComponents.length; k++) {
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECRLRevision") || relatedComponents[k].getType().equals("SB6_ECRXRevision")) {
|
|
|
|
|
|
|
|
ids += relatedComponents[k].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(qc(ids));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(string.equals("ECNID")) {
|
|
|
|
|
|
|
|
String ids = "";
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID1==================="+relatedComponents.length);
|
|
|
|
|
|
|
|
for (int k = 0; k < relatedComponents.length; k++) {
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECNLRevision") || relatedComponents[k].getType().equals("SB6_ECNXRevision")) {
|
|
|
|
|
|
|
|
ids += relatedComponents[k].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) {
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID2==================="+relatedComponents2.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int m = 0; m < relatedComponents2.length; m++) {
|
|
|
|
|
|
|
|
if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) {
|
|
|
|
|
|
|
|
ids += relatedComponents2[m].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) {
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID2==================="+relatedComponents2.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int m = 0; m < relatedComponents2.length; m++) {
|
|
|
|
|
|
|
|
if(relatedComponents2[m].getType().equals("SB6_ECNXRevision")) {
|
|
|
|
|
|
|
|
ids += relatedComponents2[m].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(qc(ids));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(string.equals("ECOID")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ids = "";
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents = rev.getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID1==================="+relatedComponents.length);
|
|
|
|
|
|
|
|
for (int k = 0; k < relatedComponents.length; k++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECRLRevision")) {
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents2 = relatedComponents[k].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID2==================="+relatedComponents2.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int m = 0; m < relatedComponents2.length; m++) {
|
|
|
|
|
|
|
|
if(relatedComponents2[m].getType().equals("SB6_ECNLRevision")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents3 = relatedComponents2[m].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID3==================="+relatedComponents3.length);
|
|
|
|
|
|
|
|
for (int n = 0; n < relatedComponents3.length; n++) {
|
|
|
|
|
|
|
|
if(relatedComponents3[n].getType().equals("SB6_ECORevision")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ids += relatedComponents3[n].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(relatedComponents[k].getType().equals("SB6_ECRXRevision")) {
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents4 = relatedComponents[k].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID4==================="+relatedComponents4.length);
|
|
|
|
|
|
|
|
for (int f = 0; f < relatedComponents4.length; f++) {
|
|
|
|
|
|
|
|
if(relatedComponents4[f].getType().equals("SB6_ECNXRevision")) {
|
|
|
|
|
|
|
|
TCComponent[] relatedComponents5 = relatedComponents4[f].getRelatedComponents("CMImplementedBy");
|
|
|
|
|
|
|
|
System.out.println("ECNID5==================="+relatedComponents5.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int g = 0; g < relatedComponents5.length; g++) {
|
|
|
|
|
|
|
|
if(relatedComponents5[g].getType().equals("SB6_ECORevision")) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ids += relatedComponents5[g].getStringProperty("item_id")+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sj.add(qc(ids));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baogao.put(num.toString(), item);
|
|
|
|
|
|
|
|
allSj.add(sj);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clearTable(createTable);
|
|
|
|
|
|
|
|
DefaultTableModel m = (DefaultTableModel) createTable.getModel();
|
|
|
|
|
|
|
|
for(int i=0; i<allSj.size(); i++) {
|
|
|
|
|
|
|
|
m.addRow(allSj.get(i).toArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//setTableCellBackgroundByLastColumn(createTable);
|
|
|
|
|
|
|
|
createTable.updateUI();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch(Exception ee) {
|
|
|
|
|
|
|
|
ee.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wait.hideProgressBar(); // 关闭进度条
|
|
|
|
|
|
|
|
if (waiting != null)
|
|
|
|
|
|
|
|
waiting.setVisible(false);// 关闭进度条
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String qc(String str) {
|
|
|
|
|
|
|
|
if(str == null || str.isEmpty()) {
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String qcStr = "";
|
|
|
|
|
|
|
|
String[] split = str.split(";");
|
|
|
|
|
|
|
|
ArrayList<String> list = new ArrayList<String>();
|
|
|
|
|
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
|
|
|
|
|
if(!list.contains(split[i])) {
|
|
|
|
|
|
|
|
list.add(split[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(list.size() > 0) {
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
|
|
|
qcStr += list.get(i)+";";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
qcStr = qcStr.substring(0, qcStr.length() - 1);
|
|
|
|
|
|
|
|
return qcStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FindData() {
|
|
|
|
|
|
|
|
TCPreferenceService preferenceService = session.getPreferenceService();
|
|
|
|
|
|
|
|
String[] strs = preferenceService.getStringValues("Connor_PRXDashBoard_SearchConfig");
|
|
|
|
|
|
|
|
if(strs != null && strs.length >0) {
|
|
|
|
|
|
|
|
SearchName = strs[0];
|
|
|
|
|
|
|
|
System.out.println("查询名称:" + SearchName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=1; i<strs.length; i++) {
|
|
|
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
|
|
|
String[] split = strs[i].split(":");
|
|
|
|
|
|
|
|
if(split != null && split.length > 2) {
|
|
|
|
|
|
|
|
list.add(split[0]); // 控件的属性类型
|
|
|
|
|
|
|
|
list.add(split[1]); // 控件的名字
|
|
|
|
|
|
|
|
String[] split2 = split[2].split("\\|");
|
|
|
|
|
|
|
|
if(split2 != null && split2.length > 1) {
|
|
|
|
|
|
|
|
list.add(split2[0]); // 控件是日期,则添加两个查询条件
|
|
|
|
|
|
|
|
list.add(split2[1]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
list.add(split[2]); // 控件是String,添加一个查询条件
|
|
|
|
|
|
|
|
if(split.length > 3) {
|
|
|
|
|
|
|
|
list.add(split[3]); // 控件是String并且是LOV
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
searchList.add(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strs = preferenceService.getStringValues("Connor_PRXDashBoard_ShowConfig");
|
|
|
|
|
|
|
|
if(strs != null && strs.length >0) {
|
|
|
|
|
|
|
|
for(int i=0; i<strs.length; i++) {
|
|
|
|
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
|
|
|
|
String[] split = strs[i].split(":");
|
|
|
|
|
|
|
|
if(split != null && split.length > 0) {
|
|
|
|
|
|
|
|
for(int j=0; j<split.length; j++) {
|
|
|
|
|
|
|
|
list.add(split[j]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
colList.add(list);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 清空表格
|
|
|
|
|
|
|
|
public void clearTable(JTable table) {
|
|
|
|
|
|
|
|
DefaultTableModel model = (DefaultTableModel) table.getModel();
|
|
|
|
|
|
|
|
while (model.getRowCount() > 0) {
|
|
|
|
|
|
|
|
model.removeRow(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void exportData() {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
exButton.addActionListener(new ActionListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
|
|
|
|
|
// 弹出文件选择框
|
|
|
|
|
|
|
|
JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
|
|
|
|
|
|
|
|
jfc.setDialogTitle("Choose a directory to export the file");
|
|
|
|
|
|
|
|
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
|
|
|
|
|
|
int returnValue = jfc.showSaveDialog(null);
|
|
|
|
|
|
|
|
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
|
|
|
|
|
|
|
File selectedDirectory = jfc.getSelectedFile();
|
|
|
|
|
|
|
|
// 导出数据到Excel
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
String format = df.format(new Date());
|
|
|
|
|
|
|
|
String fw = selectedDirectory.getAbsolutePath() + "/问题报告看板-" + format + ".xlsx";
|
|
|
|
|
|
|
|
writeExcel(fw, allSj);
|
|
|
|
|
|
|
|
JOptionPane.showMessageDialog(null, "导出成功!");
|
|
|
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成excel
|
|
|
|
|
|
|
|
public void writeExcel(String filePath, List<List<String>> data) throws IOException {
|
|
|
|
|
|
|
|
// 创建一个工作簿对象
|
|
|
|
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook();
|
|
|
|
|
|
|
|
// 创建一个工作表对象
|
|
|
|
|
|
|
|
XSSFSheet sheet = workbook.createSheet();
|
|
|
|
|
|
|
|
// 创建第一行,写表头
|
|
|
|
|
|
|
|
XSSFRow rowHeader = sheet.createRow(0);
|
|
|
|
|
|
|
|
// 创建表头单元格对象
|
|
|
|
|
|
|
|
XSSFCell headerCell = rowHeader.createCell(0);
|
|
|
|
|
|
|
|
// 设置表头单元格的值
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个单元格合并区域对象,将第一行第一列和第一行最后一列合并
|
|
|
|
|
|
|
|
CellRangeAddress region = new CellRangeAddress(0, 0, 0, data.get(0).size() - 1);
|
|
|
|
|
|
|
|
// 使用addMergedRegion方法将单元格合并区域应用到工作表中
|
|
|
|
|
|
|
|
sheet.addMergedRegion(region);
|
|
|
|
|
|
|
|
// // 设置表头单元格样式
|
|
|
|
|
|
|
|
CellStyle style = workbook.createCellStyle();
|
|
|
|
|
|
|
|
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
|
|
|
headerCell.setCellStyle(style);
|
|
|
|
|
|
|
|
headerCell.setCellValue("问题看板");
|
|
|
|
|
|
|
|
// 写标题
|
|
|
|
|
|
|
|
XSSFRow rowNext = sheet.createRow(1);
|
|
|
|
|
|
|
|
for(int i=0; i<columns.length; i++) {
|
|
|
|
|
|
|
|
// 创建一个单元格对象
|
|
|
|
|
|
|
|
XSSFCell cell = rowNext.createCell(i);
|
|
|
|
|
|
|
|
cell.setCellValue(columns[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 遍历数据列表,将数据写入到工作表中
|
|
|
|
|
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
|
|
|
|
|
// 创建一行对象
|
|
|
|
|
|
|
|
XSSFRow row = sheet.createRow(i + 2);
|
|
|
|
|
|
|
|
// 获取当前行数据
|
|
|
|
|
|
|
|
List<String> rowData = data.get(i);
|
|
|
|
|
|
|
|
// 遍历当前行数据,将数据写入到行中
|
|
|
|
|
|
|
|
for (int j = 0; j < rowData.size(); j++) {
|
|
|
|
|
|
|
|
// 创建一个单元格对象
|
|
|
|
|
|
|
|
XSSFCell cell = row.createCell(j);
|
|
|
|
|
|
|
|
// 设置单元格的值
|
|
|
|
|
|
|
|
cell.setCellValue(rowData.get(j));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 创建一个文件输出流对象
|
|
|
|
|
|
|
|
FileOutputStream outputStream = new FileOutputStream(filePath);
|
|
|
|
|
|
|
|
// 将工作簿写入到文件输出流中
|
|
|
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
|
|
|
// 关闭文件输出流
|
|
|
|
|
|
|
|
outputStream.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加双击事件
|
|
|
|
|
|
|
|
public void doubleAdd(JTable table) {
|
|
|
|
|
|
|
|
table.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
if (e.getClickCount() == 2) {
|
|
|
|
|
|
|
|
System.out.println("双击表格");
|
|
|
|
|
|
|
|
int row = table.rowAtPoint(e.getPoint());
|
|
|
|
|
|
|
|
String valueAt = (String)table.getValueAt(row, 0);
|
|
|
|
|
|
|
|
TCComponent tcComponent = baogao.get(valueAt);
|
|
|
|
|
|
|
|
openForm(tcComponent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 打开对象
|
|
|
|
|
|
|
|
private void openForm(TCComponent form) {
|
|
|
|
|
|
|
|
// try{
|
|
|
|
|
|
|
|
// boolean modifiable = false;
|
|
|
|
|
|
|
|
// TCComponentUser currentUser = session.getUser();
|
|
|
|
|
|
|
|
// String zuzhi = currentUser.getLoginGroup().toString();
|
|
|
|
|
|
|
|
// System.out.println("currentUser:" + currentUser.toString());
|
|
|
|
|
|
|
|
// System.out.println("zuzhi:" + zuzhi);
|
|
|
|
|
|
|
|
// // owning_group
|
|
|
|
|
|
|
|
// TCComponent[] members = form.getRelatedComponents("owning_group");
|
|
|
|
|
|
|
|
// if(members!=null && members.length>0) {
|
|
|
|
|
|
|
|
// System.out.println("组织数组不为空");
|
|
|
|
|
|
|
|
// for(int i=0;i<members.length;i++) {
|
|
|
|
|
|
|
|
// String string = members[i].toString();
|
|
|
|
|
|
|
|
// System.out.println("组织:" + string);
|
|
|
|
|
|
|
|
// if(zuzhi.equals(string)) {
|
|
|
|
|
|
|
|
// modifiable = true;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// System.out.println("modifiable:" + modifiable);
|
|
|
|
|
|
|
|
// if(!modifiable) {
|
|
|
|
|
|
|
|
// MessageBox.post("没有权限打开此对象!","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (Exception e1) {
|
|
|
|
|
|
|
|
// MessageBox.post("没有权限打开此对象!","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
TCAccessControlService accessControlService = session.getTCAccessControlService();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
boolean checkPrivilege = accessControlService.checkPrivilege(form, "READ");
|
|
|
|
|
|
|
|
if(!checkPrivilege) {
|
|
|
|
|
|
|
|
MessageBox.post("没有权限打开此对象!","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (TCException e) {
|
|
|
|
|
|
|
|
System.out.println("错误,抛出异常");
|
|
|
|
|
|
|
|
MessageBox.post("没有权限打开此对象!","提示",MessageBox.INFORMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InterfaceAIFComponent[] contexts = new InterfaceAIFComponent[] { form };
|
|
|
|
|
|
|
|
AbstractAIFCommand abstractaifcommand = new OpenCommand(app.getDesktop(), contexts);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
abstractaifcommand.executeModal();
|
|
|
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public void setTableCellBackgroundByLastColumn(JTable table) {
|
|
|
|
|
|
|
|
// // 设置渲染器
|
|
|
|
|
|
|
|
// DefaultTableCellRenderer renderer = new DefaultTableCellRenderer() {
|
|
|
|
|
|
|
|
// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
|
|
|
|
|
|
// Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
|
|
|
|
|
|
// String grade = (String) table.getValueAt(row, table.getColumnCount() - 2);
|
|
|
|
|
|
|
|
// if (grade.contains("延期") && !grade.contains("完成")) {
|
|
|
|
|
|
|
|
// c.setBackground(Color.RED);
|
|
|
|
|
|
|
|
// } else if (grade.contains("提前")) {
|
|
|
|
|
|
|
|
// c.setBackground(Color.BLUE);
|
|
|
|
|
|
|
|
// } else if (grade.contains("按期")) {
|
|
|
|
|
|
|
|
// c.setBackground(Color.GREEN);
|
|
|
|
|
|
|
|
// } else if (grade.contains("延期") && grade.contains("完成")) {
|
|
|
|
|
|
|
|
// c.setBackground(Color.YELLOW);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// c.setBackground(table.getBackground());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return c;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// table.getColumnModel().getColumn(table.getColumnCount() - 2).setCellRenderer(renderer);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 日期差
|
|
|
|
|
|
|
|
public static int daysBetweenDates(Date date1, Date date2) {
|
|
|
|
|
|
|
|
long difference = date2.getTime() - date1.getTime();
|
|
|
|
|
|
|
|
int num = (int) (difference / (1000 * 60 * 60 * 24));
|
|
|
|
|
|
|
|
return num > 0 ? num : -num;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 排序并重新关联
|
|
|
|
|
|
|
|
public List<List<String>> sortByIndexAndUpdateMap(List<List<String>> data, int index,
|
|
|
|
|
|
|
|
HashMap<String, String> map, HashMap<String, TCComponent> map2) {
|
|
|
|
|
|
|
|
System.out.println("重新排序");
|
|
|
|
|
|
|
|
HashMap<String, String> newMap = new HashMap<String, String>();
|
|
|
|
|
|
|
|
HashMap<String, TCComponent> newMap2 = new HashMap<String, TCComponent>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<List<String>> sortedList = new ArrayList<>(data);
|
|
|
|
|
|
|
|
// 冒泡排序
|
|
|
|
|
|
|
|
if(sortedList.get(0).get(index-1).compareTo(sortedList.get(sortedList.size() -1 ).get(index-1)) < 0) {
|
|
|
|
|
|
|
|
System.out.println("从大到小");
|
|
|
|
|
|
|
|
for (int i = 0; i < sortedList.size() - 1; i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < sortedList.size() - 1 - i; j++) {
|
|
|
|
|
|
|
|
List<String> list1 = sortedList.get(j);
|
|
|
|
|
|
|
|
List<String> list2 = sortedList.get(j + 1);
|
|
|
|
|
|
|
|
if (list1.get(index-1).compareTo(list2.get(index-1)) < 0) {
|
|
|
|
|
|
|
|
// list1的第i个元素小于list2的第i个元素,交换位置
|
|
|
|
|
|
|
|
sortedList.set(j, list2);
|
|
|
|
|
|
|
|
sortedList.set(j + 1, list1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
System.out.println("从小到大");
|
|
|
|
|
|
|
|
for (int i = 0; i < sortedList.size() - 1; i++) {
|
|
|
|
|
|
|
|
for (int j = 0; j < sortedList.size() - 1 - i; j++) {
|
|
|
|
|
|
|
|
List<String> list1 = sortedList.get(j);
|
|
|
|
|
|
|
|
List<String> list2 = sortedList.get(j + 1);
|
|
|
|
|
|
|
|
if (list1.get(index-1).compareTo(list2.get(index-1)) > 0) {
|
|
|
|
|
|
|
|
// list1的第i个元素小于list2的第i个元素,交换位置
|
|
|
|
|
|
|
|
sortedList.set(j, list2);
|
|
|
|
|
|
|
|
sortedList.set(j + 1, list1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历List<List<String>>,更新每个List<String>的第一个元素,并更新map中的数据
|
|
|
|
|
|
|
|
for (int i = 0; i < sortedList.size(); i++) {
|
|
|
|
|
|
|
|
List<String> list = sortedList.get(i);
|
|
|
|
|
|
|
|
String oldIndex = list.get(0);
|
|
|
|
|
|
|
|
String newIndex = String.valueOf(i + 1);
|
|
|
|
|
|
|
|
// // 更新List<String>的序号
|
|
|
|
|
|
|
|
// list.set(0, newIndex);
|
|
|
|
|
|
|
|
// 获取原来关联的TCComponent对象
|
|
|
|
|
|
|
|
TCComponent comp = map2.get(oldIndex);
|
|
|
|
|
|
|
|
// 将TCComponent对象关联到新的序号上
|
|
|
|
|
|
|
|
map2.remove(oldIndex);
|
|
|
|
|
|
|
|
newMap2.put(newIndex, comp);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
baogao = newMap2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历List<List<String>>,更新每个List<String>的第一个元素
|
|
|
|
|
|
|
|
for (int i = 0; i < sortedList.size(); i++) {
|
|
|
|
|
|
|
|
List<String> list = sortedList.get(i);
|
|
|
|
|
|
|
|
list.set(0, String.valueOf(i + 1));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("排序完成");
|
|
|
|
|
|
|
|
return sortedList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|