|
@@ -13,30 +13,19 @@ import java.awt.event.ComponentEvent;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 工作记录面板组件
|
|
|
|
|
- * 支持分页查询和展示工作记录数据
|
|
|
|
|
|
|
+ * 称重工作记录面板:从后台 mesWuliaoCz/pclist 拉取数据
|
|
|
*/
|
|
*/
|
|
|
public class WorkRecordPanel extends JPanel {
|
|
public class WorkRecordPanel extends JPanel {
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(WorkRecordPanel.class);
|
|
private static final Logger log = LoggerFactory.getLogger(WorkRecordPanel.class);
|
|
|
|
|
|
|
|
- // 表格列名
|
|
|
|
|
- private static final String[] COLUMN_NAMES = {"工件码", "工位号", "工位结果", "作业人员", "日期"};
|
|
|
|
|
-
|
|
|
|
|
- // 分页配置
|
|
|
|
|
|
|
+ private static final String[] COLUMN_NAMES = {"炉次", "班次", "物料类型", "重量(kg)", "操作人", "时间"};
|
|
|
private static final int PAGE_SIZE = 20;
|
|
private static final int PAGE_SIZE = 20;
|
|
|
|
|
|
|
|
- // 查询条件
|
|
|
|
|
- private String oprno; // 工位号(null或空则查全部)
|
|
|
|
|
- private String lineSn; // 产线编号
|
|
|
|
|
- private boolean isAllStation; // 是否是"所有工位"模式
|
|
|
|
|
-
|
|
|
|
|
- // 分页状态
|
|
|
|
|
private int pageNo = 1;
|
|
private int pageNo = 1;
|
|
|
private long totalCount = 0;
|
|
private long totalCount = 0;
|
|
|
private int totalPages = 0;
|
|
private int totalPages = 0;
|
|
|
|
|
|
|
|
- // UI组件
|
|
|
|
|
private JTable table;
|
|
private JTable table;
|
|
|
private DefaultTableModel tableModel;
|
|
private DefaultTableModel tableModel;
|
|
|
private JLabel pageLabel;
|
|
private JLabel pageLabel;
|
|
@@ -45,31 +34,22 @@ public class WorkRecordPanel extends JPanel {
|
|
|
private JButton btnRefresh;
|
|
private JButton btnRefresh;
|
|
|
private JButton btnSearch;
|
|
private JButton btnSearch;
|
|
|
private JLabel statusLabel;
|
|
private JLabel statusLabel;
|
|
|
- private JTextField snSearchField; // 工件码搜索框
|
|
|
|
|
- private JTextField oprnoSearchField; // 工位号搜索框(仅"所有工位"模式)
|
|
|
|
|
- private JLabel snLabel;
|
|
|
|
|
- private JLabel oprnoLabel;
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 构造函数
|
|
|
|
|
- * @param oprno 工位号(如OP150A查询该工位,null或空则查所有工位)
|
|
|
|
|
- * @param lineSn 产线编号
|
|
|
|
|
- */
|
|
|
|
|
- public WorkRecordPanel(String oprno, String lineSn) {
|
|
|
|
|
- this.oprno = oprno;
|
|
|
|
|
- this.lineSn = lineSn;
|
|
|
|
|
- this.isAllStation = (oprno == null || oprno.isEmpty());
|
|
|
|
|
|
|
+ private JTextField lcSearchField;
|
|
|
|
|
+ private JTextField typeSearchField;
|
|
|
|
|
+
|
|
|
|
|
+ public WorkRecordPanel() {
|
|
|
initUI();
|
|
initUI();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 初始化UI
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** 兼容旧构造:忽略工位参数,统一查询称重记录 */
|
|
|
|
|
+ public WorkRecordPanel(String oprno, String lineSn) {
|
|
|
|
|
+ this();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void initUI() {
|
|
private void initUI() {
|
|
|
setLayout(null);
|
|
setLayout(null);
|
|
|
setBackground(Color.WHITE);
|
|
setBackground(Color.WHITE);
|
|
|
|
|
|
|
|
- // 顶部控制区
|
|
|
|
|
JPanel topPanel = new JPanel();
|
|
JPanel topPanel = new JPanel();
|
|
|
topPanel.setLayout(null);
|
|
topPanel.setLayout(null);
|
|
|
topPanel.setBounds(0, 0, 1200, 50);
|
|
topPanel.setBounds(0, 0, 1200, 50);
|
|
@@ -78,45 +58,38 @@ public class WorkRecordPanel extends JPanel {
|
|
|
|
|
|
|
|
int xPos = 10;
|
|
int xPos = 10;
|
|
|
|
|
|
|
|
- // 状态标签
|
|
|
|
|
- String displayOprno = isAllStation ? "所有工位" : oprno;
|
|
|
|
|
- statusLabel = new JLabel("工位:" + displayOprno);
|
|
|
|
|
|
|
+ statusLabel = new JLabel("称重记录");
|
|
|
statusLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
statusLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
- statusLabel.setBounds(xPos, 10, 160, 30);
|
|
|
|
|
|
|
+ statusLabel.setBounds(xPos, 10, 140, 30);
|
|
|
topPanel.add(statusLabel);
|
|
topPanel.add(statusLabel);
|
|
|
- xPos += 165;
|
|
|
|
|
-
|
|
|
|
|
- // 工件码搜索
|
|
|
|
|
- snLabel = new JLabel("工件码:");
|
|
|
|
|
- snLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
- snLabel.setBounds(xPos, 10, 50, 30);
|
|
|
|
|
- topPanel.add(snLabel);
|
|
|
|
|
- xPos += 52;
|
|
|
|
|
-
|
|
|
|
|
- snSearchField = new JTextField();
|
|
|
|
|
- snSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
- snSearchField.setBounds(xPos, 10, 200, 30);
|
|
|
|
|
- snSearchField.addActionListener(e -> doSearch()); // 回车搜索
|
|
|
|
|
- topPanel.add(snSearchField);
|
|
|
|
|
- xPos += 210;
|
|
|
|
|
-
|
|
|
|
|
- // 工位号搜索(仅"所有工位"模式显示)
|
|
|
|
|
- if (isAllStation) {
|
|
|
|
|
- oprnoLabel = new JLabel("工位:");
|
|
|
|
|
- oprnoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
- oprnoLabel.setBounds(xPos, 10, 40, 30);
|
|
|
|
|
- topPanel.add(oprnoLabel);
|
|
|
|
|
- xPos += 42;
|
|
|
|
|
-
|
|
|
|
|
- oprnoSearchField = new JTextField();
|
|
|
|
|
- oprnoSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
- oprnoSearchField.setBounds(xPos, 10, 100, 30);
|
|
|
|
|
- oprnoSearchField.addActionListener(e -> doSearch()); // 回车搜索
|
|
|
|
|
- topPanel.add(oprnoSearchField);
|
|
|
|
|
- xPos += 110;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ xPos += 145;
|
|
|
|
|
+
|
|
|
|
|
+ JLabel lcLabel = new JLabel("炉次:");
|
|
|
|
|
+ lcLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
+ lcLabel.setBounds(xPos, 10, 40, 30);
|
|
|
|
|
+ topPanel.add(lcLabel);
|
|
|
|
|
+ xPos += 42;
|
|
|
|
|
+
|
|
|
|
|
+ lcSearchField = new JTextField();
|
|
|
|
|
+ lcSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
+ lcSearchField.setBounds(xPos, 10, 80, 30);
|
|
|
|
|
+ lcSearchField.addActionListener(e -> doSearch());
|
|
|
|
|
+ topPanel.add(lcSearchField);
|
|
|
|
|
+ xPos += 90;
|
|
|
|
|
+
|
|
|
|
|
+ JLabel typeLabel = new JLabel("物料:");
|
|
|
|
|
+ typeLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
+ typeLabel.setBounds(xPos, 10, 40, 30);
|
|
|
|
|
+ topPanel.add(typeLabel);
|
|
|
|
|
+ xPos += 42;
|
|
|
|
|
+
|
|
|
|
|
+ typeSearchField = new JTextField();
|
|
|
|
|
+ typeSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
|
|
+ typeSearchField.setBounds(xPos, 10, 120, 30);
|
|
|
|
|
+ typeSearchField.addActionListener(e -> doSearch());
|
|
|
|
|
+ topPanel.add(typeSearchField);
|
|
|
|
|
+ xPos += 130;
|
|
|
|
|
|
|
|
- // 查询按钮
|
|
|
|
|
btnSearch = new JButton("查询");
|
|
btnSearch = new JButton("查询");
|
|
|
btnSearch.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
btnSearch.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
btnSearch.setBounds(xPos, 10, 70, 30);
|
|
btnSearch.setBounds(xPos, 10, 70, 30);
|
|
@@ -124,7 +97,6 @@ public class WorkRecordPanel extends JPanel {
|
|
|
topPanel.add(btnSearch);
|
|
topPanel.add(btnSearch);
|
|
|
xPos += 80;
|
|
xPos += 80;
|
|
|
|
|
|
|
|
- // 刷新按钮
|
|
|
|
|
btnRefresh = new JButton("刷新");
|
|
btnRefresh = new JButton("刷新");
|
|
|
btnRefresh.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
btnRefresh.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
btnRefresh.setBounds(xPos, 10, 70, 30);
|
|
btnRefresh.setBounds(xPos, 10, 70, 30);
|
|
@@ -135,7 +107,6 @@ public class WorkRecordPanel extends JPanel {
|
|
|
topPanel.add(btnRefresh);
|
|
topPanel.add(btnRefresh);
|
|
|
xPos += 80;
|
|
xPos += 80;
|
|
|
|
|
|
|
|
- // 上一页按钮
|
|
|
|
|
btnPrevious = new JButton("上一页");
|
|
btnPrevious = new JButton("上一页");
|
|
|
btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
btnPrevious.setBounds(xPos, 10, 80, 30);
|
|
btnPrevious.setBounds(xPos, 10, 80, 30);
|
|
@@ -148,7 +119,6 @@ public class WorkRecordPanel extends JPanel {
|
|
|
topPanel.add(btnPrevious);
|
|
topPanel.add(btnPrevious);
|
|
|
xPos += 85;
|
|
xPos += 85;
|
|
|
|
|
|
|
|
- // 页码显示
|
|
|
|
|
pageLabel = new JLabel("0/0");
|
|
pageLabel = new JLabel("0/0");
|
|
|
pageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
pageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
pageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
pageLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
@@ -157,7 +127,6 @@ public class WorkRecordPanel extends JPanel {
|
|
|
topPanel.add(pageLabel);
|
|
topPanel.add(pageLabel);
|
|
|
xPos += 75;
|
|
xPos += 75;
|
|
|
|
|
|
|
|
- // 下一页按钮
|
|
|
|
|
btnNext = new JButton("下一页");
|
|
btnNext = new JButton("下一页");
|
|
|
btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
btnNext.setBounds(xPos, 10, 80, 30);
|
|
btnNext.setBounds(xPos, 10, 80, 30);
|
|
@@ -169,13 +138,11 @@ public class WorkRecordPanel extends JPanel {
|
|
|
});
|
|
});
|
|
|
topPanel.add(btnNext);
|
|
topPanel.add(btnNext);
|
|
|
|
|
|
|
|
- // 表格面板
|
|
|
|
|
JPanel tablePanel = new JPanel();
|
|
JPanel tablePanel = new JPanel();
|
|
|
tablePanel.setBounds(0, 50, 1200, 518);
|
|
tablePanel.setBounds(0, 50, 1200, 518);
|
|
|
tablePanel.setLayout(new GridLayout(1, 1, 0, 0));
|
|
tablePanel.setLayout(new GridLayout(1, 1, 0, 0));
|
|
|
add(tablePanel);
|
|
add(tablePanel);
|
|
|
|
|
|
|
|
- // 创建表格模型
|
|
|
|
|
tableModel = new DefaultTableModel(COLUMN_NAMES, 0) {
|
|
tableModel = new DefaultTableModel(COLUMN_NAMES, 0) {
|
|
|
@Override
|
|
@Override
|
|
|
public boolean isCellEditable(int row, int column) {
|
|
public boolean isCellEditable(int row, int column) {
|
|
@@ -183,136 +150,79 @@ public class WorkRecordPanel extends JPanel {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 创建表格
|
|
|
|
|
table = new JTable(tableModel);
|
|
table = new JTable(tableModel);
|
|
|
table.setRowHeight(32);
|
|
table.setRowHeight(32);
|
|
|
table.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
table.setFont(new Font("微软雅黑", Font.PLAIN, 13));
|
|
|
table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
|
|
table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
|
|
|
table.getTableHeader().setReorderingAllowed(false);
|
|
table.getTableHeader().setReorderingAllowed(false);
|
|
|
-
|
|
|
|
|
- // 设置列宽
|
|
|
|
|
setColumnWidths();
|
|
setColumnWidths();
|
|
|
|
|
|
|
|
- // 设置居中渲染器
|
|
|
|
|
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
|
|
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
|
|
|
centerRenderer.setHorizontalAlignment(JLabel.CENTER);
|
|
centerRenderer.setHorizontalAlignment(JLabel.CENTER);
|
|
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
|
|
table.getColumnModel().getColumn(i).setCellRenderer(centerRenderer);
|
|
table.getColumnModel().getColumn(i).setCellRenderer(centerRenderer);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 添加滚动面板
|
|
|
|
|
- JScrollPane scrollPane = new JScrollPane(table);
|
|
|
|
|
- tablePanel.add(scrollPane);
|
|
|
|
|
|
|
+ tablePanel.add(new JScrollPane(table));
|
|
|
|
|
|
|
|
- // 添加组件大小变化监听器
|
|
|
|
|
addComponentListener(new ComponentAdapter() {
|
|
addComponentListener(new ComponentAdapter() {
|
|
|
@Override
|
|
@Override
|
|
|
public void componentResized(ComponentEvent e) {
|
|
public void componentResized(ComponentEvent e) {
|
|
|
int w = getWidth();
|
|
int w = getWidth();
|
|
|
int h = getHeight();
|
|
int h = getHeight();
|
|
|
-
|
|
|
|
|
- // 调整顶部面板宽度
|
|
|
|
|
topPanel.setBounds(0, 0, w, 50);
|
|
topPanel.setBounds(0, 0, w, 50);
|
|
|
-
|
|
|
|
|
- // 调整表格面板
|
|
|
|
|
if (h > 50) {
|
|
if (h > 50) {
|
|
|
tablePanel.setBounds(0, 50, w, h - 50);
|
|
tablePanel.setBounds(0, 50, w, h - 50);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
topPanel.revalidate();
|
|
topPanel.revalidate();
|
|
|
tablePanel.revalidate();
|
|
tablePanel.revalidate();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 设置列宽
|
|
|
|
|
- */
|
|
|
|
|
private void setColumnWidths() {
|
|
private void setColumnWidths() {
|
|
|
- TableColumn column;
|
|
|
|
|
- // 工件码
|
|
|
|
|
- column = table.getColumnModel().getColumn(0);
|
|
|
|
|
- column.setPreferredWidth(260);
|
|
|
|
|
- // 工位号
|
|
|
|
|
- column = table.getColumnModel().getColumn(1);
|
|
|
|
|
- column.setPreferredWidth(90);
|
|
|
|
|
- // 工位结果
|
|
|
|
|
- column = table.getColumnModel().getColumn(2);
|
|
|
|
|
- column.setPreferredWidth(70);
|
|
|
|
|
- // 作业人员
|
|
|
|
|
- column = table.getColumnModel().getColumn(3);
|
|
|
|
|
- column.setPreferredWidth(100);
|
|
|
|
|
- // 日期
|
|
|
|
|
- column = table.getColumnModel().getColumn(4);
|
|
|
|
|
- column.setPreferredWidth(150);
|
|
|
|
|
|
|
+ int[] widths = {80, 80, 120, 100, 120, 180};
|
|
|
|
|
+ for (int i = 0; i < widths.length && i < table.getColumnCount(); i++) {
|
|
|
|
|
+ TableColumn column = table.getColumnModel().getColumn(i);
|
|
|
|
|
+ column.setPreferredWidth(widths[i]);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 清空搜索框
|
|
|
|
|
- */
|
|
|
|
|
private void clearSearchFields() {
|
|
private void clearSearchFields() {
|
|
|
- snSearchField.setText("");
|
|
|
|
|
- if (oprnoSearchField != null) {
|
|
|
|
|
- oprnoSearchField.setText("");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ lcSearchField.setText("");
|
|
|
|
|
+ typeSearchField.setText("");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 执行搜索
|
|
|
|
|
- */
|
|
|
|
|
private void doSearch() {
|
|
private void doSearch() {
|
|
|
pageNo = 1;
|
|
pageNo = 1;
|
|
|
loadData();
|
|
loadData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 刷新数据(重置到第一页)
|
|
|
|
|
- */
|
|
|
|
|
public void refreshData() {
|
|
public void refreshData() {
|
|
|
pageNo = 1;
|
|
pageNo = 1;
|
|
|
loadData();
|
|
loadData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 加载数据
|
|
|
|
|
- */
|
|
|
|
|
public void loadData() {
|
|
public void loadData() {
|
|
|
- // 获取搜索条件
|
|
|
|
|
- String searchSn = snSearchField.getText().trim();
|
|
|
|
|
- String searchOprno = oprno; // 默认使用构造函数传入的工位号
|
|
|
|
|
-
|
|
|
|
|
- // 如果是"所有工位"模式,检查是否有工位号搜索条件
|
|
|
|
|
- if (isAllStation && oprnoSearchField != null) {
|
|
|
|
|
- String inputOprno = oprnoSearchField.getText().trim();
|
|
|
|
|
- if (!inputOprno.isEmpty()) {
|
|
|
|
|
- searchOprno = inputOprno;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- final String finalSearchOprno = searchOprno;
|
|
|
|
|
- final String finalSearchSn = searchSn;
|
|
|
|
|
|
|
+ final String lc = lcSearchField.getText().trim();
|
|
|
|
|
+ final String type = typeSearchField.getText().trim();
|
|
|
|
|
|
|
|
- // 在后台线程中执行数据加载
|
|
|
|
|
SwingWorker<WorkRecordResp, Void> worker = new SwingWorker<WorkRecordResp, Void>() {
|
|
SwingWorker<WorkRecordResp, Void> worker = new SwingWorker<WorkRecordResp, Void>() {
|
|
|
@Override
|
|
@Override
|
|
|
- protected WorkRecordResp doInBackground() throws Exception {
|
|
|
|
|
- // 更新状态
|
|
|
|
|
|
|
+ protected WorkRecordResp doInBackground() {
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
statusLabel.setText("正在加载...");
|
|
statusLabel.setText("正在加载...");
|
|
|
setButtonsEnabled(false);
|
|
setButtonsEnabled(false);
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
- // 调用接口查询数据
|
|
|
|
|
- return DataUtil.getWorkRecordList(finalSearchOprno, finalSearchSn, pageNo, PAGE_SIZE);
|
|
|
|
|
|
|
+ return DataUtil.getWeighRecordList(lc, type, pageNo, PAGE_SIZE);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void done() {
|
|
protected void done() {
|
|
|
try {
|
|
try {
|
|
|
- WorkRecordResp resp = get();
|
|
|
|
|
- updateUI(resp, finalSearchOprno);
|
|
|
|
|
|
|
+ updateUI(get());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("加载工作记录失败: {}", e.getMessage());
|
|
|
|
|
|
|
+ log.error("加载称重记录失败: {}", e.getMessage());
|
|
|
updateUIError("加载失败: " + e.getMessage());
|
|
updateUIError("加载失败: " + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -320,9 +230,6 @@ public class WorkRecordPanel extends JPanel {
|
|
|
worker.execute();
|
|
worker.execute();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 设置按钮启用状态
|
|
|
|
|
- */
|
|
|
|
|
private void setButtonsEnabled(boolean enabled) {
|
|
private void setButtonsEnabled(boolean enabled) {
|
|
|
btnSearch.setEnabled(enabled);
|
|
btnSearch.setEnabled(enabled);
|
|
|
btnRefresh.setEnabled(enabled);
|
|
btnRefresh.setEnabled(enabled);
|
|
@@ -330,11 +237,7 @@ public class WorkRecordPanel extends JPanel {
|
|
|
btnNext.setEnabled(enabled && pageNo < totalPages);
|
|
btnNext.setEnabled(enabled && pageNo < totalPages);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 更新UI显示数据
|
|
|
|
|
- */
|
|
|
|
|
- private void updateUI(WorkRecordResp resp, String queryOprno) {
|
|
|
|
|
- // 清空表格
|
|
|
|
|
|
|
+ private void updateUI(WorkRecordResp resp) {
|
|
|
tableModel.setRowCount(0);
|
|
tableModel.setRowCount(0);
|
|
|
|
|
|
|
|
if (resp == null || !resp.isResult()) {
|
|
if (resp == null || !resp.isResult()) {
|
|
@@ -343,48 +246,32 @@ public class WorkRecordPanel extends JPanel {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 更新分页信息
|
|
|
|
|
totalCount = resp.getCount();
|
|
totalCount = resp.getCount();
|
|
|
totalPages = (int) Math.ceil((double) totalCount / PAGE_SIZE);
|
|
totalPages = (int) Math.ceil((double) totalCount / PAGE_SIZE);
|
|
|
- if (totalPages == 0) totalPages = 1;
|
|
|
|
|
|
|
+ if (totalPages == 0) {
|
|
|
|
|
+ totalPages = 1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 更新页码显示
|
|
|
|
|
pageLabel.setText(pageNo + "/" + totalPages);
|
|
pageLabel.setText(pageNo + "/" + totalPages);
|
|
|
-
|
|
|
|
|
- // 更新按钮状态
|
|
|
|
|
setButtonsEnabled(true);
|
|
setButtonsEnabled(true);
|
|
|
|
|
+ statusLabel.setText("称重记录 共" + totalCount + "条");
|
|
|
|
|
|
|
|
- // 更新状态标签
|
|
|
|
|
- String oprnoDisplay;
|
|
|
|
|
- if (isAllStation) {
|
|
|
|
|
- oprnoDisplay = (queryOprno == null || queryOprno.isEmpty()) ? "所有工位" : queryOprno;
|
|
|
|
|
- } else {
|
|
|
|
|
- oprnoDisplay = oprno;
|
|
|
|
|
- }
|
|
|
|
|
- statusLabel.setText("工位:" + oprnoDisplay + " 共" + totalCount + "条");
|
|
|
|
|
-
|
|
|
|
|
- // 填充表格数据
|
|
|
|
|
List<WorkRecordData> list = resp.getList();
|
|
List<WorkRecordData> list = resp.getList();
|
|
|
if (list != null && !list.isEmpty()) {
|
|
if (list != null && !list.isEmpty()) {
|
|
|
for (WorkRecordData data : list) {
|
|
for (WorkRecordData data : list) {
|
|
|
- Object[] row = {
|
|
|
|
|
- data.getSn(),
|
|
|
|
|
- data.getOprno(),
|
|
|
|
|
- data.getContent(),
|
|
|
|
|
|
|
+ tableModel.addRow(new Object[]{
|
|
|
|
|
+ data.getLc(),
|
|
|
|
|
+ data.getBc(),
|
|
|
|
|
+ data.getType(),
|
|
|
|
|
+ data.getZl(),
|
|
|
data.getUpdateBy(),
|
|
data.getUpdateBy(),
|
|
|
- data.getUpdateDate()
|
|
|
|
|
- };
|
|
|
|
|
- tableModel.addRow(row);
|
|
|
|
|
|
|
+ data.getCreateDate()
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 刷新表格
|
|
|
|
|
table.repaint();
|
|
table.repaint();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 更新UI显示错误信息
|
|
|
|
|
- */
|
|
|
|
|
private void updateUIError(String message) {
|
|
private void updateUIError(String message) {
|
|
|
statusLabel.setText("错误: " + message);
|
|
statusLabel.setText("错误: " + message);
|
|
|
pageLabel.setText("0/0");
|
|
pageLabel.setText("0/0");
|
|
@@ -393,11 +280,4 @@ public class WorkRecordPanel extends JPanel {
|
|
|
btnNext.setEnabled(false);
|
|
btnNext.setEnabled(false);
|
|
|
tableModel.setRowCount(0);
|
|
tableModel.setRowCount(0);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取当前工位号
|
|
|
|
|
- */
|
|
|
|
|
- public String getOprno() {
|
|
|
|
|
- return oprno;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|