|
|
@@ -120,15 +120,10 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
public static int alarmFlag = 0; // 报警标志
|
|
|
|
|
|
- // OP150寿命
|
|
|
-// public static int[] toolNums = { 1,2,3,4,5,6,7,8,9,10};
|
|
|
-// public static String[] toolTitle = { "合金铣刀", "插刀", "插刀", "合金钻头", "合金钻头", "合金钻头", "合金钻头", "合金铣刀", "切削丝锥", "倒角刀" };
|
|
|
-// public static String[] toolLife = { "122", "", "", "", "", "", "", "", "", "" };
|
|
|
-
|
|
|
- // OP160寿命
|
|
|
- public static int[] toolNums = { 1,2,3,4,5,6,7,8,9};
|
|
|
- public static String[] toolTitle = { "刀杆", "合金铣刀", "合金铣刀", "倒角刀", "合金钻头", "合金钻头", "合金铣刀", "合金插刀", "合金铣刀" };
|
|
|
- public static String[] toolLife = { "", "", "", "", "", "", "", "", "", "" };
|
|
|
+ // OP130寿命
|
|
|
+ public static int[] toolNums = { 1};
|
|
|
+ public static String[] toolTitle = { "D16立铣刀" };
|
|
|
+ public static String[] toolLife = { "" };
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
|
@@ -178,15 +173,13 @@ public class MesClient extends JFrame {
|
|
|
public void run() {
|
|
|
if(work_status == 1){
|
|
|
|
|
|
- if(CommonUtils.formatOprno(mes_gw).equals("OP150")){
|
|
|
- int program = ModbusUitl.getProgram(modbusTcp);
|
|
|
- int program2 = CommonUtils.getProductProgram(product_sn.getText().trim());
|
|
|
- if(program != program2){
|
|
|
- MesClient.setMenuStatus("工件码与程序不匹配",-1);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+// if(CommonUtils.formatOprno(mes_gw).equals("OP150")){
|
|
|
+// int program = ModbusUitl.getProgram(modbusTcp);
|
|
|
+// int program2 = CommonUtils.getProductProgram(product_sn.getText().trim());
|
|
|
+// if(program != program2){
|
|
|
+// MesClient.setMenuStatus("工件码与程序不匹配",-1);
|
|
|
+// }
|
|
|
+// }
|
|
|
ModbusUitl.getParamData(modbusTcp);
|
|
|
}else{
|
|
|
int qdstatus = ModbusUitl.getEnable(modbusTcp);
|
|
|
@@ -1267,162 +1260,4 @@ public class MesClient extends JFrame {
|
|
|
MesClient.status_menu.setText(msg);
|
|
|
}
|
|
|
|
|
|
- public static void getMaterailData(){
|
|
|
- try{
|
|
|
- JSONObject retObj = DataUtil.getBindMaterail();
|
|
|
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- java.util.List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
|
|
|
- int i = 0;
|
|
|
- rowData = new Object[arrs.size()][7];
|
|
|
- for (BindMaterialResp bindMaterialResp:arrs){
|
|
|
- rowData[i][0] = bindMaterialResp.getMaterialTitle();
|
|
|
- rowData[i][1] = bindMaterialResp.getBatchSn();
|
|
|
- rowData[i][2] = bindMaterialResp.getLastTimes();
|
|
|
- rowData[i][3] = "";
|
|
|
- rowData[i][4] = bindMaterialResp.getCraft();
|
|
|
- rowData[i][5] = bindMaterialResp.getMaterialId();
|
|
|
- rowData[i][6] = bindMaterialResp.getType();
|
|
|
- i++;
|
|
|
- }
|
|
|
- bindBatchPanel();
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void updateMaterailData(){
|
|
|
- try{
|
|
|
- JSONObject retObj = DataUtil.getBindMaterail();
|
|
|
- if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- List<BindMaterialResp> arrs = retObj.getList("data",BindMaterialResp.class);
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- for (BindMaterialResp bindMaterialResp:arrs){
|
|
|
- rowData[i][0] = bindMaterialResp.getMaterialTitle();
|
|
|
- rowData[i][1] = bindMaterialResp.getBatchSn();
|
|
|
- rowData[i][2] = bindMaterialResp.getLastTimes();
|
|
|
- rowData[i][3] = "";
|
|
|
- rowData[i][4] = bindMaterialResp.getCraft();
|
|
|
- rowData[i][5] = bindMaterialResp.getMaterialId();
|
|
|
- rowData[i][6] = bindMaterialResp.getType();
|
|
|
- i++;
|
|
|
- }
|
|
|
-
|
|
|
- MesClient.table.repaint();
|
|
|
- }
|
|
|
- }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.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
- MesClient.setMenuStatus("扫物料:"+bindMaterialResp.getMaterialTitle()+"成功",0);
|
|
|
- updateMaterailData();
|
|
|
- }else{
|
|
|
- if(retObj.get("result")==null){
|
|
|
- MesClient.setMenuStatus("请求失败,请重试",-1);
|
|
|
- }else{
|
|
|
- if(retObj.get("result").toString().equalsIgnoreCase("false")){
|
|
|
- MesClient.setMenuStatus(retObj.getString("message"),-1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void bindBatchPanel(){
|
|
|
- JPanel indexPanelBB = new JPanel();
|
|
|
- JPanel panel = new JPanel();
|
|
|
- panel.setBounds(0, 0, 990, 550);
|
|
|
-// panel.setBounds(81, 50, 810, 479);
|
|
|
- indexPanelBB.add(panel);
|
|
|
-
|
|
|
- panel.setLayout(new GridLayout(0, 1, 0, 0));
|
|
|
- table = new JTable(rowData, columnNames){
|
|
|
- public boolean isCellEditable(int row, int column) {
|
|
|
- if(column == 3){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- };
|
|
|
- table.setRowHeight(40);
|
|
|
- table.setEnabled(true);
|
|
|
- table.setFont(new Font("微软雅黑", Font.PLAIN, 14));
|
|
|
-
|
|
|
- table.getColumnModel().getColumn(3).setCellRenderer(new TableCellRendererButton());
|
|
|
- table.getColumnModel().getColumn(3).setCellEditor(new TableCellEditorButton());
|
|
|
-
|
|
|
-
|
|
|
- JScrollPane scrollPane = new JScrollPane(table);
|
|
|
- panel.add(scrollPane);
|
|
|
-
|
|
|
- JScrollPane indexScrollPaneB = new JScrollPane(indexPanelBB);
|
|
|
- indexPanelBB.setLayout(null);
|
|
|
- tabbedPane.addTab("绑定物料", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), indexScrollPaneB, null);
|
|
|
- }
|
|
|
-
|
|
|
- // 开启发送结果定时任务
|
|
|
- public static void startUpdateQualityTimer(){
|
|
|
- // 创建异步线程池
|
|
|
- ExecutorService executorService = Executors.newSingleThreadExecutor();
|
|
|
- // 提交任务
|
|
|
- executorService.submit(() -> {
|
|
|
- log.info("异步任务执行中...");
|
|
|
- // 模拟耗时操作
|
|
|
- try {
|
|
|
- while (true){
|
|
|
- try {
|
|
|
- // 确保连接已经打开
|
|
|
- if (JdbcUtils.conn == null || JdbcUtils.conn.isClosed()) {
|
|
|
- JdbcUtils.openConnection();
|
|
|
- }
|
|
|
-
|
|
|
- Statement statement = JdbcUtils.conn.createStatement();
|
|
|
- String selectSql = "SELECT id, bw FROM submit_record\n" +
|
|
|
- "WHERE state = 0 ORDER BY id DESC LIMIT 10";
|
|
|
- String updateSql = "UPDATE submit_record \n" +
|
|
|
- "SET state = '1'\n" +
|
|
|
- "WHERE id = ";
|
|
|
- ResultSet rs = statement.executeQuery(selectSql);
|
|
|
- while(rs.next()){
|
|
|
- int id = rs.getInt("id");
|
|
|
- String bw = rs.getString("bw");
|
|
|
- // 发送请求
|
|
|
- String url = "http://"+MesClient.mes_server_ip+":8980/js/a/mes/mesProductRecord/updateQualityByTiming";
|
|
|
- log.info("质量:"+bw);
|
|
|
- String s = HttpUtils.sendPostRequestJson(url, bw );
|
|
|
- log.info("结果:"+s);
|
|
|
- Boolean result = JSONObject.parseObject(s).getBoolean("result");
|
|
|
- if(result) {
|
|
|
- // 更改状态为 1
|
|
|
- statement.executeUpdate(updateSql + id);
|
|
|
- }
|
|
|
- }
|
|
|
- rs.close();
|
|
|
- statement.close();
|
|
|
- } catch (Exception e) {
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- try {
|
|
|
- Thread.sleep(2000);
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.info(e.getMessage());
|
|
|
- }
|
|
|
- log.info("异步任务执行完毕");
|
|
|
- });
|
|
|
- }
|
|
|
}
|