|
|
@@ -240,13 +240,7 @@ public class MesClient extends JFrame {
|
|
|
cjTimer.schedule(new TimerTask() {
|
|
|
public void run() {
|
|
|
try{
|
|
|
- if(!MesClient.sessionid.isEmpty()){
|
|
|
- PlcUtil.getStatusA(s7PLC);
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- try{
|
|
|
+ // 只监控 B 面
|
|
|
if(!MesClient.sessionid.isEmpty()){
|
|
|
PlcUtil.getStatusB(s7PLC);
|
|
|
}
|
|
|
@@ -258,7 +252,6 @@ public class MesClient extends JFrame {
|
|
|
}
|
|
|
|
|
|
public static Timer cjTimerText;
|
|
|
- public static String lastDetectedPage = ""; // 记录上次检测到的面
|
|
|
public static void textFocus() {
|
|
|
if(cjTimerText!=null) {
|
|
|
cjTimerText.cancel();
|
|
|
@@ -269,17 +262,24 @@ public class MesClient extends JFrame {
|
|
|
textField.requestFocusInWindow();
|
|
|
|
|
|
String page = PlcUtil.getCurAside(s7PLC);
|
|
|
- if(page.equals("A")){
|
|
|
- lblNewLabel_5.setText("当前:A面");
|
|
|
+ if(page != null && page.equals("B")){
|
|
|
+ // B 面可扫码:绿色背景
|
|
|
+ lblNewLabel_5.setText("当前:B面(可扫码)");
|
|
|
+ lblNewLabel_5.setForeground(new Color(0, 128, 0));
|
|
|
+ if(product_sn2.getText().isEmpty() || product_sn2.getText().contains("请等待")){
|
|
|
+ product_sn2.setText("OP060 - 请扫码");
|
|
|
+ product_sn2.setBackground(new Color(144, 238, 144)); // 浅绿色
|
|
|
+ product_sn2.setForeground(Color.BLACK);
|
|
|
+ }
|
|
|
}else{
|
|
|
- lblNewLabel_5.setText("当前:B面");
|
|
|
- }
|
|
|
-
|
|
|
- // 识别完当前面后,给禁用信号(仅在面切换时执行)
|
|
|
- if(!page.equals(lastDetectedPage)){
|
|
|
- lastDetectedPage = page;
|
|
|
- // Keep reserved start permission; side change only updates display state.
|
|
|
- System.out.println("turntable side changed: " + page + ", keep reserved enable signal");
|
|
|
+ // A 面等待转台:灰色背景
|
|
|
+ lblNewLabel_5.setText("当前:A面(等待转台)");
|
|
|
+ lblNewLabel_5.setForeground(Color.GRAY);
|
|
|
+ if(product_sn2.getText().isEmpty() || product_sn2.getText().contains("请扫码") || product_sn2.getText().contains("请等待")){
|
|
|
+ product_sn2.setText("请等待转到B面扫码");
|
|
|
+ product_sn2.setBackground(Color.LIGHT_GRAY);
|
|
|
+ product_sn2.setForeground(Color.DARK_GRAY);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}, 1000,1000);
|
|
|
@@ -474,7 +474,18 @@ public class MesClient extends JFrame {
|
|
|
check_quality_result2 = false;
|
|
|
MesClient.finish_ng_bt.setEnabled(true);
|
|
|
MesClient.mesQualityFlagB = false;
|
|
|
- product_sn2.setText("");
|
|
|
+
|
|
|
+ // 清空后根据转台位置恢复提示
|
|
|
+ String page = PlcUtil.getCurAside(s7PLC);
|
|
|
+ if(page != null && page.equals("B")){
|
|
|
+ product_sn2.setText("OP060 - 请扫码");
|
|
|
+ product_sn2.setBackground(new Color(144, 238, 144)); // 浅绿色
|
|
|
+ product_sn2.setForeground(Color.BLACK);
|
|
|
+ }else{
|
|
|
+ product_sn2.setText("请等待转到B面扫码");
|
|
|
+ product_sn2.setBackground(Color.LIGHT_GRAY);
|
|
|
+ product_sn2.setForeground(Color.DARK_GRAY);
|
|
|
+ }
|
|
|
|
|
|
MesClient.pxstatus2.setText("B");
|
|
|
|
|
|
@@ -647,7 +658,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
if(!sn.isEmpty()){
|
|
|
String qret = "OK";
|
|
|
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,"B");
|
|
|
+ String oprno = mes_gw + mes_gwflag; // OP060A
|
|
|
+ Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20,oprno);
|
|
|
if(!sendret){
|
|
|
MesClient.setMenuStatus("上传MES失败,请重试",-1);
|
|
|
}
|
|
|
@@ -775,21 +787,13 @@ public class MesClient extends JFrame {
|
|
|
indexPanelA.setLayout(null);
|
|
|
|
|
|
product_sn = new JTextField();
|
|
|
- product_sn.setText("");
|
|
|
+ product_sn.setText("OP050工位(不监控)");
|
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
product_sn.setEditable(false);
|
|
|
- product_sn.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
+ product_sn.setEnabled(false); // 禁用
|
|
|
+ product_sn.setBackground(Color.LIGHT_GRAY); // 灰色背景
|
|
|
+ product_sn.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 20));
|
|
|
product_sn.setBounds(26, 144, 446, 70);
|
|
|
- // 添加鼠标点击事件,点击显示二维码
|
|
|
- product_sn.addMouseListener(new MouseAdapter() {
|
|
|
- @Override
|
|
|
- public void mouseClicked(MouseEvent e) {
|
|
|
- String sn = product_sn.getText();
|
|
|
- if(sn != null && !sn.trim().isEmpty()){
|
|
|
- new com.mes.component.QRCodeDialog(mesClientFrame, "A面工件码二维码", sn);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
indexPanelA.add(product_sn);
|
|
|
product_sn.setColumns(10);
|
|
|
|
|
|
@@ -923,18 +927,19 @@ public class MesClient extends JFrame {
|
|
|
indexPanelA.add(lblNewLabel_1_1_1);
|
|
|
|
|
|
product_sn2 = new JTextField();
|
|
|
- product_sn2.setText("");
|
|
|
+ product_sn2.setText("请等待转到B面扫码");
|
|
|
product_sn2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- product_sn2.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
+ product_sn2.setFont(new Font("Microsoft YaHei UI", Font.BOLD, 22));
|
|
|
product_sn2.setEditable(false);
|
|
|
product_sn2.setColumns(10);
|
|
|
product_sn2.setBounds(517, 144, 446, 70);
|
|
|
+ product_sn2.setBackground(Color.LIGHT_GRAY); // 默认灰色,等待转台
|
|
|
// 添加鼠标点击事件,点击显示二维码
|
|
|
product_sn2.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
|
String sn = product_sn2.getText();
|
|
|
- if(sn != null && !sn.trim().isEmpty()){
|
|
|
+ if(sn != null && !sn.trim().isEmpty() && !sn.contains("请等待")){
|
|
|
new com.mes.component.QRCodeDialog(mesClientFrame, "B面工件码二维码", sn);
|
|
|
}
|
|
|
}
|
|
|
@@ -1060,18 +1065,18 @@ public class MesClient extends JFrame {
|
|
|
textField.setHorizontalAlignment(SwingConstants.LEFT);
|
|
|
textField.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 22));
|
|
|
textField.setColumns(10);
|
|
|
- textField.setBounds(264, 10, 510, 50);
|
|
|
+ textField.setBounds(400, 10, 510, 50); // 向右移动,给状态标签留空间
|
|
|
textField.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
scanBarcode();
|
|
|
}
|
|
|
});
|
|
|
indexPanelA.add(textField);
|
|
|
-
|
|
|
- lblNewLabel_5 = new JLabel("当前:A面");
|
|
|
- lblNewLabel_5.setForeground(new Color(0, 128, 64));
|
|
|
- lblNewLabel_5.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
- lblNewLabel_5.setBounds(136, 10, 113, 50);
|
|
|
+
|
|
|
+ lblNewLabel_5 = new JLabel("等待检测转台位置...");
|
|
|
+ lblNewLabel_5.setForeground(Color.GRAY);
|
|
|
+ lblNewLabel_5.setFont(new Font("微软雅黑", Font.BOLD, 20));
|
|
|
+ lblNewLabel_5.setBounds(126, 10, 360, 50);
|
|
|
indexPanelA.add(lblNewLabel_5);
|
|
|
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
@@ -1351,28 +1356,32 @@ public class MesClient extends JFrame {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- String page = PlcUtil.getReserveSide(s7PLC);
|
|
|
- if(page.equals("A")){
|
|
|
- if(!product_sn.getText().isEmpty() && mesQualityFlagA){
|
|
|
- MesClient.setMenuStatus("A面已存在工件码,勿重复扫码",1);
|
|
|
- return;
|
|
|
- }
|
|
|
- product_sn.setText(sn);
|
|
|
- }else{
|
|
|
- if(!product_sn2.getText().isEmpty() && mesQualityFlagB){
|
|
|
- MesClient.setMenuStatus("B面已存在工件码,勿重复扫码",1);
|
|
|
- return;
|
|
|
- }
|
|
|
- product_sn2.setText(sn);
|
|
|
+ // 检查转台位置,只有在 B 面才允许扫码
|
|
|
+ String page = PlcUtil.getCurAside(s7PLC);
|
|
|
+ if(page == null || !page.equals("B")){
|
|
|
+ MesClient.setMenuStatus("请等待转到 B 面",1);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ // 固定走 B 面逻辑
|
|
|
+ if(!product_sn2.getText().isEmpty() && !product_sn2.getText().contains("请扫码") && !product_sn2.getText().contains("请等待") && mesQualityFlagB){
|
|
|
+ MesClient.setMenuStatus("B面已存在工件码,勿重复扫码",1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 显示工件码,恢复白色背景
|
|
|
+ product_sn2.setText(sn);
|
|
|
+ product_sn2.setBackground(Color.WHITE);
|
|
|
+ product_sn2.setForeground(Color.BLACK);
|
|
|
+
|
|
|
MesClient.setMenuStatus("扫码成功",0);
|
|
|
|
|
|
//刷新界面
|
|
|
mesClientFrame.repaint();
|
|
|
getUser();
|
|
|
- // 查询工件质量
|
|
|
- Boolean sendret = DataUtil.checkQuality(nettyClient,sn,user20,page);
|
|
|
+ // 查询工件质量,传入完整工序号
|
|
|
+ String oprno = mes_gw + mes_gwflag; // OP060A
|
|
|
+ Boolean sendret = DataUtil.checkQuality(nettyClient,sn,user20,oprno);
|
|
|
if(!sendret){
|
|
|
MesClient.setMenuStatus("消息发送失败,请重试",1);
|
|
|
}
|