skyouc
1 天以前 45430b88dab1451ecff39236dab01d5668b5b9c8
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java
@@ -31,17 +31,13 @@
    @Autowired
    private TaskService taskService;
    @Autowired
    private TaskItemService taskItemService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private LocService locService;
    @Autowired
    private BasStationService basStationService;
    @PreAuthorize("hasAuthority('manager:task:list')")
    @PostMapping("/task/page")
@@ -103,75 +99,8 @@
        if (Objects.isNull(ids) || ids.length < 1) {
            return R.error("参数不能为空!!");
        }
        List<Short> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, ids).in(Task::getTaskStatus, longs));
        if (tasks.isEmpty()) {
            throw new CoolException("任务已处执行状态不可取消!!");
        }
        for (Task task : tasks) {
            //恢复组托状态
            WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
                    .eq(WaitPakin::getBarcode, task.getBarcode())
            );
            if (null != waitPakin) {
                waitPakin.setIoStatus(Short.valueOf(PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
                if (!waitPakinService.updateById(waitPakin)) {
                    throw new CoolException("更新组托状态失败!!");
                }
            }
            Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>()
                    .eq(Loc::getCode, task.getTaskType() < 100 ? task.getTargLoc() : task.getOrgLoc())
            );
            if (null != loc
                    && (loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)
                    || loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type))) {
                loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
                if (!locService.updateById(loc)) {
                    throw new CoolException("更新库位状态失败!!");
                }
            }
            if (task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.id)){
                BasStation basStation = null;
                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
                        || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
                ){
                    basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                            .eq(BasStation::getStationName, task.getOrgSite())
                            .eq(BasStation::getUseStatus, StaUseStatusType.TYPE_R.type)
                    );
                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
                        || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_IN.type)
                        || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
                        || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
                        || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
                ) {
                    basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                            .eq(BasStation::getStationName, task.getTargLoc())
                            .eq(BasStation::getUseStatus, StaUseStatusType.TYPE_R.type)
                    );
                }
                if (null == basStation) {
                    throw new CoolException("站点状态错误!!");
                }
                basStation.setUseStatus(StaUseStatusType.TYPE_F.type);
                if (!basStationService.updateById(basStation)){
                    throw new CoolException("更新站点状态失败!!");
                }
            }
        }
        if (!taskService.removeByIds(Arrays.asList(ids))) {
            return R.error("Delete Fail");
        }
        if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, ids))) {
            return R.error("Details delete Failed");
        }
        return R.ok("Delete Success").add(ids);
       return taskService.removeTask(ids);
//        return R.ok("Delete Success").add(ids);
    }
    @PreAuthorize("hasAuthority('manager:task:list')")
@@ -203,30 +132,40 @@
        }
        List<Short> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getId, id).in(Task::getTaskStatus, longs));
//        if (tasks.isEmpty()) {
//            throw new CoolException("任务已处执行状态不可一键完成!!");
//        }
//        taskService.completeTask(tasks);
        for (Task task : tasks) {
            task.setTaskStatus(task.getTaskType() < (short)100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id);
            task.setTaskStatus(task.getTaskType() < (short) 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id);
        }
        if (!taskService.updateBatchById(tasks)){
        if (!taskService.updateBatchById(tasks)) {
            return R.error("完成任务失败");
        }
        return R.ok("完成任务成功");
    }
    /**
     * 拣料出库
     * @return
     */
    @PreAuthorize("hasAuthority('manager:task:update')")
    @ApiOperation("取消任务")
    @PostMapping("/task/cancel/{id}")
    public R cancelTask(@PathVariable String id) {
    @ApiOperation("拣料出库")
    @PostMapping("/task/pick/{id}")
    public R pickTask(@PathVariable Long id) {
        if (Objects.isNull(id)) {
            throw new CoolException("参数不能为空!!");
            throw new CoolException("能数不能为空!!");
        }
        return R.ok();
        return taskService.pickTask(id);
    }
//    @PreAuthorize("hasAuthority('manager:task:update')")
//    @ApiOperation("取消任务")
//    @PostMapping("/task/cancel/{id}")
//    public R cancelTask(@PathVariable String id) {
//        if (Objects.isNull(id)) {
//            throw new CoolException("参数不能为空!!");
//        }
//        return R.ok();
//    }
    @PreAuthorize("hasAuthority('manager:task:update')")
    @ApiOperation("任务出库置顶")
    @PostMapping("/task/top/{id}")