|
|
@@ -524,6 +524,30 @@ public class MesClient extends JFrame {
|
|
|
// shiftUserCheck();
|
|
|
}
|
|
|
|
|
|
+ /** 两枪均达到预定数量后启用提交并自动上传 OK 结果 */
|
|
|
+ public static void tryAutoSubmitWhenBothGunsDone() {
|
|
|
+ if (cura < maxa || curb < maxb) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ finish_ok_bt.setEnabled(true);
|
|
|
+ finish_ng_bt.setEnabled(true);
|
|
|
+ if (work_status != 1 || !check_quality_result) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String sn = product_sn.getText();
|
|
|
+ getUser();
|
|
|
+ JSONObject retObj = DataUtil.pcResult(sn, user20, "", "OK");
|
|
|
+ if (retObj == null || retObj.get("result") == null
|
|
|
+ || !retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ setMenuStatus("结果上传MES失败,请重试", -1);
|
|
|
+ } else {
|
|
|
+ resetScanA();
|
|
|
+ setMenuStatus("结果提交成功,请扫下一件", 0);
|
|
|
+ scan_type = 1;
|
|
|
+ scanBarcode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static int userLoginHours;//用户登录所处小时
|
|
|
//换班用户信息检查
|
|
|
private static void shiftUserCheck() {
|
|
|
@@ -718,16 +742,7 @@ public class MesClient extends JFrame {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
super.mouseClicked(e);
|
|
|
-
|
|
|
- String pass = "503833";
|
|
|
- //弹窗扫工件码
|
|
|
- String scanBarcode = JOptionPane.showInputDialog(null, "请输入密码");
|
|
|
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")&&scanBarcode.equals(pass)) {
|
|
|
-
|
|
|
- resetScanA();
|
|
|
- }else{
|
|
|
- MesClient.setMenuStatus("密码错误",-1);
|
|
|
- }
|
|
|
+ resetScanA();
|
|
|
}
|
|
|
});
|
|
|
settingMenu.add(resetTcpMenu_1);
|
|
|
@@ -1136,140 +1151,11 @@ public class MesClient extends JFrame {
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
tabbedPane.setEnabledAt(0, true);
|
|
|
|
|
|
-// indexPanelC = new JPanel();
|
|
|
-// searchScrollPaneDj = new JScrollPane(indexPanelC);
|
|
|
-// indexPanelC.setLayout(null);
|
|
|
-
|
|
|
-// tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
-
|
|
|
-
|
|
|
indexPanelC = new JPanel();
|
|
|
searchScrollPaneDj = new JScrollPane(indexPanelC);
|
|
|
-// indexPanelC.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
indexPanelC.setLayout(null);
|
|
|
|
|
|
- JPanel panel2 = new JPanel();
|
|
|
- panel2.setBounds(0, 0, 990, 50);
|
|
|
-// panel2.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
- panel2.setLayout(null);
|
|
|
- //记录查询搜索框
|
|
|
- textField = new JTextField();
|
|
|
- textField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
-// textField.setEnabled(false);
|
|
|
- textField.setForeground(Color.BLACK);
|
|
|
- textField.setBounds(10, 5, 371, 40);
|
|
|
- panel2.add(textField);
|
|
|
-// textField.setColumns(20);
|
|
|
- indexPanelC.add(panel2);
|
|
|
-
|
|
|
- JButton btnNewButton = new JButton("搜索");
|
|
|
- btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- btnNewButton.setBounds(385, 5, 90, 40);
|
|
|
- panel2.add(btnNewButton);
|
|
|
- // 上一页按钮添加按钮事件监听
|
|
|
- btnNewButton.addActionListener(e -> {
|
|
|
- JdbcUtils.getTestData();
|
|
|
- });
|
|
|
- JButton resetBtn = new JButton("重置");
|
|
|
- resetBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- resetBtn.setBounds(475, 5, 90, 40);
|
|
|
- panel2.add(resetBtn);
|
|
|
- // 上一页按钮添加按钮事件监听
|
|
|
- resetBtn.addActionListener(e -> {
|
|
|
- textField.setText("");
|
|
|
- JdbcUtils.getTestData();
|
|
|
- });
|
|
|
-
|
|
|
-// JButton resetBtn2 = new JButton("导出");
|
|
|
-// resetBtn2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
-// resetBtn2.setBounds(565, 5, 90, 40);
|
|
|
-// panel2.add(resetBtn2);
|
|
|
-// // 上一页按钮添加按钮事件监听
|
|
|
-// resetBtn2.addActionListener(e -> {
|
|
|
-// List<QmData> lists = JdbcUtils.getTestDataAll();
|
|
|
-// Boolean ret = ExportUtil.export(lists);
|
|
|
-// if(ret){
|
|
|
-// MesClient.setMenuStatus("导出成功,请在D盘中查看",0);
|
|
|
-// }else{
|
|
|
-// MesClient.setMenuStatus("导出失败,请重试",-1);
|
|
|
-// }
|
|
|
-// });
|
|
|
-
|
|
|
- JButton btnPrevious = new JButton("上一页");
|
|
|
- btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
- btnPrevious.setBounds(680, 5, 100, 40);
|
|
|
- panel2.add(btnPrevious);
|
|
|
-
|
|
|
- // 页码显示
|
|
|
- pageLabel = new JLabel("0/0"); // 初始页码和总页数
|
|
|
- pageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
- pageLabel.setHorizontalAlignment(SwingConstants.CENTER); // 设置文本居中对齐
|
|
|
- pageLabel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); // 添加灰色边框
|
|
|
- pageLabel.setBounds(780, 5, 100, 40); // 设置位置和大小
|
|
|
- panel2.add(pageLabel);
|
|
|
-
|
|
|
- // “下一页”按钮
|
|
|
- JButton btnNext = new JButton("下一页");
|
|
|
- btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
- btnNext.setBounds(880, 5, 100, 40);
|
|
|
- panel2.add(btnNext);
|
|
|
-
|
|
|
- // 分页逻辑变量
|
|
|
-
|
|
|
- // 上一页按钮添加按钮事件监听
|
|
|
- btnPrevious.addActionListener(e -> {
|
|
|
- if (pageNo > 1) {
|
|
|
- pageNo--;
|
|
|
- JdbcUtils.getTestData();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- btnNext.addActionListener(e -> {
|
|
|
- if (pageNo < totalPages) {
|
|
|
- pageNo++;
|
|
|
- JdbcUtils.getTestData();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- JPanel panel = new JPanel();
|
|
|
- panel.setBounds(0, 49, 990, 518);
|
|
|
- panel.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
- indexPanelC.add(panel);
|
|
|
-
|
|
|
- System.err.println(JSONObject.toJSONString(rowData2));
|
|
|
- System.err.println(columnNames2.length);
|
|
|
-
|
|
|
- // 使用非匿名子类,避免 ClassNotFoundException
|
|
|
- table2 = new CustomTable(rowData2, columnNames2);
|
|
|
-
|
|
|
- // 使用内部类处理鼠标事件
|
|
|
- table2.addMouseListener(new TableMouseListener());
|
|
|
-
|
|
|
- // 设置table的宽度为100%
|
|
|
- table2.setRowHeight(40);
|
|
|
- table2.setEnabled(true);
|
|
|
- table2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
-
|
|
|
-// table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRendererButton());
|
|
|
-// table.getColumnModel().getColumn(3).setCellEditor(new TableCellEditorButton());
|
|
|
-
|
|
|
- // 设置第二列的长度为100像素
|
|
|
- TableColumn column = table2.getColumnModel().getColumn(0);
|
|
|
- column.setPreferredWidth(290);
|
|
|
-
|
|
|
- column = table2.getColumnModel().getColumn(1);
|
|
|
- column.setPreferredWidth(160);
|
|
|
-
|
|
|
- CenterRenderer centerRenderer = new CenterRenderer();
|
|
|
- for (int i = 0; i < table2.getColumnCount(); i++) {
|
|
|
- table2.getColumn(table2.getColumnName(i)).setCellRenderer(centerRenderer);
|
|
|
- }
|
|
|
-
|
|
|
- JScrollPane scrollPane = new JScrollPane(table2);
|
|
|
- panel.add(scrollPane);
|
|
|
-
|
|
|
-// tabbedPane.addTab("记录查询", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
-
|
|
|
+ tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
|
|
|
|
|
|
indexPanelB = new JPanel();
|
|
|
@@ -1290,9 +1176,9 @@ public class MesClient extends JFrame {
|
|
|
tabbedPane.addChangeListener(e -> {
|
|
|
JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
|
|
|
int selectedIndex = sourceTabbedPane.getSelectedIndex();
|
|
|
-
|
|
|
- // 索引 2 是设备管理页面
|
|
|
- if (selectedIndex == 2) {
|
|
|
+ String title = sourceTabbedPane.getTitleAt(selectedIndex);
|
|
|
+
|
|
|
+ if ("设备管理".equals(title)) {
|
|
|
// 弹出密码验证(使用 JPasswordField 以掩码显示)
|
|
|
JPasswordField passwordField = new JPasswordField();
|
|
|
int action = JOptionPane.showConfirmDialog(mesClientFrame, passwordField, "请输入管理员密码", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
|
|
|
@@ -1300,7 +1186,7 @@ public class MesClient extends JFrame {
|
|
|
if (action == JOptionPane.OK_OPTION) {
|
|
|
String password = new String(passwordField.getPassword());
|
|
|
if ("503833".equals(password)) {
|
|
|
- JdbcUtils.getTestData();
|
|
|
+ // 设备管理页
|
|
|
} else {
|
|
|
JOptionPane.showMessageDialog(mesClientFrame, "密码错误,无权进入!", "错误", JOptionPane.ERROR_MESSAGE);
|
|
|
sourceTabbedPane.setSelectedIndex(0);
|