wuyouming666
2024-07-10 fc7b97877ca01587fe4b3e6c7ac2f9f5be8dcc53
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -4,6 +4,7 @@
import cn.smallbun.screw.core.util.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.mes.common.S7object;
import com.mes.common.config.Const;
import com.mes.device.PlcParameterObject;
@@ -81,7 +82,7 @@
    @Scheduled(fixedDelay = 3000)
    public void plcHomeEdgTask() {
       PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue();
        String glassIdeValue = plcParameterObject.getPlcParameter("requestID").getValue();
        //A08  A09表示线路相同  可做等价  无数据转int异常
@@ -92,7 +93,6 @@
        String confirmationWrodValue = plcParameterObject.getPlcParameter("confirmationWord").getValue();
        String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
        String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
        log.info("1、获取到的请求字为:{},获取到的扫描ID为:{},获取到的确认字为:{},获取到的出片状态分别为:g06:{}、g08:{}、g11:{}、g13:{},当前格子号为:{}",
@@ -145,8 +145,7 @@
        //玻璃尺寸是否走人工下片
        if (glassInfo.getWidth() > maxWidth || glassInfo.getHeight() > maxHeight || glassInfo.getWidth() < minWidth || glassInfo.getHeight() < minHeight) {
            log.info("该玻璃尺寸不符合要求,需要走人工下片直接进片");
        }
        else {
        } else {
            log.info("该玻璃尺寸非人工下片");
            //获取该玻璃的流程卡是否已绑定架子
            DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
@@ -161,7 +160,7 @@
            if (!checkFlag && !isBind) {
                log.info("该玻璃的流程卡未绑定架子,获取是否有空架子");
                List<DownWorkstation> list = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
                        .isNull(DownWorkstation::getFlowCardId));
                        .isNull(DownWorkstation::getFlowCardId).orderByDesc(DownWorkstation::getWorkstationId));
                if (CollectionUtils.isNotEmpty(list)) {
                    log.info("有空架子,将流程卡与架子好绑定,执行进片任务 结束");
                    //绑定流程卡
@@ -245,8 +244,8 @@
            return Boolean.FALSE;
        }
        Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
        if (!generateTaskByShelf(glassStatus11, flag08, glassStatus13, tempList, cageDetails)) {
            return generateTaskByShelf(glassStatus11, !flag08, glassStatus13, tempList, cageDetails);
        if (!generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId)) {
            return generateTaskByShelf(glassStatus06, glassStatus11, !flag08, glassStatus13, tempList, cageDetails, glassId);
        }
        return Boolean.TRUE;
    }
@@ -288,16 +287,16 @@
        }
    }
    private Boolean generateTaskByShelf(String glassStatus, Boolean flag08, String glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails) {
    private Boolean generateTaskByShelf(String glassStatus06, String glassStatus11, Boolean flag08, String glassStatus13, List<DownStorageCageDetails> tempList, DownStorageCageDetails cageDetails, String glassId) {
        //获取2个机械臂范围内的架子绑定的流程卡信息
        List<Integer> workList = new ArrayList();
        if (flag08) {
            if (!"2".equals(glassStatus)) {
            if (!"2".equals(glassStatus11)) {
                workList.addAll(Const.G11_WORK_STATION);
            }
        } else {
            if (!"2".equals(glassStatus)) {
            if (!"2".equals(glassStatus06)) {
                workList.addAll(Const.G06_WORK_STATION);
            }
        }
@@ -306,7 +305,7 @@
        //对笼内玻璃进行过滤,仅出符合逻辑的玻璃
        if (CollectionUtils.isNotEmpty(workList)) {
            List<DownWorkstation> downWorkstationList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
                    .eq(DownWorkstation::getEnableState, 0).in(DownWorkstation::getWorkstationId, workList));
                    .eq(DownWorkstation::getEnableState, Const.SLOT_ON).in(DownWorkstation::getWorkstationId, workList));
            log.info("架子被禁用,无法出片落架");
            if (CollectionUtils.isEmpty(downWorkstationList)) {
                log.info("笼子被禁用,无法走机械臂下片");
@@ -357,10 +356,8 @@
            List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE);
            List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList());
            if (CollectionUtils.isEmpty(downGlassFlowList)) {
                //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃
                DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount();
                //绑定流程卡,更新玻璃状态,生成出片任务,
                tempGlassId = downStorageCageDetails.getGlassId();
                //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无  则返回扫描扫到的玻璃id进行出片
                tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId);
                isBind = Boolean.TRUE;
                break loop;
            }
@@ -371,9 +368,8 @@
//                List<DownWorkstation> emptyShelfList = downWorkstationService.list(new LambdaQueryWrapper<DownWorkstation>()
//                        .isNull(DownWorkstation::getFlowCardId));
                if (isEmptyShelf) {
                    DownStorageCageDetails downStorageCageDetails = downStorageCageDetailsService.getGlassInfoMaxCount();
                    //绑定流程卡,更新玻璃状态,生成出片任务
                    tempGlassId = downStorageCageDetails.getGlassId();
                    //架子都未绑定流程卡,出笼内子数量最多尺寸最大的玻璃id,无  则返回扫描扫到的玻璃id进行出片
                    tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId);
                    isBind = Boolean.TRUE;
                    break loop;
                }
@@ -484,6 +480,13 @@
            return Boolean.FALSE;
        }
        //更新落架玻璃数量
        if (endCell == 7) {
            downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
                    .eq("layer", downStorageCageDetails.getLayer()).setSql("artificial_number = artificial_number +1"));
        } else {
            downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
                    .eq("layer", downStorageCageDetails.getLayer()).setSql("racks_number = racks_number +1"));
        }
        //生成任务信息
        DownGlassInfo downGlassInfo = new DownGlassInfo();
@@ -506,7 +509,7 @@
        downGlassTask.setHeight((int) glassInfo.getHeight());
        downGlassTask.setFlowCardId(glassInfo.getFlowCardId());
        downGlassTask.setLayer(glassInfo.getLayer());
        downGlassTask.setTaskStauts(0);
        downGlassTask.setTaskStatus(0);
        downGlassTask.setCreateTime(new Date());
        downGlassTaskService.save(downGlassTask);
        //向plc发送命令