|
|
@@ -47,6 +47,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static int mes_auth = 0;
|
|
|
public static String mes_gw = "";
|
|
|
+ public static String mes_gw1 = ""; // A面对应工位
|
|
|
+ public static String mes_gw2 = ""; // B面对应工位
|
|
|
public static String mes_gw_des = "";
|
|
|
public static String mes_server_ip = "";
|
|
|
public static int mes_tcp_port = 3000;
|
|
|
@@ -117,6 +119,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static Boolean mesQualityFlagB = false; // true=可工作
|
|
|
|
|
|
+ public static String scanOprno = "";
|
|
|
|
|
|
public static String user20 = "";
|
|
|
|
|
|
@@ -157,6 +160,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
//获取当前面
|
|
|
textFocus();
|
|
|
+ // 扫码
|
|
|
+ startScanTimer();
|
|
|
|
|
|
// 获取PLC 加工状态参数
|
|
|
getPlcParam();
|
|
|
@@ -186,8 +191,10 @@ public class MesClient extends JFrame {
|
|
|
MesClient.curPage = PlcUtil.getCurAside(s7PLC);
|
|
|
if(MesClient.curPage .equals("A")){
|
|
|
page_text.setText("当前:A面");
|
|
|
+ scanOprno = mes_gw1;
|
|
|
}else{
|
|
|
page_text.setText("当前:B面");
|
|
|
+ scanOprno = mes_gw2;
|
|
|
}
|
|
|
}
|
|
|
}, 1000,1000);
|
|
|
@@ -265,6 +272,50 @@ public class MesClient extends JFrame {
|
|
|
}, 1000,500);
|
|
|
}
|
|
|
|
|
|
+ // 扫码定时任务
|
|
|
+ public static Timer ScanTimer;
|
|
|
+ public static void startScanTimer() {
|
|
|
+ if(ScanTimer!=null) {
|
|
|
+ ScanTimer.cancel();
|
|
|
+ }
|
|
|
+ ScanTimer = new Timer();
|
|
|
+ ScanTimer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ JSONObject result = DataUtil.getCurSn(scanOprno, MesClient.mes_server_ip, MesClient.mes_line_sn);
|
|
|
+ if (result != null || result.getString("result").equalsIgnoreCase("true")){
|
|
|
+ // 看是否成功
|
|
|
+ if (result.get("result") != null && result.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ String sn = result.getString("data");
|
|
|
+ MesClient.curSna = sn;
|
|
|
+ if (sn != null && !sn.equals("")) {
|
|
|
+ // 质量检查
|
|
|
+ JSONObject result2 = DataUtil.checkQuality(sn,MesClient.user20,scanOprno,MesClient.mes_line_sn,MesClient.mes_server_ip);
|
|
|
+ if (result2 != null){
|
|
|
+ if (result2.get("result") != null && result2.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ // 允许做件
|
|
|
+ if (scanOprno != null && !scanOprno.equals(MesClient.mes_gw1)){
|
|
|
+ MesClient.mesQualityFlagA = true;
|
|
|
+ MesClient.tjFlaga = 1;
|
|
|
+ MesClient.setMenuStatus("A:可以加工,等待设备启动",0);
|
|
|
+ }else if (scanOprno != null && scanOprno.equals(MesClient.mes_gw2)){
|
|
|
+ MesClient.mesQualityFlagB = true;
|
|
|
+ MesClient.tjFlagb = 1;
|
|
|
+ MesClient.setMenuStatus("B:可以加工,等待设备启动",0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else {
|
|
|
+ // 不允许做件
|
|
|
+ MesClient.setMenuStatus(result2.getString("message"),-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000,500);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private static void readProperty() throws IOException{
|
|
|
String enconding = "UTF-8";
|
|
|
@@ -273,6 +324,8 @@ public class MesClient extends JFrame {
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
pro.load(br);
|
|
|
mes_gw = pro.getProperty("mes.gw");
|
|
|
+ mes_gw1 = pro.getProperty("mes.gw1");
|
|
|
+ mes_gw2 = pro.getProperty("mes.gw2");
|
|
|
|
|
|
// mes_gw_des = pro.getProperty("mes.gw_des");
|
|
|
mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
@@ -285,6 +338,7 @@ public class MesClient extends JFrame {
|
|
|
mes_gwflag = pro.getProperty("mes.gwflag");
|
|
|
|
|
|
System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
|
|
|
+ System.out.println("mes_gw1=" + mes_gw1 + ", mes_gw2=" + mes_gw2);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -608,8 +662,7 @@ public class MesClient extends JFrame {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
super.mouseClicked(e);
|
|
|
- finish_ok_bt.setEnabled(true);
|
|
|
- finish_ng_bt.setEnabled(true);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
});
|
|
|
@@ -622,8 +675,7 @@ public class MesClient extends JFrame {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
super.mouseClicked(e);
|
|
|
- finish_ok_bt2.setEnabled(true);
|
|
|
- finish_ng_bt2.setEnabled(true);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
});
|
|
|
@@ -764,19 +816,19 @@ public class MesClient extends JFrame {
|
|
|
finish_ng_bt.setEnabled(false);
|
|
|
finish_ng_bt.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
- String sn = getBarcode(product_sn2.getText());
|
|
|
+ String sn = getBarcode(product_sn.getText());
|
|
|
getUser();
|
|
|
|
|
|
if(!sn.isEmpty()){
|
|
|
- String qret = "OK";
|
|
|
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,"B");
|
|
|
+ String qret = "NG";
|
|
|
+ Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,"A");
|
|
|
if(!sendret){
|
|
|
- MesClient.pxstatus2.setText("B:结果上传MES失败");
|
|
|
- MesClient.tjStatusb = 1;
|
|
|
+ MesClient.pxstatus1.setText("A:结果上传MES失败");
|
|
|
+ MesClient.tjStatusa = 1;
|
|
|
}else{
|
|
|
- MesClient.pxstatus2.setText("B:提交成功");
|
|
|
- MesClient.status_menu.setText("B件提交成功");
|
|
|
- MesClient.resetScanB();
|
|
|
+ MesClient.pxstatus1.setText("A:提交成功");
|
|
|
+ MesClient.status_menu.setText("A件提交成功");
|
|
|
+ MesClient.resetScanA();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -797,7 +849,7 @@ public class MesClient extends JFrame {
|
|
|
//
|
|
|
//
|
|
|
// }
|
|
|
- String sn = getBarcode(product_sn.getText());
|
|
|
+ String sn = getBarcode(product_sn2.getText());
|
|
|
getUser();
|
|
|
|
|
|
if(!sn.isEmpty()){
|
|
|
@@ -854,14 +906,14 @@ public class MesClient extends JFrame {
|
|
|
lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel.setBounds(26, 340, 100, 40);
|
|
|
- lblNewLabel.setVisible(false);
|
|
|
+ lblNewLabel.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel);
|
|
|
|
|
|
JLabel lblNewLabel_1 = new JLabel("电流");
|
|
|
lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1.setBounds(226, 340, 100, 40);
|
|
|
- lblNewLabel_1.setVisible(false);
|
|
|
+ lblNewLabel_1.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1);
|
|
|
|
|
|
param1 = new JTextField();
|
|
|
@@ -870,7 +922,7 @@ public class MesClient extends JFrame {
|
|
|
param1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
param1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param1.setBounds(136, 340, 70, 40);
|
|
|
- param1.setVisible(false);
|
|
|
+ param1.setVisible(true);
|
|
|
indexPanelA.add(param1);
|
|
|
param1.setColumns(10);
|
|
|
|
|
|
@@ -881,14 +933,14 @@ public class MesClient extends JFrame {
|
|
|
param2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param2.setColumns(10);
|
|
|
param2.setBounds(345, 340, 70, 40);
|
|
|
- param2.setVisible(false);
|
|
|
+ param2.setVisible(true);
|
|
|
indexPanelA.add(param2);
|
|
|
|
|
|
JLabel lblNewLabel_2 = new JLabel("送丝速度");
|
|
|
lblNewLabel_2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_2.setBounds(26, 401, 100, 40);
|
|
|
- lblNewLabel_2.setVisible(false);
|
|
|
+ lblNewLabel_2.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_2);
|
|
|
|
|
|
param3 = new JTextField();
|
|
|
@@ -898,14 +950,14 @@ public class MesClient extends JFrame {
|
|
|
param3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param3.setColumns(10);
|
|
|
param3.setBounds(136, 401, 70, 40);
|
|
|
- param3.setVisible(false);
|
|
|
+ param3.setVisible(true);
|
|
|
indexPanelA.add(param3);
|
|
|
|
|
|
JLabel lblNewLabel_1_1 = new JLabel("错误代码");
|
|
|
lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1_1.setBounds(213, 401, 122, 40);
|
|
|
- lblNewLabel_1_1.setVisible(false);
|
|
|
+ lblNewLabel_1_1.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1_1);
|
|
|
|
|
|
param4 = new JTextField();
|
|
|
@@ -915,7 +967,7 @@ public class MesClient extends JFrame {
|
|
|
param4.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param4.setColumns(10);
|
|
|
param4.setBounds(345, 401, 70, 40);
|
|
|
- param4.setVisible(false);
|
|
|
+ param4.setVisible(true);
|
|
|
indexPanelA.add(param4);
|
|
|
|
|
|
param5 = new JTextField();
|
|
|
@@ -925,14 +977,14 @@ public class MesClient extends JFrame {
|
|
|
param5.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param5.setColumns(10);
|
|
|
param5.setBounds(226, 470, 70, 40);
|
|
|
- param5.setVisible(false);
|
|
|
+ param5.setVisible(true);
|
|
|
indexPanelA.add(param5);
|
|
|
|
|
|
JLabel lblNewLabel_1_1_1 = new JLabel("JOB号");
|
|
|
lblNewLabel_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1_1_1.setBounds(106, 470, 122, 40);
|
|
|
- lblNewLabel_1_1_1.setVisible(false);
|
|
|
+ lblNewLabel_1_1_1.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1_1_1);
|
|
|
|
|
|
product_sn2 = new JTextField();
|
|
|
@@ -957,7 +1009,7 @@ public class MesClient extends JFrame {
|
|
|
lblNewLabel_3.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_3.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_3.setBounds(528, 340, 100, 40);
|
|
|
- lblNewLabel_3.setVisible(false);
|
|
|
+ lblNewLabel_3.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_3);
|
|
|
|
|
|
param21 = new JTextField();
|
|
|
@@ -967,14 +1019,14 @@ public class MesClient extends JFrame {
|
|
|
param21.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param21.setColumns(10);
|
|
|
param21.setBounds(638, 340, 70, 40);
|
|
|
- param21.setVisible(false);
|
|
|
+ param21.setVisible(true);
|
|
|
indexPanelA.add(param21);
|
|
|
|
|
|
JLabel lblNewLabel_1_2 = new JLabel("电流");
|
|
|
lblNewLabel_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1_2.setBounds(742, 340, 100, 40);
|
|
|
- lblNewLabel_1_2.setVisible(false);
|
|
|
+ lblNewLabel_1_2.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1_2);
|
|
|
|
|
|
param22 = new JTextField();
|
|
|
@@ -984,14 +1036,14 @@ public class MesClient extends JFrame {
|
|
|
param22.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param22.setColumns(10);
|
|
|
param22.setBounds(852, 340, 70, 40);
|
|
|
- param22.setVisible(false);
|
|
|
+ param22.setVisible(true);
|
|
|
indexPanelA.add(param22);
|
|
|
|
|
|
JLabel lblNewLabel_2_1 = new JLabel("送丝速度");
|
|
|
lblNewLabel_2_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_2_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_2_1.setBounds(528, 401, 100, 40);
|
|
|
- lblNewLabel_2_1.setVisible(false);
|
|
|
+ lblNewLabel_2_1.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_2_1);
|
|
|
|
|
|
param23 = new JTextField();
|
|
|
@@ -1001,14 +1053,14 @@ public class MesClient extends JFrame {
|
|
|
param23.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param23.setColumns(10);
|
|
|
param23.setBounds(638, 401, 70, 40);
|
|
|
- param23.setVisible(false);
|
|
|
+ param23.setVisible(true);
|
|
|
indexPanelA.add(param23);
|
|
|
|
|
|
JLabel lblNewLabel_1_1_2 = new JLabel("错误代码");
|
|
|
lblNewLabel_1_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1_1_2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1_1_2.setBounds(718, 401, 122, 40);
|
|
|
- lblNewLabel_1_1_2.setVisible(false);
|
|
|
+ lblNewLabel_1_1_2.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1_1_2);
|
|
|
|
|
|
param24 = new JTextField();
|
|
|
@@ -1018,15 +1070,14 @@ public class MesClient extends JFrame {
|
|
|
param24.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param24.setColumns(10);
|
|
|
param24.setBounds(852, 401, 70, 40);
|
|
|
- param24.setVisible(false);
|
|
|
+ param24.setVisible(true);
|
|
|
indexPanelA.add(param24);
|
|
|
|
|
|
JLabel lblNewLabel_1_1_1_1 = new JLabel("JOB号");
|
|
|
lblNewLabel_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
lblNewLabel_1_1_1_1.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
lblNewLabel_1_1_1_1.setBounds(609, 470, 122, 40);
|
|
|
- lblNewLabel_1_1_1_1.setVisible(false);
|
|
|
- lblNewLabel_1_1_1_1.setVisible(false);
|
|
|
+ lblNewLabel_1_1_1_1.setVisible(true);
|
|
|
indexPanelA.add(lblNewLabel_1_1_1_1);
|
|
|
|
|
|
param25 = new JTextField();
|
|
|
@@ -1036,7 +1087,7 @@ public class MesClient extends JFrame {
|
|
|
param25.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 18));
|
|
|
param25.setColumns(10);
|
|
|
param25.setBounds(742, 470, 70, 40);
|
|
|
- param25.setVisible(false);
|
|
|
+ param25.setVisible(true);
|
|
|
indexPanelA.add(param25);
|
|
|
|
|
|
pxstatus1 = new JLabel("A");
|