wu
2024-10-26 328f9b1f7a046378ef5d8f2b8337770fff372cc7
springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
@@ -34,12 +34,13 @@
    String flowcard=glassInfo.getFlowcard();
    int glasstype=glassInfo.getGlasstype();
    //判断是否有同类型的
    cage=albaniaMapper.SelectCage(glasstype,width, 50);
    cage=albaniaMapper.SelectCage(glasstype,width, 300);
     
    //如果有同类型时直接增加
    if(cage!=null){
        //发送plc任务
        Mestast(glassid, 1001, cage.getId(), 1,"MESID1",1);
        System.out.println("任务发送玻璃id:"+glassid+"起始位置:"+1001+"格子号:"+cage.getId()+"启动:"+1);
        
    }else{ 
         //判断玻璃是否进入大片笼
@@ -54,8 +55,8 @@
        if(cage!=null){
            albaniaMapper.AddCage(cage.getId(), glassid,width, height, 1, glasstype, 0);
            Mestast(glassid,1001,cage.getId(),1,"MESID1",1);
            System.out.println("任务发送玻璃id:"+glassid+"起始位置:"+1001+"格子号:"+cage.getId()+"启动:"+1);
            albaniaMapper.UpdateStorage(width,height,cage.getId());
            System.out.println(cage+"任务发送");
        }else{
            return(400);
        }
@@ -74,27 +75,33 @@
        StorageCage glass=new StorageCage();
        int glassend=0;
        method=albaniaMapper.SelectMethod(line);
        if(method==null){
            return (400);
        }
        double width=0;
            for(int i=1;i<=7;i++){
                //如果不是直通模式只出有完整配片的流程卡
                if(method.getMethod()==0){
                    glassmate= albaniaMapper.SelectOutGlass(line);
                    glassmate= albaniaMapper.SelectOutGlass(1);
                }else{
                    //直通模式时按顺序直出
                    glassmate= albaniaMapper.SelectOutGlass2(line);
                    glassmate= albaniaMapper.SelectOutGlass2(1);
                    //获取直通模式最后一块
                    glassend=albaniaMapper.SelectOutGlassend(line);
                    glassend=albaniaMapper.SelectOutGlassend(1);
                }
                System.err.println("method:"+method+"glassmate:"+glassmate);
                System.err.println(line);
                if(glassmate==null){ 
                    //未领取任务
                    System.out.println("未领取任务");
                    return (400);
                }else{
                glass= albaniaMapper.SelectCageGlass(glassmate.getGlasstype()); 
                System.out.println("glassmate:"+glassmate+"glassend:"+glassend+"glass:"+glass);
                  if(glass!=null){  
                    //发送任务之前判断车上的剩余宽度是否大于此玻璃
                    width=width+glassmate.getWidth()+50;
                    width=width+glassmate.getWidth()+300;
                    //大于车上空余宽度时提前发送出片启动
                    if(width>5000){
                        //本次配片完成发送启动命令
@@ -104,10 +111,11 @@
                    //发送配片数据
                    Mestast(glass.getGlassId(), glass.getId(),40, 0,"MESID"+i,i);
                    albaniaMapper.AddFinishNumber(glassmate.getFlowcard(), glassmate.getMateid(), glassmate.getTier());
                    albaniaMapper.Inserttask(1, 0, glass.getId(), 2002, glassmate.getGlassid(), glassmate.getGlasstype(),glass.getFlowcard(),glassmate.getMateid(),glassmate.getTier());
                    albaniaMapper.Inserttask(1, 0, glass.getId(), 2001, glassmate.getGlassid(), glassmate.getGlasstype(),glass.getFlowcard(),glassmate.getMateid(),glassmate.getTier());
                      if(glassmate.getTier()==glassmate.getId()||glassmate.getTier()==glassend){//当配片数量等于成品小片总片数时
                        //本次配片完成发送启动命令
                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//出片任务启动
                        System.out.println("任务类型:1,任务状态:0,起始:"+glass.getId()+",目标"+"40");
                        return (200);//结束
                      }
                     
@@ -181,6 +189,13 @@
            S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)MESToPLC);//mes理片任务类型
        }    
    }
    // 扫码增加队列任务
    public boolean scan(String address) {
        List<Short> list = S7control.getinstance().ReadWord(address, 1);// 返回为ture时为1
        boolean listbool = list.contains((short) 1);
        return listbool;
    }
}