hou 1 gün önce
işleme
f55612eade
100 değiştirilmiş dosya ile 4823 ekleme ve 0 silme
  1. 24 0
      .classpath
  2. 7 0
      .gitignore
  3. 17 0
      .project
  4. 2 0
      image/.gitignore
  5. BIN
      image/background.png
  6. BIN
      image/bg/a_side.png
  7. BIN
      image/bg/b_side.png
  8. BIN
      image/bg/bar_add.png
  9. BIN
      image/bg/bar_bookmark.png
  10. BIN
      image/bg/bar_cmd_go.png
  11. BIN
      image/bg/bar_edit.png
  12. BIN
      image/bg/bar_pause.png
  13. BIN
      image/bg/bar_sampling.png
  14. BIN
      image/bg/bar_setting.png
  15. BIN
      image/bg/bar_stop.png
  16. BIN
      image/bg/close_bt.png
  17. BIN
      image/bg/company_setting_logo.png
  18. BIN
      image/bg/delete.png
  19. BIN
      image/bg/department_setting_logo.png
  20. BIN
      image/bg/download.png
  21. BIN
      image/bg/equipment_setting_logo.png
  22. BIN
      image/bg/gj_001_1_20.png
  23. BIN
      image/bg/gj_001_21_40.png
  24. BIN
      image/bg/gj_001_41_60.png
  25. BIN
      image/bg/green_dot.png
  26. BIN
      image/bg/grey_dot.png
  27. BIN
      image/bg/icon.png
  28. BIN
      image/bg/inductance_logo.png
  29. BIN
      image/bg/insulation_logo.png
  30. BIN
      image/bg/login.png
  31. BIN
      image/bg/logo.png
  32. BIN
      image/bg/logoff.png
  33. BIN
      image/bg/menu_data_analysis.png
  34. BIN
      image/bg/menu_data_preprocess.png
  35. BIN
      image/bg/menu_file.png
  36. BIN
      image/bg/menu_setting.png
  37. BIN
      image/bg/min_bt.png
  38. BIN
      image/bg/ng_bg.png
  39. BIN
      image/bg/ok_bg.png
  40. BIN
      image/bg/open_file.png
  41. BIN
      image/bg/refresh.png
  42. BIN
      image/bg/reset_logo.png
  43. BIN
      image/bg/resistance_logo.png
  44. BIN
      image/bg/save_bg.png
  45. BIN
      image/bg/scan_barcode.png
  46. BIN
      image/bg/tree_folder_icon.png
  47. BIN
      image/bg/tree_leaf_icon.png
  48. BIN
      image/bg/user.png
  49. BIN
      image/bg/vertical_line.png
  50. BIN
      image/bg/zoom_in.png
  51. BIN
      image/bg/zoom_out.png
  52. BIN
      image/close_bt.png
  53. 0 0
      image/cmd.txt
  54. BIN
      image/icon.ico
  55. BIN
      image/info_bt.png
  56. BIN
      image/min_bt.png
  57. BIN
      lib/commons-codec-1.15.jar
  58. BIN
      lib/core-3.5.1.jar
  59. BIN
      lib/fastjson2-2.0.16.jar
  60. BIN
      lib/gson-2.10.jar
  61. BIN
      lib/iot-communication-1.4.4.jar
  62. BIN
      lib/javase-3.5.1.jar
  63. BIN
      lib/jfreechart-1.5.4.jar
  64. BIN
      lib/jshortcut-0.4-oberzalek.jar
  65. BIN
      lib/kotlin-stdlib-1.8.10.jar
  66. BIN
      lib/logback-classic-1.2.13.jar
  67. BIN
      lib/logback-core-1.2.13.jar
  68. BIN
      lib/netty-all-4.1.48.Final.jar
  69. BIN
      lib/okhttp-4.10.0.jar
  70. BIN
      lib/okio-jvm-3.3.0.jar
  71. BIN
      lib/s7connector-2.1.jar
  72. BIN
      lib/slf4j-api-1.7.36.jar
  73. BIN
      lib/sqlite-jdbc-3.36.0.3.jar
  74. 13 0
      src/com/mes/component/CallFromJs.java
  75. 659 0
      src/com/mes/component/CncLifeDialog.java
  76. 62 0
      src/com/mes/component/MesRadio.java
  77. 48 0
      src/com/mes/component/MesWebView.java
  78. 30 0
      src/com/mes/component/MyDialog.java
  79. 986 0
      src/com/mes/component/WorkJPanelDevice.java
  80. 31 0
      src/com/mes/entity/ToolParam.java
  81. 58 0
      src/com/mes/ui/BindMaterialResp.java
  82. 414 0
      src/com/mes/ui/DataUtil.java
  83. 200 0
      src/com/mes/ui/LoginFarme.java
  84. 598 0
      src/com/mes/ui/MesClient.java
  85. 56 0
      src/com/mes/ui/OprnoUtil.java
  86. 58 0
      src/com/mes/ui/ParamReq.java
  87. 48 0
      src/com/mes/ui/TableCellEditorButton.java
  88. 14 0
      src/com/mes/ui/TableCellRendererButton.java
  89. 61 0
      src/com/mes/ui/WorkRecordData.java
  90. 403 0
      src/com/mes/ui/WorkRecordPanel.java
  91. 63 0
      src/com/mes/ui/WorkRecordResp.java
  92. 19 0
      src/com/mes/util/Base64Utils.java
  93. 34 0
      src/com/mes/util/DateLocalUtils.java
  94. 45 0
      src/com/mes/util/ErrorMsg.java
  95. 164 0
      src/com/mes/util/HttpUtils.java
  96. 359 0
      src/com/mes/util/JdbcUtils.java
  97. 133 0
      src/com/mes/util/S7Util.java
  98. 120 0
      src/com/mes/util/SinumerikUtil.java
  99. 97 0
      src/com/mes/util/TCPClient.java
  100. 0 0
      src/resources/config/config.properties

+ 24 - 0
.classpath

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+		<attributes>
+			<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/fastjson2-2.0.16.jar"/>
+</classpath>

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+.idea
+.settings
+classes
+bin
+out
+*.db
+*.iml

+ 17 - 0
.project

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>mes-auto</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 2 - 0
image/.gitignore

@@ -0,0 +1,2 @@
+META-INF
+_system~.ini

BIN
image/background.png


BIN
image/bg/a_side.png


BIN
image/bg/b_side.png


BIN
image/bg/bar_add.png


BIN
image/bg/bar_bookmark.png


BIN
image/bg/bar_cmd_go.png


BIN
image/bg/bar_edit.png


BIN
image/bg/bar_pause.png


BIN
image/bg/bar_sampling.png


BIN
image/bg/bar_setting.png


BIN
image/bg/bar_stop.png


BIN
image/bg/close_bt.png


BIN
image/bg/company_setting_logo.png


BIN
image/bg/delete.png


BIN
image/bg/department_setting_logo.png


BIN
image/bg/download.png


BIN
image/bg/equipment_setting_logo.png


BIN
image/bg/gj_001_1_20.png


BIN
image/bg/gj_001_21_40.png


BIN
image/bg/gj_001_41_60.png


BIN
image/bg/green_dot.png


BIN
image/bg/grey_dot.png


BIN
image/bg/icon.png


BIN
image/bg/inductance_logo.png


BIN
image/bg/insulation_logo.png


BIN
image/bg/login.png


BIN
image/bg/logo.png


BIN
image/bg/logoff.png


BIN
image/bg/menu_data_analysis.png


BIN
image/bg/menu_data_preprocess.png


BIN
image/bg/menu_file.png


BIN
image/bg/menu_setting.png


BIN
image/bg/min_bt.png


BIN
image/bg/ng_bg.png


BIN
image/bg/ok_bg.png


BIN
image/bg/open_file.png


BIN
image/bg/refresh.png


BIN
image/bg/reset_logo.png


BIN
image/bg/resistance_logo.png


BIN
image/bg/save_bg.png


BIN
image/bg/scan_barcode.png


BIN
image/bg/tree_folder_icon.png


BIN
image/bg/tree_leaf_icon.png


BIN
image/bg/user.png


BIN
image/bg/vertical_line.png


BIN
image/bg/zoom_in.png


BIN
image/bg/zoom_out.png


BIN
image/close_bt.png


+ 0 - 0
image/cmd.txt


BIN
image/icon.ico


BIN
image/info_bt.png


BIN
image/min_bt.png


BIN
lib/commons-codec-1.15.jar


BIN
lib/core-3.5.1.jar


BIN
lib/fastjson2-2.0.16.jar


BIN
lib/gson-2.10.jar


BIN
lib/iot-communication-1.4.4.jar


BIN
lib/javase-3.5.1.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


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

@@ -0,0 +1,13 @@
+package com.mes.component;
+
+import com.mes.ui.MesClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CallFromJs {
+    public static final Logger log =  LoggerFactory.getLogger(CallFromJs.class);
+    public String callFromJs(String info){
+        log.info("ss:"+info);
+        return MesClient.sessionid+":java:" + info;
+    }
+}

+ 659 - 0
src/com/mes/component/CncLifeDialog.java

@@ -0,0 +1,659 @@
+package com.mes.component;
+
+import com.mes.entity.ToolParam;
+import com.mes.ui.MesClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CncLifeDialog extends JDialog {
+    public final Logger log =  LoggerFactory.getLogger(CncLifeDialog.class);
+
+    public CncLifeDialog(Frame owner, int[] toolNums,String[] toolTitle,String[] toolLife){
+        super(owner, "刀具寿命");
+
+        init(toolNums,toolTitle,toolLife);
+    }
+
+    public JLabel toolTitle1;
+    public JTextField toolNum1;
+    public JTextField toolLife1;
+    public JLabel toolTitle2;
+    public JTextField toolNum2;
+    public JTextField toolLife2;
+    public JLabel toolTitle3;
+    public JTextField toolNum3;
+    public JTextField toolLife3;
+    public JLabel toolTitle4;
+    public JTextField toolNum4;
+    public JTextField toolLife4;
+    public JLabel toolTitle5;
+    public JLabel toolTitle9;
+    public JLabel toolTitle13;
+    public JLabel toolTitle17;
+    public JTextField toolNum5;
+    public JTextField toolNum9;
+    public JTextField toolNum13;
+    public JTextField toolNum17;
+    public JTextField toolLife5;
+    public JTextField toolLife13;
+    public JTextField toolLife17;
+    public JLabel toolTitle6;
+    public JLabel toolTitle10;
+    public JLabel toolTitle14;
+    public JLabel toolTitle18;
+    public JTextField toolNum6;
+    public JTextField toolNum10;
+    public JTextField toolNum14;
+    public JTextField toolNum18;
+    public JTextField toolLife6;
+    public JTextField toolLife9;
+    public JTextField toolLife10;
+    public JTextField toolLife14;
+    public JTextField toolLife18;
+    public JLabel toolTitle7;
+    public JLabel toolTitle11;
+    public JLabel toolTitle15;
+    public JLabel toolTitle19;
+    public JTextField toolNum7;
+    public JTextField toolNum11;
+    public JTextField toolNum15;
+    public JTextField toolNum19;
+    public JTextField toolLife7;
+    public JTextField toolLife11;
+    public JTextField toolLife15;
+    public JTextField toolLife19;
+    public JLabel toolTitle8;
+    public JLabel toolTitle12;
+    public JLabel toolTitle16;
+    public JLabel toolTitle20;
+    public JTextField toolNum8;
+    public JTextField toolNum12;
+    public JTextField toolNum16;
+    public JTextField toolNum20;
+    public JTextField toolLife8;
+    public JTextField toolLife12;
+    public JTextField toolLife16;
+    public JTextField toolLife20;
+    public List<ToolParam> toolParams = new ArrayList<ToolParam>();
+
+    private void init(int[] toolNums,String[] toolTitle,String[] toolLife){
+        Container container = this.getContentPane();
+        container.setLayout(null);
+        this.setSize(1024,468);
+        this.setLocationRelativeTo(null);
+
+        toolTitle1 = new JLabel("");
+        toolTitle1.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle1.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle1.setBounds(50, 70, 100, 30);
+        container.add(toolTitle1);
+
+        toolNum1 = new JTextField();
+        toolNum1.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum1.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum1.setText("1");
+        toolNum1.setEnabled(false);
+        toolNum1.setBounds(154, 70, 30, 30);
+        container.add(toolNum1);
+        toolNum1.setColumns(10);
+
+        toolLife1 = new JTextField();
+        toolLife1.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife1.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife1.setEnabled(false);
+        toolLife1.setColumns(10);
+        toolLife1.setBounds(187, 70, 60, 30);
+        container.add(toolLife1);
+
+        toolTitle2 = new JLabel("");
+        toolTitle2.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle2.setBounds(258, 70, 100, 30);
+        container.add(toolTitle2);
+
+        toolNum2 = new JTextField();
+        toolNum2.setText("2");
+        toolNum2.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum2.setEnabled(false);
+        toolNum2.setColumns(10);
+        toolNum2.setBounds(359, 70, 30, 30);
+        container.add(toolNum2);
+
+        toolLife2 = new JTextField();
+        toolLife2.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife2.setEnabled(false);
+        toolLife2.setColumns(10);
+        toolLife2.setBounds(393, 70, 60, 30);
+        container.add(toolLife2);
+
+        toolTitle3 = new JLabel("");
+        toolTitle3.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle3.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle3.setBounds(472, 70, 100, 30);
+        container.add(toolTitle3);
+
+        toolNum3 = new JTextField();
+        toolNum3.setText("3");
+        toolNum3.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum3.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum3.setEnabled(false);
+        toolNum3.setColumns(10);
+        toolNum3.setBounds(572, 70, 30, 30);
+        container.add(toolNum3);
+
+        toolLife3 = new JTextField();
+        toolLife3.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife3.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife3.setEnabled(false);
+        toolLife3.setColumns(10);
+        toolLife3.setBounds(606, 70, 60, 30);
+        container.add(toolLife3);
+
+        toolTitle4 = new JLabel("");
+        toolTitle4.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle4.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle4.setBounds(676, 70, 100, 30);
+        container.add(toolTitle4);
+
+        toolNum4 = new JTextField();
+        toolNum4.setText("4");
+        toolNum4.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum4.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum4.setEnabled(false);
+        toolNum4.setColumns(10);
+        toolNum4.setBounds(776, 70, 30, 30);
+        container.add(toolNum4);
+
+        toolLife4 = new JTextField();
+        toolLife4.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife4.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife4.setEnabled(false);
+        toolLife4.setColumns(10);
+        toolLife4.setBounds(810, 70, 60, 30);
+        container.add(toolLife4);
+
+        toolTitle5 = new JLabel("");
+        toolTitle5.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle5.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle5.setBounds(50, 110, 100, 30);
+        container.add(toolTitle5);
+
+        toolTitle9 = new JLabel("");
+        toolTitle9.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle9.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle9.setBounds(50, 150, 100, 30);
+        container.add(toolTitle9);
+
+        toolTitle13 = new JLabel("");
+        toolTitle13.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle13.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle13.setBounds(50, 190, 100, 30);
+        container.add(toolTitle13);
+
+        toolTitle17 = new JLabel("");
+        toolTitle17.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle17.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle17.setBounds(50, 230, 100, 30);
+        container.add(toolTitle17);
+
+        toolNum5 = new JTextField();
+        toolNum5.setText("5");
+        toolNum5.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum5.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum5.setEnabled(false);
+        toolNum5.setColumns(10);
+        toolNum5.setBounds(154, 110, 30, 30);
+        container.add(toolNum5);
+
+        toolNum9 = new JTextField();
+        toolNum9.setText("9");
+        toolNum9.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum9.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum9.setEnabled(false);
+        toolNum9.setColumns(10);
+        toolNum9.setBounds(154, 150, 30, 30);
+        container.add(toolNum9);
+
+        toolNum13 = new JTextField();
+        toolNum13.setText("13");
+        toolNum13.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum13.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum13.setEnabled(false);
+        toolNum13.setColumns(10);
+        toolNum13.setBounds(154, 190, 30, 30);
+        container.add(toolNum13);
+
+        toolNum17 = new JTextField();
+        toolNum17.setText("17");
+        toolNum17.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum17.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum17.setEnabled(false);
+        toolNum17.setColumns(10);
+        toolNum17.setBounds(154, 230, 30, 30);
+        container.add(toolNum17);
+
+        toolLife5 = new JTextField();
+        toolLife5.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife5.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife5.setEnabled(false);
+        toolLife5.setColumns(10);
+        toolLife5.setBounds(186, 110, 60, 30);
+        container.add(toolLife5);
+
+        toolLife9 = new JTextField();
+        toolLife9.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife9.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife9.setEnabled(false);
+        toolLife9.setColumns(10);
+        toolLife9.setBounds(187, 150, 60, 30);
+        container.add(toolLife9);
+
+        toolLife13 = new JTextField();
+        toolLife13.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife13.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife13.setEnabled(false);
+        toolLife13.setColumns(10);
+        toolLife13.setBounds(187, 190, 60, 30);
+        container.add(toolLife13);
+
+        toolLife17 = new JTextField();
+        toolLife17.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife17.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife17.setEnabled(false);
+        toolLife17.setColumns(10);
+        toolLife17.setBounds(187, 230, 60, 30);
+        container.add(toolLife17);
+
+        toolTitle6 = new JLabel("");
+        toolTitle6.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle6.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle6.setBounds(258, 110, 100, 30);
+        container.add(toolTitle6);
+
+        toolTitle10 = new JLabel("");
+        toolTitle10.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle10.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle10.setBounds(258, 150, 100, 30);
+        container.add(toolTitle10);
+
+        toolTitle14 = new JLabel("");
+        toolTitle14.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle14.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle14.setBounds(258, 190, 100, 30);
+        container.add(toolTitle14);
+
+        toolTitle18 = new JLabel("");
+        toolTitle18.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle18.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle18.setBounds(258, 230, 100, 30);
+        container.add(toolTitle18);
+
+        toolNum6 = new JTextField();
+        toolNum6.setText("6");
+        toolNum6.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum6.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum6.setEnabled(false);
+        toolNum6.setColumns(10);
+        toolNum6.setBounds(359, 110, 30, 30);
+        container.add(toolNum6);
+
+        toolNum10 = new JTextField();
+        toolNum10.setText("10");
+        toolNum10.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum10.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum10.setEnabled(false);
+        toolNum10.setColumns(10);
+        toolNum10.setBounds(359, 150, 30, 30);
+        container.add(toolNum10);
+
+        toolNum14 = new JTextField();
+        toolNum14.setText("14");
+        toolNum14.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum14.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum14.setEnabled(false);
+        toolNum14.setColumns(10);
+        toolNum14.setBounds(359, 190, 30, 30);
+        container.add(toolNum14);
+
+        toolNum18 = new JTextField();
+        toolNum18.setText("18");
+        toolNum18.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum18.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum18.setEnabled(false);
+        toolNum18.setColumns(10);
+        toolNum18.setBounds(359, 230, 30, 30);
+        container.add(toolNum18);
+
+        toolLife6 = new JTextField();
+        toolLife6.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife6.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife6.setEnabled(false);
+        toolLife6.setColumns(10);
+        toolLife6.setBounds(393, 110, 60, 30);
+        container.add(toolLife6);
+
+        toolLife10 = new JTextField();
+        toolLife10.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife10.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife10.setEnabled(false);
+        toolLife10.setColumns(10);
+        toolLife10.setBounds(393, 150, 60, 30);
+        container.add(toolLife10);
+
+        toolLife14 = new JTextField();
+        toolLife14.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife14.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife14.setEnabled(false);
+        toolLife14.setColumns(10);
+        toolLife14.setBounds(393, 190, 60, 30);
+        container.add(toolLife14);
+
+        toolLife18 = new JTextField();
+        toolLife18.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife18.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife18.setEnabled(false);
+        toolLife18.setColumns(10);
+        toolLife18.setBounds(393, 230, 60, 30);
+        container.add(toolLife18);
+
+        toolTitle7 = new JLabel("");
+        toolTitle7.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle7.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle7.setBounds(472, 110, 100, 30);
+        container.add(toolTitle7);
+
+        toolTitle11 = new JLabel("");
+        toolTitle11.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle11.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle11.setBounds(472, 150, 100, 30);
+        container.add(toolTitle11);
+
+        toolTitle15 = new JLabel("");
+        toolTitle15.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle15.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle15.setBounds(472, 190, 100, 30);
+        container.add(toolTitle15);
+
+        toolTitle19 = new JLabel("");
+        toolTitle19.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle19.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle19.setBounds(472, 230, 100, 30);
+        container.add(toolTitle19);
+
+        toolNum7 = new JTextField();
+        toolNum7.setText("7");
+        toolNum7.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum7.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum7.setEnabled(false);
+        toolNum7.setColumns(10);
+        toolNum7.setBounds(572, 110, 30, 30);
+        container.add(toolNum7);
+
+        toolNum11 = new JTextField();
+        toolNum11.setText("11");
+        toolNum11.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum11.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum11.setEnabled(false);
+        toolNum11.setColumns(10);
+        toolNum11.setBounds(572, 150, 30, 30);
+        container.add(toolNum11);
+
+        toolNum15 = new JTextField();
+        toolNum15.setText("15");
+        toolNum15.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum15.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum15.setEnabled(false);
+        toolNum15.setColumns(10);
+        toolNum15.setBounds(572, 190, 30, 30);
+        container.add(toolNum15);
+
+        toolNum19 = new JTextField();
+        toolNum19.setText("19");
+        toolNum19.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum19.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum19.setEnabled(false);
+        toolNum19.setColumns(10);
+        toolNum19.setBounds(572, 230, 30, 30);
+        container.add(toolNum19);
+
+        toolLife7 = new JTextField();
+        toolLife7.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife7.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife7.setEnabled(false);
+        toolLife7.setColumns(10);
+        toolLife7.setBounds(606, 110, 60, 30);
+        container.add(toolLife7);
+
+        toolLife11 = new JTextField();
+        toolLife11.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife11.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife11.setEnabled(false);
+        toolLife11.setColumns(10);
+        toolLife11.setBounds(606, 150, 60, 30);
+        container.add(toolLife11);
+
+        toolLife15 = new JTextField();
+        toolLife15.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife15.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife15.setEnabled(false);
+        toolLife15.setColumns(10);
+        toolLife15.setBounds(606, 190, 60, 30);
+        container.add(toolLife15);
+
+        toolLife19 = new JTextField();
+        toolLife19.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife19.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife19.setEnabled(false);
+        toolLife19.setColumns(10);
+        toolLife19.setBounds(606, 230, 60, 30);
+        container.add(toolLife19);
+
+        toolTitle8 = new JLabel("");
+        toolTitle8.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle8.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle8.setBounds(676, 110, 100, 30);
+        container.add(toolTitle8);
+
+        toolTitle12 = new JLabel("");
+        toolTitle12.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle12.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle12.setBounds(676, 150, 100, 30);
+        container.add(toolTitle12);
+
+        toolTitle16 = new JLabel("");
+        toolTitle16.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle16.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle16.setBounds(676, 190, 100, 30);
+        container.add(toolTitle16);
+
+        toolTitle20 = new JLabel("");
+        toolTitle20.setHorizontalAlignment(SwingConstants.RIGHT);
+        toolTitle20.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolTitle20.setBounds(676, 230, 100, 30);
+        container.add(toolTitle20);
+
+        toolNum8 = new JTextField();
+        toolNum8.setText("8");
+        toolNum8.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum8.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum8.setEnabled(false);
+        toolNum8.setColumns(10);
+        toolNum8.setBounds(776, 110, 30, 30);
+        container.add(toolNum8);
+
+        toolNum12 = new JTextField();
+        toolNum12.setText("12");
+        toolNum12.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum12.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum12.setEnabled(false);
+        toolNum12.setColumns(10);
+        toolNum12.setBounds(776, 150, 30, 30);
+        container.add(toolNum12);
+
+        toolNum16 = new JTextField();
+        toolNum16.setText("16");
+        toolNum16.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum16.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum16.setEnabled(false);
+        toolNum16.setColumns(10);
+        toolNum16.setBounds(776, 190, 30, 30);
+        container.add(toolNum16);
+
+        toolNum20 = new JTextField();
+        toolNum20.setText("20");
+        toolNum20.setHorizontalAlignment(SwingConstants.CENTER);
+        toolNum20.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolNum20.setEnabled(false);
+        toolNum20.setColumns(10);
+        toolNum20.setBounds(776, 230, 30, 30);
+        container.add(toolNum20);
+
+        toolLife8 = new JTextField();
+        toolLife8.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife8.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife8.setEnabled(false);
+        toolLife8.setColumns(10);
+        toolLife8.setBounds(810, 110, 60, 30);
+        container.add(toolLife8);
+
+        toolLife12 = new JTextField();
+        toolLife12.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife12.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife12.setEnabled(false);
+        toolLife12.setColumns(10);
+        toolLife12.setBounds(810, 150, 60, 30);
+        container.add(toolLife12);
+
+        toolLife16 = new JTextField();
+        toolLife16.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife16.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife16.setEnabled(false);
+        toolLife16.setColumns(10);
+        toolLife16.setBounds(810, 190, 60, 30);
+        container.add(toolLife16);
+
+        toolLife20 = new JTextField();
+        toolLife20.setHorizontalAlignment(SwingConstants.CENTER);
+        toolLife20.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        toolLife20.setEnabled(false);
+        toolLife20.setColumns(10);
+        toolLife20.setBounds(810, 230, 60, 30);
+        container.add(toolLife20);
+
+        setToolParamsVal(toolNums,toolTitle,toolLife);
+        
+        this.setModal(true);
+        this.setVisible(true);
+
+    }
+
+    public void setToolParamsVal(int[] toolNums,String[] toolTitle,String[] toolLife) {
+        for (int i = 1; i < 21; i++) {
+            int j = 0;
+            for(Integer toolNum : toolNums){
+                if(toolNum == i){
+                    ToolParam toolParam = new ToolParam();
+                    toolParam.setNums(toolNum);
+                    toolParam.setTitle(toolTitle[j]);
+                    toolParam.setLife(toolLife[j]);
+                    toolParams.add(toolParam);
+                    break;
+                }
+                j++;
+            }
+        }
+
+        for (ToolParam toolParam : toolParams) {
+            switch (toolParam.getNums()) {
+                case 1:
+                    toolTitle1.setText(toolParam.getTitle());
+                    toolLife1.setText(toolParam.getLife());
+                    break;
+                case 2:
+                    toolTitle2.setText(toolParam.getTitle());
+                    toolLife2.setText(toolParam.getLife());
+                    break;
+                case 3:
+                    toolTitle3.setText(toolParam.getTitle());
+                    toolLife3.setText(toolParam.getLife());
+                    break;
+                case 4:
+                    toolTitle4.setText(toolParam.getTitle());
+                    toolLife4.setText(toolParam.getLife());
+                    break;
+                case 5:
+                    toolTitle5.setText(toolParam.getTitle());
+                    toolLife5.setText(toolParam.getLife());
+                    break;
+                case 6:
+                    toolTitle6.setText(toolParam.getTitle());
+                    toolLife6.setText(toolParam.getLife());
+                    break;
+                case 7:
+                    toolTitle7.setText(toolParam.getTitle());
+                    toolLife7.setText(toolParam.getLife());
+                    break;
+                case 8:
+                    toolTitle8.setText(toolParam.getTitle());
+                    toolLife8.setText(toolParam.getLife());
+                    break;
+                case 9:
+                    toolTitle9.setText(toolParam.getTitle());
+                    toolLife9.setText(toolParam.getLife());
+                    break;
+                case 10:
+                    toolTitle10.setText(toolParam.getTitle());
+                    toolLife10.setText(toolParam.getLife());
+                    break;
+                case 11:
+                    toolTitle11.setText(toolParam.getTitle());
+                    toolLife11.setText(toolParam.getLife());
+                    break;
+                case 12:
+                    toolTitle12.setText(toolParam.getTitle());
+                    toolLife12.setText(toolParam.getLife());
+                    break;
+                case 13:
+                    toolTitle13.setText(toolParam.getTitle());
+                    toolLife13.setText(toolParam.getLife());
+                    break;
+                case 14:
+                    toolTitle14.setText(toolParam.getTitle());
+                    toolLife14.setText(toolParam.getLife());
+                    break;
+                case 15:
+                    toolTitle15.setText(toolParam.getTitle());
+                    toolLife15.setText(toolParam.getLife());
+                    break;
+                case 16:
+                    toolTitle16.setText(toolParam.getTitle());
+                    toolLife16.setText(toolParam.getLife());
+                    break;
+                case 17:
+                    toolTitle17.setText(toolParam.getTitle());
+                    toolLife17.setText(toolParam.getLife());
+                    break;
+                case 18:
+                    toolTitle18.setText(toolParam.getTitle());
+                    toolLife18.setText(toolParam.getLife());
+                    break;
+                case 19:
+                    toolTitle19.setText(toolParam.getTitle());
+                    toolLife19.setText(toolParam.getLife());
+                    break;
+                case 20:
+                    toolTitle20.setText(toolParam.getTitle());
+                    toolLife20.setText(toolParam.getLife());
+                    break;
+            }
+        }
+        this.repaint();
+    }
+}

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

@@ -0,0 +1,62 @@
+package com.mes.component;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class MesRadio extends JPanel {
+
+    public static final Logger log =  LoggerFactory.getLogger(MesRadio.class);
+
+    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;
+                    log.info("选择:"+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;
+    }
+}

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

@@ -0,0 +1,48 @@
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+public class MesWebView extends JFXPanel {
+
+    public static final Logger log =  LoggerFactory.getLogger(MesWebView.class);
+
+    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();
+            log.info(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();
+    }
+}

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

@@ -0,0 +1,30 @@
+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);
+    }
+}

+ 986 - 0
src/com/mes/component/WorkJPanelDevice.java

@@ -0,0 +1,986 @@
+package com.mes.component;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.github.s7connector.api.DaveArea;
+import com.github.s7connector.api.S7Connector;
+import com.github.s7connector.api.S7Serializer;
+import com.github.s7connector.api.factory.S7ConnectorFactory;
+import com.github.s7connector.api.factory.S7SerializerFactory;
+import com.github.xingshuangs.iot.protocol.modbus.service.ModbusTcp;
+import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import com.mes.ui.DataUtil;
+import com.mes.ui.MesClient;
+import com.mes.ui.OprnoUtil;
+import com.mes.util.DateLocalUtils;
+import com.mes.util.JdbcUtils;
+import com.mes.util.S7Util;
+//import com.mes.util.S7Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class WorkJPanelDevice extends JPanel {
+
+    public final Logger log =  LoggerFactory.getLogger(WorkJPanelDevice.class);
+
+    public String oprno = "OP140";
+
+    public String pos = "A";
+
+    public String lastSn = ""; // 最近的码
+
+    public String lineSn = "XT";
+
+    public JLabel feedinglabel;
+
+    public JLabel feedingmeslabel;
+
+    public JLabel runlabel; //运行反馈,
+
+    public JLabel blankinglabel; // 下料反馈
+
+    public JLabel blankingmeslabel; // 下料MES反馈
+
+    public JButton scanBtn;
+
+    public JTextField productSn;
+
+    public JTextField productSnFeeding;
+
+    public JButton status_menu;
+
+    public JButton resetBtn;
+
+    public JButton checkBtn;
+
+    public JButton historyBtn;
+
+    public JButton toolBtn;
+
+    public JButton resetFeedingBtn;
+
+    public ImageIcon imageGreen;
+
+    public ImageIcon imageGray;
+
+    public String plcIp = "192.168.22.201";
+
+    public String deviceIp = "192.168.88.99";
+
+    public S7Connector s7Connector;
+
+    public S7PLC s7PLC = null;
+
+    public ModbusTcp modbusTcp;
+
+    public S7PLC s7PLCFSW = null;
+
+    public Integer workWidth = 470;
+    public Integer workHeight = 300;
+
+    public String plcDb = "";
+
+    public String preSn = ""; // 扫码内容
+
+    public Integer tjFeedingFlag = 0; // 上料状态标识
+    public Integer tjFlag = 0; // 1=可加工 2=设备运行中 3=加工结束
+    public Integer tjStatus = 0; // 提交标识
+
+    public Boolean plcHeart = false;
+
+    public Integer isLocal = 1; // 0=正式 1=本地
+
+    public Integer isScan = 1; // 1=西侧 2=东测
+
+    public Boolean fswOnline = true; //
+
+    public String finallySn = "";
+
+    public List<String> hjparams = new ArrayList<>();
+
+    public Integer errflag = 0; // 1=报警 0=正常
+
+    public Integer errflag2 = 0;
+
+    public String fswDeviceName = "";
+
+    public JLabel oprnoLabel2;
+
+    public  JLabel oprnoLabel;
+
+    // OP170
+//    public int[] toolNums = { 1,2,3,4,5};
+//    public String[] toolTitle = { "高速端铣刀", "合金铣刀", "合金台阶钻", "合金台阶钻", "合金钻头" };
+//    public String[] toolLife = { "", "", "", "", "" };
+
+    // OP160
+    public int[] toolNums = { 1,2,3,4,5};
+    public String[] toolTitle = { "合金铣刀", "插孔铣刀", "合金台阶钻", "铝用合金钻头", "切削丝锥" };
+    public String[] toolLife = { "", "", "", "", "" };
+
+
+    // 缓存上一次的信号值,用于检测变化(key=地址, value=上次值)
+    private java.util.Map<String, Boolean> lastBooleanValues = new java.util.HashMap<>();
+    private java.util.Map<String, Boolean> lastWriteBooleanValues = new java.util.HashMap<>();
+
+    public WorkJPanelDevice(String position){
+        this.setLayout(null);
+        this.setBackground(Color.WHITE);
+        this.pos = position;
+        this.oprno = DataUtil.formatOprno(MesClient.mes_gw);
+        s7PLC = new S7PLC(EPlcType.S1500, plcIp);
+        s7PLC.setConnectTimeout(500);
+        s7PLC.setReceiveTimeout(500);
+
+        log.info("deviceIp:"+deviceIp);
+        fswDeviceName = OprnoUtil.getGwDes(lineSn, oprno);
+
+        if(oprno.equals("OP210")){       //FSW
+            if(position.equals("A")){
+                plcDb = "DB3010";
+                deviceIp = "";
+            }else if(position.equals("B")){
+                plcDb = "DB3011";
+                deviceIp = "";
+            } else if (position.equals("C")) {
+                plcDb = "DB3012";
+                deviceIp = "";
+            }
+        }else if(oprno.equals("OP140")){        //CNC反面
+            if(position.equals("A")){
+                plcDb = "DB3001";
+                deviceIp = "";
+            }else if(position.equals("B")){
+                plcDb = "DB3002";
+                deviceIp = "";
+            }else if (position.equals("C")) {
+                plcDb = "DB3003";
+                deviceIp = "";
+            }else if (position.equals("D")) {
+                plcDb = "DB3004";
+                deviceIp = "";
+            }else if (position.equals("E")) {
+                plcDb = "DB3005";
+                deviceIp = "";
+            }else if (position.equals("F")) {
+                plcDb = "DB3006";
+                deviceIp = "";
+            }else if (position.equals("G")) {
+                plcDb = "DB3007";
+                deviceIp = "";
+            }
+        }else if(oprno.equals("OP230")){      //CNC正面
+            if(position.equals("A")){
+                plcDb = "DB3013";
+                deviceIp = "";
+            }else if(position.equals("B")){
+                plcDb = "DB3014";
+                deviceIp = "";
+            }else if (position.equals("C")){
+                plcDb = "DB3015";
+                deviceIp = "";
+            }else if (position.equals("D")){
+                plcDb = "DB3016";
+                deviceIp = "";
+            }
+        }else if(oprno.equals("OP190")){    //冷板安装
+            if(position.equals("A")){
+                plcDb = "DB3008";
+            }
+        }
+
+        modbusTcp = new ModbusTcp(1, deviceIp);
+        modbusTcp.setConnectTimeout(500);
+        modbusTcp.setReceiveTimeout(500);
+
+        oprnoLabel = new JLabel(oprno+pos);
+        oprnoLabel.setHorizontalAlignment(SwingConstants.CENTER);
+        oprnoLabel.setForeground(Color.BLACK);
+        oprnoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        oprnoLabel.setBounds(0, -10, workWidth/5, 40);
+        this.add(oprnoLabel);
+
+        oprnoLabel2 = new JLabel(fswDeviceName);
+        oprnoLabel2.setHorizontalAlignment(SwingConstants.CENTER);
+        oprnoLabel2.setForeground(Color.BLACK);
+        oprnoLabel2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
+        oprnoLabel2.setBounds(0, 12, workWidth / 5, 40);
+        this.add(oprnoLabel2);
+
+        status_menu = new JButton("等待请求扫码");
+        status_menu.setBounds(workWidth/5, 0, workWidth*4/5, 40);
+        status_menu.setForeground(Color.GREEN);
+        status_menu.setForeground(Color.GREEN);
+        status_menu.setFont(new Font("微软雅黑", Font.PLAIN, 16));
+        status_menu.setBackground(Color.BLACK);
+        this.add(status_menu);
+
+        JLabel oprnoLabelFeeding = new JLabel("工件");
+        oprnoLabelFeeding.setHorizontalAlignment(SwingConstants.CENTER);
+        oprnoLabelFeeding.setForeground(Color.BLACK);
+        oprnoLabelFeeding.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        oprnoLabelFeeding.setBounds(0, 50, workWidth/5, 40);
+        this.add(oprnoLabelFeeding);
+
+        productSnFeeding = new JTextField("");
+        productSnFeeding.setHorizontalAlignment(SwingConstants.CENTER);
+        productSnFeeding.setForeground(Color.BLACK);
+        productSnFeeding.setFont(new Font("微软雅黑", Font.PLAIN, 16));
+        productSnFeeding.setEditable(false);
+        productSnFeeding.setBounds(workWidth/5, 50, workWidth*3/5, 40);
+        productSnFeeding.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                String sn = productSnFeeding.getText().trim();
+                if(!sn.isEmpty()){
+                    MesClient.createQRCode(productSnFeeding.getText(),oprno+pos);
+                }
+            }
+        });
+        this.add(productSnFeeding);
+
+        resetFeedingBtn = new JButton("刷新");
+        resetFeedingBtn.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                int choice = JOptionPane.showConfirmDialog(null, "确定刷新上料工件吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    log.info("人工点击刷新上料工件:"+productSnFeeding.getText().trim());
+                    resetFeeding();
+                    resetScanA();
+                }
+            }
+        });
+        resetFeedingBtn.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        resetFeedingBtn.setBounds(workWidth*4/5 + 10, 50, workWidth/5 - 10, 40);
+        this.add(resetFeedingBtn);
+
+        JLabel oprnoLabelWork = new JLabel("加工");
+        oprnoLabelWork.setHorizontalAlignment(SwingConstants.CENTER);
+        oprnoLabelWork.setForeground(Color.BLACK);
+        oprnoLabelWork.setFont(new Font("微软雅黑", Font.PLAIN, 20));
+        oprnoLabelWork.setBounds(0, 100, workWidth/5, 40);
+//        this.add(oprnoLabelWork);
+
+        productSn = new JTextField("");
+        productSn.setHorizontalAlignment(SwingConstants.CENTER);
+        productSn.setForeground(Color.BLACK);
+        productSn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
+        productSn.setEditable(false);
+        productSn.setBounds(workWidth/5, 100, workWidth*3/5, 40);
+        productSn.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                String sn = productSn.getText().trim();
+                if(!sn.isEmpty()){
+                    MesClient.createQRCode(productSn.getText(),oprno+pos);
+                }
+            }
+        });
+//        this.add(productSn);
+
+
+
+        resetBtn = new JButton("刷新");
+        resetBtn.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                int choice = JOptionPane.showConfirmDialog(null, "确定刷新加工工件吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    resetBlanking();
+                }
+            }
+        });
+        resetBtn.setFont(new Font("微软雅黑", Font.PLAIN, 22));
+        resetBtn.setBounds(workWidth*4/5 + 10, 100, workWidth/5 - 10, 40);
+//        this.add(resetBtn);
+
+
+        checkBtn = new JButton("开班点检");
+        checkBtn.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                showCheckDialog();
+            }
+        });
+        checkBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        checkBtn.setBounds(0, 220, workWidth/4, 35);
+        this.add(checkBtn);
+
+        historyBtn = new JButton("工作记录");
+        historyBtn.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                showRecordDialog();
+            }
+        });
+        historyBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+        historyBtn.setBounds(workWidth*3/4, 220, workWidth/4, 35);
+        this.add(historyBtn);
+
+        if(oprno.equals("OP160") || oprno.equals("OP170")){
+            toolBtn = new JButton("刀具寿命");
+            toolBtn.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    new CncLifeDialog(MesClient.mesClientFrame,toolNums,toolTitle,toolLife);
+                }
+            });
+            toolBtn.setFont(new Font("微软雅黑", Font.PLAIN, 18));
+            toolBtn.setBounds(workWidth*1/2 - workWidth/8, 220, workWidth/4, 35);
+            this.add(toolBtn);
+        }
+
+        imageGreen = new ImageIcon(MesClient.class.getResource("/bg/green_dot.png"));
+        imageGreen.setImage(imageGreen.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
+
+        imageGray = new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png"));
+        imageGray.setImage(imageGray.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH));
+
+        feedinglabel = new JLabel("允许MES读码");
+        feedinglabel.setHorizontalAlignment(SwingConstants.LEFT);
+        feedinglabel.setIcon(imageGreen);
+        feedinglabel.setForeground(Color.BLACK);
+        feedinglabel.setBounds(0, 120, workWidth/3, 30);
+        this.add(feedinglabel);
+
+        feedingmeslabel = new JLabel("MES允许上料");
+        feedingmeslabel.setHorizontalAlignment(SwingConstants.LEFT);
+        feedingmeslabel.setIcon(imageGreen);
+        feedingmeslabel.setForeground(Color.BLACK);
+        feedingmeslabel.setBounds(workWidth/3, 120, workWidth/3, 30);
+        feedingmeslabel.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                boolean ret = readAllowFeeding();
+                int choice = JOptionPane.showConfirmDialog(null, "确定修改MES扫码反馈结果为"+(ret?"false":"true")+"吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    writeAllowFeeding(!ret);
+                }
+            }
+        });
+        this.add(feedingmeslabel);
+
+        runlabel = new JLabel("工位开始工作");
+        runlabel.setHorizontalAlignment(SwingConstants.LEFT);
+        runlabel.setIcon(imageGreen);
+        runlabel.setForeground(Color.BLACK);
+        runlabel.setBounds(workWidth*2/3, 120, workWidth/3, 30);
+        this.add(runlabel);
+
+        blankinglabel = new JLabel("下料请求");
+        blankinglabel.setHorizontalAlignment(SwingConstants.LEFT);
+        blankinglabel.setIcon(imageGreen);
+        blankinglabel.setForeground(Color.BLACK);
+        blankinglabel.setBounds(0, 160, workWidth/3, 30);
+        this.add(blankinglabel);
+
+        blankingmeslabel = new JLabel("MES下料反馈");
+        blankingmeslabel.setHorizontalAlignment(SwingConstants.LEFT);
+        blankingmeslabel.setIcon(imageGreen);
+        blankingmeslabel.setForeground(Color.BLACK);
+        blankingmeslabel.setBounds(workWidth/3, 160, workWidth/3, 30);
+        this.add(blankingmeslabel);
+        blankingmeslabel.addMouseListener(new MouseAdapter() {
+            public void mouseClicked(MouseEvent e) {
+                boolean ret = readAllowBlanking();
+                int choice = JOptionPane.showConfirmDialog(null, "确定修改MES下料反馈结果为"+(ret?"false":"true")+"吗?", "操作确认", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+                if (choice == JOptionPane.YES_OPTION) {
+                    writeAllowBlanking(!ret);
+                }
+            }
+        });
+
+
+        heartData();
+
+        startOprnoTimer();
+
+        //monitorDeviceStatus();
+
+        resetScanA();
+
+    }
+
+    private void showCheckDialog() {
+        String url = "http://" + MesClient.mes_server_ip + ":8980/js/a/mes/mesProcessCheckRecord/ulist?ucode=" + MesClient.user_menu.getText() + "&oprno=" + oprno + pos + "&lineSn=" + MesClient.mes_line_sn;
+        showWebViewDialog("点检 - " + oprno + pos, url);
+    }
+
+    private void showRecordDialog() {
+        String url = "http://" + MesClient.mes_server_ip + ":8980/js/a/mes/mesProductRecord/work?oprno=" + oprno + pos+ "&lineSn=" + MesClient.mes_line_sn;
+        showWebViewDialog("工作记录 - " + oprno + pos, url);
+    }
+
+
+    private void showWebViewDialog(String title, String url) {
+        System.out.println("Opening dialog: " + title);
+
+        JFrame frame = new JFrame(title);
+        frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
+        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+
+        MesWebView webView = new MesWebView(url);
+        frame.setLayout(new BorderLayout());
+        frame.getContentPane().add(webView, BorderLayout.CENTER);
+
+        frame.setVisible(true);
+        System.out.println("Dialog opened");
+    }
+
+    public void setMenuStatus(String msg,int error){
+        if(error == 0){
+            this.status_menu.setForeground(Color.GREEN);
+        }else{
+            this.status_menu.setForeground(Color.RED);
+        }
+        this.status_menu.setText(msg);
+    }
+
+    // 定时任务 -----------------------------------------------------------------------------------------------------
+
+    public Timer cjTimerText2;
+    public void heartData() {
+        if(cjTimerText2!=null) {
+            cjTimerText2.cancel();
+        }
+        cjTimerText2 = new Timer();
+        cjTimerText2.schedule(new TimerTask() {
+            public void run() {
+                if(MesClient.isLogin == 1 && isLocal == 0){
+                    if(oprno.equals("OP160") && pos.equals("A")){
+                        try{ // 心跳
+                            sendHeart("DB3000",s7PLC);
+                        }catch (Exception e){
+                            e.printStackTrace();
+                        }
+
+                        try{ // CNC上线
+                            ReplyPlc("DB3000",s7PLC);
+                        }catch (Exception e){
+                            e.printStackTrace();
+                        }
+
+                        try{ // 涂胶上线
+                            ReplyPlc("DB3010",s7PLC);
+                        }catch (Exception e){
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            }
+        }, 1000,2000);
+    }
+
+    //MES->PLC心跳
+    public void sendHeart(String db,S7PLC s7PLC){
+        try{
+            Boolean ret = s7PLC.readBoolean(db+".60.0");
+            s7PLC.writeBoolean(db+".60.0",!ret);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    private void ReplyPlc(String db,S7PLC s7PLC){
+        Boolean ret = s7PLC.readBoolean(db+".12.0");
+        if(ret){ // 允许MES读工件码
+            if(!db.equals("DB3010")){
+                String sn = s7PLC.readString(db+".24.0",33).trim();
+                if(!sn.isEmpty()){
+                    // TODO::判断是否可上件
+                    s7PLC.writeBoolean(db+".0.0",true);
+                }
+            }else{
+                s7PLC.writeBoolean(db+".0.0",true);
+            }
+        }else{ // 允许上料置位
+            s7PLC.writeBoolean(db+".0.0",false);
+        }
+    }
+
+    public Timer cjTimerText3;
+    public void monitorDeviceStatus() {
+        if(cjTimerText3!=null) {
+            cjTimerText3.cancel();
+        }
+        cjTimerText3 = new Timer();
+        cjTimerText3.schedule(new TimerTask() {
+            public void run() {
+
+                if(MesClient.isLogin == 1 && isLocal == 0){
+                    try{
+                        initS7();
+                        monitorDevice();
+                        boolean ret = S7Util.getFswAlarm(s7Connector);
+                        if(ret){
+                            errflag = 0;
+                        }
+                        if(!ret && errflag == 0 ){
+                            errflag = 1;
+                            DataUtil.deviceAlarm(oprno+pos,productSn.getText(),oprno+pos+"随动夹具报警",MesClient.user_menu.getText());
+                        }
+                        fswOnline = true;
+                    }catch (Exception e){
+                        log.info(e.getMessage());
+                        fswOnline = false;
+                    }
+
+                    if(fswOnline){
+                        oprnoLabel.setForeground(Color.BLACK);
+                        oprnoLabel2.setForeground(Color.BLACK);
+                    }else{
+                        oprnoLabel.setForeground(Color.RED);
+                        oprnoLabel2.setForeground(Color.RED);
+                    }
+
+                    try{
+//                        int ret = getAlarm();
+//                        if(ret == 0){
+//                            errflag2 = 0;
+//                        }
+//                        if(ret != 0 && errflag2 == 0 ){
+//                            String content = oprno+pos;
+//                            if(ret == 1){
+//                                content += "安全门故障";
+//                            }else if(ret == 2){
+//                                content += "急停故障";
+//                            }else if(ret == 3){
+//                                content += "光栅故障";
+//                            }else if(ret == 4){
+//                                content += "夹紧故障";
+//                            }
+//
+//                            errflag2 = 1;
+//                            DataUtil.deviceAlarm(oprno+pos,productSn.getText(),content,MesClient.user_menu.getText());
+//                        }
+                    }catch (Exception e){
+
+                    }
+                }
+            }
+        }, 1000,1000);
+    }
+
+    public Timer oprnoTimer;
+    public void startOprnoTimer() {
+
+        //心跳显示图标
+        if(oprnoTimer!=null) {
+            oprnoTimer.cancel();
+        }
+        oprnoTimer = new Timer();
+        oprnoTimer.schedule(new TimerTask() {
+            public void run() {
+                try{
+
+                    if(MesClient.isLogin == 1){
+                        //请求扫码
+                        Boolean retFeeding = readFeeding();
+                        feedinglabel.setIcon(retFeeding?imageGreen:imageGray);
+
+                        // 读取MES允许上料信号
+                        Boolean retFeedingAllow = readAllowFeeding();
+                        feedingmeslabel.setIcon(retFeedingAllow?imageGreen:imageGray);
+
+                        if(!retFeeding && retFeedingAllow){
+                            writeAllowFeeding(false);
+                        }
+
+                        // 读取下料信号
+                        Boolean retBlanking = readBlanking();
+                        blankinglabel.setIcon(retBlanking?imageGreen:imageGray);
+
+                        // 读取MES允许下料信号
+                        Boolean retAllowBlanking = readAllowBlanking();
+                        blankingmeslabel.setIcon(retAllowBlanking?imageGreen:imageGray);
+
+                        // 当检测到允许MES读码信号为 true,且当前MES下料反馈还为 true 时,将其复位为 false
+                        if (retFeeding && retAllowBlanking) {
+                            writeAllowBlanking(false);
+                            // 同步更新UI图标反馈为灰色
+                            blankingmeslabel.setIcon(imageGray);
+                        }
+
+                        // 读取设备运行信号
+                        Boolean retRunning = readRunning();
+                        runlabel.setIcon(retRunning?imageGreen:imageGray);
+
+                        //上料
+                        if(tjFeedingFlag == 0){
+                            if(retFeeding){
+                                barCode();
+                            }
+                            if(retRunning){
+                                resetFeeding();
+                            }
+                        }else if(tjFeedingFlag == 1){
+                            if(retRunning){
+                                tjFeedingFlag = 2;
+                                resetFeeding();
+                                setMenuStatus("工件加工中", 0);
+
+                                getToolLife();
+
+                            }else{
+                                if(!retFeedingAllow){
+                                    writeAllowFeeding(true);
+                                }
+                            }
+                        }else if(tjFeedingFlag == 2){
+                            if(retBlanking){ // 运行结束
+                                tjFeedingFlag = 3;
+                                setMenuStatus("工件加工结束,结果上传中", 0);
+                                writeAllowBlanking(true);
+                                if(tjStatus == 0){
+                                    tjStatus = 1;
+                                    String result = readResult();
+                                    result = result.equals("OK")?"OK":"NG";
+                                    if(oprno.equals("OP220")||oprno.equals("OP230")){
+                                        result = "OK";
+                                    }
+                                    JSONObject retObj = DataUtil.sendQuality(productSnFeeding.getText(),oprno+pos,result,MesClient.user_menu.getText());
+                                    if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                                        resetBlanking();
+                                    }else{
+                                        if(retObj.get("result")==null){
+                                            setMenuStatus("请求失败,请重试",-1);
+                                        }else{
+                                            if(retObj.get("result").toString().equalsIgnoreCase("false")){
+                                                setMenuStatus(retObj.getString("message"),-1);
+                                            }
+                                        }
+                                    }
+                                }else{
+
+                                }
+                            }
+
+
+                        }
+
+                    }
+
+
+
+                }catch (Exception e) {
+                    log.error(e.getMessage());
+                }
+            }
+        }, 100,1500);
+    }
+
+
+    public void barCode(){
+
+        //如果为空则不进行上料
+        if(!productSnFeeding.getText().isEmpty()){
+            return;
+        }
+
+        String sn = readQrcode();
+        if(sn.equals("")){
+            if(productSnFeeding.getText().isEmpty()){
+                productSnFeeding.setText("");
+                this.setMenuStatus("扫码结果为空", -1);
+            }
+        }else{
+            productSnFeeding.setText(sn);
+            lastSn = sn;
+
+            // 查询工件质量
+            JSONObject retObj = DataUtil.checkQuality(sn,oprno+pos,MesClient.user_menu.getText());
+            if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                tjFeedingFlag = 1;//可加工
+                setMenuStatus("工件可以加工", 0);
+                writeAllowFeeding(true);    //允许上料
+            }else{
+                writeAllowFeeding(false);
+                resetFeedingBtn.setEnabled(true);
+                if(retObj.get("result")==null){
+                    setMenuStatus("请求失败,请重试",-1);
+                }else{
+                    if(retObj.get("result").toString().equalsIgnoreCase("false")){
+                        setMenuStatus(retObj.getString("message"),-1);
+                    }
+                }
+            }
+        }
+    }
+
+    public void resetBlanking() {
+        tjFeedingFlag = 0;
+        tjStatus = 0;
+        productSnFeeding.setText("");
+        setMenuStatus("工件结果已提交,等待下一件",0);
+       // resetBtn.setEnabled(true);
+    }
+
+    public void resetFeeding() {
+//        productSnFeeding.setText("");
+//        tjFeedingFlag = 0;
+//        setMenuStatus("等待请求扫码",0);
+        resetFeedingBtn.setEnabled(true);
+        writeAllowFeeding(false);
+    }
+
+    public void resetScanA() {
+        tjFeedingFlag = 0;
+        tjFlag = 0;
+        tjStatus = 0;
+//        productSn.setText("");
+        productSnFeeding.setText("");
+        setMenuStatus("等待请求扫码",0);
+//        resetBtn.setEnabled(true);
+        resetFeedingBtn.setEnabled(true);
+
+        if(isLocal == 0){
+            writeAllowFeeding(false);
+            writeAllowBlanking(false);
+        }
+    }
+
+
+    // 与设备交互-----------------------------------------------------------------------------------------
+
+    // 请求扫码
+    public boolean readFeeding(){
+        if(isLocal == 1){
+            return false;
+        }else{
+            return readBoolean(plcDb+".12.0");
+        }
+    }
+
+    // 读取下料信号
+    public boolean readBlanking(){
+        if(isLocal == 1){
+            return false;
+        }else{
+            return readBoolean(plcDb+".12.2");
+        }
+    }
+
+    // 读取设备运行信号
+    public boolean readRunning(){
+        if(isLocal == 1){
+            return true;
+        }else{
+            return readBoolean(plcDb+".12.1");
+        }
+    }
+
+    // 读取设备通讯状态
+    public boolean readDeviceStatus(){
+        if(isLocal == 1){
+            return true;
+        }else{
+            return readBoolean(plcDb+".12.5");
+        }
+    }
+
+    // 读取MES允许上料信号
+    public boolean readAllowFeeding(){
+        if(isLocal == 1){
+            return false;
+        }else{
+            return readBoolean(plcDb+".0.0");
+        }
+    }
+
+    // 写入MES允许上料信号
+    public boolean writeAllowFeeding(Boolean b){
+        if(isLocal == 1){
+            return true;
+        }else{
+            return writeBoolean(plcDb+".0.0",b);
+        }
+    }
+
+    // 读取MES允许下料信号
+    public boolean readAllowBlanking(){
+        if(isLocal == 1){
+            return true;
+        }else{
+            return readBoolean(plcDb+".0.1");
+        }
+    }
+
+    // 写入MES允许下料信号
+    public boolean writeAllowBlanking(Boolean b){
+        if(isLocal == 1){
+            return true;
+        }else{
+            return writeBoolean(plcDb+".0.1",b);
+        }
+    }
+
+    // 读取二维码
+    public String readQrcode(){
+        if(isLocal == 1){
+            return "";
+        }else{
+            String sn = s7PLC.readString(plcDb+".24.0", 33).trim();
+            return sn;
+        }
+    }
+
+    public boolean readBoolean(String db){
+        boolean permit;
+        try {
+            permit = s7PLC.readBoolean(db);
+            // 值变化时才打印日志(排除心跳地址.0.4和.0.6)
+            Boolean lastValue = lastBooleanValues.get(db);
+            if (lastValue == null || lastValue != permit) {
+                if (!db.endsWith(".0.4") && !db.endsWith(".0.6")) {
+                    log.info("<"+this.oprno+this.pos+">读取"+db+"-->变化:{} -> {}", lastValue, permit);
+                }
+                lastBooleanValues.put(db, permit);
+            }
+        } catch (Exception e) {
+            log.error("<"+this.oprno+this.pos+">读取"+db+"-->失败", e);
+            return false;
+        }
+        return permit;
+    }
+
+    public boolean writeBoolean(String db, boolean permit){
+        try {
+            // 值变化时才写入和打印日志(排除心跳地址.0.4和.0.6)
+            Boolean lastValue = lastWriteBooleanValues.get(db);
+            if (lastValue == null || lastValue != permit) {
+                s7PLC.writeBoolean(db,permit);
+                if (!db.endsWith(".0.4") && !db.endsWith(".0.6")) {
+                    log.info("<"+this.oprno+this.pos+">写入"+db+"-->变化:{} -> {}", lastValue, permit);
+                }
+                lastWriteBooleanValues.put(db, permit);
+            }
+        } catch (Exception e) {
+            log.error("<"+this.oprno+this.pos+">写入"+db+"-->失败,写入内容:{}", permit ? "true" : "false");
+            log.error(e.getMessage(), e);
+            return false;
+        }
+        return true;
+    }
+
+    public void getToolLife(){
+        try{
+            int i=0;
+            List<String> ps = new ArrayList<>();
+            for(Integer toolNum : toolNums){
+                String life = String.valueOf(getLife(modbusTcp,toolNum));
+                toolLife[i] = life;
+                ps.add(toolNum+"_"+life);
+                i++;
+            }
+            if(!toolLife[i].isEmpty()){
+                DataUtil.saveLife(lineSn,oprno,productSnFeeding.getText(),MesClient.user_menu.getText(),String.join("\\|",ps));
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    //
+    public Integer getLife(ModbusTcp modbusTcp,Integer i){
+        try{
+            if(isLocal == 1){
+                return 0;
+            }else{
+                short max1 = modbusTcp.readInt16((2103+(i*10))*2+3);
+                short cur1 = modbusTcp.readInt16((2103+(i*10))*2+1);
+                return max1 - cur1;
+//            Integer st = 150; // 宏变量对应R变量   @551=>R151
+//            Integer max1 = modbusTcp.readInt32((st + i)*2,EByteBuffFormat.DC_BA);
+//            return max1;
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            return 0;
+        }
+    }
+
+    public void initS7(){
+        try {
+            if(s7Connector == null) {
+                //PLC地址
+                String ipAddress = deviceIp;
+                log.info("deviceIp2:"+deviceIp);
+                //默认端口
+                int port = 102;
+                int rack=0;
+                int slot=3;
+                int timeout=5000;
+                s7Connector=
+                        S7ConnectorFactory
+                                .buildTCPConnector()
+                                .withHost(ipAddress)
+                                .withPort(port) //optional
+//								.withRack(rack) //optional
+//								.withSlot(slot) //optional
+                                .withTimeout(timeout) //连接超时时间
+                                .build();
+                S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
+            }
+        } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
+            s7Connector = null;
+            e.printStackTrace();
+        }
+    }
+
+    public void monitorDevice(){
+        log.info("monitorDevice");
+        if(tjFlag == 2){
+            try{
+                String zzzs = String.valueOf(s7PLCFSW.readSpindleRate());
+                String jgsd = String.valueOf(s7PLCFSW.readFeedRate());
+//                String zzzs = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 0));
+//                String jgsd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 4));
+                String zzzb = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 8));
+                String ylz = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 12));
+                Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
+                String hjcd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 28));
+                String hjms = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 32));
+                String record_time = DateLocalUtils.getCurrentTime();
+                hjparams.add(zzzs+"|"+jgsd+"|"+zzzb+"|"+ylz+"|"+hjjs+"|"+hjcd+"|"+hjms+"|"+record_time);
+                if (hjparams.size() == 60  && productSn.getText() != null && !productSn.getText().trim().isEmpty() ) {
+                    JdbcUtils.insertParamData(oprno+pos,MesClient.mes_line_sn,productSn.getText(), JSON.toJSONString(hjparams));
+                    hjparams = new ArrayList<>();
+                }
+            }catch (Exception e){
+                e.printStackTrace();
+                s7Connector = null;
+            }
+            log.info("monitorDevice:"+JSON.toJSONString(hjparams));
+        }else{
+            if(hjparams.size() > 0){
+                JdbcUtils.insertParamData(oprno,MesClient.mes_line_sn,lastSn, JSON.toJSONString(hjparams));
+                hjparams = new ArrayList<>();
+            }
+        }
+
+    }
+
+    public String readResult(){
+        String result = "OK";
+        boolean resultOk = false;
+        boolean resultNg = false;
+        try {
+            resultOk = s7PLC.readBoolean(plcDb+".12.3");
+            log.info("<4>读取信号-->读取工位加工结果是否OK成功,结果:{}", resultOk ? "true" : "false");
+            resultNg = s7PLC.readBoolean(plcDb+".12.4");
+            log.info("<4>读取信号-->读取工位加工结果是否NG成功,结果:{}", resultNg ? "true" : "false");
+            if(resultOk){
+                return "OK";
+            }
+            if(resultNg){
+                return "NG";
+            }
+        } catch (Exception e) {
+            return result;
+        }
+        return result;
+    }
+
+}

+ 31 - 0
src/com/mes/entity/ToolParam.java

@@ -0,0 +1,31 @@
+package com.mes.entity;
+
+public class ToolParam {
+    private Integer nums;
+    private String title;
+    private String life;
+
+    public Integer getNums() {
+        return nums;
+    }
+
+    public void setNums(Integer nums) {
+        this.nums = nums;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getLife() {
+        return life;
+    }
+
+    public void setLife(String life) {
+        this.life = life;
+    }
+}

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

@@ -0,0 +1,58 @@
+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;
+    }
+}

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

@@ -0,0 +1,414 @@
+package com.mes.ui;
+
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.mes.util.DateLocalUtils;
+import com.mes.util.JdbcUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class DataUtil {
+
+    public static final Logger log = LoggerFactory.getLogger(DataUtil.class);
+
+    public static JSONObject checkQuality(String sn,String oprno, String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/pccheck";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "AQDW", sn);
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject sendQuality(String sn,String oprno,String ret,String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/pcresult";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&result="+ret+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", sn);
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject sendQuality(String sn,String oprno,String ret,String user,String ps){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/pcresult";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&result="+ret+"&ucode="+user+"&ps="+ps;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", sn);
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject createOrder(String oprno,String wsn1,String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/pccreate";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&wsn1="+wsn1+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", "");
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject getSn(String oprno,int transferSn,int transferFloor,String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesTransfer/getSn";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&transferSn="+transferSn+"&transferFloor="+transferFloor+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", "");
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject saveSn(String oprno,String sn,int transferSn,int transferFloor,String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesTransfer/saveSn";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&transferSn="+transferSn+"&transferFloor="+transferFloor+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", "");
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject deviceAlarm(String oprno,String sn,String content,String user){
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/pcdevice";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"content="+content+"&ucode="+user;
+            log.info("url="+url);
+            log.info("params="+params);
+            String result = doPost(url,params);
+            log.info("result="+result);
+
+            if(result.equalsIgnoreCase("false")) {
+                return null;
+            }else {
+                JdbcUtils.insertData(oprno, "100000", params, "MQDW", "");
+                return JSONObject.parseObject(result);
+            }
+        }catch (Exception e){
+            log.info("e="+e.getMessage());
+            return null;
+        }
+    }
+
+    public static JSONObject upParams(String upparams) {
+        try{
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+//            String oprno = pro.getProperty("mes.gw").trim();
+            String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductFsw/batchsave";
+            String params = "__ajax=json&params="+upparams;
+            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 saveLife(String lineSn,String oprno,String sn,String ucode,String ps) {
+        try{
+            String url = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesProductCncLife/saveLife";
+            String params = "__ajax=json&oprno="+oprno+"&lineSn="+lineSn+"&sn="+sn+"&params="+ps+"&ucode="+ucode;
+            System.out.println("url="+url);
+            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(15000);
+            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;
+    }
+
+    /**
+     * 查询工作记录
+     * @param oprno 工位号(5位如OP010会查询所有子工位,空则查所有工位)
+     * @param sn 工件码(可选,用于搜索)
+     * @param pageNo 页码
+     * @param pageSize 每页条数
+     * @return 工作记录响应
+     */
+    public static WorkRecordResp getWorkRecordList(String oprno, String sn, int pageNo, int pageSize) {
+        WorkRecordResp resp = new WorkRecordResp();
+        try {
+            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);
+            String mes_server_ip = pro.getProperty("mes.server_ip");
+            String lineSn = pro.getProperty("mes.line_sn").trim();
+            
+            String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/workData";
+            StringBuilder params = new StringBuilder();
+            params.append("__ajax=json");
+            params.append("&lineSn=").append(lineSn);
+            params.append("&pageNo=").append(pageNo);
+            params.append("&pageSize=").append(pageSize);
+            
+            if (oprno != null && !oprno.isEmpty()) {
+                params.append("&oprno=").append(oprno);
+            }
+            // 注意:不传auto参数,这样"所有工位"查询时会返回整条产线所有工位的数据
+            if (sn != null && !sn.isEmpty()) {
+                params.append("&sn=").append(sn);
+            }
+            
+            log.info("查询工作记录: url=" + url + ", params=" + params.toString());
+            String result = doPost(url, params.toString());
+            log.info("查询工作记录结果: result=" + result);
+            
+            if (result == null || result.trim().isEmpty()) {
+                resp.setResult(false);
+                resp.setMessage("请求返回空结果");
+                return resp;
+            }
+            
+            JSONObject jsonObj = JSONObject.parseObject(result);
+            if (jsonObj == null) {
+                resp.setResult(false);
+                resp.setMessage("解析响应失败");
+                return resp;
+            }
+            
+            resp.setResult(true);
+            resp.setPageNo(jsonObj.getIntValue("pageNo"));
+            resp.setPageSize(jsonObj.getIntValue("pageSize"));
+            resp.setCount(jsonObj.getLongValue("count"));
+            
+            List<WorkRecordData> list = new ArrayList<>();
+            JSONArray listArray = jsonObj.getJSONArray("list");
+            if (listArray != null) {
+                for (int i = 0; i < listArray.size(); i++) {
+                    JSONObject item = listArray.getJSONObject(i);
+                    WorkRecordData data = new WorkRecordData();
+                    data.setId(item.getString("id"));
+                    data.setSn(item.getString("sn"));
+                    data.setOprno(item.getString("oprno"));
+                    data.setUpdateBy(item.getString("updateBy"));
+                    data.setUpdateDate(item.getString("updateDate"));
+                    data.setContent(item.getString("content"));
+                    list.add(data);
+                }
+            }
+            resp.setList(list);
+            
+        } catch (Exception e) {
+            log.error("查询工作记录异常: " + e.getMessage());
+            e.printStackTrace();
+            resp.setResult(false);
+            resp.setMessage("查询异常: " + e.getMessage());
+        }
+        return resp;
+    }
+
+    public static String formatOprno(String oprno){
+        List<String> lists = new ArrayList<>();
+        if(oprno.length() == 6){
+            String ysoprno = oprno.substring(0,5).trim();
+            if(!lists.contains(ysoprno)){
+                oprno = ysoprno;
+            }
+        }
+
+        return  oprno;
+    }
+}

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

@@ -0,0 +1,200 @@
+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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+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 {
+
+    public static final Logger log =  LoggerFactory.getLogger(LoginFarme.class);
+    //登录模块组件
+    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+OprnoUtil.getGwDes(MesClient.mes_line_sn,MesClient.mes_gw));
+
+        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);
+        log.info("&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, "请扫码工牌二维码");
+        log.info("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);
+            log.info("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);
+            log.info("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) {
+                    //1操作工人,2管理员
+                    //登录成功
+                    MesClient.isLogin = 1;
+                    MesClient.user_menu.setText(user_id);
+                    MesClient.welcomeWin.setVisible(false);
+                    MesClient.mesClientFrame.setVisible(true);
+
+                    // 已弃用WebView,改为使用WorkRecordPanel
+                     if(MesClient.jfxPanel == 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.jfxPanel = new MesWebView(url);
+                         MesClient.jfxPanel.setSize(990, 550);
+                         MesClient.indexPanelWork.add(MesClient.jfxPanel);
+                     }
+                    MesClient.initWarehouseData();
+                }
+
+            }
+
+        }else {
+            JOptionPane.showMessageDialog(MesClient.mesClientFrame,"登录失败,用户名或密码错误","提示窗口", JOptionPane.INFORMATION_MESSAGE);
+            return;
+        }
+    }
+}

+ 598 - 0
src/com/mes/ui/MesClient.java

@@ -0,0 +1,598 @@
+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 = "";
+
+    public static String preSn30 = "";
+
+    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 WorkJPanelDevice workJPanelDeviceA;
+    public static WorkJPanelDevice workJPanelDeviceB;
+    public static WorkJPanelDevice workJPanelDeviceC;
+    public static WorkJPanelDevice workJPanelDeviceD;
+    public static WorkJPanelDevice workJPanelDeviceE;
+    public static WorkJPanelDevice workJPanelDeviceF;
+    public static WorkJPanelDevice workJPanelDeviceG;
+
+    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();
+
+                    upParams();
+
+
+                }catch (Exception e){
+                    log.error(e.getMessage());
+                }
+            }
+        });
+    }
+
+    public static Timer cjTimer3;
+    public static void upParams() {
+        if(cjTimer3!=null) {
+            cjTimer3.cancel();
+        }
+        cjTimer3 = new Timer();
+        cjTimer3.schedule(new TimerTask() {
+            public void run() {
+                try{
+                    List<ParamReq> prods = JdbcUtils.getParams();
+                    if(prods.size() > 0){
+                        // 定时上传参数
+                        JSONObject retObj = DataUtil.upParams(JSON.toJSONString(prods));
+                        if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
+                            // 更新sqlite已同步
+                            for(ParamReq prodReq:prods){
+                                JdbcUtils.updateProdSync(prodReq.getId(),1);
+                            }
+                        }
+                    }
+                }catch (Exception e){
+                    e.printStackTrace();
+                }
+            }
+        }, 1000,120*1000);
+    }
+
+    //读配置文件
+    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系统客户端:"+mes_gw+OprnoUtil.getGwDes(MesClient.mes_line_sn,MesClient.mes_gw));
+//        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);
+        if(mes_gw.equals("OP220")){
+            indexPanelA.setLayout(new GridLayout(1,1, 5, 5));
+        }else{
+            indexPanelA.setLayout(new GridLayout(2,2, 5, 5));
+        }
+        indexPanelA.setBackground(Color.LIGHT_GRAY);
+
+
+        if(mes_gw.equals("OP140")){
+            JPanel indexPanel20A = new JPanel();
+            indexPanel20A.setLayout(null);
+            indexPanel20A.setBackground(Color.WHITE);
+            workJPanelDeviceA = new WorkJPanelDevice("A");
+            workJPanelDeviceA.setBounds(10, 10, workJPanelDeviceA.workWidth, workJPanelDeviceA.workHeight);
+            indexPanel20A.add(workJPanelDeviceA);
+            indexPanelA.add(indexPanel20A);
+
+            JPanel indexPanel20B = new JPanel();
+            indexPanel20B.setLayout(null);
+            indexPanel20B.setBackground(Color.WHITE);
+            workJPanelDeviceB = new WorkJPanelDevice("B");
+            workJPanelDeviceB.setBounds(10, 10, workJPanelDeviceB.workWidth, workJPanelDeviceB.workHeight);
+            indexPanel20B.add(workJPanelDeviceB);
+            indexPanelA.add(indexPanel20B);
+
+            JPanel indexPanel20C = new JPanel();
+            indexPanel20C.setLayout(null);
+            indexPanel20C.setBackground(Color.WHITE);
+            workJPanelDeviceC = new WorkJPanelDevice("C");
+            workJPanelDeviceC.setBounds(10, 10, workJPanelDeviceC.workWidth, workJPanelDeviceC.workHeight);
+            indexPanel20C.add(workJPanelDeviceC);
+            indexPanelA.add(indexPanel20C);
+
+            JPanel indexPanel20D = new JPanel();
+            indexPanel20D.setLayout(null);
+            indexPanel20D.setBackground(Color.WHITE);
+            workJPanelDeviceD = new WorkJPanelDevice("D");
+            workJPanelDeviceD.setBounds(10, 10, workJPanelDeviceD.workWidth, workJPanelDeviceD.workHeight);
+            indexPanel20D.add(workJPanelDeviceD);
+            indexPanelA.add(indexPanel20D);
+
+            JPanel indexPanel20E = new JPanel();
+            indexPanel20E.setLayout(null);
+            indexPanel20E.setBackground(Color.WHITE);
+            workJPanelDeviceE = new WorkJPanelDevice("E");
+            workJPanelDeviceE.setBounds(10, 10, workJPanelDeviceE.workWidth, workJPanelDeviceE.workHeight);
+            indexPanel20E.add(workJPanelDeviceE);
+            indexPanelA.add(indexPanel20E);
+
+            JPanel indexPanel20F = new JPanel();
+            indexPanel20F.setLayout(null);
+            indexPanel20F.setBackground(Color.WHITE);
+            workJPanelDeviceF = new WorkJPanelDevice("F");
+            workJPanelDeviceF.setBounds(10, 10, workJPanelDeviceF.workWidth, workJPanelDeviceF.workHeight);
+            indexPanel20F.add(workJPanelDeviceF);
+            indexPanelA.add(indexPanel20F);
+
+            JPanel indexPanel20G = new JPanel();
+            indexPanel20G.setLayout(null);
+            indexPanel20G.setBackground(Color.WHITE);
+            workJPanelDeviceG = new WorkJPanelDevice("G");
+            workJPanelDeviceG.setBounds(10, 10, workJPanelDeviceG.workWidth, workJPanelDeviceG.workHeight);
+            indexPanel20G.add(workJPanelDeviceG);
+            indexPanelA.add(indexPanel20G);
+        }else if(mes_gw.equals("OP230")){
+            JPanel indexPanel20A = new JPanel();
+            indexPanel20A.setLayout(null);
+            indexPanel20A.setBackground(Color.WHITE);
+            workJPanelDeviceA = new WorkJPanelDevice("D");
+            workJPanelDeviceA.setBounds(10, 10, workJPanelDeviceA.workWidth, workJPanelDeviceA.workHeight);
+            indexPanel20A.add(workJPanelDeviceA);
+            indexPanelA.add(indexPanel20A);
+
+            JPanel indexPanel20B = new JPanel();
+            indexPanel20B.setLayout(null);
+            indexPanel20B.setBackground(Color.WHITE);
+            workJPanelDeviceB = new WorkJPanelDevice("E");
+            workJPanelDeviceB.setBounds(10, 10, workJPanelDeviceB.workWidth, workJPanelDeviceB.workHeight);
+            indexPanel20B.add(workJPanelDeviceB);
+            indexPanelA.add(indexPanel20B);
+
+            JPanel indexPanel20C = new JPanel();
+            indexPanel20C.setLayout(null);
+            indexPanel20C.setBackground(Color.WHITE);
+            workJPanelDeviceC = new WorkJPanelDevice("F");
+            workJPanelDeviceC.setBounds(10, 10, workJPanelDeviceC.workWidth, workJPanelDeviceC.workHeight);
+            indexPanel20C.add(workJPanelDeviceC);
+            indexPanelA.add(indexPanel20C);
+
+            JPanel indexPanel20D = new JPanel();
+            indexPanel20D.setLayout(null);
+            indexPanel20D.setBackground(Color.WHITE);
+            workJPanelDeviceD = new WorkJPanelDevice("D");
+            workJPanelDeviceD.setBounds(10, 10, workJPanelDeviceD.workWidth, workJPanelDeviceD.workHeight);
+            indexPanel20D.add(workJPanelDeviceD);
+            indexPanelA.add(indexPanel20D);
+        }else if(mes_gw.equals("OP190")){
+            JPanel indexPanel20A = new JPanel();
+            indexPanel20A.setLayout(null);
+            indexPanel20A.setBackground(Color.WHITE);
+            workJPanelDeviceA = new WorkJPanelDevice("A");
+            workJPanelDeviceA.setBounds(10, 10, workJPanelDeviceA.workWidth, workJPanelDeviceA.workHeight);
+            indexPanel20A.add(workJPanelDeviceA);
+            indexPanelA.add(indexPanel20A);
+        }
+
+        tabbedPane.addTab("工作面板", null, indexScrollPaneA, null);
+        tabbedPane.setEnabledAt(0, true);
+
+        tabbedPane.addChangeListener(new ChangeListener() {
+            @Override
+            public void stateChanged(ChangeEvent e) {
+                JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
+                int selectedIndex = tabbedPane.getSelectedIndex();
+                if(selectedIndex == 1){
+
+                }
+            }
+        });
+    }
+
+    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;
+    }
+}

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

@@ -0,0 +1,56 @@
+package com.mes.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class OprnoUtil {
+    public static String[] xtoprnos = new String[]{
+            "OP140", "OP190", "OP210", "OP230",
+    };
+    public static String[] xtoprnodes = new String[]{
+            "框架CNC反面加工", "液冷板安装", "液冷板FSW", "CNC加工箱体正面"
+    };
+    public static String[] lboprnos = new String[]{
+
+    };
+    public static String[] lboprnodes = new String[]{
+
+    };
+    public static String getGwDes(String lineSn,String oprno){
+        String des = "";
+        oprno = formatOprno(oprno);
+        if(lineSn.equals("XT")){
+            int i = 0;
+            for (String gw:xtoprnos){
+                if(gw.equals(oprno)){
+                    des = xtoprnodes[i];
+                    break;
+                }
+                i++;
+            }
+        }else if(lineSn.equals("LB")){
+            int i = 0;
+            for (String gw:lboprnos){
+                if(gw.equals(oprno)){
+                    des = lboprnodes[i];
+                    break;
+                }
+                i++;
+            }
+        }
+        return des;
+    }
+
+    public static String formatOprno(String oprno){
+        List<String> lists = new ArrayList<>();
+
+        if(oprno.length() == 6){
+            String ysoprno = oprno.substring(0,5).trim();
+            if(!lists.contains(ysoprno)){
+                oprno = ysoprno;
+            }
+        }
+
+        return  oprno;
+    }
+}

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

@@ -0,0 +1,58 @@
+package com.mes.ui;
+
+public class ParamReq {
+    private Integer id;
+    private String oprno;
+    private String lineSn;
+    private String sn;
+    private String content;
+    private Integer sync;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getOprno() {
+        return oprno;
+    }
+
+    public void setOprno(String oprno) {
+        this.oprno = oprno;
+    }
+
+    public String getLineSn() {
+        return lineSn;
+    }
+
+    public void setLineSn(String lineSn) {
+        this.lineSn = lineSn;
+    }
+
+    public String getSn() {
+        return sn;
+    }
+
+    public void setSn(String sn) {
+        this.sn = sn;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Integer getSync() {
+        return sync;
+    }
+
+    public void setSync(Integer sync) {
+        this.sync = sync;
+    }
+}

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

@@ -0,0 +1,48 @@
+package com.mes.ui;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public class TableCellEditorButton extends DefaultCellEditor {
+
+    public static final Logger log =  LoggerFactory.getLogger(TableCellEditorButton.class);
+    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) {
+                log.info("按钮事件触发----");
+                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;
+    }
+}

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

@@ -0,0 +1,14 @@
+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;
+    }
+}

+ 61 - 0
src/com/mes/ui/WorkRecordData.java

@@ -0,0 +1,61 @@
+package com.mes.ui;
+
+/**
+ * 工作记录数据实体类
+ */
+public class WorkRecordData {
+    private String id;
+    private String sn;          // 工件码
+    private String oprno;       // 工位号
+    private String updateBy;    // 作业人员
+    private String updateDate;  // 日期
+    private String content;     // 工位结果
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getSn() {
+        return sn;
+    }
+
+    public void setSn(String sn) {
+        this.sn = sn;
+    }
+
+    public String getOprno() {
+        return oprno;
+    }
+
+    public void setOprno(String oprno) {
+        this.oprno = oprno;
+    }
+
+    public String getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(String updateBy) {
+        this.updateBy = updateBy;
+    }
+
+    public String getUpdateDate() {
+        return updateDate;
+    }
+
+    public void setUpdateDate(String updateDate) {
+        this.updateDate = updateDate;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+}

+ 403 - 0
src/com/mes/ui/WorkRecordPanel.java

@@ -0,0 +1,403 @@
+package com.mes.ui;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableColumn;
+import java.awt.*;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.util.List;
+
+/**
+ * 工作记录面板组件
+ * 支持分页查询和展示工作记录数据
+ */
+public class WorkRecordPanel extends JPanel {
+
+    private static final Logger log = LoggerFactory.getLogger(WorkRecordPanel.class);
+
+    // 表格列名
+    private static final String[] COLUMN_NAMES = {"工件码", "工位号", "工位结果", "作业人员", "日期"};
+
+    // 分页配置
+    private static final int PAGE_SIZE = 20;
+
+    // 查询条件
+    private String oprno;  // 工位号(null或空则查全部)
+    private String lineSn; // 产线编号
+    private boolean isAllStation; // 是否是"所有工位"模式
+
+    // 分页状态
+    private int pageNo = 1;
+    private long totalCount = 0;
+    private int totalPages = 0;
+
+    // UI组件
+    private JTable table;
+    private DefaultTableModel tableModel;
+    private JLabel pageLabel;
+    private JButton btnPrevious;
+    private JButton btnNext;
+    private JButton btnRefresh;
+    private JButton btnSearch;
+    private JLabel statusLabel;
+    private JTextField snSearchField;      // 工件码搜索框
+    private JTextField oprnoSearchField;   // 工位号搜索框(仅"所有工位"模式)
+    private JLabel snLabel;
+    private JLabel oprnoLabel;
+
+    /**
+     * 构造函数
+     * @param oprno 工位号(如OP010A查询该工位,null或空则查所有工位)
+     * @param lineSn 产线编号
+     */
+    public WorkRecordPanel(String oprno, String lineSn) {
+        this.oprno = oprno;
+        this.lineSn = lineSn;
+        this.isAllStation = (oprno == null || oprno.isEmpty());
+        initUI();
+    }
+
+    /**
+     * 初始化UI
+     */
+    private void initUI() {
+        setLayout(null);
+        setBackground(Color.WHITE);
+
+        // 顶部控制区
+        JPanel topPanel = new JPanel();
+        topPanel.setLayout(null);
+        topPanel.setBounds(0, 0, 1200, 50);
+        topPanel.setBackground(new Color(248, 248, 248));
+        add(topPanel);
+
+        int xPos = 10;
+
+        // 状态标签
+        String displayOprno = isAllStation ? "所有工位" : oprno;
+        statusLabel = new JLabel("工位:" + displayOprno);
+        statusLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        statusLabel.setBounds(xPos, 10, 160, 30);
+        topPanel.add(statusLabel);
+        xPos += 165;
+
+        // 工件码搜索
+        snLabel = new JLabel("工件码:");
+        snLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        snLabel.setBounds(xPos, 10, 50, 30);
+        topPanel.add(snLabel);
+        xPos += 52;
+
+        snSearchField = new JTextField();
+        snSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        snSearchField.setBounds(xPos, 10, 200, 30);
+        snSearchField.addActionListener(e -> doSearch()); // 回车搜索
+        topPanel.add(snSearchField);
+        xPos += 210;
+
+        // 工位号搜索(仅"所有工位"模式显示)
+        if (isAllStation) {
+            oprnoLabel = new JLabel("工位:");
+            oprnoLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+            oprnoLabel.setBounds(xPos, 10, 40, 30);
+            topPanel.add(oprnoLabel);
+            xPos += 42;
+
+            oprnoSearchField = new JTextField();
+            oprnoSearchField.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+            oprnoSearchField.setBounds(xPos, 10, 100, 30);
+            oprnoSearchField.addActionListener(e -> doSearch()); // 回车搜索
+            topPanel.add(oprnoSearchField);
+            xPos += 110;
+        }
+
+        // 查询按钮
+        btnSearch = new JButton("查询");
+        btnSearch.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        btnSearch.setBounds(xPos, 10, 70, 30);
+        btnSearch.addActionListener(e -> doSearch());
+        topPanel.add(btnSearch);
+        xPos += 80;
+
+        // 刷新按钮
+        btnRefresh = new JButton("刷新");
+        btnRefresh.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        btnRefresh.setBounds(xPos, 10, 70, 30);
+        btnRefresh.addActionListener(e -> {
+            clearSearchFields();
+            refreshData();
+        });
+        topPanel.add(btnRefresh);
+        xPos += 80;
+
+        // 上一页按钮
+        btnPrevious = new JButton("上一页");
+        btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        btnPrevious.setBounds(xPos, 10, 80, 30);
+        btnPrevious.addActionListener(e -> {
+            if (pageNo > 1) {
+                pageNo--;
+                loadData();
+            }
+        });
+        topPanel.add(btnPrevious);
+        xPos += 85;
+
+        // 页码显示
+        pageLabel = new JLabel("0/0");
+        pageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        pageLabel.setHorizontalAlignment(SwingConstants.CENTER);
+        pageLabel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
+        pageLabel.setBounds(xPos, 10, 70, 30);
+        topPanel.add(pageLabel);
+        xPos += 75;
+
+        // 下一页按钮
+        btnNext = new JButton("下一页");
+        btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        btnNext.setBounds(xPos, 10, 80, 30);
+        btnNext.addActionListener(e -> {
+            if (pageNo < totalPages) {
+                pageNo++;
+                loadData();
+            }
+        });
+        topPanel.add(btnNext);
+
+        // 表格面板
+        JPanel tablePanel = new JPanel();
+        tablePanel.setBounds(0, 50, 1200, 518);
+        tablePanel.setLayout(new GridLayout(1, 1, 0, 0));
+        add(tablePanel);
+
+        // 创建表格模型
+        tableModel = new DefaultTableModel(COLUMN_NAMES, 0) {
+            @Override
+            public boolean isCellEditable(int row, int column) {
+                return false;
+            }
+        };
+
+        // 创建表格
+        table = new JTable(tableModel);
+        table.setRowHeight(32);
+        table.setFont(new Font("微软雅黑", Font.PLAIN, 13));
+        table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
+        table.getTableHeader().setReorderingAllowed(false);
+
+        // 设置列宽
+        setColumnWidths();
+
+        // 设置居中渲染器
+        DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
+        centerRenderer.setHorizontalAlignment(JLabel.CENTER);
+        for (int i = 0; i < table.getColumnCount(); i++) {
+            table.getColumnModel().getColumn(i).setCellRenderer(centerRenderer);
+        }
+
+        // 添加滚动面板
+        JScrollPane scrollPane = new JScrollPane(table);
+        tablePanel.add(scrollPane);
+
+        // 添加组件大小变化监听器
+        addComponentListener(new ComponentAdapter() {
+            @Override
+            public void componentResized(ComponentEvent e) {
+                int w = getWidth();
+                int h = getHeight();
+
+                // 调整顶部面板宽度
+                topPanel.setBounds(0, 0, w, 50);
+
+                // 调整表格面板
+                if (h > 50) {
+                    tablePanel.setBounds(0, 50, w, h - 50);
+                }
+
+                topPanel.revalidate();
+                tablePanel.revalidate();
+            }
+        });
+    }
+
+    /**
+     * 设置列宽
+     */
+    private void setColumnWidths() {
+        TableColumn column;
+        // 工件码
+        column = table.getColumnModel().getColumn(0);
+        column.setPreferredWidth(260);
+        // 工位号
+        column = table.getColumnModel().getColumn(1);
+        column.setPreferredWidth(90);
+        // 工位结果
+        column = table.getColumnModel().getColumn(2);
+        column.setPreferredWidth(70);
+        // 作业人员
+        column = table.getColumnModel().getColumn(3);
+        column.setPreferredWidth(100);
+        // 日期
+        column = table.getColumnModel().getColumn(4);
+        column.setPreferredWidth(150);
+    }
+
+    /**
+     * 清空搜索框
+     */
+    private void clearSearchFields() {
+        snSearchField.setText("");
+        if (oprnoSearchField != null) {
+            oprnoSearchField.setText("");
+        }
+    }
+
+    /**
+     * 执行搜索
+     */
+    private void doSearch() {
+        pageNo = 1;
+        loadData();
+    }
+
+    /**
+     * 刷新数据(重置到第一页)
+     */
+    public void refreshData() {
+        pageNo = 1;
+        loadData();
+    }
+
+    /**
+     * 加载数据
+     */
+    public void loadData() {
+        // 获取搜索条件
+        String searchSn = snSearchField.getText().trim();
+        String searchOprno = oprno; // 默认使用构造函数传入的工位号
+
+        // 如果是"所有工位"模式,检查是否有工位号搜索条件
+        if (isAllStation && oprnoSearchField != null) {
+            String inputOprno = oprnoSearchField.getText().trim();
+            if (!inputOprno.isEmpty()) {
+                searchOprno = inputOprno;
+            }
+        }
+
+        final String finalSearchOprno = searchOprno;
+        final String finalSearchSn = searchSn;
+
+        // 在后台线程中执行数据加载
+        SwingWorker<WorkRecordResp, Void> worker = new SwingWorker<WorkRecordResp, Void>() {
+            @Override
+            protected WorkRecordResp doInBackground() throws Exception {
+                // 更新状态
+                SwingUtilities.invokeLater(() -> {
+                    statusLabel.setText("正在加载...");
+                    setButtonsEnabled(false);
+                });
+
+                // 调用接口查询数据
+                return DataUtil.getWorkRecordList(finalSearchOprno, finalSearchSn, pageNo, PAGE_SIZE);
+            }
+
+            @Override
+            protected void done() {
+                try {
+                    WorkRecordResp resp = get();
+                    updateUI(resp, finalSearchOprno);
+                } catch (Exception e) {
+                    log.error("加载工作记录失败: {}", e.getMessage());
+                    updateUIError("加载失败: " + e.getMessage());
+                }
+            }
+        };
+        worker.execute();
+    }
+
+    /**
+     * 设置按钮启用状态
+     */
+    private void setButtonsEnabled(boolean enabled) {
+        btnSearch.setEnabled(enabled);
+        btnRefresh.setEnabled(enabled);
+        btnPrevious.setEnabled(enabled && pageNo > 1);
+        btnNext.setEnabled(enabled && pageNo < totalPages);
+    }
+
+    /**
+     * 更新UI显示数据
+     */
+    private void updateUI(WorkRecordResp resp, String queryOprno) {
+        // 清空表格
+        tableModel.setRowCount(0);
+
+        if (resp == null || !resp.isResult()) {
+            String msg = resp != null ? resp.getMessage() : "请求失败";
+            updateUIError(msg);
+            return;
+        }
+
+        // 更新分页信息
+        totalCount = resp.getCount();
+        totalPages = (int) Math.ceil((double) totalCount / PAGE_SIZE);
+        if (totalPages == 0) totalPages = 1;
+
+        // 更新页码显示
+        pageLabel.setText(pageNo + "/" + totalPages);
+
+        // 更新按钮状态
+        setButtonsEnabled(true);
+
+        // 更新状态标签
+        String oprnoDisplay;
+        if (isAllStation) {
+            oprnoDisplay = (queryOprno == null || queryOprno.isEmpty()) ? "所有工位" : queryOprno;
+        } else {
+            oprnoDisplay = oprno;
+        }
+        statusLabel.setText("工位:" + oprnoDisplay + " 共" + totalCount + "条");
+
+        // 填充表格数据
+        List<WorkRecordData> list = resp.getList();
+        if (list != null && !list.isEmpty()) {
+            for (WorkRecordData data : list) {
+                Object[] row = {
+                        data.getSn(),
+                        data.getOprno(),
+                        data.getContent(),
+                        data.getUpdateBy(),
+                        data.getUpdateDate()
+                };
+                tableModel.addRow(row);
+            }
+        }
+
+        // 刷新表格
+        table.repaint();
+    }
+
+    /**
+     * 更新UI显示错误信息
+     */
+    private void updateUIError(String message) {
+        statusLabel.setText("错误: " + message);
+        pageLabel.setText("0/0");
+        setButtonsEnabled(true);
+        btnPrevious.setEnabled(false);
+        btnNext.setEnabled(false);
+        tableModel.setRowCount(0);
+    }
+
+    /**
+     * 获取当前工位号
+     */
+    public String getOprno() {
+        return oprno;
+    }
+}

+ 63 - 0
src/com/mes/ui/WorkRecordResp.java

@@ -0,0 +1,63 @@
+package com.mes.ui;
+
+import java.util.List;
+
+/**
+ * 工作记录查询响应实体类
+ */
+public class WorkRecordResp {
+    private boolean result;
+    private String message;
+    private int pageNo;
+    private int pageSize;
+    private long count;
+    private List<WorkRecordData> list;
+
+    public boolean isResult() {
+        return result;
+    }
+
+    public void setResult(boolean result) {
+        this.result = result;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public int getPageNo() {
+        return pageNo;
+    }
+
+    public void setPageNo(int pageNo) {
+        this.pageNo = pageNo;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public long getCount() {
+        return count;
+    }
+
+    public void setCount(long count) {
+        this.count = count;
+    }
+
+    public List<WorkRecordData> getList() {
+        return list;
+    }
+
+    public void setList(List<WorkRecordData> list) {
+        this.list = list;
+    }
+}

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

@@ -0,0 +1,19 @@
+package com.mes.util;
+
+import com.mes.ui.MesClient;
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Base64Utils {
+    public static final Logger log =  LoggerFactory.getLogger(Base64Utils.class);
+	public static String getBase64(String str) {
+		// 待编码的二进制数据
+        byte[] binaryData = str.getBytes();
+        // 使用Base64.encodeBase64String进行编码
+        String encodedString = Base64.encodeBase64String(binaryData);
+        // 输出编码后的结果
+        log.info("Base64编码结果: " + encodedString);
+        return encodedString;
+	}
+}

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

@@ -0,0 +1,34 @@
+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;
+	}
+}

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

@@ -0,0 +1,45 @@
+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 = "该工件OP"+ lx+"0加工NG";
+            }else if(processMsgRet.equalsIgnoreCase("QD")) {
+                lmsg = "该工件OP"+ lx+"0未加工";
+            }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("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 = "工件码重复";
+            }
+        }catch (Exception e){ }
+        return lmsg;
+    }
+}

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

@@ -0,0 +1,164 @@
+package com.mes.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+public class HttpUtils {
+
+    public static final Logger log =  LoggerFactory.getLogger(HttpUtils.class);
+	/**
+	 * HTTP请求,正确报文解析,并保存数据到生产记录数据
+	 * @return 
+	 * @throws URISyntaxException
+	 */
+    //http post请求
+    public static String sendRequest(String urlParam) {
+		String requestType = "POST";
+        //根据接收内容返回数据结果
+    	String ret = "";
+    	log.info(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();
+            log.info("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);
+                }
+                log.info(resultBuffer.toString());
+                ret = resultBuffer.toString();
+            }else {
+            	//ret = String.valueOf(responseCode);
+            	ret = "false";
+            }
+            con.disconnect();
+        }catch(Exception e) {
+        	//ret = false;
+        	//log.info("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 = "";
+        log.info(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();
+            log.info("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);
+                }
+                log.info(resultBuffer.toString());
+                ret = resultBuffer.toString();
+            }else {
+                //ret = String.valueOf(responseCode);
+                ret = "false";
+            }
+            con.disconnect();
+        }catch(Exception e) {
+            //ret = false;
+            //log.info("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();
+    }
+
+	
+
+}

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

@@ -0,0 +1,359 @@
+package com.mes.util;
+
+import com.mes.ui.ParamReq;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.List;
+
+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,不存在则创建
+            log.info("连接到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);
+
+		String sqlEquipment2 = "CREATE TABLE if not exists bw_params("
+				+ "id INTEGER PRIMARY KEY AUTOINCREMENT,oprno VARCHAR(20),line_sn VARCHAR(20),"
+				+ "sn VARCHAR(50),content MEDIUMTEXT,create_time DATETIME,sync int(10) NULL DEFAULT 0"
+				+ ")";
+		statement.executeUpdate(sqlEquipment2);
+
+		// 创建 提交记录表
+		String cache = "CREATE TABLE if not exists cache(\n" +
+				"   id INTEGER PRIMARY KEY AUTOINCREMENT, -- 自增ID\n" +
+				"   sn VARCHAR(20),                    -- 唯一标识 \n" +
+				"   content VARCHAR(255),                       -- 绑定内容\n" +
+				"   record_time DATETIME                 -- 记录时间\n" +
+				")";
+		statement.executeUpdate(cache);
+
+        statement.close();
+    }
+
+	//插入数据
+	public static boolean insertParamData(String oprno, String line_sn, String sn,String content) {
+		if (sn == null || sn.trim().isEmpty()) {
+			return false;
+		}
+		JdbcUtils.getConn();
+		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_params (oprno,line_sn,sn,content,create_time) VALUES"
+					+ " ('"+oprno+"', '"+line_sn+"', '"+sn+"', '"+content+"','"+record_time+"')");//向数据库中插入数据
+			statement.close();
+			ret = true;
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			//e.printStackTrace();
+			ret = false;
+		}
+
+		return ret;
+	}
+
+	public static void updateProdSync(Integer id,Integer sync) throws SQLException {
+		Connection conn = JdbcUtils.getConn();
+		Statement statement=conn.createStatement();   //创建连接对象,是Java的一个操作数据库的重要接口
+		statement.executeUpdate("update bw_params set sync = "+sync + " where id = "+id);
+		statement.close();
+	}
+
+	public static String getCache(String key) {
+		//SQL语句
+		String sql = "select id,sn,content from cache where sn = '"+key+"' order by id asc limit 1";
+		Connection conn = JdbcUtils.getConn();
+		Statement stmt=null;
+		ResultSet ret = null;
+		String password=null;
+		List<ParamReq> prods = new ArrayList<>();
+		String content = "";
+		try {
+			stmt = conn.createStatement();
+			//执行语句,得到结果集
+			ret = stmt.executeQuery(sql);
+			while (ret.next()) {
+				content = ret.getString(3);
+			}
+			ret.close();
+			conn.close();//关闭连接
+		} catch (SQLException e1) {
+			e1.printStackTrace();
+		}
+		return content;
+	}
+
+	public static Boolean setCache(String key,String value) {
+		String record_time = DateLocalUtils.getCurrentTime();
+		Connection conn = JdbcUtils.getConn();
+		if(value == null || value.trim().isEmpty()) {
+			return false;
+		}
+		String content = getCache(key);
+		if(content == null || content.trim().isEmpty()) { // 新增
+			try {
+				Statement statement=conn.createStatement();
+				statement.executeUpdate("INSERT INTO cache (sn,content,record_time) VALUES"
+						+ " ('"+key+"', '"+value+"','"+record_time+"')");//向数据库中插入数据
+				statement.close();
+			}catch (Exception e) {
+				e.printStackTrace();
+			}
+		}else{
+			if(value.trim().equals(content.trim())) {
+				return true;
+			}else{ // 更新
+				try{
+					Statement statement=conn.createStatement();   //创建连接对象,是Java的一个操作数据库的重要接口
+					statement.executeUpdate("update cache set content = "+value.trim() + " where sn = '"+key+"'");
+					statement.close();
+				}catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		}
+		return true;
+	}
+
+	public static List<ParamReq> getParams() {
+		//SQL语句
+		String sql = "select id,oprno,line_sn,sn,content,sync from bw_params where sync = 0 order by id asc limit 100";
+		Connection conn = JdbcUtils.getConn();
+		Statement stmt=null;
+		ResultSet ret = null;
+		String password=null;
+		List<ParamReq> prods = new ArrayList<>();
+		try {
+			stmt = conn.createStatement();
+			//执行语句,得到结果集
+			ret = stmt.executeQuery(sql);
+			System.out.println("sql:"+ sql);
+			while (ret.next()) {
+				ParamReq cmtReq = new ParamReq();
+				cmtReq.setId(ret.getInt(1));
+				cmtReq.setOprno(ret.getString(2));
+				cmtReq.setLineSn(ret.getString(3));
+				cmtReq.setSn(ret.getString(4));
+				cmtReq.setContent(ret.getString(5));
+				cmtReq.setSync(Integer.valueOf(ret.getString(6)));
+				prods.add(cmtReq);
+			}
+			ret.close();
+			conn.close();//关闭连接
+		} catch (SQLException e1) {
+			e1.printStackTrace();
+		}
+		return prods;
+	}
+    
+    //插入数据
+    public static boolean insertData(String gw, String gy, String bw, String message_type, String sn) {
+    	boolean ret = false;
+    	String record_time = DateLocalUtils.getCurrentTime();
+    	if(conn==null) {
+    		ret = false;
+    	}else {
+    		try {
+    			//创建连接对象,是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();
+		if(conn==null) {
+			ret = false;
+		}else {
+			try {
+				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 create_measure_data() throws SQLException {
+    	Statement statement=conn.createStatement();   //创建连接对象,是Java的一个操作数据库的重要接口
+    	//statement.executeUpdate("drop table if exists measure_data");//判断是否有表tables的存在。有则删除
+    	//设备结构数据库
+        String sqlEquipment = "CREATE TABLE if not exists measure_data("
+        		+ "id INTEGER PRIMARY KEY AUTOINCREMENT,function_location VARCHAR(200),description VARCHAR(200),"
+        		+ "data_item VARCHAR(100),measure_time DATETIME,data_type INT(3)," //data_type=1电阻校准数据,2电感校准数据,3绝缘电阻校准数据
+        		+ "data_01 double(30),data_02 double(30),data_03 double(30),data_04 double(30),data_05 double(30),"
+        		+ "data_06 double(30),data_07 double(30),data_08 double(30),data_09 double(30),data_10 double(30),"
+        		+ "data_11 double(30),data_12 double(30),data_13 double(30),data_14 double(30),data_15 double(30),"
+        		+ "data_16 double(30),data_17 double(30),data_18 double(30),data_19 double(30),data_20 double(30)"
+        		+ ")";
+        statement.executeUpdate(sqlEquipment);
+//        statement.executeUpdate("INSERT INTO measure_data VALUES (1, '第一电厂-设备管理部-电机1',  '第一电厂-设备管理部-电机1', '2022-03-22 15:16:18', '2022-03-22 15:16:18',1,"
+//        		+ "0.05, 0.82, 3, 80, 130, 180, 402, 502, 809, 1103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)");//向数据库中插入数据        
+//        ResultSet rSet=statement.executeQuery("select * from measure_data");//搜索数据库,将搜索的放入数据集ResultSet中
+//        while (rSet.next()) {            //遍历这个数据集
+//            log.info("function_location:"+rSet.getString(2));//依次输出 也可以这样写 rSet.getString(“name”)
+//            log.info("data_01:"+rSet.getString(4));
+//        }
+//        rSet.close();//关闭数据集
+        statement.close();
+    }
+    
+    public static void close(){
+    	log.info("SQLite数据库连接关闭!");
+        try {
+        	if(conn!=null) {
+        		conn.close();
+        	}
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    
+  //设备结构数据库
+//    String sqlEquipment = "CREATE TABLE if not exists tree_structure(id INTEGER PRIMARY KEY AUTOINCREMENT,function_location VARCHAR(200),description VARCHAR(200),sup_fl VARCHAR(200),level INT(3)," +
+//            "isleaf INT(3))";
+//    statement.executeUpdate("drop table if exists tree_structure");//判断是否有表tables的存在。有则删除
+//    statement.executeUpdate(sqlEquipment);
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (1, '第一电厂', '第一电厂', NULL, 1, 0)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (2, '第一电厂-设备管理部', '第一电厂-设备管理部', '第一电厂', 2, 0)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (3, '第一电厂-设备管理部-发电机组', '第一电厂-设备管理部-发电机组', '第一电厂-设备管理部', 3, 0)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (4, '第一电厂-设备管理部-发电机组-电机1', '第一电厂-设备管理部-发电机组-电机1', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (5, '第一电厂-设备管理部-发电机组-电机2', '第一电厂-设备管理部-发电机组-电机2', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (6, '第二电厂', '第二电厂', NULL, 1, 0)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (7, '第二电厂-设备管理部', '第二电厂-设备管理部', '第二电厂', 2, 0)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (8, '第一电厂-设备管理部-发电机组-电机3', '第一电厂-设备管理部-发电机组-电机3', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (10, '第一电厂-设备管理部-发电机组-电机4', '第一电厂-设备管理部-发电机组-电机4', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (11, '第一电厂-设备管理部-发电机组-电机5', '第一电厂-设备管理部-发电机组-电机5', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (12, '第一电厂-设备管理部-发电机组-电机8', '第一电厂-设备管理部-发电机组-电机8', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (13, '第一电厂-设备管理部-发电机组-电机6', '第一电厂-设备管理部-发电机组-电机6', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (14, '第一电厂-设备管理部-发电机组-电机7', '第一电厂-设备管理部-发电机组-电机7', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (15, '第一电厂-设备管理部-发电机组-电机9', '第一电厂-设备管理部-发电机组-电机9', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    statement.executeUpdate("INSERT INTO tree_structure VALUES (16, '第一电厂-设备管理部-发电机组-电机10', '第一电厂-设备管理部-发电机组-电机10', '第一电厂-设备管理部-发电机组', 4, 1)");//向数据库中插入数据
+//    ResultSet rSet=statement.executeQuery("select * from tree_structure");//搜索数据库,将搜索的放入数据集ResultSet中
+    
+//    /**
+//    * 通过用户名到数据库中获取凭证密码
+//    * @param userName
+//    * @return
+//    */
+//    private static String getPasswordByUserName(String userName) {
+//    //SQL语句  
+//    String sql = "select password from users where username = " +"'" + userName+"'";
+//        Connection conn = JdbcUtils.getConn();
+//        Statement stmt=null; 
+//        ResultSet ret = null;  
+//        String password=null;
+//    try {
+//    stmt = conn.createStatement();
+//    //执行语句,得到结果集  
+//    ret = stmt.executeQuery(sql);
+//                while (ret.next()) {  
+//                //这里只查询的密码
+//                password = ret.getString(1);  
+//                }
+//                ret.close();  
+//                conn.close();//关闭连接  
+//    } catch (SQLException e1) {
+//    e1.printStackTrace();
+//    }  
+//    return password;
+//    }
+}
+ 
+

+ 133 - 0
src/com/mes/util/S7Util.java

@@ -0,0 +1,133 @@
+package com.mes.util;
+
+import com.github.s7connector.api.DaveArea;
+import com.github.s7connector.api.S7Connector;
+import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.text.DecimalFormat;
+
+public class S7Util {
+    public static final Logger log =  LoggerFactory.getLogger(S7Util.class);
+
+    public static Boolean getFswAlarm(S7Connector s7Connector){
+        byte[] bytes1 = s7Connector.read(DaveArea.DB, 9051, 1, 24);
+        int alarm242 = getBit(bytes1[0],5);
+        if(alarm242 == 1){
+            return false;
+        }
+        int alarm243 = getBit(bytes1[0],4);
+        if(alarm243 == 1){
+            return false;
+        }
+        int alarm244 = getBit(bytes1[0],3);
+        if(alarm244 == 1){
+            return false;
+        }
+        int alarm245 = getBit(bytes1[0],2);
+        if(alarm245 == 1){
+            return false;
+        }
+        int alarm246 = getBit(bytes1[0],1);
+        if(alarm246 == 1){
+            return false;
+        }
+        int alarm247 = getBit(bytes1[0],0);
+        if(alarm247 == 1){
+            return false;
+        }
+
+        byte[] bytes2 = s7Connector.read(DaveArea.DB, 9051, 1, 25);
+        int alarm250 = getBit(bytes2[0],7);
+        if(alarm250 == 1){
+            return false;
+        }
+
+        int alarm251 = getBit(bytes2[0],6);
+        if(alarm251 == 1){
+            return false;
+        }
+
+        int alarm252 = getBit(bytes2[0],5);
+        if(alarm252 == 1){
+            return false;
+        }
+
+        int alarm253 = getBit(bytes2[0],4);
+        if(alarm253 == 1){
+            return false;
+        }
+
+        int alarm254 = getBit(bytes2[0],3);
+        if(alarm254 == 1){
+            return false;
+        }
+
+        int alarm255 = getBit(bytes2[0],2);
+        if(alarm255 == 1){
+            return false;
+        }
+
+        int alarm256 = getBit(bytes2[0],1);
+        if(alarm256 == 1){
+            return false;
+        }
+
+        return true;
+
+    }
+
+    // 格式化s7取出的值
+    public static String formatS7Val(byte[] val){
+        int intValue = new BigInteger(xtob(val)).intValue();
+        float floatValue = Float.intBitsToFloat(intValue);
+
+        // 保留1位小数
+        DecimalFormat df = new DecimalFormat("#.#");
+        df.setMaximumFractionDigits(1);
+        String result = df.format(floatValue);
+        float roundedNum = Float.parseFloat(result);
+
+        return roundedNum+"";
+    }
+
+    // 转大端排序
+    private static byte[] xtob( byte[] bytes){
+        return bytes;
+//        // 创建新的byte数组并复制原始数据
+//        byte[] reversedBytes = new byte[bytes.length];
+//        System.arraycopy(bytes, 0, reversedBytes, 0, bytes.length);
+//
+//        // 反转byte数组元素的位置
+//        for (int i = 0; i < bytes.length / 2; i++) {
+//            byte temp = reversedBytes[i];
+//            reversedBytes[i] = reversedBytes[reversedBytes.length - 1 - i];
+//            reversedBytes[reversedBytes.length - 1 - i] = temp;
+//        }
+//        return reversedBytes;
+    }
+
+    private static String byteToBinaryString(byte[] byteArray) {
+        StringBuilder binaryString = new StringBuilder();
+        for (byte b : byteArray) {
+            binaryString.append(String.format("%8s", Integer.toBinaryString(b & 0xFF)).replace(' ', '0'));
+        }
+        return binaryString.toString();
+    }
+
+    public static int getBit(byte b, int n) {
+        // 将byte转换为二进制字符串
+        String binaryString = Integer.toBinaryString(b & 0xFF);
+        // 补足位数到8位
+        binaryString = String.format("%8s", binaryString).replace(' ', '0');
+        // 获取第n位的字符,然后转换为整数
+        return binaryString.charAt(n) == '1' ? 1 : 0;
+    }
+
+    public static Integer formatS7Int(byte[] val){
+        return new BigInteger(xtob(val)).intValue();
+    }
+
+}

+ 120 - 0
src/com/mes/util/SinumerikUtil.java

@@ -0,0 +1,120 @@
+package com.mes.util;
+
+import com.github.s7connector.api.DaveArea;
+import com.github.s7connector.api.S7Connector;
+import com.github.s7connector.api.S7Serializer;
+import com.github.s7connector.api.factory.S7ConnectorFactory;
+import com.github.s7connector.api.factory.S7SerializerFactory;
+
+import java.math.BigInteger;
+import java.text.DecimalFormat;
+
+//西门子机床获取DB块数据
+public class SinumerikUtil {
+
+    private static Integer bigEndian = 0; // 是否转大端排序 0=不转 1=转
+
+    // 获取Float状态的数据
+    public static Float readFloat(S7Connector s7Connector, Short db, Short length, Short offset){
+        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
+        //第二个参数:DB地址,若plc中是DB1000,则填1000
+        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
+        //第四个参数:偏移量
+        return formatS7Val(s7Connector.read(DaveArea.DB, db, length, offset));
+    }
+
+    // 获取Integer状态的数据
+    public static Integer readInt(S7Connector s7Connector, Short db, Short length, Short offset){
+        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
+        //第二个参数:DB地址,若plc中是DB1000,则填1000
+        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
+        //第四个参数:偏移量
+        return formatS7Int(s7Connector.read(DaveArea.DB, db, length, offset));
+    }
+
+    // 获取FInteger状态的数据
+    public static Boolean readBoolean(S7Connector s7Connector, Short db, Short offset, Short position){
+        //第一个参数:DaveArea.DB 表示读取PLC的地址区域为DB
+        //第二个参数:DB地址,若plc中是DB1000,则填1000
+        //第三个参数:数据长度, <=plc中两个偏移量的间隔,当前偏移量为1000,下一个地址偏移量为1100,则长度可填 0-1000;
+        //第四个参数:偏移量
+        byte[] bytes = s7Connector.read(DaveArea.DB, db, 1, offset);
+        int ret = getBit(bytes[0], 7 - position);
+        return ret == 1?true:false;
+    }
+
+    public static int getBit(byte b, int n) {
+        // 将byte转换为二进制字符串
+        String binaryString = Integer.toBinaryString(b & 0xFF);
+        // 补足位数到8位
+        binaryString = String.format("%8s", binaryString).replace(' ', '0');
+        // 获取第n位的字符,然后转换为整数
+        return binaryString.charAt(n) == '1' ? 1 : 0;
+    }
+
+    // 格式化s7取出的值
+    private static float formatS7Val(byte[] val){
+        int intValue = new BigInteger(xtob(val)).intValue();
+        float floatValue = Float.intBitsToFloat(intValue);
+
+        // 保留1位小数
+        DecimalFormat df = new DecimalFormat("#.#");
+        df.setMaximumFractionDigits(1);
+        String result = df.format(floatValue);
+        float roundedNum = Float.parseFloat(result);
+
+        return roundedNum;
+    }
+
+    private static Integer formatS7Int(byte[] val){
+        return new BigInteger(xtob(val)).intValue();
+    }
+
+    public static S7Connector initS7(S7Connector s7Connector, String plcUrl){
+        try {
+            if(s7Connector == null) {
+
+                //PLC地址
+                String ipAddress = plcUrl;
+                //默认端口
+//				int port = 102;
+                int rack=0;
+                int slot=3;
+                int timeout=5000;
+                s7Connector=
+                        S7ConnectorFactory
+                                .buildTCPConnector()
+                                .withHost(ipAddress)
+//								.withPort(port) //optional
+//								.withRack(rack) //optional
+//								.withSlot(slot) //optional
+                                .withTimeout(timeout) //连接超时时间
+                                .build();
+                S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
+            }
+        } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
+            s7Connector = null;
+            e.printStackTrace();
+        }
+        return s7Connector;
+    }
+
+    // 转大端排序
+    private static byte[] xtob( byte[] bytes){
+        if(bigEndian == 0){
+            return bytes;
+        }else{
+            // 创建新的byte数组并复制原始数据
+            byte[] reversedBytes = new byte[bytes.length];
+            System.arraycopy(bytes, 0, reversedBytes, 0, bytes.length);
+
+            // 反转byte数组元素的位置
+            for (int i = 0; i < bytes.length / 2; i++) {
+                byte temp = reversedBytes[i];
+                reversedBytes[i] = reversedBytes[reversedBytes.length - 1 - i];
+                reversedBytes[reversedBytes.length - 1 - i] = temp;
+            }
+            return reversedBytes;
+        }
+    }
+}

+ 97 - 0
src/com/mes/util/TCPClient.java

@@ -0,0 +1,97 @@
+package com.mes.util;
+
+import java.io.*;
+import java.net.Socket;
+import java.util.concurrent.*;
+
+public class TCPClient {
+    public String serverIP;
+    public int serverPort;
+    public Socket socket;
+    public PrintWriter out;
+    public BufferedReader in;
+    private ExecutorService executor = Executors.newSingleThreadExecutor();
+
+    public TCPClient(String serverIP, int serverPort) {
+        this.serverIP = serverIP;
+        this.serverPort = serverPort;
+    }
+
+    public void connect() throws Exception {
+            try {
+                // 创建Socket对象并连接到服务器
+                socket = new Socket(serverIP, serverPort);
+                // 连接成功后初始化输入输出流
+                OutputStream outputStream = socket.getOutputStream();
+                out = new PrintWriter(outputStream, true);
+
+                InputStream inputStream = socket.getInputStream();
+                in = new BufferedReader(new InputStreamReader(inputStream));
+//                System.out.println("扫码枪连接成功");
+                // 启动监听线程
+//                startListener();
+
+            } catch (Exception e) {
+                // 连接失败,重新连接
+//                MesClient.setMenuStatus("扫码枪连接异常,请重试",1);
+                e.printStackTrace();
+            }
+    }
+
+
+    //LON==扫码   LOFF==停止扫码
+    public void sendCommand(String command)  {
+            out.println(command);
+    }
+
+
+    public String receiveResponse() {
+        try {
+            this.sendCommand("LON\r\n");
+
+            // 创建一个Future来读取行
+            Future<String> future = executor.submit(() -> {
+                try {
+//                    System.out.println(in.readLine());
+                    return in.readLine();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            });
+
+            try {
+                // 尝试在10秒内获取结果
+                return future.get(10, TimeUnit.SECONDS);
+            } catch (TimeoutException e) {
+                // 处理超时情况future.cancel(true);
+                future.cancel(true);
+                throw new TimeoutException("Read operation timed out");
+            }
+        } catch (TimeoutException e) {
+            this.sendCommand("LOFF\r\n");
+//            this.setMenuStatus("扫码枪识别超时,请重试",1);
+            e.printStackTrace();
+            return null;
+        } catch (Exception e) {
+            this.sendCommand("LOFF\r\n");
+//            this.setMenuStatus("扫码枪连接异常,请重试",1);
+            close();
+            e.printStackTrace();
+            return null;
+        }
+    }
+    public void close() {
+        try {
+            // 关闭Socket连接
+            if (socket != null) {
+                socket.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }finally {
+        }
+    }
+
+
+
+}

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


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor