ZY
2025-04-07 a6f6f82ccb56c168ecd564eca377b41f25a901bb
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -10,13 +10,9 @@
import com.zy.asrs.domain.param.CrnOperatorParam;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.wms.StorageEscalationParam;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.StaDescMapper;
import com.zy.asrs.mapper.TaskWrkMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.Utils;
import com.zy.common.service.CommonService;
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
@@ -31,7 +27,6 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.SiemensDevpThread;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -69,6 +64,9 @@
    private BasCrnErrorMapper basCrnErrorMapper;
    @Autowired
    private TaskWrkMapper taskWrkMapper;
    @Autowired
    private DevpTaskMapper devpTaskMapper;
    @Autowired
    private TaskWrkService taskWrkService;
@@ -81,9 +79,6 @@
    @Autowired
    private CommonService commonService;
    @Autowired
    private ToWmsService toWmsService;
@@ -91,9 +86,9 @@
    private CrnController crnController;
    @Autowired
    private ConfigService configService;
    private TransferTaskService transferTaskService;
    public void generateStoreWrkFile1() throws IOException, InterruptedException {
    public void generateStoreWrkFile() throws IOException, InterruptedException {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -424,6 +419,15 @@
                    if (flag) {
                        LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                .eq("row1", (locMast.getRow1() - 1))
                                .eq("bay1", locMast.getBay1())
                                .eq("lev1", locMast.getLev1()).eq("loc_sts", "F"));
                        if (!Cools.isEmpty(locMast1)) {
                            log.info(locMast.getLocNo() + "出深库位,浅库位有货");
                            continue;
                        }
                    } else {
                        LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>()
                                .eq("row1", (locMast.getRow1() + 1))
                                .eq("bay1", locMast.getBay1())
                                .eq("lev1", locMast.getLev1()).eq("loc_sts", "F"));
                        if (!Cools.isEmpty(locMast1)) {
@@ -834,6 +838,9 @@
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                if (devp.getId() == 2){
                    continue;
                }
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                for (DevpSlave.Sta inSta : devp.getInSta()) {
                    WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getBackSta());
@@ -992,4 +999,97 @@
        }
    }
    /**
     * 跑库程序
     */
    public void debug() {
        //首先库位有一个在库的库位
        LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "F"));
        if (locMast != null) {
            // 再生成一个移库任务
            LocMast mk = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", "O").ne("mk", 1));
        }
    }
    /**
     * 转移任务下发
     */
    public void transferTaskStart() {
        for (DevpSlave.Sta sta : slaveProperties.getDevp().get(1).getInSta()) {
            try {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
                StaProtocol staProtocol = devpThread.getStation().get(sta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
                    // 查询工作档
                    TransferTask transferTask = transferTaskService.selectByStartPoint(sta.getStaNo());
                    if (transferTask == null) {
                        continue;
                    }
                    log.info("下发输送线转移任务:taskWrk:" + JSON.toJSONString(transferTask));
                    staProtocol.setWorkNo(transferTask.getWrkNo().shortValue());
                    staProtocol.setStaNo(transferTask.getTargetPoint().shortValue());
                    boolean offer = false;
                    try {
                        offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
                    } catch (Exception e) {
                        log.error("下发输送线转移任务:异常:" + e);
                        log.error("下发输送线转移任务:异常:offer:" + offer);
                    }
                    if (offer) {
                        log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(transferTask));
                        transferTask.setStatus(2);
                        transferTaskService.updateById(transferTask);
                    } else {
                        log.error("下发输送线任务失败:taskWrk:" + JSON.toJSONString(transferTask));
                    }
                }
            } catch (Exception e) {
                log.error("转移任务异常:异常信息:" + e);
            }
        }
    }
    /**
     * 转移任务完成
     */
    public void transferTaskEnd() {
        for (DevpSlave.Sta sta : slaveProperties.getDevp().get(1).getInSta()) {
            try {
                // 获取终点站
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
                StaProtocol staProtocol = devpThread.getStation().get(sta.getOverSta());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
                    // 查询工作档
                    TransferTask transferTask = transferTaskService.selectByEndPoint(sta.getStaNo());
                    if (transferTask == null) {
                        continue;
                    }
                    log.info("转移任务完成:transferTask:" + JSON.toJSONString(transferTask));
                    transferTask.setStatus(5);
                    transferTaskService.updateById(transferTask);
                }
            } catch (Exception e) {
                log.error("转移任务异常:异常信息:" + e);
            }
        }
    }
}