main
李建辉 6 months ago
parent 3952e9fd98
commit fd63bc99fd

@ -69,7 +69,10 @@ import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentListOfValues; import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType; import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCComponentProcessType;
import com.teamcenter.rac.kernel.TCComponentProject; 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.TCException;
import com.teamcenter.rac.kernel.TCProperty; import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
@ -92,7 +95,8 @@ public class QDRWDialog extends JFrame implements ActionListener {
private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>(); private LinkedHashMap<Integer, String> lovPositionMap = new LinkedHashMap<Integer, String>();
private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>(); private LinkedHashMap<String, Integer> positionFieldMap = new LinkedHashMap<String, Integer>();
private LinkedHashMap<Integer, Integer> widtheMap = new LinkedHashMap<Integer, 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 }; // 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 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
private DefaultTableModel dtm1; private DefaultTableModel dtm1;
private JComboBox<String> cfdJComboBox = new JComboBox<String>(); private JComboBox<String> cfdJComboBox = new JComboBox<String>();
@ -111,10 +115,9 @@ public class QDRWDialog extends JFrame implements ActionListener {
private ArrayList<Integer> canWriteColume = new ArrayList<Integer>(); private ArrayList<Integer> canWriteColume = new ArrayList<Integer>();
private ArrayList<String> sqlField; private ArrayList<String> sqlField;
private QDRWTableColorRender QDRWTableColorRender; private QDRWTableColorRender QDRWTableColorRender;
LinkedHashMap<String,LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap; LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> valueMap;
private Connection conn = null;
public QDRWDialog(TCSession session, String pref, String taskName) {
public QDRWDialog(TCSession session,String pref,String taskName) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
this.session = session; this.session = session;
this.pref = pref; this.pref = pref;
@ -129,72 +132,66 @@ public class QDRWDialog extends JFrame implements ActionListener {
String[] prefs = session.getPreferenceService().getStringValues(pref); String[] prefs = session.getPreferenceService().getStringValues(pref);
if (prefs == null || prefs.length <= 0) { if (prefs == null || prefs.length <= 0) {
MessageBox.post("首选项“"+pref+"”未配置!", "提示 ", MessageBox.INFORMATION); MessageBox.post("首选项“" + pref + "”未配置!", "提示 ", MessageBox.INFORMATION);
return; 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]));
}
String[] split2 = prefs[0].split(";"); }
for (int j = 0; j < split2.length; j++) {
String[] split3 = split2[j].split("="); else if (split3.length == 4) {
positionFieldMap.put(split3[0],j); fieldsMap.put(split3[0], split3[1]);
if(split3.length == 3) { // System.out.println("split3[2]========" + split3[2]);
if (split3[2].contains("%")) {
if(split3[1].contains("#")) { String[] split4 = split3[2].split("%");
String[] split = split3[1].split("#"); widtheMap.put(j, Integer.parseInt(split4[0]));
fieldsMap.put(split3[0],split[1]); // System.out.println("split4[0]========" + split4[0]);
colorMap.put(j+1,split3[0]); canWriteColume.add(j);
}else { } else {
fieldsMap.put(split3[0],split3[1]); widtheMap.put(j, Integer.parseInt(split3[2]));
} }
if(split3[2].contains("%")) { lovPositionMap.put(j, split3[3]);
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])); 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();
// 创建一个新的列表来保存所有的值
else if(split3.length == 4) { List<String> valuesList = new ArrayList<>(valuesCollection);
fieldsMap.put(split3[0],split3[1]);
System.out.println("split3[2]========"+split3[2]); // 在列表的第一个位置插入新的 String 值
if(split3[2].contains("%")) { valuesList.add(0, "");
String[] split4 = split3[2].split("%");
widtheMap.put(j, Integer.parseInt(split4[0])); // 如果需要,可以将列表转回集合
System.out.println("split4[0]========"+split4[0]); Collection<String> updatedValuesCollection = valuesList;
canWriteColume.add(j); // 将集合转换为数组
}else { header = updatedValuesCollection.toArray(new String[0]);
widtheMap.put(j, Integer.parseInt(split3[2])); System.out.println("header===============" + header.length);
}
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();
// 创建一个新的列表来保存所有的值
List<String> valuesList = new ArrayList<>(valuesCollection);
// 在列表的第一个位置插入新的 String 值
valuesList.add(0, "");
// 如果需要,可以将列表转回集合
Collection<String> updatedValuesCollection = valuesList;
// 将集合转换为数组
header = updatedValuesCollection.toArray(new String[0]);
System.out.println("header==============="+header.length);
JPanel topPanel = getTopPanel(); JPanel topPanel = getTopPanel();
JScrollPane pane = getTablePanel(); JScrollPane pane = getTablePanel();
@ -216,7 +213,7 @@ public class QDRWDialog extends JFrame implements ActionListener {
// int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2; // int y = (int) screensize.getHeight() / 2 - window.getHeight() / 2;
this.setLocationRelativeTo(null); this.setLocationRelativeTo(null);
//设置列宽 // 设置列宽
TableColumnModel colModel = table.getColumnModel(); TableColumnModel colModel = table.getColumnModel();
for (Entry<Integer, Integer> map : widtheMap.entrySet()) { for (Entry<Integer, Integer> map : widtheMap.entrySet()) {
colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue()); colModel.getColumn(map.getKey()).setPreferredWidth(map.getValue());
@ -224,7 +221,6 @@ public class QDRWDialog extends JFrame implements ActionListener {
} }
public void createActionEvent() { public void createActionEvent() {
this.ssButton.addActionListener(this); this.ssButton.addActionListener(this);
this.ckButton.addActionListener(this); this.ckButton.addActionListener(this);
@ -237,7 +233,7 @@ public class QDRWDialog extends JFrame implements ActionListener {
// TODO Auto-generated method stub // TODO Auto-generated method stub
JPanel topPanel = new JPanel(); JPanel topPanel = new JPanel();
topPanel.setLayout(new PropertyLayout()); topPanel.setLayout(new PropertyLayout());
jhksB = new DateButton(null, "yyyy-MM-dd", false, false, false); jhksB = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhksB.setDate("未设置日期"); jhksB.setDate("未设置日期");
jhksS = new DateButton(null, "yyyy-MM-dd", false, false, false); jhksS = new DateButton(null, "yyyy-MM-dd", false, false, false);
@ -247,35 +243,35 @@ public class QDRWDialog extends JFrame implements ActionListener {
jhwcS = new DateButton(null, "yyyy-MM-dd", false, false, false); jhwcS = new DateButton(null, "yyyy-MM-dd", false, false, false);
jhwcS.setDate("未设置日期"); jhwcS.setDate("未设置日期");
topPanel.add("1.1.left.center", new JLabel("ID ")); topPanel.add("1.1.left.center", new JLabel("ID "));
topPanel.add("1.2.left.center",idField); topPanel.add("1.2.left.center", idField);
topPanel.add("1.3.left.center", new JLabel(" 计划开始早于 ")); topPanel.add("1.3.left.center", new JLabel(" 计划开始早于 "));
topPanel.add("1.4.left.center",jhksB); topPanel.add("1.4.left.center", jhksB);
topPanel.add("1.5.left.center", new JLabel(" 计划开始晚于 ")); topPanel.add("1.5.left.center", new JLabel(" 计划开始晚于 "));
topPanel.add("1.6.left.center",jhksS); topPanel.add("1.6.left.center", jhksS);
topPanel.add("1.7.left.center", new JLabel(" 计划完成早于 ")); topPanel.add("1.7.left.center", new JLabel(" 计划完成早于 "));
topPanel.add("1.8.left.center",jhwcB); topPanel.add("1.8.left.center", jhwcB);
topPanel.add("1.9.left.center", new JLabel(" 计划完成晚于 ")); topPanel.add("1.9.left.center", new JLabel(" 计划完成晚于 "));
topPanel.add("1.10.left.center",jhwcS); topPanel.add("1.10.left.center", jhwcS);
topPanel.add("2.1.left.center", new JLabel(" ")); topPanel.add("2.1.left.center", new JLabel(" "));
return topPanel; return topPanel;
} }
// 查询部分 // 查询部分
private JPanel getBottomPanel() { private JPanel getBottomPanel() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(); JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new PropertyLayout()); bottomPanel.setLayout(new PropertyLayout());
bottomPanel.add("1.1.left.center", new JLabel(" ")); bottomPanel.add("1.1.left.center", new JLabel(" "));
bottomPanel.add("1.2.left.center", ssButton); bottomPanel.add("1.2.left.center", ssButton);
bottomPanel.add("1.3.left.center", new JLabel(" ")); bottomPanel.add("1.3.left.center", new JLabel(" "));
bottomPanel.add("1.4.left.center", ckButton); bottomPanel.add("1.4.left.center", ckButton);
bottomPanel.add("1.5.left.center", new JLabel(" ")); bottomPanel.add("1.5.left.center", new JLabel(" "));
bottomPanel.add("1.6.left.center", qrqdButton); bottomPanel.add("1.6.left.center", qrqdButton);
bottomPanel.add("1.7.left.center", new JLabel(" ")); bottomPanel.add("1.7.left.center", new JLabel(" "));
bottomPanel.add("1.8.left.center", gbButton); bottomPanel.add("1.8.left.center", gbButton);
return bottomPanel; return bottomPanel;
} }
private JScrollPane getTablePanel() { private JScrollPane getTablePanel() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
table = getjTable(null, null, header, null, false); table = getjTable(null, null, header, null, false);
@ -284,9 +280,9 @@ public class QDRWDialog extends JFrame implements ActionListener {
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整 table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整
// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//设置JTable的列宽随着列表内容的大小进行调整 // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//设置JTable的列宽随着列表内容的大小进行调整
// table.setPreferredSize(new Dimension(1200,400)); // table.setPreferredSize(new Dimension(1200,400));
// 设置自定义渲染器 // 设置自定义渲染器
QDRWTableColorRender = new QDRWTableColorRender(); QDRWTableColorRender = new QDRWTableColorRender();
table.setDefaultRenderer(Object.class, QDRWTableColorRender); table.setDefaultRenderer(Object.class, QDRWTableColorRender);
JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane pane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(table)); table.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(table));
@ -304,7 +300,7 @@ public class QDRWDialog extends JFrame implements ActionListener {
// } // }
// table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox)); // table.getColumnModel().getColumn(map.getKey()).setCellEditor(new DefaultCellEditor(jComboBox));
// } // }
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
// 添加鼠标监听器 // 添加鼠标监听器
@ -316,22 +312,20 @@ public class QDRWDialog extends JFrame implements ActionListener {
int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
int selectedRow = table.rowAtPoint(e.getPoint()); int selectedRow = table.rowAtPoint(e.getPoint());
if (selectColumn == 0){ if (selectColumn == 0) {
Object valueAt = table.getValueAt(selectedRow, selectColumn); Object valueAt = table.getValueAt(selectedRow, selectColumn);
if (valueAt.toString().equals("1")) { if (valueAt.toString().equals("1")) {
table.setValueAt("0", selectedRow, selectColumn); table.setValueAt("0", selectedRow, selectColumn);
} else { } else {
table.setValueAt("1", selectedRow, selectColumn); table.setValueAt("1", selectedRow, selectColumn);
} }
} }
} }
} }
}); });
} }
}); });
pane.setPreferredSize(new Dimension(1800, 850)); pane.setPreferredSize(new Dimension(1800, 850));
pane.setViewportView(table);// 为scrollPane指定显示对象为table pane.setViewportView(table);// 为scrollPane指定显示对象为table
return pane; return pane;
@ -377,9 +371,9 @@ public class QDRWDialog extends JFrame implements ActionListener {
dtm1 = new DefaultTableModel(values, titleNames) { dtm1 = new DefaultTableModel(values, titleNames) {
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
if(column == 0) { if (column == 0) {
return true; return true;
}else { } else {
return false; return false;
} }
} }
@ -396,101 +390,199 @@ public class QDRWDialog extends JFrame implements ActionListener {
if (source.equals(this.gbButton)) { if (source.equals(this.gbButton)) {
dispose(); dispose();
} } else if (source.equals(this.ckButton)) {
else if(source.equals(this.ckButton)){
int selectedRow = table.getSelectedRow(); int selectedRow = table.getSelectedRow();
if(selectedRow < 0) { if (selectedRow < 0) {
MessageBox.post("请选择某一行!", "提示", 2); MessageBox.post("请选择某一行!", "提示", 2);
} }
String selectId = (String)table.getValueAt(selectedRow,0); String selectId = (String) table.getValueAt(selectedRow, 1);
String selectType = (String)table.getValueAt(selectedRow,1); String selectType = (String) table.getValueAt(selectedRow, 2);
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
new QDRWRWFPDialog(session,selectType,selectId); new QDRWRWFPDialog(session, selectType, selectId);
//d.setModal(true); // d.setModal(true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}); });
}else if(source.equals(this.qrqdButton)){ } else if (source.equals(this.qrqdButton)) {
String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value == null || value.length == 0) {
MessageBox.post("首选项LD_dbinfo2配置有误请检查。", "提示", 2);
return;
} else {
Collections.addAll(dateConnList, value);
}
conn = getConn();
int count = 0; int count = 0;
for (int i = 0; i < table.getRowCount(); i++) { for (int i = 0; i < table.getRowCount(); i++) {
if (table.getValueAt(i, 0).toString().equals("1")) { if (table.getValueAt(i, 0).toString().equals("1")) {
boolean isProsess = false;
String id = table.getValueAt(i, 1).toString(); 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); LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id);
for (Entry<Integer, String> map : colorMap.entrySet()) { for (Entry<Integer, String> map : colorMap.entrySet()) {
String prefValue = map.getValue(); boolean isProsess = false;
String[] split = prefValue.split("\\."); 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("否")) {
isProsess = true;
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("是")
&& (QQRW == null || QQRW.isEmpty())) {
isProsess = true;
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("是")
&& (QQRW != null && !QQRW.isEmpty())) {
// 找前驱任务
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++; count++;
} }
} }
if (count == 0) { if (count == 0) {
MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION); MessageBox.post("请勾选数据!", "提示 ", MessageBox.INFORMATION);
if(conn != null) {
try {
conn.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
return; return;
} }
}else if(source.equals(this.ssButton)){ if(conn != null) {
try {
conn.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
MessageBox.post("启动完成!", "提示 ", MessageBox.INFORMATION);
} else if (source.equals(this.ssButton)) {
table.removeAll(); table.removeAll();
dtm1.setRowCount(0); dtm1.setRowCount(0);
String condition = ""; String condition = "";
String ids = idField.getText(); String ids = idField.getText();
String jhksBStr = jhksB.getText(); String jhksBStr = jhksB.getText();
String jhksSStr = jhksS.getText(); String jhksSStr = jhksS.getText();
String jhwcBStr = jhwcB.getText(); String jhwcBStr = jhwcB.getText();
String jhwcSStr = jhwcS.getText(); String jhwcSStr = jhwcS.getText();
System.out.println("jhksBStr======="+jhksBStr); System.out.println("jhksBStr=======" + jhksBStr);
if(!jhksBStr.contains("未设置")) { if (!jhksBStr.contains("未设置")) {
condition += "and JHKS >= '"+ jhksBStr +"' "; condition += "and JHKS >= '" + jhksBStr + "' ";
} }
if(!jhksSStr.contains("未设置")) { if (!jhksSStr.contains("未设置")) {
condition += "and JHKS <= '"+ jhksSStr +"' "; condition += "and JHKS <= '" + jhksSStr + "' ";
} }
if(!jhwcBStr.contains("未设置")) { if (!jhwcBStr.contains("未设置")) {
condition += "and JHJS >= '"+ jhwcBStr +"' "; condition += "and JHJS >= '" + jhwcBStr + "' ";
} }
if(!jhwcSStr.contains("未设置")) { if (!jhwcSStr.contains("未设置")) {
condition += "and JHJS <= '"+ jhwcSStr +"' "; condition += "and JHJS <= '" + jhwcSStr + "' ";
} }
if (ids == null || ids.isEmpty()) {
if(ids == null || ids.isEmpty()) {
MessageBox.post("请填写条件!", "提示", 2); MessageBox.post("请填写条件!", "提示", 2);
return; return;
} }
if(ids != null && !ids.isEmpty()) { if (ids != null && !ids.isEmpty()) {
if(ids.contains(";")) { if (ids.contains(";")) {
String[] split = ids.split(";"); String[] split = ids.split(";");
StringBuilder sqlIn = new StringBuilder(); StringBuilder sqlIn = new StringBuilder();
sqlIn.append("("); sqlIn.append("(");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
sqlIn.append("'"+split[i] +"',"); sqlIn.append("'" + split[i] + "',");
} }
//去掉最后一个, // 去掉最后一个,
sqlIn.setLength(sqlIn.length() - 1); sqlIn.setLength(sqlIn.length() - 1);
sqlIn.append(")"); sqlIn.append(")");
System.out.println("sqlIn======================"+sqlIn.toString()); System.out.println("sqlIn======================" + sqlIn.toString());
condition += "and ID IN "+sqlIn.toString(); condition += "and ID IN " + sqlIn.toString();
}else { } else {
condition += "and ID='"+ids+"' "; condition += "and ID='" + ids + "' ";
} }
} }
String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2"); String[] value = session.getPreferenceService().getStringValues("LD_dbinfo2");
if (value == null || value.length == 0) { if (value == null || value.length == 0) {
@ -508,86 +600,88 @@ public class QDRWDialog extends JFrame implements ActionListener {
sqlField.add(split[1]); sqlField.add(split[1]);
} }
fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1); fieldsSql = fieldsSql.substring(0, fieldsSql.length() - 1);
System.out.println("fieldsSql=========="+fieldsSql); System.out.println("fieldsSql==========" + fieldsSql);
System.out.println("condition==================="+condition); //System.out.println("condition===================" + condition);
String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where 1=1 "+condition; String sqlIdString = "SELECT ID FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + condition;
System.out.println("sqlIdString========="+sqlIdString); System.out.println("sqlIdString=========" + sqlIdString);
Connection conn = getConn(); conn = getConn();
PreparedStatement stmt = null; PreparedStatement stmt = null;
String selectIds = ""; String selectIds = "";
String lastCondition = ""; String lastCondition = "";
//查ID // 查ID
try{ try {
stmt = conn.prepareStatement(sqlIdString); stmt = conn.prepareStatement(sqlIdString);
ResultSet result = stmt.executeQuery(); ResultSet result = stmt.executeQuery();
while (result.next()) { while (result.next()) {
String id = result.getString("ID"); String id = result.getString("ID");
if(!selectIds.contains(id)) { if (!selectIds.contains(id)) {
selectIds+=id+";"; selectIds += id + ";";
}
} }
}
if(selectIds != null && !selectIds.isEmpty()) {
if(selectIds.contains(";")) { if (selectIds != null && !selectIds.isEmpty()) {
if (selectIds.contains(";")) {
String[] split = selectIds.split(";"); String[] split = selectIds.split(";");
StringBuilder sqlIn = new StringBuilder(); StringBuilder sqlIn = new StringBuilder();
sqlIn.append("("); sqlIn.append("(");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
sqlIn.append("'"+split[i] +"',"); sqlIn.append("'" + split[i] + "',");
} }
//去掉最后一个, // 去掉最后一个,
sqlIn.setLength(sqlIn.length() - 1); sqlIn.setLength(sqlIn.length() - 1);
sqlIn.append(")"); sqlIn.append(")");
System.out.println("sqlIn======================"+sqlIn.toString()); //System.out.println("sqlIn======================" + sqlIn.toString());
lastCondition += "and ID IN "+sqlIn.toString(); lastCondition += "and ID IN " + sqlIn.toString();
}else { } else {
lastCondition += "and ID='"+ids+"' "; lastCondition += "and ID='" + ids + "' ";
} }
} }
} catch (SQLException e1) { } catch (SQLException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
// 存数据的map
//存数据的map valueMap = new LinkedHashMap<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>>();
valueMap = new LinkedHashMap<String,LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>>(); // String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS
//String sqlString = "SELECT " + fieldsSql + " FROM LY_CHANGETASSKFORM_DETAILS where 1=1 "+lastCondition; // where 1=1 "+lastCondition;
String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 "+lastCondition; String sqlString = "SELECT * FROM LY_CHANGETASSKFORM_DETAILS where 1=1 " + lastCondition;
System.out.println("sqlString======"+sqlString); System.out.println("sqlString======" + sqlString);
try{ try {
stmt = conn.prepareStatement(sqlString); stmt = conn.prepareStatement(sqlString);
ResultSet result = stmt.executeQuery(); ResultSet result = stmt.executeQuery();
ResultSetMetaData metaData = result.getMetaData(); ResultSetMetaData metaData = result.getMetaData();
int columnCount = metaData.getColumnCount(); int columnCount = metaData.getColumnCount();
while (result.next()) { while (result.next()) {
String id = result.getString("ID"); String id = result.getString("ID");
String xh = result.getString("XH"); String xh = result.getString("XH");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> tempMap1 = null; LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> tempMap1 = null;
if(valueMap.containsKey(id)) { if (valueMap.containsKey(id)) {
tempMap1 = valueMap.get(id); tempMap1 = valueMap.get(id);
}else { } else {
tempMap1 = new LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>(); tempMap1 = new LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>();
} }
ArrayList<LinkedHashMap<String, String>> tempList = new ArrayList<LinkedHashMap<String, String>>(); ArrayList<LinkedHashMap<String, String>> tempList = new ArrayList<LinkedHashMap<String, String>>();
for (int i = 1; i <= columnCount; i++) { for (int i = 1; i <= columnCount; i++) {
// 获取列名 // 获取列名
String columnName = metaData.getColumnName(i); // 获取实际的列名 String columnName = metaData.getColumnName(i); // 获取实际的列名
// 获取列的值 // 获取列的值
String columnValue = result.getString(i); // 使用 getObject() 获取列的值 String columnValue = result.getString(i); // 使用 getObject() 获取列的值
LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> fieldMap = new LinkedHashMap<String, String>();
fieldMap.put(columnName,columnValue == null? columnValue : validateAndFormatDate(columnValue)); fieldMap.put(columnName,
tempList.add(fieldMap); columnValue == null ? columnValue : validateAndFormatDate(columnValue));
} tempList.add(fieldMap);
}
tempMap1.put(xh,tempList);
valueMap.put(id,tempMap1); tempMap1.put(xh, tempList);
valueMap.put(id, tempMap1);
} }
System.out.println(valueMap.toString()); //System.out.println(valueMap.toString());
QDRWTableColorRender.valueMap = valueMap; QDRWTableColorRender.valueMap = valueMap;
QDRWTableColorRender.colorMap = colorMap; QDRWTableColorRender.colorMap = colorMap;
for (Entry<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> map : valueMap.entrySet()) { for (Entry<String, LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>>> map : valueMap
.entrySet()) {
ArrayList<String> tableList = new ArrayList<String>(); ArrayList<String> tableList = new ArrayList<String>();
tableList.add("0"); tableList.add("0");
for (Entry<String, String> tempMap : fieldsMap.entrySet()) { for (Entry<String, String> tempMap : fieldsMap.entrySet()) {
@ -595,70 +689,69 @@ public class QDRWDialog extends JFrame implements ActionListener {
String[] split = pref.split("\\."); String[] split = pref.split("\\.");
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> value2 = map.getValue(); LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> value2 = map.getValue();
ArrayList<LinkedHashMap<String, String>> arrayList = value2.get(split[0]); ArrayList<LinkedHashMap<String, String>> arrayList = value2.get(split[0]);
if(arrayList != null) { if (arrayList != null) {
for (int i = 0; i < arrayList.size(); i++) { for (int i = 0; i < arrayList.size(); i++) {
LinkedHashMap<String, String> linkedHashMap = arrayList.get(i); LinkedHashMap<String, String> linkedHashMap = arrayList.get(i);
if(linkedHashMap.containsKey(split[1])) { if (linkedHashMap.containsKey(split[1])) {
tableList.add(linkedHashMap.get(split[1])); tableList.add(linkedHashMap.get(split[1]));
} }
} }
} }
} }
dtm1.addRow(tableList.toArray(new Object[0])); dtm1.addRow(tableList.toArray(new Object[0]));
} }
} catch (SQLException e1) { } catch (SQLException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try { try {
if(stmt != null) { if (stmt != null) {
stmt.close(); stmt.close();
} }
if(conn != null) { if (conn != null) {
conn.close(); conn.close();
} }
} catch (SQLException e1) { } catch (SQLException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
} }
// 获取数据库连接 // 获取数据库连接
public static Connection getConn() { public static Connection getConn() {
Connection conn = null; Connection conn = null;
try { try {
conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1)); conn = DbPool.getConnection(dateConnList.get(0), dateConnList.get(1));
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
}
return conn;
} }
return conn;
public String validateAndFormatDate(String input) { }
// 定义输入和输出的日期格式
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"); public String validateAndFormatDate(String input) {
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 定义输入和输出的日期格式
DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
try { DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 尝试解析输入的日期时间字符串
LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter); try {
// 尝试解析输入的日期时间字符串
// 转换为只包含日期的LocalDate对象 LocalDateTime dateTime = LocalDateTime.parse(input, inputFormatter);
LocalDate date = dateTime.toLocalDate();
// 转换为只包含日期的LocalDate对象
// 格式化结果日期为字符串 LocalDate date = dateTime.toLocalDate();
return date.format(outputFormatter);
} catch (DateTimeParseException e) { // 格式化结果日期为字符串
// 如果解析失败,说明输入不符合指定格式,返回原始字符串 return date.format(outputFormatter);
return input; } catch (DateTimeParseException e) {
} // 如果解析失败,说明输入不符合指定格式,返回原始字符串
} return input;
}
}
// // 自定义渲染器 // // 自定义渲染器
// static class CustomColorRenderer extends DefaultTableCellRenderer { // static class CustomColorRenderer extends DefaultTableCellRenderer {
@ -726,30 +819,107 @@ public class QDRWDialog extends JFrame implements ActionListener {
// } // }
// } // }
// //
public boolean dgRW(LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap,String xh) { public void dgRW(LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap, String xhs,
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(xh); ArrayList<Integer> judgeList) {
for (int i = 0; i < arrayList.size(); i++) {
String RWXDSJ = ""; if (xhs.contains(",")) {
String SJWCSJ= ""; String[] split = xhs.split(",");
String QQRW = ""; for (int z = 0; z < split.length; z++) {
if(arrayList.get(i).containsKey("RWXDSJ")) {
RWXDSJ = arrayList.get(i).get("RWXDSJ"); 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")) { if (arrayList.get(i).containsKey("SJWCSJ")) {
SJWCSJ = arrayList.get(i).get("SJWCSJ"); SJWCSJ = arrayList.get(i).get("SJWCSJ");
} }
if(arrayList.get(i).containsKey("QQRW")) { if (arrayList.get(i).containsKey("QQRW")) {
QQRW = arrayList.get(i).get("QQRW"); QQRW = arrayList.get(i).get("QQRW");
} }
if((RWXDSJ == null || RWXDSJ.isEmpty()) && (SJWCSJ == null || SJWCSJ.isEmpty()) && ) {
}
}else { System.out.println("---SJWCSJ=======" + SFSJGG);
return true; System.out.println("---SFSJGG=======" + SFSJGG);
System.out.println("---QQRW=======" + SFSJGG);
if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("是")) {
if (SJWCSJ == null || SJWCSJ.isEmpty()) {
judgeList.add(0);
} }
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("否") && QQRW != null
} && !QQRW.isEmpty()) {
dgRW(linkedHashMap, QQRW, judgeList);
return false; }
}
}
} 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("是")) {
if (SJWCSJ == null || SJWCSJ.isEmpty()) {
judgeList.add(0);
}
} else if (SFSJGG != null && !SFSJGG.isEmpty() && SFSJGG.equals("否") && 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 + "" + 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("零组件...", new String[] { "零组件 ID" }, new String[] { id });
}
} }

@ -22,16 +22,16 @@ public class QDRWTableColorRender extends TableColorRender {
String id = (String)table.getValueAt(row, 1); String id = (String)table.getValueAt(row, 1);
LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id); LinkedHashMap<String, ArrayList<LinkedHashMap<String, String>>> linkedHashMap = valueMap.get(id);
System.out.println("colorMap======"+colorMap.toString()); //System.out.println("colorMap======"+colorMap.toString());
for (Entry<Integer, String> map : colorMap.entrySet()) { for (Entry<Integer, String> map : colorMap.entrySet()) {
Integer columnColor = map.getKey(); Integer columnColor = map.getKey();
if(column == columnColor) { if(column == columnColor) {
System.out.println("columnColor========"+columnColor); //System.out.println("columnColor========"+columnColor);
String prefValue = map.getValue(); String prefValue = map.getValue();
String[] split = prefValue.split("\\."); String[] split = prefValue.split("\\.");
ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[0]); ArrayList<LinkedHashMap<String, String>> arrayList = linkedHashMap.get(split[0]);
String sjwcsj = ""; String sjwcsj = "";
String jhks = ""; String RWXDSJ = "";
String jhjs = ""; String jhjs = "";
for (int i = 0; i < arrayList.size(); i++) { for (int i = 0; i < arrayList.size(); i++) {
@ -39,28 +39,28 @@ public class QDRWTableColorRender extends TableColorRender {
if(arrayList.get(i).containsKey("SJWCSJ")) { if(arrayList.get(i).containsKey("SJWCSJ")) {
sjwcsj = arrayList.get(i).get("SJWCSJ"); sjwcsj = arrayList.get(i).get("SJWCSJ");
} }
if(arrayList.get(i).containsKey("JHKS")) { if(arrayList.get(i).containsKey("RWXDSJ")) {
jhks = arrayList.get(i).get("JHKS"); RWXDSJ = arrayList.get(i).get("RWXDSJ");
} }
if(arrayList.get(i).containsKey("JHJS")) { if(arrayList.get(i).containsKey("JHJS")) {
jhjs = arrayList.get(i).get("JHJS"); jhjs = arrayList.get(i).get("JHJS");
} }
} }
System.out.println("sjwcsj========"+sjwcsj); //System.out.println("sjwcsj========"+sjwcsj);
System.out.println("jhks========"+jhks); //System.out.println("jhks========"+jhks);
System.out.println("jhjs========"+jhjs); //System.out.println("jhjs========"+jhjs);
if(sjwcsj != null && !sjwcsj.isEmpty()) { if(sjwcsj != null && !sjwcsj.isEmpty()) {
renderer.setBackground(Color.GREEN); renderer.setBackground(Color.GREEN);
}else { }else {
if(jhjs != null && !jhjs.isEmpty() && jhks != null && !jhks.isEmpty()) { if(jhjs != null && !jhjs.isEmpty() && RWXDSJ != null && !RWXDSJ.isEmpty()) {
if(isNotAfterCurrentDate(jhjs)) { if(isNotAfterCurrentDate(jhjs)) {
renderer.setBackground(Color.RED); renderer.setBackground(Color.RED);
System.out.println("row==="+row+"===column==="+column); // System.out.println("row==="+row+"===column==="+column);
}else { }else {
//setBackground(Color.YELLOW); //setBackground(Color.YELLOW);
renderer.setBackground(Color.YELLOW); renderer.setBackground(Color.GRAY);
} }
} }
} }
@ -86,7 +86,7 @@ public class QDRWTableColorRender extends TableColorRender {
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
// 处理解析异常 // 处理解析异常
System.out.println("Invalid date format: " + e.getMessage()); System.out.println("Invalid date format: " + e.getMessage());
return false; // 或者你也可以选择抛出异常,或者根据需求做其他处理 return false; // 或者你也可以选择抛出异常,或者根据需求做其他处理
} }
} }

Loading…
Cancel
Save