#
luxiaotao1123
2025-01-15 fd6d26f8ffe6a37533e741337f3eca9134d934c7
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/ValidService.java
@@ -37,11 +37,11 @@
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;
    public List<Task> validBusDto(List<TaskDto> taskDtoList) {
    public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) {
        List<Task> taskList = new ArrayList<>();
        for (TaskDto taskDto : taskDtoList) {
            if (Cools.isEmpty(taskDto.getSeqNum())) {
                throw new BusinessException("seqNum不能为空");
                throw new BusinessException("Task seqNum can't be empty!");
            }
            Task task = new Task();
            taskList.add(task);
@@ -53,22 +53,24 @@
            if (!Cools.isEmpty(taskDto.getOriLoc())) {
                Loc oriLoc = locService.selecatByLocNo(taskDto.getOriLoc());
                if (null == oriLoc) {
                    throw new BusinessException("oriLoc: " + taskDto.getOriLoc() + "不存在");
                    throw new BusinessException("oriLoc: " + taskDto.getOriLoc() + " doesn't exist!");
                }
                task.setOriLoc(oriLoc.getId());
//                task.setOriCode(oriLoc.getCode());
            }
            if (!Cools.isEmpty(taskDto.getOriSta())) {
                Sta oriSta = staService.selectByStaNo(taskDto.getOriSta());
                if (null == oriSta) {
                    throw new BusinessException("oriSta: " + taskDto.getOriSta() + "不存在");
                    throw new BusinessException("oriSta: " + taskDto.getOriSta() + " doesn't exist!");
                }
                task.setOriSta(oriSta.getId());
//                task.setOriCode(oriSta.getCode());
            }
            // dest --------------------------
            if (!Cools.isEmpty(taskDto.getDestLoc())) {
                Loc destLoc = locService.selecatByLocNo(taskDto.getDestLoc());
                if (null == destLoc) {
                    throw new BusinessException("destLoc: " + taskDto.getDestLoc() + "不存在");
                    throw new BusinessException("destLoc: " + taskDto.getDestLoc() + " doesn't exist!");
                }
                task.setDestLoc(destLoc.getId());
                task.setDestCode(destLoc.getCode());
@@ -76,7 +78,7 @@
            if (!Cools.isEmpty(taskDto.getDestSta())) {
                Sta destSta = staService.selectByStaNo(taskDto.getDestSta());
                if (null == destSta) {
                    throw new BusinessException("destSta: " + taskDto.getDestSta() + "不存在");
                    throw new BusinessException("destSta: " + taskDto.getDestSta() + " doesn't exist!");
                }
                task.setDestSta(destSta.getId());
                task.setDestCode(destSta.getCode());
@@ -84,16 +86,16 @@
            // task-type ----------------------------------
            if (null == task.getOriLoc() && null == task.getOriSta()) {
                throw new BusinessException(task.getSeqNum() + " 错误,oriLoc和oriSta必须存在一项");
                throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong,there must be at least one of oriLoc and oriSta");
            }
            if (null != task.getOriLoc() && null != task.getOriSta()) {
                throw new BusinessException(task.getSeqNum() + " 错误,oriLoc和oriSta只能存在一项");
                throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong,there must be at least one of oriLoc and oriSta");
            }
            if (null == task.getDestLoc() && null == task.getDestSta()) {
                throw new BusinessException(task.getSeqNum() + " 错误,destLoc和destSta必须存在一项");
                throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong,either destLoc and destSta must be present");
            }
            if (null != task.getDestLoc() && null != task.getDestSta()) {
                throw new BusinessException(task.getSeqNum() + " 错误,destLoc和destSta只能存在一项");
                throw new BusinessException("seNum:" + task.getSeqNum() + " is wrong,either destLoc and destSta must be present");
            }
            if (null != task.getOriSta()) {
                if (null != task.getDestLoc()) {
@@ -125,17 +127,17 @@
                    oriLoc = locService.getById(task.getOriLoc());
                    destLoc = locService.getById(task.getDestLoc());
                    startCode = codeService.getById(oriLoc.getCode());
                    endCode = codeService.getById(destLoc.getCode());
                    startCode = codeService.getCacheById(oriLoc.getCode());
                    endCode = codeService.getCacheById(destLoc.getCode());
                    if (null == startCode) {
                        throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 未绑定地面码");
                        throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " hasn't been bound to a QrCode yet");
                    }
                    if (null == endCode) {
                        throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 未绑定地面码");
                        throw new BusinessException("destLoc:" + destLoc.getLocNo() + " is not bound to a QrCode yet");
                    }
                    pathList = mapService.validFeasibility(startCode, endCode);
                    if (Cools.isEmpty(pathList)) {
                        throw new BusinessException(task.getSeqNum() + "任务错误,oriLoc:" + task.getOriLoc() + "无法行走至 destLoc" + task.getDestLoc());
                        throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrong,oriLoc:" + task.getOriLoc() + " is unable to reach destLoc" + task.getDestLoc());
                    }
                    task.setPhase(JSON.toJSONString(pathList));
                    break;
@@ -143,17 +145,17 @@
                    oriLoc = locService.getById(task.getOriLoc());
                    destSta = staService.getById(task.getDestSta());
                    startCode = codeService.getById(oriLoc.getCode());
                    endCode = codeService.getById(destSta.getCode());
                    startCode = codeService.getCacheById(oriLoc.getCode());
                    endCode = codeService.getCacheById(destSta.getCode());
                    if (null == startCode) {
                        throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " 未绑定地面码");
                        throw new BusinessException("oriLoc:" + oriLoc.getLocNo() + " hasn't been bound to QrCode yet");
                    }
                    if (null == endCode) {
                        throw new BusinessException("destSta:" + destSta.getStaNo() + " 未绑定地面码");
                        throw new BusinessException("destSta:" + destSta.getStaNo() + " is not bound to QrCode yet");
                    }
                    pathList = mapService.validFeasibility(startCode, endCode);
                    if (Cools.isEmpty(pathList)) {
                        throw new BusinessException(task.getSeqNum() + "任务错误,oriLoc:" + task.getOriLoc() + "无法行走至 destSta" + task.getDestSta());
                        throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrong,oriLoc:" + task.getOriLoc() + " can't move to destSta" + task.getDestSta());
                    }
                    task.setPhase(JSON.toJSONString(pathList));
                    break;
@@ -161,17 +163,17 @@
                    oriSta = staService.getById(task.getOriSta());
                    destLoc = locService.getById(task.getDestLoc());
                    startCode = codeService.getById(oriSta.getCode());
                    endCode = codeService.getById(destLoc.getCode());
                    startCode = codeService.getCacheById(oriSta.getCode());
                    endCode = codeService.getCacheById(destLoc.getCode());
                    if (null == startCode) {
                        throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 未绑定地面码");
                        throw new BusinessException("oriSta:" + oriSta.getStaNo() + " hasn't bound to QrCode yet");
                    }
                    if (null == endCode) {
                        throw new BusinessException("destLoc:" + destLoc.getLocNo() + " 未绑定地面码");
                        throw new BusinessException("destLoc:" + destLoc.getLocNo() + " is not bound to QrCode yet");
                    }
                    pathList = mapService.validFeasibility(startCode, endCode);
                    if (Cools.isEmpty(pathList)) {
                        throw new BusinessException(task.getSeqNum() + "任务错误,oriSta:" + task.getOriSta() + "无法行走至 destLoc" + task.getDestLoc());
                        throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrong,oriSta:" + task.getOriSta() + " is unable to react destLoc" + task.getDestLoc());
                    }
                    task.setPhase(JSON.toJSONString(pathList));
                    break;
@@ -179,22 +181,22 @@
                    oriSta = staService.getById(task.getOriSta());
                    destSta = staService.getById(task.getDestSta());
                    startCode = codeService.getById(oriSta.getCode());
                    endCode = codeService.getById(destSta.getCode());
                    startCode = codeService.getCacheById(oriSta.getCode());
                    endCode = codeService.getCacheById(destSta.getCode());
                    if (null == startCode) {
                        throw new BusinessException("oriSta:" + oriSta.getStaNo() + " 未绑定地面码");
                        throw new BusinessException("oriSta:" + oriSta.getStaNo() + " hasn't been bound to a QrCode yet");
                    }
                    if (null == endCode) {
                        throw new BusinessException("destSta:" + destSta.getStaNo() + " 未绑定地面码");
                        throw new BusinessException("destSta:" + destSta.getStaNo() + " is not bound to a QrCode yet");
                    }
                    pathList = mapService.validFeasibility(startCode, endCode);
                    if (Cools.isEmpty(pathList)) {
                        throw new BusinessException(task.getSeqNum() + "任务错误,oriSta:" + task.getOriSta() + "无法行走至 destSta" + task.getDestSta());
                        throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrong,oriSta:" + task.getOriSta() + " can't move to destSta" + task.getDestSta());
                    }
                    task.setPhase(JSON.toJSONString(pathList));
                    break;
                default:
                    throw new BusinessException(task.getSeqNum() + "任务类型错误");
                    throw new BusinessException("seqNum:" + task.getSeqNum() + " is wrong, cause this type not exist");
            }
        }