hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageHollowTask.java
@@ -4,18 +4,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.kangaroohy.milo.model.ReadWriteEntity;
import com.kangaroohy.milo.service.MiloService;
import com.mes.base.entity.BigStorageCageBaseInfo;
import com.mes.bigstorage.entity.BigStorageCage;
import com.mes.bigstorage.entity.BigStorageCageDetails;
import com.mes.bigstorage.entity.BigStorageDTO;
import com.mes.bigstorage.entity.dto.BigStorageDTO;
import com.mes.bigstorage.entity.dto.SlotSequenceDTO;
import com.mes.bigstorage.entity.dto.TemperingLayoutDTO;
import com.mes.bigstorage.service.BigStorageCageDetailsService;
import com.mes.bigstorage.service.BigStorageCageService;
import com.mes.bigstorage.service.BigStorageGlassInfoService;
import com.mes.bigstoragecagetask.entity.BigStorageCageHistoryTask;
import com.mes.bigstoragecagetask.entity.BigStorageCageTask;
import com.mes.bigstoragecagetask.service.BigStorageCageHistoryTaskService;
@@ -26,10 +25,9 @@
import com.mes.damage.service.DamageService;
import com.mes.glassinfo.entity.GlassInfo;
import com.mes.glassinfo.service.GlassInfoService;
import com.mes.hollow.service.BigStorageCageHollowDetailsService;
import com.mes.hollow.service.BigStorageCageHollowService;
import com.mes.temperingglass.entity.TemperingGlass;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.temperingglass.service.TemperingGlassService;
import com.mes.hollow.service.HollowGlassInfoService;
import com.mes.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -53,8 +51,8 @@
    @Resource
    private BigStorageCageHollowDetailsService bigStorageCageHollowDetailsService;
    @Resource
    private TemperingGlassService temperingGlassService;
    //    @Resource
//    private TemperingGlassService temperingGlassService;
    @Resource
    private DamageService damageService;
    @Resource
@@ -65,6 +63,8 @@
    private BigStorageCageHollowService bigStorageCageHollowService;
    @Resource
    private BigStorageCageHistoryTaskService bigStorageCageHistoryTaskService;
    @Resource
    private BigStorageGlassInfoService bigStorageGlassInfoService;
    @Resource
    private BigStorageCageTaskService bigStorageCageTaskService;
    @Autowired(required = false)
@@ -87,6 +87,18 @@
    @Value("${mes.sequence.order}")
    private boolean sequenceOrder;
    @Resource
    HollowGlassInfoService hollowGlassInfoService;
    //    @Scheduled(fixedDelay = 1000)
    public void test() {
        hollowGlassInfoService.queryHollowTargetSlot("P24111201|2|20");
    }
    //    @Scheduled(fixedDelay = 1000)
    public void test1() {
        bigStorageGlassInfoService.queryBigStorageTargetSlot("P24111201|2|20");
    }
    public void inBigStorageTask() throws Exception {
        ReadWriteEntity inkageEntity = miloService.readFromOpcUa("DLP2A.DLP2A.mesControl");
@@ -109,6 +121,9 @@
        if (CollectionUtils.isEmpty(inTaskList)) {
            log.info("当前大车无进片玻璃,结束进片任务");
        }
        //todo:去中空队列表中查询玻璃信息是否存在
        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, inTaskList.get(0).getGlassId()));
        //todo:
        List<String> glassIdList = inTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList());
        log.info("获取任务的玻璃id:{}", glassIdList);
        List<GlassInfo> glassInfoList = glassInfoService.list(new LambdaQueryWrapper<GlassInfo>().in(GlassInfo::getGlassId, glassIdList));
@@ -172,49 +187,9 @@
        }
        //todo:是否允许钢化
        if (redisUtil.getCacheObject("temperingSwitch")) {
            //是否有正在钢化的玻璃:钢化小片表关联历史任务表,筛选未出笼的玻璃信息
            List<TemperingGlass> temperingGlassList = temperingGlassService.selectJoinList(TemperingGlass.class, new MPJLambdaWrapper<TemperingGlass>()
                    .selectAll(TemperingGlass.class)
                    .leftJoin(BigStorageCageHistoryTask.class, BigStorageCageHistoryTask::getGlassId, TemperingGlass::getGlassId)
                    .eq(TemperingGlass::getState, Const.TEMPERING_NEW)
                    .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_OUT)
                    .isNull(BigStorageCageHistoryTask::getGlassId)
                    .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlass::getTemperingFeedSequence));
            //todo:历史任务表
            if (CollectionUtils.isNotEmpty(temperingGlassList)) {
                log.info("有正在出片的钢化任务");
                computeOutGlassInfo(temperingGlassList, "big_storage_cage_out_two_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
                Date endDate = new Date();
                log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
                return;
            }
            //钢化优先:获取理片笼  玻璃小片  破损表 数量   判断笼内版图是否到齐
            List<TemperingLayoutDTO> temperingLayoutDTOList = bigStorageCageDetailsService.temperingIsAll();
            if (CollectionUtils.isNotEmpty(temperingLayoutDTOList)) {
                //玻璃到齐包括已出片的
                //到齐,将玻璃小片数据存入钢化小片表,逻辑生成出片任务  结束
                for (TemperingLayoutDTO item : temperingLayoutDTOList) {
//                    if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) {
                    List<TemperingGlass> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlass.class, JoinWrappers.lambda(GlassInfo.class)
                            .selectAll(GlassInfo.class)
                            .select("-1 as state")
                            .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot)
                            .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId)
                            .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                            .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId())
                            .eq(GlassInfo::getEngineerId, item.getEngineerId())
                            .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence));
                    if (CollectionUtils.isNotEmpty(temperingGlassInfos)) {
                        temperingGlassService.saveBatch(temperingGlassInfos);
                        computeOutGlassInfo(temperingGlassInfos, "big_storage_cage_out_two_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
                        Date endDate = new Date();
                        log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
                        return;
                    }
//                    }
                }
            }
        }
        //是否有人工下片任务   有直接出
        List<BigStorageCageDetails> artificialList = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
                .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
@@ -226,6 +201,7 @@
            log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
            return;
        }
        //是否存在需要内部调度的格子:执行内部调度任务
        List<TemperingLayoutDTO> temperingOccupySlotList = bigStorageCageDetailsService.queryTemperingOccupySlot();
        if (CollectionUtils.isNotEmpty(temperingOccupySlotList)) {
@@ -252,6 +228,7 @@
                }
            }
        }
        Date endDate = new Date();
        log.info("大理片笼出片任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
        return;