自动化立体仓库 - WMS系统
zhou zhou
1 天以前 6df97fba67b0e0698a02673e65c6eca00879d5be
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -11,6 +11,7 @@
import com.zy.asrs.entity.result.ForwardAGVTaskDTO;
import com.zy.asrs.entity.result.HIKApiDTO;
import com.zy.asrs.entity.result.HIKResultDTO;
import com.zy.asrs.enums.LocAreaType;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
@@ -117,6 +118,8 @@
    private BasStationService basStationService;
    @Autowired
    private BasContainerService basContainerService;
    @Autowired
    private BasAreasService basAreasService;
    @Override
    @Transactional
@@ -959,7 +962,6 @@
                        log.error("", e);
                    }
                }
            }
            // 生成入库单据
@@ -1187,13 +1189,12 @@
                .eq("frozen", 0)
                .ne("full_plt", "Y")
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type).orderAsc(Arrays.asList("row1"))));
    }
    /**
     * @author Ryan
     * @date 2025/9/22
     * @description: 呼叫AGV搬运
     * @description: 呼叫空车
     * @version 1.0
     */
    @Override
@@ -1255,6 +1256,7 @@
     */
    @Override
    public R OutCallAgv(AgvCallParams params, Long userId) {
        /**获取入库最早的一条数据**/
        LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>()
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type)
                .eq("frozen", 0)
@@ -1270,34 +1272,115 @@
            throw new CoolException("站点正在执行任务!!");
        }
        generateOutTask(station, locCaches, userId);
        /**生成缓存区出库任务*/
        generateCacheOutTask(station, locCaches, userId);
        /**生成立库出库任务*/
        generateCRNOutTask(locCaches);
        return R.ok();
    }
    @Override
    public R callEmptyCar(AgvCallParams params) {
    public R callEmptyCar(AgvCallParams params, Long userId) {
        List<LocCache> locSts = locCacheService.selectList(new EntityWrapper<LocCache>().eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type));
        if (locSts.isEmpty()){
        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getOrgSite()));
        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
                .eq("area_id", basAreas.getId())
        );
        if (locCaches.isEmpty()){
            throw new CoolException("暂无空板库位");
        }
        HIKApiDTO hikApiDTO =new HIKApiDTO()
                .setOrg(locSts.get(0).getLocNo())
                .setOrgType("05")
                .setTar(params.getTarSite())
                .setTarType("05")
                .setTaskType("GT5")
                .setPriority("1")
                .setCtnrType("2")
                ;
        HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
        if (!hikResultDTO.isSuccess()){
            return R.error(hikResultDTO.getMessage());
        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
                .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                .eq("dev_no", params.getTarSite()));
        if (Objects.isNull(station)) {
            throw new CoolException("站点正在执行任务!!");
        }
        generateCacheOutTask(station, locCaches.get(0), userId);
//        HIKApiDTO hikApiDTO =new HIKApiDTO()
//                .setOrg(locCaches.get(0).getLocNo())
//                .setOrgType("05")
//                .setTar(params.getTarSite())
//                .setTarType("05")
//                .setTaskType("GT5")
//                .setPriority("1")
//                .setCtnrType("2")
//                ;
//        HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
//        if (!hikResultDTO.isSuccess()){
//            return R.error(hikResultDTO.getMessage());
//        }
        return R.ok();
    }
    @Override
//    @Transactional(rollbackFor = Exception.class)
    public R collectionInCall(AgvCallParams params, Long userId) {
        if (Objects.isNull(params.getOrgSite())) {
            throw new CoolException("源站点不能为空!!");
        }
        List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", params.getBarcode()));
        if (!tasks.isEmpty()){
            throw new CoolException("托盘码已生成任务");
        }
        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
        List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
                .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_D.type)
                .eq("area_id", basAreas.getId())
        );
        if (locCaches.isEmpty()) {
            throw new CoolException("当前暂无空库位!!");
        }
        generateAgvTask("agv", locCaches.get(0), params.getOrgSite(), params.getBarcode(), userId);
        return R.ok();
    }
    /**
     * 生成立库出库任务
     * @author Ryan
     * @date 2025/12/3 8:06
     * @param locCaches
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void generateCRNOutTask(LocCache locCaches) {
        if (Objects.isNull(locCaches)) {
            throw new CoolException("库位不能为空!!");
        }
        BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
        if (Objects.isNull(basAreas)) {
            throw new CoolException("库区不存在!!");
        }
        List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
                .eq("area_id", basAreas.getAreaNo())
                .eq("loc_id", locCaches.getId()));
        if (Objects.isNull(locDetls)) {
            throw new CoolException("库存明细不存在!!");
        }
        //按物料编码分类
        Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMatnr));
        listMap.forEach((key, detls) -> {
        });
        locDetls.forEach(locDetl -> {
        });
    }
    /**
@@ -1307,7 +1390,7 @@
     * @version 1.0
     */
    @Transactional(rollbackFor = Exception.class)
    public void generateOutTask(BasStation station, LocCache loc, Long userId) {
    public void generateCacheOutTask(BasStation station, LocCache loc, Long userId) {
        // 获取工作号
        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
        // 保存工作档
@@ -1315,10 +1398,10 @@
        task.setWrkNo(workNo)
                .setIoTime(new Date())
                .setWrkSts(11L) // 工作状态:11.生成出库ID
                .setIoType(101) // 入出库状态: 11.库格移载
                .setIoType(loc.getLocSts().equals("D") ? 110 : 101) // 入出库状态: 11.库格移载
                .setTaskType("agv")
                .setIoPri(10D)
                .setFullPlt("Y") // 满板:Y
                .setFullPlt(loc.getLocSts().equals("D") ? "N" : "Y") // 满板:Y
                .setPicking("N") // 拣料
                .setExitMk("N")// 退出
                .setStaNo(station.getDevNo())
@@ -1334,33 +1417,32 @@
            throw new CoolException("保存工作档失败");
        }
        List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_id", loc.getId()));
        if (Objects.isNull(detls) || detls.isEmpty()) {
            throw new CoolException("数据错误:库位明细为空!!");
        if (!detls.isEmpty()) {
            List<TaskDetl> taskDetls = new ArrayList<>();
            detls.forEach(pakin -> {
                TaskDetl wrkDetl = new TaskDetl();
                BeanUtils.copyProperties(pakin, wrkDetl);
                wrkDetl.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);
                taskDetls.add(wrkDetl);
            });
            //保存工作档明细
            if (!taskDetlService.insertBatch(taskDetls)) {
                throw new CoolException("保存工作档明细失败");
            }
        }
        List<TaskDetl> taskDetls = new ArrayList<>();
        detls.forEach(pakin -> {
            TaskDetl wrkDetl = new TaskDetl();
            BeanUtils.copyProperties(pakin, wrkDetl);
            wrkDetl.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);
            taskDetls.add(wrkDetl);
        });
        //保存工作档明细
        if (!taskDetlService.insertBatch(taskDetls)) {
            throw new CoolException("保存工作档明细失败");
        }
        loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
        loc.setModiUser(userId);
@@ -1445,9 +1527,16 @@
        if (!taskDetlService.insertBatch(taskDetls)) {
            throw new CoolException("保存工作档明细失败");
        }
        pakins.forEach(pakin -> {pakin.setIoStatus("Y");});
        if (!waitPakinService.updateBatchById(pakins)) {
            throw new CoolException("更新组托信息失败");
        }
        // 修改目标库位状态
        if (loc.getLocSts().equals("O")) {
            loc.setLocSts("S"); // S.入库预约
        if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
            loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.入库预约
            loc.setModiTime(new Date());
            loc.setModiUser(userId);
            if (!locCacheService.updateById(loc)) {
@@ -1456,6 +1545,20 @@
        } else {
            throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$());
        }
        // 修改目标站点信息
        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
        if (station.getLocSts().equals("O")) {
            station.setLocSts("R"); // S.入库预约
            station.setBarcode(barcode);
            station.setModiTime(new Date());
            station.setModiUser(userId);
            if (!basStationService.updateById(station)) {
                throw new CoolException("更新目标库位状态失败");
            }
        } else {
            throw new CoolException("移转失败,目标库位状态:" + station.getLocSts());
        }
    }