自动化立体仓库 - WMS系统
skyouc
2 天以前 b4c6f129662be7fb14f71235817a24e15f824449
src/main/java/com/zy/api/service/impl/AgvScheduleServiceImpl.java
@@ -15,6 +15,7 @@
import com.zy.asrs.entity.result.HIKResultDTO;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.enums.TaskIOType;
import com.zy.asrs.enums.TaskStatusType;
import com.zy.asrs.service.ApiLogService;
import com.zy.asrs.service.LocCacheService;
import com.zy.asrs.service.TaskService;
@@ -24,8 +25,10 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@@ -48,47 +51,80 @@
     * @version 1.0
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R callAgvCarry(CallAgvParams params) {
        if (params.getType().equals(OrderType.ORDER_OUT.type)) {
            //缓存区出库
        } else if (params.getType().equals(OrderType.ORDER_IN.type)) {
            //缓存区入库
        } else {
        if (Objects.isNull(params)) {
            return R.error("参数不能为空!!");
        }
        if (Objects.isNull(params.getWrkNo())) {
            return R.error("任务号不能为空!!");
        }
        Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", params.getWrkNo()));
        if (Objects.isNull(task)) {
            return R.error("任务信息不存在!!");
        }
        if (Arrays.asList(TaskIOType.ALL_IN.type, TaskIOType.PICK_IN.type, TaskIOType.MERGE_IN.type)
                .contains(task.getIoType())) {
            // 入库
            task.setWrkSts(TaskStatusType.AGV_TASK_ISSUED_IN.type);
        } else if (Arrays.asList(TaskIOType.ALL_OUT.type, TaskIOType.PICK_OUT.type, TaskIOType.MERGE_OUT.type)
                .contains(task.getIoType())) {
            // 出库
            task.setWrkSts(TaskStatusType.AGV_TASK_ISSUED_OUT.type);
        }
        if (!taskService.updateById(task)) {
            throw new CoolException("任务状态更新失败!!");
        }
        return R.ok();
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public R callback(CallAgvParams params) {
        //TODO 1. 搬运完成,修改站点库位状态
        if (params.getType().equals(OrderType.ORDER_OUT.type)) {
            //出库单
            if (params.getStatus().equals("RUNING")) {
                LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", params.getOrgLoc()));
                if (Objects.isNull(locCache)) {
                    throw new CoolException("库位信息不存在!!");
        if (Objects.isNull(params)) {
            return R.error("参数不能为空!!");
                }
                if (!locCache.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
                    locCache.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
        if (Objects.isNull(params.getWrkNo())) {
            return R.error("任务号不能为空!!");
                }
            } else if (params.getStatus().equals("FINISHED")) {
                Task task = taskService.selectOne(new EntityWrapper<Task>().eq("wrk_no", params.getWrkNo()));
                if (Objects.isNull(task)) {
                    throw new CoolException("任务信息不存在!!");
            return R.error("任务信息不存在!!");
                }
//        if (!Arrays.asList(TaskStatusType.AGV_TASK_ISSUED_IN.type, TaskStatusType.AGV_TASK_ISSUED_OUT.type).contains(task.getIoType())) {
//            return R.error("");
//        }
//
        if (Arrays.asList(TaskIOType.ALL_IN.type, TaskIOType.PICK_IN.type, TaskIOType.MERGE_IN.type)
                .contains(task.getIoType())) {
            // 入库
            if (params.getStatus().equals("RUNNING")) {
                task.setWrkSts(TaskStatusType.AGV_TASK_RUNNING_IN.type);
            } else if (params.getStatus().equals("FINISHED")){
                task.setWrkSts(TaskStatusType.AGV_TASK_FINISHED_IN.type);
            }
        } else if (Arrays.asList(TaskIOType.ALL_OUT.type, TaskIOType.PICK_OUT.type, TaskIOType.MERGE_OUT.type)
                .contains(task.getIoType())) {
            // 出库
            if (params.getStatus().equals("RUNNING")) {
                task.setWrkSts(TaskStatusType.AGV_TASK_RUNNING_OUT.type);
            } else if (params.getStatus().equals("FINISHED")){
                task.setWrkSts(TaskStatusType.AGV_TASK_FINISHED_OUT.type);
            }
        }
                if (!taskService.updateById(task)) {
                    throw new CoolException("任务状态更新失败!!");
                }
            }
        } else {
            //入库单
            throw new CoolException("状态修改失败!!");
        }
        return null;
        return R.ok("执行完成 !!");
    }
    public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO, String path) {
        HIKResultDTO result = new HIKResultDTO();
@@ -99,8 +135,10 @@
        forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType());
        forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority());
        List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>();
        positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType()));
        positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType()));
        positionCodePathsList
                .add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType()));
        positionCodePathsList
                .add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType()));
        forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
        String body = JSON.toJSONString(forwardAGVTaskParam);
        String response = "";
@@ -132,14 +170,12 @@
                        "127.0.0.1",
                        body,
                        response,
                        result.isSuccess()
                );
                        result.isSuccess());
            } catch (Exception e) {
                log.error("", e);
            }
        }
        return result;
    }
}