wu
2024-10-11 6ad80ed766ca364fae07a98fd8f42086c9b0aecd
springboot-vue3/src/main/java/com/example/springboot/service/SpianServiceNew.java
@@ -24,11 +24,13 @@
        //有进片请求但是测量台没有玻璃
        return 400;
    }
    System.out.println(glassInfo+"初始");
    //定义初始字段
    StorageCage cage;
    String glassid=glassInfo.getGlassid();
    Double width=glassInfo.getWidth();
    //int mateid=glassInfo.getMateid();
    Double height=glassInfo.getHeight();
    String flowcard=glassInfo.getFlowcard();
    int glasstype=glassInfo.getGlasstype();
    //判断是否有同类型的
@@ -37,29 +39,30 @@
    //如果有同类型时直接增加
    if(cage!=null){
        //发送plc任务
        Mestast(glassid, 40, cage.getId(), 1,"MESID1",1);
        //任务发送字
        Mestast(glassid, 1001, cage.getId(), 1,"MESID1",1);
        
    }else{ 
         //判断玻璃是否进入大片笼
         if(glassInfo.getThickness()>=15){
            cage=albaniaMapper.SelectNewCell(3,5);
        }else{
            cage=albaniaMapper.SelectNewCell(0,5);
            //发送plc任务
            cage=albaniaMapper.SelectNewCell(0,4);
            System.out.println(cage+"理片笼判断");
        }
        //当返回的格子号为空时,返回400笼子已满
        if(cage!=null){
            albaniaMapper.AddCage(cage.getId(), glassid, cage.getGlassWidth(), cage.getGlassHeight(), cage.getGlassWidthMm(), cage.getGlassHeightMm(), 1, cage.getGlasstype(), 0);
            albaniaMapper.AddCage(cage.getId(), glassid,width, height, 1, glasstype, 0);
            Mestast(glassid,1001,cage.getId(),1,"MESID1",1);
            //发送plc任务
            albaniaMapper.UpdateStorage(width,height,cage.getId());
            System.out.println(cage+"任务发送");
        }else{
            return(400);
        }
    }
    //增加任务记录
    albaniaMapper.Inserttask(0, 0, 1001, cage.getId(), glassid,glasstype, flowcard,0,0);
    albaniaMapper.UpdateQueueState(glassid);
    return(200);
}
@@ -69,6 +72,7 @@
        GlassInfo glassmate=new GlassInfo();
        GlassInfo method=new GlassInfo();
        StorageCage glass=new StorageCage();
        int glassend=0;
        method=albaniaMapper.SelectMethod(line);
        double width=0;
            for(int i=1;i<=7;i++){
@@ -78,6 +82,8 @@
                }else{
                    //直通模式时按顺序直出
                    glassmate= albaniaMapper.SelectOutGlass2(line);
                    //获取直通模式最后一块
                    glassend=albaniaMapper.SelectOutGlassend(line);
                }
                
                if(glassmate==null){ 
@@ -85,26 +91,26 @@
                    return (400);
                }else{
                    
                    glass= albaniaMapper.SelectCageGlass(glassmate.getGlasstype());
                  if(glass!=null){
                glass= albaniaMapper.SelectCageGlass(glassmate.getGlasstype());
                  if(glass!=null){
                    //发送任务之前判断车上的剩余宽度是否大于此玻璃
                    width+=glassmate.getWidth()+50;
                    width=width+glassmate.getWidth()+50;
                    //大于车上空余宽度时提前发送出片启动
                    if(width>5000){
                        //本次配片完成发送启动命令
                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//出片任务启动
                        return (200);//结束
                      }
                    //发送配片数据
                    Mestast(glass.getGlassId(), glass.getId(),7, 0,"MESID"+i,i);
                    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());
                      if(glassmate.getTier()==glassmate.getId()){//当配片数量等于成品小片总片数时
                      if(glassmate.getTier()==glassmate.getId()||glassmate.getTier()==glassend){//当配片数量等于成品小片总片数时
                        //本次配片完成发送启动命令
                        S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToPLC").getAddress(), (short)1);//出片任务启动
                        return (200);//结束
                      }
                      
                    }else{
                        return (400);//结束
@@ -131,9 +137,6 @@
        System.out.println("outmesidbytes:" + bytes.length);
        System.out.println(plcmes.getPlcParameter(address).getAddress());
        System.out.println();
        //S7control.getinstance().WriteByte(plcmes.getPlcParameter(address).getAddress(),bytes);
        //S7control.getinstance().WriteByte(address, bytes);// 派发出片id
    }