|
|
@@ -544,33 +544,102 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 提交工件码进行质量询问(手动扫码与后台拉码共用)
|
|
|
+ // 提交工件码进行质量询问(手动扫码与后台拉码共用,HTTP pccheck)
|
|
|
public static boolean submitSnForQualityCheck(String scanBarcode, boolean fromBackend) {
|
|
|
- getUser();
|
|
|
- String barcode36 = getBarcode(scanBarcode);
|
|
|
product_sn.setText(scanBarcode);
|
|
|
curSn = scanBarcode;
|
|
|
backendPollingSn = scanBarcode.trim();
|
|
|
lastRejectedBackendSn = "";
|
|
|
mesClientFrame.repaint();
|
|
|
|
|
|
- if (!tcp_connect_flag) {
|
|
|
+ if (sessionid == null || sessionid.isEmpty()) {
|
|
|
backendPollingSn = "";
|
|
|
- setMenuStatus("设备未连接Mes服务器", -1);
|
|
|
+ setMenuStatus("请先登录", -1);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- Boolean sendret = DataUtil.checkQuality(nettyClient, barcode36, user20);
|
|
|
- if (!sendret) {
|
|
|
+ String user = user_menu.getText().trim();
|
|
|
+ JSONObject retObj = DataUtil.checkQuality(scanBarcode.trim(), user);
|
|
|
+ if (retObj != null && retObj.get("result") != null
|
|
|
+ && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
backendPollingSn = "";
|
|
|
- setMenuStatus("消息发送失败,请重试", -1);
|
|
|
- return false;
|
|
|
+ status_menu.setForeground(Color.GREEN);
|
|
|
+ check_quality_result = true;
|
|
|
+ work_status = 1;
|
|
|
+ tjStatus = 0;
|
|
|
+ finish_ok_bt.setEnabled(true);
|
|
|
+ finish_ng_bt.setEnabled(true);
|
|
|
+
|
|
|
+ String msg = retObj.getString("message");
|
|
|
+ if (fromBackend) {
|
|
|
+ setMenuStatus(msg != null && !msg.isEmpty() ? msg : "已从后台获取工件码,可以加工", 0);
|
|
|
+ } else {
|
|
|
+ setMenuStatus(msg != null && !msg.isEmpty() ? msg : "该工件可以加工", 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModbusUtil.setPowerOn(plcA);
|
|
|
+ ModbusUtil.setPowerOn(plcB);
|
|
|
+ ModbusUtil.setTask(plcA, aSetNum, "A");
|
|
|
+ ModbusUtil.setTask(plcB, bSetNum, "B");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ check_quality_result = false;
|
|
|
+ work_status = 0;
|
|
|
+ backendPollingSn = "";
|
|
|
+ if (!curSn.isEmpty()) {
|
|
|
+ lastRejectedBackendSn = curSn.trim();
|
|
|
}
|
|
|
+ clearBackendCurSn();
|
|
|
+ product_sn.setText("");
|
|
|
+ curSn = "";
|
|
|
|
|
|
- if (fromBackend) {
|
|
|
- setMenuStatus("已从后台获取工件码,质量检查中", 0);
|
|
|
+ if (retObj == null || retObj.get("result") == null) {
|
|
|
+ setMenuStatus("质量检查请求失败,请重试", -1);
|
|
|
+ } else if (retObj.get("result").toString().equalsIgnoreCase("false")) {
|
|
|
+ String msg = retObj.getString("message");
|
|
|
+ setMenuStatus(msg != null && !msg.isEmpty() ? msg : "该工件不能加工", -1);
|
|
|
+ } else {
|
|
|
+ setMenuStatus("质量检查失败,请重试", -1);
|
|
|
+ }
|
|
|
+
|
|
|
+ ModbusUtil.setPowerOff(plcA);
|
|
|
+ ModbusUtil.setPowerOff(plcB);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交质量结果(HTTP pcresult)
|
|
|
+ public static void submitQualityResult(String result) {
|
|
|
+ if (work_status != 1 || !check_quality_result) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String sn = product_sn.getText().trim();
|
|
|
+ if (sn.isEmpty()) {
|
|
|
+ setMenuStatus("工件码为空,请重试", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (sessionid == null || sessionid.isEmpty()) {
|
|
|
+ setMenuStatus("请先登录", -1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ String user = user_menu.getText().trim();
|
|
|
+ JSONObject retObj = DataUtil.sendQuality(sn, result, user);
|
|
|
+ if (retObj != null && retObj.get("result") != null
|
|
|
+ && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ resetScanA();
|
|
|
+ setMenuStatus("结果提交成功,等待下一件", 0);
|
|
|
+ } else {
|
|
|
+ tjStatus = 0;
|
|
|
+ if (retObj == null || retObj.get("result") == null) {
|
|
|
+ setMenuStatus("结果提交失败,请重试", -1);
|
|
|
+ } else if (retObj.get("result").toString().equalsIgnoreCase("false")) {
|
|
|
+ String msg = retObj.getString("message");
|
|
|
+ setMenuStatus(msg != null && !msg.isEmpty() ? msg : "结果提交失败,请重试", -1);
|
|
|
+ } else {
|
|
|
+ setMenuStatus("结果提交失败,请重试", -1);
|
|
|
+ }
|
|
|
}
|
|
|
- return true;
|
|
|
}
|
|
|
|
|
|
public static void resetScanA() {
|
|
|
@@ -858,19 +927,7 @@ public class MesClient extends JFrame {
|
|
|
finish_ok_bt.setEnabled(false);
|
|
|
finish_ok_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- if(work_status == 1 && check_quality_result){
|
|
|
-
|
|
|
- String sn = getBarcode(product_sn.getText());
|
|
|
- getUser();
|
|
|
-
|
|
|
- String qret = "OK";
|
|
|
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20);
|
|
|
- if(!sendret){
|
|
|
- MesClient.setMenuStatus("消息发送失败,请重试",-1);
|
|
|
-// JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ submitQualityResult("OK");
|
|
|
}
|
|
|
});
|
|
|
finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
|
|
|
@@ -884,18 +941,7 @@ 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){
|
|
|
-
|
|
|
- String sn = getBarcode(product_sn.getText());
|
|
|
- getUser();
|
|
|
- String qret = "NG";
|
|
|
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20);
|
|
|
- if(!sendret){
|
|
|
- MesClient.setMenuStatus("消息发送失败,请重试",-1);
|
|
|
-// JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
+ submitQualityResult("NG");
|
|
|
}
|
|
|
});
|
|
|
finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
|