#
Junjie
2023-10-23 8ecad328df8465b3d81c15e37943f6e9d3adf86b
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -25,6 +25,8 @@
import com.zy.core.model.protocol.*;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.*;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -104,6 +106,8 @@
    private WrkMastLocMapper wrkMastLocMapper;
    @Autowired
    private BasLiftOptService basLiftOptService;
    @Autowired
    private ConfigService configService;
    /**
@@ -524,6 +528,7 @@
                            wrkMast.setStaNo(liftStaProtocol.getStaNo());//目标站
                            wrkMast.setLocNo(sourceLocNo); // 目标库位 = 出库时的源库位
                            wrkMast.setShuttleNo(null); // 穿梭车清空
                            wrkMast.setLiftNo(null);// 提升机清空
                            wrkMast.setModiTime(new Date());
                            if (wrkMastMapper.updateById(wrkMast) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
@@ -1323,6 +1328,8 @@
                                if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) {
                                    //不需要用到机械臂,直接转29.出库完成
                                    wrkMast.setWrkSts(29L);
                                    wrkMast.setShuttleNo(null);//释放小车
                                    wrkMast.setLiftNo(null);//释放提升机
                                }
                            }
@@ -1497,7 +1504,7 @@
            }
            //获取穿梭车最近且空闲的提升机输送站点
            LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId());
            LiftStaProtocol liftSta = shuttleDispatchUtils.getRecentLiftSta(shuttleThread.getSlave().getId(), Utils.getLev(wrkMast.getLocNo()));
            if (liftSta == null) {
                return false;//没有可用且空闲的输送站点
            }
@@ -2060,6 +2067,7 @@
                                //覆盖工作档目标站
                                wrkMast.setStaNo(targetSta.intValue());
                                wrkMast.setShuttleNo(null);//释放小车
                                wrkMast.setLiftNo(null);//释放提升机
                                if (wrkMastMapper.updateById(wrkMast) > 0) {
                                    //向300站写入目标站
                                    staProtocol = staProtocol.clone();
@@ -2081,6 +2089,7 @@
//                        //覆盖工作档目标站
//                        wrkMast.setStaNo(targetSta.intValue());
//                        wrkMast.setShuttleNo(null);//释放小车
//                        wrkMast.setLiftNo(null);//释放提升机
//                        if (wrkMastMapper.updateById(wrkMast) > 0) {
//                            //向300站写入目标站
//                            staProtocol = staProtocol.clone();
@@ -2152,9 +2161,9 @@
                continue;
            }
            if (staProtocol309.isAutoing() && staProtocol309.isLoading()) {
            if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 11);//308站条码器
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器
                if (barcodeThread == null) {
                    continue;
                }
@@ -2162,10 +2171,13 @@
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-301-001-01@3", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            } else if (staProtocol312.isAutoing() && staProtocol312.isLoading()) {
            }
            if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 12);//311站条码器
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器
                if (barcodeThread == null) {
                    continue;
                }
@@ -2173,6 +2185,7 @@
                if(!Cools.isEmpty(barcode)) {
                    //通知AGV取货
                    agvRestockCall("CS-302-001-01@3", barcode);
                    log.info("通知AGV取货,条码号:" + barcode);
                }
            }
        }
@@ -2219,7 +2232,7 @@
                    continue;
                }
                if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成
                if (wrkMast.getWrkSts() != 29) {//29.出库完成
                    continue;
                }
@@ -2229,6 +2242,7 @@
                    //覆盖工作档目标站
                    wrkMast.setStaNo(sourceStaNo);
                    wrkMast.setSourceStaNo(staNo);
                    wrkMast.setMk("N");
                    if (wrkMastMapper.updateById(wrkMast) > 0) {
                        //向300站写入目标站
                        staProtocol = staProtocol.clone();
@@ -2540,7 +2554,16 @@
                }
            } else if (wrkCharge.getWrkSts() == 52) {
                //检测小车是否满电
                //获取满电阈值
                int maxPower = 95;
                EntityWrapper<Config> wrapper = new EntityWrapper<>();
                wrapper.eq("code", "chargeMaxValue");
                Config config = configService.selectOne(wrapper);
                if (config != null) {
                    maxPower = Integer.parseInt(config.getValue());
                }
                if (shuttleProtocol.getPowerPercent() < maxPower) {
                    continue;
                }
@@ -2834,6 +2857,27 @@
                return false;
            }
            //*************尝试锁定目标站路径***************
            //获取目标站
            LiftStaProtocol targetLiftSta = NyLiftUtils.getLiftStaByStaNo(wrkMast.getStaNo());
            if (targetLiftSta == null) {
                return false;//找不到站点
            }
            NavigateNode targetNode = NavigatePositionConvert.locNoToNode(targetLiftSta.getLocNo());//目标节点
            NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(wrkMast.getLocNo()));
            List<NavigateNode> targetNodes = new ArrayList<>();
            targetNodes.add(targetNode);
            boolean checkPathIsAvailable = NavigateUtils.checkPathIsAvailable(targetNodes, shuttleProtocol.getShuttleNo().intValue(), Utils.getLev(wrkMast.getLocNo()), null);
            if (!checkPathIsAvailable) {
                return false;//检测目标站点路径是否未被占用
            }
            //尝试锁定目标站路径
            boolean result = navigateMapData.writeNavigateNodeToRedisMap(targetNodes, true);//所使用的路径进行锁定禁用
            if (!result) {
                return false;//路径锁定失败
            }
            //*************尝试锁定目标站路径***************
            //站点节点
            NavigateNode staNode = NavigatePositionConvert.locNoToNode(sourceLiftSta.getLocNo());
@@ -3036,6 +3080,19 @@
            if (basLift.getPoint() == null) {
                return false;//没有设置提升机点位坐标
            }
            //*************尝试解锁目标站路径***************
            NavigateNode targetNode = NavigatePositionConvert.locNoToNode(liftSta.getLocNo());//目标节点
            NavigateMapData navigateMapData = new NavigateMapData(Utils.getLev(wrkMast.getLocNo()));
            List<NavigateNode> targetNodes = new ArrayList<>();
            targetNodes.add(targetNode);
            //尝试解锁目标站路径
            boolean result = navigateMapData.writeNavigateNodeToRedisMap(targetNodes, false);//所使用的路径进行解锁
            if (!result) {
                return false;//路径解锁失败
            }
            //*************尝试解锁目标站路径***************
            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
            liftNode.setZ(liftSta.getLev());