hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageNewTask.java
@@ -141,6 +141,11 @@
            return;
        }
        log.info("获取任务的玻璃id:{}", glassIdList);
        ReadWriteEntity countEntity = miloService.readFromOpcUa("DLP1A.DLP1A.glassCount");
        if (null == countEntity.getValue() || Integer.parseInt(countEntity.getValue() + "") != glassIdList.size()) {
            log.info("当前大车进片玻璃数量{}与mes读取到的数量{}不匹配,结束进片任务", countEntity.getValue(), glassIdList.size());
            return;
        }
        Map<String, Long> glassCountMap = glassIdList.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()));
        for (Map.Entry<String, Long> entry : glassCountMap.entrySet()) {
            if (entry.getValue() > 1) {
@@ -165,19 +170,21 @@
        }
        //按照玻璃厚度分组,判断剩余格子是否可以存放
        Map<Double, Long> thickCountMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getThickness, Collectors.counting()));
        for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) {
            int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>()
                    .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth)
                    .le(BigStorageCage::getMinThickness, entry.getKey())
                    .ge(BigStorageCage::getMaxThickness, entry.getKey()));
            if (count < entry.getValue()) {
                log.info("笼内格子剩余数量不足,结束本次进片");
                //todo:向plc发送报警
                return;
        if (glassInfoList.get(0).getThickness() < slotMaxthickness) {
            for (Map.Entry<Double, Long> entry : thickCountMap.entrySet()) {
                int count = bigStorageCageService.count(new LambdaQueryWrapper<BigStorageCage>()
                        .eq(BigStorageCage::getEnableState, Const.SLOT_ON).eq(BigStorageCage::getRemainWidth, slotWidth)
                        .le(BigStorageCage::getMinThickness, entry.getKey())
                        .ge(BigStorageCage::getMaxThickness, entry.getKey()));
                if (count < entry.getValue()) {
                    log.info("笼内格子剩余数量不足,结束本次进片");
                    //todo:向plc发送报警
                    return;
                }
            }
        }
        //todo:超大尺寸
        if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() > slotMaxthickness) {
        if (slotMaxHeight < Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) || glassInfoList.get(0).getThickness() >= slotMaxthickness) {
            int count = bigStorageCageDetailsService.count(new LambdaQueryWrapper<BigStorageCageDetails>()
                    .eq(BigStorageCageDetails::getSlot, THROUGH_SLOT)
                    .in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL));
@@ -193,14 +200,14 @@
                .set(EdgGlassTaskInfo::getState, Const.EDG_GLASS_SUCCESS).in(EdgGlassTaskInfo::getGlassId, glassIdList));
        //报工
        for (String glass : glassIdList) {
            damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "磨边", "进大理片笼");
            damageService.autoSubmitReport(glass, inTaskList.get(0).getStartSlot(), "磨边", "进大理片笼", 1);
        }
        Map<String, List<GlassInfo>> glassListMap = glassInfoList.stream().collect(Collectors.groupingBy(GlassInfo::getGlassId));
        //计算目标格子
        List<BigStorageCageHistoryTask> historyTasks = new ArrayList<>();
        //超大尺寸与正常尺寸玻璃计算方式不一样
        if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight())) {
        if (slotMaxHeight > Math.min(glassInfoList.get(0).getWidth(), glassInfoList.get(0).getHeight()) && glassInfoList.get(0).getThickness() < slotMaxthickness) {
            for (BigStorageCageTask task : inTaskList) {
                GlassInfo info = glassListMap.get(task.getGlassId()).get(0);
                BigStorageDTO bigStorageDTO = bigStorageGlassInfoService.queryBigStorageTargetSlot(info.getEngineerId(), info.getTemperingLayoutId(), info.getTemperingFeedSequence());
@@ -226,6 +233,7 @@
                cageDetails.setState(Const.GLASS_STATE_NEW);
                cageDetails.setDeviceId(bigStorageDTO.getDeviceId());
                cageDetails.setSequence(bigStorageDTO.getSlotSequence());
                cageDetails.setAngle((int) info.getAngle());
                cageDetails.setGap(glassGap);
                cageDetails.setFilmsId(info.getFilmsid());
                cageDetails.setId(null);
@@ -250,6 +258,7 @@
            cageDetails.setDeviceId(0);
            cageDetails.setSequence(0);
            cageDetails.setGap(glassGap);
            cageDetails.setAngle((int) info.getAngle());
            cageDetails.setFilmsId(info.getFilmsid());
            cageDetails.setId(null);
            bigStorageCageDetailsService.save(cageDetails);
@@ -288,7 +297,7 @@
        //是否有正在钢化的玻璃:钢化小片表关联历史任务表,筛选未出笼的玻璃信息
//            获取当前钢化任务未完成出片的玻璃信息
        List<TemperingGlassInfo> unFinishTemperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>()
                .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW).orderByAsc(TemperingGlassInfo::getTemperingFeedSequence));
                .eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW).orderByAsc(TemperingGlassInfo::getTemperingLayoutId).orderByAsc(TemperingGlassInfo::getTemperingFeedSequence));
        if (CollectionUtil.isNotEmpty(unFinishTemperingGlassInfoList)) {
            log.info("有正在出片的钢化任务");
            computeOutGlassInfoByVirtualSlot(unFinishTemperingGlassInfoList, "big_storage_cage_out_one_task", temperingOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
@@ -318,9 +327,9 @@
                for (TemperingLayoutDTO item : temperingLayoutDTOList) {
//                    if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) {
                    List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class)
                            .selectAll(GlassInfo.class)
                            .select("-1 as state")
                            .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot)
                            .select("-1 as state,t.filmsid as films_id,t.glass_id,t.flow_card_id,t.glass_type,t.width,t.height" +
                                    ",t.thickness,t.ishorizontal,t.tempering_layout_id,t.tempering_feed_sequence,t.x_coordinate,t.y_coordinate," +
                                    "t.angle,t1.slot,t.engineer_id")
                            .innerJoin(BigStorageCageDetails.class, BigStorageCageDetails::getGlassId, GlassInfo::getGlassId)
                            .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                            .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId())
@@ -532,7 +541,7 @@
                    bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_OUT);
                } else {
                    bigStorageCageDetailsService.updateBySlot(storageCageDTOList, Const.GLASS_STATE_IN);
                    //todo:按照格子信息更新对应的设备id
                    //按照格子信息更新对应的设备id
                    List<Integer> slotList = storageCageDTOList.stream().map(UpdateBigStorageCageDTO::getTargetSlot).distinct().collect(Collectors.toList());
                    bigStorageCageDetailsService.updateDeviceIdBySlot(slotList);
@@ -685,9 +694,18 @@
     */
    private <T extends BigStorageCageBaseInfo> Boolean computeOutGlassInfoByVirtualSlot(List<T> list, String tableName, int targetSlot, int state, int taskType) {
        //任务数据:获取车子存放玻璃最大数量,玻璃间隔
        List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId(
                list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence());
        List<T> outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList());
        List<T> outGlassList = list;
        if (!THROUGH_SLOT.equals(list.get(0).getSlot())) {
            //todo:临时解决方案:出片时考虑玻璃碰撞,改为一片一出
            // 界面关闭调度开关 !Const.BIG_STORAGE_BEFORE_DISPATCH.equals(taskType)
            if (list.get(0).getThickness() >= 8) {
                outGlassList = list.subList(0, 1);
            } else {
                List<String> glassIdList = bigStorageGlassRelationInfoService.queryNeedOutGlassId(
                        list.get(0).getEngineerId(), list.get(0).getTemperingLayoutId(), list.get(0).getTemperingFeedSequence());
                outGlassList = list.stream().filter(e -> glassIdList.contains(e.getGlassId())).collect(Collectors.toList());
            }
        }
        Assert.isFalse(CollectionUtil.isEmpty(outGlassList), "未获取出片数据,结束出片任务");
        log.info("获取出片任务数据{}条,执行保存", outGlassList.size());
        List<BigStorageCageTask> bigStorageCageTaskList = outGlassList.stream()