|
|
@@ -5,6 +5,7 @@ import com.mes.component.MesRadio;
|
|
|
import com.mes.component.MesWebView;
|
|
|
import com.mes.netty.NettyClient;
|
|
|
import com.mes.util.*;
|
|
|
+import com.mes.util.CommonQmDevice;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -129,7 +130,12 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static String tjFlagTextErr = "结果上传MES失败,请重试";
|
|
|
|
|
|
+ public static CommonQmDevice commonQmDevice;
|
|
|
public static SerialPortUtils serialPortUtils;
|
|
|
+ public static Integer mesTjFlag = 0;
|
|
|
+ public static Integer workstop = 0;
|
|
|
+ public static String lastQmPressure = "";
|
|
|
+ public static String lastQmLeak = "";
|
|
|
public static JTextField printSn2;
|
|
|
public static JTextField printTitle2;
|
|
|
public static JTextField printValue2;
|
|
|
@@ -167,7 +173,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
getTask();
|
|
|
|
|
|
- serialPortUtils=new SerialPortUtils(configParam.getSerialPort(),getEffectiveOprno(),configParam.getOprnoTitle(),configParam.getDevice());
|
|
|
+ commonQmDevice = new CommonQmDevice(configParam);
|
|
|
+ serialPortUtils = commonQmDevice.serialPortUtils;
|
|
|
|
|
|
// startDateTimer();
|
|
|
|
|
|
@@ -346,6 +353,10 @@ public class MesClient extends JFrame {
|
|
|
product_sn.setEditable(true);
|
|
|
tjFlag = 0;
|
|
|
mesStartFlag = 0;
|
|
|
+ mesTjFlag = 0;
|
|
|
+ workstop = 0;
|
|
|
+ lastQmPressure = "";
|
|
|
+ lastQmLeak = "";
|
|
|
curTaskName.setText("");
|
|
|
|
|
|
// f_scan_data_bt_1.setIcon(new ImageIcon(MesClient.class.getResource("/bg/scan_barcode.png")));
|
|
|
@@ -665,7 +676,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static void scanBarcode() {
|
|
|
if (work_status == 1) {
|
|
|
- MesClient.serialPortUtils.start();
|
|
|
+ startQmDevice();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -727,7 +738,7 @@ public class MesClient extends JFrame {
|
|
|
// }
|
|
|
|
|
|
if(checkProductSn(scanBarcode.trim())){
|
|
|
- serialPortUtils.changeProgram(); // 切换程序
|
|
|
+ changeQmProgram(); // 切换程序
|
|
|
if(MesClient.mes_enable){
|
|
|
getUser();
|
|
|
// 查询工件质量
|
|
|
@@ -737,15 +748,7 @@ public class MesClient extends JFrame {
|
|
|
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);
|
|
|
+ beginTestAfterScan();
|
|
|
}
|
|
|
}
|
|
|
// f_scan_data_bt_1.setIcon(null);
|
|
|
@@ -753,6 +756,99 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /** 扫码/质量检查通过后进入测试状态 */
|
|
|
+ public static void beginTestAfterScan() {
|
|
|
+ work_status = 1;
|
|
|
+ MesClient.tjFlag = 1;
|
|
|
+ MesClient.mesStartFlag = 0;
|
|
|
+ MesClient.mesTjFlag = 0;
|
|
|
+ MesClient.workstop = 0;
|
|
|
+ MesClient.lastQmPressure = "";
|
|
|
+ MesClient.lastQmLeak = "";
|
|
|
+ MesClient.check_quality_result = true;
|
|
|
+ MesClient.setMenuStatus("该工件可以测试,等待测试", 0);
|
|
|
+ product_sn.setEditable(false);
|
|
|
+ if (MesClient.configParam.getStartMode().equals("自动启动")) {
|
|
|
+ startQmDevice();
|
|
|
+ }
|
|
|
+ MesClient.result.setText("等待结果");
|
|
|
+ MesClient.result.setForeground(Color.GRAY);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void startQmDevice() {
|
|
|
+ if (commonQmDevice != null) {
|
|
|
+ commonQmDevice.start();
|
|
|
+ } else if (serialPortUtils != null) {
|
|
|
+ serialPortUtils.start();
|
|
|
+ } else {
|
|
|
+ MesClient.setMenuStatus("设备未初始化", -1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void changeQmProgram() {
|
|
|
+ if (commonQmDevice != null) {
|
|
|
+ commonQmDevice.changeProgram();
|
|
|
+ } else if (serialPortUtils != null) {
|
|
|
+ serialPortUtils.changeProgram();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本地存库后提交MES,成功则复位扫码。
|
|
|
+ */
|
|
|
+ public static boolean afterTestSaveAndUpload(TestParam testParam) {
|
|
|
+ try {
|
|
|
+ String testDate = testParam.getCreateTime();
|
|
|
+ if (testDate == null || testDate.isEmpty()) {
|
|
|
+ testDate = DateLocalUtils.getCurrentTime();
|
|
|
+ testParam.setCreateTime(testDate);
|
|
|
+ }
|
|
|
+ if (testParam.getOprno() == null || testParam.getOprno().isEmpty()) {
|
|
|
+ testParam.setOprno(getEffectiveOprno());
|
|
|
+ }
|
|
|
+ if (testParam.getLineSn() == null || testParam.getLineSn().isEmpty()) {
|
|
|
+ testParam.setLineSn(getEffectiveLineSn());
|
|
|
+ }
|
|
|
+ JdbcUtils.insertTestRecord(testParam);
|
|
|
+
|
|
|
+ if (mes_enable) {
|
|
|
+ JSONObject retObj = DataUtil.qmResultData(testParam);
|
|
|
+ if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ MesClient.resetScanA();
|
|
|
+ MesClient.setMenuStatus("测试结果上传成功,请扫下一件", 0);
|
|
|
+ try { JdbcUtils.getTestData(); } catch (Exception ignore) {}
|
|
|
+ if (MesClient.configParam.getPrintLabel().equals("是") && "OK".equals(testParam.getResult())) {
|
|
|
+ PrintUtil.printLabel(testParam.getSn(),
|
|
|
+ (testParam.getParam1() != null ? testParam.getParam1() : "") + (testParam.getParam2() != null ? testParam.getParam2() : ""),
|
|
|
+ (testParam.getParam3() != null ? testParam.getParam3() : "") + (testParam.getParam4() != null ? testParam.getParam4() : ""),
|
|
|
+ testDate);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ MesClient.mesStartFlag = 0;
|
|
|
+ MesClient.mesTjFlag = 0;
|
|
|
+ MesClient.workstop = 0;
|
|
|
+ MesClient.setMenuStatus("测试结果上传失败,请重试", -1);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MesClient.resetScanA();
|
|
|
+ try { JdbcUtils.getTestData(); } catch (Exception ignore) {}
|
|
|
+ if (MesClient.configParam.getPrintLabel().equals("是") && "OK".equals(testParam.getResult())) {
|
|
|
+ PrintUtil.printLabel(testParam.getSn(),
|
|
|
+ (testParam.getParam1() != null ? testParam.getParam1() : "") + (testParam.getParam2() != null ? testParam.getParam2() : ""),
|
|
|
+ (testParam.getParam3() != null ? testParam.getParam3() : "") + (testParam.getParam4() != null ? testParam.getParam4() : ""),
|
|
|
+ testDate);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("保存上传测试结果失败", e);
|
|
|
+ MesClient.setMenuStatus("测试结果保存失败,请重试", -1);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static void scanBarcodeOld() {
|
|
|
if(work_status == 1){
|
|
|
// MesClient.serialPortUtils.sendData("START");
|
|
|
@@ -812,7 +908,7 @@ public class MesClient extends JFrame {
|
|
|
MesClient.setMenuStatus("扫码成功,等待测试",0);
|
|
|
|
|
|
if(MesClient.configParam.getStartMode().equals("自动启动")){
|
|
|
- MesClient.serialPortUtils.start();
|
|
|
+ startQmDevice();
|
|
|
}
|
|
|
f_scan_data_bt_1.setIcon(null);
|
|
|
f_scan_data_bt_1.setText("启动");
|
|
|
@@ -1333,7 +1429,7 @@ public class MesClient extends JFrame {
|
|
|
startMode.setBounds(140, 71, 200, 30);
|
|
|
indexPanelD.add(startMode);
|
|
|
|
|
|
- JLabel lblNewLabel_3_1_1 = new JLabel("串口号");
|
|
|
+ JLabel lblNewLabel_3_1_1 = new JLabel("串口号/IP");
|
|
|
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);
|
|
|
@@ -1345,7 +1441,7 @@ public class MesClient extends JFrame {
|
|
|
serialPort.setBounds(140, 123, 200, 30);
|
|
|
indexPanelD.add(serialPort);
|
|
|
|
|
|
- JLabel lblNewLabel_3_1_1_1 = new JLabel("波特率");
|
|
|
+ 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);
|
|
|
@@ -1566,8 +1662,16 @@ public class MesClient extends JFrame {
|
|
|
// }
|
|
|
|
|
|
formatConfigData();
|
|
|
- serialPortUtils.closePort();
|
|
|
- serialPortUtils = new SerialPortUtils(configParam.getSerialPort(),getEffectiveOprno(),configParam.getOprnoTitle(),configParam.getDevice());
|
|
|
+ if (commonQmDevice != null) {
|
|
|
+ commonQmDevice.reconnect();
|
|
|
+ serialPortUtils = commonQmDevice.serialPortUtils;
|
|
|
+ } else {
|
|
|
+ if (serialPortUtils != null) {
|
|
|
+ serialPortUtils.closePort();
|
|
|
+ }
|
|
|
+ commonQmDevice = new CommonQmDevice(configParam);
|
|
|
+ serialPortUtils = commonQmDevice.serialPortUtils;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1622,7 +1726,7 @@ public class MesClient extends JFrame {
|
|
|
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.setModel(new DefaultComboBoxModel(new String[] {"innomatec", "ateq", "INNTAI"}));
|
|
|
device.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
|
// device.setBounds(536, 445, 200, 30);
|
|
|
// device.setBounds(140, 390, 200, 30);
|
|
|
@@ -2019,113 +2123,6 @@ public class MesClient extends JFrame {
|
|
|
MesClient.status_menu.setText(msg);
|
|
|
}
|
|
|
|
|
|
- public static void getMaterailData(){
|
|
|
- try{
|
|
|
- JSONObject retObj = DataUtil.getBindMaterail();
|
|
|
- if(retObj != null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
|
|
|
- int i = 0;
|
|
|
- bindRowData = new Object[arrs.size()][7];
|
|
|
- for (BindMaterialResp bindMaterialResp:arrs){
|
|
|
- bindRowData[i][0] = bindMaterialResp.getMaterialTitle();
|
|
|
- bindRowData[i][1] = bindMaterialResp.getBatchSn();
|
|
|
- bindRowData[i][2] = bindMaterialResp.getLastTimes();
|
|
|
- bindRowData[i][3] = "";
|
|
|
- bindRowData[i][4] = bindMaterialResp.getCraft();
|
|
|
- bindRowData[i][5] = bindMaterialResp.getMaterialId();
|
|
|
- bindRowData[i][6] = bindMaterialResp.getType();
|
|
|
- i++;
|
|
|
- }
|
|
|
- bindBatchPanel();
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void updateMaterailData(){
|
|
|
- try{
|
|
|
- if(bindTable == null || bindRowData == null){
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject retObj = DataUtil.getBindMaterail();
|
|
|
- if(retObj != null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- for (BindMaterialResp bindMaterialResp:arrs){
|
|
|
- if(i >= bindRowData.length){
|
|
|
- break;
|
|
|
- }
|
|
|
- bindRowData[i][0] = bindMaterialResp.getMaterialTitle();
|
|
|
- bindRowData[i][1] = bindMaterialResp.getBatchSn();
|
|
|
- bindRowData[i][2] = bindMaterialResp.getLastTimes();
|
|
|
- bindRowData[i][3] = "";
|
|
|
- bindRowData[i][4] = bindMaterialResp.getCraft();
|
|
|
- bindRowData[i][5] = bindMaterialResp.getMaterialId();
|
|
|
- bindRowData[i][6] = bindMaterialResp.getType();
|
|
|
- i++;
|
|
|
- }
|
|
|
-
|
|
|
- MesClient.bindTable.repaint();
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 绑定物料批次码
|
|
|
- public static void scanBatchSn(BindMaterialResp bindMaterialResp) {
|
|
|
- String scanBarcodeTitle = "请扫物料:"+bindMaterialResp.getMaterialTitle();
|
|
|
- String scanBarcode = JOptionPane.showInputDialog(null, scanBarcodeTitle);
|
|
|
- if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
|
-
|
|
|
- JSONObject retObj = DataUtil.saveBindMaterail(scanBarcode,bindMaterialResp.getCraft(),bindMaterialResp.getMaterialId(),bindMaterialResp.getType());
|
|
|
- if(retObj != null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- MesClient.setMenuStatus("扫物料:"+bindMaterialResp.getMaterialTitle()+"成功",0);
|
|
|
- updateMaterailData();
|
|
|
- }else{
|
|
|
- if(retObj == null || retObj.get("result")==null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- }else{
|
|
|
- if(retObj.get("result").toString().equalsIgnoreCase("false")){
|
|
|
- MesClient.setMenuStatus(retObj.getString("message"),-1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void bindBatchPanel(){
|
|
|
- JPanel indexPanelBB = new JPanel();
|
|
|
- JPanel panel = new JPanel();
|
|
|
- panel.setBounds(0, 0, 990, 550);
|
|
|
- indexPanelBB.add(panel);
|
|
|
-
|
|
|
- panel.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
- bindTable = new JTable(bindRowData, bindColumnNames){
|
|
|
- public boolean isCellEditable(int row, int column) {
|
|
|
- if(column == 3){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- };
|
|
|
- bindTable.setRowHeight(40);
|
|
|
- bindTable.setEnabled(true);
|
|
|
- bindTable.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
-
|
|
|
- bindTable.getColumnModel().getColumn(3).setCellRenderer(new TableCellRendererButton());
|
|
|
- bindTable.getColumnModel().getColumn(3).setCellEditor(new TableCellEditorButton());
|
|
|
-
|
|
|
- JScrollPane scrollPane = new JScrollPane(bindTable);
|
|
|
- panel.add(scrollPane);
|
|
|
-
|
|
|
- JScrollPane indexScrollPaneB = new JScrollPane(indexPanelBB);
|
|
|
- indexPanelBB.setLayout(null);
|
|
|
- tabbedPane.addTab("绑定物料", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexScrollPaneB, null);
|
|
|
- }
|
|
|
-
|
|
|
public static void getTask(){
|
|
|
taskParamList = JdbcUtils.getTask();
|
|
|
System.out.println("taskParamList:"+taskParamList.size());
|
|
|
@@ -2268,7 +2265,7 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static void updateMaterailData(){
|
|
|
try{
|
|
|
- if(materialRowData == null){
|
|
|
+ if(materialTable == null || materialRowData == null){
|
|
|
return;
|
|
|
}
|
|
|
JSONObject retObj = DataUtil.getBindMaterail();
|
|
|
@@ -2280,6 +2277,9 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
int i = 0;
|
|
|
for (BindMaterialResp bindMaterialResp:arrs){
|
|
|
+ if(i >= materialRowData.length){
|
|
|
+ break;
|
|
|
+ }
|
|
|
materialRowData[i][0] = bindMaterialResp.getMaterialTitle();
|
|
|
materialRowData[i][1] = bindMaterialResp.getBatchSn();
|
|
|
materialRowData[i][2] = bindMaterialResp.getLastTimes();
|
|
|
@@ -2290,9 +2290,7 @@ public class MesClient extends JFrame {
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
- if(materialTable != null){
|
|
|
- materialTable.repaint();
|
|
|
- }
|
|
|
+ materialTable.repaint();
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.info(e.getMessage());
|
|
|
@@ -2305,11 +2303,11 @@ public class MesClient extends JFrame {
|
|
|
if(scanBarcode!=null&&!scanBarcode.equalsIgnoreCase("")) {
|
|
|
|
|
|
JSONObject retObj = DataUtil.saveBindMaterail(scanBarcode,bindMaterialResp.getCraft(),bindMaterialResp.getMaterialId(),bindMaterialResp.getType());
|
|
|
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
+ if(retObj != null && retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
MesClient.setMenuStatus("扫物料:"+bindMaterialResp.getMaterialTitle()+"成功",0);
|
|
|
updateMaterailData();
|
|
|
}else{
|
|
|
- if(retObj.get("result")==null){
|
|
|
+ if(retObj == null || retObj.get("result")==null){
|
|
|
MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
}else{
|
|
|
if(retObj.get("result").toString().equalsIgnoreCase("false")){
|