wu
2024-03-25 202ca0f62257d108e95ca2e5912b86cf7b407906
springboot-vue3/src/main/java/com/example/springboot/component/PlcHoldNew.java
@@ -1,17 +1,25 @@
package com.example.springboot.component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.example.springboot.service.JdbcConnections;
import com.example.springboot.service.SpianServiceNew;
import com.example.springboot.service.StorageCageService;
import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.entity.device.PlcParameterObject;
import com.example.springboot.mapper.AlarmMapper;
import com.example.springboot.mapper.AlbaniaMapper;
import com.example.springboot.mapper.SpianMapper;
public class PlcHoldNew extends Thread {
  private AlarmMapper alarmMapper;
  @Autowired
  private JdbcConnections jdbcConnections;
  private AlbaniaMapper albaniaMapper;
  private SpianServiceNew spianService;
  private StorageCageService storageCageService;
  int aaa;
  @Override
@@ -26,11 +34,9 @@
        e.printStackTrace();
      }
    
      //S7control.getinstance().ReadWord("DB14.0", 1);
      // if (S7control.getinstance().CheckConnected() == false) {
      spianService = WebSocketServer.applicationContext.getBean(SpianServiceNew.class);
      albaniaMapper = WebSocketServer.applicationContext.getBean(AlbaniaMapper.class);
      spianService.selectAll(albaniaMapper.SelectGlass());
      //spianService.selectAll(albaniaMapper.SelectGlass());
      //读取DB14区文件
      PlcParameterObject plcmes=PLCAutoMes.PlcMesObject;
      
@@ -43,21 +49,22 @@
  
      
      //一号线请求
      if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) {
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        spianService.selectout(1);
      }
      //二线号请求时
      if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) {
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        spianService.selectout(2);
      }
      // if (ExportTOMES1.equals("1") == true&&B01State.equals("0")==true) {
      //   //将运输车状态改为忙碌
      //   S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
      //   spianService.selectout(1);
      // }
      // //二线号请求时
      // if (ExportToMES2.equals("1") == true&&B01State.equals("0")==true) {
      //   //将运输车状态改为忙碌
      //   S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
      //   spianService.selectout(2);
      // }
      //进片请求时
      if(PLCToMES!=null && B01State!=null){
      if(PLCToMES.equals("1")==true&&B01State.equals("0")==true){
        //将运输车状态改为忙碌
        S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        //S7control.getinstance().WriteWord(plcmes.getPlcParameter("B01report").getAddress(), (short) 1);
        
        spianService.selectAll(albaniaMapper.SelectGlass());
      }
@@ -68,17 +75,16 @@
        
        //完成确认字
        for(int i=1;i<7;i++){
          String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//依次获取任务ID
            int tastid=albaniaMapper.SelectTaskId(Glassid.substring(0,14));
          String Tastover=plcmes.getPlcParameter("IDStatus"+i).getValue();//依次获取任务类型
          String Glassid=plcmes.getPlcParameter("MESID"+i).getValue();//依次获取任务类型
          if(Tastover.equals("1")){
            //调用完成任务 Glassid
            storageCageService.FinishTask(tastid);
            //删除queue表的数据
            albaniaMapper.DeleteQueue(Glassid.substring(0,14));
            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLCStatus"+i).getAddress(), (short) 1);//完成确认字
        }
      }
      }
    }
  
      // 查询数据库
      // 推送到前端