You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

936 lines
32 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.langtech.plm.bg;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.RowSorter;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
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.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentProcessType;
import com.teamcenter.rac.kernel.TCComponentProject;
import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.DateButton;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.soa.client.model.LovValue;
public class QDRWDialog extends JFrame implements ActionListener {
private Map<String, JTextField> textMap = new HashMap<>();
private TCSession session;
private JTable table;
private String[] header;
private ArrayList<String> gsPrefTopLine;
private LinkedHashMap<Integer, String> colorMap = new LinkedHashMap<Integer, String>();
private LinkedHashMap<String, String> gsPrefMap = new LinkedHashMap<String, String>();
private LinkedHashMap<String, String> fieldsMap = new LinkedHashMap<String, String>();
private LinkedHashMap<String, String> cfdjPref = new LinkedHashMap<String, String>();
private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>();
private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>();
private LinkedHashMap<Integer, Integer> widtheMap = new LinkedHashMap<Integer, Integer>();
// public static final int[] HEADERWIDTH = new int[] { 50, 100, 200, 200, 100,
// 100, 80, 80, 100, 150, 150, 150, 150,150, 150, 150, 150, 150, 150 };
private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private DefaultTableModel dtm1;
private JComboBox<String> cfdJComboBox = new JComboBox<String>();
private DateButton jhksB;
private DateButton jhksS;
private DateButton jhwcB;
private DateButton jhwcS;
private JTextField idField = new JTextField(30);
private JButton ssButton = new JButton("<22><><EFBFBD><EFBFBD>");
private JButton ckButton = new JButton("<22><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
private JButton qrqdButton = new JButton(<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
private JButton gbButton = new JButton("<22>ر<EFBFBD>");
private static ArrayList<String> dateConnList = new ArrayList<String>();
private String pref;
private String taskName;
private ArrayList<Integer> canWriteColume = new ArrayList<Integer>();
private ArrayList<String> sqlField;
private QDRWTableColorRender QDRWTableColorRender;
LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
private Connection conn = null;
private String tamplateName;
private String chooseType;
public QDRWDialog(TCSession session, String pref, String taskName,String tamplateName,String chooseType) {
// TODO Auto-generated constructor stub
this.session = session;
this.pref = pref;
this.taskName = taskName;
this.tamplateName = tamplateName;
this.chooseType = chooseType;
initUI();
}
public void initUI() {
// TODO Auto-generated method stub
this.setTitle("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
this.setLayout(new BorderLayout());
String[] prefs = session.getPreferenceService().getStringValues(pref);
if (prefs == null || prefs.length <= 0) {
MessageBox.post("<22><>ѡ<EFBFBD>" + pref + "<22><>δ<EFBFBD><CEB4><EFBFBD>ã<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
return;
}
String[] split2 = prefs[0].split(";");
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("=");
positionFieldMap.put(split3[0], j);
if (split3.length == 3) {
if (split3[1].contains("#")) {
String[] split = split3[1].split("#");
fieldsMap.put(split3[0], split[1]);
colorMap.put(j + 1, split3[0]);
} else {
fieldsMap.put(split3[0], split3[1]);
}
if (split3[2].contains("%")) {
String[] split4 = split3[2].split("%");
widtheMap.put(j + 1, Integer.parseInt(split4[0]));
canWriteColume.add(j);
} else {
widtheMap.put(j + 1, Integer.parseInt(split3[2]));
}
}
else if (split3.length == 4) {
fieldsMap.put(split3[0], split3[1]);
// System.out.println("split3[2]========" + split3[2]);
if (split3[2].contains("%")) {
String[] split4 = split3[2].split("%");
widtheMap.put(j, Integer.parseInt(split4[0]));
// System.out.println("split4[0]========" + split4[0]);
canWriteColume.add(j);
} else {
widtheMap.put(j, Integer.parseInt(split3[2]));
}
lovPositionMap.put(j, split3[3]);
}
}
System.out.println("canWriteColume=====" + canWriteColume.size());
System.out.println("fieldsMap=====" + fieldsMap);
System.out.println("positionMap=====" + lovPositionMap);
System.out.println("widtheMap=====" + widtheMap);
Collection<String> valuesCollection = fieldsMap.values();
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>µ<EFBFBD><C2B5>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
List<String> valuesList = new ArrayList<>(valuesCollection);
// <20><><EFBFBD>б<EFBFBD><D0B1>ĵ<EFBFBD>һ<EFBFBD><D2BB>λ<EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD>µ<EFBFBD> String ֵ
valuesList.add(0, "");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD>б<EFBFBD>ת<EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD>
Collection<String> updatedValuesCollection = valuesList;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
header = updatedValuesCollection.toArray(new String[0]);
System.out.println("header===============" + header.length);
JPanel topPanel = getTopPanel();
JScrollPane pane = getTablePanel();
pane.setBorder(BorderFactory.createTitledBorder(""));
// JPanel btnPanel = getRightPanel();
JPanel bottomPane = getBottomPanel();
this.add(topPanel, BorderLayout.NORTH);
this.add(pane, BorderLayout.CENTER);
this.add(bottomPane, BorderLayout.SOUTH);
this.createActionEvent();
this.pack();
this.setPreferredSize(new Dimension(1850, 1000));
this.validate();
this.setVisible(true);
// <20><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
// Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize();
// int x = (int) screensize.getWidth() / 2 - window.getWidth() / 2;
// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2;
this.setLocationRelativeTo(null);
// <20><><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD>
TableColumnModel colModel = table.getColumnModel();
for (Entry<Integer, Integer> map : widtheMap.entrySet()) {
colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue());
}
}
public void createActionEvent() {
this.ssButton.addActionListener(this);
this.ckButton.addActionListener(this);
this.gbButton.addActionListener(this);
this.qrqdButton.addActionListener(this);
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
private JPanel getTopPanel() {
// TODO Auto-generated method stub
JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout());
jhksB = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhksB.setDate(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
jhksS = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhksS.setDate(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
jhwcB = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhwcB.setDate(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
jhwcS = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhwcS.setDate(<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
topPanel.add("1.1.left.center", new JLabel("ID "));
topPanel.add("1.2.left.center", idField);
topPanel.add("1.3.left.center", new JLabel(" <20>ƻ<EFBFBD><C6BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> "));
topPanel.add("1.4.left.center", jhksB);
topPanel.add("1.5.left.center", new JLabel(" <20>ƻ<EFBFBD><C6BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> "));
topPanel.add("1.6.left.center", jhksS);
topPanel.add("1.7.left.center", new JLabel(" <20>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "));
topPanel.add("1.8.left.center", jhwcB);
topPanel.add("1.9.left.center", new JLabel(" <20>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "));
topPanel.add("1.10.left.center", jhwcS);
topPanel.add("2.1.left.center", new JLabel(" "));
return topPanel;
}
// <20><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
private JPanel getBottomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new PropertyLayout());
bottomPanel.add("1.1.left.center", new JLabel(" "));
bottomPanel.add("1.2.left.center", ssButton);
bottomPanel.add("1.3.left.center", new JLabel(" "));
bottomPanel.add("1.4.left.center", ckButton);
bottomPanel.add("1.5.left.center", new JLabel(" "));
bottomPanel.add("1.6.left.center", qrqdButton);
bottomPanel.add("1.7.left.center", new JLabel(" "));
bottomPanel.add("1.8.left.center", gbButton);
return bottomPanel;
}
private JScrollPane getTablePanel() {
// TODO Auto-generated method stub
table = getjTable(null, null, header, null, false);
table.setRowHeight(30);
// table.setPreferredSize(new Dimension(1500,400));
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // <20><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽΪ<CABD>ر<EFBFBD><D8B1>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//<2F><><EFBFBD><EFBFBD>JTable<6C><65><EFBFBD>п<EFBFBD><D0BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
// table.setPreferredSize(new Dimension(1200,400));
// <20><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE>
QDRWTableColorRender = new QDRWTableColorRender();
table.setDefaultRenderer(Object.class, QDRWTableColorRender);
JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(table));
table.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(table));
// for (Entry<Integer, String> map : lovPositionMap.entrySet()) {
// JComboBox<String> jComboBox = new JComboBox<String>();
// String value = map.getValue();
// if(value.contains(",")) {
// String[] split = value.split(",");
// for (int i = 0; i < split.length; i++) {
// jComboBox.addItem(split[i]);
// }
// }else {
// jComboBox.addItem(value);
// }
// table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox));
// }
SwingUtilities.invokeLater(new Runnable() {
public void run() {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2 || e.getClickCount() == 1) {
// TODO Auto-generated method stub
int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
int selectedRow = table.rowAtPoint(e.getPoint());
if (selectColumn == 0) {
Object valueAt = table.getValueAt(selectedRow, selectColumn);
if (valueAt.toString().equals("1")) {
table.setValueAt("0", selectedRow, selectColumn);
} else {
table.setValueAt("1", selectedRow, selectColumn);
}
}
}
}
});
}
});
pane.setPreferredSize(new Dimension(1800, 850));
pane.setViewportView(table);// ΪscrollPaneָ<65><D6B8><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Ϊtable
return pane;
}
/***
* Jtableͨ<65>÷<EFBFBD><C3B7><EFBFBD>
*
* @param partsTable
* @param dtm
* @param titleNames
* @param values
* @return
*/
public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values,
Boolean isTable2) {
// int simpleLen = 100;
// int totleLen = 1000;
if (partsTable == null) {
partsTable = new JTable(this.getTableModel(dtm, titleNames, values));
partsTable.setRowHeight(20);
partsTable.getTableHeader().setReorderingAllowed(false);
partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(partsTable.getModel());
partsTable.setRowSorter(sorter);
// for (int i = 0; i < titleNames.length; i++) {
// if(i==2) {
// partsTable.getColumnModel().getColumn(i).setPreferredWidth(200);
// }else {
// partsTable.getColumnModel().getColumn(i).setPreferredWidth(120);
// }
//
// }
}
return partsTable;
}
public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) {
dtm1 = null;
if (dtm == null) {
dtm1 = new DefaultTableModel(values, titleNames) {
@Override
public boolean isCellEditable(int row, int column) {
if (column == 0) {
return true;
} else {
return false;
}
}
};
}
return dtm1;
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
System.out.println("source==>+" + source);
if (source.equals(this.gbButton)) {
dispose();
} else if (source.equals(this.ckButton)) {
int selectedRow = table.getSelectedRow();
if (selectedRow < 0) {
MessageBox.post("<22><>ѡ<EFBFBD><D1A1>ijһ<C4B3><D2BB>!", "<22><>ʾ", 2);
}
String selectId = (String) table.getValueAt(selectedRow, 1);
String selectType = (String) table.getValueAt(selectedRow, 2);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
new QDRWRWFPDialog(session, selectType, selectId);
// d.setModal(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} else if (source.equals(this.qrqdButton)) {
String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value == null || value.length == 0) {
MessageBox.post("<22><>ѡ<EFBFBD><D1A1>LD_dbinfo2<6F><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>顣", "<22><>ʾ", 2);
return;
} else {
Collections.addAll(dateConnList, value);
}
conn = getConn();
int count = 0;
for (int i = 0; i < table.getRowCount(); i++) {
if (table.getValueAt(i, 0).toString().equals("1")) {
String id = table.getValueAt(i, 1).toString();
TCComponentItemRevision rev = null;
try {
System.out.println("id============="+id);
TCComponent[] tcComponentsById = getTCComponentsById(session,id);
if(tcComponentsById != null && tcComponentsById.length > 0) {
System.out.println("tcComponentsById.length============="+tcComponentsById.length);
TCComponentItem item = (TCComponentItem)tcComponentsById[0];
rev = item.getLatestItemRevision();
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id);
for (Entry<Integer, String> map : colorMap.entrySet()) {
boolean isProsess = false;
String prefValue = map.getValue();
String[] split = prefValue.split("\\.");
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[0]);
String RWXDSJ = "";
String QQRW = "";
String SFSJGG = "";
String GGPSNR = "";
for (int j = 0; j < arrayList.size(); j++) {
if (arrayList.get(j).containsKey("RWXDSJ")) {
RWXDSJ = arrayList.get(j).get("RWXDSJ");
}
if (arrayList.get(j).containsKey("QQRW")) {
QQRW = arrayList.get(j).get("QQRW");
}
if (arrayList.get(j).containsKey("SFSJGG")) {
SFSJGG = arrayList.get(j).get("SFSJGG");
}
if (arrayList.get(j).containsKey("GGPSNR")) {
GGPSNR = arrayList.get(j).get("GGPSNR");
}
}
System.out.println("RWXDSJ======="+RWXDSJ);
System.out.println("QQRW======="+QQRW);
System.out.println("SFSJGG======="+SFSJGG);
if (RWXDSJ == null || RWXDSJ.isEmpty()) {
if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>")) {
isProsess = true;
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>")
&& (QQRW == null || QQRW.isEmpty())) {
isProsess = true;
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>")
&& (QQRW != null && !QQRW.isEmpty())) {
// <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ArrayList<Integer> judgeList = new ArrayList<Integer>();
dgRW(linkedHashMap, QQRW,judgeList);
if(judgeList.size() == 0) {
isProsess = true;
}
}
}
System.out.println("taskName========="+taskName);
System.out.println("isProsess========"+isProsess);
if(isProsess && taskName != null && !taskName.isEmpty() && rev != null) {
try {
CreateProcess(session,rev,taskName,GGPSNR,split[0],id);
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
count++;
}
}
if (count == 0) {
MessageBox.post("<22>ѡ<EBB9B4><D1A1><EFBFBD>ݣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
if(conn != null) {
try {
conn.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return;
}
if(conn != null) {
try {
conn.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
MessageBox.post("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>", "<22><>ʾ ", MessageBox.INFORMATION);
} else if (source.equals(this.ssButton)) {
table.removeAll();
dtm1.setRowCount(0);
String condition = "";
String ids = idField.getText();
String jhksBStr = jhksB.getText();
String jhksSStr = jhksS.getText();
String jhwcBStr = jhwcB.getText();
String jhwcSStr = jhwcS.getText();
System.out.println("jhksBStr=======" + jhksBStr);
if (!jhksBStr.contains(<><CEB4><EFBFBD><EFBFBD>")) {
condition += "and JHKS >= '" + jhksBStr + "' ";
}
if (!jhksSStr.contains(<><CEB4><EFBFBD><EFBFBD>")) {
condition += "and JHKS <= '" + jhksSStr + "' ";
}
if (!jhwcBStr.contains(<><CEB4><EFBFBD><EFBFBD>")) {
condition += "and JHJS >= '" + jhwcBStr + "' ";
}
if (!jhwcSStr.contains(<><CEB4><EFBFBD><EFBFBD>")) {
condition += "and JHJS <= '" + jhwcSStr + "' ";
}
if (ids != null && !ids.isEmpty()) {
if (ids.contains(";")) {
String[] split = ids.split(";");
StringBuilder sqlIn = new StringBuilder();
sqlIn.append("(");
for (int i = 0; i < split.length; i++) {
sqlIn.append("'" + split[i] + "',");
}
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
sqlIn.setLength(sqlIn.length() - 1);
sqlIn.append(")");
System.out.println("sqlIn======================" + sqlIn.toString());
condition += "and ID IN " + sqlIn.toString();
} else {
condition += "and ID='" + ids + "' ";
}
}
String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value == null || value.length == 0) {
MessageBox.post("<22><>ѡ<EFBFBD><D1A1>LD_dbinfo2<6F><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>顣", "<22><>ʾ", 2);
return;
} else {
Collections.addAll(dateConnList, value);
}
sqlField = new ArrayList<String>();
Set<String> keySet = fieldsMap.keySet();
String fieldsSql = "";
for (String string : keySet) {
String[] split = string.split("\\.");
fieldsSql += split[1] + ",";
sqlField.add(split[1]);
}
fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1);
System.out.println("fieldsSql==========" + fieldsSql);
//System.out.println("condition===================" + condition);
if (condition == null || condition.isEmpty()) {
MessageBox.post("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>!", "<22><>ʾ", 2);
return;
}
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where TEMPLATENAME = '"+tamplateName+ "' and OBJECTTYPE = '"+ chooseType + "' " + condition;
System.out.println("sqlIdString=========" + sqlIdString);
conn = getConn();
PreparedStatement stmt = null;
String selectIds = "";
String lastCondition = "";
// <20><>ID
try {
stmt = conn.prepareStatement(sqlIdString);
ResultSet result = stmt.executeQuery();
while (result.next()) {
String id = result.getString("ID");
if (!selectIds.contains(id)) {
selectIds += id + ";";
}
}
if (selectIds != null && !selectIds.isEmpty()) {
if (selectIds.contains(";")) {
String[] split = selectIds.split(";");
StringBuilder sqlIn = new StringBuilder();
sqlIn.append("(");
for (int i = 0; i < split.length; i++) {
sqlIn.append("'" + split[i] + "',");
}
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
sqlIn.setLength(sqlIn.length() - 1);
sqlIn.append(")");
//System.out.println("sqlIn======================" + sqlIn.toString());
lastCondition += "and ID IN " + sqlIn.toString();
} else {
lastCondition += "and ID='" + ids + "' ";
}
}
} catch (SQLException e1) {
e1.printStackTrace();
}
// <20><><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>map
valueMap = new LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>>();
// String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS
// where 1=1 "+lastCondition;
String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition;
System.out.println("sqlString======" + sqlString);
if(lastCondition.isEmpty()) {
MessageBox.post(<><EFBFBD><E9B5BD><EFBFBD>ݣ<EFBFBD>", "<22><>ʾ", 2);
return;
}else {
try {
stmt = conn.prepareStatement(sqlString);
ResultSet result = stmt.executeQuery();
ResultSetMetaData metaData = result.getMetaData();
int columnCount = metaData.getColumnCount();
while (result.next()) {
String id = result.getString("ID");
String xh = result.getString("XH");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> tempMap1 = null;
if (valueMap.containsKey(id)) {
tempMap1 = valueMap.get(id);
} else {
tempMap1 = new LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>();
}
ArrayList<LinkedHashMap<String, String>> tempList = new ArrayList<LinkedHashMap<String, String>>();
for (int i = 1; i <= columnCount; i++) {
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
String columnName = metaData.getColumnName(i); // <20><>ȡʵ<C8A1>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>
// <20><>ȡ<EFBFBD>е<EFBFBD>ֵ
String columnValue = result.getString(i); // ʹ<><CAB9> getObject() <20><>ȡ<EFBFBD>е<EFBFBD>ֵ
LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
fieldMap.put(columnName,
columnValue == null ? columnValue : validateAndFormatDate(columnValue));
tempList.add(fieldMap);
}
tempMap1.put(xh, tempList);
valueMap.put(id, tempMap1);
}
//System.out.println(valueMap.toString());
QDRWTableColorRender.valueMap = valueMap;
QDRWTableColorRender.colorMap = colorMap;
for (Entry<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> map : valueMap
.entrySet()) {
ArrayList<String> tableList = new ArrayList<String>();
tableList.add("0");
for (Entry<String, String> tempMap : fieldsMap.entrySet()) {
String pref = tempMap.getKey();
String[] split = pref.split("\\.");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> value2 = map.getValue();
ArrayList<LinkedHashMap<String, String>> arrayList = value2.get(split[0]);
if (arrayList != null) {
for (int i = 0; i < arrayList.size(); i++) {
LinkedHashMap<String, String> linkedHashMap = arrayList.get(i);
if (linkedHashMap.containsKey(split[1])) {
tableList.add(linkedHashMap.get(split[1]));
}
}
}
}
dtm1.addRow(tableList.toArray(new Object[0]));
}
} catch (SQLException e1) {
e1.printStackTrace();
}
}
try {
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>
public static Connection getConn() {
Connection conn = null;
try {
conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return conn;
}
public String validateAndFormatDate(String input) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڸ<EFBFBD>ʽ
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
try {
// <20><><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter);
// ת<><D7AA>Ϊֻ<CEAA><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>LocalDate<74><65><EFBFBD><EFBFBD>
LocalDate date = dateTime.toLocalDate();
// <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
return date.format(outputFormatter);
} catch (DateTimeParseException e) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB2BB><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<D4AD>ַ<EFBFBD><D6B7><EFBFBD>
return input;
}
}
// // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE>
// static class CustomColorRenderer extends DefaultTableCellRenderer {
// public LinkedHashMap<String,LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
// public LinkedHashMap<Integer, String> colorMap;
//
//
// @Override
// public Component getTableCellRendererComponent(JTable table, Object value,
// boolean isSelected, boolean hasFocus,
// int row, int column) {
// // <20><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><E0B7BD><EFBFBD><EFBFBD>ȡĬ<C8A1><C4AC><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
// Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
//
// String id = (String)table.getValueAt(row, 1);
// LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id);
// System.out.println("colorMap======"+colorMap.toString());
// for (Entry<Integer, String> map : colorMap.entrySet()) {
// Integer columnColor = map.getKey();
// if(column == 4 && row == 1) {
// System.out.println("columnColor========"+columnColor);
// String prefValue = map.getValue();
// String[] split = prefValue.split("\\.");
// ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[0]);
// String sjwcsj = "";
// String jhks = "";
// String jhjs = "";
//
// for (int i = 0; i < arrayList.size(); i++) {
//
// if(arrayList.get(i).containsKey("SJWCSJ")) {
// sjwcsj = arrayList.get(i).get("SJWCSJ");
// }
// if(arrayList.get(i).containsKey("JHKS")) {
// jhks = arrayList.get(i).get("JHKS");
// }
// if(arrayList.get(i).containsKey("JHJS")) {
// jhjs = arrayList.get(i).get("JHJS");
// }
// }
// System.out.println("sjwcsj========"+sjwcsj);
// System.out.println("jhks========"+jhks);
// System.out.println("jhjs========"+jhjs);
// if(sjwcsj != null && !sjwcsj.isEmpty()) {
// c.setBackground(Color.GREEN);
// }else {
// if(jhjs != null && !jhjs.isEmpty() && jhks != null && !jhks.isEmpty()) {
// if(isNotAfterCurrentDate(jhjs)) {
// c.setBackground(Color.RED);
//
//
// System.out.println("row==="+row+"===column==="+column);
// }else {
// //setBackground(Color.YELLOW);
// c.setBackground(Color.YELLOW);
// }
// }
// }
// }
//
// }
//
//
// return c;
// }
// }
//
public void dgRW(LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap, String xhs,
ArrayList<Integer> judgeList) {
if (xhs.contains(",")) {
String[] split = xhs.split(",");
for (int z = 0; z < split.length; z++) {
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[z]);
String SJWCSJ = "";
String SFSJGG = "";
String QQRW = "";
for (int i = 0; i < arrayList.size(); i++) {
if (arrayList.get(i).containsKey("SFSJGG")) {
SFSJGG = arrayList.get(i).get("SFSJGG");
}
if (arrayList.get(i).containsKey("SJWCSJ")) {
SJWCSJ = arrayList.get(i).get("SJWCSJ");
}
if (arrayList.get(i).containsKey("QQRW")) {
QQRW = arrayList.get(i).get("QQRW");
}
}
System.out.println("---SJWCSJ=======" + SFSJGG);
System.out.println("---SFSJGG=======" + SFSJGG);
System.out.println("---QQRW=======" + SFSJGG);
if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>")) {
if (SJWCSJ == null || SJWCSJ.isEmpty()) {
judgeList.add(0);
}
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>") && QQRW != null
&& !QQRW.isEmpty()) {
dgRW(linkedHashMap, QQRW, judgeList);
}
}
} else {
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(xhs);
String SJWCSJ = "";
String SFSJGG = "";
String QQRW = "";
for (int i = 0; i < arrayList.size(); i++) {
if (arrayList.get(i).containsKey("SFSJGG")) {
SFSJGG = arrayList.get(i).get("SFSJGG");
}
if (arrayList.get(i).containsKey("SJWCSJ")) {
SJWCSJ = arrayList.get(i).get("SJWCSJ");
}
if (arrayList.get(i).containsKey("QQRW")) {
QQRW = arrayList.get(i).get("QQRW");
}
}
System.out.println("---SJWCSJ=======" + SJWCSJ);
System.out.println("---SFSJGG=======" + SFSJGG);
System.out.println("---QQRW=======" + QQRW);
if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>")) {
if (SJWCSJ == null || SJWCSJ.isEmpty()) {
judgeList.add(0);
}
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("<22><>") && QQRW != null && !QQRW.isEmpty()) {
dgRW(linkedHashMap, QQRW, judgeList);
}
}
}
public void CreateProcess(TCSession session, TCComponent target, String processName, String rwmc,String xh,String id)
throws TCException {
try {
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
.getTypeComponent("EPMTaskTemplate");
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
if (taskTemplate != null) {
String name = target.getProperty("object_string");
TCComponent create = processType.create(processName + "<22><>" + name + "_" + rwmc, "", taskTemplate,
new TCComponent[] { target }, new int[] { 1 });
//System.out.println("uid===================" + create.getUid());
//System.out.println("type==" + create.getType());
//System.out.println("type==" + create.getStringProperty("object_type"));
String updateSql = "update LY_CHANGETASSKFORM_DETAILS set WFUID = '"+create.getUid()+"' where ID = '"+id+"' and XH = '"+xh+"'";
try {
PreparedStatement prepareStatement = conn.prepareStatement(updateSql);
boolean execute = prepareStatement.execute();
System.out.println("execute=="+execute+"|updateSql===="+updateSql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (TCException var7) {
var7.printStackTrace();
throw var7;
}
}
public static TCComponent[] getTCComponentsById(TCSession session, String id) throws Exception {
return session.search("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...", new String[] { "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID" }, new String[] { id });
}
}