wangxichen 2 napja
szülő
commit
22ba1dacd1
45 módosított fájl, 245 hozzáadás és 3261 törlés
  1. 7 12
      .classpath
  2. 3 1
      .gitignore
  3. BIN
      lib/commons-codec-1.15.jar
  4. BIN
      lib/gson-2.10.jar
  5. BIN
      lib/iot-communication-1.4.4.jar
  6. BIN
      lib/jSerialComm-2.6.2.jar
  7. BIN
      lib/jfreechart-1.5.4.jar
  8. BIN
      lib/jshortcut-0.4-oberzalek.jar
  9. BIN
      lib/kotlin-stdlib-1.8.10.jar
  10. BIN
      lib/logback-classic-1.2.13.jar
  11. BIN
      lib/logback-core-1.2.13.jar
  12. BIN
      lib/netty-all-4.1.48.Final.jar
  13. BIN
      lib/okhttp-4.10.0.jar
  14. BIN
      lib/okio-jvm-3.3.0.jar
  15. BIN
      lib/s7connector-2.1.jar
  16. BIN
      lib/slf4j-api-1.7.36.jar
  17. BIN
      lib/sqlite-jdbc-3.36.0.3.jar
  18. 0 10
      src/com/mes/component/CallFromJs.java
  19. 0 57
      src/com/mes/component/MesRadio.java
  20. 0 44
      src/com/mes/component/MesWebView.java
  21. 0 30
      src/com/mes/component/MyDialog.java
  22. 0 105
      src/com/mes/netty/MesMsgUtils.java
  23. 0 63
      src/com/mes/netty/NettyClient.java
  24. 0 82
      src/com/mes/netty/NettyClientHandler.java
  25. 0 74
      src/com/mes/netty/ProtocolParam.java
  26. 0 176
      src/com/mes/netty/XDecoder.java
  27. 0 58
      src/com/mes/ui/BindMaterialResp.java
  28. 0 283
      src/com/mes/ui/DataUtil.java
  29. 0 212
      src/com/mes/ui/LoginFarme.java
  30. 235 964
      src/com/mes/ui/MesClient.java
  31. 0 107
      src/com/mes/ui/MesRevice.java
  32. 0 53
      src/com/mes/ui/OprnoUtil.java
  33. 0 112
      src/com/mes/ui/StationConfig.java
  34. 0 43
      src/com/mes/ui/TableCellEditorButton.java
  35. 0 14
      src/com/mes/ui/TableCellRendererButton.java
  36. 0 11
      src/com/mes/util/Base64Utils.java
  37. 0 242
      src/com/mes/util/ClientRuntimeAgent.java
  38. 0 13
      src/com/mes/util/ClientType.java
  39. 0 46
      src/com/mes/util/ClientUpdateUtil.java
  40. 0 32
      src/com/mes/util/DateLocalUtils.java
  41. 0 64
      src/com/mes/util/ErrorMsg.java
  42. 0 157
      src/com/mes/util/HttpUtils.java
  43. 0 145
      src/com/mes/util/JdbcUtils.java
  44. 0 7
      src/resources/config/config.properties
  45. 0 44
      src/resources/logback.xml

+ 7 - 12
.classpath

@@ -5,20 +5,15 @@
 			<attribute name="module" value="true"/>
 		</attributes>
 	</classpathentry>
-    <classpathentry kind="src" path="image"/>
 	<classpathentry excluding="resources/" kind="src" path="src"/>
 	<classpathentry kind="src" path="src/resources"/>
 	<classpathentry kind="output" path="bin"/>
-	<classpathentry kind="lib" path="lib/s7connector-2.1.jar"/>
-	<classpathentry kind="lib" path="lib/slf4j-api-2.0.6.jar"/>
-	<classpathentry kind="lib" path="lib/okhttp-4.10.0.jar"/>
-	<classpathentry kind="lib" path="lib/kotlin-stdlib-1.8.10.jar"/>
-	<classpathentry kind="lib" path="lib/okio-jvm-3.3.0.jar"/>
-	<classpathentry kind="lib" path="lib/gson-2.10.jar"/>
-	<classpathentry kind="lib" path="lib/jfreechart-1.5.4.jar"/>
-	<classpathentry kind="lib" path="lib/jshortcut-0.4-oberzalek.jar"/>
-	<classpathentry kind="lib" path="lib/netty-all-4.1.48.Final.jar"/>
-	<classpathentry kind="lib" path="lib/sqlite-jdbc-3.36.0.3.jar"/>
-	<classpathentry kind="lib" path="lib/commons-codec-1.15.jar"/>
+	<classpathentry kind="lib" path="lib/mes-print.jar"/>
 	<classpathentry kind="lib" path="lib/fastjson2-2.0.16.jar"/>
+	<classpathentry kind="lib" path="lib/pdfbox-2.0.30.jar"/>
+	<classpathentry kind="lib" path="lib/fontbox-2.0.30.jar"/>
+	<classpathentry kind="lib" path="lib/commons-logging-1.2.jar"/>
+	<classpathentry kind="lib" path="lib/core-3.5.1.jar"/>
+	<classpathentry kind="lib" path="lib/javase-3.5.1.jar"/>
+	<classpathentry kind="lib" path="lib/snmp4j-3.7.7.jar"/>
 </classpath>

+ 3 - 1
.gitignore

@@ -3,5 +3,7 @@
 classes
 bin
 out
+release
 *.db
-*.iml
+*.iml
+data

BIN
lib/commons-codec-1.15.jar


BIN
lib/gson-2.10.jar


BIN
lib/iot-communication-1.4.4.jar


BIN
lib/jSerialComm-2.6.2.jar


BIN
lib/jfreechart-1.5.4.jar


BIN
lib/jshortcut-0.4-oberzalek.jar


BIN
lib/kotlin-stdlib-1.8.10.jar


BIN
lib/logback-classic-1.2.13.jar


BIN
lib/logback-core-1.2.13.jar


BIN
lib/netty-all-4.1.48.Final.jar


BIN
lib/okhttp-4.10.0.jar


BIN
lib/okio-jvm-3.3.0.jar


BIN
lib/s7connector-2.1.jar


BIN
lib/slf4j-api-1.7.36.jar


BIN
lib/sqlite-jdbc-3.36.0.3.jar


+ 0 - 10
src/com/mes/component/CallFromJs.java

@@ -1,10 +0,0 @@
-package com.mes.component;
-
-import com.mes.ui.MesClient;
-
-public class CallFromJs {
-    public String callFromJs(String info){
-        System.out.print("ss:"+info);
-        return MesClient.sessionid+":java:" + info;
-    }
-}

+ 0 - 57
src/com/mes/component/MesRadio.java

@@ -1,57 +0,0 @@
-package com.mes.component;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class MesRadio extends JPanel {
-
-    private String result = "";
-    private Integer i = 0;
-
-    public MesRadio(String[] radioTitles,String[] radioVals){
-        this.setLayout(new FlowLayout());
-        ButtonGroup group = new ButtonGroup();
-        i = 0;
-        for (String title:radioTitles){
-            JRadioButton radioButton = new JRadioButton(title);
-            radioButton.setFont(new Font("微软雅黑", Font.PLAIN, 28));
-
-            String val = radioVals[i];
-            radioButton.setName(val);
-
-            this.add(radioButton);
-            group.add(radioButton);
-
-            radioButton.addActionListener(new ActionListener() {
-                @Override
-                public void actionPerformed(ActionEvent e) {
-                    result = val;
-                    System.out.println("选择:"+result);
-                }
-            });
-            i++;
-        }
-    }
-
-    public void setResult(String ret){
-        this.result = "";
-        Component[] components = this.getComponents();
-        for (Component jRadioButton:components){
-            if(jRadioButton instanceof JRadioButton){
-                JRadioButton jRadioButtonParam = (JRadioButton)jRadioButton;
-                if(ret.equals(jRadioButtonParam.getName())){
-                    jRadioButtonParam.setSelected(true);
-                    this.result = jRadioButtonParam.getName();
-                }else{
-                    jRadioButtonParam.setSelected(false);
-                }
-            }
-        }
-    }
-
-    public String getResult(){
-        return this.result;
-    }
-}

+ 0 - 44
src/com/mes/component/MesWebView.java

@@ -1,44 +0,0 @@
-package com.mes.component;
-
-import javafx.application.Platform;
-import javafx.beans.value.ObservableValue;
-import javafx.concurrent.Worker;
-import javafx.embed.swing.JFXPanel;
-import javafx.scene.Scene;
-import javafx.scene.web.WebEngine;
-import javafx.scene.web.WebView;
-import netscape.javascript.JSObject;
-
-import java.util.Date;
-
-public class MesWebView extends JFXPanel {
-
-    public static WebEngine engine = null;
-
-    public MesWebView(String url){
-
-        Platform.runLater(() -> {
-            WebView webView = new WebView();
-            setScene(new Scene(webView));
-            Date date = new Date();
-//            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesQuality/check?__sid="+sessionid+"&oprno="+mes_gw+"&t="+date.getTime();
-            System.out.print(url);
-            engine = webView.getEngine();
-            CallFromJs bridge = new CallFromJs();
-            engine.getLoadWorker().stateProperty().addListener(
-                    (ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) -> {
-                        if (newState == Worker.State.SUCCEEDED) {
-                            JSObject window = (JSObject) engine.executeScript("window");
-                            window.setMember("apps", bridge);
-                            window.setMember("sout", System.out);
-                        }
-                    }
-            );
-            engine.load(url);
-        });
-    }
-
-    public void reloadWeb(){
-        engine.reload();
-    }
-}

+ 0 - 30
src/com/mes/component/MyDialog.java

@@ -1,30 +0,0 @@
-package com.mes.component;
-
-import javax.swing.*;
-import java.awt.*;
-
-public class MyDialog extends JDialog {
-
-    public MyDialog(Frame owner, String title, String msg){
-        super(owner, title);
-        init(msg);
-    }
-
-    private void init(String msg){
-        Container container = this.getContentPane();
-        container.setLayout(null);
-        container.setBackground(Color.BLACK);
-        this.setSize(800,220);
-        this.setLocationRelativeTo(null);
-
-        JLabel tslabel = new JLabel(msg);
-        tslabel.setHorizontalAlignment(SwingConstants.CENTER);
-        tslabel.setForeground(Color.RED);
-        tslabel.setFont(new Font("微软雅黑", Font.PLAIN,48));
-        tslabel.setBounds(0,30,800,100);
-
-        container.add(tslabel);
-        this.setModal(true);
-        this.setVisible(true);
-    }
-}

+ 0 - 105
src/com/mes/netty/MesMsgUtils.java

@@ -1,105 +0,0 @@
-package com.mes.netty;
-
-public class MesMsgUtils {
-
-    // 协议 v2(2026-06-29):oprno 字段从 6 字符扩到 8 字符,所有长度 +2
-    public static int SYNR_LEN = 48;
-    public static int AXTW_LEN = 48;
-    public static int ACLW_LEN = 48;
-    public static int MCJW_LEN = 98;
-    public static int AQDW_LEN = 99;
-    public static int MBDW_LEN = 98;
-    public static int MJBW_LEN = 98;
-    public static int MQDW_LEN = 99;
-    public static int MKSW_LEN = 96;
-    public static int MSBW_LEN = 96;
-    public static int MCSW_LEN = 96;
-    public static int AQRW_LEN = 96;
-
-    public static String MSG_TYPE[] = {
-        "SYNR",
-        "AXTW",
-        "ACLW",
-        "MCJW",
-        "AQDW",
-        "MBDW",
-        "MJBW",
-        "MQDW",
-        "MKSW",
-        "MSBW",
-        "MCSW",
-        "AQRW",
-    };
-
-    public static int isMsgContentOK(String msg, String msg_type) {
-        //ret=0OK,1 空内容,2 长度不符
-        int ret = 0;
-        if(msg==null||msg.equalsIgnoreCase("")) {
-            ret = 1;
-            return ret;
-        }
-
-        int len = msg.length();
-        //System.out.println("len="+len);
-        switch(msg_type) {
-            case "SYNR":
-            case "AXTW":
-            case "ACLW":
-                if(len==SYNR_LEN) {
-                    ret = 0;
-                }else {
-                    ret = 2;
-                }
-                break;
-            case "AQDW":
-                if(len==AQDW_LEN) {
-                    ret = 0;
-                }else {
-                    ret = 2;
-                }
-                break;
-            case "MQDW":
-                if(len==MQDW_LEN) {
-                    ret = 0;
-                }else {
-                    ret = 2;
-                }
-                break;
-            default:
-                if(len==MCJW_LEN) {
-                    ret = 0;
-                }else {
-                    ret = 2;
-                }
-                break;
-        }
-        return ret;
-    }
-
-    // 判断报文类型是否在清单里
-    public static boolean isMsgTypeOk(String msg_type) {
-        for (String str : MSG_TYPE) {
-            if (str.equals(msg_type)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    // 处理报文数据
-    public static String processMsg(String msg, String msg_type) {
-        String processMsgRet = "";
-        if(msg_type.equalsIgnoreCase("SYNR")) {
-
-        }else if(msg_type.equalsIgnoreCase("AXTW")) {
-
-        }else if(msg_type.equalsIgnoreCase("ACLW")) {
-
-        }else{
-            processMsgRet = ProtocolParam.getResult(msg);
-        }
-        return processMsgRet;
-    }
-
-
-}

+ 0 - 63
src/com/mes/netty/NettyClient.java

@@ -1,63 +0,0 @@
-package com.mes.netty;
-
-import io.netty.bootstrap.Bootstrap;
-import io.netty.channel.*;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.channel.socket.nio.NioSocketChannel;
-import io.netty.handler.codec.string.StringEncoder;
-import java.util.concurrent.TimeUnit;
-
-import com.mes.ui.MesClient;
-
-public class NettyClient {
-    public SocketChannel socketChannel;
-    public static ChannelFuture future;
-
-    public  void run(Object msg){
-        //配置线程组
-        EventLoopGroup group = new NioEventLoopGroup();
-        //创建服务启动器
-        Bootstrap bootstrap = new Bootstrap();
-
-        //配置参数
-        bootstrap.group(group)
-                .channel(NioSocketChannel.class)
-                .option(ChannelOption.TCP_NODELAY,true)
-                .handler(new ChannelInitializer<SocketChannel>() {
-                    protected void initChannel(SocketChannel socketChannel) throws Exception {
-                        socketChannel.pipeline()
-                                .addLast(new XDecoder())
-                                .addLast(new StringEncoder())
-//                                    .addLast(new StringDecoder())
-                                .addLast(new NettyClientHandler());
-                    }
-                })
-                .remoteAddress(MesClient.mes_server_ip,MesClient.mes_tcp_port);
-
-        //连接
-        future = bootstrap.connect();
-        System.out.println("客户端正在连接服务端...");
-        //客户端断线重连逻辑
-        future.addListener((ChannelFutureListener) future1 -> {
-            if (future1.isSuccess()) {
-                //tcp连接成功
-                MesClient.tcp_connect_flag = true;
-                //设置TCP请求状态
-                MesClient.connect_request_flag = false;
-                System.out.println("连接Netty服务端成功");
-                future.channel().writeAndFlush(msg);
-            } else {
-                //tcp连接失败
-                MesClient.tcp_connect_flag = false;
-                MesClient.connect_request_flag = true;
-                System.out.println("连接失败,进行断线重连");
-                future1.channel().eventLoop().schedule(() -> run(msg), 10, TimeUnit.SECONDS);
-            }
-            //设置tcp连接状态
-            MesClient.setTcpStatus();
-        });
-        socketChannel = (SocketChannel) future.channel();
-
-    }
-}

+ 0 - 82
src/com/mes/netty/NettyClientHandler.java

@@ -1,82 +0,0 @@
-package com.mes.netty;
-
-import com.mes.ui.MesClient;
-import com.mes.ui.MesRevice;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class NettyClientHandler extends ChannelInboundHandlerAdapter {
-
-    private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    public static byte[] responseByte;
-
-    @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
-        System.out.println("mes connecting:" + sdf.format(new Date()));
-    }
-
-    @Override
-    public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
-        Channel channel = ctx.channel();
-        System.err.println("close tcp, ip:" + channel.remoteAddress());
-        MesClient.tcp_connect_flag = false;
-        MesClient.setTcpStatus();
-        // 关闭通道
-        channel.close();
-    }
-
-    @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
-        System.out.println("msg:"+msg);
-
-        String mes_msg = formatResult(msg.toString());
-        if(mes_msg == null || mes_msg.isEmpty()){ // error msg
-            return;
-        }
-
-        String msg_type = ProtocolParam.getMsgType(mes_msg);
-        System.out.println("msg_type="+msg_type);
-
-        String processMsgRet = MesMsgUtils.processMsg(mes_msg, msg_type);
-        System.out.println("processMsgRet="+processMsgRet);
-        switch(msg_type) {
-            case "AQDW": // 查询质量
-                MesRevice.checkQualityRevice(processMsgRet,mes_msg);
-                break;
-            case "MKSW":
-                MesRevice.startRevice(processMsgRet,mes_msg);
-                break;
-            case "MBDW":
-                MesRevice.bindRevice(processMsgRet,mes_msg);
-                break;
-            case "MJBW":
-                MesRevice.unbindRevice(processMsgRet,mes_msg);
-                break;
-            case "MQDW":
-                MesRevice.updateResultRevice(processMsgRet,mes_msg);
-                break;
-        }
-
-
-    }
-
-    @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-        ctx.close();
-    }
-
-    private String formatResult(String msg){
-        System.err.println("length:" + msg.length() + " content:" + msg);
-        String msgType = msg.substring(0,2).trim();
-        if(msgType.equals("OK")){
-            return msg.substring(3,msg.length());
-        }else{
-            return "";
-        }
-    }
-
-}

+ 0 - 74
src/com/mes/netty/ProtocolParam.java

@@ -1,74 +0,0 @@
-package com.mes.netty;
-
-
-// 固定格式报文各参数获取方法
-// 协议 v2(2026-06-29 修订):oprno 字段从 6 字符扩到 8 字符,后续字段偏移整体 +2
-public class ProtocolParam {
-    // bbbbfffffARWAQDWGWOP100   GY100000ID151245P00000106200123062900001      RSOKDA2023-09-07ZT10:16:58
-    public static Integer fixedLength = 99; // 固定长度(响应报文,v1=96,v2 扩 oprno 后 +2)
-
-    // 获取消息类型  所有报文都可使用
-    public static String getMsgType(String msg){
-        System.out.print(msg);
-        if(msg.length() < 16){
-            return "";
-        }
-        return msg.substring(12,16);
-    }
-
-    // 获取工位号(8 字符)
-    public static String getOprno(String msg){
-        if(msg.length() < 26){
-            return "";
-        }
-        return msg.substring(18,26);
-    }
-
-    // 获取工艺号
-    public static String getCraft(String msg){
-        if(msg.length() < 34){
-            return "";
-        }
-        return msg.substring(28,34);
-    }
-
-    // 获取镭雕码或设备报警故障代码
-    public static String getSn(String msg){
-        if(msg.length() < 72){
-            return "";
-        }
-        return msg.substring(36,72);
-    }
-
-    public static String getLx(String msg){
-        if(msg.length() < 75){
-            return "";
-        }
-        return msg.substring(72,75).trim();
-    }
-
-    // 获取结果
-    public static String getResult(String msg){
-        if(msg.length() < 77){
-            return "";
-        }
-        return msg.substring(75,77);
-    }
-
-    // 获取日期
-    public static String getDay(String msg){
-        if(msg.length() < 89){
-            return "";
-        }
-        return msg.substring(79,89);
-    }
-
-    // 获取时间
-    public static String getTime(String msg){
-        if(msg.length() < 99){
-            return "";
-        }
-        return msg.substring(91,99);
-    }
-
-}

+ 0 - 176
src/com/mes/netty/XDecoder.java

@@ -1,176 +0,0 @@
-package com.mes.netty;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
-import java.util.List;
-
-public class XDecoder extends ByteToMessageDecoder {
-    static final int PACKET_SIZE = 46; // 最短包长度
-    static final int PACKET_MAX_SIZE = 1000; // 最长包长度
-
-    // 用来临时保留没有处理过的请求报文
-    ByteBuf tempMsg = Unpooled.buffer();
-
-    /**
-     * @param ctx
-     * @param in 请求的数据
-     * @param out 将粘在一起的报文拆分后的结果保留起来
-     * @throws Exception
-     */
-    @Override
-    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
-        System.out.println(Thread.currentThread() + "收到了一次数据包,长度是:" + in.readableBytes());
-        String content = hexStringToAscii(ByteBufUtil.hexDump(in));
-        System.out.println("接收包内容:" + hexStringToAscii(ByteBufUtil.hexDump(in)));
-
-        // 合并报文
-        ByteBuf message = null;
-        int tmpMsgSize = tempMsg.readableBytes();
-        // 如果暂存有上一次余下的请求报文,则合并
-        if (tmpMsgSize > 0) {
-            message = Unpooled.buffer();
-            message.writeBytes(tempMsg);
-            message.writeBytes(in);
-            System.out.println("合并:上一数据包余下的长度为:" + tmpMsgSize + ",合并后长度为:" + message.readableBytes());
-            System.out.println("合并后包内容:" + hexStringToAscii(ByteBufUtil.hexDump(message)));
-        } else {
-            message = in;
-        }
-
-//        System.out.println(Thread.currentThread() + "收到了一次数据包,长度是:" + message.readableBytes());
-        int size = 0;
-        String split = "bbbbfffffARW";
-
-        while (true){
-            size = message.readableBytes();
-            if(size >= PACKET_SIZE){
-                String retType = "NG:";
-                int qcsize = 0;
-                String str = hexStringToAscii(ByteBufUtil.hexDump(message));
-                String[] lists = str.split(split);
-
-                if(lists.length == 1 && size > PACKET_MAX_SIZE){ // 大于最大包长度
-                    byte[] request = new byte[size - PACKET_MAX_SIZE];
-                    // 每次从总的消息中读取n个字节的数据
-                    message.readBytes(request);
-                    // 将拆分后的结果放入out列表中,交由后面的业务逻辑去处理
-                    out.add(retType+hexStringToAscii(ByteBufUtil.hexDump(Unpooled.copiedBuffer(request))));
-                    break;
-                }
-
-                if(lists[0].length() > 0){
-                    byte[] request = new byte[lists[0].length()];
-                    // 每次从总的消息中读取n个字节的数据
-                    message.readBytes(request);
-                    // 将拆分后的结果放入out列表中,交由后面的业务逻辑去处理
-                    out.add(retType+hexStringToAscii(ByteBufUtil.hexDump(Unpooled.copiedBuffer(request))));
-                }else{
-                    if(lists.length > 1){
-                        String ss = lists[1];
-                        if(ss.length() <= 4){
-                            qcsize += ss.length();
-                        }else{
-                            String msgType = ProtocolParam.getMsgType(split+ss);
-                            if(!MesMsgUtils.isMsgTypeOk(msgType)){
-                                qcsize += split.length() + ss.length();
-                            }else{
-                                Integer ppsize = checkResultSize(ss,msgType,split);
-                                if(ppsize > 0){
-                                    qcsize = ppsize;
-                                    retType = "OK:";
-                                }else{
-                                    qcsize += split.length() + ss.length();
-                                }
-                            }
-                        }
-                    }
-                }
-
-
-                if(qcsize > 0){
-                    byte[] request = new byte[qcsize];
-                    // 每次从总的消息中读取n个字节的数据
-                    message.readBytes(request);
-                    // 将拆分后的结果放入out列表中,交由后面的业务逻辑去处理
-                    out.add(retType+hexStringToAscii(ByteBufUtil.hexDump(Unpooled.copiedBuffer(request))));
-                }
-            }else{
-                break;
-            }
-        }
-
-        // 多余的报文存起来
-        // 第一个报文: i+  暂存
-        // 第二个报文: 1 与第一次
-        size = message.readableBytes();
-        if (size != 0) {
-            System.out.println("多余的数据长度:" + size);
-            // 剩下来的数据放到tempMsg暂存
-            tempMsg.clear();
-            tempMsg.writeBytes(message.readBytes(size));
-        }
-    }
-
-    private Integer checkResultSize(String str, String msg_type, String split){
-        String oldstr = str;
-        str = split+str;
-        int tpsize = 0;
-        switch(msg_type) {
-            case "SYNR": // 同步
-                if(str.length() >= MesMsgUtils.SYNR_LEN){
-                    tpsize = MesMsgUtils.SYNR_LEN;
-                }
-                break;
-            case "AXTW": // 心跳
-                if(str.length() >= MesMsgUtils.AXTW_LEN){
-                    tpsize = MesMsgUtils.AXTW_LEN;
-                }
-                break;
-            case "ACLW": // 重连
-                if(str.length() >= MesMsgUtils.ACLW_LEN){
-                    tpsize = MesMsgUtils.ACLW_LEN;
-                }
-                break;
-            case "AQDW":
-                if(str.length() >= MesMsgUtils.AQDW_LEN){
-                    tpsize = MesMsgUtils.AQDW_LEN;
-                }
-                break;
-            case "MQDW":
-                if(str.length() >= MesMsgUtils.MQDW_LEN){
-                    tpsize = MesMsgUtils.MQDW_LEN;
-                }
-                break;
-            case "MCJW":
-            case "MBDW":
-            case "MJBW":
-            case "MKSW":
-            case "MSBW":
-            case "MCSW":
-            case "AQRW":
-            default: // default new packet
-                if(str.length() >= MesMsgUtils.MCJW_LEN){
-                    tpsize = MesMsgUtils.MCJW_LEN;
-                }
-                break;
-        }
-
-        return tpsize;
-    }
-
-    // 16字符串转Ascii
-    private String hexStringToAscii(String hexString) {
-        StringBuilder sbuilder = new StringBuilder();
-        for (int i = 0; i < hexString.length(); i += 2) {
-            String hexByte = hexString.substring(i, i + 2);
-            int byteValue = Integer.parseInt(hexByte, 16);
-            char c = (char) byteValue;
-            sbuilder.append(c);
-        }
-        return sbuilder.toString();
-    }
-}

+ 0 - 58
src/com/mes/ui/BindMaterialResp.java

@@ -1,58 +0,0 @@
-package com.mes.ui;
-
-public class BindMaterialResp {
-    private String materialId;
-    private String materialTitle;
-    private String craft;
-    private String batchSn;
-    private String lastTimes;
-    private String type;
-
-    public String getMaterialId() {
-        return materialId;
-    }
-
-    public void setMaterialId(String materialId) {
-        this.materialId = materialId;
-    }
-
-    public String getMaterialTitle() {
-        return materialTitle;
-    }
-
-    public void setMaterialTitle(String materialTitle) {
-        this.materialTitle = materialTitle;
-    }
-
-    public String getCraft() {
-        return craft;
-    }
-
-    public void setCraft(String craft) {
-        this.craft = craft;
-    }
-
-    public String getBatchSn() {
-        return batchSn;
-    }
-
-    public void setBatchSn(String batchSn) {
-        this.batchSn = batchSn;
-    }
-
-    public String getLastTimes() {
-        return lastTimes;
-    }
-
-    public void setLastTimes(String lastTimes) {
-        this.lastTimes = lastTimes;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-}

+ 0 - 283
src/com/mes/ui/DataUtil.java

@@ -1,283 +0,0 @@
-package com.mes.ui;
-
-import com.alibaba.fastjson2.JSONObject;
-import com.mes.netty.NettyClient;
-import com.mes.util.DateLocalUtils;
-import com.mes.util.JdbcUtils;
-
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-public class DataUtil {
-
-    public static Boolean synrTcp(NettyClient nettyClient,String mes_gw){
-        try{
-            //TCP连接后,直接先发同步报文
-            String start = "aaaabbbbbABW";
-            String msgType = "SYNR";
-            String gw = "GW"+DataUtil.rightPad(mes_gw, 8);
-            String da = "DA" + DateLocalUtils.getCurrentDate();
-            String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
-            String synr_str = start + msgType + gw + da + zt;
-            //插入报文本地数据
-            String gy = "";
-            String sn = "";
-            JdbcUtils.insertData(gw, gy, synr_str, msgType, sn);
-
-            nettyClient.run(synr_str);
-
-            return true;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean heartBeat(NettyClient nettyClient,String mes_gw){
-        try{
-            //TCP连接后,直接先发同步报文
-            String start = "aaaabbbbbABW";
-            String msgType = "AXTW";
-            String gw = "GW"+DataUtil.rightPad(mes_gw, 8);
-            String da = "DA" + DateLocalUtils.getCurrentDate();
-            String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
-            String axtw_str = start + msgType + gw + da + zt;
-            //插入报文本地数据
-            String gy = "";
-            String sn = "";
-            JdbcUtils.insertData(gw, gy, axtw_str, msgType, sn);
-            nettyClient.future.channel().writeAndFlush(axtw_str);
-
-            return true;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean checkQuality(NettyClient nettyClient, String sn, String user){
-        try{
-            String msgType = "AQDW";
-            String gy = "100000";
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"00","");
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean startWork(NettyClient nettyClient,String sn,String user){
-        try{
-            String msgType = "MKSW";
-            String gy = "";
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"00","");
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean bindUser(NettyClient nettyClient,String sn,String user){
-        try{
-            String msgType = "MBDW";
-            String gy = "400001";
-            String param = rightPad(user, 36);
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,"",user,"01",param);
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean bindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
-        try{
-            String msgType = "MBDW";
-            String param = rightPad(wsn, 36);
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean unBindWarehouse(NettyClient nettyClient,String sn,String wsn,String user,String craft){
-        try{
-            String msgType = "MJBW";
-            String param = rightPad(wsn, 36);
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,craft,"",sn,"",user,"01",param);
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean sendQuality(NettyClient nettyClient,String sn,String ret,String user){
-        try{
-            String msgType = "MQDW";
-            String gy = "100000";
-            String param = "";
-            Boolean aqdw_str = sendMessage(nettyClient,msgType,gy,"",sn,ret,user,"00",param);
-            return aqdw_str;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean sendQualityNew(NettyClient nettyClient,String sn,String ret,String user){
-        try{
-            String msgType = "MQDW";
-            String craft = "100000";
-            String params = "";
-            String gw = "GW"+rightPad(MesClient.mes_gw, 8);
-            String start = "aaaabbbbbABW";
-            String gy = "GY" + rightPad(craft, 6);
-            String reslx = "LX" + rightPad("", 2);
-            String id = MesClient.mes_line_sn + rightPad(sn, 36);
-            String rs = "RS"+ rightPad(ret, 2);
-            String da = "DA" + DateLocalUtils.getCurrentDate();
-            String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
-            String yh = "YH" + rightPad(user, 20);
-            String aqdw_str = start + msgType + gw + gy + reslx + id + rs + da + zt + yh + "00" + params;
-            System.out.println("message="+aqdw_str);
-            JdbcUtils.insertSubmitRecord(gw, sn, aqdw_str);
-            return true;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static Boolean sendMessage(NettyClient nettyClient,String msgType,String craft,String lx,String sn,String result,String user,String paramNums,String params){
-        try{
-            String gw = "GW"+rightPad(MesClient.mes_gw, 8);
-            String start = "aaaabbbbbABW";
-            String gy = "GY" + rightPad(craft, 6);
-            String reslx = "LX" + rightPad(lx, 2);
-            String id = MesClient.mes_line_sn + rightPad(sn, 36);
-            String rs = "RS"+ rightPad(result, 2);
-            String da = "DA" + DateLocalUtils.getCurrentDate();
-            String zt = "ZT" + DateLocalUtils.getCurrentTimeHMS();
-            String yh = "YH" + rightPad(user, 20);
-            String aqdw_str = start + msgType + gw + gy + reslx + id + rs + da + zt + yh + paramNums + params;
-            System.out.println("message="+aqdw_str);
-            JdbcUtils.insertData(gw, gy, aqdw_str, msgType, sn);
-            nettyClient.future.channel().writeAndFlush(aqdw_str);
-            return true;
-        }catch (Exception e){
-            return false;
-        }
-    }
-
-    public static String rightPad(final String str, final int size) {
-        if (str == null) {
-            return null;
-        }
-
-        String strret = str;
-        if(str.length() > size){
-            strret = str.substring(0,size);
-        }
-        return String.format("%-"+size+"s", strret);
-    }
-
-    public static JSONObject getBindMaterail() {
-        try{
-            String mes_server_ip = MesClient.mes_server_ip;
-            String oprno = MesClient.mes_gw.trim();
-            String lineSn = MesClient.mes_line_sn.trim();
-            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesLineProcessMaterial/materials";
-            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn;
-            System.out.println("params="+params);
-            String result = doPost(url,params);
-            System.out.println("result="+result);
-
-            if(result.equalsIgnoreCase("false")) {
-                return null;
-            }else {
-                return JSONObject.parseObject(result);
-            }
-        }catch (Exception e){
-            return null;
-        }
-    }
-
-    public static JSONObject saveBindMaterail(String batchSn,String craft,String materialId,String type) {
-        try{
-            String mes_server_ip = MesClient.mes_server_ip;
-            String oprno = MesClient.mes_gw.trim();
-            String lineSn = MesClient.mes_line_sn.trim();
-            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesMaterialPrebind/bind";
-            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&batchSn="+batchSn+"&craft="+craft+"&materialId="+materialId+"&type="+type;
-            System.out.println("params="+params);
-            String result = doPost(url,params);
-            System.out.println("result="+result);
-
-            if(result.equalsIgnoreCase("false")) {
-                return null;
-            }else {
-                return JSONObject.parseObject(result);
-            }
-        }catch (Exception e){
-            return null;
-        }
-    }
-
-    public static String doPost(String httpUrl, String param) {
-        HttpURLConnection connection = null;
-        InputStream is = null;
-        OutputStream os = null;
-        BufferedReader br = null;
-        String result = null;
-        try {
-            URL url = new URL(httpUrl);
-            connection = (HttpURLConnection) url.openConnection();
-            connection.setRequestMethod("POST");
-            connection.setConnectTimeout(15000);
-            connection.setReadTimeout(60000);
-            connection.setDoOutput(true);
-            connection.setDoInput(true);
-            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-            connection.setRequestProperty("Authorization", "Bearer da3efcbf-0845-4fe3-8aba-ee040be542c0");
-            os = connection.getOutputStream();
-            os.write(param.getBytes());
-            if (connection.getResponseCode() == 200) {
-                is = connection.getInputStream();
-                br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
-                StringBuffer sbf = new StringBuffer();
-                String temp = null;
-                while ((temp = br.readLine()) != null) {
-                    sbf.append(temp);
-                    sbf.append("\r\n");
-                }
-                result = sbf.toString();
-            }
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (null != br) {
-                try {
-                    br.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if (null != os) {
-                try {
-                    os.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            if (null != is) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            connection.disconnect();
-        }
-        return result;
-    }
-}

+ 0 - 212
src/com/mes/ui/LoginFarme.java

@@ -1,212 +0,0 @@
-package com.mes.ui;
-
-import com.alibaba.fastjson2.JSONObject;
-import com.mes.component.MesRadio;
-import com.mes.component.MesWebView;
-import com.mes.util.Base64Utils;
-import com.mes.util.HttpUtils;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.time.LocalDateTime;
-
-public class LoginFarme extends JFrame {
-    //登录模块组件
-    static JLabel userNameLabel= new JLabel("<html><body>用户名:</body></html>",JLabel.LEFT);//用户名
-    static JLabel userPasswordLabel= new JLabel("<html><body>密码:</body></html>",JLabel.LEFT);//用户名
-    public static JTextField userNameTxt;
-    public static JPasswordField userPasswordTxt;
-    static JButton loginButton = new JButton("用户密码登录");
-    static JButton scanLoginButton = new JButton("扫  码  登  录");
-
-    public LoginFarme(){
-        setTitle("MES系统客户端:"+MesClient.mes_gw+" - "+MesClient.mes_gw_des);
-
-        ImageIcon bg = new ImageIcon(MesClient.class.getResource("/background.png"));
-        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-        JLabel imgLabel = new JLabel(bg);//将背景图放在标签里。
-        getLayeredPane().add(imgLabel, new Integer(Integer.MIN_VALUE));//注意这里是关键,将背景标签添加到jfram的LayeredPane面板里。
-        imgLabel.setBounds(0,0,bg.getIconWidth(), bg.getIconHeight());//设置背景标签的位置
-        Container contentPane=getContentPane();
-        contentPane.setLayout(null);//布局,很重要
-        JPanel welcomePanel = new JPanel();
-        //welcomePanel.setLayout(new GridLayout(3, 1));
-        welcomePanel.setLayout(null);
-        //welcomeLable.setBounds(10, 5, 700, 100);
-        welcomePanel.setBounds(30, 330, 890, 300);
-        welcomePanel.setOpaque(false);//背景透明
-        contentPane.add(welcomePanel);
-
-        //登录页面
-        userNameLabel.setBounds(300, 100, 120, 40);
-        userNameLabel.setFont(new java.awt.Font("Dialog",   1,   16));
-        userPasswordLabel.setBounds(300, 150, 120, 40);
-        userPasswordLabel.setFont(new java.awt.Font("Dialog",   1,   16));
-        userNameTxt = new JTextField(20);
-        userNameTxt.setText("system");
-        userNameTxt.setBounds(400, 105, 150, 30);
-        userPasswordTxt = new JPasswordField(20);
-        userPasswordTxt.setBounds(400, 155, 150, 30);
-        userPasswordTxt.setText("Aa111111");
-        loginButton.setFont(new java.awt.Font("Dialog",   1,   16));
-        loginButton.setBounds(300, 200, 255, 40);
-        loginButton.setIcon(new ImageIcon(MesClient.class.getResource("/bg/user.png")));
-
-//        scanLoginButton.setVisible(false);
-        scanLoginButton.setFont(new java.awt.Font("Dialog",   1,   16));
-        scanLoginButton.setBounds(300, 250, 255, 40);
-        scanLoginButton.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
-
-        welcomePanel.add(userNameLabel);
-        welcomePanel.add(userPasswordLabel);
-        welcomePanel.add(userNameTxt);
-        welcomePanel.add(userPasswordTxt);
-        welcomePanel.add(loginButton);
-        welcomePanel.add(scanLoginButton);
-        loginButton.addActionListener(new ActionListener(){
-            public void actionPerformed(ActionEvent e) {
-                login();
-            }
-        });
-        scanLoginButton.addActionListener(new ActionListener(){
-            public void actionPerformed(ActionEvent e) {
-                scanLogin();
-            }
-        });
-
-        ((JPanel)contentPane).setOpaque(false); //注意这里,将内容面板设为透明。这样LayeredPane面板中的背景才能显示出来。
-        //welcomeWin.setSize(902,678);
-        setResizable(false);//禁止最大化
-        setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
-
-        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
-        int width = 902;
-        int height = 678;
-        setBounds((d.width-width)/2, (d.height-height)/2-(d.height-height)/4, width, height);
-        /*****正常模式******/
-        setVisible(true);
-    }
-
-    //登录
-    public static void login() {
-        String user_str = userNameTxt.getText().toString();
-        String password_str = userPasswordTxt.getText().toString();
-        if(user_str.equalsIgnoreCase("")||password_str.equalsIgnoreCase("")) {
-            JOptionPane.showMessageDialog(MesClient.mesClientFrame,"用户名或密码不能为空","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-            return;
-        }
-        String username = Base64Utils.getBase64(user_str);
-        String password = Base64Utils.getBase64(password_str);
-        System.out.println("&username=" + username + "&password=" + password);
-        String url = "http://"+MesClient.mes_server_ip+":8980/js/a/login?__ajax=json&username="+username+"&password="+password+"&validCode=&__sid=";
-        String loginResult = HttpUtils.sendRequest(url);
-        if(loginResult.equalsIgnoreCase("false")) {
-            JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录异常,请检查网络或联系网络管理员","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-            return;
-        }else {
-            JSONObject retObj = JSONObject.parseObject(loginResult);
-            if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
-                //检查用户权限是否可登录界面
-                checkUserAuthority(retObj);
-            }else {
-                //ret = "msg save error";
-                //ret = false;
-                JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录失败,用户名或密码错误","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                return;
-            }
-        }
-    }
-    //扫码登录
-    public static void scanLogin() {
-        //userNameTxt.setText("");
-        //userPasswordTxt.setText("");
-        String scanContent = JOptionPane.showInputDialog(null, "请扫码工牌二维码");
-        System.out.println("scanContent="+scanContent);
-        if(scanContent!=null&&!scanContent.equalsIgnoreCase("")) {
-            String url = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLogin/login?__login=true&__ajax=json&username="+scanContent;
-            String loginResult = HttpUtils.sendRequest(url);
-            System.out.println("loginResult="+loginResult);
-            if(loginResult.equalsIgnoreCase("false")) {
-                JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录异常,请检查网络或联系网络管理员","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                return;
-            }else {
-                JSONObject retObj = JSONObject.parseObject(loginResult);
-                if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
-                    //检查用户权限是否可登录界面
-                    checkUserAuthority(retObj);
-                }else {
-                    JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录失败,用户名或密码错误","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                    return;
-                }
-            }
-        }else {
-            JOptionPane.showMessageDialog(MesClient.mesClientFrame,"扫码内容错误","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-            return;
-        }
-    }
-
-    //检查用户权限是否可登录界面
-    public static void checkUserAuthority(JSONObject retObj) {
-        //设置登录用户名
-        JSONObject userObj = JSONObject.parseObject(retObj.get("user").toString());
-        String user_id = userObj.getString("id").toString();
-
-        //获取sessionid,判断权限
-        MesClient.sessionid = retObj.get("sessionid").toString();
-        if(MesClient.sessionid!=null&&!MesClient.sessionid.equalsIgnoreCase("")) {
-            //请求权限
-            String url_authority = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesLineProcess/userAuth?__ajax=json&type=0&__sid="+MesClient.sessionid+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
-            String authorityResult = HttpUtils.sendRequest(url_authority);
-            System.out.println("authorityResult="+authorityResult);
-            JSONObject authorityObj = JSONObject.parseObject(authorityResult);
-            if(authorityObj.get("result")!=null&&authorityObj.get("result").toString().equalsIgnoreCase("true")) {
-                JSONObject authObjTmp = JSONObject.parseObject(authorityObj.get("data").toString());
-                MesClient.mes_auth = Integer.parseInt(authObjTmp.getString("auth").toString());
-                if(MesClient.mes_auth==0) {
-                    //无权限登录
-                    JOptionPane.showMessageDialog(MesClient.mesClientFrame,"您无权登录该工位","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-                    return;
-                }else if(MesClient.mes_auth==1||MesClient.mes_auth==2) {
-                    // 获取等于所处时间-当前小时
-                    LocalDateTime now = LocalDateTime.now();
-                    MesClient.userLoginHours = now.getHour();
-                    //初始化tcp连接,发送同步报文
-                    MesClient.initTcpConnection();
-                    //启动timer心跳包
-                    MesClient.startHeartBeatTimer();
-
-                    //1操作工人,2管理员
-                    //登录成功
-                    MesClient.user_menu.setText(user_id);
-                    MesClient.welcomeWin.setVisible(false);
-                    // Apply the maximized state when the main window is actually shown after login.
-                    MesClient.mesClientFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
-                    MesClient.mesClientFrame.setVisible(true);
-                    MesClient.mesClientFrame.revalidate();
-                    MesClient.mesClientFrame.repaint();
-
-                    if(MesClient.jfxPanel == null){
-                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/work?oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
-                        MesClient.jfxPanel = new MesWebView(url);
-                        MesClient.indexPanelB.add(MesClient.jfxPanel, BorderLayout.CENTER);
-                    }
-
-                    if(MesClient.jfxPanel2 == null){
-                        String url = "http://"+ MesClient.mes_server_ip+":8980/js/a/mes/mesProcessCheckRecord/ulist?ucode="+user_id+"&oprno="+MesClient.mes_gw+"&lineSn="+MesClient.mes_line_sn;
-                        MesClient.jfxPanel2 = new MesWebView(url);
-                        MesClient.indexPanelC.add(MesClient.jfxPanel2, BorderLayout.CENTER);
-                    }
-
-                    MesClient.initWarehouseData();
-                }
-
-            }
-
-        }else {
-            JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录失败,用户名或密码错误","提示窗口", JOptionPane.INFORMATION_MESSAGE);
-            return;
-        }
-    }
-}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 235 - 964
src/com/mes/ui/MesClient.java


+ 0 - 107
src/com/mes/ui/MesRevice.java

@@ -1,107 +0,0 @@
-package com.mes.ui;
-
-import com.mes.netty.ProtocolParam;
-import com.mes.component.MyDialog;
-import com.mes.util.ErrorMsg;
-
-import javax.swing.*;
-import java.awt.*;
-
-public class MesRevice {
-
-    // 质量查询
-    public static void checkQualityRevice(String processMsgRet,String mes_msg){
-        try{
-            if(processMsgRet.equalsIgnoreCase("UD")) {
-                String sn = ProtocolParam.getSn(mes_msg).trim();
-                MesClient.status_menu.setForeground(Color.GREEN);
-                MesClient.check_quality_result = true;//质量合格,可以绑定加工
-                MesClient.status_menu.setText("该工件可以加工");
-                MesClient.work_status = 1;
-                MesClient.f_scan_data_bt_1.setEnabled(false);
-                MesClient.finish_ok_bt.setEnabled(true);
-                MesClient.finish_ng_bt.setEnabled(true);
-
-                String oprno = ProtocolParam.getOprno(mes_msg).trim();
-                if(oprno.equals("OP400")){
-                    String lx = ProtocolParam.getLx(mes_msg);
-                    if(lx.equals("FX")){
-                        MesClient.fxlabel.setVisible(true);
-                    }
-                }
-
-                // 自动提交OK结果
-                String barcode36 = MesClient.getBarcode(sn);
-                if(!barcode36.isEmpty()){
-                    MesClient.getUser();
-                    String qret = "OK";
-                    Boolean sendret = DataUtil.sendQuality(MesClient.nettyClient,barcode36,qret,MesClient.user20);
-                    if(!sendret){
-                        MesClient.setMenuStatus("消息发送失败,请重试",-1);
-                    }
-                }
-            }else {
-                MesClient.check_quality_result = false;
-                String lmsg = ErrorMsg.getErrorMsg(processMsgRet, ProtocolParam.getLx(mes_msg));
-                MesClient.setMenuStatus(lmsg,-1);
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    // 开始回复处理
-    public static void startRevice(String processMsgRet,String mes_msg){
-        try{
-            if(processMsgRet.equalsIgnoreCase("OK")) {
-
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    // 绑定
-    public static void bindRevice(String processMsgRet,String mes_msg){
-        try{
-            if(processMsgRet.equalsIgnoreCase("OK")) {
-
-            }else{
-
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    // 解绑
-    public static void unbindRevice(String processMsgRet,String mes_msg){
-        try{
-            if(processMsgRet.equalsIgnoreCase("OK")) {
-
-            }else{
-
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-    // 上传质量
-    public static void updateResultRevice(String processMsgRet,String mes_msg){
-        try{
-            if(processMsgRet.equalsIgnoreCase("OK")) {
-
-                MesClient.resetScanA();
-                MesClient.setMenuStatus("结果提交成功,请扫下一件",0);
-                MesClient.scan_type = 1;
-                MesClient.scanBarcode();
-
-            }else{
-                MesClient.setMenuStatus("结果提交失败,请重试",-1);
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-}

+ 0 - 53
src/com/mes/ui/OprnoUtil.java

@@ -1,53 +0,0 @@
-package com.mes.ui;
-
-/**
- * 工位描述工具:硬编码工位列表,避免每台客户端都依赖服务端接口。
- */
-public class OprnoUtil {
-
-    /** T9 产线工位号(按 sorts 排序) */
-    public static String[] t9oprnos = new String[]{
-            "OP040", "OP050", "OP060", "OP070", "INSP030",
-            "OP090", "OP100", "OP120", "OP130", "INSP050",
-            "INSP060", "OP170", "OP190", "OP200", "INSP080",
-            "OP230", "INSP090", "INSP100", "INSP130", "INSP110",
-            "OP250"
-    };
-
-    /** T9 产线工位名(与 t9oprnos 一一对应) */
-    public static String[] t9oprnodes = new String[]{
-            "激光打码", "框架总成焊接1", "框架总成焊接2", "人工补焊1", "框架气密",
-            "框架激光切割正面", "框架激光切割反面", "套筒焊接", "人工补焊2", "总成检具检验",
-            "黑件入库", "紧固件装配正面/反面", "框架涂胶", "冷板装配", "半成品气密",
-            "安装密封垫底护板", "整包气密", "液冷板气密", "等电位电阻测试", "CCD检测",
-            "包装入库"
-    };
-
-    /**
-     * 根据工位号查工位描述。
-     * 子工位号自动转父工位(OP040A -> OP040、INSP030A -> INSP030)。
-     */
-    public static String getGwDes(String lineSn, String oprno) {
-        if (oprno == null) return "";
-        String code = formatOprno(oprno);
-        for (int i = 0; i < t9oprnos.length; i++) {
-            if (t9oprnos[i].equals(code)) return t9oprnodes[i];
-        }
-        return "";
-    }
-
-    /**
-     * 子工位号 -> 父工位号。
-     * 规则:去除末尾连续字母,前提是字母前是数字,如 OP040A -> OP040、INSP030B -> INSP030。
-     */
-    public static String formatOprno(String oprno) {
-        if (oprno == null) return "";
-        int len = oprno.length();
-        while (len > 1
-                && Character.isLetter(oprno.charAt(len - 1))
-                && Character.isDigit(oprno.charAt(len - 2))) {
-            len--;
-        }
-        return oprno.substring(0, len);
-    }
-}

+ 0 - 112
src/com/mes/ui/StationConfig.java

@@ -1,112 +0,0 @@
-package com.mes.ui;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.util.Properties;
-
-public class StationConfig {
-
-    private static final String RUNTIME_CONFIG_PATH = "config/runtime.properties";
-
-    public static String loadRuntimeGw(String defaultGw) {
-        File file = new File(RUNTIME_CONFIG_PATH);
-        if (!file.exists()) {
-            return defaultGw;
-        }
-
-        Properties pro = new Properties();
-        BufferedReader br = null;
-        try {
-            br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
-            pro.load(br);
-            String runtimeGw = pro.getProperty("mes.gw");
-            if (runtimeGw == null || runtimeGw.trim().equalsIgnoreCase("")) {
-                return defaultGw;
-            }
-            return runtimeGw.trim();
-        } catch (Exception e) {
-            return defaultGw;
-        } finally {
-            if (br != null) {
-                try {
-                    br.close();
-                } catch (IOException ignored) {
-                }
-            }
-        }
-    }
-
-    // ---- 工件码前缀校验(多前缀,逗号分隔;列表为空=不校验)----
-    private static final String BARCODE_PREFIX_KEY = "mes.barcode_prefix";
-
-    /** 读前缀列表,空列表表示不校验 */
-    public static java.util.List<String> loadBarcodePrefixes() {
-        java.util.List<String> list = new java.util.ArrayList<String>();
-        File file = new File(RUNTIME_CONFIG_PATH);
-        if (!file.exists()) return list;
-        Properties pro = new Properties();
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) {
-            pro.load(br);
-            String v = pro.getProperty(BARCODE_PREFIX_KEY);
-            if (v == null) return list;
-            for (String s : v.split(",")) {
-                String t = s.trim();
-                if (!t.isEmpty() && !list.contains(t)) list.add(t);
-            }
-        } catch (Exception ignored) {
-        }
-        return list;
-    }
-
-    /** 保存前缀列表,保留文件其他 key */
-    public static void saveBarcodePrefixes(java.util.List<String> prefixes) throws IOException {
-        StringBuilder sb = new StringBuilder();
-        if (prefixes != null) {
-            for (String p : prefixes) {
-                if (p == null || p.trim().isEmpty()) continue;
-                if (sb.length() > 0) sb.append(",");
-                sb.append(p.trim());
-            }
-        }
-        File file = new File(RUNTIME_CONFIG_PATH);
-        Properties pro = new Properties();
-        if (file.exists()) {
-            try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"))) {
-                pro.load(br);
-            }
-        }
-        pro.setProperty(BARCODE_PREFIX_KEY, sb.toString());
-        File parent = file.getParentFile();
-        if (parent != null && !parent.exists()) parent.mkdirs();
-        try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"))) {
-            pro.store(bw, "runtime station config");
-        }
-    }
-
-    public static void saveRuntimeGw(String gw) throws IOException {
-        File file = new File(RUNTIME_CONFIG_PATH);
-        File parent = file.getParentFile();
-        if (parent != null && !parent.exists()) {
-            parent.mkdirs();
-        }
-
-        Properties pro = new Properties();
-        pro.setProperty("mes.gw", gw);
-
-        BufferedWriter bw = null;
-        try {
-            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
-            pro.store(bw, "runtime station config");
-        } finally {
-            if (bw != null) {
-                bw.close();
-            }
-        }
-    }
-}

+ 0 - 43
src/com/mes/ui/TableCellEditorButton.java

@@ -1,43 +0,0 @@
-package com.mes.ui;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-public class TableCellEditorButton extends DefaultCellEditor {
-    private JButton btn;
-    public TableCellEditorButton() {
-        super(new JTextField());
-        //设置点击一次就激活,否则默认好像是点击2次激活。
-        this.setClickCountToStart(1);
-        btn = new JButton("扫码");
-        btn.addActionListener(new ActionListener() {
-
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                System.out.println("按钮事件触发----");
-                int selectedRow = MesClient.table.getSelectedRow();//获得选中行的索引
-//                MesClient.rowData[selectedRow][1] = (new Date()).getTime();
-//                MesClient.table.repaint(); //重绘
-
-//                MesClient.scan_type = selectedRow + 4;
-                BindMaterialResp bindMaterialResp = new BindMaterialResp();
-                bindMaterialResp.setMaterialTitle(MesClient.rowData[selectedRow][0] + "");
-                bindMaterialResp.setBatchSn(MesClient.rowData[selectedRow][1] + "");
-                bindMaterialResp.setLastTimes(MesClient.rowData[selectedRow][2] + "");
-                bindMaterialResp.setCraft(MesClient.rowData[selectedRow][4] + "");
-                bindMaterialResp.setMaterialId(MesClient.rowData[selectedRow][5] + "");
-                bindMaterialResp.setType(MesClient.rowData[selectedRow][6] + "");
-
-                MesClient.scanBatchSn(bindMaterialResp);
-            }
-        });
-
-    }
-    @Override
-    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
-
-        return btn;
-    }
-}

+ 0 - 14
src/com/mes/ui/TableCellRendererButton.java

@@ -1,14 +0,0 @@
-package com.mes.ui;
-
-import javax.swing.*;
-import javax.swing.table.TableCellRenderer;
-import java.awt.*;
-
-public class TableCellRendererButton implements TableCellRenderer {
-    @Override
-    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
-                                                   int row, int column) {
-        JButton button = new JButton("扫码");
-        return button;
-    }
-}

+ 0 - 11
src/com/mes/util/Base64Utils.java

@@ -1,11 +0,0 @@
-package com.mes.util;
-
-import org.apache.commons.codec.binary.Base64;
-
-public class Base64Utils {
-	public static String getBase64(String str) {
-        byte[] binaryData = str.getBytes();
-        String encodedString = Base64.encodeBase64String(binaryData);
-        return encodedString;
-	}
-}

+ 0 - 242
src/com/mes/util/ClientRuntimeAgent.java

@@ -1,242 +0,0 @@
-package com.mes.util;
-
-import com.alibaba.fastjson2.JSONObject;
-
-import java.io.*;
-import java.net.*;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.*;
-import java.util.Properties;
-import java.util.concurrent.*;
-
-/**
- * 客户端运行状态代理。
- * - 类型由 ClientType.CODE 硬编码自报
- * - clientId 由服务端根据 (类型, IP) 决定
- * - 心跳上报本地 config.properties 当前内容(currentConfigJson)
- * - 服务端下发 desiredConfigJson 直接合并写回 config.properties(备份 .bak)→ 重启生效
- * - 服务端下发 desiredJarVersion 与本地不一致 → 下载对应 jar → 备份 .bak → 替换 → 重启
- */
-public final class ClientRuntimeAgent {
-    private static final ScheduledExecutorService EXEC = Executors.newSingleThreadScheduledExecutor(r -> {
-        Thread t = new Thread(r, "client-runtime-agent");
-        t.setDaemon(true);
-        return t;
-    });
-    private static volatile boolean updating;
-
-    private ClientRuntimeAgent() {}
-
-    public static void start(String serverIp, String station, String line) {
-        start(serverIp, station, line, "com.mes.ui.MesClient");
-    }
-
-    public static void start(final String serverIp, final String station, final String line, final String mainClass) {
-        if (serverIp == null || serverIp.trim().isEmpty()) return;
-        send(serverIp, station, line, mainClass);
-        EXEC.scheduleAtFixedRate(() -> send(serverIp, station, line, mainClass), 30, 30, TimeUnit.SECONDS);
-    }
-
-    private static void send(String serverIp, String station, String line, String mainClass) {
-        String type = ClientType.CODE;
-        try {
-            String body = "clientType=" + enc(type)
-                    + "&stationCode=" + enc(station)
-                    + "&lineSn=" + enc(line)
-                    + "&jarVersion=" + version()
-                    + "&configVersion=" + configVersion()
-                    + "&status=RUNNING"
-                    + "&statusMessage=" + enc("客户端运行中")
-                    + "&currentConfigJson=" + enc(readLocalConfigAsJson());
-            HttpURLConnection c = (HttpURLConnection) new URL("http://" + serverIp + ":8980/js/a/mes/clientRuntime/heartbeat").openConnection();
-            c.setRequestMethod("POST");
-            c.setConnectTimeout(5000);
-            c.setReadTimeout(10000);
-            c.setDoOutput(true);
-            c.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
-            byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
-            c.setFixedLengthStreamingMode(bytes.length);
-            try (OutputStream out = c.getOutputStream()) { out.write(bytes); }
-            int code = c.getResponseCode();
-            System.out.println("[ClientRuntime] heartbeat type=" + type + " code=" + code);
-            if (code == 200) {
-                String resp = read(c.getInputStream());
-                System.out.println("[ClientRuntime] response=" + resp);
-                JSONObject data = JSONObject.parseObject(resp).getJSONObject("data");
-                if (data != null) {
-                    Long cv = data.getLong("desiredConfigVersion");
-                    String cfg = data.getString("desiredConfigJson");
-                    if (cv != null && cfg != null && !cfg.trim().isEmpty() && cv > configVersion()) {
-                        applyConfig(cv, cfg, mainClass);
-                        return; // applyConfig 会重启,不用继续处理 jar
-                    }
-                    Long jv = data.getLong("desiredJarVersion");
-                    if (jv != null && jv > version() && !updating) update(serverIp, type, jv, mainClass);
-                }
-            } else {
-                System.err.println("[ClientRuntime] heartbeat rejected code=" + code);
-            }
-            c.disconnect();
-        } catch (Exception e) {
-            System.err.println("[ClientRuntime] heartbeat/update failed: " + e.getMessage());
-        }
-    }
-
-    // 读本地 config/config.properties 转为 JSON 字符串
-    private static String readLocalConfigAsJson() {
-        Path p = Paths.get("config", "config.properties");
-        if (!Files.exists(p)) return "";
-        try {
-            Properties props = new Properties();
-            try (InputStream in = Files.newInputStream(p)) { props.load(in); }
-            StringBuilder sb = new StringBuilder("{");
-            boolean first = true;
-            for (String key : props.stringPropertyNames()) {
-                if (!first) sb.append(",");
-                first = false;
-                sb.append('"').append(esc(key)).append("\":\"").append(esc(props.getProperty(key))).append('"');
-            }
-            sb.append('}');
-            return sb.toString();
-        } catch (Exception e) {
-            return "";
-        }
-    }
-
-    /**
-     * 应用服务端下发的配置:合并到 config.properties(保留未下发的 key),备份 .bak,然后重启生效。
-     */
-    private static void applyConfig(long ver, String cfg, String mainClass) throws Exception {
-        JSONObject json;
-        try { json = JSONObject.parseObject(cfg); } catch (Exception e) { System.err.println("[ClientRuntime] invalid config json"); return; }
-        if (json == null || json.isEmpty()) return;
-
-        Path dir = Paths.get("config");
-        Files.createDirectories(dir);
-        Path pfile = dir.resolve("config.properties");
-        Properties props = new Properties();
-        if (Files.exists(pfile)) {
-            try (InputStream in = Files.newInputStream(pfile)) { props.load(in); }
-            Files.copy(pfile, dir.resolve("config.properties.bak"), StandardCopyOption.REPLACE_EXISTING);
-        }
-        // 合并:JSON 里的 key 覆盖到 properties
-        for (String key : json.keySet()) {
-            String val = json.getString(key);
-            if (val == null) continue;
-            props.setProperty(key, val);
-        }
-        try (OutputStream out = Files.newOutputStream(pfile)) {
-            props.store(out, "Updated by ClientRuntimeAgent " + new java.util.Date());
-        }
-        // 注意:config-version.txt 不在这里写,交给 restartSelf 的 vbs 在启动新 Java 前写
-        // 这样即使 restart 失败,version 也不会被更新,下次心跳仍会触发同一个 applyConfig
-        System.out.println("[ClientRuntime] config applied v=" + ver + ", restarting");
-        restartSelf(mainClass, ver);
-    }
-
-    /** 触发升级:下载新 jar → 备份 → 替换 → 重启 */
-    private static void update(String serverIp, String type, long target, String mainClass) throws Exception {
-        updating = true;
-        JSONObject root = JSONObject.parseObject(read(new URL("http://" + serverIp + ":8980/js/a/mes/clientVersion/ver?clientType=" + enc(type) + "&version=" + target).openStream()));
-        JSONObject data = root.getJSONObject("data");
-        if (data == null) throw new IOException("target version unavailable");
-        File jar = currentJar();
-        File download = new File(jar.getParentFile(), jar.getName() + ".download");
-        download(data.getString("path"), download);
-        if (download.length() == 0) throw new IOException("empty download");
-        // 版本号不在这里写,改由 VBScript 在移动文件成功后写入,避免 VBS 失败时版本号已变
-
-        File vbs = new File(jar.getParentFile(), "client-update-" + System.currentTimeMillis() + ".vbs");
-        String jarPath = jar.getAbsolutePath();
-        String bakPath = jarPath + ".bak";
-        String downloadPath = download.getAbsolutePath();
-        String libGlob = new File(jar.getParentFile(), "lib").getAbsolutePath() + File.separator + "*";
-        String workDir = jar.getParentFile().getAbsolutePath();
-        String verFile = new File(new File(workDir, "config"), "client-version.txt").getAbsolutePath();
-        try (Writer w = new OutputStreamWriter(new FileOutputStream(vbs), StandardCharsets.UTF_8)) {
-            w.write(
-                "Set sh = CreateObject(\"WScript.Shell\")\r\n" +
-                "Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n" +
-                "WScript.Sleep 2000\r\n" +
-                "If fso.FileExists(\"" + jarPath + "\") Then\r\n" +
-                "  If fso.FileExists(\"" + bakPath + "\") Then fso.DeleteFile \"" + bakPath + "\"\r\n" +
-                "  fso.MoveFile \"" + jarPath + "\", \"" + bakPath + "\"\r\n" +
-                "End If\r\n" +
-                "fso.MoveFile \"" + downloadPath + "\", \"" + jarPath + "\"\r\n" +
-                "Set f = fso.CreateTextFile(\"" + verFile + "\", True)\r\n" +
-                "f.Write \"" + target + "\"\r\n" +
-                "f.Close\r\n" +
-                "sh.CurrentDirectory = \"" + workDir + "\"\r\n" +
-                "sh.Run \"javaw -cp \"\"" + jarPath + ";" + libGlob + "\"\" " + mainClass + "\", 0, False\r\n" +
-                "fso.DeleteFile WScript.ScriptFullName\r\n"
-            );
-        }
-        new ProcessBuilder("wscript.exe", vbs.getAbsolutePath()).start();
-        System.exit(0);
-    }
-
-    /** 仅重启当前 jar,不替换文件(用于配置生效);vbs 在启动新 Java 前把 verToWrite 写入 config-version.txt */
-    private static void restartSelf(String mainClass, long verToWrite) throws Exception {
-        File jar = currentJar();
-        File vbs = new File(jar.getParentFile(), "client-restart-" + System.currentTimeMillis() + ".vbs");
-        String jarPath = jar.getAbsolutePath();
-        String libGlob = new File(jar.getParentFile(), "lib").getAbsolutePath() + File.separator + "*";
-        String workDir = jar.getParentFile().getAbsolutePath();
-        String verFile = new File(new File(workDir, "config"), "config-version.txt").getAbsolutePath();
-        try (Writer w = new OutputStreamWriter(new FileOutputStream(vbs), StandardCharsets.UTF_8)) {
-            w.write(
-                "Set sh = CreateObject(\"WScript.Shell\")\r\n" +
-                "Set fso = CreateObject(\"Scripting.FileSystemObject\")\r\n" +
-                "WScript.Sleep 2000\r\n" +
-                "Set f = fso.CreateTextFile(\"" + verFile + "\", True)\r\n" +
-                "f.Write \"" + verToWrite + "\"\r\n" +
-                "f.Close\r\n" +
-                "sh.CurrentDirectory = \"" + workDir + "\"\r\n" +
-                "sh.Run \"javaw -cp \"\"" + jarPath + ";" + libGlob + "\"\" " + mainClass + "\", 0, False\r\n" +
-                "fso.DeleteFile WScript.ScriptFullName\r\n"
-            );
-        }
-        new ProcessBuilder("wscript.exe", vbs.getAbsolutePath()).start();
-        System.exit(0);
-    }
-
-    private static void download(String u, File f) throws IOException {
-        HttpURLConnection c = (HttpURLConnection) new URL(u).openConnection();
-        c.setConnectTimeout(10000);
-        c.setReadTimeout(120000);
-        if (c.getResponseCode() != 200) throw new IOException("download failed");
-        try (InputStream in = c.getInputStream(); OutputStream out = new FileOutputStream(f)) {
-            byte[] b = new byte[8192];
-            int n;
-            while ((n = in.read(b)) != -1) out.write(b, 0, n);
-        } finally { c.disconnect(); }
-    }
-
-    private static File currentJar() throws Exception {
-        File f = new File(ClientRuntimeAgent.class.getProtectionDomain().getCodeSource().getLocation().toURI());
-        if (!f.isFile()) throw new IOException("not running from jar");
-        return f;
-    }
-
-    private static long version() { return readLong("client-version.txt", 1); }
-    private static long configVersion() { return readLong("config-version.txt", 0); }
-    private static long readLong(String n, long d) {
-        try { return Long.parseLong(new String(Files.readAllBytes(Paths.get("config", n)), StandardCharsets.UTF_8).trim()); }
-        catch (Exception e) { return d; }
-    }
-    private static String enc(String s) {
-        try { return URLEncoder.encode(s == null ? "" : s, "UTF-8"); } catch (Exception e) { return ""; }
-    }
-    private static String esc(String s) {
-        if (s == null) return "";
-        return s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r").replace("\t", "\\t");
-    }
-    private static String read(InputStream in) throws IOException {
-        try (BufferedReader r = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
-            StringBuilder b = new StringBuilder();
-            String l;
-            while ((l = r.readLine()) != null) b.append(l);
-            return b.toString();
-        }
-    }
-}

+ 0 - 13
src/com/mes/util/ClientType.java

@@ -1,13 +0,0 @@
-package com.mes.util;
-
-/**
- * 客户端类型常量。
- * 每个客户端项目值不同,由 JAR 自报,不从本地配置读,防止串味。
- *   mesclient-okng     → MANUAL
- *   mesclient-qm       → QIMI
- *   mesclient-op170    → RIVETING
- */
-public final class ClientType {
-    public static final String CODE = "MANUAL";
-    private ClientType() {}
-}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 0 - 46
src/com/mes/util/ClientUpdateUtil.java


+ 0 - 32
src/com/mes/util/DateLocalUtils.java

@@ -1,32 +0,0 @@
-package com.mes.util;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class DateLocalUtils {
-	public static SimpleDateFormat DATA_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
-	public static SimpleDateFormat DATA_FORMAT1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-	
-	
-	public static String getCurrentTime() {
-		String currentTime = DATA_FORMAT.format(new Date());
-		return currentTime;
-	}
-	
-	public static String getCurrentTime1() {
-		String currentTime = DATA_FORMAT1.format(new Date());
-		return currentTime;
-	}
-
-	public static SimpleDateFormat DATA_FORMAT2 = new SimpleDateFormat("yyyy-MM-dd");
-	public static String getCurrentDate() {
-		String currentTime = DATA_FORMAT2.format(new Date());
-		return currentTime;
-	}
-
-	public static SimpleDateFormat DATA_FORMAT3 = new SimpleDateFormat("HH:mm:ss");
-	public static String getCurrentTimeHMS() {
-		String currentTime = DATA_FORMAT3.format(new Date());
-		return currentTime;
-	}
-}

+ 0 - 64
src/com/mes/util/ErrorMsg.java

@@ -1,64 +0,0 @@
-package com.mes.util;
-
-public class ErrorMsg {
-    public static String getErrorMsg(String processMsgRet,String lx){
-        String lmsg = "该工件本工位不可加工";
-        try{
-            if(processMsgRet.equalsIgnoreCase("OK")||processMsgRet.equalsIgnoreCase("NG")) {
-                lmsg = "该工件本工位已加工,结果:"+processMsgRet;
-            }else if(processMsgRet.equalsIgnoreCase("NE")) {
-                lmsg = "该工件未录入系统";
-            }else if(processMsgRet.equalsIgnoreCase("NN")) {
-                lmsg = "该工件跳过该工位";
-            }else if(processMsgRet.equalsIgnoreCase("QN")) {
-                lmsg = "该工件"+ getOprnoName(lx)+"加工NG";
-            }else if(processMsgRet.equalsIgnoreCase("QD")) {
-                lmsg = "该工件"+ getOprnoName(lx)+"未加工";
-            }else if(processMsgRet.equalsIgnoreCase("NF")) {
-                lmsg = "该工件已合格下线";
-            }else if(processMsgRet.equalsIgnoreCase("NR")) {
-                lmsg = "该工件离线返修中";
-            }else if(processMsgRet.equalsIgnoreCase("NB")) {
-                lmsg = "该工件已报废";
-            }else if(processMsgRet.equalsIgnoreCase("ND")) {
-                lmsg = "该工件NG待处理";
-            }else if(processMsgRet.equalsIgnoreCase("FN")) {
-                lmsg = "首件检查工件不合格停机";
-            }else if(processMsgRet.equalsIgnoreCase("GN")) {
-                lmsg = "更换配件首件检查不合格停机";
-            }else if(processMsgRet.equalsIgnoreCase("CS")) {
-                lmsg = "首件检查两小时内未检查,超时停机";
-            }else if(processMsgRet.equalsIgnoreCase("DJ")) {
-                lmsg = "未进行开班点检";
-            }else if(processMsgRet.equalsIgnoreCase("BM")) {
-                lmsg = "未绑定物料";
-            }else if(processMsgRet.equalsIgnoreCase("PL")) {
-                lmsg = "配件寿命不足";
-            }else if(processMsgRet.equalsIgnoreCase("QM")) {
-                lmsg = "两次气密必须间隔15分钟";
-            }else if(processMsgRet.equalsIgnoreCase("GS")) {
-                lmsg = "工件码格式不正确";
-            }else if(processMsgRet.equalsIgnoreCase("CF")) {
-                lmsg = "工件码重复";
-            }else if(processMsgRet.equalsIgnoreCase("AL")) {
-                lmsg = "该工件存在未处理的报警信息";
-            }
-        }catch (Exception e){ }
-        return lmsg;
-    }
-    private static String getOprnoName(String lx) {
-        if (lx == null) {
-            return "OP";
-        }
-        lx = lx.trim();
-        if (lx.startsWith("I")) {
-            try {
-                int num = Integer.parseInt(lx.substring(1)) * 10;
-                return String.format("INSP%03d", num);
-            } catch (Exception e) {
-                return "INSP" + lx.substring(1);
-            }
-        }
-        return "OP" + lx + "0";
-    }
-}

+ 0 - 157
src/com/mes/util/HttpUtils.java

@@ -1,157 +0,0 @@
-package com.mes.util;
-
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-public class HttpUtils {
-	/**
-	 * HTTP请求,正确报文解析,并保存数据到生产记录数据
-	 * @return 
-	 * @throws URISyntaxException
-	 */
-    //http post请求
-    public static String sendRequest(String urlParam) {
-		String requestType = "POST";
-        //根据接收内容返回数据结果
-    	String ret = "";
-    	System.out.println(urlParam);
-        HttpURLConnection con = null;
-        BufferedReader buffer = null;
-        StringBuffer resultBuffer = null;
-        try {
-            URL url = new URL(urlParam);
-            //得到连接对象
-            con = (HttpURLConnection) url.openConnection();
-            //设置请求类型
-            con.setRequestMethod(requestType);
-            //设置请求需要返回的数据类型和字符集类型
-            con.setRequestProperty("Content-Type", "application/json;charset=GBK");  
-            //允许写出
-            con.setDoOutput(true);
-            //允许读入
-            con.setDoInput(true);
-            //不使用缓存
-            con.setUseCaches(false);
-            //得到响应码
-            int responseCode = con.getResponseCode();
-            System.out.println("responseCode="+responseCode);
-            if(responseCode == HttpURLConnection.HTTP_OK){
-                //得到响应流
-                InputStream inputStream = con.getInputStream();
-                //将响应流转换成字符串
-                resultBuffer = new StringBuffer();
-                String line;
-                buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
-                while ((line = buffer.readLine()) != null) {
-                    resultBuffer.append(line);
-                }
-                System.out.println(resultBuffer.toString());
-                ret = resultBuffer.toString();
-            }else {
-            	//ret = String.valueOf(responseCode);
-            	ret = "false";
-            }
-            con.disconnect();
-        }catch(Exception e) {
-        	//ret = false;
-        	//System.out.println("e.toString()="+e.toString());
-        	//return e.toString();
-            //e.printStackTrace();
-        	ret = "false";
-        }
-        return ret;
-    }
-
-
-    public static String sendPostRequest(String urlParam, String params) {
-        String requestType = "POST";
-        //根据接收内容返回数据结果
-        String ret = "";
-        System.out.println(urlParam);
-        HttpURLConnection con = null;
-        BufferedReader buffer = null;
-        StringBuffer resultBuffer = null;
-        try {
-            URL url = new URL(urlParam);
-            //得到连接对象
-            con = (HttpURLConnection) url.openConnection();
-            //设置请求类型
-            con.setRequestMethod(requestType);
-            //设置请求需要返回的数据类型和字符集类型
-            con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=GBK");
-            //允许写出
-            con.setDoOutput(true);
-            //允许读入
-            con.setDoInput(true);
-            //不使用缓存
-            con.setUseCaches(false);
-
-            // 获取URLConnection对象对应的输出流
-            OutputStreamWriter out = new OutputStreamWriter( con.getOutputStream(),"UTF-8");// utf-8编码
-            // 发送请求参数
-            out.write(params);
-
-            //得到响应码
-            int responseCode = con.getResponseCode();
-            System.out.println("responseCode="+responseCode);
-            if(responseCode == HttpURLConnection.HTTP_OK){
-                //得到响应流
-                InputStream inputStream = con.getInputStream();
-                //将响应流转换成字符串
-                resultBuffer = new StringBuffer();
-                String line;
-                buffer = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
-                while ((line = buffer.readLine()) != null) {
-                    resultBuffer.append(line);
-                }
-                System.out.println(resultBuffer.toString());
-                ret = resultBuffer.toString();
-            }else {
-                //ret = String.valueOf(responseCode);
-                ret = "false";
-            }
-            con.disconnect();
-        }catch(Exception e) {
-            //ret = false;
-            //System.out.println("e.toString()="+e.toString());
-            //return e.toString();
-            //e.printStackTrace();
-            ret = "false";
-        }
-        return ret;
-    }
-
-    public static String sendPostRequestJson(String apiUrl, String jsonData) throws IOException {
-        URL url = new URL(apiUrl);
-        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-        conn.setRequestMethod("POST");
-        conn.setRequestProperty("Content-Type", "application/json");
-        conn.setDoOutput(true);
-
-        // 发送请求数据
-        try (OutputStream os = conn.getOutputStream()) {
-            byte[] input = jsonData.getBytes("utf-8");
-            os.write(input, 0, input.length);
-        }
-
-        // 获取响应数据
-        StringBuilder response = new StringBuilder();
-        int responseCode = conn.getResponseCode();
-//        System.out.println("Sending POST request to URL: " + apiUrl);
-//        System.out.println("Post parameters: " + jsonData);
-//        System.out.println("Response Code: " + responseCode);
-
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
-            String responseLine;
-            while ((responseLine = br.readLine()) != null) {
-                response.append(responseLine.trim());
-            }
-        }
-
-        conn.disconnect();
-        return response.toString();
-    }
-
-}

+ 0 - 145
src/com/mes/util/JdbcUtils.java

@@ -1,145 +0,0 @@
-package com.mes.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-public class JdbcUtils {
-	public static final Logger log =  LoggerFactory.getLogger(JdbcUtils.class);
-	//通过上面的工具就可以获取到properties文件中的键值从而可以加载驱动 获取链接 从而 可以增删改查
-	public static Connection conn = null;
-    public static String Drivde="org.sqlite.JDBC";
-	public static String DATABASE_URL="jdbc:sqlite:mes_db.db";
-    
-    public static Connection getConn(){
-        try {
-            Class.forName(Drivde);// 加载驱动,连接sqlite的jdbc
-            conn = DriverManager.getConnection(DATABASE_URL);//连接数据库zhou.db,不存在则创建
-            System.out.println("连接到SQLite数据库成功!");
-            create_bw_record();//初始化结构表
-            //create_measure_data();//初始化测试数据表
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-        	close();//关闭数据库连接
-            e.printStackTrace();
-        }
-        return conn;
-    }
-
-	public static void openConnection() {
-		try {
-			Class.forName(Drivde);// 加载驱动,连接sqlite的jdbc
-			conn = DriverManager.getConnection(DATABASE_URL);
-		} catch (ClassNotFoundException e) {
-			e.printStackTrace();
-		} catch (SQLException e) {
-			e.printStackTrace();
-			// 如果连接失败,尝试重连
-			reconnect();
-		}
-	}
-
-	private static void reconnect() {
-		try {
-			// 关闭旧连接
-			if (conn != null && !conn.isClosed()) {
-				conn.close();
-			}
-			// 重新建立连接
-			conn = DriverManager.getConnection(DATABASE_URL);
-		} catch (SQLException e) {
-			e.printStackTrace();
-			// 如果重连失败,可以进一步处理异常,比如记录日志、通知管理员等
-		}
-	}
-    
-    public static void create_bw_record() throws SQLException {
-    	Statement statement=conn.createStatement();   //创建连接对象,是Java的一个操作数据库的重要接口
-        //设备结构数据库
-        String sqlEquipment = "CREATE TABLE if not exists bw_record("
-        		+ "id INTEGER PRIMARY KEY AUTOINCREMENT,gw VARCHAR(20),gy VARCHAR(20),message_type VARCHAR(20),sn VARCHAR(48),bw VARCHAR(1000),record_time DATETIME,"
-        		+ "info_01 VARCHAR(200),info_02 VARCHAR(200),info_03 VARCHAR(200))";
-//        statement.executeUpdate("drop table if exists bw_record");//判断是否有表tables的存在。有则删除
-        statement.executeUpdate(sqlEquipment);
-
-		// 创建 提交记录表
-		String submitRecord = "CREATE TABLE if not exists submit_record(\n" +
-				"   id INTEGER PRIMARY KEY AUTOINCREMENT, -- 自增ID\n" +
-				"   oprno VARCHAR(20),                    -- 工位号 \n" +
-				"   sn VARCHAR(48),                       -- 二维码\n" +
-				"   bw VARCHAR(1000),                     -- 报文 \n" +
-				"   record_time DATETIME,                 -- 记录时间\n" +
-				"   state CHAR(1)      -- 状态(0 ->未提交, 1 ->已提交)\n" +
-				")";
-		statement.executeUpdate(submitRecord);
-
-        statement.close();
-    }
-    
-    //插入数据
-    public static boolean insertData(String gw, String gy, String bw, String message_type, String sn) {
-    	boolean ret = false;
-    	String record_time = DateLocalUtils.getCurrentTime();
-		try {
-			// 确保连接已经打开
-			if (JdbcUtils.conn == null || JdbcUtils.conn.isClosed()) {
-				JdbcUtils.openConnection();
-			}
-			//创建连接对象,是Java的一个操作数据库的重要接口
-			Statement statement=conn.createStatement();
-			statement.executeUpdate("INSERT INTO bw_record (gw,gy,bw,record_time,message_type,sn) VALUES"
-					+ " ('"+gw+"', '"+gy+"', '"+bw+"', '"+record_time+"','"+message_type+"','"+sn+"')");//向数据库中插入数据
-			statement.close();
-			ret = true;
-		} catch (SQLException e) {
-			// TODO Auto-generated catch block
-			//e.printStackTrace();
-			ret = false;
-		}
-
-		return ret;
-    }
-
-	// 向 submit_record表 插入提交记录数据
-	public static boolean insertSubmitRecord(String oprno, String sn, String bw){
-		boolean ret = false;
-		String record_time = DateLocalUtils.getCurrentTime();
-		try {
-			// 确保连接已经打开
-			if (JdbcUtils.conn == null || JdbcUtils.conn.isClosed()) {
-				JdbcUtils.openConnection();
-			}
-			Statement statement=conn.createStatement();
-			String insertSQL = "INSERT INTO submit_record (oprno, sn, bw, record_time, state)" +
-					"VALUES('" + oprno + "', '" + sn + "', '" + bw + "', '" + record_time + "', '0')";
-			statement.executeUpdate(insertSQL);
-			statement.close();
-			ret = true;
-			log.info("向submit_record表插入数据成功: {}", insertSQL);
-		} catch (SQLException e) {
-			ret = false;
-			log.info("向submit_record表插入数据失败");
-		}
-		return ret;
-	}
-
-    
-    public static void close(){
-        try {
-        	if(conn!=null) {
-        		conn.close();
-        	}
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }
-    }
-    
-    
-
-}
- 
-

+ 0 - 7
src/resources/config/config.properties

@@ -1,7 +0,0 @@
-mes.gw=OP120B
-#mes.server_ip=127.0.0.1
-mes.server_ip=192.168.114.99
-mes.tcp_port=3000
-
-mes.heart_beat_cycle=60
-mes.line_sn=XT

+ 0 - 44
src/resources/logback.xml

@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<configuration>
-
-    <!-- 定义日志文件的存储位置及文件名 -->
-    <property name="LOG_HOME" value="C:/Users/jcxa/Desktop/test/Logs"/>
-    <property name="PROJECT_NAME" value="log"/>
-
-    <!-- 控制台输出 -->
-    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder>
-            <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level  %logger{36} - %msg%n</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
-            <level>INFO</level>
-        </filter>
-    </appender>
-
-    <!-- 文件输出 -->
-    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <file>${LOG_HOME}/${PROJECT_NAME}/${PROJECT_NAME}.log</file>
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${LOG_HOME}/${PROJECT_NAME}/archived/${PROJECT_NAME}_%d{yyyy-MM-dd}.log</fileNamePattern>
-            <!-- 保留最近 1个月内的日志-->
-            <maxHistory>30</maxHistory>  <!-- 如果删除该项配置,则logback无法自动删除旧日志, 导致totalSizeCap也将失去作用-->
-            <!-- 滚动文件总大小不超过1GB-->
-            <totalSizeCap>1GB</totalSizeCap>
-        </rollingPolicy>
-        <encoder>
-            <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level  %logger{36} - %msg%n</pattern>
-        </encoder>
-    </appender>
-
-    <!-- 根Logger -->
-    <root level="info">
-        <appender-ref ref="STDOUT" />
-        <appender-ref ref="FILE" />
-    </root>
-
-    <logger name="org.slf4j" level="ERROR"/>
-    <logger name="ch.qos.logback" level="ERROR"/>
-    <logger name="ch.qos.logback.classic.joran.action.ConfigurationAction" level="OFF"/>
-
-</configuration>