|
|
@@ -623,27 +623,59 @@ public class MesClient extends JFrame {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
if (work_status == 1) {
|
|
|
- // TODO
|
|
|
- // 加入工作流程
|
|
|
- if (plc_status == 0){
|
|
|
- // 等待扫码
|
|
|
- String sn = product_sn.getText().trim();
|
|
|
- if (sn.isEmpty()) {
|
|
|
- plc_status = 1;
|
|
|
- }
|
|
|
- } else if (plc_status == 1) {
|
|
|
- // 发送允许启动信号
|
|
|
- Boolean ret = PLCUtils.writeStartMethod(plc);
|
|
|
- if (ret) {
|
|
|
- plc_status = 2;
|
|
|
- }
|
|
|
- } else if (plc_status == 2) {
|
|
|
- // 等待加工结束信号
|
|
|
- Boolean ret = PLCUtils.readStopMethod(plc);
|
|
|
- if (ret){
|
|
|
- // 将允许启动置空
|
|
|
- PLCUtils.writeStopMethod(plc);
|
|
|
- // 获取参数
|
|
|
+
|
|
|
+// if (plc_status == 0){
|
|
|
+// // 等待扫码
|
|
|
+// String sn = product_sn.getText().trim();
|
|
|
+// if (sn.isEmpty()) {
|
|
|
+// plc_status = 1;
|
|
|
+// }
|
|
|
+// } else if (plc_status == 1) {
|
|
|
+// // 发送允许启动信号
|
|
|
+// Boolean ret = PLCUtils.writeStartMethod(plc);
|
|
|
+// if (ret) {
|
|
|
+// plc_status = 2;
|
|
|
+// }
|
|
|
+// } else if (plc_status == 2) {
|
|
|
+// // 等待加工结束信号
|
|
|
+// Boolean ret = PLCUtils.readStopMethod(plc);
|
|
|
+// if (ret){
|
|
|
+// // 将允许启动置空
|
|
|
+// PLCUtils.writeStopMethod(plc);
|
|
|
+// // 获取参数
|
|
|
+// QmParam qmParam = PLCUtils.getParameter(plc);
|
|
|
+// // 发送参数
|
|
|
+// JSONObject retObj1 = DataUtil.sendQualityParam( user20, product_sn.getText().trim(), MesClient.mes_gw, MesClient.mes_line_sn,qmParam);
|
|
|
+// if(retObj1 != null && retObj1.get("result") != null && retObj1.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+// MesClient.resetScanA();
|
|
|
+// MesClient.setMenuStatus("测试结果上传成功,请扫下一件",0);
|
|
|
+// }else{
|
|
|
+// MesClient.setMenuStatus("测试结果上传失败,请重试",-1);
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// // 获取结果
|
|
|
+// String result = PLCUtils.getResult(plc);
|
|
|
+// // 发送结果
|
|
|
+// String sn = product_sn.getText().trim();
|
|
|
+// JSONObject retObj = DataUtil.sendQuality( sn,result,user20);
|
|
|
+// if (retObj != null && "true".equalsIgnoreCase(retObj.getString("result"))) {
|
|
|
+// resetState();
|
|
|
+// status_menu.setForeground(Color.GREEN);
|
|
|
+// status_menu.setText("结果提交成功,请扫下一件");
|
|
|
+// finish_ng_bt.setEnabled(false);
|
|
|
+// } else {
|
|
|
+// status_menu.setForeground(Color.RED);
|
|
|
+// String msg = (retObj != null && retObj.containsKey("message")) ? retObj.getString("message") : "提交失败";
|
|
|
+// status_menu.setText(msg);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ // 获取结果
|
|
|
+ String result = PLCUtils.getResult(plc);
|
|
|
+ // 如果等于OK或者NG的时候才处理结果
|
|
|
+ if("OK".equals(result)){
|
|
|
+ // 获取参数
|
|
|
QmParam qmParam = PLCUtils.getParameter(plc);
|
|
|
// 发送参数
|
|
|
JSONObject retObj1 = DataUtil.sendQualityParam( user20, product_sn.getText().trim(), MesClient.mes_gw, MesClient.mes_line_sn,qmParam);
|
|
|
@@ -652,11 +684,7 @@ public class MesClient extends JFrame {
|
|
|
MesClient.setMenuStatus("测试结果上传成功,请扫下一件",0);
|
|
|
}else{
|
|
|
MesClient.setMenuStatus("测试结果上传失败,请重试",-1);
|
|
|
- return;
|
|
|
}
|
|
|
- // 获取结果
|
|
|
- String result = PLCUtils.getResult(plc);
|
|
|
- // 发送结果
|
|
|
String sn = product_sn.getText().trim();
|
|
|
JSONObject retObj = DataUtil.sendQuality( sn,result,user20);
|
|
|
if (retObj != null && "true".equalsIgnoreCase(retObj.getString("result"))) {
|
|
|
@@ -669,8 +697,22 @@ public class MesClient extends JFrame {
|
|
|
String msg = (retObj != null && retObj.containsKey("message")) ? retObj.getString("message") : "提交失败";
|
|
|
status_menu.setText(msg);
|
|
|
}
|
|
|
+ } else if ("NG".equals(result)) {
|
|
|
+ String sn = product_sn.getText().trim();
|
|
|
+ JSONObject retObj = DataUtil.sendQuality( sn,result,user20);
|
|
|
+ if (retObj != null && "true".equalsIgnoreCase(retObj.getString("result"))) {
|
|
|
+ resetState();
|
|
|
+ status_menu.setForeground(Color.GREEN);
|
|
|
+ status_menu.setText("结果提交成功,请扫下一件");
|
|
|
+ finish_ng_bt.setEnabled(false);
|
|
|
+ } else {
|
|
|
+ status_menu.setForeground(Color.RED);
|
|
|
+ String msg = (retObj != null && retObj.containsKey("message")) ? retObj.getString("message") : "提交失败";
|
|
|
+ status_menu.setText(msg);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
} else if (work_status == 0) {
|
|
|
JSONObject result = DataUtil.getCurSn(mes_gw, mes_server_ip, mes_line_sn);
|
|
|
// 正常处理结果
|