wu
2024-09-05 52516230c75988540b51e7160b1f5c03b96583ea
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcStorageCageTask.java
@@ -4,7 +4,6 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
@@ -152,11 +151,28 @@
    public void plcToHomeEdgFreeCarTask() {
        Date startDate = new Date();
        log.info("大理片笼空车进片任务开始执行时间:{}", startDate);
        PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
        String mesD03Address = plcMesObject.getPlcParameter("MESToD03").getValue();
        String mesD05Address = plcMesObject.getPlcParameter("MESToD05").getValue();
        log.info("MESToD03:{},MESToD05:{}", mesD03Address, mesD05Address);
        if ("2".equals(mesD03Address) || "2".equals(mesD05Address)) {
            log.info("有启动信号,MESToD03:{},MESToD05:{}", mesD03Address, mesD05Address);
        }
        PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
        String e01Status = plcParameterObject.getPlcParameter("E01State").getValue();
        String d03ToMES = plcParameterObject.getPlcParameter("D03ToMES").getValue();
        String d05ToMES = plcParameterObject.getPlcParameter("D05ToMES").getValue();
        log.info("执行空车送片任务,获取到的大车状态为{},卧转立状态分别为d03:{},d05:{}", e01Status, d03ToMES, d05ToMES);
        List<BigStorageCageFeedTask> bigStorageCageFeedTasks = bigStorageCageFeedTaskService.list(
                new LambdaQueryWrapper<BigStorageCageFeedTask>()
                        .ne(BigStorageCageFeedTask::getTargetSlot, 0)
                        .lt(BigStorageCageFeedTask::getTaskState, Const.BIG_STORAGE_IN_SLOT)
        );
        if (bigStorageCageFeedTasks.size() > 0) {
            Date endDate = new Date();
            log.info("大车有正在执行的任务{},结束送片任务,任务结束时间:{},共耗时:{}ms,结束扫码任务", bigStorageCageFeedTasks, endDate, endDate.getTime() - startDate.getTime());
            return;
        }
        if (REQUEST_WORD.equals(e01Status)) {
            Date endDate = new Date();
            log.info("进片大车非空闲,结束送片任务,任务结束时间:{},共耗时:{}ms,结束扫码任务", endDate, endDate.getTime() - startDate.getTime());
@@ -584,7 +600,11 @@
                if (glassCount < inCarMaxSize) {
                    addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst, heightFirst);
                } else {
                    addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightFirst);
                    if (glassCount < inCarMaxSize + 1) {
                        addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightFirst);
                    } else {
                        return Boolean.FALSE;
                    }
                }
            } else {
                flag = Boolean.FALSE;
@@ -595,12 +615,20 @@
            if (remainWidth >= widthFirst) {
                if (remainWidth - widthFirst - glassGap >= widthSecond) {
                    if (glassCount < inCarMaxSize) {
                        addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst, heightSecond);
                        addFeedTask(glassId, line, Const.BIG_STORAGE_IN_WAIT, widthFirst, heightFirst);
                    } else {
                        addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightSecond);
                        if (glassCount < inCarMaxSize + 1) {
                            addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightFirst);
                        } else {
                            return Boolean.FALSE;
                        }
                    }
                } else {
                    addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightSecond);
                    if (glassCount < inCarMaxSize + 1) {
                        addFeedTask(glassId, line, Const.BIG_STORAGE_IN_RUN, widthFirst, heightFirst);
                    } else {
                        return Boolean.FALSE;
                    }
                }
            } else {
                flag = Boolean.FALSE;
@@ -634,6 +662,8 @@
        bigStorageCageFeedTask.setWidth(width);
        bigStorageCageFeedTask.setHeight(height);
        bigStorageCageFeedTask.setCreateTime(new Date());
        //删除理片笼表拿走/破损数据数据
        damageService.deleteByGlassId(glassId);
        return bigStorageCageFeedTaskService.save(bigStorageCageFeedTask);
    }
@@ -722,7 +752,7 @@
        for (int i = 1; i <= taskList.size(); i++) {
            s7control.writeWord(plcMesObject.getPlcParameter("StartAddToImport" + i).getAddress(), taskList.get(i - 1).getLine());
            s7control.writeWord(plcMesObject.getPlcParameter("TargetAddToImport" + i).getAddress(), taskList.get(i - 1).getTargetSlot());
            log.info("向plc发送第{}片玻璃已完成", i);
            log.info("向plc发送第{}片玻璃已完成,起始位置是{},目标位置是", i, taskList.get(i - 1).getLine(), taskList.get(i - 1).getTargetSlot());
        }
        int returnData = 0;
        int count = 1;