From bf8c9d277d57e880fdaa4cb4b6568c18f5ccfcf1 Mon Sep 17 00:00:00 2001 From: lijh Date: Fri, 15 Dec 2023 15:58:16 +0800 Subject: [PATCH] ljh commit --- .../plm/CostListManagement/pojo/GzxqBean.java | 232 ++++++ .../com/connor/plm/GZXQ/ButtonCellEditor.java | 124 ++++ .../connor/plm/GZXQ/ButtonCellRenderer.java | 56 ++ .../src/com/connor/plm/GZXQ/DateChooser.java | 698 ++++++++++++++++++ .../src/com/connor/plm/GZXQ/GZXQHandler.java | 53 ++ .../src/com/connor/plm/GZXQ/NewJFrame.java | 610 +++++++++++++++ 6 files changed, 1773 insertions(+) create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellEditor.java create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellRenderer.java create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/GZXQ/DateChooser.java create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/GZXQ/GZXQHandler.java create mode 100644 com.connor.chint.wuhan/src/com/connor/plm/GZXQ/NewJFrame.java diff --git a/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java new file mode 100644 index 0000000..52da8ee --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/CostListManagement/pojo/GzxqBean.java @@ -0,0 +1,232 @@ +package com.connor.plm.CostListManagement.pojo; + +public class GzxqBean { + private String instanceId; + private String factory; + private String sfId; + private String head; + private String scheduledtime; + private String model; + private String productname; + private String toolnumber; + private String toolname; + private String toolinglevel; + private String reason; + private String jsgyrequirements; + private String link; + private String state; + + + + public GzxqBean() { + super(); + } + + + + public String getInstanceId() { + return instanceId; + } + + + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + + + public String getFactory() { + return factory; + } + + + + public void setFactory(String factory) { + this.factory = factory; + } + + + + public String getSfId() { + return sfId; + } + + + + public void setSfId(String sfId) { + this.sfId = sfId; + } + + + + public String getHead() { + return head; + } + + + + public void setHead(String head) { + this.head = head; + } + + + + public String getScheduledtime() { + return scheduledtime; + } + + + + public void setScheduledtime(String scheduledtime) { + this.scheduledtime = scheduledtime; + } + + + + public String getModel() { + return model; + } + + + + public void setModel(String model) { + this.model = model; + } + + + + public String getProductname() { + return productname; + } + + + + public void setProductname(String productname) { + this.productname = productname; + } + + + + public String getToolnumber() { + return toolnumber; + } + + + + public void setToolnumber(String toolnumber) { + this.toolnumber = toolnumber; + } + + + + public String getToolname() { + return toolname; + } + + + + public void setToolname(String toolname) { + this.toolname = toolname; + } + + + + public String getToolinglevel() { + return toolinglevel; + } + + + + public void setToolinglevel(String toolinglevel) { + this.toolinglevel = toolinglevel; + } + + + + public String getReason() { + return reason; + } + + + + public void setReason(String reason) { + this.reason = reason; + } + + + + public String getJsgyrequirements() { + return jsgyrequirements; + } + + + + public void setJsgyrequirements(String jsgyrequirements) { + this.jsgyrequirements = jsgyrequirements; + } + + + + public String getLink() { + return link; + } + + + + public void setLink(String link) { + this.link = link; + } + + + + public String getState() { + return state; + } + + + + public void setState(String state) { + this.state = state; + } + + + + public GzxqBean(String instanceId, String factory, String sfId, String head, String scheduledtime, String model, + String productname, String toolnumber, String toolname, String toolinglevel, String reason, + String jsgyrequirements, String link, String state) { + super(); + this.instanceId = instanceId; + this.factory = factory; + this.sfId = sfId; + this.head = head; + this.scheduledtime = scheduledtime; + this.model = model; + this.productname = productname; + this.toolnumber = toolnumber; + this.toolname = toolname; + this.toolinglevel = toolinglevel; + this.reason = reason; + this.jsgyrequirements = jsgyrequirements; + this.link = link; + this.state = state; + } + + + + @Override + public String toString() { + return "GzxqBean [instanceId=" + instanceId + ", factory=" + factory + ", sfId=" + sfId + ", head=" + head + + ", scheduledtime=" + scheduledtime + ", model=" + model + ", productname=" + productname + + ", toolnumber=" + toolnumber + ", toolname=" + toolname + ", toolinglevel=" + toolinglevel + + ", reason=" + reason + ", jsgyrequirements=" + jsgyrequirements + ", link=" + link + ", state=" + + state + "]"; + } + + + + + + + +} diff --git a/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellEditor.java b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellEditor.java new file mode 100644 index 0000000..ab96689 --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellEditor.java @@ -0,0 +1,124 @@ +package com.connor.plm.GZXQ; + +import java.awt.Component; +import java.awt.Desktop; +import java.net.URI; +import java.util.List; + +import javax.swing.AbstractCellEditor; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; + +import com.connor.plm.CostListManagement.pojo.Cusquotation; +import com.connor.plm.CostListManagement.pojo.GzxqBean; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; + +public class ButtonCellEditor extends AbstractCellEditor implements TableCellEditor{ + + + private JButton button; + private JTable table; + private List quotations; + private Boolean flag = false; + public static GzxqBean quotation; + public static Cusquotation cusquotation; + public static TCSession session; + + public ButtonCellEditor(JTable jTable2,List quotations,TCSession session, TCComponent f) { + button = new JButton(); + this.table = jTable2; + this.quotations = quotations; + this.session = session; + button.addActionListener(e -> { + // 这里可以添加按钮的点击事件响应逻辑 + int selectedRow = table.getSelectedRow(); + System.out.println("点击了第"+selectedRow+"行"); + String text = button.getText(); + System.out.println("点击按钮名称:"+text); + if("打开".equals(text)) { + String url = quotations.get(selectedRow).getLink(); + try { + browse2(url); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if("设计".equals(text)){ + String formnumber = quotations.get(selectedRow).getInstanceId(); + String sfid = quotations.get(selectedRow).getSfId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent target = app.getTargetComponent(); + if(target instanceof TCComponentFolder) { + TCComponentFolder folder = (TCComponentFolder)target; + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("ZT2_Frock"); + String newID = typeComponent.getNewID(); + TCComponentItem item = typeComponent.create(newID, "A", "ZT2_Frock", "", "", null); + TCComponentItemRevision itemRev = item.getLatestItemRevision(); + if(itemRev != null && formnumber != null && !formnumber.isEmpty()) { + itemRev.setStringProperty("zt2_formnumber", formnumber); + } + if(itemRev != null && sfid != null && !sfid.isEmpty()) { + itemRev.setStringProperty("zt2_sfid", sfid); + } + folder.add("contents", item); + folder.refresh(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + + }else { + try { + TCComponentItemType typeComponent = (TCComponentItemType) session.getTypeComponent("ZT2_Frock"); + String newID = typeComponent.getNewID(); + TCComponentItem item = typeComponent.create(newID, "A", "ZT2_Frock", "", "", null); + TCComponentItemRevision itemRev = item.getLatestItemRevision(); + if(itemRev != null && formnumber != null && !formnumber.isEmpty()) { + itemRev.setStringProperty("zt2_formnumber", formnumber); + + } + if(itemRev != null && sfid != null && !sfid.isEmpty()) { + itemRev.setStringProperty("zt2_sfid", sfid); + } + session.getUser().getNewStuffFolder().add("contents", item); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + + } + } + }); + + } +private void browse2(String url) throws Exception { + Desktop desktop = Desktop.getDesktop(); + if (Desktop.isDesktopSupported() && desktop.isSupported(Desktop.Action.BROWSE)) { + URI uri = new URI(url); + desktop.browse(uri); + } +} + +@Override +public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, + int row, int column) { + button.setText(value != null ? value.toString() : ""); + return button; +} + +@Override +public Object getCellEditorValue() { + return button.getText(); +} + +} diff --git a/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellRenderer.java b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellRenderer.java new file mode 100644 index 0000000..ea129d5 --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/ButtonCellRenderer.java @@ -0,0 +1,56 @@ +package com.connor.plm.GZXQ; + +import java.awt.Component; +import java.awt.Desktop; +import java.awt.Panel; +import java.net.URI; +import java.util.List; + +import javax.swing.AbstractCellEditor; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; + +import com.connor.plm.CostListManagement.pojo.GzxqBean; +import com.connor.plm.CostListManagement.pojo.Quotation; +import com.connor.plm.CreateOuotation.JDBFrame; +import com.connor.plm.CreateOuotation.MainApp; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +import javafx.application.Platform; +import javafx.embed.swing.JFXPanel; +import javafx.event.EventHandler; +import javafx.stage.Stage; +import javafx.stage.WindowEvent; + +class ButtonCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer { + + private JButton button; + private JTable table; + private List quotations; + private TCSession session; + private TCComponent f; + public ButtonCellRenderer(JTable jTable2, List quotations,TCSession session, TCComponent f) { + button = new JButton(); + this.quotations = quotations; + this.table = jTable2; + this.session = session; + this.f = f; + } + public interface CostPageCallback { + void onOpenCostPage(); + } + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + button.setText(value != null ? value.toString() : ""); + return button; + } +} + + diff --git a/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/DateChooser.java b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/DateChooser.java new file mode 100644 index 0000000..92c40a0 --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/DateChooser.java @@ -0,0 +1,698 @@ +package com.connor.plm.GZXQ; + +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.Point; +import java.awt.Polygon; +import java.awt.Stroke; +import java.awt.Toolkit; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Date; +import java.util.Iterator; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.Popup; +import javax.swing.PopupFactory; +import javax.swing.SwingUtilities; +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; + +public class DateChooser extends JPanel { + private static final long serialVersionUID = 4529266044762990227L; + private Date initDate; + private Calendar now; + private Calendar select; + private JPanel monthPanel; + private DateChooser.JP1 jp1; + private DateChooser.JP2 jp2; + private DateChooser.JP3 jp3; + private DateChooser.JP4 jp4; + private Font font; + private final DateChooser.LabelManager lm; + private SimpleDateFormat sdf; + private boolean isShow; + private Popup pop; + private JComponent showDate; + + public static DateChooser getInstance() { + return new DateChooser(); + } + + public static DateChooser getInstance(Date date) { + return new DateChooser(date); + } + + public static DateChooser getInstance(String format) { + return new DateChooser(format); + } + + public static DateChooser getInstance(Date date, String format) { + return new DateChooser(date, format); + } + + private DateChooser() { + this(new Date()); + } + + private DateChooser(Date date) { + this(date, "yyyy年MM月dd日"); + } + + private DateChooser(String format) { + this(new Date(), format); + } + + private DateChooser(Date date, String format) { + this.now = Calendar.getInstance(); + this.font = new Font("宋体", 0, 12); + this.lm = new DateChooser.LabelManager(); + this.isShow = false; + this.initDate = date; + this.sdf = new SimpleDateFormat(format); + this.select = Calendar.getInstance(); + this.select.setTime(this.initDate); + this.initPanel(); + } + + public void setEnabled(boolean b) { + super.setEnabled(b); + this.showDate.setEnabled(b); + } + + public Date getDate() { + return this.select.getTime(); + } + + public String getStrDate() { + return this.sdf.format(this.select.getTime()); + } + + public String getStrDate(String format) { + this.sdf = new SimpleDateFormat(format); + return this.sdf.format(this.select.getTime()); + } + + private void initPanel() { + this.monthPanel = new JPanel(new BorderLayout()); + this.monthPanel.setBorder(BorderFactory.createLineBorder(Color.BLUE)); + JPanel up = new JPanel(new BorderLayout()); + up.add(this.jp1 = new DateChooser.JP1(), "North"); + up.add(this.jp2 = new DateChooser.JP2(), "Center"); + this.monthPanel.add(this.jp3 = new DateChooser.JP3(), "Center"); + this.monthPanel.add(up, "North"); + this.monthPanel.add(this.jp4 = new DateChooser.JP4(), "South"); + this.addAncestorListener(new AncestorListener() { + public void ancestorAdded(AncestorEvent event) { + } + + public void ancestorRemoved(AncestorEvent event) { + } + + public void ancestorMoved(AncestorEvent event) { + DateChooser.this.hidePanel(); + } + }); + } + + public void register(final JComponent showDate) { + this.showDate = showDate; + showDate.setRequestFocusEnabled(true); + showDate.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent me) { + showDate.requestFocusInWindow(); + } + }); + this.setBackground(Color.WHITE); + this.add(showDate, "Center"); + this.setPreferredSize(new Dimension(90, 25)); + this.setBorder(BorderFactory.createLineBorder(Color.GRAY)); + showDate.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setCursor(new Cursor(12)); + showDate.setForeground(Color.RED); + } + + } + + public void mouseExited(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setCursor(new Cursor(0)); + showDate.setForeground(Color.BLACK); + } + + } + + public void mousePressed(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setForeground(Color.CYAN); + if (DateChooser.this.isShow) { + DateChooser.this.hidePanel(); + } else { + DateChooser.this.showPanel(showDate); + } + } + + } + + public void mouseReleased(MouseEvent me) { + if (showDate.isEnabled()) { + showDate.setForeground(Color.BLACK); + } + + } + }); + showDate.addFocusListener(new FocusListener() { + public void focusLost(FocusEvent e) { + DateChooser.this.hidePanel(); + } + + public void focusGained(FocusEvent e) { + } + }); + } + + private void refresh() { + this.jp1.updateDate(); + this.jp2.updateDate(); + this.jp3.updateDate(); + this.jp4.updateDate(); + SwingUtilities.updateComponentTreeUI(this); + } + + private void commit() { + if (this.showDate instanceof JTextField) { + ((JTextField) this.showDate).setText(this.sdf.format(this.select.getTime())); + } else if (this.showDate instanceof JLabel) { + ((JLabel) this.showDate).setText(this.sdf.format(this.select.getTime())); + } + + this.hidePanel(); + } + + private void hidePanel() { + if (this.pop != null) { + this.isShow = false; + this.pop.hide(); + this.pop = null; + } + + } + + private void showPanel(Component owner) { + if (this.pop != null) { + this.pop.hide(); + } + + Point show = new Point(0, this.showDate.getHeight()); + SwingUtilities.convertPointToScreen(show, this.showDate); + Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + int x = show.x; + int y = show.y; + if (x < 0) { + x = 0; + } + + if (x > size.width - 295) { + x = size.width - 295; + } + + if (y >= size.height - 170) { + y -= 188; + } + + this.pop = PopupFactory.getSharedInstance().getPopup(owner, this.monthPanel, x, y); + this.pop.show(); + this.isShow = true; + } + + public static void main(String[] args) { + DateChooser dateChooser1 = getInstance("yyyy-MM-dd HH:mm"); + DateChooser dateChooser2 = getInstance("yyyy-MM-dd"); + JTextField showDate1 = new JTextField("单击选择日期"); + JLabel showDate2 = new JLabel("单击选择日期"); + dateChooser1.register(showDate1); + dateChooser2.register(showDate2); + JFrame jf = new JFrame("测试日期选择器"); + jf.add(showDate1, "North"); + jf.add(showDate2, "South"); + jf.pack(); + jf.setLocationRelativeTo((Component) null); + jf.setVisible(true); + jf.setDefaultCloseOperation(3); + } + + private class JP1 extends JPanel { + private static final long serialVersionUID = -5638853772805561174L; + JLabel yearleft; + JLabel yearright; + JLabel monthleft; + JLabel monthright; + JLabel center; + JLabel centercontainer; + + public JP1() { + super(new BorderLayout()); + this.setBackground(new Color(160, 185, 215)); + this.initJP1(); + } + + private void initJP1() { + this.yearleft = new JLabel(" <<", 0); + this.yearleft.setToolTipText("上一年"); + this.yearright = new JLabel(">> ", 0); + this.yearright.setToolTipText("下一年"); + this.yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + this.yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); + this.monthleft = new JLabel(" <", 4); + this.monthleft.setToolTipText("上一月"); + this.monthright = new JLabel("> ", 2); + this.monthright.setToolTipText("下一月"); + this.monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); + this.monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); + this.centercontainer = new JLabel("", 0); + this.centercontainer.setLayout(new BorderLayout()); + this.center = new JLabel("", 0); + this.centercontainer.add(this.monthleft, "West"); + this.centercontainer.add(this.center, "Center"); + this.centercontainer.add(this.monthright, "East"); + this.add(this.yearleft, "West"); + this.add(this.centercontainer, "Center"); + this.add(this.yearright, "East"); + this.setPreferredSize(new Dimension(295, 25)); + this.updateDate(); + this.yearleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.yearleft.setCursor(new Cursor(12)); + JP1.this.yearleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.yearleft.setCursor(new Cursor(0)); + JP1.this.yearleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(1, -1); + JP1.this.yearleft.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.yearleft.setForeground(Color.BLACK); + } + }); + this.yearright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.yearright.setCursor(new Cursor(12)); + JP1.this.yearright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.yearright.setCursor(new Cursor(0)); + JP1.this.yearright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(1, 1); + JP1.this.yearright.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.yearright.setForeground(Color.BLACK); + } + }); + this.monthleft.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.monthleft.setCursor(new Cursor(12)); + JP1.this.monthleft.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.monthleft.setCursor(new Cursor(0)); + JP1.this.monthleft.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(2, -1); + JP1.this.monthleft.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.monthleft.setForeground(Color.BLACK); + } + }); + this.monthright.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + JP1.this.monthright.setCursor(new Cursor(12)); + JP1.this.monthright.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + JP1.this.monthright.setCursor(new Cursor(0)); + JP1.this.monthright.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + DateChooser.this.select.add(2, 1); + JP1.this.monthright.setForeground(Color.WHITE); + DateChooser.this.refresh(); + } + + public void mouseReleased(MouseEvent me) { + JP1.this.monthright.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + this.center.setText(DateChooser.this.select.get(1) + "年" + (DateChooser.this.select.get(2) + 1) + "月"); + } + } + + private class JP2 extends JPanel { + private static final long serialVersionUID = -8176264838786175724L; + + public JP2() { + this.setPreferredSize(new Dimension(295, 20)); + } + + protected void paintComponent(Graphics g) { + g.setFont(DateChooser.this.font); + g.drawString("星期日 星期一 星期二 星期三 星期四 星期五 星期六", 5, 10); + g.drawLine(0, 15, this.getWidth(), 15); + } + + private void updateDate() { + } + } + + private class JP3 extends JPanel { + private static final long serialVersionUID = 43157272447522985L; + + public JP3() { + super(new GridLayout(6, 7)); + this.setPreferredSize(new Dimension(295, 100)); + this.initJP3(); + } + + private void initJP3() { + this.updateDate(); + } + + public void updateDate() { + this.removeAll(); + DateChooser.this.lm.clear(); + Date temp = DateChooser.this.select.getTime(); + Calendar select = Calendar.getInstance(); + select.setTime(temp); + select.set(5, 1); + int index = select.get(7); + int sum = index == 1 ? 8 : index; + select.add(5, 0 - sum); + + for (int i = 0; i < 42; ++i) { + select.add(5, 1); + DateChooser.this.lm.addLabel(DateChooser.this.new MyLabel(select.get(1), select.get(2), select.get(5))); + } + + Iterator var6 = DateChooser.this.lm.getLabels().iterator(); + + while (var6.hasNext()) { + DateChooser.MyLabel my = (DateChooser.MyLabel) var6.next(); + this.add(my); + } + + select.setTime(temp); + } + } + + private class JP4 extends JPanel { + private static final long serialVersionUID = -6391305687575714469L; + + public JP4() { + super(new BorderLayout()); + this.setPreferredSize(new Dimension(295, 20)); + this.setBackground(new Color(160, 185, 215)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); + final JLabel jl = new JLabel("今天: " + sdf.format(new Date())); + jl.setToolTipText("点击选择今天日期"); + this.add(jl, "Center"); + jl.addMouseListener(new MouseAdapter() { + public void mouseEntered(MouseEvent me) { + jl.setCursor(new Cursor(12)); + jl.setForeground(Color.RED); + } + + public void mouseExited(MouseEvent me) { + jl.setCursor(new Cursor(0)); + jl.setForeground(Color.BLACK); + } + + public void mousePressed(MouseEvent me) { + jl.setForeground(Color.WHITE); + DateChooser.this.select.setTime(new Date()); + DateChooser.this.refresh(); + DateChooser.this.commit(); + } + + public void mouseReleased(MouseEvent me) { + jl.setForeground(Color.BLACK); + } + }); + } + + private void updateDate() { + } + } + + private class LabelManager { + private List list = new ArrayList(); + + public LabelManager() { + } + + public List getLabels() { + return this.list; + } + + public void addLabel(DateChooser.MyLabel my) { + this.list.add(my); + } + + public void clear() { + this.list.clear(); + } + + public void setSelect(DateChooser.MyLabel my, boolean b) { + Iterator var4 = this.list.iterator(); + + while (var4.hasNext()) { + DateChooser.MyLabel m = (DateChooser.MyLabel) var4.next(); + if (m.equals(my)) { + m.setSelected(true, b); + } else { + m.setSelected(false, b); + } + } + + } + + public void setSelect(Point p, boolean b) { + if (b) { + boolean findPrevious = false; + boolean findNext = false; + Iterator var6 = this.list.iterator(); + + while (var6.hasNext()) { + DateChooser.MyLabel mx = (DateChooser.MyLabel) var6.next(); + if (mx.contains(p)) { + findNext = true; + if (mx.getIsSelected()) { + findPrevious = true; + } else { + mx.setSelected(true, b); + } + } else if (mx.getIsSelected()) { + findPrevious = true; + mx.setSelected(false, b); + } + + if (findPrevious && findNext) { + return; + } + } + } else { + DateChooser.MyLabel temp = null; + Iterator var9 = this.list.iterator(); + + while (var9.hasNext()) { + DateChooser.MyLabel m = (DateChooser.MyLabel) var9.next(); + if (m.contains(p)) { + temp = m; + } else if (m.getIsSelected()) { + m.setSelected(false, b); + } + } + + if (temp != null) { + temp.setSelected(true, b); + } + } + + } + } + + private class MyLabel extends JLabel + implements Comparator, MouseListener, MouseMotionListener { + private static final long serialVersionUID = 3668734399227577214L; + private int year; + private int month; + private int day; + private boolean isSelected; + + public MyLabel(int year, int month, int day) { + super("" + day, 0); + this.year = year; + this.day = day; + this.month = month; + this.addMouseListener(this); + this.addMouseMotionListener(this); + this.setFont(DateChooser.this.font); + if (month == DateChooser.this.select.get(2)) { + this.setForeground(Color.BLACK); + } else { + this.setForeground(Color.LIGHT_GRAY); + } + + if (day == DateChooser.this.select.get(5)) { + this.setBackground(new Color(160, 185, 215)); + } else { + this.setBackground(Color.WHITE); + } + + } + + public boolean getIsSelected() { + return this.isSelected; + } + + public void setSelected(boolean b, boolean isDrag) { + this.isSelected = b; + if (b && !isDrag) { + int temp = DateChooser.this.select.get(2); + DateChooser.this.select.set(this.year, this.month, this.day); + if (temp == this.month) { + SwingUtilities.updateComponentTreeUI(DateChooser.this.jp3); + } else { + DateChooser.this.refresh(); + } + } + + this.repaint(); + } + + protected void paintComponent(Graphics g) { + if (this.day == DateChooser.this.select.get(5) && this.month == DateChooser.this.select.get(2)) { + g.setColor(new Color(160, 185, 215)); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + + if (this.year == DateChooser.this.now.get(1) && this.month == DateChooser.this.now.get(2) + && this.day == DateChooser.this.now.get(5)) { + Graphics2D gdx = (Graphics2D) g; + gdx.setColor(Color.RED); + Polygon p = new Polygon(); + p.addPoint(0, 0); + p.addPoint(this.getWidth() - 1, 0); + p.addPoint(this.getWidth() - 1, this.getHeight() - 1); + p.addPoint(0, this.getHeight() - 1); + gdx.drawPolygon(p); + } + + if (this.isSelected) { + Stroke s = new BasicStroke(1.0F, 2, 2, 1.0F, new float[] { 2.0F, 2.0F }, 1.0F); + Graphics2D gd = (Graphics2D) g; + gd.setStroke(s); + gd.setColor(Color.BLACK); + Polygon px = new Polygon(); + px.addPoint(0, 0); + px.addPoint(this.getWidth() - 1, 0); + px.addPoint(this.getWidth() - 1, this.getHeight() - 1); + px.addPoint(0, this.getHeight() - 1); + gd.drawPolygon(px); + } + + super.paintComponent(g); + } + + public boolean contains(Point p) { + return this.getBounds().contains(p); + } + + private void update() { + this.repaint(); + } + + public void mouseClicked(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + this.isSelected = true; + this.update(); + } + + public void mouseReleased(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); + DateChooser.this.lm.setSelect(p, false); + DateChooser.this.commit(); + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + } + + public void mouseDragged(MouseEvent e) { + Point p = SwingUtilities.convertPoint(this, e.getPoint(), DateChooser.this.jp3); + DateChooser.this.lm.setSelect(p, true); + } + + public void mouseMoved(MouseEvent e) { + } + + public int compare(DateChooser.MyLabel o1, DateChooser.MyLabel o2) { + Calendar c1 = Calendar.getInstance(); + c1.set(o1.year, o2.month, o1.day); + Calendar c2 = Calendar.getInstance(); + c2.set(o2.year, o2.month, o2.day); + return c1.compareTo(c2); + } + } +} diff --git a/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/GZXQHandler.java b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/GZXQHandler.java new file mode 100644 index 0000000..7154f1d --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/GZXQHandler.java @@ -0,0 +1,53 @@ +package com.connor.plm.GZXQ; + +import java.awt.Dimension; +import java.awt.Toolkit; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +/** + * 成本单管理 + * @author admin + * 2023/11/16 + */ +public class GZXQHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + try { + new Thread() { + @Override + public void run() { + NewJFrame newJFrame = new NewJFrame(session); + int width2 = newJFrame.getWidth(); + int height2 = newJFrame.getHeight(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 + int screenWidth = screenSize.width; // 获取屏幕宽度 + int screenHeight = screenSize.height; // 获取屏幕高度 + int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 + int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 + newJFrame.setTitle("工装需求查询"); + // this.getContentPane().setBackground(Color.red); + newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); + newJFrame.setSize(950, height2); // 设置Frame的大小 + newJFrame.setLocation(x, y); // 设置Frame的位置 + newJFrame.setResizable(false); + newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 + newJFrame.setVisible(true); + } + }.start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/NewJFrame.java b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/NewJFrame.java new file mode 100644 index 0000000..525495c --- /dev/null +++ b/com.connor.chint.wuhan/src/com/connor/plm/GZXQ/NewJFrame.java @@ -0,0 +1,610 @@ +package com.connor.plm.GZXQ; +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; + +import com.connor.chint.sap2.util.SqlUtil; +import com.connor.plm.CostListManagement.pojo.GzxqBean; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +/** + * + * @author admin + */ +public class NewJFrame extends javax.swing.JFrame { + + + private TCSession session; + private Connection conn; + private TCComponent f; + /** + * Creates new form NewJFrame + * @param session + */ + public NewJFrame(TCSession session) { + String[] prefs = session.getPreferenceService().getStringValues("database_tc"); + System.out.println("===============开始连接tc数据库==============="); + long time31 = System.nanoTime(); + conn = SqlUtil.getTCDataConnection(prefs); + long time32 = System.nanoTime(); + System.out.println("===============连接tc数据库用时(ms): " + ((time32 - time31) / 1000000L)+"==============="); + this.session = session; + initComponents(); + + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // + private void initComponents() { + + jScrollPane2 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jPanel1 = new javax.swing.JPanel(); + jLabel2 = new javax.swing.JLabel(); + jTextField1 = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + jTextField2 = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + jTextField3 = new javax.swing.JTextField(); + jLabel5 = new javax.swing.JLabel(); + jTextField4 = new javax.swing.JTextField(); + jLabel6 = new javax.swing.JLabel(); + jTextField5 = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + jTextField6 = new javax.swing.JTextField(); + jLabel8 = new javax.swing.JLabel(); + jTextField7 = new javax.swing.JTextField(); + jLabel9 = new javax.swing.JLabel(); + jTextField8 = new javax.swing.JTextField(); + jLabel10 = new javax.swing.JLabel(); + jTextField9 = new javax.swing.JTextField(); + jLabel11 = new javax.swing.JLabel(); + jTextField10 = new javax.swing.JTextField(); + jLabel12 = new javax.swing.JLabel(); + jTextField11 = new javax.swing.JTextField(); + jLabel13 = new javax.swing.JLabel(); + jTextField12 = new javax.swing.JTextField(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jLabel14 = new javax.swing.JLabel(); + jTextField13 = new javax.swing.JTextField(); + jLabel15 = new javax.swing.JLabel(); + jTextField14 = new javax.swing.JTextField(); + jTextField14.setVisible(false); + jLabel1 = new javax.swing.JLabel(); + jPanel2 = new javax.swing.JPanel(); + jScrollPane3 = new javax.swing.JScrollPane(); + jTable2 = new javax.swing.JTable(); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + + jScrollPane2.setViewportView(jTable1); + + setBackground(new java.awt.Color(255, 255, 255)); + // this.setBackground(new java.awt.Color(255, 255, 255)); + jPanel1.setBackground(new java.awt.Color(255, 255, 255)); + jPanel1.setPreferredSize(new Dimension(900, 400)); + jPanel1.setBorder(new TitledBorder(new EtchedBorder())); + jLabel2.setText("流程实例ID"); + + jTextField1.setText(""); + + jLabel3.setText("工艺负责人"); + + jTextField2.setText(""); + + jLabel4.setText("产品型号"); + + jTextField3.setText(""); + + jLabel5.setText("工装编号"); + + jTextField4.setText(""); + + jLabel6.setText("工装等级"); + + jTextField5.setText(""); + + jLabel7.setText("申请人"); + + jTextField6.setText(""); + + jLabel8.setText("申请人"); + + jTextField7.setText(""); + DateChooser dateChooser = DateChooser.getInstance("yyyy-M-d"); + dateChooser.register(jTextField7); + jLabel9.setText("计划时间"); + + jTextField8.setText(""); + + jLabel10.setText("产品名称"); + + jTextField9.setText(""); + + jLabel11.setText("工装名称"); + + jTextField10.setText(""); + + jLabel12.setText("委托理由"); + + jTextField11.setText(""); + + jLabel13.setText("接收时间"); + + jTextField12.setText(""); + + jButton1.setText("jButton1"); + + jButton2.setText("查询"); + jButton2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + + +// if (conn == null) { +// System.out.println("连接TC数据库失败"); +// // MessageBox.post(MaterialNoDialog.this, "连接TC数据库失败", "", MessageBox.ERROR); +// return; +// } + String sql = "select * from \"CHINT_ FROCK\" where 1=1 "; + if(jTextField1.getText()!=null && !"".equals(jTextField1.getText().trim())) { + sql += "and instanceId = \'" + jTextField1.getText() +"\'"; + } + if(jTextField2.getText()!=null && !"".equals(jTextField2.getText().trim())) { + sql += "and \"HEAD\" = \'" + jTextField2.getText() +"\'"; + } + if(jTextField3.getText()!=null && !"".equals(jTextField3.getText().trim())) { + sql += "and \"MODEL\" = \'" + jTextField3.getText() +"\'"; + } + if(jTextField4.getText()!=null && !"".equals(jTextField4.getText().trim())) { + sql += "and \"TOOLNUMBER\" = \'" + jTextField4.getText() +"\'"; + } + if(jTextField5.getText()!=null && !"".equals(jTextField5.getText().trim())) { + sql += "and \"TOOLNAME\" = \'" + jTextField5.getText() +"\'"; + } + if(jTextField8.getText()!=null && !"".equals(jTextField8.getText().trim())) { + sql += "and sfId = \'" + jTextField8.getText() +"\'"; + } + if(jTextField7.getText()!=null && !"".equals(jTextField7.getText().trim())) { + sql += "and \"SCHEDULEDTIME\" = \'" + jTextField7.getText() +"\'"; + } + if(jTextField9.getText()!=null && !"".equals(jTextField9.getText().trim())) { + sql += "and \"PRODUCTNAME\" = \'" + jTextField9.getText() +"\'"; + } + if(jTextField10.getText()!=null && !"".equals(jTextField10.getText().trim())) { + sql += "and \"TOOLNAME\" = \'" + jTextField10.getText() +"\'"; + } + if(jTextField11.getText()!=null && !"".equals(jTextField11.getText().trim())) { + sql += "and \"REASON\" = \'" + jTextField11.getText() +"\'"; + } + System.out.println("sql:"+sql); + PreparedStatement statement; + try { + statement = conn.prepareStatement(sql); + ResultSet res = statement.executeQuery(); + List quotations = new ArrayList(); + while (res.next()) { + + GzxqBean gzxqBean = new GzxqBean( + res.getString("instanceId") != null ? res.getString("instanceId") : "", + res.getString("factory") != null ? res.getString("factory") : "", + res.getString("sfId") != null ? res.getString("sfId") : "", + res.getString("head") != null ? res.getString("head") : "", + res.getString("scheduledtime") != null ? res.getString("scheduledtime") : "", + res.getString("model") != null ? res.getString("model") : "", + res.getString("productname") != null ? res.getString("productname") : "", + res.getString("toolnumber") != null ? res.getString("toolnumber") : "", + res.getString("toolname") != null ? res.getString("toolname") : "", + res.getString("toolinglevel") != null ? res.getString("toolinglevel") : "", + res.getString("reason") != null ? res.getString("reason") : "", + res.getString("jsgyrequirements") != null ? res.getString("jsgyrequirements") : "", + res.getString("link") != null ? res.getString("link") : "", + res.getString("state") != null ? res.getString("state") : "" + ); + quotations.add(gzxqBean); + } + //将数据插入到表格 + String[] title = new String [] { "序号","申请人","流程实例ID","工艺负责人","计划时间", "委托理由", "技术工艺要求", "OA表单链接","创建工装需求","状态"}; +// DefaultTableModel model = new DefaultTableModel(new Object [][] {},title); + DefaultTableModel model = new DefaultTableModel(new Object [][] {},title) { + + // 重写isCellEditable方法,禁止第一列 第二列 第五列单元格编辑 + @Override + public boolean isCellEditable(int row, int column) { + // 将第一列、第二列和第五列设置为不可编辑 + return !(column == 0 || column == 1 || column == 2 || column == 3 || column == 4 || column == 5 || column == 6 || column == 9); + } + }; + +// Object[][] str = {{"数据1列1", "数据1列2", "打卡", "创建", "数据1列5"},{"数据1列1", "数据1列2", "打卡", "创建", "数据1列5"}}; +// DefaultTableModel model = new DefaultTableModel(str,title) { +// // 重写isCellEditable方法,禁止第一列 第二列 第五列单元格编辑 +// @Override +// public boolean isCellEditable(int row, int column) { +// // 将第一列、第二列和第五列设置为不可编辑 +// return !(column == 0 || column == 1 || column == 4); +// } +// }; + jTable2.setModel(model); + if(quotations.size() > 0) { + for(int i = 0;i + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ +// try { +// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { +// if ("Nimbus".equals(info.getName())) { +// javax.swing.UIManager.setLookAndFeel(info.getClassName()); +// break; +// } +// } +// } catch (ClassNotFoundException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (InstantiationException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (IllegalAccessException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } catch (javax.swing.UnsupportedLookAndFeelException ex) { +// java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); +// } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + NewJFrame newJFrame = new NewJFrame(null); + int width2 = newJFrame.getWidth(); + int height2 = newJFrame.getHeight(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // 获取屏幕尺寸 + int screenWidth = screenSize.width; // 获取屏幕宽度 + int screenHeight = screenSize.height; // 获取屏幕高度 + int x = (screenWidth - width2) / 2; // 计算Frame的左上角x坐标 + int y = (screenHeight - height2) / 2; // 计算Frame的左上角y坐标 + newJFrame.setTitle("工装需求查询"); + // this.getContentPane().setBackground(Color.red); + newJFrame.getContentPane().setBackground(new java.awt.Color(255, 255, 255)); + newJFrame.setSize(width2, height2); // 设置Frame的大小 + newJFrame.setLocation(x, y); // 设置Frame的位置 + newJFrame.setResizable(false); + newJFrame.setDefaultCloseOperation(2); // 设置窗口关闭时的默认操作 + newJFrame.setVisible(true); + } + }); + } + + // Variables declaration - do not modify + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JTable jTable1; + private javax.swing.JTable jTable2; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField10; + private javax.swing.JTextField jTextField11; + private javax.swing.JTextField jTextField12; + private javax.swing.JTextField jTextField13; + private javax.swing.JTextField jTextField14; + private javax.swing.JTextField jTextField2; + private javax.swing.JTextField jTextField3; + private javax.swing.JTextField jTextField4; + private javax.swing.JTextField jTextField5; + private javax.swing.JTextField jTextField6; + private javax.swing.JTextField jTextField7; + private javax.swing.JTextField jTextField8; + private javax.swing.JTextField jTextField9; + // End of variables declaration +}