| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302 |
- package com.mes.ui;
- import com.alibaba.fastjson2.JSON;
- import com.alibaba.fastjson2.JSONObject;
- import com.mes.component.GunPanel;
- import com.mes.component.MesRadio;
- import com.mes.component.MesWebView;
- import com.mes.netty.NettyClient;
- import com.mes.util.DateLocalUtils;
- import com.mes.util.JdbcUtils;
- import com.mes.ygsl.YgslConfig;
- import io.netty.buffer.ByteBuf;
- import io.netty.buffer.Unpooled;
- import javafx.embed.swing.JFXPanel;
- 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.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.time.LocalDateTime;
- import java.util.*;
- import java.util.List;
- import java.util.Timer;
- public class MesClient extends JFrame {
- 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 int mes_tcp_port = 3000; // TCP服务端口
- public static int mes_heart_beat_cycle = 10; // 心跳周期
- public static int mes_heart_icon_cycle = 1;
- public static String mes_line_sn = ""; // 产线编号
- //TCP连接
- public static NettyClient nettyClient;
- //TCP连接状态
- public static boolean tcp_connect_flag = false;
- //TCP连接请求
- public static boolean connect_request_flag = false;
- //session
- public static String sessionid = "";
- public static JPanel contentPane;
- public static MesClient mesClientFrame;
- public static JTabbedPane tabbedPane;
- public static JScrollPane indexScrollPaneA;
- public static JScrollPane searchScrollPane;
- public static JScrollPane searchScrollPaneDj;
- public static Boolean check_quality_result = false;
- public static Integer work_status = 0;
- public static Integer pz_status = 0; // 拍照状态
- public static JButton heart_beat_menu;
- public static JButton status_menu;
- public static JButton user_menu;
- public static int scan_type = 0;
- public static JButton finish_ok_bt;
- public static JButton finish_ng_bt;
- public static JTextField product_sn;
- public static JButton f_scan_data_bt_1;
- public static String user20 = "";
- public static JFrame welcomeWin;
- public static JPanel indexPanelB;
- public static MesWebView jfxPanel = null;
- public static JPanel indexPanelC;
- public static MesWebView jfxPanel2 = null;
- public static MesRadio mesRadioHj;
- public static JTable table;
- public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
- public static Object[][] rowData = null;
- public static List<GunPanel> gunPanels = new ArrayList<>();
- public static JPanel gunPanelContainer;
- public static JLabel pzlabel;
- public static java.util.Timer submitCheckTimer;
- public static boolean autoSubmitEnabled = true;
- public static void main(String[] args) {
- // 设置全局异常处理器,防止程序突然崩溃
- Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- System.err.println("=== 捕获到未处理的异常 ===");
- System.err.println("线程: " + t.getName());
- System.err.println("异常信息: " + e.getMessage());
- e.printStackTrace();
- // 显示错误对话框
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JOptionPane.showMessageDialog(
- mesClientFrame,
- "程序发生错误:\n" + e.getMessage(),
- "错误",
- JOptionPane.ERROR_MESSAGE
- );
- }
- });
- }
- });
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- try{
- //读文件配置
- readProperty();
- // 显示界面
- mesClientFrame = new MesClient();
- mesClientFrame.setVisible(false);
- JdbcUtils.getConn();
- welcomeWin = new LoginFarme();
- welcomeWin.setVisible(true);
- if(mes_gw.equals("OP290")){
- pz_status = 0; // 未拍照
- }else{
- pz_status = 1; // 已拍照
- }
- getMaterailData();
- upParams();
- deviceOnline();
- checkpz();
- startSubmitCheckTimer();
- }catch (Exception e){
- System.err.println("=== 初始化过程中发生异常 ===");
- e.printStackTrace();
- JOptionPane.showMessageDialog(
- null,
- "程序初始化失败:\n" + e.getMessage(),
- "错误",
- JOptionPane.ERROR_MESSAGE
- );
- }
- }
- });
- }
- public static void initGunPanels() {
- gunPanels.clear();
- // 清空容器中的所有组件,防止重复添加
- if (gunPanelContainer != null) {
- gunPanelContainer.removeAll();
- }
- System.out.println("initGunPanels - gunPanelContainer: " + gunPanelContainer);
- List<YgslConfig> configs = JdbcUtils.getEnabledYgslConfigs();
- System.out.println("initGunPanels - 获取到配置: " + configs.size() + " 把枪");
- for (YgslConfig config : configs) {
- GunPanel gunPanel = new GunPanel(config);
- gunPanel.setTaskCompletedListener(new GunPanel.OnTaskCompletedListener() {
- @Override
- public void onTaskCompleted(GunPanel panel) {
- checkAllGunsCompleted();
- }
- });
- gunPanels.add(gunPanel);
- if (gunPanelContainer != null) {
- gunPanelContainer.add(gunPanel);
- gunPanel.connect();
- System.out.println("已添加枪到容器: " + config.getGunName());
- } else {
- System.out.println("gunPanelContainer 为空,无法添加!");
- }
- }
- // 刷新容器显示
- if (gunPanelContainer != null) {
- gunPanelContainer.revalidate();
- gunPanelContainer.repaint();
- }
- System.out.println("已加载 " + gunPanels.size() + " 把扭力枪");
- }
- public static void startSubmitCheckTimer() {
- if (submitCheckTimer != null) {
- submitCheckTimer.cancel();
- }
- submitCheckTimer = new Timer();
- submitCheckTimer.schedule(new TimerTask() {
- @Override
- public void run() {
- try {
- checkAllGunsCompleted();
- } catch (Exception e) {
- System.err.println("=== submitCheckTimer定时任务异常 ===");
- e.printStackTrace();
- }
- }
- }, 1000, 1000);
- }
- private static void checkAllGunsCompleted() {
- if (work_status != 1 || !check_quality_result) {
- return;
- }
- if (!autoSubmitEnabled) {
- return;
- }
- boolean allCompleted = true;
- for (GunPanel panel : gunPanels) {
- if (!panel.isTaskCompleted()) {
- allCompleted = false;
- break;
- }
- }
- if (allCompleted) {
- final boolean submitSuccess = submitQualityResult();
- SwingUtilities.invokeLater(() -> {
- if (submitSuccess) {
- setMenuStatus("所有任务完成,结果已提交", 0);
- resetScanA();
- // scanBarcode();
- } else {
- setMenuStatus("结果提交失败,请重试", -1);
- }
- });
- }
- }
- private static boolean submitQualityResult() {
- String sn = getBarcode(product_sn.getText());
- getUser();
- String qret = "OK";
- return DataUtil.sendQuality(nettyClient, sn, qret, user20);
- }
- //读配置文件
- 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_gw_des = OprnoUtil.getGwDes(mes_line_sn,mes_gw);
- System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
- }
- // 初始化TCP
- public static void initTcpConnection() {
- try {
- if(nettyClient==null) {
- //初始化TCP连接
- nettyClient = new NettyClient();
- //TCP连接状态
- tcp_connect_flag = false;
- //设置TCP请求状态
- connect_request_flag = true;
- DataUtil.synrTcp(nettyClient,mes_gw);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- //启动心跳包程序
- public static java.util.Timer heartBeatTimer;
- public static java.util.Timer heartBeatIconTimer;
- public static boolean iconREDFlag = true;
- public static void startHeartBeatTimer() {
- if(heartBeatTimer!=null) {
- heartBeatTimer.cancel();
- }
- heartBeatTimer = new java.util.Timer();
- heartBeatTimer.schedule(new TimerTask() {
- public void run() {
- try {
- if(nettyClient!=null&&tcp_connect_flag) {
- //System.out.println("发送心跳报文");
- DataUtil.heartBeat(nettyClient,mes_gw);
- heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
- }
- } catch (Exception e) {
- System.err.println("=== 心跳发送异常 ===");
- e.printStackTrace();
- }
- }
- }, 100,mes_heart_beat_cycle*1000);
- //心跳显示图标
- if(heartBeatIconTimer!=null) {
- heartBeatIconTimer.cancel();
- }
- heartBeatIconTimer = new Timer();
- heartBeatIconTimer.schedule(new TimerTask() {
- public void run() {
- try {
- if(tcp_connect_flag) {
- 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();
- }else {
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
- heart_beat_menu.repaint();
- //若未连接则尝试连接
- if(nettyClient!=null&&!tcp_connect_flag){
- System.out.println("TCP已断开");
- //TCP重新同步连接
- if(!connect_request_flag) {
- //System.out.println("TCP重新同步连接");
- //设置TCP请求状态,只重新同步连接一次
- connect_request_flag = true;
- DataUtil.synrTcp(nettyClient,mes_gw);
- }
- }
- }
- } catch (Exception e) {
- System.err.println("=== 心跳图标更新异常 ===");
- e.printStackTrace();
- }
- }
- }, 100,mes_heart_icon_cycle*1000);
- }
- public static void startYgslHeartBeatTimer() {
- }
- //设置tcp连接状态显示
- public static void setTcpStatus() {
- if(tcp_connect_flag) {
- // status_menu.setText("已连接MES服务器");
- MesClient.setMenuStatus("已连接MES服务器",0);
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- heart_beat_menu.repaint();
- }else {
- // status_menu.setText("未连接MES服务器");
- MesClient.setMenuStatus("未连接MES服务器",-1);
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- heart_beat_menu.repaint();
- }
- }
- public static java.util.Timer cjTimer5;
- public static void deviceOnline() {
- if(cjTimer5 != null) {
- cjTimer5.cancel();
- }
- cjTimer5 = new java.util.Timer();
- cjTimer5.schedule(new java.util.TimerTask() {
- public void run() {
- try{
- for (GunPanel panel : gunPanels) {
- if (panel.isOnline()) {
- if (work_status == 1 && pz_status == 1) {
- if (panel.isTaskCompleted()) {
- panel.disableTool();
- } else {
- panel.enableTool();
- }
- } else {
- panel.disableTool();
- }
- }
- }
- }catch (Exception e){
- System.err.println("=== deviceOnline定时任务异常 ===");
- e.printStackTrace();
- }
- }
- }, 1000, 1000);
- }
- public static java.util.Timer cjTimer2;
- public static void upParams() {
- if(cjTimer2!=null) {
- cjTimer2.cancel();
- }
- cjTimer2 = new Timer();
- cjTimer2.schedule(new TimerTask() {
- public void run() {
- try{
- List<YgslResp> prods = JdbcUtils.getYgsl();
- System.out.println("datas:"+ JSON.toJSONString(prods));
- if(prods.size() > 0){
- // 定时上传参数
- JSONObject retObj = DataUtil.upParams(JSON.toJSONString(prods));
- if(retObj!=null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
- // 更新sqlite已同步
- for(YgslResp prodReq:prods){
- JdbcUtils.updateSync(prodReq.getId(),1);
- }
- }
- }
- }catch (Exception e){
- System.err.println("=== upParams定时任务异常 ===");
- e.printStackTrace();
- }
- }
- }, 1000,30*1000);
- }
- public static java.util.Timer cjTimer3;
- public static void checkpz() {
- if(cjTimer3!=null) {
- cjTimer3.cancel();
- }
- cjTimer3 = new Timer();
- cjTimer3.schedule(new TimerTask() {
- public void run() {
- try{
- if(work_status == 1 && mes_gw.equals("OP290") && pz_status == 0){
- JSONObject retObj = DataUtil.checkpz(product_sn.getText());
- if(retObj!=null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
- pz_status = 1; // 已拍照
- pzlabel.setVisible(true);
- }
- }
- }catch (Exception e){
- System.err.println("=== checkpz定时任务异常 ===");
- e.printStackTrace();
- }
- }
- }, 1000,2*1000);
- }
- public static void initWarehouseData(){
- resetScanA();
- }
- public static void resetScanA() {
- work_status = 0;
- check_quality_result = false;
- MesClient.finish_ok_bt.setEnabled(false);
- MesClient.finish_ng_bt.setEnabled(false);
- product_sn.setText("");
- MesClient.f_scan_data_bt_1.setEnabled(true);
- MesClient.setMenuStatus("请扫工件码",0);
- for (GunPanel panel : gunPanels) {
- panel.reset();
- panel.disableTool();
- }
- pzlabel.setVisible(false);
- if(mes_gw.equals("OP290")){
- pz_status = 0;
- }else{
- pz_status = 1;
- }
- updateMaterailData();
- shiftUserCheck();
- }
- public static int userLoginHours;//用户登录所处小时
- //换班用户信息检查
- private static void shiftUserCheck() {
- LocalDateTime now = LocalDateTime.now();
- // 判断时间范围
- if (userLoginHours >= 8 && userLoginHours < 20) {
- int hour = now.getHour();
- if (hour >= 20 || hour < 8) {
- logoff();
- }
- } else {
- int hour = now.getHour();
- if (hour >= 8 && hour < 20) {
- logoff();
- }
- }
- }
- public static void resetScanB() {
- }
- //获取用户20位
- public static void getUser() {
- user20 = user_menu.getText().toString();
- String space_tmp1 = "";
- if(user20.length()<20) {
- for(int i=0;i<20-user20.length();i++) {
- space_tmp1 = space_tmp1 + " ";
- }
- }
- user20 = user20 + space_tmp1;
- }
- //获取barcode内容36位
- public static String getBarcode(String barcodeTmp) {
- String barcodeRet = barcodeTmp;
- if(barcodeTmp.equalsIgnoreCase("")) {
- return "";
- }else {
- if(barcodeTmp.length()<36) {
- String space = "";
- for(int i=0;i<36-barcodeTmp.length();i++) {
- space = space + " ";
- }
- barcodeRet = barcodeTmp + space;
- }
- }
- return barcodeRet;
- }
- public static void scanBarcode() {
- if(work_status == 1){
- JOptionPane.showMessageDialog(mesClientFrame,"工作中,勿扫码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- String scanBarcodeTitle = "";
- switch(scan_type) {
- case 1:
- product_sn.setText("");
- scanBarcodeTitle = "请扫工件码";
- break;
- }
- //弹窗扫工件码
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
- //获取用户
- getUser();
- //获取扫码内容36位
- String barcode36 = getBarcode(scanBarcode);//处理36为码
- //工位号
- String gw = "";
- switch(scan_type) {
- case 1:
- product_sn.setText(scanBarcode);
- break;
- }
- //刷新界面
- mesClientFrame.repaint();
- if(!tcp_connect_flag) {
- JOptionPane.showMessageDialog(mesClientFrame,"设备未连接Mes服务器","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- // 查询工件质量
- Boolean sendret = DataUtil.checkQuality(nettyClient,barcode36,user20);
- if(!sendret){
- JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- }else {
- JOptionPane.showMessageDialog(mesClientFrame,"请扫工件码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- }
- public static void logoff() {
- // welcomeWin.setVisible(true);
- mesClientFrame.setVisible(false);
- nettyClient = null;
- // if(heartBeatTimer!=null) {
- // heartBeatTimer.cancel();
- // }
- // if(heartBeatIconTimer!=null) {
- // heartBeatIconTimer.cancel();
- // }
- tcp_connect_flag = false;
- connect_request_flag = false;
- }
- public MesClient() {
- setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
- setTitle("MES系统客户端:"+mes_gw + "- " + mes_gw_des);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(0, 0, 1024, 768);
- 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);
- JMenuItem resetTcpMenu = new JMenuItem("\u91CD\u8FDEMES");
- resetTcpMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
- resetTcpMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- resetTcpMenu.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- super.mouseClicked(e);
- //重连mes
- nettyClient.future.channel().close();
- }
- });
- settingMenu.add(resetTcpMenu);
- JMenuItem resetTcpMenu_1 = new JMenuItem("刷新工件");
- resetTcpMenu_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
- resetTcpMenu_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- resetTcpMenu_1.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- super.mouseClicked(e);
- resetScanA();
- }
- });
- settingMenu.add(resetTcpMenu_1);
- JMenuItem resetTcpMenu_11 = new JMenuItem("手动提交");
- resetTcpMenu_11.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
- resetTcpMenu_11.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- resetTcpMenu_11.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent e) {
- super.mouseClicked(e);
- MesClient.finish_ok_bt.setEnabled(true);
- MesClient.finish_ng_bt.setEnabled(true);
- }
- });
- settingMenu.add(resetTcpMenu_11);
- 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服务器");
- if(tcp_connect_flag) {
- status_menu.setText("已连接MES服务器");
- status_menu.setForeground(Color.GREEN);
- }else {
- status_menu.setText("未连接MES服务器");
- status_menu.setForeground(Color.DARK_GRAY);
- }
- 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("2024-02-20 23:20:10");
- 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("JinJuShi");
- user_menu.setForeground(Color.GREEN);
- user_menu.setFont(new Font("微软雅黑", Font.PLAIN, 22));
- user_menu.setBackground(Color.BLACK);
- toolBar.add(user_menu);
- JLabel space_3 = new JLabel(" ");
- toolBar.add(space_3);
- JLabel space_4 = new JLabel(" ");
- toolBar.add(space_4);
- tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- tabbedPane.setMinimumSize(new Dimension(400, 50));
- tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
- contentPane.add(tabbedPane);
- //首页
- JPanel indexPanelA = new JPanel();
- indexScrollPaneA = new JScrollPane(indexPanelA);
- indexPanelA.setLayout(null);
- pzlabel = new JLabel("水嘴密封圈已拍照");
- pzlabel.setHorizontalAlignment(SwingConstants.CENTER);
- pzlabel.setFont(new Font("微软雅黑", Font.PLAIN, 28));
- pzlabel.setForeground(Color.green);
- pzlabel.setBounds(81, 20, 602, 40);
- pzlabel.setVisible(false);
- indexPanelA.add(pzlabel);
- product_sn = new JTextField();
- product_sn.setHorizontalAlignment(SwingConstants.CENTER);
- product_sn.setEditable(false);
- product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
- product_sn.setBounds(81, 70, 602, 70);
- indexPanelA.add(product_sn);
- product_sn.setColumns(10);
- f_scan_data_bt_1 = new JButton("扫码");
- f_scan_data_bt_1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- scan_type = 1;
- scanBarcode();
- }
- });
- f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
- f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 32));
- f_scan_data_bt_1.setBounds(693, 70, 198, 70);
- indexPanelA.add(f_scan_data_bt_1);
- // String[] hjtitles = new String[]{"焊机1","焊机2","焊机3"};
- // String[] hjvals = new String[]{"HJ001","HJ002","HJ003"};
- // mesRadioHj = new MesRadio(hjtitles,hjvals);
- // mesRadioHj.setSize(500,50);
- // mesRadioHj.setBounds(190,170,500,50);
- // indexPanelA.add(mesRadioHj);
- finish_ok_bt = new JButton("OK");
- finish_ok_bt.setEnabled(false);
- finish_ok_bt.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(work_status == 1 && check_quality_result){
- String sn = getBarcode(product_sn.getText());
- getUser();
- String qret = "OK";
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20);
- if(!sendret){
- JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- }
- }
- });
- finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
- finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
- finish_ok_bt.setBounds(185, 405, 240, 80);
- finish_ok_bt.setEnabled(false);
- indexPanelA.add(finish_ok_bt);
- finish_ng_bt = new JButton("NG");
- finish_ng_bt.setEnabled(false);
- finish_ng_bt.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(work_status == 1 && check_quality_result){
- String sn = getBarcode(product_sn.getText());
- getUser();
- String qret = "NG";
- Boolean sendret = DataUtil.sendQuality(nettyClient,sn,qret,user20);
- if(!sendret){
- JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- }
- }
- });
- finish_ng_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ng_bg.png")));
- finish_ng_bt.setFont(new Font("微软雅黑", Font.PLAIN, 32));
- finish_ng_bt.setBounds(495, 405, 240, 80);
- finish_ng_bt.setEnabled(false);
- indexPanelA.add(finish_ng_bt);
- gunPanelContainer = new JPanel();
- gunPanelContainer.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 15));
- gunPanelContainer.setBounds(20, 160, 750, 300);
- gunPanelContainer.setOpaque(false);
- indexPanelA.add(gunPanelContainer);
- tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
- tabbedPane.setEnabledAt(0, true);
- // searchScrollPane = new JScrollPane((Component) null);
- indexPanelC = new JPanel();
- searchScrollPaneDj = new JScrollPane(indexPanelC);
- indexPanelC.setLayout(null);
- tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
- indexPanelB = new JPanel();
- searchScrollPane = new JScrollPane(indexPanelB);
- indexPanelB.setLayout(null);
- tabbedPane.addTab("工作记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPane, null);
- // 增加工具配置页面
- JPanel indexConfigPanel = new JPanel();
- indexConfigPanel.setLayout(null);
- tabbedPane.addTab("工具配置", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexConfigPanel, null);
- initGunConfigPanel(indexConfigPanel);
- tabbedPane.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
- int selectedIndex = tabbedPane.getSelectedIndex();
- System.out.println("selectedIndex:"+selectedIndex);
- 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 getMaterailData(){
- JSONObject retObj = DataUtil.getBindMaterail();
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
- java.util.List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
- int i = 0;
- rowData = new Object[arrs.size()][7];
- for (BindMaterialResp bindMaterialResp:arrs){
- rowData[i][0] = bindMaterialResp.getMaterialTitle();
- rowData[i][1] = bindMaterialResp.getBatchSn();
- rowData[i][2] = bindMaterialResp.getLastTimes();
- rowData[i][3] = "";
- rowData[i][4] = bindMaterialResp.getCraft();
- rowData[i][5] = bindMaterialResp.getMaterialId();
- rowData[i][6] = bindMaterialResp.getType();
- i++;
- }
- bindBatchPanel();
- }
- }
- public static void updateMaterailData(){
- JSONObject retObj = DataUtil.getBindMaterail();
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
- List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
- int i = 0;
- for (BindMaterialResp bindMaterialResp:arrs){
- rowData[i][0] = bindMaterialResp.getMaterialTitle();
- rowData[i][1] = bindMaterialResp.getBatchSn();
- rowData[i][2] = bindMaterialResp.getLastTimes();
- rowData[i][3] = "";
- rowData[i][4] = bindMaterialResp.getCraft();
- rowData[i][5] = bindMaterialResp.getMaterialId();
- rowData[i][6] = bindMaterialResp.getType();
- i++;
- }
- MesClient.table.repaint();
- }
- }
- // 绑定物料批次码
- public static void scanBatchSn(BindMaterialResp bindMaterialResp) {
- //弹窗扫工件码
- String scanBarcodeTitle = "请扫物料:"+bindMaterialResp.getMaterialTitle();
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
- JSONObject retObj = DataUtil.saveBindMaterail(scanBarcode,bindMaterialResp.getCraft(),bindMaterialResp.getMaterialId(),bindMaterialResp.getType());
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
- MesClient.setMenuStatus("扫物料:"+bindMaterialResp.getMaterialTitle()+"成功",0);
- updateMaterailData();
- }else{
- if(retObj.get("result")==null){
- MesClient.setMenuStatus("请求失败,请重试",-1);
- }else{
- if(retObj.get("result").toString().equalsIgnoreCase("false")){
- MesClient.setMenuStatus(retObj.getString("message"),-1);
- }
- }
- }
- }
- }
- public static void bindBatchPanel(){
- JPanel indexPanelBB = new JPanel();
- JPanel panel = new JPanel();
- panel.setBounds(0, 0, 990, 550);
- // panel.setBounds(81, 50, 810, 479);
- indexPanelBB.add(panel);
- panel.setLayout(new GridLayout(0, 1, 0, 0));
- table = new JTable(rowData, columnNames){
- public boolean isCellEditable(int row, int column) {
- if(column == 3){
- return true;
- }
- return false;
- }
- };
- table.setRowHeight(40);
- table.setEnabled(true);
- table.setFont(new Font("微软雅黑", Font.PLAIN, 14));
- table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRendererButton());
- table.getColumnModel().getColumn(3).setCellEditor(new TableCellEditorButton());
- JScrollPane scrollPane = new JScrollPane(table);
- panel.add(scrollPane);
- JScrollPane indexScrollPaneB = new JScrollPane(indexPanelBB);
- indexPanelBB.setLayout(null);
- tabbedPane.addTab("绑定物料", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexScrollPaneB, null);
- }
- private static JTable configTable;
- private static JButton addGunButton;
- private static JButton saveConfigButton;
- public static void initGunConfigPanel(JPanel panel) {
- JLabel titleLabel = new JLabel("扭力枪配置管理");
- titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
- titleLabel.setBounds(350, 20, 300, 40);
- panel.add(titleLabel);
- String[] columnNames = {"枪号", "名称", "IP地址", "端口", "任务数", "启用", "自动提交"};
- List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
- Object[][] data = new Object[configs.size()][7];
- for (int i = 0; i < configs.size(); i++) {
- YgslConfig config = configs.get(i);
- data[i][0] = config.getGunIndex();
- data[i][1] = config.getGunName();
- data[i][2] = config.getIpAddress();
- data[i][3] = config.getPort();
- data[i][4] = config.getTaskCount();
- data[i][5] = config.getEnabled() == 1 ? "是" : "否";
- data[i][6] = config.getAutoSubmit() == 1 ? "是" : "否";
- }
- configTable = new JTable(data, columnNames);
- configTable.setRowHeight(35);
- configTable.setFont(new Font("微软雅黑", Font.PLAIN, 14));
- configTable.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 14));
- JScrollPane scrollPane = new JScrollPane(configTable);
- scrollPane.setBounds(50, 70, 900, 400);
- panel.add(scrollPane);
- addGunButton = new JButton("添加枪");
- addGunButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- addGunButton.setBounds(150, 490, 120, 40);
- addGunButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addNewGun(panel);
- }
- });
- panel.add(addGunButton);
- saveConfigButton = new JButton("保存配置");
- saveConfigButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- saveConfigButton.setBounds(300, 490, 120, 40);
- saveConfigButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveGunConfigs();
- }
- });
- panel.add(saveConfigButton);
- JButton deleteButton = new JButton("删除选中");
- deleteButton.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- deleteButton.setBounds(450, 490, 120, 40);
- deleteButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- int selectedRow = configTable.getSelectedRow();
- if (selectedRow >= 0) {
- int confirm = JOptionPane.showConfirmDialog(mesClientFrame, "确定要删除选中的配置吗?", "确认删除", JOptionPane.YES_NO_OPTION);
- if (confirm == JOptionPane.YES_OPTION) {
- List<YgslConfig> allConfigs = JdbcUtils.getYgslConfigs();
- if (selectedRow < allConfigs.size()) {
- JdbcUtils.deleteYgslConfig(allConfigs.get(selectedRow).getId());
- reloadGunConfigs(panel);
- }
- }
- } else {
- JOptionPane.showMessageDialog(mesClientFrame, "请先选中一行", "提示", JOptionPane.INFORMATION_MESSAGE);
- }
- }
- });
- panel.add(deleteButton);
- configTable.addMouseListener(new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- int row = configTable.getSelectedRow();
- if (row >= 0) {
- editGunConfig(row, panel);
- }
- }
- });
- }
- private static void editGunConfig(int row, JPanel panel) {
- List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
- if (row >= configs.size()) return;
- YgslConfig config = configs.get(row);
- JDialog dialog = new JDialog(mesClientFrame, "编辑扭力枪", true);
- dialog.setSize(400, 400);
- dialog.setLocationRelativeTo(mesClientFrame);
- dialog.setLayout(null);
- JLabel idLabel = new JLabel("ID: " + config.getId());
- idLabel.setBounds(50, 20, 300, 30);
- dialog.add(idLabel);
- JLabel nameLabel = new JLabel("枪号:");
- nameLabel.setBounds(50, 60, 80, 30);
- dialog.add(nameLabel);
- JTextField nameField = new JTextField(String.valueOf(config.getGunIndex()));
- nameField.setBounds(140, 60, 180, 30);
- dialog.add(nameField);
- JLabel gunNameLabel = new JLabel("名称:");
- gunNameLabel.setBounds(50, 100, 80, 30);
- dialog.add(gunNameLabel);
- JTextField gunNameField = new JTextField(config.getGunName());
- gunNameField.setBounds(140, 100, 180, 30);
- dialog.add(gunNameField);
- JLabel ipLabel = new JLabel("IP地址:");
- ipLabel.setBounds(50, 140, 80, 30);
- dialog.add(ipLabel);
- JTextField ipField = new JTextField(config.getIpAddress());
- ipField.setBounds(140, 140, 180, 30);
- dialog.add(ipField);
- JLabel portLabel = new JLabel("端口:");
- portLabel.setBounds(50, 180, 80, 30);
- dialog.add(portLabel);
- JTextField portField = new JTextField(String.valueOf(config.getPort()));
- portField.setBounds(140, 180, 180, 30);
- dialog.add(portField);
- JLabel taskLabel = new JLabel("任务数:");
- taskLabel.setBounds(50, 220, 80, 30);
- dialog.add(taskLabel);
- JTextField taskField = new JTextField(String.valueOf(config.getTaskCount()));
- taskField.setBounds(140, 220, 180, 30);
- dialog.add(taskField);
- JLabel enabledLabel = new JLabel("启用:");
- enabledLabel.setBounds(50, 260, 80, 30);
- dialog.add(enabledLabel);
- JComboBox<String> enabledBox = new JComboBox<>(new String[]{"否", "是"});
- enabledBox.setBounds(140, 260, 180, 30);
- enabledBox.setSelectedIndex(config.getEnabled() == 1 ? 1 : 0);
- dialog.add(enabledBox);
- JButton okButton = new JButton("保存");
- okButton.setBounds(100, 310, 80, 30);
- okButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- config.setGunIndex(Integer.parseInt(nameField.getText()));
- config.setGunName(gunNameField.getText());
- config.setIpAddress(ipField.getText());
- config.setPort(Integer.parseInt(portField.getText()));
- config.setTaskCount(Integer.parseInt(taskField.getText()));
- config.setEnabled(enabledBox.getSelectedIndex() == 1 ? 1 : 0);
- JdbcUtils.updateYgslConfig(config);
- dialog.dispose();
- reloadGunConfigs(panel);
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(dialog, "输入格式错误,请检查", "错误", JOptionPane.ERROR_MESSAGE);
- }
- }
- });
- dialog.add(okButton);
- JButton cancelButton = new JButton("取消");
- cancelButton.setBounds(200, 310, 80, 30);
- cancelButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- dialog.dispose();
- }
- });
- dialog.add(cancelButton);
- dialog.setVisible(true);
- }
- private static void addNewGun(JPanel panel) {
- JDialog dialog = new JDialog(mesClientFrame, "添加扭力枪", true);
- dialog.setSize(400, 350);
- dialog.setLocationRelativeTo(mesClientFrame);
- dialog.setLayout(null);
- JLabel nameLabel = new JLabel("枪号:");
- nameLabel.setBounds(50, 30, 80, 30);
- dialog.add(nameLabel);
- JTextField nameField = new JTextField();
- nameField.setBounds(140, 30, 180, 30);
- dialog.add(nameField);
- JLabel gunNameLabel = new JLabel("名称:");
- gunNameLabel.setBounds(50, 80, 80, 30);
- dialog.add(gunNameLabel);
- JTextField gunNameField = new JTextField("M5");
- gunNameField.setBounds(140, 80, 180, 30);
- dialog.add(gunNameField);
- JLabel ipLabel = new JLabel("IP地址:");
- ipLabel.setBounds(50, 130, 80, 30);
- dialog.add(ipLabel);
- JTextField ipField = new JTextField("192.168.5.100");
- ipField.setBounds(140, 130, 180, 30);
- dialog.add(ipField);
- JLabel portLabel = new JLabel("端口:");
- portLabel.setBounds(50, 180, 80, 30);
- dialog.add(portLabel);
- JTextField portField = new JTextField("4545");
- portField.setBounds(140, 180, 180, 30);
- dialog.add(portField);
- JLabel taskLabel = new JLabel("任务数:");
- taskLabel.setBounds(50, 230, 80, 30);
- dialog.add(taskLabel);
- JTextField taskField = new JTextField("12");
- taskField.setBounds(140, 230, 180, 30);
- dialog.add(taskField);
- JButton okButton = new JButton("确定");
- okButton.setBounds(100, 280, 80, 30);
- okButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- try {
- int gunIndex = Integer.parseInt(nameField.getText());
- String gunName = gunNameField.getText();
- String ip = ipField.getText();
- int port = Integer.parseInt(portField.getText());
- int taskCount = Integer.parseInt(taskField.getText());
- YgslConfig config = new YgslConfig(gunIndex, gunName, ip, port, taskCount);
- JdbcUtils.insertYgslConfig(config);
- dialog.dispose();
- reloadGunConfigs(panel);
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(dialog, "输入格式错误,请检查", "错误", JOptionPane.ERROR_MESSAGE);
- }
- }
- });
- dialog.add(okButton);
- JButton cancelButton = new JButton("取消");
- cancelButton.setBounds(200, 280, 80, 30);
- cancelButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- dialog.dispose();
- }
- });
- dialog.add(cancelButton);
- dialog.setVisible(true);
- }
- private static void saveGunConfigs() {
- try {
- List<YgslConfig> configs = JdbcUtils.getYgslConfigs();
- int rowCount = configTable.getRowCount();
- for (int i = 0; i < rowCount && i < configs.size(); i++) {
- YgslConfig config = configs.get(i);
- config.setGunIndex((Integer) configTable.getValueAt(i, 0));
- config.setGunName((String) configTable.getValueAt(i, 1));
- config.setIpAddress((String) configTable.getValueAt(i, 2));
- config.setPort((Integer) configTable.getValueAt(i, 3));
- config.setTaskCount((Integer) configTable.getValueAt(i, 4));
- config.setEnabled(((String) configTable.getValueAt(i, 5)).equals("是") ? 1 : 0);
- config.setAutoSubmit(((String) configTable.getValueAt(i, 6)).equals("是") ? 1 : 0);
- JdbcUtils.updateYgslConfig(config);
- }
- JOptionPane.showMessageDialog(mesClientFrame, "配置保存成功!重启后生效", "提示", JOptionPane.INFORMATION_MESSAGE);
- } catch (Exception e) {
- e.printStackTrace();
- JOptionPane.showMessageDialog(mesClientFrame, "保存失败:" + e.getMessage(), "错误", JOptionPane.ERROR_MESSAGE);
- }
- }
- private static void reloadGunConfigs(JPanel panel) {
- panel.removeAll();
- initGunConfigPanel(panel);
- panel.revalidate();
- panel.repaint();
- }
- }
|