ZengTao
2025-03-28 f68d3c71819feb59e7a227a5d992b059b900916c
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();
@@ -95,10 +94,18 @@
        String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
        String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
//        requestWord="3";
//        glassIdeValue="P25031802|4|1";
//        out06Glassstate="1";
//        out08Glassstate="1";
//        out11Glassstate ="1";
//        out13Glassstate="1";
//        currentSlot="1";
//        confirmationWrodValue="0";
        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 +138,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);
@@ -158,7 +165,7 @@
            //下片数量-1
            for (DownGlassTask downGlassTask : downGlassTaskList
            ) {
                if (Const.GLASS_CACHE_TYPE_OUT_ALL.equals(downGlassTask.getTaskType())) {
                if (Const.GLASS_CACHE_TYPE_OUT_ALL.contains(downGlassTask.getTaskType())) {
                    downWorkstationService.update(
                            new LambdaUpdateWrapper<DownWorkstation>()
                                    .setSql("racks_number = racks_number-1")
@@ -173,7 +180,7 @@
                damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
                damage.setWorkingProcedure("下片");
                damage.setRemark("下片");
                damage.setStatus(0);
                damage.setStatus(1);
                damage.setType(e.getTaskStatus());
                return damage;
            }).collect(Collectors.toList());
@@ -187,7 +194,6 @@
     * 更新已绑定工位流程卡的破损/拿走的数量信息
     */
    @Scheduled(fixedDelay = 1000)
    @Async
    public void updateWorkStationOtherCount() {
        Date startDate = new Date();
        log.info("下片破更新损玻璃数量任务开始执行时间:{}", startDate);
@@ -200,7 +206,10 @@
            //更新工位其他玻璃信息的数量
            QueryWrapper<Damage> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("process_id", downWorkstation.getFlowCardId());
            queryWrapper.eq("technology_number", downWorkstation.getLayer());
            queryWrapper.gt("type", 3);
            if (downWorkstation.getLayer() != 0) {
                queryWrapper.eq("technology_number", downWorkstation.getLayer());
            }
            int otherNumber = damageService.count(queryWrapper);
            downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getOtherNumber, otherNumber)
                    .eq(DownWorkstation::getWorkstationId, downWorkstation.getWorkstationId()));
@@ -227,12 +236,20 @@
        //玻璃尺寸是否走人工下片
        if (glassWidth > maxWidth || glassHeight > maxHeight || glassWidth < minWidth || glassHeight < minHeight) {
            log.info("该玻璃尺寸不符合要求,需要走人工下片直接进片");
            return;
        } 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 +264,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;
                }
            }
@@ -264,7 +285,8 @@
                    for (DownGlassInfoDTO e : downGlassInfoDTOList) {
                        List<GlassInfo> glassInfoList = e.getGlassInfoList();
                        List<GlassInfo> glassInfoTempList = glassInfoList.stream().filter(item -> item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight()
                                && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList());
                                && item.getThickness() == glassInfo.getThickness() && item.getMarkIcon().equals(glassInfo.getMarkIcon())
                                && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList());
                        if (CollectionUtils.isNotEmpty(glassInfoTempList)) {
                            for (GlassInfo item : glassInfoTempList) {
                                //玻璃是否为多层:1、先获取当前流程卡落架最多的层数,如果为空,表明未绑定流程卡,未落架,然后按照是否可绑定架子决定是否替换。(可忽略不计,本校验仅在前一次调用起作用)
@@ -298,8 +320,8 @@
        DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails();
        BeanUtils.copyProperties(glassInfo, downStorageCageDetails);
        //当需要合并落架时不绑定层号
        if(glassInfo.getCombine()==0){
            downStorageCageDetails.setLayer(null);
        if (glassInfo.getCombine() != 0) {
            downStorageCageDetails.setLayer(0);
        }
        downStorageCageDetails.setState(Const.GLASS_STATE_IN);
        downStorageCageDetails.setSlot(nearestEmpty.getSlot());
@@ -326,8 +348,8 @@
            GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
            BeanUtils.copyProperties(glassInfo, cageDetails);
            //当需要合并落架时不绑定层号
            if(glassInfo.getCombine()==0){
                cageDetails.setLayer(null);
            if (glassInfo.getCombine() != 0) {
                cageDetails.setLayer(0);
            }
            //获取当前笼子空格信息
            DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
@@ -345,6 +367,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 {
@@ -445,6 +468,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 -> {
@@ -631,10 +655,13 @@
                return Boolean.FALSE;
            }
        } else {
            if (downStorageCageDetails.getWidth() > maxWidth || downStorageCageDetails.getHeight() > maxHeight) {
            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 = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
                DownWorkstation workstation;
                workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
                        .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
                endCell = workstation.getWorkstationId();
            }
@@ -652,14 +679,36 @@
        DownGlassInfo downGlassInfo = new DownGlassInfo();
        BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
        //落架片序
        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
        downGlassInfo.setWorkStationId(endCell);
        downGlassInfo.setGmtCreate(new Date());
        downGlassInfoService.save(downGlassInfo);
        //生成任务信息
        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 = 1;
//        DownGlassInfo downGlassInfo1 = downGlassInfoService.getOne(wrapper);
//        if (downGlassInfo1 != null) {
//            k = 1;
//        } else {
//            k = 1;
//        }
        GlassInfo glassInfo = new GlassInfo();
        BeanUtils.copyProperties(downStorageCageDetails, glassInfo);
        GlassInfo glassInfo1 = glassInfoService.getOne(
                new LambdaUpdateWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassInfo.getGlassId())
        );
        downGlassInfo.setSequence(k);
        downGlassInfo.setWorkStationId(endCell);
        downGlassInfo.setGmtCreate(new Date());
        downGlassInfo.setLayer(glassInfo1.getLayer());
        downGlassInfoService.save(downGlassInfo);
        //生成任务信息
        //删除理片笼表拿走/破损数据数据
        glassInfo.setLayer(glassInfo1.getLayer());
        damageService.deleteByGlassId(glassInfo.getGlassId());
        return initDownGlassTask(glassInfo, downStorageCageDetails.getSlot(), endCell, taskType);
    }
@@ -678,6 +727,14 @@
        downGlassTask.setTaskStatus(0);
        downGlassTask.setCreateTime(new Date());
        downGlassTaskService.save(downGlassTask);
        //添加报工数据
        Damage damage = new Damage();
        damage.setGlassId(glassInfo.getGlassId());
        damage.setWorkingProcedure("钢化");
        damage.setLine(4001);
        damage.setType(1);
        damage.setRemark("钢化后卧式理片");
        damageService.insertDamage(damage);
        //向plc发送命令
        return sendMessageToPlc((int) glassInfo.getWidth(), (int) glassInfo.getHeight(), (int) glassInfo.getThickness(),
                startCell, endCell, taskType);