wuyouming666
2024-05-06 3dc8dcf5854bb90b9d5fb07ab449053ed6a361ae
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/downstorage/service/impl/DownStorageCageServiceImpl.java
@@ -1,5 +1,6 @@
package com.mes.downstorage.service.impl;
import com.github.yulichang.toolkit.JoinWrappers;
import com.mes.common.PLCAutoMes;
import com.mes.common.S7control;
import com.mes.device.PlcParameterObject;
@@ -19,6 +20,7 @@
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -65,11 +67,11 @@
    public DownGlassTask createDownGlassTask(GlassInfo glassInfo, String startCell, String endCell,String taskType ) {
        DownGlassTask downGlassTask = new DownGlassTask();
        BeanUtils.copyProperties(downGlassTask,glassInfo);
        BeanUtils.copyProperties(glassInfo,downGlassTask);
        downGlassTask.setStartCell(startCell);
       downGlassTask.setTaskType(taskType);
      downGlassTask.setEndCell(endCell);
@@ -80,7 +82,7 @@
    public DownGlassTask createDownGlassTask(DownStorageCageDetails glassInfo, String startCell, String endCell,String taskType ) {
        DownGlassTask downGlassTask = new DownGlassTask();
        BeanUtils.copyProperties(downGlassTask,glassInfo);
        BeanUtils.copyProperties(glassInfo,downGlassTask);
        downGlassTask.setStartCell(startCell);
        downGlassTask.setTaskType(taskType);
        downGlassTask.setEndCell(endCell);
@@ -97,13 +99,13 @@
        //存在此玻璃编号
        if (GlassInfo != null) {
            //同找到同流程卡附近空格
            List<DownStorageCageDetails> list = downStorageCageDetailsService.getIsExistIntoCacheByflowcardid(GlassInfo.getFlowcardId(),  GlassInfo.getWidth());
            List<DownStorageCageDetails> list = selectCacheEmpty();
            List<DownStorageCageDetails> selectCacheEmpty=downStorageCageDetailsService.selectCacheEmpty2();
            //            list<Map> list=selectCacheEmpty();
//            list<Map> = downStorageCageService.selectCacheEmpty();
            if (selectCacheEmpty.size() > 0) {
            if (list.size() > 0) {
                //存在空格
                //1.生成任务:  起始位置0   结束位置this.slot  任务类型 1   (进片任务)
                //2.回复 1进片
@@ -115,7 +117,7 @@
                downGlassTaskService.insertCacheTask(downGlassTask);
               S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1);
               //S7control.getinstance().WriteWord(plcmes.getPlcParameter("MESToGaStatus").getAddress(), (short) 1);
                //完成后插入小片数据到缓存表
@@ -159,13 +161,13 @@
                String endcell = "13";
                String SendEndcell = "1";
//                selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId());
                DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2");
                downGlassTaskService.insertCacheTask(downGlassTask);
                S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell);
                S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
           //  S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.28").getAddress(), SendEndcell);
               // S7control.getinstance().writeString(plcmes.getPlcParameter("DB14.20").getAddress(), "1");
                return true;
            }
        }
@@ -177,7 +179,7 @@
            DownStorageCageDetails item3 = list2.get(0);
            String endcell = "11";
            String SendEndcell = "1";
            // selectInfo.insertCacheTask(item3.getGlassId() + "", "0", endcell, "2", item3.getWidth(), item3.getHeight(), item3.getFilmsid(), item3.getThickness(), item3.getFlowCardId());
            DownGlassTask downGlassTask =createDownGlassTask(item3,"0",endcell,"2");
            downGlassTaskService.insertCacheTask(downGlassTask);
@@ -191,7 +193,7 @@
            DownStorageCageDetails item = list.get(0);
            // 出到 G06
            //selectInfo.insertCacheTask(item.getGlassId() + "", "0", "06", "2", item.getWidth(), item.getHeight(), item.getFilmsid(), item.getThickness(), item.getFlowCardId());
            DownGlassTask downGlassTask =createDownGlassTask(item,"0","06","2");
            downGlassTaskService.insertCacheTask(downGlassTask);
@@ -204,7 +206,7 @@
            DownStorageCageDetails item2 = list2.get(0);
            // 出到 G11
            // selectInfo.insertCacheTask(item2.getGlassId() + "", "0", "11", "2", item2.getWidth(), item2.getHeight(), item2.getFilmsid(), item2.getThickness(), item2.getFlowCardId());
            DownGlassTask downGlassTask =createDownGlassTask(item2,"0","11","2");
            downGlassTaskService.insertCacheTask(downGlassTask);
@@ -222,8 +224,17 @@
    }
    @Override
    public List<DownStorageCageDetails> selectCacheEmpty() {
        return baseMapper.selectJoinList(DownStorageCageDetails.class,
                JoinWrappers.lambda(DownStorageCage.class)
                        .selectAll(DownStorageCage.class)
                        .select(DownStorageCageDetails::getWidth, DownStorageCageDetails::getHeight, DownStorageCageDetails::getGlassId)
                        .leftJoin(DownStorageCageDetails.class, on -> on
                                .eq(DownStorageCageDetails::getDeviceId, DownStorageCage::getDeviceId)
                                .eq(DownStorageCageDetails::getSlot, DownStorageCage::getSlot))
                        .isNull(DownStorageCageDetails::getSlot)
        );
    }
}