skyouc
4 天以前 e5d2c6f2eb8cc33675308d7d33fd4029d5fd2e34
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/TaskController.java
@@ -6,17 +6,17 @@
import com.vincent.rsf.framework.common.Cools;
import com.vincent.rsf.framework.common.R;
import com.vincent.rsf.framework.exception.CoolException;
import com.vincent.rsf.server.api.entity.enums.TaskStsType;
import com.vincent.rsf.server.manager.entity.*;
import com.vincent.rsf.server.manager.enums.*;
import com.vincent.rsf.server.common.utils.ExcelUtil;
import com.vincent.rsf.server.common.annotation.OperationLog;
import com.vincent.rsf.server.common.domain.BaseParam;
import com.vincent.rsf.server.common.domain.KeyValVo;
import com.vincent.rsf.server.common.domain.PageParam;
import com.vincent.rsf.server.manager.entity.Task;
import com.vincent.rsf.server.manager.entity.TaskItem;
import com.vincent.rsf.server.manager.service.TaskItemService;
import com.vincent.rsf.server.manager.service.TaskService;
import com.vincent.rsf.server.manager.service.*;
import com.vincent.rsf.server.manager.service.impl.BasStationServiceImpl;
import com.vincent.rsf.server.system.controller.BaseController;
import com.vincent.rsf.server.system.enums.LocStsType;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -34,6 +34,14 @@
    @Autowired
    private TaskItemService taskItemService;
    @Autowired
    private WaitPakinService waitPakinService;
    @Autowired
    private LocService locService;
    @Autowired
    private BasStationService basStationService;
    @PreAuthorize("hasAuthority('manager:task:list')")
    @PostMapping("/task/page")
@@ -100,6 +108,63 @@
        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");
        }
@@ -141,8 +206,15 @@
//        if (tasks.isEmpty()) {
//            throw new CoolException("任务已处执行状态不可一键完成!!");
//        }
        taskService.completeTask(tasks);
        return R.ok();
//        taskService.completeTask(tasks);
        for (Task task : tasks) {
            task.setTaskStatus(task.getTaskType() < (short)100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.COMPLETE_OUT.id);
        }
        if (!taskService.updateBatchById(tasks)){
            return R.error("完成任务失败");
        }
        return R.ok("完成任务成功");
    }
    @PreAuthorize("hasAuthority('manager:task:update')")
@@ -154,7 +226,6 @@
        }
        return R.ok();
    }
    @PreAuthorize("hasAuthority('manager:task:update')")
    @ApiOperation("任务出库置顶")