|
|
@@ -105,6 +105,16 @@ public class MesClient extends JFrame {
|
|
|
public static int totalPages; // 总页数
|
|
|
public static JTextField textField;//搜索框
|
|
|
|
|
|
+ public static JTable okngTable;
|
|
|
+ public static Object[] okngColumnNames = {"样件", "工件码", "测试日期", "压力", "泄露值", "结果"};
|
|
|
+ public static Object[][] okngRowData = new Object[12][6];
|
|
|
+ public static JLabel okngPageLabel;
|
|
|
+ public static int okngPageNo = 1;
|
|
|
+ public static int okngTotalPages;
|
|
|
+ public static JTextField okngTextField;
|
|
|
+ private static final List<String> okngSampleSns = new ArrayList<>();
|
|
|
+ private static final Map<String, String> okngSampleType = new HashMap<>();
|
|
|
+
|
|
|
public static JTable table2;
|
|
|
public static Object[] columnNames2 = { "任务名称" };
|
|
|
public static Object[][] rowData2 = {{""},{""},{""}};
|
|
|
@@ -919,6 +929,7 @@ public class MesClient extends JFrame {
|
|
|
toolBar.add(space_4);
|
|
|
|
|
|
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
+ tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
|
|
tabbedPane.setMinimumSize(new Dimension(400, 50));
|
|
|
tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
|
|
|
contentPane.add(tabbedPane);
|
|
|
@@ -1239,6 +1250,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
tabbedPane.addTab("记录查询", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
|
|
|
+ initOkngRecordPanel();
|
|
|
|
|
|
indexPanelB = new JPanel();
|
|
|
searchScrollPane = new JScrollPane(indexPanelB);
|
|
|
@@ -1940,6 +1952,9 @@ public class MesClient extends JFrame {
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
|
|
|
int selectedIndex = tabbedPane.getSelectedIndex();
|
|
|
+ if (selectedIndex == tabbedPane.indexOfTab("OKNG样件")) {
|
|
|
+ loadOkngRecordData();
|
|
|
+ }
|
|
|
if(selectedIndex == 1){
|
|
|
|
|
|
}
|
|
|
@@ -1948,6 +1963,202 @@ public class MesClient extends JFrame {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private static void initOkngRecordPanel() {
|
|
|
+ JPanel container = new JPanel();
|
|
|
+ container.setLayout(null);
|
|
|
+ JScrollPane scrollPane = new JScrollPane(container);
|
|
|
+
|
|
|
+ JPanel top = new JPanel();
|
|
|
+ top.setBounds(0, 0, 990, 50);
|
|
|
+ top.setLayout(null);
|
|
|
+ container.add(top);
|
|
|
+
|
|
|
+ okngTextField = new JTextField();
|
|
|
+ okngTextField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
+ okngTextField.setForeground(Color.BLACK);
|
|
|
+ okngTextField.setBounds(10, 5, 371, 40);
|
|
|
+ top.add(okngTextField);
|
|
|
+
|
|
|
+ JButton searchBtn = new JButton("搜索");
|
|
|
+ searchBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
+ searchBtn.setBounds(385, 5, 90, 40);
|
|
|
+ top.add(searchBtn);
|
|
|
+ searchBtn.addActionListener(e -> {
|
|
|
+ okngPageNo = 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 -> {
|
|
|
+ okngTextField.setText("");
|
|
|
+ okngPageNo = 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 (okngPageNo > 1) {
|
|
|
+ okngPageNo--;
|
|
|
+ loadOkngRecordData();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ okngPageLabel = new JLabel("0/0");
|
|
|
+ okngPageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
+ okngPageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ okngPageLabel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
|
|
|
+ okngPageLabel.setBounds(780, 5, 100, 40);
|
|
|
+ top.add(okngPageLabel);
|
|
|
+
|
|
|
+ JButton btnNext = new JButton("下一页");
|
|
|
+ btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
+ btnNext.setBounds(880, 5, 100, 40);
|
|
|
+ top.add(btnNext);
|
|
|
+ btnNext.addActionListener(e -> {
|
|
|
+ if (okngPageNo < okngTotalPages) {
|
|
|
+ okngPageNo++;
|
|
|
+ loadOkngRecordData();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ JPanel tablePanel = new JPanel();
|
|
|
+ tablePanel.setBounds(0, 49, 990, 518);
|
|
|
+ tablePanel.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
+ container.add(tablePanel);
|
|
|
+
|
|
|
+ okngTable = new JTable(okngRowData, okngColumnNames) {
|
|
|
+ public boolean isCellEditable(int row, int column) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ okngTable.setRowHeight(40);
|
|
|
+ okngTable.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
+ CenterRenderer centerRenderer = new CenterRenderer();
|
|
|
+ for (int i = 0; i < okngTable.getColumnCount(); i++) {
|
|
|
+ okngTable.getColumn(okngTable.getColumnName(i)).setCellRenderer(centerRenderer);
|
|
|
+ }
|
|
|
+ tablePanel.add(new JScrollPane(okngTable));
|
|
|
+
|
|
|
+ tabbedPane.addTab("OKNG样件", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), scrollPane, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void loadOkngRecordData() {
|
|
|
+ for (int i = 0; i < okngRowData.length; i++) {
|
|
|
+ for (int j = 0; j < okngRowData[i].length; j++) {
|
|
|
+ okngRowData[i][j] = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean loaded = refreshOkngSamples();
|
|
|
+ int pageSize = 12;
|
|
|
+ String snLike = okngTextField == null ? "" : okngTextField.getText();
|
|
|
+ if (!loaded) {
|
|
|
+ okngTotalPages = 0;
|
|
|
+ if (okngPageLabel != null) {
|
|
|
+ okngPageLabel.setText("失败");
|
|
|
+ }
|
|
|
+ if (okngTable != null) {
|
|
|
+ okngTable.repaint();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int totalItems = JdbcUtils.countTestRecordBySns(okngSampleSns, snLike);
|
|
|
+ if (totalItems <= 0) {
|
|
|
+ okngTotalPages = 0;
|
|
|
+ if (okngPageLabel != null) {
|
|
|
+ okngPageLabel.setText(okngSampleSns.isEmpty() ? "未配置" : "0/0");
|
|
|
+ }
|
|
|
+ if (okngTable != null) {
|
|
|
+ okngTable.repaint();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ okngTotalPages = (int) Math.ceil((double) totalItems / (double) pageSize);
|
|
|
+ if (okngPageNo > okngTotalPages) {
|
|
|
+ okngPageNo = okngTotalPages;
|
|
|
+ }
|
|
|
+ if (okngPageNo < 1) {
|
|
|
+ okngPageNo = 1;
|
|
|
+ }
|
|
|
+ if (okngPageLabel != null) {
|
|
|
+ okngPageLabel.setText(okngPageNo + "/" + okngTotalPages);
|
|
|
+ }
|
|
|
+ int offset = (okngPageNo - 1) * pageSize;
|
|
|
+ List<String[]> rows = JdbcUtils.queryTestRecordBySns(okngSampleSns, snLike, pageSize, offset);
|
|
|
+ int rowIndex = 0;
|
|
|
+ for (String[] row : rows) {
|
|
|
+ if (rowIndex >= okngRowData.length) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ okngRowData[rowIndex][0] = okngSampleType.getOrDefault(row[0], "");
|
|
|
+ okngRowData[rowIndex][1] = row[0];
|
|
|
+ okngRowData[rowIndex][2] = row[1];
|
|
|
+ okngRowData[rowIndex][3] = row[2];
|
|
|
+ okngRowData[rowIndex][4] = row[3];
|
|
|
+ okngRowData[rowIndex][5] = row[4];
|
|
|
+ rowIndex++;
|
|
|
+ }
|
|
|
+ if (okngTable != null) {
|
|
|
+ okngTable.repaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean refreshOkngSamples() {
|
|
|
+ okngSampleSns.clear();
|
|
|
+ okngSampleType.clear();
|
|
|
+ String oprno = "";
|
|
|
+ String lineSn = "";
|
|
|
+ try {
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
|
+ pro.load(br);
|
|
|
+ oprno = pro.getProperty("mes.gw");
|
|
|
+ lineSn = pro.getProperty("mes.line_sn");
|
|
|
+ br.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("读取工位配置失败", e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ JSONObject ret = DataUtil.getQmSampleSns(oprno == null ? "" : oprno.trim(), lineSn == null ? "" : lineSn.trim());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void setMenuStatus(String msg,int error){
|
|
|
if(error == 0){
|
|
|
MesClient.status_menu.setForeground(Color.GREEN);
|