| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127 |
- package com.mes.ui;
- import com.alibaba.fastjson2.JSONObject;
- import com.mes.component.MesRadio;
- import com.mes.component.MesWebView;
- import com.mes.netty.NettyClient;
- import com.mes.util.*;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import javax.print.PrintService;
- import javax.print.PrintServiceLookup;
- import javax.swing.*;
- import javax.swing.border.EmptyBorder;
- import javax.swing.event.ChangeEvent;
- import javax.swing.event.ChangeListener;
- import javax.swing.table.DefaultTableCellRenderer;
- import javax.swing.table.DefaultTableModel;
- import javax.swing.table.TableColumn;
- import java.awt.*;
- import java.awt.event.*;
- 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 {
- 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 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 searchScrollPaneD;
- public static JScrollPane searchScrollPaneDj;
- public static JScrollPane searchScrollPaneTask;
- 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 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 boolean mes_enable = true; // true=MES开启
- public static JFrame welcomeWin;
- public static JPanel indexPanelB;
- public static MesWebView jfxPanel = null;
- public static JPanel indexPanelC;
- public static JPanel indexPanelD;
- public static JPanel indexPanelCheck; // 开班点检页签面板(独立于「记录查询」)
- public static JPanel panelCheck; // 点检 WebView 容器
- public static JLabel labCheckTitle; // 显示当前点检工位号
- public static MesWebView jfxPanel2 = null;
- public static MesWebView jfxPanel3 = null;
- public static MesRadio mesRadioHj;
- public static JLabel curTaskName;
- public static JTable table;
- public static Object[] columnNames = {"工件码", "测试日期", "压力", "泄露值","结果"};
- // public static Object[][] rowData = null;
- // public static Object[][] rowData = {
- // {"151245P00001213100100024120700111","2024-12-09 12:30:30","60","60","60","200kPa","3ml/min","OK"},
- // {"151245P00001213100100024120700112","2024-12-09 13:30:30","60","60","60","-200kPa","3ml/min","OK"},
- // {"151245P00001213100100024120700113","2024-12-09 14:30:30","60","60","60","200kPa","3ml/min","OK"},
- // {"151245P00001213100100024120700113","2024-12-09 14:30:30","60","60","60","200kPa","3ml/min","OK"},
- // };
- public static Object[][] rowData = new Object[12][5];
- public static JLabel pageLabel;
- public static int pageNo=1 ; // 当前页
- public static int totalPages; // 总页数
- public static JTextField textField;//搜索框
- public static JTable table2;
- public static Object[] columnNames2 = { "任务名称" };
- public static Object[][] rowData2 = {{""},{""},{""}};
- public static Integer tjFlag = 0;
- public static String tjFlagText2 = "设备运行中";
- public static String tjFlagText3 = "设备运行结束";
- public static String tjFlagText4 = "结果已上传MES,请扫下一件";
- public static String tjFlagText5 = "已扫码,等待设备运行";
- public static String tjFlagTextErr = "结果上传MES失败,请重试";
- public static SerialPortUtils serialPortUtils;
- public static JTextField printSn2;
- public static JTextField printTitle2;
- public static JTextField printValue2;
- public static JButton printBtn2;
- public static ConfigParam configParam;
- public static Integer isConfigEdit = 0;
- public static Integer mesStartFlag = 0;
- public static List<TaskParam> taskParamList = new ArrayList<>();
- public static TaskParam curTaskParam = null;
- public static void main(String[] args) {
- if (LockUtil.getInstance().isAppActive() == true){
- // JOptionPane.showMessageDialog(null, "已有一个程序在运行,程序退出");
- return;
- }
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- try{
- //读文件配置
- readProperty();
- // 显示界面
- mesClientFrame = new MesClient();
- mesClientFrame.setVisible(false);
- JdbcUtils.getConn();
- welcomeWin = new LoginFarme();
- welcomeWin.setVisible(true);
- formatConfigEdit(false);
- formatConfigData();
- getTask();
- serialPortUtils=new SerialPortUtils(configParam.getSerialPort(),configParam.getOprno(),configParam.getOprnoTitle(),configParam.getDevice());
- // startDateTimer();
- textFocus();
- // resetScanA();
- }catch (Exception e){
- log.error("启动初始化异常", e);
- }
- }
- });
- }
- public static Timer cjTimerText;
- public static void textFocus() {
- if(cjTimerText!=null) {
- cjTimerText.cancel();
- }
- cjTimerText = new Timer();
- cjTimerText.schedule(new TimerTask() {
- public void run() {
- if(work_status == 0){
- product_sn.requestFocusInWindow();
- }
- }
- }, 1000,1000);
- }
- public static java.util.Timer dateBeatTimer;
- public static void startDateTimer() {
- if (dateBeatTimer != null) {
- dateBeatTimer.cancel();
- }
- dateBeatTimer = new java.util.Timer();
- dateBeatTimer.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.setForeground(Color.GREEN);
- heart_beat_menu.repaint();
- }
- }, 100, 1* 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_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);
- }
- // 初始化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() {
- if(nettyClient!=null&&tcp_connect_flag) {
- //log.info("发送心跳报文");
- DataUtil.heartBeat(nettyClient,mes_gw);
- heart_beat_menu.setText(DateLocalUtils.getCurrentTime());
- }
- }
- }, 100,mes_heart_beat_cycle*1000);
- //心跳显示图标
- if(heartBeatIconTimer!=null) {
- heartBeatIconTimer.cancel();
- }
- heartBeatIconTimer = new Timer();
- heartBeatIconTimer.schedule(new TimerTask() {
- public void run() {
- 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){
- log.info("TCP已断开");
- //TCP重新同步连接
- if(!connect_request_flag) {
- //log.info("TCP重新同步连接");
- //设置TCP请求状态,只重新同步连接一次
- connect_request_flag = true;
- DataUtil.synrTcp(nettyClient,mes_gw);
- }
- }
- }
- }
- }, 100,mes_heart_icon_cycle*1000);
- }
- //设置tcp连接状态显示
- public static void setTcpStatus() {
- if(tcp_connect_flag) {
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- heart_beat_menu.repaint();
- }else {
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/grey_dot.png")));
- heart_beat_menu.repaint();
- }
- }
- 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("");
- product_sn.setEditable(true);
- tjFlag = 0;
- mesStartFlag = 0;
- curTaskName.setText("");
- // f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
- // f_scan_data_bt_1.setText("扫码");
- // MesClient.f_scan_data_bt_1.setEnabled(true);
- MesClient.setMenuStatus("请扫工件码",0);
- // MesClient.result.setText("等待结果");
- // MesClient.result.setForeground(Color.GRAY);
- }
- public static int userLoginHours;//用户登录所处小时
- public static JTextField param1;
- public static JTextField param2;
- public static JTextField param3;
- public static JTextField param4;
- public static JLabel result;
- public static JTextField programNo;
- public static JTextField serialPort;
- public static JTextField baudRate;
- public static JTextField printName;
- public static JTextField labelName;
- public static JTextField labelx;
- public static JTextField labely;
- public static JTextField labelLineSpace;
- public static JTextField labelFont;
- public static JTextField stationNo;
- public static JComboBox stopBit;
- public static JComboBox checkBit;
- public static JComboBox dataBits;
- public static JComboBox printLabel;
- public static JComboBox leakage;
- public static JComboBox startMode;
- public static JButton saveBtn;
- public static JTextField productSnLength;
- public static JTextField productSnPre;
- public static JComboBox device;
- public static JTextField ngTime;
- public static JTextField ngNumber;
- public static JTextField ngUpgradeTime;
- public static JTextField oprno;
- public static JTextField oprnoTitle;
- public static JTextField lineSn;
- public static JLabel taskName;
- public static JTextField taskMaxNumA;
- public static JTextField taskMaxFoutA;
- public static JTextField taskMinFoutA;
- public static JTextField taskMaxSoutA;
- public static JTextField taskMinSoutA;
- public static JTextField taskMaxNumB;
- public static JTextField taskMaxFoutB;
- public static JTextField taskMinFoutB;
- public static JTextField taskMaxSoutB;
- public static JTextField taskMinSoutB;
- public static JComboBox taskLeakage;
- public static JTextField barcodeSpec;
- public static JTextField barcodeSpecStart;
- public static JTextField barcodeLength;
- public static void formatConfigEdit(Boolean ret){
- programNo.setEnabled(ret);
- serialPort.setEnabled(ret);
- startMode.setEnabled(ret);
- baudRate.setEnabled(ret);
- printName.setEnabled(ret);
- labelName.setEnabled(ret);
- labelx.setEnabled(ret);
- labely.setEnabled(ret);
- labelLineSpace.setEnabled(ret);
- labelFont.setEnabled(ret);
- stationNo.setEnabled(ret);
- stopBit.setEnabled(ret);
- checkBit.setEnabled(ret);
- dataBits.setEnabled(ret);
- printLabel.setEnabled(ret);
- leakage.setEnabled(ret);
- productSnPre.setEnabled(ret);
- productSnLength.setEnabled(ret);
- device.setEnabled(ret);
- // ngTime.setEnabled(ret);
- // ngNumber.setEnabled(ret);
- // ngUpgradeTime.setEnabled(ret);
- oprno.setEnabled(ret);
- oprnoTitle.setEnabled(ret);
- lineSn.setEnabled(ret);
- }
- public static void formatConfigData(){
- MesClient.configParam = JdbcUtils.getConfig();
- log.info(configParam.toString());
- if(configParam.getProgramNo() == null||configParam.getProgramNo().isEmpty()){
- configParam.setProgramNo("1");
- }
- programNo.setText(configParam.getProgramNo());
- if(configParam.getStartMode() == null||configParam.getStartMode().isEmpty()){
- configParam.setStartMode("手动启动");
- }
- startMode.setSelectedItem(configParam.getStartMode());
- if(configParam.getSerialPort() == null||configParam.getSerialPort().isEmpty()){
- configParam.setSerialPort("COM1");
- }
- serialPort.setText(configParam.getSerialPort());
- if(configParam.getBaudRate() == null||configParam.getBaudRate().isEmpty()){
- configParam.setBaudRate("38400");
- }
- baudRate.setText(configParam.getBaudRate());
- if(configParam.getDataBits() == null||configParam.getDataBits().isEmpty()){
- configParam.setDataBits("8");
- }
- dataBits.setSelectedItem(configParam.getDataBits());
- if(configParam.getCheckBit() == null||configParam.getCheckBit().isEmpty()){
- configParam.setCheckBit("NONE");
- }
- checkBit.setSelectedItem(configParam.getCheckBit());
- if(configParam.getStopBit() == null||configParam.getStopBit().isEmpty()){
- configParam.setStopBit("1");
- }
- stopBit.setSelectedItem(configParam.getStopBit());
- if(configParam.getLeakage() == null||configParam.getLeakage().isEmpty()){
- configParam.setLeakage("压降");
- }
- leakage.setSelectedItem(configParam.getLeakage());
- if(configParam.getPrintLabel() == null||configParam.getPrintLabel().isEmpty()){
- configParam.setPrintLabel("否");
- }
- printLabel.setSelectedItem(configParam.getPrintLabel());
- if(configParam.getPrintName() == null||configParam.getPrintName().isEmpty()){
- configParam.setPrintName("");
- }
- printName.setText(configParam.getPrintName());
- if(configParam.getLabelName() == null||configParam.getLabelName().isEmpty()){
- configParam.setLabelName("");
- }
- labelName.setText(configParam.getLabelName());
- if(configParam.getLabelx() == null||configParam.getLabelx().isEmpty()){
- configParam.setLabelx("30");
- }
- labelx.setText(configParam.getLabelx());
- if(configParam.getLabely() == null||configParam.getLabely().isEmpty()){
- configParam.setLabely("30");
- }
- labely.setText(configParam.getLabely());
- if(configParam.getLabelLineSpace() == null||configParam.getLabelLineSpace().isEmpty()){
- configParam.setLabelLineSpace("20");
- }
- labelLineSpace.setText(configParam.getLabelLineSpace());
- if(configParam.getLabelFont() == null||configParam.getLabelFont().isEmpty()){
- configParam.setLabelFont("10");
- }
- labelFont.setText(configParam.getLabelFont());
- if(configParam.getStationNo() == null||configParam.getStationNo().isEmpty()){
- configParam.setStationNo("1");
- }
- stationNo.setText(configParam.getStationNo());
- if(configParam.getProductSnPre() == null||configParam.getProductSnPre().isEmpty()){
- configParam.setProductSnPre("");
- }
- productSnPre.setText(configParam.getProductSnPre());
- if(configParam.getProductSnLength() == null||configParam.getProductSnLength().isEmpty()){
- configParam.setProductSnLength("");
- }
- productSnLength.setText(configParam.getProductSnLength());
- if(configParam.getDevice() == null||configParam.getDevice().isEmpty()){
- configParam.setDevice("innomatec");
- }
- device.setSelectedItem(configParam.getDevice());
- // if(configParam.getNgTime() == null||configParam.getNgTime().isEmpty()){
- // configParam.setNgTime("");
- // }
- // ngTime.setText(configParam.getNgTime());
- //
- // if(configParam.getNgNumber() == null||configParam.getNgNumber().isEmpty()){
- // configParam.setNgNumber("");
- // }
- // ngNumber.setText(configParam.getNgNumber());
- //
- // if(configParam.getNgUpgradeTime() == null||configParam.getNgUpgradeTime().isEmpty()){
- // configParam.setNgUpgradeTime("");
- // }
- // ngUpgradeTime.setText(configParam.getNgUpgradeTime());
- if(configParam.getOprno() == null||configParam.getOprno().isEmpty()){
- configParam.setOprno("");
- }
- oprno.setText(configParam.getOprno());
- if(configParam.getOprnoTitle() == null||configParam.getOprnoTitle().isEmpty()){
- configParam.setOprnoTitle("");
- }
- oprnoTitle.setText(configParam.getOprnoTitle());
- if(configParam.getLineSn() == null||configParam.getLineSn().isEmpty()){
- configParam.setLineSn("XT");
- }
- lineSn.setText(configParam.getLineSn());
- if(!oprnoTitle.getText().isEmpty()){
- String stationInfo = oprno.getText() +"-"+ oprnoTitle.getText();
- welcomeWin.setTitle("气密检测客户端--"+stationInfo);
- mesClientFrame.setTitle("气密检测客户端--"+stationInfo);
- }
- }
- //换班用户信息检查
- 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) {
- MesClient.serialPortUtils.start();
- return;
- }
- }
- public static void scanBarcode2() {
- if(work_status == 1){
- // MesClient.serialPortUtils.sendData("START");
- return;
- }
- String scanBarcode = product_sn.getText().trim();
- //刷新界面
- mesClientFrame.repaint();
- if(scanBarcode.isEmpty()){
- MesClient.setMenuStatus("工件码不能为空",1);
- product_sn.setText("");
- return;
- }
- // // 验证工件码前缀
- // if(MesClient.configParam.getProductSnPre() != null && !MesClient.configParam.getProductSnPre().trim().isEmpty()) {
- // int preLen = MesClient.configParam.getProductSnPre().trim().length();
- // if(preLen > scanBarcode.length()){
- // MesClient.setMenuStatus("工件码前缀不符合要求",-1);
- // product_sn.setText("");
- // return;
- // }else{
- // String pre = scanBarcode.substring(0,preLen);
- // if(!pre.equals(MesClient.configParam.getProductSnPre().trim())){
- // MesClient.setMenuStatus("工件码前缀不符合要求",-1);
- // product_sn.setText("");
- // return;
- // }
- // }
- // }
- //
- // //验证工件码长度
- // int snLen = MesClient.configParam.getProductSnLength() != null && MesClient.configParam.getProductSnLength().trim().isEmpty() ? 0 : Integer.valueOf(MesClient.configParam.getProductSnLength());
- // if(snLen > 0 && snLen != scanBarcode.length()) {
- // MesClient.setMenuStatus("工件码长度不符合要求",-1);
- // product_sn.setText("");
- // return;
- // }
- // // 验证NG
- // int isCheck = JdbcUtils.checkSnTimer(scanBarcode,configParam);
- // System.err.println("isCheck:" + isCheck);
- // if(isCheck == 1){
- // int ngTime = Integer.valueOf(configParam.getNgTime());
- // MesClient.setMenuStatus("工件码测试NG必须间隔"+ngTime+"分钟",-1);
- // product_sn.setText("");
- // return;
- // } else if(isCheck == 2){
- // int ngUpgradeTime = Integer.valueOf(configParam.getNgUpgradeTime());
- // int ngNumber = Integer.valueOf(configParam.getNgNumber());
- // MesClient.setMenuStatus("工件码测试NG"+ngNumber+"次,必须间隔"+ngUpgradeTime+"分钟",-1);
- // product_sn.setText("");
- // return;
- // }
- if(checkProductSn(scanBarcode.trim())){
- serialPortUtils.changeProgram(); // 切换程序
- if(MesClient.mes_enable){
- getUser();
- // 查询工件质量
- Boolean sendret = DataUtil.checkQuality(nettyClient,scanBarcode,user20);
- if(!sendret){
- MesClient.setMenuStatus("消息发送失败,请重试",-1);
- return;
- }
- }else{
- work_status = 1;
- MesClient.tjFlag = 1;
- MesClient.setMenuStatus("扫码成功,等待测试",0);
- product_sn.setEditable(false);
- if(MesClient.configParam.getStartMode().equals("自动启动")){
- MesClient.serialPortUtils.start();
- }
- MesClient.result.setText("等待结果");
- MesClient.result.setForeground(Color.GRAY);
- }
- }
- // f_scan_data_bt_1.setIcon(null);
- // f_scan_data_bt_1.setText("启动");
- }
- public static void scanBarcodeOld() {
- if(work_status == 1){
- // MesClient.serialPortUtils.sendData("START");
- return;
- }
- String scanBarcodeTitle = "";
- switch(scan_type) {
- case 1:
- product_sn.setText("");
- scanBarcodeTitle = "请扫工件码";
- break;
- }
- //弹窗扫工件码
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
- // 验证工件码前缀
- if(MesClient.configParam.getProductSnPre() != null && !MesClient.configParam.getProductSnPre().trim().isEmpty()) {
- int preLen = MesClient.configParam.getProductSnPre().trim().length();
- if(preLen > scanBarcode.length()){
- MesClient.setMenuStatus("工件码前缀不符合要求",-1);
- return;
- }else{
- String pre = scanBarcode.substring(0,preLen);
- if(!pre.equals(MesClient.configParam.getProductSnPre().trim())){
- MesClient.setMenuStatus("工件码前缀不符合要求",-1);
- return;
- }
- }
- }
- //验证工件码长度
- int snLen = MesClient.configParam.getProductSnLength() != null && MesClient.configParam.getProductSnLength().trim().isEmpty() ? 0 : Integer.valueOf(MesClient.configParam.getProductSnLength());
- if(snLen > 0 && snLen != scanBarcode.length()) {
- MesClient.setMenuStatus("工件码长度不符合要求",-1);
- return;
- }
- //获取用户
- getUser();
- //获取扫码内容36位
- String barcode36 = getBarcode(scanBarcode);//处理36为码
- //工位号
- String gw = "";
- switch(scan_type) {
- case 1:
- product_sn.setText(scanBarcode);
- break;
- }
- //刷新界面
- mesClientFrame.repaint();
- work_status = 1;
- // f_scan_data_bt_1.setEnabled(false);
- MesClient.tjFlag = 1;
- MesClient.setMenuStatus("扫码成功,等待测试",0);
- if(MesClient.configParam.getStartMode().equals("自动启动")){
- MesClient.serialPortUtils.start();
- }
- f_scan_data_bt_1.setIcon(null);
- f_scan_data_bt_1.setText("启动");
- }else {
- JOptionPane.showMessageDialog(mesClientFrame,"请扫工件码","提示窗口", JOptionPane.INFORMATION_MESSAGE);
- return;
- }
- }
- public static void logoff() {
- // welcomeWin.setVisible(true);
- mesClientFrame.setVisible(false);
- //退出程序 退出登录
- System.exit(0);
- 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("气密检测客户端");
- 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("重连MES");
- 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);
- 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) {
- MesClient.setMenuStatus("已连接MES服务器",0);
- status_menu.setForeground(Color.GREEN);
- }else {
- MesClient.setMenuStatus("请扫工件码",-1);
- 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("");
- heart_beat_menu.setIcon(new ImageIcon(MesClient.class.getResource("/bg/green_dot.png")));
- heart_beat_menu.setForeground(Color.GREEN);
- heart_beat_menu.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- heart_beat_menu.setBackground(Color.BLACK);
- toolBar.add(heart_beat_menu);
- JLabel space_2 = new JLabel(" ");
- toolBar.add(space_2);
- JLabel user_status_label = new JLabel("登录用户:");
- user_status_label.setHorizontalAlignment(SwingConstants.CENTER);
- user_status_label.setForeground(Color.BLACK);
- user_status_label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- user_status_label.setBackground(Color.LIGHT_GRAY);
- toolBar.add(user_status_label);
- user_menu = new JButton("");
- user_menu.setForeground(Color.GREEN);
- user_menu.setFont(new Font("微软雅黑", Font.PLAIN, 22));
- user_menu.setBackground(Color.BLACK);
- toolBar.add(user_menu);
- JLabel space_3 = new JLabel(" ");
- toolBar.add(space_3);
- JLabel space_4 = new JLabel(" ");
- toolBar.add(space_4);
- tabbedPane = new JTabbedPane(JTabbedPane.TOP);
- tabbedPane.setMinimumSize(new Dimension(400, 50));
- tabbedPane.setFont(new Font("宋体", Font.BOLD, 22));
- contentPane.add(tabbedPane);
- //首页
- JPanel indexPanelA = new JPanel();
- indexScrollPaneA = new JScrollPane(indexPanelA);
- indexPanelA.setLayout(null);
- curTaskName = new JLabel("当前任务:");
- curTaskName.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- curTaskName.setHorizontalAlignment(SwingConstants.CENTER);
- curTaskName.setBounds(81, 10, 800, 40);
- indexPanelA.add(curTaskName);
- product_sn = new JTextField();
- product_sn.setHorizontalAlignment(SwingConstants.LEFT);
- product_sn.setEditable(true);
- product_sn.setFont(new Font("微软雅黑", Font.PLAIN, 28));
- product_sn.setBounds(81, 70, 602, 70);
- indexPanelA.add(product_sn);
- product_sn.setColumns(10);
- product_sn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- scan_type = 1;
- scanBarcode2();
- }
- });
- // f_scan_data_bt_1 = new JButton("扫码");
- 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);
-
- JLabel lblNewLabel = new JLabel("测试压");
- lblNewLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel.setBounds(137, 210, 140, 40);
- indexPanelA.add(lblNewLabel);
-
- param1 = new JTextField();
- param1.setEditable(false);
- param1.setBounds(287, 210, 150, 40);
- indexPanelA.add(param1);
- param1.setColumns(10);
-
- JLabel lblNewLabel_1 = new JLabel("泄露值");
- lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- lblNewLabel_1.setBounds(447, 210, 140, 40);
- indexPanelA.add(lblNewLabel_1);
-
- param2 = new JTextField();
- param2.setEditable(false);
- param2.setColumns(10);
- param2.setBounds(597, 210, 150, 40);
- indexPanelA.add(param2);
-
- JLabel lblNewLabel_2 = new JLabel("测电阻电压");
- lblNewLabel_2.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- lblNewLabel_2.setBounds(137, 288, 140, 40);
- // indexPanelA.add(lblNewLabel_2);
-
- param3 = new JTextField();
- param3.setEditable(false);
- param3.setColumns(10);
- param3.setBounds(287, 288, 150, 40);
- // indexPanelA.add(param3);
-
- JLabel lblNewLabel_1_1 = new JLabel("电阻");
- lblNewLabel_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- lblNewLabel_1_1.setBounds(447, 288, 140, 40);
- // indexPanelA.add(lblNewLabel_1_1);
-
- param4 = new JTextField();
- param4.setEditable(false);
- param4.setColumns(10);
- param4.setBounds(597, 288, 150, 40);
- // indexPanelA.add(param4);
- result = new JLabel("等待结果") {
- @Override
- protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g.create();
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- // 设置圆角背景和边框颜色
- g2.setColor(new Color(255, 255, 255)); // 背景颜色
- g2.fillRoundRect(0, 0, getWidth(), getHeight(), 20, 20); // 圆角矩形,圆角半径为20
- g2.setColor(new Color(255, 255, 255)); // 边框颜色
- g2.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 20, 20); // 绘制边框
- g2.dispose();
- super.paintComponent(g);
- }
- };
- // result.setForeground(Color.GREEN);
- // result.setForeground(Color.RED);
- result.setForeground(Color.GRAY);
- result.setHorizontalAlignment(SwingConstants.CENTER);
- result.setFont(new Font("微软雅黑", Font.BOLD, 50));
- // result.setBounds(290, 392, 356, 89);
- result.setBounds(290, 332, 356, 89);
- indexPanelA.add(result);
- finish_ok_bt = new JButton("OK");
- finish_ok_bt.setEnabled(false);
- finish_ok_bt.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- }
- });
- 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, 291, 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) {
- }
- });
- 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(508, 291, 240, 80);
- finish_ng_bt.setEnabled(false);
- // indexPanelA.add(finish_ng_bt);
- tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
- tabbedPane.setEnabledAt(0, true);
- indexPanelC = new JPanel();
- searchScrollPaneDj = new JScrollPane(indexPanelC);
- // indexPanelC.setLayout(new GridLayout(0, 1, 0, 0));
- indexPanelC.setLayout(null);
- JPanel panel2 = new JPanel();
- panel2.setBounds(0, 0, 990, 50);
- // panel2.setLayout(new GridLayout(0, 1, 0, 0));
- panel2.setLayout(null);
- //记录查询搜索框
- textField = new JTextField();
- textField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // textField.setEnabled(false);
- textField.setForeground(Color.BLACK);
- textField.setBounds(10, 5, 371, 40);
- panel2.add(textField);
- // textField.setColumns(20);
- indexPanelC.add(panel2);
- JButton btnNewButton = new JButton("搜索");
- btnNewButton.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- btnNewButton.setBounds(385, 5, 90, 40);
- panel2.add(btnNewButton);
- // 上一页按钮添加按钮事件监听
- btnNewButton.addActionListener(e -> {
- JdbcUtils.getTestData();
- });
- JButton resetBtn = new JButton("重置");
- resetBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- resetBtn.setBounds(475, 5, 90, 40);
- panel2.add(resetBtn);
- // 上一页按钮添加按钮事件监听
- resetBtn.addActionListener(e -> {
- textField.setText("");
- JdbcUtils.getTestData();
- });
- JButton resetBtn2 = new JButton("导出");
- resetBtn2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- resetBtn2.setBounds(565, 5, 90, 40);
- panel2.add(resetBtn2);
- // 上一页按钮添加按钮事件监听
- resetBtn2.addActionListener(e -> {
- List<QmData> lists = JdbcUtils.getTestDataAll();
- Boolean ret = ExportUtil.export(lists);
- if(ret){
- MesClient.setMenuStatus("导出成功,请在D盘中查看",0);
- }else{
- MesClient.setMenuStatus("导出失败,请重试",-1);
- }
- });
- JButton btnPrevious = new JButton("上一页");
- btnPrevious.setFont(new Font("微软雅黑", Font.PLAIN, 18));
- btnPrevious.setBounds(680, 5, 100, 40);
- panel2.add(btnPrevious);
- // 页码显示
- pageLabel = new JLabel("0/0"); // 初始页码和总页数
- pageLabel.setFont(new Font("微软雅黑", Font.PLAIN, 18));
- pageLabel.setHorizontalAlignment(SwingConstants.CENTER); // 设置文本居中对齐
- pageLabel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1)); // 添加灰色边框
- pageLabel.setBounds(780, 5, 100, 40); // 设置位置和大小
- panel2.add(pageLabel);
- // “下一页”按钮
- JButton btnNext = new JButton("下一页");
- btnNext.setFont(new Font("微软雅黑", Font.PLAIN, 18));
- btnNext.setBounds(880, 5, 100, 40);
- panel2.add(btnNext);
- // 分页逻辑变量
- // 上一页按钮添加按钮事件监听
- btnPrevious.addActionListener(e -> {
- if (pageNo > 1) {
- pageNo--;
- JdbcUtils.getTestData();
- }
- });
- btnNext.addActionListener(e -> {
- if (pageNo < totalPages) {
- pageNo++;
- JdbcUtils.getTestData();
- }
- });
- JPanel panel = new JPanel();
- panel.setBounds(0, 49, 990, 518);
- panel.setLayout(new GridLayout(0, 1, 0, 0));
- indexPanelC.add(panel);
- System.err.println(JSONObject.toJSONString(rowData));
- System.err.println(columnNames.length);
- table = new JTable(rowData, columnNames) {
- public boolean isCellEditable(int row, int column) {
- return false;
- }
- };
- // 添加 MouseListener 获取点击事件
- table.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- if(e.getClickCount() == 1) {
- int row = table.rowAtPoint(e.getPoint()); // 获取点击的行号
- int col = table.columnAtPoint(e.getPoint()); // 获取点击的列号
- if (row >= 0 && col >= 0) { // 确保点击在数据区域内
- Object value = table.getValueAt(row, col); // 获取点击单元格的数据
- System.out.println("Clicked cell value: " + value);
- // 获取整行的数据
- Object[] rowData = new Object[table.getColumnCount()];
- for (int i = 0; i < table.getColumnCount(); i++) {
- rowData[i] = table.getValueAt(row, i);
- }
- log.info("Row data: " + java.util.Arrays.toString(rowData));
- log.info("O:"+String.valueOf(rowData[0]));
- if(String.valueOf(rowData[0]) != null && !String.valueOf(rowData[0]).equals("null") && !String.valueOf(rowData[0]).isEmpty()){
- // 显示一个简单的确认框
- int result = JOptionPane.showConfirmDialog(null, "确定要打印标签吗?", "确认",
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
- if (result == JOptionPane.YES_OPTION) {
- System.out.println("用户点击了“是”");
- PrintUtil.printLabel(String.valueOf(rowData[0]),String.valueOf(rowData[2]),String.valueOf(rowData[3]),String.valueOf(rowData[1]));
- } else if (result == JOptionPane.NO_OPTION) {
- System.out.println("用户点击了“否”");
- } else if (result == JOptionPane.CLOSED_OPTION) {
- System.out.println("对话框被关闭");
- }
- // TestParam testParam = JdbcUtils.getTestData(2);
- // System.out.println(testParam.toString());
- // JSONObject retObj = DataUtil.qmResultData(testParam);
- // System.out.println(retObj.toString());
- }
- }
- }
- }
- });
- // 设置table的宽度为100%
- 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());
- // 设置第二列的长度为100像素
- TableColumn column = table.getColumnModel().getColumn(0);
- column.setPreferredWidth(290);
- column = table.getColumnModel().getColumn(1);
- column.setPreferredWidth(160);
- CenterRenderer centerRenderer = new CenterRenderer();
- for (int i = 0; i < table.getColumnCount(); i++) {
- table.getColumn(table.getColumnName(i)).setCellRenderer(centerRenderer);
- }
- // column = table.getColumnModel().getColumn(6);
- // column.setPreferredWidth(100);
- // column = table.getColumnModel().getColumn(7);
- // column.setPreferredWidth(100);
- JScrollPane scrollPane = new JScrollPane(table);
- panel.add(scrollPane);
- tabbedPane.addTab("记录查询", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
- // 开班点检页签:独立于「记录查询」,工位号从软件设置(configParam)读取
- indexPanelCheck = new JPanel(new BorderLayout());
- indexPanelCheck.setPreferredSize(new Dimension(990, 550));
- labCheckTitle = new JLabel("开班点检(工位号读取软件设置)", JLabel.CENTER);
- indexPanelCheck.add(labCheckTitle, BorderLayout.NORTH);
- panelCheck = new JPanel(new BorderLayout());
- indexPanelCheck.add(panelCheck, BorderLayout.CENTER);
- JScrollPane searchScrollPaneCheck = new JScrollPane(indexPanelCheck);
- tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneCheck, 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);
- indexPanelD = new JPanel();
- searchScrollPaneD = new JScrollPane(indexPanelD);
- indexPanelD.setLayout(null);
- PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
- String[] printerNames;
- if (printServices != null && printServices.length > 0) {
- printerNames = new String[printServices.length];
- for (int i = 0; i < printServices.length; i++) {
- printerNames[i] = printServices[i].getName();
- }
- } else {
- // 本机未检测到打印机:用占位项,避免用 printerNames.length 索引空数组导致越界
- printerNames = new String[]{"未知"};
- }
-
- JLabel lblNewLabel_3 = new JLabel("设备程序号");
- lblNewLabel_3.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3.setBounds(10, 22, 120, 30);
- // indexPanelD.add(lblNewLabel_3);
-
- programNo = new JTextField();
- programNo.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- programNo.setBounds(140, 22, 200, 30);
- // indexPanelD.add(programNo);
- programNo.setColumns(10);
-
- JLabel lblNewLabel_3_1 = new JLabel("设备启动方式");
- lblNewLabel_3_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1.setBounds(10, 71, 120, 30);
- indexPanelD.add(lblNewLabel_3_1);
-
- startMode = new JComboBox();
- startMode.setModel(new DefaultComboBoxModel(new String[] {"手动启动", "自动启动"}));
- startMode.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- startMode.setBounds(140, 71, 200, 30);
- indexPanelD.add(startMode);
-
- JLabel lblNewLabel_3_1_1 = new JLabel("串口号");
- lblNewLabel_3_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1.setBounds(10, 123, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1);
-
- serialPort = new JTextField();
- serialPort.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- serialPort.setColumns(10);
- serialPort.setBounds(140, 123, 200, 30);
- indexPanelD.add(serialPort);
-
- JLabel lblNewLabel_3_1_1_1 = new JLabel("波特率");
- lblNewLabel_3_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1.setBounds(10, 176, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1);
-
- baudRate = new JTextField();
- baudRate.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- baudRate.setColumns(10);
- baudRate.setBounds(140, 176, 200, 30);
- indexPanelD.add(baudRate);
-
- JLabel lblNewLabel_3_1_1_1_1 = new JLabel("数据位");
- lblNewLabel_3_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1.setBounds(10, 229, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1);
-
- dataBits = new JComboBox();
- dataBits.setModel(new DefaultComboBoxModel(new String[] {"5", "6", "7", "8"}));
- dataBits.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- dataBits.setBounds(140, 229, 200, 30);
- indexPanelD.add(dataBits);
-
- JLabel lblNewLabel_3_1_1_1_1_1 = new JLabel("校验位");
- lblNewLabel_3_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1.setBounds(10, 282, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1);
-
- checkBit = new JComboBox();
- checkBit.setModel(new DefaultComboBoxModel(new String[] {"NONE", "ODD", "EVEN", "MARK", "SPACE"}));
- checkBit.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- checkBit.setBounds(140, 282, 200, 30);
- indexPanelD.add(checkBit);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1 = new JLabel("停止位");
- lblNewLabel_3_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1.setBounds(10, 335, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1);
-
- stopBit = new JComboBox();
- stopBit.setModel(new DefaultComboBoxModel(new String[] {"1", "1.5", "2"}));
- stopBit.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- stopBit.setBounds(140, 335, 200, 30);
- indexPanelD.add(stopBit);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1 = new JLabel("是否打印标签");
- lblNewLabel_3_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1.setBounds(408, 22, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1);
-
- printLabel = new JComboBox();
- printLabel.setModel(new DefaultComboBoxModel(new String[] {"是", "否"}));
- printLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- printLabel.setBounds(536, 22, 200, 30);
- indexPanelD.add(printLabel);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1 = new JLabel("打印机名称");
- lblNewLabel_3_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1.setBounds(408, 71, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1);
-
- printName = new JTextField();
- printName.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- printName.setColumns(10);
- printName.setBounds(536, 71, 200, 30);
- indexPanelD.add(printName);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1 = new JLabel("标签名称");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1.setBounds(408, 123, 120, 30);
- // indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1);
-
- labelName = new JTextField();
- labelName.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- labelName.setColumns(10);
- labelName.setBounds(536, 123, 200, 30);
- // indexPanelD.add(labelName);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1 = new JLabel("标签偏移X");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1.setBounds(408, 176, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1);
-
- labelx = new JTextField();
- labelx.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- labelx.setColumns(10);
- labelx.setBounds(536, 176, 200, 30);
- indexPanelD.add(labelx);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1 = new JLabel("标签偏移Y");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1.setBounds(408, 229, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1);
-
- labely = new JTextField();
- labely.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- labely.setColumns(10);
- labely.setBounds(536, 229, 200, 30);
- indexPanelD.add(labely);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1 = new JLabel("标签行间距");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1.setBounds(408, 282, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1);
-
- labelLineSpace = new JTextField();
- labelLineSpace.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- labelLineSpace.setColumns(10);
- labelLineSpace.setBounds(536, 282, 200, 30);
- indexPanelD.add(labelLineSpace);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1 = new JLabel("标签字号");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1.setBounds(408, 335, 120, 30);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1.setBounds(408, 123, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1);
-
- labelFont = new JTextField();
- labelFont.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- labelFont.setColumns(10);
- // labelFont.setBounds(536, 335, 200, 30);
- labelFont.setBounds(536, 123, 200, 30);
- indexPanelD.add(labelFont);
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2 = new JLabel("MODBUS站号");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2.setBounds(408, 282, 120, 30);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2.setBounds(408, 335, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_2);
- stationNo = new JTextField();
- stationNo.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- stationNo.setColumns(10);
- stationNo.setBounds(536, 335, 200, 30);
- indexPanelD.add(stationNo);
-
- saveBtn = new JButton("编辑配置");
- saveBtn.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- saveBtn.setBounds(787, 267, 156, 57);
- indexPanelD.add(saveBtn);
- saveBtn.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(isConfigEdit == 0){
- String pass = "503833";
- //弹窗扫工件码
- String scanBarcode = JOptionPane.showInputDialog(null, "请输入密码");
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")&&scanBarcode.equals(pass)) {
- isConfigEdit = 1;
- formatConfigEdit(true);
- saveBtn.setText("保存配置");
- }else{
- MesClient.setMenuStatus("密码错误",-1);
- }
- }else{
- formatConfigEdit(false);
- saveBtn.setText("编辑配置");
- configParam.setProgramNo(programNo.getText());
- configParam.setSerialPort(serialPort.getText());
- configParam.setBaudRate(baudRate.getText());
- configParam.setPrintName(printName.getText());
- configParam.setLabelName(labelName.getText());
- configParam.setLabelx(labelx.getText());
- configParam.setLabely(labely.getText());
- configParam.setLabelLineSpace(labelLineSpace.getText());
- configParam.setLabelFont(labelFont.getText());
- configParam.setStationNo(stationNo.getText());
- configParam.setStopBit(stopBit.getSelectedItem().toString());
- configParam.setCheckBit(checkBit.getSelectedItem().toString());
- configParam.setStopBit(stopBit.getSelectedItem().toString());
- configParam.setDataBits(dataBits.getSelectedItem().toString());
- configParam.setPrintLabel(printLabel.getSelectedItem().toString());
- configParam.setStartMode(startMode.getSelectedItem().toString());
- configParam.setProductSnPre(productSnPre.getText().trim());
- configParam.setProductSnLength(productSnLength.getText().trim());
- configParam.setLeakage(leakage.getSelectedItem().toString());
- configParam.setDevice(device.getSelectedItem().toString());
- //9.1修改
- // configParam.setNgTime(ngTime.getText());
- // configParam.setNgNumber(ngNumber.getText());
- // configParam.setNgUpgradeTime(ngUpgradeTime.getText());
- configParam.setOprno(oprno.getText().trim());
- configParam.setOprnoTitle(oprnoTitle.getText().trim());
- configParam.setLineSn(lineSn.getText().trim());
- System.out.println("configParam:"+JSONObject.toJSONString(configParam));
- if(configParam.getId() != null && configParam.getId() > 0){
- JdbcUtils.updateConfig(configParam.getId(),JSONObject.toJSONString(configParam));
- }else{
- JdbcUtils.insertConfig(JSONObject.toJSONString(configParam));
- }
- isConfigEdit = 0;
- formatConfigData();
- serialPortUtils.closePort();
- serialPortUtils = new SerialPortUtils(configParam.getSerialPort(),configParam.getOprno(),configParam.getOprnoTitle(),configParam.getDevice());
- }
- }
- });
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_2 = new JLabel("泄露值取值");
- lblNewLabel_3_1_1_1_1_1_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // lblNewLabel_3_1_1_1_1_1_1_2.setBounds(10, 445, 120, 30);
- // lblNewLabel_3_1_1_1_1_1_1_2.setBounds(408, 390, 120, 30);
- lblNewLabel_3_1_1_1_1_1_1_2.setBounds(10, 390, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_2);
-
- leakage = new JComboBox();
- leakage.setModel(new DefaultComboBoxModel(new String[] {"压降", "泄漏率"}));
- leakage.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // leakage.setBounds(140, 445, 200, 30);
- // leakage.setBounds(536, 390, 200, 30);
- leakage.setBounds(140, 390, 200, 30);
- indexPanelD.add(leakage);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1 = new JLabel("工件码长度");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setBounds(408, 390, 120, 30);
- // indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1);
-
- productSnLength = new JTextField();
- productSnLength.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- productSnLength.setColumns(10);
- productSnLength.setBounds(536, 390, 200, 30);
- // indexPanelD.add(productSnLength);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1 = new JLabel("工件码前缀");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1.setBounds(10, 390, 120, 30);
- // indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_1);
-
- productSnPre = new JTextField();
- productSnPre.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- productSnPre.setColumns(10);
- productSnPre.setBounds(140, 390, 200, 30);
- // indexPanelD.add(productSnPre);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2 = new JLabel("检测设备");
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2.setHorizontalAlignment(SwingConstants.RIGHT);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2.setBounds(408, 445, 120, 30);
- // lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2.setBounds(10, 390, 120, 30);
- lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2.setBounds(10, 22, 120, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_1_1_1_1_1_1_2);
-
- device = new JComboBox();
- device.setModel(new DefaultComboBoxModel(new String[] {"innomatec", "ateq"}));
- device.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // device.setBounds(536, 445, 200, 30);
- // device.setBounds(140, 390, 200, 30);
- device.setBounds(140, 22, 200, 30);
- indexPanelD.add(device);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_2 = new JLabel("工位号");
- lblNewLabel_3_1_1_1_1_1_1_1_1_2.setHorizontalAlignment(SwingConstants.CENTER);
- lblNewLabel_3_1_1_1_1_1_1_1_1_2.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_2.setBounds(762, 22, 200, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_2);
- // ngTime = new JTextField();
- // ngTime.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // ngTime.setColumns(10);
- // ngTime.setBounds(762, 54, 200, 30);
- // indexPanelD.add(ngTime);
- oprno = new JTextField();
- oprno.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- oprno.setColumns(10);
- oprno.setBounds(762, 54, 200, 30);
- indexPanelD.add(oprno);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_2_1 = new JLabel("工位名称");
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1.setHorizontalAlignment(SwingConstants.CENTER);
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1.setBounds(762, 94, 200, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_2_1);
-
- // ngNumber = new JTextField();
- // ngNumber.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // ngNumber.setColumns(10);
- // ngNumber.setBounds(762, 123, 200, 30);
- // indexPanelD.add(ngNumber);
- oprnoTitle = new JTextField();
- oprnoTitle.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- oprnoTitle.setColumns(10);
- oprnoTitle.setBounds(762, 123, 200, 30);
- indexPanelD.add(oprnoTitle);
-
- JLabel lblNewLabel_3_1_1_1_1_1_1_1_1_2_1_1 = new JLabel("产线编号");
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1_1.setHorizontalAlignment(SwingConstants.CENTER);
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lblNewLabel_3_1_1_1_1_1_1_1_1_2_1_1.setBounds(762, 163, 200, 30);
- indexPanelD.add(lblNewLabel_3_1_1_1_1_1_1_1_1_2_1_1);
- //
- // ngUpgradeTime = new JTextField();
- // ngUpgradeTime.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // ngUpgradeTime.setColumns(10);
- // ngUpgradeTime.setBounds(762, 195, 200, 30);
- // indexPanelD.add(ngUpgradeTime);
- lineSn = new JTextField();
- lineSn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- lineSn.setColumns(10);
- lineSn.setBounds(762, 195, 200, 30);
- indexPanelD.add(lineSn);
- tabbedPane.addTab("软件设置", new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")), searchScrollPaneD, null);
- JPanel indexPanelTask = new JPanel();
- searchScrollPaneTask = new JScrollPane(indexPanelTask);
- indexPanelTask.setLayout(null);
- JPanel panel22 = new JPanel();
- panel22.setBounds(0, 0, 300, 530);
- indexPanelTask.add(panel22);
- panel22.setLayout(new GridLayout(0, 1, 0, 0));
- table2 = new JTable(rowData2, columnNames2){
- public boolean isCellEditable(int row, int column) {
- return false;
- }
- };
- table2.setRowHeight(40);
- table2.setEnabled(true);
- table2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
- // 添加鼠标点击事件
- table2.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent e) {
- // 获取点击位置的行和列索引
- int row = table2.rowAtPoint(e.getPoint());
- int col = table2.columnAtPoint(e.getPoint());
- // 检查点击是否有效(即是否真的在表格内)
- if (row >= 0 && col >= 0) {
- // 获取点击的单元格的值
- Object value = table2.getValueAt(row, col);
- String val = String.valueOf(value);
- System.out.println("Clicked on row " + row + ", column " + col + ": " + value);
- // 在这里添加你的逻辑代码
- for(TaskParam taskParam:taskParamList){
- if(val.equals(taskParam.getTitle())){
- MesClient.curTaskParam = taskParam;
- formatTaskParam();
- break;
- }
- }
- }
- }
- });
- // 自定义渲染器
- DefaultTableCellRenderer centerRenderer2 = new DefaultTableCellRenderer();
- centerRenderer2.setHorizontalAlignment(JLabel.CENTER); // 设置内容居中
- table2.setDefaultRenderer(Object.class, centerRenderer2); // 应用到所有列
- JScrollPane scrollPane2 = new JScrollPane(table2);
- panel22.add(scrollPane2);
- JButton addTask = new JButton("新增任务");
- addTask.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- String taskContent = JOptionPane.showInputDialog(null, "请输入任务名称").trim();
- if(taskContent!=null&&!taskContent.equalsIgnoreCase("")) {
- String passContent = JOptionPane.showInputDialog(null, "请输入密码");
- if(passContent!=null&&!passContent.equalsIgnoreCase("")) {
- if(passContent.equals("503833")){
- int wyflag = 1;
- for(TaskParam taskParam:taskParamList){
- if(taskParam.getTitle().equals(taskContent)){
- wyflag = 0;
- break;
- }
- }
- if(wyflag == 0){
- MesClient.setMenuStatus("任务名称已被占用",-1);
- return;
- }
- TaskParam taskParam = new TaskParam();
- taskParam.setTitle(taskContent);
- JdbcUtils.insertTask(taskParam);
- getTask();
- }else{
- MesClient.setMenuStatus("密码错误",-1);
- }
- }
- }
- }
- });
- addTask.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- addTask.setBounds(310, 10, 120, 40);
- indexPanelTask.add(addTask);
- JButton delTask = new JButton("删除任务");
- delTask.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(MesClient.curTaskParam == null){
- MesClient.setMenuStatus("请先选择任务",-1);
- return;
- }
- String passContent = JOptionPane.showInputDialog(null, "请输入密码");
- if(passContent!=null&&!passContent.equalsIgnoreCase("")) {
- if(passContent.equals("503833")){
- JdbcUtils.deleteTask(MesClient.curTaskParam.getId());
- getTask();
- MesClient.curTaskParam = null;
- formatTaskParam();
- }else{
- MesClient.setMenuStatus("密码错误",-1);
- }
- }
- }
- });
- delTask.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- delTask.setBounds(440, 10, 120, 40);
- indexPanelTask.add(delTask);
- JButton saveTask = new JButton("保存任务");
- saveTask.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if(MesClient.curTaskParam == null){
- MesClient.setMenuStatus("请先选择任务",-1);
- return;
- }
- String passContent = JOptionPane.showInputDialog(null, "请输入密码");
- if(passContent!=null&&!passContent.equalsIgnoreCase("")) {
- if(passContent.equals("503833")){
- MesClient.curTaskParam.setBarcodeSpecStart(barcodeSpecStart.getText().trim());
- MesClient.curTaskParam.setBarcodeSpec(barcodeSpec.getText().trim());
- MesClient.curTaskParam.setBarcodeLength(barcodeLength.getText().trim());
- MesClient.curTaskParam.setTaskProgramNo(taskMaxNumA.getText().trim());
- MesClient.curTaskParam.setTaskLabelName(taskMaxFoutA.getText().trim());
- MesClient.curTaskParam.setTaskLeakage(taskLeakage.getSelectedItem().toString());
- JdbcUtils.updateTask(MesClient.curTaskParam.getId(),MesClient.curTaskParam);
- getTask();
- formatTaskParam();
- }else{
- MesClient.setMenuStatus("密码错误",-1);
- }
- }
- }
- });
- saveTask.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- saveTask.setBounds(570, 10, 120, 40);
- indexPanelTask.add(saveTask);
- taskName = new JLabel("");
- taskName.setFont(new Font("微软雅黑", Font.PLAIN, 20));
- taskName.setBounds(700, 10, 283, 40);
- indexPanelTask.add(taskName);
- JLabel taskMaxNumLabelA = new JLabel("程序号");
- taskMaxNumLabelA.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxNumLabelA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxNumLabelA.setBounds(310, 93, 110, 30);
- indexPanelTask.add(taskMaxNumLabelA);
- taskMaxNumA = new JTextField();
- taskMaxNumA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxNumA.setBounds(422, 93, 110, 30);
- indexPanelTask.add(taskMaxNumA);
- taskMaxNumA.setColumns(10);
- JLabel taskMaxFoutLabelA = new JLabel("标签名称");
- taskMaxFoutLabelA.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxFoutLabelA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxFoutLabelA.setBounds(310, 133, 110, 30);
- indexPanelTask.add(taskMaxFoutLabelA);
- taskMaxFoutA = new JTextField();
- taskMaxFoutA.setColumns(10);
- taskMaxFoutA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxFoutA.setBounds(422, 133, 110, 30);
- indexPanelTask.add(taskMaxFoutA);
- JLabel taskMinFoutLabelA = new JLabel("泄漏值取值");
- taskMinFoutLabelA.setHorizontalAlignment(SwingConstants.CENTER);
- taskMinFoutLabelA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinFoutLabelA.setBounds(310, 173, 110, 30);
- indexPanelTask.add(taskMinFoutLabelA);
- taskLeakage = new JComboBox();
- taskLeakage.setModel(new DefaultComboBoxModel(new String[] {"压降", "泄漏率"}));
- taskLeakage.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskLeakage.setBounds(422, 173, 110, 30);
- indexPanelTask.add(taskLeakage);
- // taskMinFoutA = new JTextField();
- // taskMinFoutA.setColumns(10);
- // taskMinFoutA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- // taskMinFoutA.setBounds(422, 173, 110, 30);
- // indexPanelTask.add(taskMinFoutA);
- JLabel taskMaxSoutLabelA = new JLabel("A枪最大行程");
- taskMaxSoutLabelA.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxSoutLabelA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxSoutLabelA.setBounds(310, 213, 110, 30);
- // indexPanelTask.add(taskMaxSoutLabelA);
- taskMaxSoutA = new JTextField();
- taskMaxSoutA.setColumns(10);
- taskMaxSoutA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxSoutA.setBounds(422, 213, 110, 30);
- // indexPanelTask.add(taskMaxSoutA);
- JLabel taskMinSoutLabelA = new JLabel("A枪最小行程");
- taskMinSoutLabelA.setHorizontalAlignment(SwingConstants.CENTER);
- taskMinSoutLabelA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinSoutLabelA.setBounds(310, 253, 110, 30);
- // indexPanelTask.add(taskMinSoutLabelA);
- taskMinSoutA = new JTextField();
- taskMinSoutA.setColumns(10);
- taskMinSoutA.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinSoutA.setBounds(422, 253, 110, 30);
- // indexPanelTask.add(taskMinSoutA);
- JLabel taskMaxNumLabelB = new JLabel("B枪预算数量");
- taskMaxNumLabelB.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxNumLabelB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxNumLabelB.setBounds(580, 93, 110, 30);
- // indexPanelTask.add(taskMaxNumLabelB);
- taskMaxNumB = new JTextField();
- taskMaxNumB.setColumns(10);
- taskMaxNumB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxNumB.setBounds(692, 93, 110, 30);
- // indexPanelTask.add(taskMaxNumB);
- JLabel taskMaxFoutLabelB = new JLabel("B枪最大拉力");
- taskMaxFoutLabelB.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxFoutLabelB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxFoutLabelB.setBounds(580, 133, 110, 30);
- // indexPanelTask.add(taskMaxFoutLabelB);
- taskMaxFoutB = new JTextField();
- taskMaxFoutB.setColumns(10);
- taskMaxFoutB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxFoutB.setBounds(692, 133, 110, 30);
- // indexPanelTask.add(taskMaxFoutB);
- JLabel taskMinFoutLabelB = new JLabel("B枪最小拉力");
- taskMinFoutLabelB.setHorizontalAlignment(SwingConstants.CENTER);
- taskMinFoutLabelB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinFoutLabelB.setBounds(580, 173, 110, 30);
- // indexPanelTask.add(taskMinFoutLabelB);
- taskMinFoutB = new JTextField();
- taskMinFoutB.setColumns(10);
- taskMinFoutB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinFoutB.setBounds(692, 173, 110, 30);
- // indexPanelTask.add(taskMinFoutB);
- JLabel taskMaxSoutLabelB = new JLabel("B枪最大行程");
- taskMaxSoutLabelB.setHorizontalAlignment(SwingConstants.CENTER);
- taskMaxSoutLabelB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxSoutLabelB.setBounds(580, 213, 110, 30);
- // indexPanelTask.add(taskMaxSoutLabelB);
- taskMaxSoutB = new JTextField();
- taskMaxSoutB.setColumns(10);
- taskMaxSoutB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMaxSoutB.setBounds(692, 213, 110, 30);
- // indexPanelTask.add(taskMaxSoutB);
- JLabel taskMinSoutLabelB = new JLabel("B枪最小行程");
- taskMinSoutLabelB.setHorizontalAlignment(SwingConstants.CENTER);
- taskMinSoutLabelB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinSoutLabelB.setBounds(580, 253, 110, 30);
- // indexPanelTask.add(taskMinSoutLabelB);
- taskMinSoutB = new JTextField();
- taskMinSoutB.setColumns(10);
- taskMinSoutB.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- taskMinSoutB.setBounds(692, 253, 110, 30);
- // indexPanelTask.add(taskMinSoutB);
- JLabel barcodeSpecLabel = new JLabel("条码固定位");
- barcodeSpecLabel.setHorizontalAlignment(SwingConstants.CENTER);
- barcodeSpecLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeSpecLabel.setBounds(310, 293, 110, 30);
- indexPanelTask.add(barcodeSpecLabel);
- barcodeSpec = new JTextField();
- barcodeSpec.setColumns(10);
- barcodeSpec.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeSpec.setBounds(422, 293, 110, 30);
- indexPanelTask.add(barcodeSpec);
- JLabel barcodeSpecStartLabel = new JLabel("起始位数");
- barcodeSpecStartLabel.setHorizontalAlignment(SwingConstants.CENTER);
- barcodeSpecStartLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeSpecStartLabel.setBounds(310, 333, 110, 30);
- indexPanelTask.add(barcodeSpecStartLabel);
- barcodeSpecStart = new JTextField();
- barcodeSpecStart.setColumns(10);
- barcodeSpecStart.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeSpecStart.setBounds(422, 333, 110, 30);
- indexPanelTask.add(barcodeSpecStart);
- JLabel barcodeLengthLabel = new JLabel("条码长度");
- barcodeLengthLabel.setHorizontalAlignment(SwingConstants.CENTER);
- barcodeLengthLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeLengthLabel.setBounds(310, 373, 110, 30);
- indexPanelTask.add(barcodeLengthLabel);
- barcodeLength = new JTextField();
- barcodeLength.setColumns(10);
- barcodeLength.setFont(new Font("微软雅黑", Font.PLAIN, 16));
- barcodeLength.setBounds(422, 373, 110, 30);
- indexPanelTask.add(barcodeLength);
- tabbedPane.addTab("任务设置", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneTask, null);
- tabbedPane.addChangeListener(new ChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
- int selectedIndex = tabbedPane.getSelectedIndex();
- if(selectedIndex == 1){
- }
- // 切到「开班点检」页签时按当前软件设置重新加载,保证工位号改动即时生效
- if(selectedIndex >= 0 && "开班点检".equals(tabbedPane.getTitleAt(selectedIndex))){
- refreshCheckPage();
- }
- JdbcUtils.getTestData();
- }
- });
- }
- /**
- * 加载/刷新「开班点检」页面:工位号与产线号均取自软件设置(configParam),
- * 而不是 config.properties 里写死的 mes.gw。未配置时才回退到 mes.gw / mes_line_sn。
- */
- public static void refreshCheckPage(){
- if(sessionid == null || sessionid.isEmpty()) return; // 未登录不加载
- if(configParam == null) return;
- String oprno = configParam.getOprno();
- if(oprno == null || oprno.trim().isEmpty()){
- // 不回退到 config.properties 的 mes_gw,避免把点检记录提交到错误工位
- if(labCheckTitle != null){
- labCheckTitle.setText("开班点检 - 未配置工位号,请在「软件设置」中配置后切回本页签");
- }
- return;
- }
- String lineSn = configParam.getLineSn();
- if(lineSn == null || lineSn.trim().isEmpty()) lineSn = mes_line_sn;
- String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProcessCheckRecord/ulist?__sid="
- + sessionid + "&oprno=" + oprno.trim() + "&lineSn=" + lineSn.trim();
- if(labCheckTitle != null){
- labCheckTitle.setText("开班点检 - 工位号:" + oprno.trim() + "(来自软件设置)");
- }
- try {
- if(jfxPanel2 == null){
- jfxPanel2 = new MesWebView(url);
- panelCheck.add(jfxPanel2, BorderLayout.CENTER);
- panelCheck.revalidate();
- panelCheck.repaint();
- }else{
- jfxPanel2.loadUrl(url);
- }
- } catch (Exception ex) {
- System.err.println("开班点检页面加载失败: " + ex.getMessage());
- ex.printStackTrace();
- }
- }
- 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 getTask(){
- taskParamList = JdbcUtils.getTask();
- System.out.println("taskParamList:"+taskParamList.size());
- if(taskParamList.size() > 0){
- int i = 0;
- rowData2 = new Object[taskParamList.size()][1];
- for(TaskParam taskParam:taskParamList){
- rowData2[i][0] = taskParam.getTitle();
- i++;
- }
- }else{
- rowData2[0][0] = "";
- }
- System.out.println("rowData2:"+JSONObject.toJSONString(rowData2));
- DefaultTableModel model = new DefaultTableModel(rowData2, columnNames2);
- table2.setModel(model);
- MesClient.table2.repaint();
- }
- public static void formatTaskParam(){
- if(MesClient.curTaskParam != null){
- taskName.setText(MesClient.curTaskParam.getTitle());
- if(MesClient.curTaskParam.getTaskProgramNo() == null || MesClient.curTaskParam.getTaskProgramNo().equals("")){
- MesClient.curTaskParam.setTaskProgramNo("");
- }
- taskMaxNumA.setText(MesClient.curTaskParam.getTaskProgramNo());
- if(MesClient.curTaskParam.getTaskLabelName() == null || MesClient.curTaskParam.getTaskLabelName().equals("")){
- MesClient.curTaskParam.setTaskLabelName("");
- }
- taskMaxFoutA.setText(MesClient.curTaskParam.getTaskLabelName());
- if(MesClient.curTaskParam.getTaskLeakage() == null || MesClient.curTaskParam.getTaskLeakage().equals("")){
- MesClient.curTaskParam.setTaskLeakage("压降");
- }
- taskLeakage.setSelectedItem(MesClient.curTaskParam.getTaskLeakage());
- if(MesClient.curTaskParam.getBarcodeSpec() == null || MesClient.curTaskParam.getBarcodeSpec().equals("")){
- MesClient.curTaskParam.setBarcodeSpec("");
- }
- barcodeSpec.setText(MesClient.curTaskParam.getBarcodeSpec());
- if(MesClient.curTaskParam.getBarcodeSpecStart() == null || MesClient.curTaskParam.getBarcodeSpecStart().equals("")){
- MesClient.curTaskParam.setBarcodeSpecStart("");
- }
- barcodeSpecStart.setText(MesClient.curTaskParam.getBarcodeSpecStart());
- if(MesClient.curTaskParam.getBarcodeLength() == null || MesClient.curTaskParam.getBarcodeLength().equals("")){
- MesClient.curTaskParam.setBarcodeLength("");
- }
- barcodeLength.setText(MesClient.curTaskParam.getBarcodeLength());
- }else{
- taskName.setText("");
- taskMaxNumA.setText("");
- taskMaxNumB.setText("");
- taskMaxFoutA.setText("");
- taskMaxFoutB.setText("");
- taskMaxSoutA.setText("");
- taskMaxSoutB.setText("");
- taskMinFoutA.setText("");
- taskMinFoutB.setText("");
- taskMinSoutA.setText("");
- taskMinSoutB.setText("");
- barcodeLength.setText("");
- barcodeSpec.setText("");
- barcodeSpecStart.setText("");
- }
- }
- // 检查工件码的正确性
- public static boolean checkProductSn(String sn){
- curTaskName.setText("");
- if(taskParamList.size() <= 0){
- MesClient.setMenuStatus("未设置任务",-1);
- return false;
- }
- try{
- for(TaskParam taskParam : taskParamList){
- if(taskParam.getBarcodeSpec()!=null&&!taskParam.getBarcodeSpec().equals("null")&&taskParam.getBarcodeSpecStart()!=null&&!taskParam.getBarcodeSpecStart().equals("null")&&taskParam.getBarcodeLength()!=null&&!taskParam.getBarcodeLength().equals("null")) {
- Boolean ret = CommonUtils.checkSnByModel(sn,taskParam.getBarcodeSpec(),Integer.valueOf(taskParam.getBarcodeSpecStart()),Integer.valueOf(taskParam.getBarcodeLength()));
- if(ret){
- configParam.setLabelName(taskParam.getTaskLabelName());
- configParam.setLeakage(taskParam.getTaskLeakage());
- configParam.setProgramNo(taskParam.getTaskProgramNo());
- curTaskName.setText("当前任务:"+taskParam.getTitle());
- // configParam.setDeviceMaxNumValA(taskParam.getTaskMaxNumA());
- // configParam.setMaxFoutValA(taskParam.getTaskMaxFoutA());
- // configParam.setMaxSoutValA(taskParam.getTaskMaxSoutA());
- // configParam.setMinFoutValA(taskParam.getTaskMinFoutA());
- // configParam.setMinSoutValA(taskParam.getTaskMinSoutA());
- //
- // configParam.setDeviceMaxNumValB(taskParam.getTaskMaxNumB());
- // configParam.setMaxFoutValB(taskParam.getTaskMaxFoutB());
- // configParam.setMaxSoutValB(taskParam.getTaskMaxSoutB());
- // configParam.setMinFoutValB(taskParam.getTaskMinFoutB());
- // configParam.setMinSoutValB(taskParam.getTaskMinSoutB());
- return true;
- }
- }
- }
- }catch (Exception e){
- e.printStackTrace();
- }
- MesClient.setMenuStatus("该类型工件未设置任务",-1);
- return false;
- }
- }
|