1
10 小时以前 6c3cc6842009f3897c3fb18bef8a6634fe653818
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -51,6 +51,8 @@
    private WaveService waveService;
    @Autowired
    private BasStationService basStationService;
    @Autowired
    private LocItemWorkingService locItemWorkingService;
    /**
@@ -106,7 +108,7 @@
                //空容器出库
                DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                        .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                        .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPTY_OUT.type));
                        .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPTY_OUT.type).last("limit 1"));
                if (Objects.isNull(deviceSite)) {
                    throw new CoolException("站点不支持空容器出库!!");
                }
@@ -134,9 +136,9 @@
    @Synchronized
    @Transactional(rollbackFor = Exception.class)
    public synchronized void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
        if (Objects.isNull(map.getSiteNo())) {
            throw new CoolException("站点不能为空!");
        }
//        if (Objects.isNull(map.getSiteNo())) {
//            throw new CoolException("站点不能为空!");
//        }
        if (Objects.isNull(map.getItems()) || map.getItems().isEmpty()) {
            throw new CoolException("明细不能为空!");
        }
@@ -211,7 +213,7 @@
                    DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                            .eq(DeviceSite::getSite, siteNo)
                            .eq(!Objects.isNull(loc.getChannel()),DeviceSite::getChannel, loc.getChannel())
                            .eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type));
                            .eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type).last("limit 1"),false);
                    if (Objects.isNull(deviceSite)) {
                        throw new CoolException("站点不支持拣料出库!!");
                    }
@@ -220,8 +222,8 @@
                    if (resouce.equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)){
                        //全板出库
                        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                                .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type));
//                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                                .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)
                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                        if (Objects.isNull(deviceSite)) {
                            throw new CoolException("站点不支持越库!!");
                        }
@@ -229,8 +231,8 @@
                    } else {
                        //全板出库
                        DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                                .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type));
//                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                                .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type)
                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                        if (Objects.isNull(deviceSite)) {
                            throw new CoolException("站点不支持全板出库!!");
                        }
@@ -243,7 +245,7 @@
                DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                        .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                        .eq(DeviceSite::getSite, siteNo)
                        .eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type));
                        .eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type).last("limit 1"));
                if (Objects.isNull(deviceSite)) {
                    throw new CoolException("当前站点不支持盘点出库!!");
                }
@@ -286,7 +288,6 @@
                    throw new CoolException("主任务关联失败!!");
                }
            }
            List<TaskItem> taskItems = new ArrayList<>();
            listMap.get(key).forEach(item -> {
                TaskItem taskItem = new TaskItem();
@@ -340,7 +341,26 @@
                if (!locItemService.updateById(item)) {
                    throw new CoolException("库存信息修改失败!!");
                }
            });
            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
            List<LocItemWorking> workings = new ArrayList<>();
            for (LocItem item : locItems) {
                LocItemWorking working = new LocItemWorking();
                BeanUtils.copyProperties(item, working);
                working.setId(null)
                        .setTaskId(task.getId())
                        .setLocItemId(item.getId())
                        .setUpdateBy(loginUserId)
                        .setUpdateTime(new Date());
                workings.add(working);
            }
            if (!locItemWorkingService.saveBatch(workings)) {
                throw new CoolException("临时库存更新失败!!");
            }
            if (!taskItemService.saveBatch(taskItems)) {
                throw new CoolException("任务明细生成失败!!");
@@ -381,7 +401,7 @@
            //目标库位为空,自动获取新库位
            DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                    .eq(DeviceSite::getType, TaskType.TASK_TYPE_LOC_MOVE.type)
                    .eq(!Objects.isNull(orgLoc.getChannel()), DeviceSite::getChannel, orgLoc.getChannel()), false);
                    .eq(!Objects.isNull(orgLoc.getChannel()), DeviceSite::getChannel, orgLoc.getChannel()).last("limit 1"), false);
            if (Objects.isNull(deviceSite)) {
                throw new CoolException("站点信息不存在!!");
            }