#
1
2025-05-09 67809d68cadd1ae3e6f697a92030201dbdf947ce
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -12,10 +12,7 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.*;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.CommandUtils;
import com.zy.asrs.utils.RouteUtils;
import com.zy.asrs.utils.TrackRangeUtils;
import com.zy.asrs.utils.Utils;
import com.zy.asrs.utils.*;
import com.zy.common.model.MatDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.CollectionUtils;
@@ -194,7 +191,7 @@
                        String barcode = barcodeThread.getBarcode();
                        if (!Cools.isEmpty(barcode) && !barcode.equals("99999999")) {
                            // 请求wms接口,获取工作号和目标库位
                            ToWmsDTO toWmsDTO = new ToWmsDTO(barcode, staProtocol.getSiteId(), 0);
                            ToWmsDTO toWmsDTO = new ToWmsDTO(staProtocol.getSiteId(),staProtocol.getGrossWt(),barcode, 0);
                            TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode));
                            if (!Cools.isEmpty(taskWrk1)) {
                                log.info("托盘码:" + barcode + "任务档存在");
@@ -465,7 +462,8 @@
                    // 判断是否满足入库条件
                    if (staProtocol.isAutoing() && staProtocol.isLoading()
                            && staProtocol.isInEnable() && (workNo == 0 || (workNo>9000 && workNo<10000))
//                            && staProtocol.isInEnable()
                            && (workNo == 0 || (workNo>9000 && workNo<10000))
                            && staProtocol.isPakMkWalk()
                    ) {
                        if (inSta.isBarcodeSign()){
@@ -510,6 +508,7 @@
                                        } else {
                                            staProtocol.setWorkNo(taskWrk1.getWrkNo());
                                            staProtocol.setStaNo(staDesc.getCrnStn());
                                            devpThread.setPakMkWalk(staProtocol.getSiteId(), false);
                                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                        }
                                    }
@@ -517,7 +516,7 @@
                                }
                            }
                        } else {
                            TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>());
                            TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("IO_TYPE",1).eq("WRK_STS",1).eq("START_POINT",staProtocol.getSiteId().toString()));
                            if (!Cools.isEmpty(taskWrk1)) {
                                if (taskWrk1.getIoType() == 1 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) {
@@ -528,8 +527,21 @@
                                        return;
                                    } else {
                                        staProtocol.setWorkNo(taskWrk1.getWrkNo());
                                        staProtocol.setStaNo(staDesc.getCrnStn());
                                        staProtocol.setStaNo(BarcodeUtils.getStaNo(staProtocol.getSiteId()));
                                        devpThread.setPakMkWalk(staProtocol.getSiteId(), false);
                                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                        Date now = new Date();
//                                        taskWrk1.setStatus(TaskStatusType.DISTRIBUTE.id);//派发状态
//                taskWrk.setAssignTime(now);//派发时间
                                        taskWrk1.setExecuteTime(now);
                                        taskWrk1.setWrkSts(2);//工作状态 3.吊车入库
                                        taskWrk1.setCrnNo(staDesc.getCrnNo());//堆垛机号
                                        taskWrk1.setModiTime(now);
                                        taskWrk1.setModiUser(9988L);
                                        taskWrkService.updateById(taskWrk1);
                                    }
                                }
                                return;
@@ -593,7 +605,7 @@
                            log.info("下发输送线任务:taskWrk:" + JSON.toJSONString(taskWrk));
//                            R r = siteController.siteDetlUpdate(Integer.valueOf(taskWrk.getTargetPoint()), taskWrk.getWrkNo().shortValue(), (short) 0, "Y", false, false);
                            staProtocol.setWorkNo(taskWrk.getWrkNo());
                            staProtocol.setStaNo(staDesc.getCrnStn());
                            staProtocol.setStaNo(BarcodeUtils.getStaNo(staProtocol.getSiteId()));
                            boolean offer = false;
                            try {
                                offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
@@ -605,7 +617,7 @@
                            if (offer) {
                                log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(taskWrk));
                                Date now = new Date();
                                taskWrk.setStatus(5);
                                taskWrk.setStatus(9);
                                taskWrk.setWrkSts(14);
                                taskWrk.setModiTime(now);
                                taskWrk.setCompleteTime(now);
@@ -783,7 +795,7 @@
                crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint()));     // 目标库位层
                crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint()));     // 目标库位排
                crnCommand.setCommand((short) 1);
                if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand), false)) {
                if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) {
                    log.error("堆垛机命令生成失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand));
                    throw new CoolException("堆垛机命令生成失败");
                } else {
@@ -797,7 +809,7 @@
                        HashMap<String, Object> headParam = new HashMap<>();
                        headParam.put("taskNo", taskWrk.getTaskNo());
                        headParam.put("status", taskWrk.getStatus());
                        headParam.put("ioType", taskWrk.getIoType());
                        headParam.put("ioType", taskWrk.getIoTypeWms());
                        headParam.put("barcode", taskWrk.getBarcode());
                        String response;
                        response = new HttpHandler.Builder()
@@ -895,7 +907,7 @@
                        command.setDestinationPosY(crnStn.getBay().shortValue());     // 目标库位列
                        command.setDestinationPosZ(crnStn.getLev().shortValue());     // 目标库位层
                        command.setCommand((short) 1);
                        if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, command), false)) {
                        if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, command))) {
                            log.error("堆垛机命令生成失败,堆垛机号={},巷道={},任务数据={}", slave.getId(), taskWrk.getCrnNo(), JSON.toJSON(command));
                            throw new CoolException("堆垛机命令生成失败");
                        } else {
@@ -917,7 +929,7 @@
                                HashMap<String, Object> headParam = new HashMap<>();
                                headParam.put("taskNo", taskWrk.getTaskNo());
                                headParam.put("status", taskWrk.getStatus());
                                headParam.put("ioType", taskWrk.getIoType());
                                headParam.put("ioType", taskWrk.getIoTypeWms());
                                headParam.put("barcode", taskWrk.getBarcode());
                                String response;
                                response = new HttpHandler.Builder()
@@ -1005,7 +1017,7 @@
                crnCommand.setDestinationPosY(Utils.getBayShort(taskWrk.getTargetPoint()));     // 目标库位列
                crnCommand.setDestinationPosZ(Utils.getLevShort(taskWrk.getTargetPoint()));     // 目标库位层
                crnCommand.setCommand((short) 1);
                if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand), false)) {
                if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) {
                    log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand));
                } else {
                    // 修改工作档状态 11.生成出库ID => 12.吊车出库中
@@ -1021,7 +1033,7 @@
                        HashMap<String, Object> headParam = new HashMap<>();
                        headParam.put("taskNo", taskWrk.getTaskNo());
                        headParam.put("status", taskWrk.getStatus());
                        headParam.put("ioType", taskWrk.getIoType());
                        headParam.put("ioType", taskWrk.getIoTypeWms());
                        headParam.put("barcode", taskWrk.getBarcode());
                        String response;
                        response = new HttpHandler.Builder()
@@ -1073,14 +1085,14 @@
            }
            //  状态:等待确认 并且  任务完成位 = 1
            if (!Cools.isEmpty(crnProtocol.getTaskFinish()) && crnProtocol.getTaskFinish() == 0 && crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) {
            if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) {
                //获取入库待确认工作档
                TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crnProtocol.getLaneNo(), crnProtocol.getTaskNo().intValue());
                if (Cools.isEmpty(taskWrk) && crnProtocol.getTaskNo() != 999) {
                    log.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},巷道号={},工作号={}", crn.getId(), crnProtocol.getLaneNo(), crnProtocol.getTaskNo());
                    continue;
                }
                Thread.sleep(300);
//                Thread.sleep(300);
                //确认完成信号
                CrnOperatorParam crnOperatorParam = new CrnOperatorParam();
                crnOperatorParam.setCrnNo(crn.getId());
@@ -1135,7 +1147,7 @@
                        HashMap<String, Object> headParam = new HashMap<>();
                        headParam.put("taskNo", taskWrk.getTaskNo());
                        headParam.put("status", taskWrk.getStatus());
                        headParam.put("ioType", taskWrk.getIoType());
                        headParam.put("ioType", taskWrk.getIoTypeWms());
                        headParam.put("barcode", taskWrk.getBarcode());
                        String response;
                        log.error("wcs完结任务上报wms==》", headParam);
@@ -1343,7 +1355,7 @@
        if (rgvProtocol == null || rgvTaskProtocol == null) {
            return false;
        }
        if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 || rgvProtocol.getRgvPosDestination() == 0L
        if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1
                || (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM))) {
            return false;
        }
@@ -1371,8 +1383,9 @@
        // 判断是否满足取货条件
        if (staProtocol.isAutoing()
//                && staProtocol.isLoading()
                && staProtocol.isStaOk()
                && staProtocol.getWorkNo() != 0) {
            TaskWrk taskWrk = taskWrkService.selectByTaskNo(staProtocol.getWorkNo().toString());
            TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo());
            if (taskWrk != null) {
                return taskWrk;
            }
@@ -1594,7 +1607,8 @@
                if (taskWrk == null) {
                    return false;
                }
                Integer targetPointConvert = taskWrk.getTargetPointConvert();
//                Integer targetPointConvert = taskWrk.getTargetPointConvert();
                Integer targetPointConvert = BarcodeUtils.getOutStaNo(taskWrk.getOriginTargetPoint());
                if (targetPointConvert == null) {
                    return false;
                }
@@ -1607,7 +1621,7 @@
                BasDevpPosition basDevpPositionEnd = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", targetPointConvert));
                //执行
                issuedTake.setTaskNo(Long.valueOf(taskWrk.getTaskNo()));
                issuedTake.setTaskStatus(1);
                issuedTake.setTaskStatus(2);
                issuedTake.setTaskNoDirection(issuedTake.gettaskNoDirection$(issuedTake.getTaskNo(), issuedTake.getTaskStatus()));
                issuedTake.setTargetPosition(basDevpPositionSou.getPlcPosition());
                issuedTake.setIsRunning(1);
@@ -1615,7 +1629,7 @@
                issuedPut.setTaskNo(Long.valueOf(taskWrk.getTaskNo()));
                issuedPut.setTaskStatus(2);
                issuedPut.setTaskStatus(3);
                issuedPut.setTaskNoDirection(issuedPut.gettaskNoDirection$(issuedPut.getTaskNo(), issuedPut.getTaskStatus()));
                issuedPut.setTargetPosition(basDevpPositionEnd.getPlcPosition());
                issuedPut.setIsRunning(1);
@@ -1665,8 +1679,17 @@
                }
                // 获取工作档数据
                LedCommand ledCommand = new LedCommand();
                //请求wms
//
//                ledCommand.setWorkNo(wrkMast.getWrkNo());
//                ledCommand.setIoType(wrkMast.getIoType());
//                ledCommand.setTitle("空板出库");
//                ledCommand.setEmptyMk(true);
//                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
//                ledCommand.setLocNo(wrkMast.getLocNo());
//                ledCommand.setStaNo(wrkMast.getStaNo());
                MatDto matDto = new MatDto();
                ledCommand.getMatDtos().add(matDto);
                commands.add(ledCommand);
            }
            Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());