|
@@ -105,6 +105,18 @@ public class MesClient extends JFrame {
|
|
|
public static int recordTotalPages_2 = 0;
|
|
public static int recordTotalPages_2 = 0;
|
|
|
public static JTextField recordSearchField_2;
|
|
public static JTextField recordSearchField_2;
|
|
|
|
|
|
|
|
|
|
+ public static JTable recordTableOkng;
|
|
|
|
|
+ public static Object[] recordColumnNamesOkng = {"工位", "样件", "工件码", "测试日期", "压力", "泄漏值", "结果"};
|
|
|
|
|
+ public static Object[][] recordRowDataOkng = new Object[12][7];
|
|
|
|
|
+ public static JLabel recordPageLabelOkng;
|
|
|
|
|
+ public static int recordPageNoOkng = 1;
|
|
|
|
|
+ public static int recordTotalPagesOkng = 0;
|
|
|
|
|
+ public static JTextField recordSearchFieldOkng;
|
|
|
|
|
+ public static JPanel panelOkng;
|
|
|
|
|
+ public static JScrollPane scrollPaneOkng;
|
|
|
|
|
+ private static final List<String> okngSampleSns = new ArrayList<>();
|
|
|
|
|
+ private static final Map<String, String> okngSampleType = new HashMap<>();
|
|
|
|
|
+
|
|
|
String currentSerialPort1 = Config.portName1;
|
|
String currentSerialPort1 = Config.portName1;
|
|
|
String currentSerialPort2 = Config.portName2;
|
|
String currentSerialPort2 = Config.portName2;
|
|
|
|
|
|
|
@@ -544,6 +556,7 @@ public class MesClient extends JFrame {
|
|
|
toolBar.add(space_4);
|
|
toolBar.add(space_4);
|
|
|
|
|
|
|
|
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
|
|
+ tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
|
|
tabbedPane.setMinimumSize(new Dimension(400, 50));
|
|
tabbedPane.setMinimumSize(new Dimension(400, 50));
|
|
|
tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
|
|
tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
|
|
|
contentPane.add(tabbedPane);
|
|
contentPane.add(tabbedPane);
|
|
@@ -844,6 +857,11 @@ public class MesClient extends JFrame {
|
|
|
panel5.setLayout(null);
|
|
panel5.setLayout(null);
|
|
|
tabbedPane.addTab(Config.gw_2+"记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), scrollPane5, null);
|
|
tabbedPane.addTab(Config.gw_2+"记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), scrollPane5, null);
|
|
|
|
|
|
|
|
|
|
+ panelOkng = new JPanel();
|
|
|
|
|
+ scrollPaneOkng = new JScrollPane(panelOkng);
|
|
|
|
|
+ panelOkng.setLayout(null);
|
|
|
|
|
+ tabbedPane.addTab("OKNG样件", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), scrollPaneOkng, null);
|
|
|
|
|
+
|
|
|
// 员工工作记录
|
|
// 员工工作记录
|
|
|
panel4 = new JPanel();
|
|
panel4 = new JPanel();
|
|
|
scrollPane4 = new JScrollPane(panel4);
|
|
scrollPane4 = new JScrollPane(panel4);
|
|
@@ -862,11 +880,13 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 切换 tab 时刷新记录查询(保持与 OP370-AUTO 一致:打开页面自动刷新)
|
|
// 切换 tab 时刷新记录查询(保持与 OP370-AUTO 一致:打开页面自动刷新)
|
|
|
- // gw_1记录 tab index: 3, gw_2记录 tab index: 4(前面有 工作面板/开班点检A/开班点检B)
|
|
|
|
|
|
|
+ // gw_1记录 tab index: 3, gw_2记录 tab index: 4, OKNG样件 tab index: 5
|
|
|
if (selectedIndex == 3) {
|
|
if (selectedIndex == 3) {
|
|
|
loadRecordData_1();
|
|
loadRecordData_1();
|
|
|
} else if (selectedIndex == 4) {
|
|
} else if (selectedIndex == 4) {
|
|
|
loadRecordData_2();
|
|
loadRecordData_2();
|
|
|
|
|
+ } else if (selectedIndex == 5) {
|
|
|
|
|
+ loadOkngRecordData();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -874,6 +894,7 @@ public class MesClient extends JFrame {
|
|
|
// 初始化两条线的“记录查询”界面
|
|
// 初始化两条线的“记录查询”界面
|
|
|
initRecordPanel_1(indexPanelB);
|
|
initRecordPanel_1(indexPanelB);
|
|
|
initRecordPanel_2(panel5);
|
|
initRecordPanel_2(panel5);
|
|
|
|
|
+ initOkngRecordPanel(panelOkng);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static void initRecordPanel_1(JPanel container) {
|
|
private static void initRecordPanel_1(JPanel container) {
|
|
@@ -1047,6 +1068,181 @@ public class MesClient extends JFrame {
|
|
|
loadRecordData_2();
|
|
loadRecordData_2();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void initOkngRecordPanel(JPanel container) {
|
|
|
|
|
+ JPanel top = new JPanel();
|
|
|
|
|
+ top.setBounds(0, 0, 990, 50);
|
|
|
|
|
+ top.setLayout(null);
|
|
|
|
|
+ container.add(top);
|
|
|
|
|
+
|
|
|
|
|
+ recordSearchFieldOkng = new JTextField();
|
|
|
|
|
+ recordSearchFieldOkng.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
|
|
+ recordSearchFieldOkng.setForeground(Color.BLACK);
|
|
|
|
|
+ recordSearchFieldOkng.setBounds(10, 5, 371, 40);
|
|
|
|
|
+ top.add(recordSearchFieldOkng);
|
|
|
|
|
+
|
|
|
|
|
+ JButton searchBtn = new JButton("搜索");
|
|
|
|
|
+ searchBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
|
|
+ searchBtn.setBounds(385, 5, 90, 40);
|
|
|
|
|
+ top.add(searchBtn);
|
|
|
|
|
+ searchBtn.addActionListener(e -> {
|
|
|
|
|
+ recordPageNoOkng = 1;
|
|
|
|
|
+ loadOkngRecordData();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ JButton resetBtn = new JButton("重置");
|
|
|
|
|
+ resetBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
|
|
+ resetBtn.setBounds(475, 5, 90, 40);
|
|
|
|
|
+ top.add(resetBtn);
|
|
|
|
|
+ resetBtn.addActionListener(e -> {
|
|
|
|
|
+ recordSearchFieldOkng.setText("");
|
|
|
|
|
+ recordPageNoOkng = 1;
|
|
|
|
|
+ loadOkngRecordData();
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ JButton btnPrevious = new JButton("上一页");
|
|
|
|
|
+ btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ btnPrevious.setBounds(680, 5, 100, 40);
|
|
|
|
|
+ top.add(btnPrevious);
|
|
|
|
|
+ btnPrevious.addActionListener(e -> {
|
|
|
|
|
+ if (recordPageNoOkng > 1) {
|
|
|
|
|
+ recordPageNoOkng--;
|
|
|
|
|
+ loadOkngRecordData();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ recordPageLabelOkng = new JLabel("0/0");
|
|
|
|
|
+ recordPageLabelOkng.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ recordPageLabelOkng.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ recordPageLabelOkng.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
|
|
|
|
|
+ recordPageLabelOkng.setBounds(780, 5, 100, 40);
|
|
|
|
|
+ top.add(recordPageLabelOkng);
|
|
|
|
|
+
|
|
|
|
|
+ JButton btnNext = new JButton("下一页");
|
|
|
|
|
+ btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ btnNext.setBounds(880, 5, 100, 40);
|
|
|
|
|
+ top.add(btnNext);
|
|
|
|
|
+ btnNext.addActionListener(e -> {
|
|
|
|
|
+ if (recordPageNoOkng < recordTotalPagesOkng) {
|
|
|
|
|
+ recordPageNoOkng++;
|
|
|
|
|
+ loadOkngRecordData();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ JPanel tablePanel = new JPanel();
|
|
|
|
|
+ tablePanel.setBounds(0, 49, 990, 518);
|
|
|
|
|
+ tablePanel.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
|
|
+ container.add(tablePanel);
|
|
|
|
|
+
|
|
|
|
|
+ recordTableOkng = new JTable(recordRowDataOkng, recordColumnNamesOkng) {
|
|
|
|
|
+ public boolean isCellEditable(int row, int column) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ recordTableOkng.setRowHeight(40);
|
|
|
|
|
+ recordTableOkng.setEnabled(true);
|
|
|
|
|
+ recordTableOkng.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
|
|
+
|
|
|
|
|
+ javax.swing.table.DefaultTableCellRenderer centerRenderer = new javax.swing.table.DefaultTableCellRenderer();
|
|
|
|
|
+ centerRenderer.setHorizontalAlignment(JLabel.CENTER);
|
|
|
|
|
+ recordTableOkng.setDefaultRenderer(Object.class, centerRenderer);
|
|
|
|
|
+
|
|
|
|
|
+ JScrollPane scrollPane = new JScrollPane(recordTableOkng);
|
|
|
|
|
+ tablePanel.add(scrollPane);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean refreshOkngSamples() {
|
|
|
|
|
+ okngSampleSns.clear();
|
|
|
|
|
+ okngSampleType.clear();
|
|
|
|
|
+ JSONObject ret = DataUtil.getQmSampleSns(Config.gw_1, Config.line_sn);
|
|
|
|
|
+ if (ret == null || !"true".equalsIgnoreCase(String.valueOf(ret.get("result")))) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ JSONObject data = ret.getJSONObject("data");
|
|
|
|
|
+ if (data == null) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ addOkngSamples(data.getString("ok"), "OK件");
|
|
|
|
|
+ addOkngSamples(data.getString("ng"), "NG件");
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static void addOkngSamples(String sns, String type) {
|
|
|
|
|
+ if (sns == null || sns.trim().isEmpty()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String sn : sns.split(",", -1)) {
|
|
|
|
|
+ String code = sn.trim();
|
|
|
|
|
+ if (code.isEmpty()) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!okngSampleSns.contains(code)) {
|
|
|
|
|
+ okngSampleSns.add(code);
|
|
|
|
|
+ }
|
|
|
|
|
+ String old = okngSampleType.get(code);
|
|
|
|
|
+ if (old == null) {
|
|
|
|
|
+ okngSampleType.put(code, type);
|
|
|
|
|
+ } else if (!old.equals(type) && !old.contains(type)) {
|
|
|
|
|
+ okngSampleType.put(code, old + "/" + type);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static void loadOkngRecordData() {
|
|
|
|
|
+ clearRecordRowData(recordRowDataOkng);
|
|
|
|
|
+ boolean loaded = refreshOkngSamples();
|
|
|
|
|
+ int pageSize = 12;
|
|
|
|
|
+ String snLike = recordSearchFieldOkng == null ? "" : recordSearchFieldOkng.getText();
|
|
|
|
|
+ List<String> oprnos = new ArrayList<>();
|
|
|
|
|
+ oprnos.add(Config.gw_1);
|
|
|
|
|
+ oprnos.add(Config.gw_2);
|
|
|
|
|
+
|
|
|
|
|
+ if (!loaded) {
|
|
|
|
|
+ recordTotalPagesOkng = 0;
|
|
|
|
|
+ if (recordPageLabelOkng != null) recordPageLabelOkng.setText("失败");
|
|
|
|
|
+ if (recordTableOkng != null) recordTableOkng.repaint();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int totalItems = QMParamsDAO.countByOprnosAndSns(oprnos, okngSampleSns, snLike);
|
|
|
|
|
+ if (totalItems <= 0) {
|
|
|
|
|
+ recordTotalPagesOkng = 0;
|
|
|
|
|
+ if (recordPageLabelOkng != null) recordPageLabelOkng.setText(okngSampleSns.isEmpty() ? "未配置" : "0/0");
|
|
|
|
|
+ if (recordTableOkng != null) recordTableOkng.repaint();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ recordTotalPagesOkng = (int) Math.ceil((double) totalItems / (double) pageSize);
|
|
|
|
|
+ if (recordPageNoOkng > recordTotalPagesOkng) recordPageNoOkng = recordTotalPagesOkng;
|
|
|
|
|
+ if (recordPageNoOkng < 1) recordPageNoOkng = 1;
|
|
|
|
|
+ if (recordPageLabelOkng != null) recordPageLabelOkng.setText(recordPageNoOkng + "/" + recordTotalPagesOkng);
|
|
|
|
|
+
|
|
|
|
|
+ int offset = (recordPageNoOkng - 1) * pageSize;
|
|
|
|
|
+ List<Map<String, Object>> rows = QMParamsDAO.queryByOprnosAndSns(oprnos, okngSampleSns, snLike, pageSize, offset);
|
|
|
|
|
+ int rowIndex = 0;
|
|
|
|
|
+ for (Map<String, Object> r : rows) {
|
|
|
|
|
+ if (rowIndex >= recordRowDataOkng.length) break;
|
|
|
|
|
+ String sn = r.get("sn") == null ? "" : String.valueOf(r.get("sn")).trim();
|
|
|
|
|
+ String recordTime = r.get("record_time") == null ? "" : String.valueOf(r.get("record_time"));
|
|
|
|
|
+ String pressure = (r.get("pressure_value") == null ? "" : String.valueOf(r.get("pressure_value")))
|
|
|
|
|
+ + (r.get("pressure_unit") == null ? "" : String.valueOf(r.get("pressure_unit")));
|
|
|
|
|
+ String leak = (r.get("leak_value") == null ? "" : String.valueOf(r.get("leak_value")))
|
|
|
|
|
+ + (r.get("leak_unit") == null ? "" : String.valueOf(r.get("leak_unit")));
|
|
|
|
|
+ String result = r.get("test_result") == null ? "" : String.valueOf(r.get("test_result"));
|
|
|
|
|
+ String oprno = r.get("oprno") == null ? "" : String.valueOf(r.get("oprno"));
|
|
|
|
|
+
|
|
|
|
|
+ recordRowDataOkng[rowIndex][0] = oprno;
|
|
|
|
|
+ recordRowDataOkng[rowIndex][1] = okngSampleType.getOrDefault(sn, "");
|
|
|
|
|
+ recordRowDataOkng[rowIndex][2] = sn;
|
|
|
|
|
+ recordRowDataOkng[rowIndex][3] = recordTime;
|
|
|
|
|
+ recordRowDataOkng[rowIndex][4] = pressure;
|
|
|
|
|
+ recordRowDataOkng[rowIndex][5] = leak;
|
|
|
|
|
+ recordRowDataOkng[rowIndex][6] = result;
|
|
|
|
|
+ rowIndex++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (recordTableOkng != null) recordTableOkng.repaint();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static void clearRecordRowData(Object[][] rowData) {
|
|
private static void clearRecordRowData(Object[][] rowData) {
|
|
|
for (int i = 0; i < rowData.length; i++) {
|
|
for (int i = 0; i < rowData.length; i++) {
|
|
|
for (int j = 0; j < rowData[i].length; j++) {
|
|
for (int j = 0; j < rowData[i].length; j++) {
|