|
|
@@ -412,12 +412,7 @@ public class MesClient extends JFrame {
|
|
|
jobSubmitting = false;
|
|
|
PlcService.setAllowWork(false);
|
|
|
resetRivetMonitorState();
|
|
|
- if (MesClient.finish_ok_bt != null) {
|
|
|
- MesClient.finish_ok_bt.setEnabled(false);
|
|
|
- }
|
|
|
- if (MesClient.finish_ng_bt != null) {
|
|
|
- MesClient.finish_ng_bt.setEnabled(false);
|
|
|
- }
|
|
|
+ disableManualResultButtons();
|
|
|
if (product_sn != null) {
|
|
|
product_sn.setText("");
|
|
|
}
|
|
|
@@ -427,7 +422,6 @@ public class MesClient extends JFrame {
|
|
|
if (MesClient.f_scan_data_bt_1 != null) {
|
|
|
MesClient.f_scan_data_bt_1.setEnabled(true);
|
|
|
}
|
|
|
- initRivetTableData();
|
|
|
MesClient.setMenuStatus("请扫工件码",0);
|
|
|
|
|
|
updateMaterailData();
|
|
|
@@ -459,16 +453,23 @@ public class MesClient extends JFrame {
|
|
|
rivetRowData[i][3] = "-";
|
|
|
rivetRowData[i][4] = "-";
|
|
|
}
|
|
|
- refreshRivetTable(0, TtymPlcPoint.RIVET_COUNT - 1);
|
|
|
+ syncRivetTableToUi(0, TtymPlcPoint.RIVET_COUNT - 1);
|
|
|
}
|
|
|
|
|
|
- private static void refreshRivetTable(int fromRow, int toRow) {
|
|
|
+ /** 将 rivetRowData 同步到表格模型并刷新显示 */
|
|
|
+ private static void syncRivetTableToUi(int fromRow, int toRow) {
|
|
|
if (rivetTable == null) {
|
|
|
return;
|
|
|
}
|
|
|
Runnable refresh = () -> {
|
|
|
if (rivetTable.getModel() instanceof DefaultTableModel) {
|
|
|
- ((DefaultTableModel) rivetTable.getModel()).fireTableRowsUpdated(fromRow, toRow);
|
|
|
+ DefaultTableModel model = (DefaultTableModel) rivetTable.getModel();
|
|
|
+ for (int row = fromRow; row <= toRow && row < TtymPlcPoint.RIVET_COUNT; row++) {
|
|
|
+ for (int col = 0; col < rivetRowData[row].length; col++) {
|
|
|
+ model.setValueAt(rivetRowData[row][col], row, col);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.fireTableRowsUpdated(fromRow, toRow);
|
|
|
} else {
|
|
|
rivetTable.repaint();
|
|
|
}
|
|
|
@@ -572,7 +573,7 @@ public class MesClient extends JFrame {
|
|
|
JdbcUtils.insertRivetRecord(oprno, lineSn, sn, pointData.pointNo, pointData.result,
|
|
|
pointData.stroke, pointData.pressure, pointData.holdTime);
|
|
|
}
|
|
|
- refreshRivetTable(0, TtymPlcPoint.RIVET_COUNT - 1);
|
|
|
+ syncRivetTableToUi(0, TtymPlcPoint.RIVET_COUNT - 1);
|
|
|
SwingUtilities.invokeLater(() -> setMenuStatus("作业完成,已读取全部铆接数据", 0));
|
|
|
}
|
|
|
|
|
|
@@ -602,18 +603,6 @@ public class MesClient extends JFrame {
|
|
|
return points;
|
|
|
}
|
|
|
|
|
|
- private static String computeOverallResult() {
|
|
|
- String overallResult = "OK";
|
|
|
- for (int i = 0; i < TtymPlcPoint.RIVET_COUNT; i++) {
|
|
|
- if (!rivetRecorded[i]) {
|
|
|
- overallResult = "NG";
|
|
|
- } else if ("NG".equals(String.valueOf(rivetRowData[i][1]))) {
|
|
|
- overallResult = "NG";
|
|
|
- }
|
|
|
- }
|
|
|
- return overallResult;
|
|
|
- }
|
|
|
-
|
|
|
private static boolean uploadRivetBatchToMes(String sn, List<JdbcUtils.RivetRecordItem> points) {
|
|
|
JSONObject retObj = DataUtil.uploadRivetBatch(sn, user20, points);
|
|
|
if (retObj != null && retObj.get("result") != null
|
|
|
@@ -638,8 +627,58 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void submitOverallResult(String sn, String result) {
|
|
|
- setMenuStatus("作业完成,正在提交总结果...", 0);
|
|
|
+ private static void retryPendingRivetUploads() {
|
|
|
+ List<String> pendingSnList = JdbcUtils.getPendingRivetSnList();
|
|
|
+ if (pendingSnList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getUser();
|
|
|
+ String currentSn = product_sn.getText().trim();
|
|
|
+ for (String sn : pendingSnList) {
|
|
|
+ List<JdbcUtils.RivetRecordItem> points = JdbcUtils.getRivetRecordsBySn(sn);
|
|
|
+ if (points.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!sn.equals(currentSn) || !jobCompleteReceived) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ uploadRivetBatchToMes(sn, points);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void enableManualResultButtons() {
|
|
|
+ if (finish_ok_bt != null) {
|
|
|
+ finish_ok_bt.setEnabled(true);
|
|
|
+ }
|
|
|
+ if (finish_ng_bt != null) {
|
|
|
+ finish_ng_bt.setEnabled(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void disableManualResultButtons() {
|
|
|
+ if (finish_ok_bt != null) {
|
|
|
+ finish_ok_bt.setEnabled(false);
|
|
|
+ }
|
|
|
+ if (finish_ng_bt != null) {
|
|
|
+ finish_ng_bt.setEnabled(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 人工点击 OK/NG 后提交总结果 */
|
|
|
+ private static void manualSubmitQualityResult(String result) {
|
|
|
+ if (work_status != 1 || !check_quality_result) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getUser();
|
|
|
+ String sn = product_sn.getText().trim();
|
|
|
+ if (sn.isEmpty()) {
|
|
|
+ setMenuStatus("工件码为空,请重试", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ disableManualResultButtons();
|
|
|
+ PlcService.setAllowWork(false);
|
|
|
+ setMenuStatus("正在提交" + result + "结果...", 0);
|
|
|
+
|
|
|
JSONObject retObj = DataUtil.sendQuality(sn, result, user20);
|
|
|
if (retObj == null) {
|
|
|
String oprno = mes_gw == null ? "" : mes_gw.trim();
|
|
|
@@ -647,13 +686,13 @@ public class MesClient extends JFrame {
|
|
|
+ "&result=" + result + "&ucode=" + user20;
|
|
|
JdbcUtils.insertSubmitRecord(oprno, sn, bw);
|
|
|
setMenuStatus("总结果提交失败,已保存到本地待重试", -1);
|
|
|
- jobSubmitting = false;
|
|
|
+ enableManualResultButtons();
|
|
|
return;
|
|
|
}
|
|
|
if (retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
resetJobCompleteSignalAfterUpload();
|
|
|
resetScanA();
|
|
|
- setMenuStatus("提交成功,请扫下一件", 0);
|
|
|
+ setMenuStatus("结果提交成功,请扫下一件", 0);
|
|
|
scan_type = 1;
|
|
|
scanBarcode();
|
|
|
} else {
|
|
|
@@ -662,34 +701,7 @@ public class MesClient extends JFrame {
|
|
|
} else if (retObj.get("result").toString().equalsIgnoreCase("false")) {
|
|
|
setMenuStatus(retObj.getString("message"), -1);
|
|
|
}
|
|
|
- jobSubmitting = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private static void retryPendingRivetUploads() {
|
|
|
- List<String> pendingSnList = JdbcUtils.getPendingRivetSnList();
|
|
|
- if (pendingSnList.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
- getUser();
|
|
|
- String currentSn = product_sn.getText().trim();
|
|
|
- for (String sn : pendingSnList) {
|
|
|
- List<JdbcUtils.RivetRecordItem> points = JdbcUtils.getRivetRecordsBySn(sn);
|
|
|
- if (points.isEmpty()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!sn.equals(currentSn) || !jobCompleteReceived) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!uploadRivetBatchToMes(sn, points)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (jobSubmitting) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- jobSubmitting = true;
|
|
|
- final String result = computeOverallResult();
|
|
|
- SwingUtilities.invokeLater(() -> submitOverallResult(sn, result));
|
|
|
+ enableManualResultButtons();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -714,7 +726,6 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
|
|
|
getUser();
|
|
|
- final String result = computeOverallResult();
|
|
|
final List<JdbcUtils.RivetRecordItem> points = buildRivetPointsFromTable();
|
|
|
System.out.println("[上传MES] 压铆参数 sn=" + sn + ":");
|
|
|
for (JdbcUtils.RivetRecordItem item : points) {
|
|
|
@@ -724,11 +735,12 @@ public class MesClient extends JFrame {
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
setMenuStatus("作业完成,正在上传压铆参数...", 0);
|
|
|
if (!uploadRivetBatchToMes(sn, points)) {
|
|
|
- setMenuStatus("压铆参数上传失败,已保存本地待重试", -1);
|
|
|
- jobSubmitting = false;
|
|
|
- return;
|
|
|
+ setMenuStatus("压铆参数上传失败,已保存本地待重试,请人工确认OK/NG", -1);
|
|
|
+ } else {
|
|
|
+ setMenuStatus("压铆参数已上传,请人工确认OK/NG", 0);
|
|
|
}
|
|
|
- submitOverallResult(sn, result);
|
|
|
+ jobSubmitting = false;
|
|
|
+ enableManualResultButtons();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -842,8 +854,7 @@ public class MesClient extends JFrame {
|
|
|
MesClient.status_menu.setForeground(Color.GREEN);
|
|
|
MesClient.work_status = 1;
|
|
|
MesClient.f_scan_data_bt_1.setEnabled(false);
|
|
|
- MesClient.finish_ok_bt.setEnabled(false);
|
|
|
- MesClient.finish_ng_bt.setEnabled(false);
|
|
|
+ disableManualResultButtons();
|
|
|
MesClient.setMenuStatus("质量合格,已允许设备作业,等待作业完成信号", 0);
|
|
|
}else{
|
|
|
MesClient.check_quality_result = false;
|
|
|
@@ -1031,6 +1042,7 @@ public class MesClient extends JFrame {
|
|
|
toolBar.add(plc_status_menu);
|
|
|
|
|
|
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);
|
|
|
@@ -1069,7 +1081,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
fxlabel = new JLabel("该工件为返修件,请仔细检查");
|
|
|
fxlabel.setFont(new Font("微软雅黑", Font.PLAIN, 38));
|
|
|
- fxlabel.setBounds(81, 160, 810, 50);
|
|
|
+ fxlabel.setBounds(81, 145, 810, 50);
|
|
|
fxlabel.setForeground(Color.RED);
|
|
|
fxlabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
fxlabel.setVisible(false);
|
|
|
@@ -1085,48 +1097,19 @@ public class MesClient extends JFrame {
|
|
|
rivetTable.setRowHeight(30);
|
|
|
rivetTable.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
JScrollPane rivetScrollPane = new JScrollPane(rivetTable);
|
|
|
- rivetScrollPane.setBounds(81, 220, 810, 240);
|
|
|
+ rivetScrollPane.setBounds(81, 150, 810, 220);
|
|
|
indexPanelA.add(rivetScrollPane);
|
|
|
|
|
|
finish_ok_bt = new JButton("OK");
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
finish_ok_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- if(work_status == 1 && check_quality_result){
|
|
|
- getUser();
|
|
|
- String sn = MesClient.product_sn.getText().trim();
|
|
|
- if(sn.isEmpty()){
|
|
|
- MesClient.setMenuStatus("工件码为空,请重试",-1);
|
|
|
- return;
|
|
|
- }
|
|
|
- PlcService.setAllowWork(false);
|
|
|
-
|
|
|
- JSONObject retObj = DataUtil.sendQuality(sn,"OK",user20);
|
|
|
- if(retObj == null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- return;
|
|
|
- }
|
|
|
- System.out.println(retObj);
|
|
|
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- MesClient.resetScanA();
|
|
|
- MesClient.setMenuStatus("结果提交成功,请扫下一件",0);
|
|
|
- MesClient.scan_type = 1;
|
|
|
- MesClient.scanBarcode();
|
|
|
- }else{
|
|
|
- if(retObj.get("result")==null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- }else{
|
|
|
- if(retObj.get("result").toString().equalsIgnoreCase("false")){
|
|
|
- MesClient.setMenuStatus(retObj.getString("message"),-1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ manualSubmitQualityResult("OK");
|
|
|
}
|
|
|
});
|
|
|
finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
|
|
|
finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
- finish_ok_bt.setBounds(185, 480, 240, 70);
|
|
|
+ finish_ok_bt.setBounds(185, 385, 240, 70);
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
indexPanelA.add(finish_ok_bt);
|
|
|
|
|
|
@@ -1134,53 +1117,24 @@ public class MesClient extends JFrame {
|
|
|
finish_ng_bt.setEnabled(false);
|
|
|
finish_ng_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- if(work_status == 1 && check_quality_result){
|
|
|
- getUser();
|
|
|
- String sn = MesClient.product_sn.getText().trim();
|
|
|
- if(sn.isEmpty()){
|
|
|
- MesClient.setMenuStatus("工件码为空,请重试",-1);
|
|
|
- return;
|
|
|
- }
|
|
|
- PlcService.setAllowWork(false);
|
|
|
-
|
|
|
- JSONObject retObj = DataUtil.sendQuality(sn,"NG",user20);
|
|
|
- if(retObj == null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- return;
|
|
|
- }
|
|
|
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- MesClient.resetScanA();
|
|
|
- MesClient.setMenuStatus("结果提交成功,请扫下一件",0);
|
|
|
- MesClient.scan_type = 1;
|
|
|
- MesClient.scanBarcode();
|
|
|
- }else{
|
|
|
- if(retObj.get("result")==null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- }else{
|
|
|
- if(retObj.get("result").toString().equalsIgnoreCase("false")){
|
|
|
- MesClient.setMenuStatus(retObj.getString("message"),-1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ manualSubmitQualityResult("NG");
|
|
|
}
|
|
|
});
|
|
|
finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
|
|
|
finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
|
|
|
- finish_ng_bt.setBounds(508, 480, 240, 70);
|
|
|
+ finish_ng_bt.setBounds(508, 385, 240, 70);
|
|
|
finish_ng_bt.setEnabled(false);
|
|
|
indexPanelA.add(finish_ng_bt);
|
|
|
+ indexPanelA.setPreferredSize(new Dimension(990, 470));
|
|
|
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
tabbedPane.setEnabledAt(0, true);
|
|
|
|
|
|
// searchScrollPane = new JScrollPane((Component) null);
|
|
|
|
|
|
- indexPanelC = new JPanel();
|
|
|
- searchScrollPaneDj = new JScrollPane(indexPanelC);
|
|
|
- indexPanelC.setLayout(null);
|
|
|
+ indexPanelC = new JPanel(new BorderLayout());
|
|
|
|
|
|
- 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")), indexPanelC, null);
|
|
|
|
|
|
|
|
|
// ========== 工作记录 Tab(改造:当前工位Tab + 所有工位Tab) ==========
|