自动化立体仓库 - WCS系统
*
lsh
5 天以前 ccd6309576bfa66ddf40b8a48202ced37c05333a
*
7个文件已添加
9个文件已修改
568 ■■■■ 已修改文件
src/main/java/com/zy/asrs/entity/BasDevpPosition.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/BasDevpPositionMapper.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/BasDevpPositionService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/BasDevpPositionServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/cache/RgvTaskCache.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/cache/TaskProtocolCache.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RgvStatusType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/RgvSlave.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/RgvProtocol.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/RgvTaskProtocol.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/RgvThread.java 299 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-prod.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BasDevpPositionMapper.xml 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/BasDevpPosition.java
New file
@@ -0,0 +1,52 @@
package com.zy.asrs.entity;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName("\"SOURCE\".\"asr_bas_devp_position\"")
public class BasDevpPosition implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @ApiModelProperty(value= "ID")
    @TableId(value = "ID", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty(value= "")
    @TableField("DEV_NO")
    private Integer devNo;
    @ApiModelProperty(value= "")
    @TableField("PLC_ID")
    private Integer plcId;
    @ApiModelProperty(value= "")
    @TableField("PLC_POSITION")
    private Long plcPosition;
    public BasDevpPosition() {}
    public BasDevpPosition(Integer devNo, Integer plcId, Long plcPosition) {
        this.devNo = devNo;
        this.plcId = plcId;
        this.plcPosition = plcPosition;
    }
//    BasDevpPosition basDevpPosition = new BasDevpPosition(
//            null,    //
//            null,    //
//            null    //
//    );
}
src/main/java/com/zy/asrs/mapper/BasDevpPositionMapper.java
New file
@@ -0,0 +1,12 @@
package com.zy.asrs.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zy.asrs.entity.BasDevpPosition;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface BasDevpPositionMapper extends BaseMapper<BasDevpPosition> {
}
src/main/java/com/zy/asrs/service/BasDevpPositionService.java
New file
@@ -0,0 +1,8 @@
package com.zy.asrs.service;
import com.baomidou.mybatisplus.service.IService;
import com.zy.asrs.entity.BasDevpPosition;
public interface BasDevpPositionService extends IService<BasDevpPosition> {
}
src/main/java/com/zy/asrs/service/impl/BasDevpPositionServiceImpl.java
New file
@@ -0,0 +1,12 @@
package com.zy.asrs.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zy.asrs.entity.BasDevpPosition;
import com.zy.asrs.mapper.BasDevpPositionMapper;
import com.zy.asrs.service.BasDevpPositionService;
import org.springframework.stereotype.Service;
@Service("basDevpPositionService")
public class BasDevpPositionServiceImpl extends ServiceImpl<BasDevpPositionMapper, BasDevpPosition> implements BasDevpPositionService {
}
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -19,13 +19,16 @@
import com.zy.core.CrnThread;
import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.RgvStatusCache;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
import com.zy.core.model.CrnSlave;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.RgvSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
@@ -1103,4 +1106,70 @@
        return taskWrk;
    }
    public boolean deviceDetection(RgvSlave slave){
        RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
        if (rgvProtocol == null) {
            return false;
        }
        if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L)
                || (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM))) {
            return false;
        }
        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
        if (rgvProtocolOther == null) {
            return false;
        }
        if (rgvProtocolOther.statusEnable){
            if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L)) {
                return false;
            }
        }
        return true;
    }
    public boolean rgvOtherStatusEnable(RgvSlave slave){
        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
        if (rgvProtocolOther == null) {
            return true;
        }
        if (rgvProtocolOther.statusEnable){
//            if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L)) {
                return true;
//            }
        }
        return false;
    }
    private void sc(){
        // 根据输送线plc遍历
        for (RgvSlave rgvSlave : slaveProperties.getRgv()) {
            if (!deviceDetection(rgvSlave)){
                continue;
            }
            RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(rgvSlave.getId());
            RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(rgvSlave.getOtherId());
            //求出当前车可运行范围
            Long[] farthestPoint = new Long[]{0L,0L};
            if (!rgvProtocolOther.statusEnable){
                farthestPoint = new Long[]{0L,0L};
            } else {
                if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)){
                }
            }
            // 遍历入库口
            for (RgvSlave.RgvStn inSta : rgvSlave.getRgvInSStn()) {
            }
        }
    }
}
src/main/java/com/zy/core/MainProcess.java
@@ -51,6 +51,8 @@
                    // 堆垛机异常信息记录
                    mainService.recCrnErr();
                } catch (Exception e) {
                    e.printStackTrace();
                }
src/main/java/com/zy/core/cache/RgvTaskCache.java
New file
@@ -0,0 +1,45 @@
package com.zy.core.cache;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.RgvTaskProtocol;
import java.util.concurrent.ConcurrentHashMap;
/**
 * Created by IX on 2025/02/21
 */
public class RgvTaskCache {
    // 本地缓存,键为 currentPosition,值为 DeviceStatus
    private static final ConcurrentHashMap<Integer, RgvTaskProtocol> cache = new ConcurrentHashMap<>();
    /**
     * 更新设备状态
     */
    public static void updateRgvStatus(RgvTaskProtocol status) {
        try {
            cache.put(status.getRgvNo(), status);
        } finally {
        }
    }
    /**
     * 获取设备状态
     */
    public static RgvTaskProtocol getRgvStatus(Integer RgvNo) {
        try {
            return cache.get(RgvNo);
        } finally {
        }
    }
    /**
     * 获取所有设备状态
     */
    public static ConcurrentHashMap<Integer, RgvTaskProtocol> getAllRgvStatus() {
        try {
            return new ConcurrentHashMap<>(cache); // 返回副本
        } finally {
        }
    }
}
src/main/java/com/zy/core/cache/TaskProtocolCache.java
@@ -66,6 +66,14 @@
    /**
     * 获取所有取任务
     */
    public List<TaskProtocol> getTakeOrPutTaskProtocol(short loaded) {
        if (loaded == 0){
            return getAllTakeTaskProtocol();
        } else if (loaded == 1){
            return getAllPutTaskProtocol();
        }
        return new ArrayList<>();
    }
    public List<TaskProtocol> getAllTakeTaskProtocol() {
//        lock.readLock().lock(); // 加读锁
        try {
src/main/java/com/zy/core/enums/RgvStatusType.java
@@ -4,6 +4,7 @@
    NONE(-1, "离线"),
    IDLE(0, "空闲"),
    ROAM(100000, "漫游"),
    WORKING(1, "作业中"),
    SOS(2, "报警"),
    FETCHING(11, "取货中"),
src/main/java/com/zy/core/model/RgvSlave.java
@@ -24,6 +24,10 @@
    private Integer otherId;
    private Long carBodyJiaoMing;
    private Long carBodyKunPeng;
    // RGV入库源站点
    private List<RgvStn> rgvInSStn = new ArrayList<>();
src/main/java/com/zy/core/model/protocol/RgvProtocol.java
@@ -49,6 +49,7 @@
     * RGV当前位置
     */
    public Long RgvPos = 0L;
    public Long RgvPosDestination = 0L;
    /**
     * 走行在定位
@@ -78,14 +79,14 @@
    public Float xDuration;
    /**
     * 是否避让
     * 车身
     */
    public Short Avoid;//0\1\2
    public Long carBodyJiaoMing = 0L;
    /**
     * 避让目的地
     * 车身
     */
    public Short AvoidingTheDestination;
    public Long carBodyKunPeng = 0L;
    /**
     * 是否启用
src/main/java/com/zy/core/model/protocol/RgvTaskProtocol.java
New file
@@ -0,0 +1,25 @@
package com.zy.core.model.protocol;
import lombok.Data;
/**
 * Created by IX on 2025/02/21
 */
@Data
public class RgvTaskProtocol {
    private Integer RgvNo;
    /**
     * 是否避让
     */
    public Integer Avoid;//0\1\2
    /**
     * 避让目的地
     */
    public Long AvoidingTheDestination;
    public RgvTaskProtocol(){}
}
src/main/java/com/zy/core/thread/RgvThread.java
@@ -14,10 +14,7 @@
import com.zy.asrs.service.BasRgvService;
import com.zy.asrs.utils.RouteUtils;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.RgvStatusCache;
import com.zy.core.cache.TaskProtocolCache;
import com.zy.core.cache.*;
import com.zy.core.enums.RgvModeType;
import com.zy.core.enums.RgvStatusType;
import com.zy.core.enums.RgvTaskModeType;
@@ -26,9 +23,11 @@
import com.zy.core.model.Task;
import com.zy.core.model.command.RgvCommand;
import com.zy.core.model.protocol.RgvProtocol;
import com.zy.core.model.protocol.RgvTaskProtocol;
import com.zy.core.model.protocol.TaskProtocol;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import java.text.MessageFormat;
import java.util.Date;
@@ -47,6 +46,12 @@
    private RgvSlave slave;
//    private RgvProtocol rgvProtocol;
    private TaskProtocolCache taskProtocolCache = new TaskProtocolCache();
    // # 轨道总长
    private Long trackEntireLength = 100L;
    //# 轨道基准点
    private Long trackBenchmark = 100L;
    //  # 避让距离
    private Long avoidDistance = 100L;
    /**
     * 工位1复位信号
@@ -71,10 +76,9 @@
            new Thread(this::readStatusRgv).start();
            // 启动任务下发线程
            new Thread(this::taskTakeIssued).start();
            new Thread(this::taskIssued).start();
            new Thread(this::taskPutIssued).start();
            // 启动漫游线程
            new Thread(this::taskWalkIssued).start();
        }
    }
@@ -97,9 +101,45 @@
    }
    /**
     * 漫游
     */
    private void taskWalkIssued() {
        while (true) {
            try {
                // 休眠 1 秒
                Thread.sleep(100);
                if (!deviceDetection()){
                    continue;
                }
                RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
                if (rgvTaskProtocol == null) {
                    initRgv();
                    rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
                }
                if (rgvTaskProtocol.getAvoid() != 1) {
                    continue;
                }
                TaskProtocol issued = new TaskProtocol();
                issued.setTaskNo(32222L);
                issued.setTargetPosition(rgvTaskProtocol.getAvoidingTheDestination());
                write(issued);
                rgvTaskProtocol.setAvoid(0);
                Thread.sleep(200);
                RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
            } catch (Exception e) {
                log.error("RGV行走任务下发线程异常!!!"+e.getMessage());
//                e.printStackTrace();
            }
        }
    }
    /**
     * 任务下发
     */
    private void taskTakeIssued() {
    private void taskIssued() {
        while (true) {
            try {
                // 休眠 1 秒
@@ -108,24 +148,28 @@
                    continue;
                }
                RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
                if (rgvProtocol == null) {
                RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
                if (rgvProtocol == null || rgvTaskProtocol == null) {
                    initRgv();
                    rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
                    rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
                }
                if (rgvProtocol.getAvoid() == 0 || !rgvProtocol.getLoaded().equals((short) 0)) {
                if (rgvTaskProtocol.getAvoid() != 0) {
                    continue;
                }
                List<TaskProtocol> allTakeTaskProtocol = taskProtocolCache.getAllTakeTaskProtocol();
                List<TaskProtocol> allTakeTaskProtocol = taskProtocolCache.getTakeOrPutTaskProtocol(rgvProtocol.getLoaded());
                for(TaskProtocol taskProtocol: allTakeTaskProtocol){
                    if (taskProtocol.getTaskStatus() == 1){//准备下发
                    if (taskProtocol.getIsRunning() == 1){//准备下发
                        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
                        //双车
                        if (rgvOtherStatusEnable()){
                            //另一台车是否允许此台车执行
                            if (!otherRgvAvoid(taskProtocol.getTargetPosition())){
                                continue;
                            }
                        }
                        Thread.sleep(200);
                        TaskProtocol issued = new TaskProtocol(taskProtocol);
                        write(issued);
                        taskProtocol.setIsRunning(taskProtocol.getIsRunning() +1);
@@ -133,8 +177,6 @@
                        break;
                    }
                }
            } catch (Exception e) {
                log.error("RGV取货任务下发线程异常!!!"+e.getMessage());
//                e.printStackTrace();
@@ -144,56 +186,176 @@
    public boolean deviceDetection(){
        RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
        if (rgvProtocol == null) {
        RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
        if (rgvProtocol == null || rgvTaskProtocol ==null) {
            return false;
        }
        if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L)
                || !rgvProtocol.getStatusType().equals(RgvStatusType.IDLE)) {
        if (!rgvProtocol.getModeType().equals(RgvModeType.AUTO) || rgvProtocol.getRgvPos().equals(0L) || rgvTaskProtocol.getAvoid() == -1 || rgvProtocol.getRgvPosDestination() == 0L
                || (!rgvProtocol.getStatusType().equals(RgvStatusType.IDLE) && !rgvProtocol.getStatusType().equals(RgvStatusType.ROAM))) {
            return false;
        }
        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
        RgvTaskProtocol rgvTaskProtocolOther = RgvTaskCache.getRgvStatus(slave.getOtherId());
        if (rgvProtocolOther == null) {
            return false;
        }
        if (rgvProtocolOther.statusEnable){
            if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L)) {
            if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L) || rgvTaskProtocolOther.getAvoid() == -1  || rgvProtocolOther.getRgvPosDestination() == 0L) {
                return false;
            }
        }
        return true;
    }
    /**
     * 任务下发
     */
    private void taskPutIssued() {
        while (true) {
            try {
                // 休眠 1 秒
                Thread.sleep(100);
            } catch (Exception e) {
                log.error("RGV放货任务下发线程异常!!!"+e.getMessage());
//                e.printStackTrace();
            }
    public boolean rgvOtherStatusEnable(){
        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
        if (rgvProtocolOther == null) {
            return true;
        }
        if (rgvProtocolOther.statusEnable){
//            if (!rgvProtocolOther.getModeType().equals(RgvModeType.AUTO) || rgvProtocolOther.getRgvPos().equals(0L)) {
            return true;
//            }
        }
        return false;
    }
    /**
     * 任务下发
     */
    private void taskWalkIssued() {
        while (true) {
            try {
                // 休眠 1 秒
                Thread.sleep(100);
    public boolean otherRgvAvoid(Long targetPosition){
        RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId());
        RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
        RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId());
            } catch (Exception e) {
                log.error("RGV行走任务下发线程异常!!!"+e.getMessage());
//                e.printStackTrace();
        if (rgvProtocol.getRgvPos()<rgvProtocolOther.getRgvPos()){
            if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)){
                if ((rgvProtocolOther.getRgvPos()-rgvProtocolOther.getCarBodyJiaoMing())
                        - (targetPosition+rgvProtocol.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing();
                    if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){
                        log.error("避让超出范围!!!任务异常  联系管理员!!!");
                        return false;
                    }
                    rgvTaskProtocol.setAvoid(1);
                    rgvTaskProtocol.setAvoidingTheDestination(avoid);
                    RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                    return true;
                }
            } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)){
                if ((rgvProtocolOther.getRgvPosDestination()-rgvProtocolOther.getCarBodyJiaoMing())
                        - (targetPosition+rgvProtocol.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing();
                    if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){
                        log.error("避让超出范围!!!任务异常  联系管理员!!!");
                        return false;
                    }
                    rgvTaskProtocol.setAvoid(1);
                    rgvTaskProtocol.setAvoidingTheDestination(avoid);
                    RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                    return true;
                }
            } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)){
                if ((rgvProtocolOther.getRgvPosDestination()-rgvProtocolOther.getCarBodyJiaoMing())
                        - (targetPosition+rgvProtocol.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvProtocolOther.getRgvNo());
                    TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache();
                    List<TaskProtocol> allPutTaskProtocol = taskProtocolCacheOther.getAllPutTaskProtocol();
                    if (allPutTaskProtocol.size() > 1){
                        return false;
                    }
                    for (TaskProtocol taskProtocol : allPutTaskProtocol){
                        if (taskProtocol.getTargetPosition()>=rgvProtocolOther.getRgvPos()){
                            long avoid = rgvProtocolOther.getRgvPos()-rgvProtocolOther.getCarBodyJiaoMing()-avoidDistance-rgvProtocol.getCarBodyKunPeng();
                            if (avoid > trackEntireLength-rgvProtocolOther.getCarBodyKunPeng()){
                                log.error("行走超出范围!!!任务异常  联系管理员!!!");
                                return false;
                            }
                            rgvTaskProtocol.setAvoid(1);
                            rgvTaskProtocol.setAvoidingTheDestination(avoid);
                            RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                            return false;
                        } else {
                            return false;
                        }
                    }
                    return false;
                }
            }
        } else {
            if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)){
                if ((targetPosition-rgvProtocol.getCarBodyJiaoMing())
                        - (rgvProtocolOther.getRgvPos()+rgvProtocolOther.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    long avoid = targetPosition -rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng();
                    if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){
                        log.error("避让超出范围!!!任务异常  联系管理员!!!");
                        return false;
                    }
                    rgvTaskProtocol.setAvoid(1);
                    rgvTaskProtocol.setAvoidingTheDestination(avoid);
                    RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                    return true;
                }
            } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)){
                if ((targetPosition-rgvProtocol.getCarBodyJiaoMing())
                        - (rgvProtocolOther.getRgvPosDestination()+rgvProtocolOther.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    long avoid = targetPosition -rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng();
                    if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){
                        log.error("避让超出范围!!!任务异常  联系管理员!!!");
                        return false;
                    }
                    rgvTaskProtocol.setAvoid(1);
                    rgvTaskProtocol.setAvoidingTheDestination(avoid);
                    RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                    return true;
                }
            } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)){
                if ((targetPosition-rgvProtocol.getCarBodyJiaoMing())
                        - (rgvProtocolOther.getRgvPosDestination()+rgvProtocolOther.getCarBodyKunPeng())
                        > avoidDistance){//无需避让
                    return true;
                } else {
                    RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvProtocolOther.getRgvNo());
                    TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache();
                    List<TaskProtocol> allPutTaskProtocol = taskProtocolCacheOther.getAllPutTaskProtocol();
                    if (allPutTaskProtocol.size() > 1){
                        return false;
                    }
                    for (TaskProtocol taskProtocol : allPutTaskProtocol){
                        if (taskProtocol.getTargetPosition()<=rgvProtocolOther.getRgvPos()){
                            long avoid = rgvProtocolOther.getRgvPos()+rgvProtocolOther.getCarBodyKunPeng()+avoidDistance+rgvProtocol.getCarBodyJiaoMing();
                            if (avoid < trackBenchmark + rgvProtocolOther.getCarBodyJiaoMing()){
                                log.error("行走超出范围!!!任务异常  联系管理员!!!");
                                return false;
                            }
                            rgvTaskProtocol.setAvoid(1);
                            rgvTaskProtocol.setAvoidingTheDestination(avoid);
                            RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
                            return false;
                        } else {
                            return false;
                        }
                    }
                    return false;
                }
            }
        }
        return false;
    }
    /**
@@ -213,14 +375,32 @@
        rgvProtocol.setxSpeed((short) 0);
        rgvProtocol.setxDistance((short) 0);
        rgvProtocol.setxDuration((short) 0);
        BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class);
        BasRgv rgv = basRgvService.selectById(slave.getId());
        if (!Cools.isEmpty(rgv)){
            rgvProtocol.setStatusEnable(rgv.getStatus() == 1);
        } else {
            rgvProtocol.setStatusEnable(false);
        rgvProtocol.setCarBodyJiaoMing(0L);
        rgvProtocol.setCarBodyKunPeng(0L);
        try{
            BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class);
            BasRgv rgv = basRgvService.selectById(slave.getId());
            if (!Cools.isEmpty(rgv)){
                rgvProtocol.setStatusEnable(rgv.getStatus() == 1);
            } else {
                rgvProtocol.setStatusEnable(false);
            }
        } catch (Exception e){
            log.error("RGV异常!!!"+e.getMessage());
            rgvProtocol.setStatusEnable(true);
        }
        RgvTaskProtocol rgvTaskProtocol = RgvTaskCache.getRgvStatus(slave.getId());
        if (rgvTaskProtocol == null) {
            rgvTaskProtocol = new RgvTaskProtocol();
            rgvTaskProtocol.setRgvNo(slave.getId());
        }
        rgvTaskProtocol.setAvoid(-1);
        rgvTaskProtocol.setAvoidingTheDestination(0L);
        RgvStatusCache.updateRgvStatus(rgvProtocol);
        RgvTaskCache.updateRgvStatus(rgvTaskProtocol);
    }
@@ -233,13 +413,14 @@
        OperateResult connect = siemensNet.ConnectServer();
        if(connect.IsSuccess){
            result = true;
            OutputQueue.RGV.offer(MessageFormat.format( "【{0}】RGV plc连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
//            OutputQueue.RGV.offer(MessageFormat.format( "【{0}】RGV plc连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.info("RGV plc连接成功 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
        } else {
            OutputQueue.RGV.offer(MessageFormat.format("【{0}】RGV plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
//            OutputQueue.RGV.offer(MessageFormat.format("【{0}】RGV plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("RGV plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            initRgv();
        }
        initRgv();
//        siemensNet.ConnectClose();
        return result;
    }
src/main/resources/application-prod.yml
@@ -40,6 +40,8 @@
    rack: 0
    slot: 0
    otherId: 2
    carBodyJiaoMing: 100
    carBodyKunPeng: 100
    #RGV源站点
    rgvInSStn[0]:
      devpPlcId: ${wcs-slave.devp[0].id}
@@ -50,11 +52,13 @@
  # RGV穿梭车2
  rgv[1]:
    id: 2
    ip: 192.168.4.250
    ip: 192.168.1.1
    port: 502
    rack: 0
    slot: 0
    otherId: 1
    carBodyJiaoMing: 100
    carBodyKunPeng: 100
    #RGV源站点
    rgvInSStn[0]:
      devpPlcId: ${wcs-slave.devp[0].id}
src/main/resources/application.yml
@@ -54,6 +54,8 @@
  trackBenchmark: 1
  # 轨道转换为米比例
  trackProportion: 10000
  # 避让距离
  avoidDistance: 100
wms:
  # 是否开启上报
src/main/resources/mapper/BasDevpPositionMapper.xml
New file
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zy.asrs.mapper.BasDevpPositionMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.asrs.entity.BasDevpPosition">
        <id column="ID" property="id" />
        <result column="DEV_NO" property="devNo" />
        <result column="PLC_ID" property="plcId" />
        <result column="PLC_POSITION" property="plcPosition" />
    </resultMap>
</mapper>