|
|
@@ -1,142 +1,173 @@
|
|
|
-package com.mes.ui;
|
|
|
-
|
|
|
-import com.mes.netty.ProtocolParam;
|
|
|
-
|
|
|
-import java.awt.*;
|
|
|
-
|
|
|
-public class MesRevice {
|
|
|
-
|
|
|
- private static boolean isColdPlateCraft(String craft) {
|
|
|
- return "400006".equals(craft != null ? craft.trim() : "");
|
|
|
- }
|
|
|
-
|
|
|
- private static boolean isUnbindSuccess(String processMsgRet) {
|
|
|
- if (processMsgRet == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- String ret = processMsgRet.trim();
|
|
|
- return ret.equalsIgnoreCase("OK")
|
|
|
- || ret.equalsIgnoreCase("UD")
|
|
|
- || ret.equalsIgnoreCase("UF")
|
|
|
- || ret.equalsIgnoreCase("UDF");
|
|
|
- }
|
|
|
-
|
|
|
- // 质量查询
|
|
|
- public static void checkQualityRevice(String processMsgRet, String mes_msg) {
|
|
|
- try {
|
|
|
- String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
- MesClient.checkSnType(sn);
|
|
|
-
|
|
|
- if (processMsgRet.equalsIgnoreCase("UD")) {
|
|
|
- MesClient.status_menu.setForeground(Color.GREEN);
|
|
|
- MesClient.check_quality_result = true;
|
|
|
- MesClient.setMenuStatus("该工件可以加工", 0);
|
|
|
-
|
|
|
- if (MesClient.work_status == 0) {
|
|
|
- String barcode36 = MesClient.getBarcode(MesClient.product_sn.getText());
|
|
|
- MesClient.getUser();
|
|
|
- DataUtil.startWork(MesClient.nettyClient, barcode36, MesClient.user20);
|
|
|
- }
|
|
|
- } else {
|
|
|
- MesClient.check_quality_result = false;
|
|
|
- ErrorMsg.setErrorMsg(mes_msg);
|
|
|
- }
|
|
|
-
|
|
|
- if (MesClient.check_quality_result) {
|
|
|
- if (MesClient.work_status == 0) {
|
|
|
- MesClient.finish_ok_bt.setEnabled(false);
|
|
|
- MesClient.finish_ng_bt.setEnabled(false);
|
|
|
- } else {
|
|
|
- MesClient.finish_ok_bt.setEnabled(true);
|
|
|
- MesClient.finish_ng_bt.setEnabled(true);
|
|
|
- }
|
|
|
- } else {
|
|
|
- MesClient.finish_ok_bt.setEnabled(false);
|
|
|
- MesClient.finish_ng_bt.setEnabled(false);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 开始回复处理
|
|
|
- public static void startRevice(String processMsgRet, String mes_msg) {
|
|
|
- try {
|
|
|
- if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
- MesClient.work_status = 1;
|
|
|
- MesClient.f_scan_data_bt_1.setEnabled(false);
|
|
|
- MesClient.tjStatus = 0;
|
|
|
- MesClient.work_status_jqb = 2;
|
|
|
-
|
|
|
- MesClient.f_scan_data_bt_2.setEnabled(true);
|
|
|
- MesClient.setMenuStatus("请扫描冷板码", 0);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 绑定
|
|
|
- public static void bindRevice(String processMsgRet, String mes_msg) {
|
|
|
- try {
|
|
|
- String craft = ProtocolParam.getCraft(mes_msg);
|
|
|
- if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
- if (isColdPlateCraft(craft)) {
|
|
|
- MesClient.setMenuStatus("绑定成功!", 0);
|
|
|
- MesClient.btnUnbindLb.setEnabled(true);
|
|
|
- MesClient.bindLbStatus = true;
|
|
|
- MesClient.f_scan_data_bt_2.setEnabled(false);
|
|
|
-
|
|
|
- MesClient.sortA = 0;
|
|
|
- MesClient.aFinish = 0;
|
|
|
- MesClient.param2.setText("0");
|
|
|
- MesClient.work_status_jqb = 3;
|
|
|
- }
|
|
|
- } else if (isColdPlateCraft(craft) && processMsgRet.equalsIgnoreCase("PZ")) {
|
|
|
- MesClient.setMenuStatus("请先上传密封圈照片,再绑定冷板!", -1);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 解绑
|
|
|
- public static void unbindRevice(String processMsgRet, String mes_msg) {
|
|
|
- try {
|
|
|
- String craft = ProtocolParam.getCraft(mes_msg);
|
|
|
- if (isUnbindSuccess(processMsgRet) && isColdPlateCraft(craft)) {
|
|
|
- MesClient.setMenuStatus("解绑成功!", 0);
|
|
|
- MesClient.clearLbBindUi();
|
|
|
- MesClient.sortA = 0;
|
|
|
- MesClient.aFinish = 0;
|
|
|
- MesClient.param2.setText("0");
|
|
|
- } else if (isColdPlateCraft(craft)) {
|
|
|
- MesClient.setMenuStatus("解绑失败!", -1);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 上传质量
|
|
|
- public static void updateResultRevice(String processMsgRet, String mes_msg) {
|
|
|
- try {
|
|
|
- if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
- try {
|
|
|
- MesClient.s7PLC.writeBoolean("DB32.0.7", true);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- MesClient.resetScanA();
|
|
|
- MesClient.setMenuStatus("结果提交成功,请扫下一件", 0);
|
|
|
- } else {
|
|
|
- MesClient.tjStatus = 1;
|
|
|
- MesClient.finish_ok_bt.setEnabled(true);
|
|
|
- MesClient.finish_ng_bt.setEnabled(true);
|
|
|
- MesClient.setMenuStatus("结果提交失败,请重试", -1);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+package com.mes.ui;
|
|
|
+
|
|
|
+import com.mes.netty.ProtocolParam;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.awt.*;
|
|
|
+
|
|
|
+public class MesRevice {
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(MesRevice.class);
|
|
|
+
|
|
|
+ private static boolean isColdPlateCraft(String craft) {
|
|
|
+ return "400006".equals(craft != null ? craft.trim() : "");
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean isUnbindSuccess(String processMsgRet) {
|
|
|
+ if (processMsgRet == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String ret = processMsgRet.trim();
|
|
|
+ return ret.equalsIgnoreCase("OK")
|
|
|
+ || ret.equalsIgnoreCase("UD")
|
|
|
+ || ret.equalsIgnoreCase("UF")
|
|
|
+ || ret.equalsIgnoreCase("UDF");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 质量查询
|
|
|
+ public static void checkQualityRevice(String processMsgRet, String mes_msg) {
|
|
|
+ try {
|
|
|
+ String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
+ MesClient.checkSnType(sn);
|
|
|
+ log.info("质量查询回包 sn={}, ret={}", sn, processMsgRet);
|
|
|
+
|
|
|
+ if (processMsgRet.equalsIgnoreCase("UD")) {
|
|
|
+ MesClient.status_menu.setForeground(Color.GREEN);
|
|
|
+ MesClient.check_quality_result = true;
|
|
|
+ MesClient.setMenuStatus("该工件可以加工", 0);
|
|
|
+
|
|
|
+ if (MesClient.work_status == 0) {
|
|
|
+ String barcode36 = MesClient.getBarcode(MesClient.product_sn.getText());
|
|
|
+ MesClient.getUser();
|
|
|
+ log.info("质量通过,发送开工 sn={}", barcode36.trim());
|
|
|
+ DataUtil.startWork(MesClient.nettyClient, barcode36, MesClient.user20);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MesClient.check_quality_result = false;
|
|
|
+ log.warn("质量查询不可加工 sn={}, ret={}", sn, processMsgRet);
|
|
|
+ ErrorMsg.setErrorMsg(mes_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (MesClient.check_quality_result) {
|
|
|
+ if (MesClient.work_status == 0) {
|
|
|
+ MesClient.finish_ok_bt.setEnabled(false);
|
|
|
+ MesClient.finish_ng_bt.setEnabled(false);
|
|
|
+ } else {
|
|
|
+ MesClient.finish_ok_bt.setEnabled(true);
|
|
|
+ MesClient.finish_ng_bt.setEnabled(true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MesClient.finish_ok_bt.setEnabled(false);
|
|
|
+ MesClient.finish_ng_bt.setEnabled(false);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("质量查询回包处理异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public static void startRevice(String processMsgRet, String mes_msg) {
|
|
|
+ try {
|
|
|
+ String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
+ log.info("开工回包 sn={}, ret={}", sn, processMsgRet);
|
|
|
+ if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
+ MesClient.work_status = 1;
|
|
|
+ MesClient.f_scan_data_bt_1.setEnabled(false);
|
|
|
+ MesClient.tjStatus = 0;
|
|
|
+ MesClient.work_status_jqb = 2;
|
|
|
+
|
|
|
+ MesClient.f_scan_data_bt_2.setEnabled(true);
|
|
|
+ MesClient.setMenuStatus("请扫描冷板码", 0);
|
|
|
+ } else {
|
|
|
+ log.warn("开工失败 sn={}, ret={}", sn, processMsgRet);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("开工回包处理异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 绑定
|
|
|
+ public static void bindRevice(String processMsgRet, String mes_msg) {
|
|
|
+ try {
|
|
|
+ String craft = ProtocolParam.getCraft(mes_msg);
|
|
|
+ String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
+ log.info("绑定回包 sn={}, craft={}, ret={}", sn, craft, processMsgRet);
|
|
|
+ if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
+ if (isColdPlateCraft(craft)) {
|
|
|
+ MesClient.setMenuStatus("绑定成功!", 0);
|
|
|
+ MesClient.btnUnbindLb.setEnabled(true);
|
|
|
+ MesClient.bindLbStatus = true;
|
|
|
+ MesClient.f_scan_data_bt_2.setEnabled(false);
|
|
|
+
|
|
|
+ MesClient.sortA = 0;
|
|
|
+ MesClient.aFinish = 0;
|
|
|
+ MesClient.param2.setText("0");
|
|
|
+ MesClient.work_status_jqb = 3;
|
|
|
+ log.info("冷板绑定成功 sn={}, lb={}", MesClient.curSn, MesClient.product_sn_lb.getText());
|
|
|
+ }
|
|
|
+ } else if (isColdPlateCraft(craft) && processMsgRet.equalsIgnoreCase("PZ")) {
|
|
|
+ log.warn("冷板绑定失败,需先上传密封圈照片 sn={}", sn);
|
|
|
+ MesClient.setMenuStatus("请先上传密封圈照片,再绑定冷板!", -1);
|
|
|
+ } else if (isColdPlateCraft(craft)) {
|
|
|
+ log.warn("冷板绑定失败 sn={}, ret={}", sn, processMsgRet);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("绑定回包处理异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解绑
|
|
|
+ public static void unbindRevice(String processMsgRet, String mes_msg) {
|
|
|
+ try {
|
|
|
+ String craft = ProtocolParam.getCraft(mes_msg);
|
|
|
+ String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
+ log.info("解绑回包 sn={}, craft={}, ret={}", sn, craft, processMsgRet);
|
|
|
+ if (isUnbindSuccess(processMsgRet) && isColdPlateCraft(craft)) {
|
|
|
+ MesClient.setMenuStatus("解绑成功!", 0);
|
|
|
+ MesClient.clearLbBindUi();
|
|
|
+ MesClient.sortA = 0;
|
|
|
+ MesClient.aFinish = 0;
|
|
|
+ MesClient.param2.setText("0");
|
|
|
+ } else if (isColdPlateCraft(craft)) {
|
|
|
+ log.warn("解绑失败 sn={}, ret={}", sn, processMsgRet);
|
|
|
+ MesClient.setMenuStatus("解绑失败!", -1);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解绑回包处理异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传质量
|
|
|
+ public static void updateResultRevice(String processMsgRet, String mes_msg) {
|
|
|
+ try {
|
|
|
+ String sn = ProtocolParam.getSn(mes_msg).trim();
|
|
|
+ log.info("结果提交回包 sn={}, ret={}, curSn={}, productSn={}, bindLb={}, aFinish={}/{}",
|
|
|
+ sn, processMsgRet, MesClient.curSn, MesClient.product_sn.getText(),
|
|
|
+ MesClient.bindLbStatus, MesClient.aFinish, MesClient.aMax);
|
|
|
+ if (processMsgRet.equalsIgnoreCase("OK")) {
|
|
|
+ try {
|
|
|
+ MesClient.s7PLC.writeBoolean("DB32.0.7", true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("结果提交成功后写 PLC 完成信号失败", e);
|
|
|
+ }
|
|
|
+ MesClient.resetScanA();
|
|
|
+ MesClient.setMenuStatus("结果提交成功,请扫下一件", 0);
|
|
|
+ log.info("结果提交成功 sn={}", sn);
|
|
|
+ } else {
|
|
|
+ MesClient.tjStatus = 1;
|
|
|
+ MesClient.finish_ok_bt.setEnabled(true);
|
|
|
+ MesClient.finish_ng_bt.setEnabled(true);
|
|
|
+ String detail = com.mes.util.ErrorMsg.getErrorMsg(
|
|
|
+ processMsgRet, ProtocolParam.getLx(mes_msg));
|
|
|
+ if (detail == null || detail.isEmpty()
|
|
|
+ || "该工件本工位不可加工".equals(detail)) {
|
|
|
+ detail = (processMsgRet == null || processMsgRet.trim().isEmpty())
|
|
|
+ ? "未知原因" : processMsgRet.trim();
|
|
|
+ }
|
|
|
+ log.error("结果提交失败 sn={}, ret={}, detail={}, msg={}", sn, processMsgRet, detail, mes_msg);
|
|
|
+ MesClient.setMenuStatus("结果提交失败:" + detail, -1);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("结果提交回包处理异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|