自动化立体仓库 - WMS系统
skyouc
昨天 0d3a8b5ee34708d87c0a60075ed153f828b233be
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -605,9 +605,6 @@
        if (Objects.isNull(container)) {
            throw new CoolException("数据错误:容器码不存在!!");
        }
        // if (param.getBarcode().length() != 8) {
        // throw new CoolException("条码长度不是8位===>>" + param.getBarcode());
        // }
        if (Objects.isNull(param.getType())) {
            param.setType("0");
@@ -689,7 +686,10 @@
                OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
                        .eq("order_id", order.getId())
                        .eq("matnr", elem.getMatnr()));
                if (Objects.isNull(elem.getBoxType1())) {
                    throw new CoolException("格层编码不能为空!!");
                }
                detls.setBoxType1(elem.getBoxType1());
                if (Objects.isNull(detls)) {
                    throw new CoolException("数据错误:单据明细不存在!!");
                }
@@ -699,14 +699,14 @@
                }
                OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(),
                        elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
                        elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
                DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(),
                        "1", elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
                DetlDto detlDto = new DetlDto(order.getOrderNo(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(),
                        elem.getStandby2(), elem.getStandby3(),
                        elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(),
                        elem.getThreeCode());
                detlDto.setOrderId(order.getId());
                detlDto.setOrderNo(order.getOrderNo());
                if (DetlDto.has(detlDtos, detlDto)) {
                if (DetlDto.hasOrder(detlDtos, detlDto)) {
                    DetlDto one = DetlDto.findDto(detlDtos, detlDto);
                    assert one != null;
                    one.setAnfme(one.getAnfme() + detlDto.getAnfme());
@@ -762,6 +762,7 @@
                waitPakin.setThreeCode(detlDto.getThreeCode());
                waitPakin.setSuppCode(detlDto.getStandby1());
                waitPakin.setStandby1(detlDto.getStandby1());
                waitPakin.setBoxType1(detlDto.getBoxType1());
                waitPakin.setIoStatus("N"); // 入出状态
                waitPakin.setAnfme(detlDto.getAnfme()); // 数量
                waitPakin.setStatus("Y"); // 状态
@@ -991,7 +992,7 @@
                try {
                    response = new HttpHandler.Builder()
                            .setUri(MesConstant.URL)
                            .setPath(MesConstant.PACK_DOWN_URL)
                            .setPath(MesConstant.IN_DISPATCH_RESULT)
                            .setJson(JSON.toJSONString(mesCombParam))
                            .build()
                            .doPost();
@@ -999,11 +1000,11 @@
                    if (jsonObject.getInteger("code").equals(200)) {
                        success = true;
                    } else if (jsonObject.getInteger("code").equals(500)) {
                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL + MesConstant.PACK_DOWN_URL,
                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
                                JSON.toJSONString(mesCombParam), response);
                        throw new CoolException(jsonObject.getString("msg"));
                    } else {
                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL + MesConstant.PACK_DOWN_URL,
                        log.error("请求接口失败!!!url:{};request:{};response:{}", MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
                                JSON.toJSONString(mesCombParam), response);
                        throw new CoolException("上报mes系统失败");
                    }
@@ -1015,7 +1016,7 @@
                        // 保存接口日志
                        apiLogService.save(
                                "打包下线帮托上报",
                                MesConstant.URL + MesConstant.PACK_DOWN_URL,
                                MesConstant.URL + MesConstant.IN_DISPATCH_RESULT,
                                null,
                                "127.0.0.1",
                                JSON.toJSONString(mesCombParam),
@@ -1066,7 +1067,7 @@
                // }
                OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), detlDto.getMatnr(), detlDto.getBatch(),
                        detlDto.getBrand(), detlDto.getStandby1(), detlDto.getStandby2(), detlDto.getStandby3(),
                        detlDto.getBoxType1(), detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme());
                        "1", detlDto.getBoxType2(), detlDto.getBoxType3(), detlDto.getAnfme());
                // 保存入库通知档
                Mat mat = matService.selectByMatnr(detlDto.getMatnr());
                if (Cools.isEmpty(mat)) {
@@ -1741,7 +1742,7 @@
                    throw new CoolException("数据错误,站点不存在!!");
                }
                station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
                station.setBarcode(null);
                station.setBarcode("");
                if (!basStationService.updateById(station)) {
                    throw new CoolException("站点状态更新失败!!");
                }
@@ -1786,7 +1787,7 @@
        }
        station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
        station.setBarcode(null);
        station.setBarcode("");
        if (!basStationService.updateById(station)) {
            throw new CoolException("站点状态修改失败!");
        }
@@ -2195,8 +2196,14 @@
                    .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
                    .orderAsc(Arrays.asList("row1", "bay1", "lev1"))
                    .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
            if (Objects.isNull(locMast)) {
                throw new CoolException("未查询到可用的空板信息!!");
            }
            CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls);
            locMasts.add(crnTaskDetlDTO);
            // 空板出库
            generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station);
        }
@@ -2304,7 +2311,7 @@
        Task task = new Task();
        task.setWrkNo(workNo)
                .setIoTime(new Date())
                .setWrkSts(11L) // 工作状态:11.生成出库ID
                .setWrkSts(301L) // 工作状态:11.生成出库ID
                .setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 入出库状态: 11.库格移载
                .setTaskType("agv")
                .setIoPri(10D)
@@ -2381,11 +2388,6 @@
     */
    @Transactional(rollbackFor = Exception.class)
    public void generateAgvTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
        List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
        if (Objects.isNull(pakins) || pakins.isEmpty()) {
            throw new CoolException("组托信息不存在!!");
        }
        List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
        if (!tasks.isEmpty()) {
            throw new CoolException("托盘已在任务执行中..");
@@ -2396,7 +2398,7 @@
        Task task = new Task();
        task.setWrkNo(workNo)
                .setIoTime(new Date())
                .setWrkSts(1L) // 工作状态:11.生成出库ID
                .setWrkSts(201L) // 工作状态:11.生成出库ID
                .setIoType(1) // 入出库状态: 11.库格移载
                .setTaskType("agv")
                .setIoPri(10D)
@@ -2416,32 +2418,39 @@
            throw new CoolException("保存工作档失败");
        }
        for (WaitPakin pakin : pakins) {
            TaskDetl wrkDetl = new TaskDetl();
            BeanUtils.copyProperties(pakin, wrkDetl);
            wrkDetl.setId(null).setWrkNo(workNo)
                    .setIoTime(new Date())
                    .setOrderNo(pakin.getOrderNo())
                    .setAnfme(pakin.getAnfme())
                    .setZpallet(pakin.getZpallet())
                    .setBatch(pakin.getBatch())
                    .setMatnr(pakin.getMatnr())
                    .setMaktx(pakin.getMaktx())
                    .setAppeUser(userId)
                    .setUnit(pakin.getUnit())
                    .setModel(pakin.getModel())
                    .setAppeTime(new Date())
                    .setModiUser(userId);
            if (!taskDetlService.insert(wrkDetl)) {
                throw new CoolException("保存工作档明细失败");
        if (!type.equals("agv_back")) {
            List<WaitPakin> pakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
            if (Objects.isNull(pakins) || pakins.isEmpty()) {
                throw new CoolException("组托信息不存在!!");
            }
        }
            for (WaitPakin pakin : pakins) {
                TaskDetl wrkDetl = new TaskDetl();
                BeanUtils.copyProperties(pakin, wrkDetl);
                wrkDetl.setId(null).setWrkNo(workNo)
                        .setIoTime(new Date())
                        .setOrderNo(pakin.getOrderNo())
                        .setAnfme(pakin.getAnfme())
                        .setZpallet(pakin.getZpallet())
                        .setBatch(pakin.getBatch())
                        .setMatnr(pakin.getMatnr())
                        .setMaktx(pakin.getMaktx())
                        .setAppeUser(userId)
                        .setUnit(pakin.getUnit())
                        .setModel(pakin.getModel())
                        .setAppeTime(new Date())
                        .setModiUser(userId);
                if (!taskDetlService.insert(wrkDetl)) {
                    throw new CoolException("保存工作档明细失败");
                }
        for (WaitPakin pakin : pakins) {
            pakin.setIoStatus("Y");
            if (!waitPakinService.updateById(pakin)) {
                throw new CoolException("更新组托信息失败");
            }
            for (WaitPakin pakin : pakins) {
                pakin.setIoStatus("Y");
                if (!waitPakinService.updateById(pakin)) {
                    throw new CoolException("更新组托信息失败");
                }
            }
        }
@@ -2463,9 +2472,9 @@
            throw new CoolException("站点不存在!!");
        }
        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type) || station.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type)) {
            station.setLocSts("R"); // S.入库预约
//            station.setBarcode(barcode);
            station.setBarcode(barcode);
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
@@ -2531,7 +2540,7 @@
    }
    /**
     * 呼叫AGV返回
     * 呼叫AGV空台车返回
     * @author Ryan
     * @date 2025/9/24
     * @param callAgvBackParam
@@ -2550,9 +2559,16 @@
        if (Objects.isNull(locCache)) {
            return R.error("未查询到可用库位");
        }
        // 修改目标站点信息
        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", callAgvBackParam.getOrgSite()));
        if (Objects.isNull(station)) {
            throw new CoolException("站点不存在!!");
        }
        try {
            generateAgvTask("agv", locCache, callAgvBackParam.getOrgSite(), callAgvBackParam.getBarcode(), userId);
            //空台车回库
            generateAgvTask("agv_back", locCache, callAgvBackParam.getOrgSite(), station.getBarcode(), userId);
        } catch (Exception e) {
            e.printStackTrace();
            return R.error(e.getMessage());