hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -81,7 +81,6 @@
    @Scheduled(fixedDelay = 300)
    @Async
    public void plcHomeEdgTask() {
        PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue();
@@ -98,7 +97,6 @@
        log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:g06:{}、g08:{}、g11:{}、g13:{},当前格子号为:{}",
                requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot);
        if ("0".equals(requestWord)) {
            if ("0".equals(confirmationWrodValue)) {
                log.info("2、获取到的请求字为0,且确认字为0,不执行任务");
@@ -131,18 +129,18 @@
    }
    @Scheduled(fixedDelay = 300)
    @Async
    public void plcShelfFull() {
        List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull();
        S7control s7control = S7object.getinstance().plccontrol;
        PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
        if (CollectionUtils.isNotEmpty(list)) {
            S7control s7control = S7object.getinstance().plccontrol;
            PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
            s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1);
        }else{
            s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 0);
        }
    }
    @Scheduled(fixedDelay = 1000)
    @Async
    public void dealDamageTask() {
        Date startDate = new Date();
        log.info("下片破损玻璃清除任务开始执行时间:{}", startDate);
@@ -187,7 +185,6 @@
     * 更新已绑定工位流程卡的破损/拿走的数量信息
     */
    @Scheduled(fixedDelay = 1000)
    @Async
    public void updateWorkStationOtherCount() {
        Date startDate = new Date();
        log.info("下片破更新损玻璃数量任务开始执行时间:{}", startDate);
@@ -230,9 +227,16 @@
        } else {
            log.info("该玻璃尺寸非人工下片");
            //获取该玻璃的流程卡是否已绑定架子
            DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
                    .eq(DownWorkstation::getLayer, glassInfo.getLayer())
                    .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
            DownWorkstation one;
            if (glassInfo.getCombine() != 0) {
                one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
                        .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
            } else {
                one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
                        .eq(DownWorkstation::getLayer, glassInfo.getLayer())
                        .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
            }
            //是否已经绑定   true:已绑定    false:未绑定
            Boolean isBind = Boolean.FALSE;
            if (null != one) {
@@ -247,8 +251,12 @@
                if (CollectionUtils.isNotEmpty(list)) {
                    log.info("有空架子,将流程卡与架子好绑定,执行进片任务 结束");
                    //绑定流程卡
                    downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
//                    downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getId(), glassInfo.getLayer());
                    if (glassInfo.getCombine() == 0) {
                        downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
                    } else {
                        downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), 0);
                    }
//                      downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getId(), glassInfo.getLayer());
                    checkFlag = Boolean.TRUE;
                }
            }
@@ -297,6 +305,10 @@
        //将任务插入理片笼详情表
        DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails();
        BeanUtils.copyProperties(glassInfo, downStorageCageDetails);
        //当需要合并落架时不绑定层号
        if (glassInfo.getCombine() != 0) {
            downStorageCageDetails.setLayer(0);
        }
        downStorageCageDetails.setState(Const.GLASS_STATE_IN);
        downStorageCageDetails.setSlot(nearestEmpty.getSlot());
        downStorageCageDetails.setDeviceId(nearestEmpty.getDeviceId());
@@ -321,6 +333,10 @@
        if (StringUtils.isNotBlank(glassId)) {
            GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
            BeanUtils.copyProperties(glassInfo, cageDetails);
            //当需要合并落架时不绑定层号
            if (glassInfo.getCombine() != 0) {
                cageDetails.setLayer(0);
            }
            //获取当前笼子空格信息
            DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
            cageDetails.setSlot(empty.getSlot());
@@ -337,6 +353,7 @@
        //2、08台空闲,先走扔工下片或2号机械臂,无玻璃出片 在走1号机械臂
        //机械臂被禁用的情况下不能继续向禁用的机械臂放玻璃
        Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
        flag08 = true;
        if (!flag08) {
            generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId);
        } else {
@@ -437,6 +454,7 @@
                    Map<String, List<DownWorkstation>> listMap = downWorkstationList.stream()
                            .filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
                    //过滤筛选获取架子上对应流程卡+层数的笼子内的玻璃信息
                    list = tempList.stream().filter(item -> listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
                    if (CollectionUtils.isEmpty(list) && flag08 && !"2".equals(glassStatus13)) {
                        list = tempList.stream().filter(item -> {
@@ -623,9 +641,16 @@
                return Boolean.FALSE;
            }
        } else {
            DownWorkstation workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
                    .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
            endCell = workstation.getWorkstationId();
            double firstLength = Math.max(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
            double secondLength = Math.min(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
            if (firstLength > maxWidth || secondLength > maxHeight) {
                endCell = Const.G13_WORK_STATION;
            } else {
                DownWorkstation workstation;
                workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
                        .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
                endCell = workstation.getWorkstationId();
            }
        }
        //更新落架玻璃数量
        if (endCell == Const.G13_WORK_STATION) {
@@ -640,12 +665,28 @@
        DownGlassInfo downGlassInfo = new DownGlassInfo();
        BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
        //落架片序
        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
        LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>();
        wrapper.eq(DownGlassInfo::getFlowCardId, downGlassInfo.getFlowCardId())
                .orderByDesc(DownGlassInfo::getSequence)
                .last("limit 1");
        if (downStorageCageDetails.getLayer() != 0) {
            wrapper.eq(DownGlassInfo::getLayer, downGlassInfo.getLayer());
        }
//        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
        int k = 0;
        DownGlassInfo downGlassInfo1 = downGlassInfoService.getOne(wrapper);
        if (downGlassInfo1 != null) {
            k = 1;
        } else {
            k = 1;
        }
        downGlassInfo.setSequence(k);
        downGlassInfo.setWorkStationId(endCell);
        downGlassInfo.setGmtCreate(new Date());
        downGlassInfoService.save(downGlassInfo);
        //生成任务信息
        GlassInfo glassInfo = new GlassInfo();
        downStorageCageDetails.setLayer(0);
        BeanUtils.copyProperties(downStorageCageDetails, glassInfo);
        //删除理片笼表拿走/破损数据数据
        damageService.deleteByGlassId(glassInfo.getGlassId());