pjb
2025-07-21 4ba63e6424b4091ec74a74d4562cc776efb516f4
src/main/java/com/zy/service/impl/MainServiceImpl.java
@@ -118,6 +118,9 @@
    private WaitPakinMapper waitPakinMapper;
    @Autowired
    private LocMastService locMastService;
    @Resource
    private LocMastMapper locMastMapper;
    @Autowired
    private StaDescService staDescService;
    @Autowired
@@ -731,7 +734,7 @@
                        continue;
                    }
                } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
                } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("M")|| shallowLoc.getLocSts().equals("Z")) {
                    News.warnNoLog(""+mark+" - 1"+" - 12"+" - // F、D  库位状态={}",shallowLoc.getLocSts());
                    // 此标记避免多次执行移库任务
                    if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) {
@@ -819,6 +822,11 @@
     */
    public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol,Integer mark) {
        News.warnNoLog(""+mark+" - 2"+" - 0"+" - 堆垛机入出库作业下发:执行出库");
        boolean crnAvailableOut = false;
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code","removeCrnAvailableOut"));
        if (config != null && config.getStatus() == 1) {
            crnAvailableOut = true;
        }
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            // 获取工作状态为11(生成出库ID)的出库工作档
            List<WrkMast> wrkMasts = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo());
@@ -855,9 +863,8 @@
                }
                // 判断堆垛机出库站状态
                if ((staProtocol.isAutoing() && !staProtocol.isLoading() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
                        && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable())
                        || (staProtocol.getSiteId() == 1056 && staProtocol.isAutoing() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y"))) {
                if (staProtocol.isAutoing() && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y") &&
                        (crnAvailableOut || !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable())) {
                    // 堆垛机控制过滤
                    if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) {
                        break;
@@ -894,7 +901,7 @@
                                }
                            }
                        } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) {
                        } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("M")|| shallowLoc.getLocSts().equals("Z")) {
                            News.warnNoLog(""+mark+" - 2"+" - 9"+" - // F、D  库位状态={}",shallowLoc.getLocSts());
//                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
                            //2022-08-16 modify,不根据updmk标记移库任务(容易被取消导致堵塞),查询工作档是否存在任务
@@ -1148,21 +1155,23 @@
                    // 空桶入库完成,先完成对应库位组任务
                    if(wrkMast.getWorkNoOther() != 0 ){
                        WrkMast wrkMast1 = wrkMastService.selectByWrkNo(wrkMast.getWorkNoOther());
                        // 交换库位号
                        String locNo = wrkMast.getLocNo();
                        wrkMast.setLocNo(wrkMast1.getLocNo());
                        // 交换入库时间,提取库存时按顺序先浅后深
                        Date ioTime = wrkMast.getIoTime();
                        if(locNo.startsWith("10")) {
                            wrkMast.setIoTime(wrkMast1.getIoTime());
                            wrkMast1.setIoTime(ioTime);
                        if (wrkMast1 != null) {
                            // 交换库位号
                            String locNo = wrkMast.getLocNo();
                            wrkMast.setLocNo(wrkMast1.getLocNo());
                            // 交换入库时间,提取库存时按顺序先浅后深
                            Date ioTime = wrkMast.getIoTime();
                            if(locNo.startsWith("10")) {
                                wrkMast.setIoTime(wrkMast1.getIoTime());
                                wrkMast1.setIoTime(ioTime);
                            }
                            wrkMast1.setLocNo(locNo);
                            wrkMast1.setCrnEndTime(now);
                            wrkMast1.setModiTime(now);
                            wrkMast1.setWrkSts(4L);
                            wrkMast1.setWorkNoOther(0);
                            wrkMastMapper.updateById(wrkMast1);
                        }
                        wrkMast1.setLocNo(locNo);
                        wrkMast1.setCrnEndTime(now);
                        wrkMast1.setModiTime(now);
                        wrkMast1.setWrkSts(4L);
                        wrkMast1.setWorkNoOther(0);
                        wrkMastMapper.updateById(wrkMast1);
                    }
                    wrkMast.setCrnEndTime(now);
                    wrkMast.setModiTime(now);
@@ -1189,6 +1198,9 @@
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
            CrnProtocol crnProtocol = crnThread.getCrnProtocol();
            if(crnProtocol == null) {
                continue;
            }
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO
                    && crnProtocol.getLoaded() == 0 && crnProtocol.getForkPos() == 0) {
                // 判断是不是已在原点
@@ -1203,8 +1215,13 @@
                Date now = new Date();
                Date modiTime = basCrnp.getModiTime();
                long diffInMillis = now.getTime()-modiTime.getTime();
                if(diffInMillis < 3 * 60 * 1000) {
                if(diffInMillis < 10 * 1000) { // 空闲小于10秒则跳过
                    continue;
                } else {  // 有入库任务或大于2分钟,回原点
                    int count = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 1).eq("crn_no", crn.getId()).in("wrk_sts", 2, 9, 10));
                    if(count == 0 && diffInMillis < 2 * 60 * 1000) {
                        continue;
                    }
                }
                // 有吊车入库或吊车出库任务
@@ -1514,13 +1531,25 @@
     */
    private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc,Integer mark) {
        // 只有208L能放11层
        String model = null;
        if(shallowLoc.getLocSts().equals("F")) {
            LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
            if(locDetl != null && locDetl.getModel() != null) {
                String matModel = locMastMapper.selectMatMatnrByMaktx(locDetl.getModel());
                if(matModel != null && matModel.equals("208L")) {
                    model = "208L";
                }
            }
        }
        try {
            News.warnNoLog(""+mark+"moveLocForDeepLoc"+" - 0"+" - 开始执行:因双深库位阻塞,对浅库位进行移转(立即执行版)");
            List<Integer> rows = locMastService.queryDistinctRow(crn.getId());
            LocMast loc = null;
            for (Integer row : rows) {
                if (Utils.isDeepLoc(slaveProperties, row)) {
                    loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType2());
//                    loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType2());
                    loc = locMastMapper.queryFreeLocMastNew(row,model);
                    if (loc != null) {
                        if (Utils.isDeepLoc(slaveProperties, loc.getLocNo())) {
@@ -1539,12 +1568,12 @@
            if (null == loc) {
                for (Integer row : rows) {
                    if (Utils.isShallowLoc(slaveProperties, row)) {
                        loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType2());
//                        loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType2());
                        loc = locMastMapper.queryFreeLocMastNew(row,model);
                        if (null != loc) {//对应深库位非在库状态,不能移库
                            String deepLoc = Utils.getDeepLoc(slaveProperties, loc.getLocNo());
                            LocMast deepLoc1 = locMastService.selectById(deepLoc);
                            if (!deepLoc1.getLocSts().equals("F") && !deepLoc1.getLocSts().equals("D")) {
                            if (!deepLoc1.getLocSts().equals("F") && !deepLoc1.getLocSts().equals("M")&& !deepLoc1.getLocSts().equals("Z")) {
                                loc = null;
                            }
                        }
@@ -1576,7 +1605,7 @@
                wrkMast.setFullPlt(shallowLoc.getLocSts().equals("F") ? "Y" : "N"); // 满板
                wrkMast.setPicking("N"); // 拣料
                wrkMast.setExitMk("N"); // 退出
                wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板
                wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("M") ? "M" : shallowLoc.getLocSts().equals("Z") ? "Z" : "N"); // 空板
                wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码
                wrkMast.setLinkMis("N");
                wrkMast.setAppeTime(new Date());
@@ -1604,7 +1633,7 @@
                    }
                }
                // 修改源库位状态
                if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) {
                if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("M") || shallowLoc.getLocSts().equals("Z")) {
                    shallowLoc.setLocSts("R"); // R.出库预约
                    shallowLoc.setModiTime(new Date());
                    if (!locMastService.updateById(shallowLoc)) {
@@ -1725,8 +1754,8 @@
                staProtocol = staProtocol.clone();
            }
            if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.isInEnable() || staProtocol.isOutEnable() && site == 1090) && staProtocol.getWorkNo() != 0 && staProtocol.getWorkNo() < 9000) {
                if (staProtocol.getWorkNo() == 1034 && !staProtocol.isHigh()) { // 1034空母拖回流任务需要高信号
                    return;
                if (staProtocol.getSiteId() == 1034 && !staProtocol.isHigh()) { // 1034空母拖回流任务需要高信号
                    continue;
                }
                // 查询工作档
                WrkMast wrkMast = wrkMastMapper.selectByWrkNo(staProtocol.getWorkNo());