| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- package com.mes.ui;
- import com.alibaba.fastjson2.JSON;
- import com.alibaba.fastjson2.JSONObject;
- import com.google.zxing.BarcodeFormat;
- import com.google.zxing.client.j2se.MatrixToImageWriter;
- import com.google.zxing.common.BitMatrix;
- import com.google.zxing.qrcode.QRCodeWriter;
- import com.mes.component.*;
- import com.mes.util.DateLocalUtils;
- import com.mes.util.JdbcUtils;
- import com.mes.util.TCPClient;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import javax.swing.*;
- import javax.swing.border.EmptyBorder;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import java.awt.*;
- import java.awt.event.*;
- import java.awt.image.BufferedImage;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.util.List;
- import java.util.Properties;
- import java.util.Timer;
- import java.util.TimerTask;
- public class MesClient extends JFrame {
- public static final Logger log = LoggerFactory.getLogger(MesClient.class);
- private static String Drivde = "org.sqlite.JDBC";
- public static int mes_auth = 0; // 权限级别 0=无权限 1=操作工人 2=管理员
- public static String mes_gw = ""; // 工位号
- public static String mes_gw_des = ""; // 工位名称
- public static String mes_server_ip = ""; // 服务器IP地址
- public static String mes_line_sn = ""; // 产线编号
- public static String mes_line_pos = "";
- //session
- public static String sessionid = "";
- public static int isLogin = 0;
- public static JPanel contentPane;
- public static MesClient mesClientFrame;
- public static JTabbedPane tabbedPane;
- public static JScrollPane indexScrollPaneA;
- public static JScrollPane indexScrollPaneB;
- public static JScrollPane indexScrollPaneC;
- public static JScrollPane indexScrollPaneD;
- // public static JScrollPane searchScrollPane; // 已弃用,改为使用 WorkRecordPanel
- public static String preSn20 = "";
- // OP050 待领取码与扫码框显示分开,所有发布/领取使用同一把锁。
- private static String preSn30 = "";
- public static synchronized void publishOp050Sn(String sn) {
- if (sn == null || (sn.trim().length() != 16 && sn.trim().length() != 19)) {
- return;
- }
- preSn30 = sn.trim();
- log.info("<OP050> 发布待领取码 sn={}", preSn30);
- }
- public static synchronized String takeOp050Sn(String station) {
- String sn = preSn30;
- preSn30 = "";
- if (!sn.isEmpty()) {
- log.info("<{}> 领取扫码 sn={},已清空公共待领取码", station, sn);
- }
- return sn;
- }
- public static Boolean check_quality_result = false;
- public static Integer work_status = 0;
- public static JButton heart_beat_menu;
- public static JButton status_menu;
- public static JButton user_menu;
- public static JFrame welcomeWin;
- // public static JPanel indexPanelWork; // 已弃用,改为使用 WorkRecordPanel
- public static MesWebView jfxPanel = null;
- public static JTable table;
- public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
- public static Object[][] rowData = null;
- public static TCPClient tcpClient1 = new TCPClient("192.168.90.51",9004);
- public static TCPClient tcpClient2 = new TCPClient("192.168.90.52",9004);
- public static TCPClient tcpClient3 = new TCPClient("192.168.90.53",9004); // 60B
- public static TCPClient tcpClient4 = new TCPClient("192.168.90.54",9004); // 70EFG
- public static int scanFlag1 = 0;
- public static int scanFlag2 = 0;
- public static int scanFlag3 = 0;
- public static int scanFlag4 = 0;
- public static String newSn = ""; // 最新二维码
- public static WorkJPanelOP10 workJPanelOP10A;
- public static WorkJPanelOP20 workJPanelOP20A;
- public static WorkJPanelOP20 workJPanelOP20C;
- public static WorkJPanelOP20 workJPanelOP20E; // FSW3
- public static WorkJPanelScan workJPanelScanA;
- public static WorkJPanelScan workJPanelScanB;
- public static WorkJPanelOP25 workJPanelOP25A;
- public static WorkJPanelOP30 workJPanelOP30A;
- public static WorkJPanelOP30 workJPanelOP30C;
- public static WorkJPanelOP30 workJPanelOP30E; // FSW3
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- try{
- //读文件配置
- readProperty();
- JdbcUtils.getConn();
- // 显示界面
- mesClientFrame = new MesClient();
- mesClientFrame.setVisible(false);
- //
- welcomeWin = new LoginFarme();
- welcomeWin.setVisible(true);
- startHeartBeatTimer();
- }catch (Exception e){
- log.error(e.getMessage());
- }
- }
- });
- }
- //读配置文件
- private static void readProperty() throws IOException{
- String enconding = "UTF-8";
- InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
- Properties pro = new Properties();
- BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
- pro.load(br);
- mes_gw = pro.getProperty("mes.gw");
- mes_gw_des = pro.getProperty("mes.gw_des");
- mes_server_ip = pro.getProperty("mes.server_ip");
- // mes_tcp_port = Integer.parseInt(pro.getProperty("mes.tcp_port"));
- // mes_heart_beat_cycle = Integer.parseInt(pro.getProperty("mes.heart_beat_cycle"));
- mes_line_sn = pro.getProperty("mes.line_sn");
- mes_line_pos = pro.getProperty("mes.line_pos");
- // mes_gw_des = OprnoUtil.getGwDes(mes_line_sn,mes_gw);
- // log.info(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
- }
- //启动心跳包程序
- public static java.util.Timer heartBeatIconTimer;
- public static boolean iconREDFlag = true;
- public static void startHeartBeatTimer() {
- //心跳显示图标
- if(heartBeatIconTimer!=null) {
- heartBeatIconTimer.cancel();
- }
- heartBeatIconTimer = new Timer();
- heartBeatIconTimer.schedule(new TimerTask() {
- public void run() {
- if(iconREDFlag) {
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- iconREDFlag = false;
- }else {
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/green_dot.png")));
- iconREDFlag = true;
- }
- heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
- heart_beat_menu.repaint();
- }
- }, 100,1000);
- }
- public static void initWarehouseData(){
- resetScanA();
- }
- public static void resetScanA() {
- MesClient.setMenuStatus("请扫工件码",0);
- }
- public static void logoff() {
- mesClientFrame.setVisible(false);
- //退出程序 退出登录
- System.exit(0);
- // nettyClient = null;
- }
- public MesClient() {
- setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
- setTitle("MES系统客户端:OP35-OP50");
- // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- // setBounds(0, 0, 1920, 1080);
- setBounds(0, 0, 1024, 768);
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // 防止默认的关闭操作
- // 添加窗口监听器
- addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- int choice = JOptionPane.showConfirmDialog(null, "确定要关闭窗口吗?", "关闭确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
- if (choice == JOptionPane.YES_OPTION) {
- // 如果用户点击“是”,则关闭窗口
- dispose(); // 释放窗口资源并关闭窗口
- System.exit(0);
- }
- }
- });
- JMenuBar menuBar = new JMenuBar();
- menuBar.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 26));
- setJMenuBar(menuBar);
- JMenu fileMenu = new JMenu("用户");
- fileMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/user.png")));
- fileMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- menuBar.add(fileMenu);
- JMenuItem exitMenuItem = new JMenuItem("退出");
- exitMenuItem.setIcon(new ImageIcon(MesClient.class.getResource("/bg/logoff.png")));
- exitMenuItem.setFont(new Font("微软雅黑", Font.PLAIN, 22));
- fileMenu.add(exitMenuItem);
- exitMenuItem.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {//只能检测到mousePressed事件
- super.mouseClicked(e);
- //dispose();
- logoff();
- }
- });
- JMenu settingMenu = new JMenu("设置");
- //settingMenu.setVisible(false);
- settingMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")));
- settingMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- menuBar.add(settingMenu);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(new BorderLayout(0, 0));
- JToolBar toolBar = new JToolBar();
- contentPane.add(toolBar, BorderLayout.NORTH);
- JLabel equipment_statu_label = new JLabel("状态:");
- equipment_statu_label.setHorizontalAlignment(SwingConstants.CENTER);
- equipment_statu_label.setForeground(Color.BLACK);
- equipment_statu_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- equipment_statu_label.setBackground(Color.LIGHT_GRAY);
- // toolBar.add(equipment_statu_label);
- status_menu = new JButton("已连接MES服务器");
- status_menu.setForeground(Color.GREEN);
- status_menu.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- }
- });
- status_menu.setForeground(Color.GREEN);
- status_menu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- status_menu.setBackground(Color.BLACK);
- // toolBar.add(status_menu);
- JLabel space_1 = new JLabel(" ");
- toolBar.add(space_1);
- JLabel heart_beat_status_label = new JLabel("心跳:");
- heart_beat_status_label.setHorizontalAlignment(SwingConstants.CENTER);
- heart_beat_status_label.setForeground(Color.BLACK);
- heart_beat_status_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- heart_beat_status_label.setBackground(Color.LIGHT_GRAY);
- toolBar.add(heart_beat_status_label);
- heart_beat_menu = new JButton("");
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/green_dot.png")));
- heart_beat_menu.setForeground(Color.GREEN);
- heart_beat_menu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- heart_beat_menu.setBackground(Color.BLACK);
- toolBar.add(heart_beat_menu);
- JLabel space_2 = new JLabel(" ");
- toolBar.add(space_2);
- JLabel user_status_label = new JLabel("登录用户:");
- user_status_label.setHorizontalAlignment(SwingConstants.CENTER);
- user_status_label.setForeground(Color.BLACK);
- user_status_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- user_status_label.setBackground(Color.LIGHT_GRAY);
- toolBar.add(user_status_label);
- user_menu = new JButton("");
- user_menu.setForeground(Color.GREEN);
- user_menu.setFont(new Font("微软雅黑", Font.PLAIN, 22));
- user_menu.setBackground(Color.BLACK);
- toolBar.add(user_menu);
- JLabel space_3 = new JLabel(" ");
- toolBar.add(space_3);
- JLabel space_4 = new JLabel(" ");
- toolBar.add(space_4);
- tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- tabbedPane.setMinimumSize(new Dimension(400, 50));
- tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
- contentPane.add(tabbedPane);
- //首页
- JPanel indexPanelA = new JPanel();
- indexScrollPaneA = new JScrollPane(indexPanelA);
- indexPanelA.setLayout(new GridLayout(1,1, 5, 5));
- indexPanelA.setBackground(Color.LIGHT_GRAY);
- if(mes_line_pos.equals("east")){
- JPanel indexPanel1 = new JPanel();
- indexPanel1.setLayout(null);
- indexPanel1.setBackground(Color.WHITE);
- workJPanelOP10A = new WorkJPanelOP10("B");
- workJPanelOP10A.setBounds(10, 10, workJPanelOP10A.workWidth, workJPanelOP10A.workHeight);
- indexPanel1.add(workJPanelOP10A);
- indexPanelA.add(indexPanel1);
- }else{
- JPanel indexPanel1 = new JPanel();
- indexPanel1.setLayout(null);
- indexPanel1.setBackground(Color.WHITE);
- workJPanelOP10A = new WorkJPanelOP10("A");
- workJPanelOP10A.setBounds(10, 10, workJPanelOP10A.workWidth, workJPanelOP10A.workHeight);
- indexPanel1.add(workJPanelOP10A);
- indexPanelA.add(indexPanel1);
- }
- tabbedPane.addTab("OP35上料+打码", null, indexScrollPaneA, null);
- tabbedPane.setEnabledAt(0, true);
- JPanel indexPanelB = new JPanel();
- indexScrollPaneB = new JScrollPane(indexPanelB);
- indexPanelB.setLayout(new GridLayout(2,2, 5, 5));
- indexPanelB.setBackground(Color.LIGHT_GRAY);
- // FSW 子工位:西侧 A/B/E,东侧 C/D/F(E/F 为新增 FSW3)
- String[] fswPos = mes_line_pos.equals("east") ? new String[]{"C", "D", "F"} : new String[]{"A", "B", "E"};
- // OP40 反面FSW:FSW1=DB7000 FSW2=DB7001 FSW3=DB7004,扫码 DB7003
- workJPanelOP20A = new WorkJPanelOP20(fswPos[0]);
- indexPanelB.add(wrapCell(workJPanelOP20A, workJPanelOP20A.workWidth, workJPanelOP20A.workHeight));
- workJPanelOP20C = new WorkJPanelOP20(fswPos[1]);
- indexPanelB.add(wrapCell(workJPanelOP20C, workJPanelOP20C.workWidth, workJPanelOP20C.workHeight));
- workJPanelOP20E = new WorkJPanelOP20(fswPos[2]);
- indexPanelB.add(wrapCell(workJPanelOP20E, workJPanelOP20E.workWidth, workJPanelOP20E.workHeight));
- workJPanelScanA = new WorkJPanelScan("A");
- indexPanelB.add(wrapCell(workJPanelScanA, workJPanelScanA.workWidth, workJPanelScanA.workHeight));
- tabbedPane.addTab("OP40反面FSW", null, indexScrollPaneB, null);
- JPanel indexPanelC = new JPanel();
- indexScrollPaneC = new JScrollPane(indexPanelC);
- indexPanelC.setLayout(new GridLayout(1,1, 5, 5));
- indexPanelC.setBackground(Color.LIGHT_GRAY);
- if(mes_line_pos.equals("east")){
- JPanel indexPanel25A = new JPanel();
- indexPanel25A.setLayout(null);
- indexPanel25A.setBackground(Color.WHITE);
- workJPanelOP25A = new WorkJPanelOP25("B");
- workJPanelOP25A.setBounds(10, 10, workJPanelOP25A.workWidth, workJPanelOP25A.workHeight);
- indexPanel25A.add(workJPanelOP25A);
- indexPanelC.add(indexPanel25A);
- }else{
- JPanel indexPanel25A = new JPanel();
- indexPanel25A.setLayout(null);
- indexPanel25A.setBackground(Color.WHITE);
- workJPanelOP25A = new WorkJPanelOP25("A");
- workJPanelOP25A.setBounds(10, 10, workJPanelOP25A.workWidth, workJPanelOP25A.workHeight);
- indexPanel25A.add(workJPanelOP25A);
- indexPanelC.add(indexPanel25A);
- }
- tabbedPane.addTab("OP45打磨", null, indexScrollPaneC, null);
- JPanel indexPanelD = new JPanel();
- indexScrollPaneD = new JScrollPane(indexPanelD);
- indexPanelD.setLayout(new GridLayout(2,2, 5, 5));
- indexPanelD.setBackground(Color.LIGHT_GRAY);
- tabbedPane.setForegroundAt(2, Color.RED);
- // OP50 正面FSW:FSW1=DB7010 FSW2=DB7011 FSW3=DB7014,扫码 DB7013
- workJPanelOP30A = new WorkJPanelOP30(fswPos[0]);
- indexPanelD.add(wrapCell(workJPanelOP30A, workJPanelOP30A.workWidth, workJPanelOP30A.workHeight));
- workJPanelOP30C = new WorkJPanelOP30(fswPos[1]);
- indexPanelD.add(wrapCell(workJPanelOP30C, workJPanelOP30C.workWidth, workJPanelOP30C.workHeight));
- workJPanelOP30E = new WorkJPanelOP30(fswPos[2]);
- indexPanelD.add(wrapCell(workJPanelOP30E, workJPanelOP30E.workWidth, workJPanelOP30E.workHeight));
- workJPanelScanB = new WorkJPanelScan("B");
- indexPanelD.add(wrapCell(workJPanelScanB, workJPanelScanB.workWidth, workJPanelScanB.workHeight));
- tabbedPane.addTab("OP50正面FSW", null, indexScrollPaneD, null);
- // ========== 工作记录 Tab(改造:OP010/OP020/OP025/OP030子工位Tab + 所有工位) ==========
- // 旧代码已注释:
- // indexPanelWork = new JPanel();
- // searchScrollPane = new JScrollPane(indexPanelWork);
- // indexPanelWork.setLayout(null);
- // tabbedPane.addTab("工作记录", null, searchScrollPane, null);
- // 创建工作记录的子 TabbedPane
- JTabbedPane workRecordTabbedPane = new JTabbedPane(JTabbedPane.TOP);
- workRecordTabbedPane.setFont(new Font("微软雅黑", Font.PLAIN, 14));
- // 定义所有子工位
- // OP035: A, B
- // OP040: A, B, C, D, E, F(E=西侧FSW3 F=东侧FSW3)
- // OP045: A, B
- // OP050: A, B, C, D, E, F
- String[][] stationGroups = {
- {"OP035", "A", "B"},
- {"OP040", "A", "B", "C", "D", "E", "F"},
- {"OP045", "A", "B"},
- {"OP050", "A", "B", "C", "D", "E", "F"}
- };
-
- // 计算总的工位数(用于数组大小)
- int totalStations = 0;
- for (String[] group : stationGroups) {
- totalStations += group.length - 1; // 减去第一个元素(基础工位号)
- }
-
- WorkRecordPanel[] workRecordPanels = new WorkRecordPanel[totalStations + 1]; // +1 for "所有工位"
- int panelIndex = 0;
-
- // 为每个子工位创建 Tab
- for (String[] group : stationGroups) {
- String baseOprno = group[0]; // 如 OP010
- for (int i = 1; i < group.length; i++) {
- String station = group[i]; // 如 A, B
- String oprno = baseOprno + station;
- workRecordPanels[panelIndex] = new WorkRecordPanel(oprno, mes_line_sn);
- workRecordTabbedPane.addTab(oprno, null, workRecordPanels[panelIndex], "查询" + oprno + "的工作记录");
- panelIndex++;
- }
- }
- // 最后添加"所有工位"Tab(查询整条产线所有工位,不限于OP010/OP020/OP025/OP030)
- workRecordPanels[totalStations] = new WorkRecordPanel(null, mes_line_sn);
- workRecordTabbedPane.addTab("所有工位", null, workRecordPanels[totalStations], "查询整条产线所有工位的工作记录");
- // 切换子Tab时自动刷新数据
- workRecordTabbedPane.addChangeListener(e -> {
- int selectedIndex = workRecordTabbedPane.getSelectedIndex();
- if (selectedIndex >= 0 && selectedIndex < workRecordPanels.length) {
- workRecordPanels[selectedIndex].refreshData();
- }
- });
- // 将子 TabbedPane 添加到主 TabbedPane
- tabbedPane.addTab("工作记录", null, workRecordTabbedPane, null);
- tabbedPane.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
- int selectedIndex = tabbedPane.getSelectedIndex();
- if(selectedIndex == 1){
- }
- }
- });
- }
- // 白底容器包一层工位面板,放进 GridLayout 单元格
- private static JPanel wrapCell(JPanel work, int w, int h) {
- JPanel cell = new JPanel();
- cell.setLayout(null);
- cell.setBackground(Color.WHITE);
- work.setBounds(10, 10, w, h);
- cell.add(work);
- return cell;
- }
- public static void setMenuStatus(String msg,int error){
- if(error == 0){
- MesClient.status_menu.setForeground(Color.GREEN);
- }else{
- MesClient.status_menu.setForeground(Color.RED);
- }
- MesClient.status_menu.setText(msg);
- }
- public static void createQRCode(String s,String title) {
- log.info("二维码:"+s);
- if(s == null || s.isEmpty()){
- return;
- }
- s = s.trim();
- try {
- BitMatrix bitMatrix = new QRCodeWriter().encode(s, BarcodeFormat.QR_CODE, 200, 200);
- BufferedImage qrImage = MatrixToImageWriter.toBufferedImage(bitMatrix);
- JDialog qrDialog = new JDialog(mesClientFrame, title, Dialog.ModalityType.APPLICATION_MODAL);
- qrDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- qrDialog.setSize(250, 250);
- qrDialog.setLocationRelativeTo(mesClientFrame);
- qrDialog.setResizable(false);
- JLabel qrLabel = new JLabel(new ImageIcon(qrImage));
- qrDialog.getContentPane().add(qrLabel, BorderLayout.CENTER);
- qrDialog.setVisible(true);
- log.info("已生成二维码");
- } catch (Exception e) {
- log.error("生成二维码失败", e);
- }
- }
- public static String scanQrcode1(){
- if(scanFlag1 == 1){
- return "";
- }
- scanFlag1 = 1;
- String sn = "";
- try{
- if (tcpClient1.socket == null || !tcpClient1.socket.isConnected() || tcpClient1.socket.isClosed()) {
- tcpClient1.connect();
- }
- log.error("扫码枪1正在进行扫码,请勿操作",0);
- sn = tcpClient1.receiveResponse();
- if (sn == null || sn.equals("")) {
- sn = "";
- }
- tcpClient1.close();
- }catch (Exception e) {
- e.printStackTrace();
- log.error("scanQrcode1:"+sn);
- tcpClient1.close();
- }
- MesClient.setMenuStatus(sn,0);
- scanFlag1 = 0;
- return sn;
- }
- public static String scanQrcode2(){
- if(scanFlag2 == 1){
- return "";
- }
- scanFlag2 = 1;
- String sn = "";
- try{
- if (tcpClient2.socket == null || !tcpClient2.socket.isConnected() || tcpClient2.socket.isClosed()) {
- tcpClient2.connect();
- }
- log.error("扫码枪2正在进行扫码,请勿操作",0);
- sn = tcpClient2.receiveResponse();
- if (sn == null || sn.equals("")) {
- sn = "";
- }
- tcpClient2.close();
- }catch (Exception e) {
- e.printStackTrace();
- log.error("scanQrcode2:"+sn);
- tcpClient2.close();
- }
- MesClient.setMenuStatus(sn,0);
- scanFlag2 = 0;
- return sn;
- }
- public static String scanQrcode3(){
- if(scanFlag3 == 1){
- return "";
- }
- scanFlag3 = 1;
- String sn = "";
- try{
- if (tcpClient3.socket == null || !tcpClient3.socket.isConnected() || tcpClient3.socket.isClosed()) {
- tcpClient3.connect();
- }
- log.error("扫码枪3正在进行扫码,请勿操作",0);
- sn = tcpClient3.receiveResponse();
- if (sn == null || sn.equals("")) {
- sn = "";
- }
- tcpClient3.close();
- }catch (Exception e) {
- e.printStackTrace();
- log.error("scanQrcode3:"+sn);
- tcpClient3.close();
- }
- MesClient.setMenuStatus(sn,0);
- scanFlag3 = 0;
- return sn;
- }
- public static String scanQrcode4(){
- if(scanFlag4 == 1){
- return "";
- }
- scanFlag4 = 1;
- String sn = "";
- try{
- if (tcpClient4.socket == null || !tcpClient4.socket.isConnected() || tcpClient4.socket.isClosed()) {
- tcpClient4.connect();
- }
- log.error("扫码枪4正在进行扫码,请勿操作",0);
- sn = tcpClient4.receiveResponse();
- if (sn == null || sn.equals("")) {
- sn = "";
- }
- tcpClient4.close();
- }catch (Exception e) {
- e.printStackTrace();
- log.error("scanQrcode4:"+sn);
- tcpClient4.close();
- }
- MesClient.setMenuStatus(sn,0);
- scanFlag4 = 0;
- return sn;
- }
- }
|