MesClient.java 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. package com.mes.ui;
  2. import com.alibaba.fastjson2.JSON;
  3. import com.alibaba.fastjson2.JSONObject;
  4. import com.mes.component.MesRadio;
  5. import com.mes.component.MesWebView;
  6. import com.mes.component.ProductTypePanel;
  7. import com.mes.netty.NettyClient;
  8. import com.mes.util.*;
  9. import javax.swing.*;
  10. import javax.swing.border.EmptyBorder;
  11. import javax.swing.event.ChangeEvent;
  12. import javax.swing.event.ChangeListener;
  13. import java.awt.*;
  14. import java.awt.event.ActionEvent;
  15. import java.awt.event.ActionListener;
  16. import java.awt.event.MouseAdapter;
  17. import java.awt.event.MouseEvent;
  18. import java.io.BufferedReader;
  19. import java.io.IOException;
  20. import java.io.InputStream;
  21. import java.io.InputStreamReader;
  22. import java.time.LocalDateTime;
  23. import java.util.List;
  24. import java.util.Properties;
  25. import java.util.Timer;
  26. import java.util.TimerTask;
  27. public class MesClient extends JFrame {
  28. private static String Drivde = "org.sqlite.JDBC";
  29. public static int mes_auth = 0; // 权限级别 0=无权限 1=操作工人 2=管理员
  30. public static String mes_gw = ""; // 工位号
  31. public static String mes_gw_des = ""; // 工位名称
  32. public static String mes_server_ip = ""; // 服务器IP地址
  33. public static int mes_tcp_port = 3000; // TCP服务端口
  34. public static int mes_heart_beat_cycle = 10; // 心跳周期
  35. public static int mes_heart_icon_cycle = 1;
  36. public static String mes_line_sn = ""; // 产线编号
  37. public static String mes_serial_port = "COM1"; // 称重仪串口号
  38. public static int mes_serial_baud = 9600; // 称重仪波特率
  39. //新增字段
  40. public static ProductTypePanel productTypePanel;
  41. public static JLabel productTypeCurrentLabel;
  42. public static final int PRODUCT_SN_LENGTH = 32;
  43. public static final String PREFIX_ZJ = "000020021815-01000016"; //智界
  44. public static final String PREFIX_SJ = "000020022029-01000016"; //尚界
  45. public static final boolean PRODUCT_TYPE_SWITCH_ENABLED = false;
  46. public static final String PRODUCT_TYPE_SWITCH_PASSWORD = "503833";
  47. public static final String PRODUCT_TYPE_ZJ = ProductTypePanel.TYPE_ZJ;
  48. public static final String PRODUCT_TYPE_SJ = ProductTypePanel.TYPE_SJ;
  49. //TCP连接
  50. public static NettyClient nettyClient;
  51. //TCP连接状态
  52. public static boolean tcp_connect_flag = false;
  53. //TCP连接请求
  54. public static boolean connect_request_flag = false;
  55. public static boolean com_connect_flag = false;
  56. //session
  57. public static String sessionid = "";
  58. public static JPanel contentPane;
  59. public static MesClient mesClientFrame;
  60. public static JTabbedPane tabbedPane;
  61. public static JScrollPane indexScrollPaneA;
  62. public static JScrollPane searchScrollPane;
  63. public static JScrollPane searchScrollPaneDj;
  64. public static SerialPortUtils serialPortUtils;
  65. public static BluetoothUtils bluetoothUtils;
  66. public static ParamConfig paramConfig;
  67. public static Boolean check_quality_result = false;
  68. public static Integer work_status = 0;
  69. public static JButton heart_beat_menu;
  70. public static JButton status_menu;
  71. public static JButton user_menu;
  72. public static int scan_type = 0;
  73. public static JButton finish_ok_bt;
  74. // public static JButton finish_ng_bt;
  75. public static JButton batch_sn_bt;
  76. public static JTextField product_sn;
  77. public static JButton f_scan_data_bt_1;
  78. public static JButton is_js_btn;
  79. public static String comboBoxValue = "COM1";
  80. public static String user20 = "";
  81. public static String is_js_btn_val = "1";
  82. public static JFrame welcomeWin;
  83. public static JPanel indexPanelB;
  84. public static MesWebView jfxPanel = null;
  85. public static JPanel indexPanelC;
  86. public static MesWebView jfxPanel2 = null;
  87. public static MesRadio mesRadioHj;
  88. public static JTable table;
  89. public static Object[] columnNames = { "物料名称", "绑定批次", "剩余次数", "操作" };
  90. public static Object[][] rowData = null;
  91. public static Timer cjTimer; //串口定时器
  92. public static Timer cjTimer2; //串口定时器2
  93. private static final String TARGET_DEVICE_ADDRESS = "001135390238";
  94. public static void main(String[] args) {
  95. //EventQueue.invokeLater(new Runnable() )是SwingUtilities类中的一个静态方法,
  96. // 用于在事件调度线程中执行指定的Runnable。
  97. //事件调度线程是Swing的核心线程,负责处理所有Swing组件的事件。
  98. EventQueue.invokeLater(new Runnable() {
  99. @Override
  100. public void run() {
  101. try{
  102. //读文件配置(新增串口号和波特率)
  103. readProperty();
  104. //检查串口连接(定时器定时检查串口连接)
  105. checkComPort();
  106. // 显示界面
  107. mesClientFrame = new MesClient();
  108. mesClientFrame.setVisible(false);
  109. //连接数据库
  110. JdbcUtils.getConn();
  111. //显示登录界面
  112. welcomeWin = new LoginFarme();
  113. welcomeWin.setVisible(true);
  114. // getMaterailData();
  115. }catch (Exception e){
  116. e.printStackTrace();
  117. }
  118. }
  119. });
  120. }
  121. public static void initComPort() {
  122. //
  123. try {
  124. if (serialPortUtils != null) {
  125. serialPortUtils.closeSerialPort();
  126. serialPortUtils = null;
  127. }
  128. //初始化串口
  129. serialPortUtils = new SerialPortUtils();
  130. //创建串口参数配置
  131. paramConfig = new ParamConfig(mes_serial_port, mes_serial_baud, 0, 8, 1);
  132. //初始化串口
  133. serialPortUtils.init(paramConfig);
  134. System.out.println("初始化称重串口: " + mes_serial_port + ", 波特率: " + mes_serial_baud);
  135. } catch (Throwable e) {
  136. //串口连接失败标志
  137. com_connect_flag = false;
  138. //打印错误信息
  139. System.err.println("称重串口初始化失败: " + e.getMessage());
  140. e.printStackTrace();
  141. }
  142. }
  143. // 串口断开时定时重连
  144. public static void checkComPort() {
  145. //如果定时器不为空,则取消定时器
  146. if (MesClient.cjTimer2 != null) {
  147. MesClient.cjTimer2.cancel();
  148. }
  149. //创建新的定时器
  150. MesClient.cjTimer2 = new Timer();
  151. //定时器执行任务
  152. MesClient.cjTimer2.schedule(new TimerTask() {
  153. @Override
  154. public void run() {
  155. try {
  156. //如果串口连接标志为false,则重连串口
  157. if (!com_connect_flag) {
  158. System.out.println("称重串口断开,正在重连");
  159. initComPort(); //重连串口
  160. }
  161. } catch (Exception e) {
  162. e.printStackTrace();
  163. }
  164. }
  165. }, 2000, 2000); //线程本身并不阻塞
  166. initComPort(); //初始化串口
  167. }
  168. //读配置文件
  169. private static void readProperty() throws IOException{
  170. String enconding = "UTF-8";
  171. InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
  172. Properties pro = new Properties();
  173. BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
  174. pro.load(br);
  175. mes_gw = pro.getProperty("mes.gw");
  176. // mes_gw_des = pro.getProperty("mes.gw_des");
  177. mes_server_ip = pro.getProperty("mes.server_ip");
  178. mes_tcp_port = Integer.parseInt(pro.getProperty("mes.tcp_port"));
  179. mes_heart_beat_cycle = Integer.parseInt(pro.getProperty("mes.heart_beat_cycle"));
  180. mes_line_sn = pro.getProperty("mes.line_sn");
  181. mes_serial_port = pro.getProperty("mes.serial.port", "COM1");
  182. mes_serial_baud = Integer.parseInt(pro.getProperty("mes.serial.baud", "9600"));
  183. mes_gw_des = OprnoUtil.getGwDes(mes_line_sn,mes_gw);
  184. System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
  185. }
  186. // 初始化TCP
  187. public static void initTcpConnection() {
  188. try {
  189. if(nettyClient==null) {
  190. //初始化TCP连接
  191. nettyClient = new NettyClient();
  192. //TCP连接状态
  193. tcp_connect_flag = false;
  194. //设置TCP请求状态
  195. connect_request_flag = true;
  196. DataUtil.synrTcp(nettyClient,mes_gw);
  197. }
  198. } catch (Exception e) {
  199. // TODO Auto-generated catch block
  200. e.printStackTrace();
  201. }
  202. }
  203. //启动心跳包程序
  204. public static java.util.Timer heartBeatTimer;
  205. public static java.util.Timer heartBeatIconTimer;
  206. public static boolean iconREDFlag = true;
  207. public static JTextField weight_text;
  208. public static JTextField batch_sn_text;
  209. public static JLabel lblNewLabel;
  210. public static JLabel lblNewLabel_1;
  211. private static JComboBox comboBox;
  212. public static JButton finish_ok_bt_1;
  213. public static void startHeartBeatTimer() {
  214. if(heartBeatTimer!=null) {
  215. heartBeatTimer.cancel();
  216. }
  217. heartBeatTimer = new java.util.Timer();
  218. heartBeatTimer.schedule(new TimerTask() {
  219. public void run() {
  220. if(nettyClient!=null&&tcp_connect_flag) {
  221. //System.out.println("发送心跳报文");
  222. DataUtil.heartBeat(nettyClient,mes_gw);
  223. heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
  224. }
  225. }
  226. }, 100,mes_heart_beat_cycle*1000);
  227. //心跳显示图标
  228. if(heartBeatIconTimer!=null) {
  229. heartBeatIconTimer.cancel();
  230. }
  231. heartBeatIconTimer = new Timer();
  232. heartBeatIconTimer.schedule(new TimerTask() {
  233. public void run() {
  234. if(tcp_connect_flag) {
  235. if(iconREDFlag) {
  236. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
  237. iconREDFlag = false;
  238. }else {
  239. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/green_dot.png")));
  240. iconREDFlag = true;
  241. }
  242. heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
  243. heart_beat_menu.repaint();
  244. }else {
  245. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
  246. heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
  247. heart_beat_menu.repaint();
  248. //若未连接则尝试连接
  249. if(nettyClient!=null&&!tcp_connect_flag){
  250. System.out.println("TCP已断开");
  251. //TCP重新同步连接
  252. if(!connect_request_flag) {
  253. //System.out.println("TCP重新同步连接");
  254. //设置TCP请求状态,只重新同步连接一次
  255. connect_request_flag = true;
  256. DataUtil.synrTcp(nettyClient,mes_gw);
  257. }
  258. }
  259. }
  260. }
  261. }, 100,mes_heart_icon_cycle*1000);
  262. }
  263. //设置tcp连接状态显示
  264. public static void setTcpStatus() {
  265. if(tcp_connect_flag) {
  266. status_menu.setText("已连接MES服务器");
  267. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
  268. heart_beat_menu.repaint();
  269. }else {
  270. status_menu.setText("未连接MES服务器");
  271. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
  272. heart_beat_menu.repaint();
  273. }
  274. }
  275. public static void initWarehouseData(){
  276. loadProductTypeFromDb(); //新增
  277. resetScanA();
  278. }
  279. public static void resetScanA() {
  280. work_status = 0;
  281. check_quality_result = false;
  282. // MesClient.start_work_bt.setVisible(false);
  283. // MesClient.finish_ng_bt.setVisible(false);
  284. // MesClient.finish_ok_bt.setVisible(false);
  285. MesClient.finish_ok_bt.setEnabled(false);
  286. product_sn.setText("");
  287. batch_sn_text.setText("");
  288. weight_text.setText("");
  289. batch_sn_bt.setEnabled(false);
  290. weight_text.setEnabled(false);
  291. is_js_btn.setText("最后一台");
  292. is_js_btn_val = "1";
  293. is_js_btn.setBackground(null);
  294. finish_ok_bt.setEnabled(false);
  295. MesClient.finish_ok_bt_1.setText("称重");
  296. // MesClient.f_scan_data_bt_1.setEnabled(false);
  297. MesClient.f_scan_data_bt_1.setEnabled(true);
  298. // DataUtil.stopWork(sessionid);
  299. updateProductTypePanelEnabled(true);
  300. if (PRODUCT_TYPE_SWITCH_ENABLED) {
  301. MesClient.setMenuStatus("当前生产类型:" + getProductTypeName() + ",请扫工件码",0);
  302. } else {
  303. MesClient.setMenuStatus("请扫工件码",0);
  304. }
  305. // product_result_text.setText("");
  306. // work_status_text.setText("");
  307. // MesClient.setMenuStatus("涂胶已超过10分钟,已失效",-1);
  308. // updateMaterailData();
  309. shiftUserCheck();
  310. }
  311. public static int userLoginHours;//用户登录所处小时
  312. //换班用户信息检查
  313. private static void shiftUserCheck() {
  314. LocalDateTime now = LocalDateTime.now();
  315. // 判断时间范围
  316. if (userLoginHours >= 8 && userLoginHours < 20) {
  317. int hour = now.getHour();
  318. if (hour >= 20 || hour < 8) {
  319. logoff();
  320. }
  321. } else {
  322. int hour = now.getHour();
  323. if (hour >= 8 && hour < 20) {
  324. logoff();
  325. }
  326. }
  327. }
  328. public static void resetScanB() {
  329. }
  330. //获取用户20位
  331. public static void getUser() {
  332. user20 = user_menu.getText().toString();
  333. String space_tmp1 = "";
  334. if(user20.length()<20) {
  335. for(int i=0;i<20-user20.length();i++) {
  336. space_tmp1 = space_tmp1 + " ";
  337. }
  338. }
  339. user20 = user20 + space_tmp1;
  340. }
  341. //获取barcode内容36位
  342. public static String getBarcode(String barcodeTmp) {
  343. String barcodeRet = barcodeTmp;
  344. if(barcodeTmp.equalsIgnoreCase("")) {
  345. return "";
  346. }else {
  347. if(barcodeTmp.length()<36) {
  348. String space = "";
  349. for(int i=0;i<36-barcodeTmp.length();i++) {
  350. space = space + " ";
  351. }
  352. barcodeRet = barcodeTmp + space;
  353. }
  354. }
  355. return barcodeRet;
  356. }
  357. public static void scanBarcode() {
  358. if(work_status == 1){
  359. JOptionPane.showMessageDialog(mesClientFrame,"工作中,勿扫码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  360. return;
  361. }
  362. String scanBarcodeTitle = "";
  363. switch(scan_type) {
  364. case 1:
  365. product_sn.setText("");
  366. scanBarcodeTitle = "请扫工件码";
  367. break;
  368. }
  369. //弹窗扫工件码
  370. String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
  371. if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
  372. scanBarcode = scanBarcode.trim(); //生产类型新增
  373. //获取用户
  374. getUser();
  375. //获取扫码内容36位
  376. String barcode36 = getBarcode(scanBarcode);//处理36为码
  377. //工位号
  378. String gw = "";
  379. switch(scan_type) {
  380. case 1:
  381. product_sn.setText(scanBarcode);
  382. break;
  383. }
  384. //刷新界面
  385. mesClientFrame.repaint();
  386. //生产类型新增
  387. String validateMsg = validateProductSnMessage(scanBarcode);
  388. if (validateMsg != null) {
  389. check_quality_result = false;
  390. work_status = 0;
  391. MesClient.finish_ok_bt.setEnabled(false);
  392. // MesClient.finish_ng_bt.setEnabled(false);
  393. MesClient.f_scan_data_bt_1.setEnabled(true);
  394. updateProductTypePanelEnabled(true);
  395. MesClient.setMenuStatus(validateMsg, -1);
  396. return;
  397. }
  398. updateProductTypePanelEnabled(false);
  399. if(!tcp_connect_flag) {
  400. JOptionPane.showMessageDialog(mesClientFrame,"设备未连接Mes服务器","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  401. return;
  402. }
  403. // 查询工件质量
  404. Boolean sendret = DataUtil.checkQuality(nettyClient,barcode36,user20);
  405. if(!sendret){
  406. JOptionPane.showMessageDialog(mesClientFrame,"消息发送失败,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  407. return;
  408. }
  409. }else {
  410. JOptionPane.showMessageDialog(mesClientFrame,"请扫工件码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  411. return;
  412. }
  413. }
  414. public static void logoff() {
  415. // welcomeWin.setVisible(true);
  416. mesClientFrame.setVisible(false);
  417. //退出程序 退出登录
  418. System.exit(0);
  419. nettyClient = null;
  420. // if(heartBeatTimer!=null) {
  421. // heartBeatTimer.cancel();
  422. // }
  423. // if(heartBeatIconTimer!=null) {
  424. // heartBeatIconTimer.cancel();
  425. // }
  426. tcp_connect_flag = false;
  427. connect_request_flag = false;
  428. }
  429. public MesClient() {
  430. setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
  431. setTitle("MES系统客户端:"+mes_gw + "- " + mes_gw_des);
  432. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  433. setBounds(0, 0, 1024, 768);
  434. JMenuBar menuBar = new JMenuBar();
  435. menuBar.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 26));
  436. setJMenuBar(menuBar);
  437. JMenu fileMenu = new JMenu("用户");
  438. fileMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/user.png")));
  439. fileMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  440. menuBar.add(fileMenu);
  441. JMenuItem exitMenuItem = new JMenuItem("退出");
  442. exitMenuItem.setIcon(new ImageIcon(MesClient.class.getResource("/bg/logoff.png")));
  443. exitMenuItem.setFont(new Font("微软雅黑", Font.PLAIN, 22));
  444. fileMenu.add(exitMenuItem);
  445. exitMenuItem.addMouseListener(new MouseAdapter() {
  446. @Override
  447. public void mousePressed(MouseEvent e) {//只能检测到mousePressed事件
  448. super.mouseClicked(e);
  449. //dispose();
  450. logoff();
  451. }
  452. });
  453. JMenu settingMenu = new JMenu("设置");
  454. //settingMenu.setVisible(false);
  455. settingMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")));
  456. settingMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  457. menuBar.add(settingMenu);
  458. JMenuItem resetTcpMenu = new JMenuItem("\u91CD\u8FDEMES");
  459. resetTcpMenu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
  460. resetTcpMenu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  461. resetTcpMenu.addMouseListener(new MouseAdapter() {
  462. @Override
  463. public void mousePressed(MouseEvent e) {
  464. super.mouseClicked(e);
  465. //重连mes
  466. nettyClient.future.channel().close();
  467. }
  468. });
  469. settingMenu.add(resetTcpMenu);
  470. JMenuItem resetTcpMenu_1 = new JMenuItem("刷新工件");
  471. resetTcpMenu_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
  472. resetTcpMenu_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  473. resetTcpMenu_1.addMouseListener(new MouseAdapter() {
  474. @Override
  475. public void mousePressed(MouseEvent e) {
  476. super.mouseClicked(e);
  477. resetScanA();
  478. }
  479. });
  480. settingMenu.add(resetTcpMenu_1);
  481. contentPane = new JPanel();
  482. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  483. setContentPane(contentPane);
  484. contentPane.setLayout(new BorderLayout(0, 0));
  485. JToolBar toolBar = new JToolBar();
  486. contentPane.add(toolBar, BorderLayout.NORTH);
  487. JLabel equipment_statu_label = new JLabel("状态:");
  488. equipment_statu_label.setHorizontalAlignment(SwingConstants.CENTER);
  489. equipment_statu_label.setForeground(Color.BLACK);
  490. equipment_statu_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  491. equipment_statu_label.setBackground(Color.LIGHT_GRAY);
  492. toolBar.add(equipment_statu_label);
  493. status_menu = new JButton("设备未连接MES服务器");
  494. if(tcp_connect_flag) {
  495. status_menu.setText("已连接MES服务器");
  496. status_menu.setForeground(Color.GREEN);
  497. }else {
  498. status_menu.setText("未连接MES服务器");
  499. status_menu.setForeground(Color.DARK_GRAY);
  500. }
  501. status_menu.addActionListener(new ActionListener() {
  502. public void actionPerformed(ActionEvent e) {
  503. }
  504. });
  505. status_menu.setForeground(Color.GREEN);
  506. status_menu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  507. status_menu.setBackground(Color.BLACK);
  508. toolBar.add(status_menu);
  509. JLabel space_1 = new JLabel(" ");
  510. toolBar.add(space_1);
  511. JLabel heart_beat_status_label = new JLabel("心跳:");
  512. heart_beat_status_label.setHorizontalAlignment(SwingConstants.CENTER);
  513. heart_beat_status_label.setForeground(Color.BLACK);
  514. heart_beat_status_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  515. heart_beat_status_label.setBackground(Color.LIGHT_GRAY);
  516. toolBar.add(heart_beat_status_label);
  517. heart_beat_menu = new JButton("2024-02-20 23:20:10");
  518. heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/green_dot.png")));
  519. heart_beat_menu.setForeground(Color.GREEN);
  520. heart_beat_menu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  521. heart_beat_menu.setBackground(Color.BLACK);
  522. toolBar.add(heart_beat_menu);
  523. JLabel space_2 = new JLabel(" ");
  524. toolBar.add(space_2);
  525. JLabel user_status_label = new JLabel("登录用户:");
  526. user_status_label.setHorizontalAlignment(SwingConstants.CENTER);
  527. user_status_label.setForeground(Color.BLACK);
  528. user_status_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  529. user_status_label.setBackground(Color.LIGHT_GRAY);
  530. toolBar.add(user_status_label);
  531. user_menu = new JButton("JinJuShi");
  532. user_menu.setForeground(Color.GREEN);
  533. user_menu.setFont(new Font("微软雅黑", Font.PLAIN, 22));
  534. user_menu.setBackground(Color.BLACK);
  535. toolBar.add(user_menu);
  536. JLabel space_3 = new JLabel(" ");
  537. toolBar.add(space_3);
  538. JLabel space_4 = new JLabel(" ");
  539. toolBar.add(space_4);
  540. //删除
  541. /* comboBox = new JComboBox();
  542. comboBox.setBackground(Color.WHITE);
  543. comboBox.setFont(new Font("微软雅黑", Font.PLAIN, 18));
  544. comboBox.setBounds(50, 10, 80, 21);
  545. comboBox.setMaximumSize(new Dimension(100, 40));
  546. comboBox.setMinimumSize(new Dimension(100, 30));
  547. comboBox.setPreferredSize(new Dimension(100, 30));
  548. comboBox.setModel(new DefaultComboBoxModel(new String[] {"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8"}));
  549. comboBox.setSelectedItem("COM4");
  550. toolBar.add(comboBox);
  551. // 串口发生改变
  552. comboBox.addActionListener(new ActionListener() {
  553. @Override
  554. public void actionPerformed(ActionEvent e) {
  555. if (bluetoothUtils != null) {
  556. bluetoothUtils.closeConnection();
  557. }
  558. MesClient.initComPort();
  559. }
  560. });*/
  561. tabbedPane = new JTabbedPane(JTabbedPane.TOP);
  562. tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
  563. tabbedPane.setMinimumSize(new Dimension(400, 50));
  564. tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
  565. contentPane.add(tabbedPane);
  566. //首页
  567. JPanel indexPanelA = new JPanel();
  568. indexScrollPaneA = new JScrollPane(indexPanelA);
  569. indexPanelA.setLayout(null);
  570. product_sn = new JTextField();
  571. product_sn.setHorizontalAlignment(SwingConstants.CENTER);
  572. product_sn.setEditable(false);
  573. product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
  574. product_sn.setBounds(81, 70, 602, 70);
  575. indexPanelA.add(product_sn);
  576. product_sn.setColumns(10);
  577. f_scan_data_bt_1 = new JButton("扫码");
  578. f_scan_data_bt_1.addActionListener(new ActionListener() {
  579. public void actionPerformed(ActionEvent e) {
  580. scan_type = 1;
  581. scanBarcode();
  582. }
  583. });
  584. f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
  585. f_scan_data_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 32));
  586. f_scan_data_bt_1.setBounds(693, 70, 198, 70);
  587. indexPanelA.add(f_scan_data_bt_1);
  588. // String[] hjtitles = new String[]{"焊机1","焊机2","焊机3"};
  589. // String[] hjvals = new String[]{"HJ001","HJ002","HJ003"};
  590. // mesRadioHj = new MesRadio(hjtitles,hjvals);
  591. // mesRadioHj.setSize(500,50);
  592. // mesRadioHj.setBounds(190,170,500,50);
  593. // indexPanelA.add(mesRadioHj);
  594. finish_ok_bt = new JButton("打包");
  595. finish_ok_bt.setEnabled(false);
  596. finish_ok_bt.addActionListener(new ActionListener() {
  597. public void actionPerformed(ActionEvent e ) {
  598. if(work_status == 1 && check_quality_result) {
  599. if ( batch_sn_text.getText().equals("")){
  600. JOptionPane.showMessageDialog(mesClientFrame,"请先获取包装码!","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  601. return;
  602. }
  603. if (weight_text.getText().isEmpty()) {
  604. JOptionPane.showMessageDialog(mesClientFrame,"请先称重!","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  605. return;
  606. }
  607. String wig = weight_text.getText();
  608. String is_js = is_js_btn_val;
  609. String result = HttpUtils.sendRequest(
  610. "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/dp350?" +
  611. "sn=" + product_sn.getText() + "&oprno=" + mes_gw + "&batchSn=" +
  612. batch_sn_text.getText() + "&weight=" + wig + "&isJs=" + is_js + "&ucode=system"+"&lineSn="+mes_line_sn);
  613. weight_text.setText("");
  614. if (result != null && !result.equals("") && !result.equals("false")) {
  615. JSONObject ret = JSON.parseObject(result);
  616. if (ret.get("result").equals("true")) {
  617. MesClient.setMenuStatus("结果提交成功,请扫下一件",0);
  618. resetScanA();
  619. // cjTimer.cancel();
  620. // MesClient.weight_text.setText("");
  621. }else {
  622. JOptionPane.showMessageDialog(mesClientFrame, "结果提交失败,"+ret.get("message")+"!", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
  623. MesClient.setMenuStatus("结果提交失败,请重试!",1);
  624. }
  625. }
  626. // String sn = getBarcode(product_sn.getText());
  627. // getUser();
  628. //
  629. // String qret = "OK";
  630. // Boolean sendret = DataUtil.sendQuality(nettyClient, sn, qret, user20);
  631. // if (!sendret) {
  632. // JOptionPane.showMessageDialog(mesClientFrame, "消息发送失败,请重试", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
  633. // return;
  634. // }
  635. }
  636. }
  637. });
  638. finish_ok_bt.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
  639. finish_ok_bt.setFont(new Font("微软雅黑", Font.PLAIN, 40));
  640. finish_ok_bt.setBounds(578, 405, 212, 92);
  641. indexPanelA.add(finish_ok_bt);
  642. //重量输入框(由串口定时器定时获取重量)
  643. weight_text = new JTextField();
  644. weight_text.setHorizontalAlignment(SwingConstants.CENTER);
  645. weight_text.setFont(new Font("微软雅黑", Font.PLAIN, 28));
  646. weight_text.setEditable(false);
  647. weight_text.setColumns(10);
  648. weight_text.setBounds(403, 300, 181, 70);
  649. weight_text.setText("");
  650. indexPanelA.add(weight_text);
  651. //包装码输入框
  652. batch_sn_text = new JTextField();
  653. batch_sn_text.setEditable(false);
  654. batch_sn_text.setHorizontalAlignment(SwingConstants.CENTER);
  655. batch_sn_text.setFont(new Font("微软雅黑", Font.PLAIN, 28));
  656. batch_sn_text.setColumns(10);
  657. batch_sn_text.setBounds(403, 192, 280, 70);
  658. indexPanelA.add(batch_sn_text);
  659. batch_sn_bt = new JButton("生成包装码");
  660. batch_sn_bt.setEnabled(false);
  661. batch_sn_bt.addActionListener(new ActionListener() {
  662. public void actionPerformed(ActionEvent e) {
  663. //生成包装码
  664. try {
  665. String result = HttpUtils.sendRequest("http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesBatchSn/createBatchSn?lineSn="+mes_line_sn);
  666. JSONObject ret = JSON.parseObject(result);
  667. String TF = ret.getString("result");
  668. if (Boolean.parseBoolean(TF)){
  669. String batchSn = ret.getJSONObject("data").getString("batchSn");
  670. //赋值 禁用生成按钮
  671. batch_sn_text.setText(batchSn);
  672. MesClient.batch_sn_bt.setEnabled(false);
  673. MesClient.finish_ok_bt.setEnabled(true);
  674. setMenuStatus("生成包装码成功",0);
  675. // 打印包装码标签(文字 + 二维码)
  676. PrintUtil.printLabel(batchSn);
  677. }else{
  678. JOptionPane.showMessageDialog(mesClientFrame,"生成包装码失败!,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  679. }
  680. } catch (Exception ex) {
  681. ex.printStackTrace();
  682. JOptionPane.showMessageDialog(mesClientFrame,"生成包装码失败!,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  683. }
  684. // if (result!= null&&!result.equals("")&&!result.equals("false")) {
  685. // JSONObject ret = JSON.parseObject(result);
  686. // if (ret != null && ret.containsKey("data")) {
  687. // String batchSn = ret.getJSONObject("data").getString("batchSn");
  688. // if (batchSn == null || batchSn.equals("")) { // 包装码为null,激活生成包装码按钮
  689. // JOptionPane.showMessageDialog(mesClientFrame,"生成包装码失败!,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  690. // }else{
  691. // //赋值 禁用生成按钮
  692. // batch_sn_text.setText(batchSn);
  693. // MesClient.batch_sn_bt.setEnabled(false);
  694. // }
  695. // }
  696. //
  697. // }else{
  698. // JOptionPane.showMessageDialog(mesClientFrame,"生成包装码失败!,请重试","提示窗口", JOptionPane.INFORMATION_MESSAGE);
  699. // }
  700. }
  701. });
  702. batch_sn_bt.setFont(new Font("微软雅黑", Font.PLAIN, 30));
  703. batch_sn_bt.setBounds(693, 192, 198, 70);
  704. indexPanelA.add(batch_sn_bt);
  705. //重量标签
  706. lblNewLabel = new JLabel("重量");
  707. lblNewLabel.setEnabled(false);
  708. lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
  709. lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 30));
  710. lblNewLabel.setBounds(238, 300, 117, 70);
  711. indexPanelA.add(lblNewLabel);
  712. lblNewLabel_1 = new JLabel("包装码");
  713. lblNewLabel_1.setEnabled(false);
  714. lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
  715. lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 30));
  716. lblNewLabel_1.setBounds(238, 192, 117, 70);
  717. indexPanelA.add(lblNewLabel_1);
  718. is_js_btn = new JButton("最后一台");
  719. is_js_btn.addActionListener(new ActionListener() {
  720. public void actionPerformed(ActionEvent e) {
  721. // if (is_js_btn.getText().equals("结束")){
  722. // is_js_btn.setText("开始");
  723. // }else if (is_js_btn.getText().equals("开始")){
  724. // is_js_btn.setText("结束");
  725. // }
  726. if (is_js_btn_val.equals("2")){
  727. is_js_btn.setBackground(null);
  728. is_js_btn_val = "1";
  729. }else{
  730. // is_js_btn.setText("结束");
  731. is_js_btn.setBackground(Color.GREEN);
  732. is_js_btn_val = "2";
  733. }
  734. }
  735. });
  736. is_js_btn.setFont(new Font("微软雅黑", Font.PLAIN, 32));
  737. is_js_btn.setBounds(693, 300, 198, 70);
  738. indexPanelA.add(is_js_btn);
  739. //称重按钮,触发称重操作
  740. finish_ok_bt_1 = new JButton("称重");
  741. finish_ok_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/ok_bg.png")));
  742. finish_ok_bt_1.addActionListener(new ActionListener() {
  743. public void actionPerformed(ActionEvent e) {
  744. if (!com_connect_flag || serialPortUtils == null) {
  745. JOptionPane.showMessageDialog(mesClientFrame, "称重串口未连接", "提示窗口", JOptionPane.INFORMATION_MESSAGE);
  746. return;
  747. }
  748. new Thread(() -> serialPortUtils.requestWeight()).start();
  749. }
  750. });
  751. finish_ok_bt_1.setFont(new Font("微软雅黑", Font.PLAIN, 40));
  752. finish_ok_bt_1.setEnabled(true);
  753. finish_ok_bt_1.setBounds(207, 405, 212, 92);
  754. indexPanelA.add(finish_ok_bt_1);
  755. tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
  756. tabbedPane.setEnabledAt(0, true);
  757. // searchScrollPane = new JScrollPane((Component) null);
  758. indexPanelC = new JPanel(new BorderLayout());
  759. if (PRODUCT_TYPE_SWITCH_ENABLED) {
  760. //新增的面板
  761. JPanel indexPanelProductType = new JPanel();
  762. indexPanelProductType.setLayout(null);
  763. JScrollPane productTypeScrollPane = new JScrollPane(indexPanelProductType);
  764. JLabel productTypeTitle = new JLabel("生产类型设置");
  765. productTypeTitle.setFont(new Font("微软雅黑", Font.BOLD, 28));
  766. productTypeTitle.setForeground(new Color(64, 64, 64));
  767. productTypeTitle.setHorizontalAlignment(SwingConstants.CENTER);
  768. productTypeTitle.setBounds(81, 80, 810, 50);
  769. indexPanelProductType.add(productTypeTitle);
  770. JLabel productTypeHint = new JLabel("请选择当前生产的工件类型,切换后将保存到本地并用于扫码校验");
  771. productTypeHint.setFont(new Font("微软雅黑", Font.PLAIN, 20));
  772. productTypeHint.setForeground(new Color(140, 140, 140));
  773. productTypeHint.setHorizontalAlignment(SwingConstants.CENTER);
  774. productTypeHint.setBounds(81, 140, 810, 40);
  775. indexPanelProductType.add(productTypeHint);
  776. productTypePanel = new ProductTypePanel(PRODUCT_TYPE_SWITCH_PASSWORD);
  777. productTypePanel.setBounds(276, 210, 420, 72);
  778. productTypePanel.setOnChangeListener(() -> {
  779. if (work_status == 0) {
  780. saveProductTypeToDb();
  781. if (PRODUCT_TYPE_SWITCH_ENABLED) {
  782. setMenuStatus("当前生产类型:" + getProductTypeName() + ",请扫工件码",0);
  783. } else {
  784. setMenuStatus("请扫工件码",0);
  785. }
  786. }
  787. refreshProductTypeCurrentLabel();
  788. });
  789. indexPanelProductType.add(productTypePanel);
  790. productTypeCurrentLabel = new JLabel();
  791. productTypeCurrentLabel.setFont(new Font("微软雅黑", Font.PLAIN, 22));
  792. productTypeCurrentLabel.setForeground(new Color(64, 64, 64));
  793. productTypeCurrentLabel.setHorizontalAlignment(SwingConstants.CENTER);
  794. productTypeCurrentLabel.setBounds(81, 310, 810, 40);
  795. refreshProductTypeCurrentLabel();
  796. indexPanelProductType.add(productTypeCurrentLabel);
  797. tabbedPane.addTab("生产类型", new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")), productTypeScrollPane, null);
  798. }
  799. tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexPanelC, null);
  800. indexPanelB = new JPanel();
  801. searchScrollPane = new JScrollPane(indexPanelB);
  802. indexPanelB.setLayout(null);
  803. tabbedPane.addTab("工作记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPane, null);
  804. tabbedPane.addChangeListener(new ChangeListener() {
  805. @Override
  806. public void stateChanged(ChangeEvent e) {
  807. JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
  808. int selectedIndex = tabbedPane.getSelectedIndex();
  809. System.out.println("selectedIndex:"+selectedIndex);
  810. if(selectedIndex == 1){
  811. }
  812. }
  813. });
  814. }
  815. private static String validateProductSnMessage(String sn) {
  816. if (sn == null || sn.isEmpty()) {
  817. return "工件码为空,请重试";
  818. }
  819. if (sn.length() != PRODUCT_SN_LENGTH) {
  820. return "工件码长度须为32位,当前" + sn.length() + "位";
  821. }
  822. if (!PRODUCT_TYPE_SWITCH_ENABLED) {
  823. return null;
  824. }
  825. String prefix = getProductSnPrefix();
  826. if (!sn.startsWith(prefix)) {
  827. return "工件码前缀与当前类型(" + getProductTypeName() + ")不匹配,当前工件码为" + getProductTypeNameBySn(sn);
  828. }
  829. return null;
  830. }
  831. private static void updateProductTypePanelEnabled(boolean enabled) {
  832. if (productTypePanel != null) {
  833. productTypePanel.setEnabled(enabled);
  834. }
  835. }
  836. public static void loadProductTypeFromDb() {
  837. if (productTypePanel == null) {
  838. return;
  839. }
  840. String savedType = JdbcUtils.getClientConfig(
  841. JdbcUtils.getProductTypeConfigKey(mes_gw),
  842. PRODUCT_TYPE_ZJ
  843. );
  844. if (PRODUCT_TYPE_SJ.equals(savedType)) {
  845. productTypePanel.setResult(PRODUCT_TYPE_SJ);
  846. } else {
  847. productTypePanel.setResult(PRODUCT_TYPE_ZJ);
  848. }
  849. refreshProductTypeCurrentLabel();
  850. }
  851. public static void refreshProductTypeCurrentLabel() {
  852. if (productTypeCurrentLabel != null) {
  853. productTypeCurrentLabel.setText("当前选择:" + getProductTypeName() + "(前缀 " + getProductSnPrefix() + ")");
  854. }
  855. }
  856. public static void saveProductTypeToDb() {
  857. if (productTypePanel == null) {
  858. return;
  859. }
  860. JdbcUtils.saveClientConfig(
  861. JdbcUtils.getProductTypeConfigKey(mes_gw),
  862. productTypePanel.getResult()
  863. );
  864. }
  865. public static String getProductSnPrefix() {
  866. if (productTypePanel != null && PRODUCT_TYPE_SJ.equals(productTypePanel.getResult())) {
  867. return PREFIX_SJ;
  868. }
  869. return PREFIX_ZJ;
  870. }
  871. public static String getProductTypeName() {
  872. if (productTypePanel != null) {
  873. return productTypePanel.getTypeName();
  874. }
  875. return "智界";
  876. }
  877. private static String getProductTypeNameBySn(String sn) {
  878. if (sn.startsWith(PREFIX_SJ)) {
  879. return "尚界";
  880. }
  881. if (sn.startsWith(PREFIX_ZJ)) {
  882. return "智界";
  883. }
  884. return "未知";
  885. }
  886. public static void setMenuStatus(String msg,int error){
  887. if(error == 0){
  888. MesClient.status_menu.setForeground(Color.GREEN);
  889. }else{
  890. MesClient.status_menu.setForeground(Color.RED);
  891. }
  892. MesClient.status_menu.setText(msg);
  893. }
  894. public static void getMaterailData(){
  895. JSONObject retObj = DataUtil.getBindMaterail();
  896. if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
  897. java.util.List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
  898. int i = 0;
  899. rowData = new Object[arrs.size()][7];
  900. for (BindMaterialResp bindMaterialResp:arrs){
  901. rowData[i][0] = bindMaterialResp.getMaterialTitle();
  902. rowData[i][1] = bindMaterialResp.getBatchSn();
  903. rowData[i][2] = bindMaterialResp.getLastTimes();
  904. rowData[i][3] = "";
  905. rowData[i][4] = bindMaterialResp.getCraft();
  906. rowData[i][5] = bindMaterialResp.getMaterialId();
  907. rowData[i][6] = bindMaterialResp.getType();
  908. i++;
  909. }
  910. bindBatchPanel();
  911. }
  912. }
  913. public static void updateMaterailData(){
  914. JSONObject retObj = DataUtil.getBindMaterail();
  915. if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
  916. List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
  917. int i = 0;
  918. for (BindMaterialResp bindMaterialResp:arrs){
  919. rowData[i][0] = bindMaterialResp.getMaterialTitle();
  920. rowData[i][1] = bindMaterialResp.getBatchSn();
  921. rowData[i][2] = bindMaterialResp.getLastTimes();
  922. rowData[i][3] = "";
  923. rowData[i][4] = bindMaterialResp.getCraft();
  924. rowData[i][5] = bindMaterialResp.getMaterialId();
  925. rowData[i][6] = bindMaterialResp.getType();
  926. i++;
  927. }
  928. MesClient.table.repaint();
  929. }
  930. }
  931. // 绑定物料批次码
  932. public static void scanBatchSn(BindMaterialResp bindMaterialResp) {
  933. //弹窗扫工件码
  934. String scanBarcodeTitle = "请扫物料:"+bindMaterialResp.getMaterialTitle();
  935. String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
  936. if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
  937. JSONObject retObj = DataUtil.saveBindMaterail(scanBarcode,bindMaterialResp.getCraft(),bindMaterialResp.getMaterialId(),bindMaterialResp.getType());
  938. if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
  939. MesClient.setMenuStatus("扫物料:"+bindMaterialResp.getMaterialTitle()+"成功",0);
  940. updateMaterailData();
  941. }else{
  942. if(retObj.get("result")==null){
  943. MesClient.setMenuStatus("请求失败,请重试",-1);
  944. }else{
  945. if(retObj.get("result").toString().equalsIgnoreCase("false")){
  946. MesClient.setMenuStatus(retObj.getString("message"),-1);
  947. }
  948. }
  949. }
  950. }
  951. }
  952. public static void bindBatchPanel(){
  953. JPanel indexPanelBB = new JPanel();
  954. JPanel panel = new JPanel();
  955. panel.setBounds(0, 0, 990, 550);
  956. // panel.setBounds(81, 50, 810, 479);
  957. indexPanelBB.add(panel);
  958. panel.setLayout(new GridLayout(0, 1, 0, 0));
  959. table = new JTable(rowData, columnNames){
  960. public boolean isCellEditable(int row, int column) {
  961. if(column == 3){
  962. return true;
  963. }
  964. return false;
  965. }
  966. };
  967. table.setRowHeight(40);
  968. table.setEnabled(true);
  969. table.setFont(new Font("微软雅黑", Font.PLAIN, 14));
  970. table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRendererButton());
  971. table.getColumnModel().getColumn(3).setCellEditor(new TableCellEditorButton());
  972. JScrollPane scrollPane = new JScrollPane(table);
  973. panel.add(scrollPane);
  974. JScrollPane indexScrollPaneB = new JScrollPane(indexPanelBB);
  975. indexPanelBB.setLayout(null);
  976. tabbedPane.addTab("绑定物料", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexScrollPaneB, null);
  977. }
  978. }