自动化立体仓库 - WCS系统
#
whycq
2024-12-27 6048b67716ebce38c553dd722a31c23072547ee4
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -9,6 +9,7 @@
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.SortTheExecutionOfTheCarUtil;
import com.zy.asrs.utils.TimeCalculatorUtils;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.*;
@@ -20,6 +21,7 @@
import com.zy.core.thread.RgvThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -46,6 +48,9 @@
    private BasCircularShuttleService basCircularShuttleService;
    @Autowired
    private WrkMastService wrkMastService;
    @Value("${constant-parameters.perimeter}")
    private Long perimeter;
    /**
     * 站点任务检测  更新小车位置信息
     */
@@ -55,7 +60,7 @@
            if (wrkMasts.isEmpty()){
                return;
            }
            List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",false));
            List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",true));
            if (basDevpPositions.isEmpty()){
                log.error("获取所有站点信息异常");
                return;
@@ -85,9 +90,15 @@
                rgvPosition.add(rgvProtocol.getRgvPos());
                rgvPositionList.add(rgvPosition);
            }
            Integer rgvNo = SortTheExecutionOfTheCarUtil.LatelyAndGreaterThan(rgvPositionList, sitePosition);
            Integer rgvNo = SortTheExecutionOfTheCarUtil.LatelyAndGreaterThan(rgvPositionList, sitePosition,perimeter);
            if (rgvNo == -1){
                log.info("更新小车排序信息异常={}",rgvNo);
                return;
            }
            List<BasCircularShuttle> basCircularShuttleList = basCircularShuttleService.selectList(new EntityWrapper<BasCircularShuttle>().orderBy("rgv_id", true));
            if (basCircularShuttleList.get(0).getRgvNo().equals(rgvNo)){
                return;
            }
            int[][] ints = new int[basCircularShuttleList.size()][2];
            for (BasCircularShuttle basCircularShuttle : basCircularShuttleList){
@@ -166,14 +177,23 @@
     */
    public synchronized void DevpTaskNoRun() {
        try{
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time",true));
            if (wrkMasts.isEmpty()){
                return;
            }
            long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(wrkMasts.get(0).getModiTime(), new Date());
            if (differenceInSeconds<=100){
                return;
            }
            BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1));
            RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo());
            RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
            if (rgvProtocol == null) {
                return;
            }
            List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",false));
            Integer devNo = SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPositions, rgvProtocol.getRgvPos());
            List<BasDevpPosition> basDevpPositions = basDevpPositionService.selectList(new EntityWrapper<BasDevpPosition>().orderBy("plc_position",true));
            Integer devNo = SortTheExecutionOfTheCarUtil.LatelyAndLessThan(basDevpPositions, rgvProtocol.getRgvPos(),perimeter);
            BasDevpPosition[] basDevpPositionsList = SortTheExecutionOfTheCarUtil.devpNoSort(basDevpPositions, devNo);
            BasDevpPosition[] basDevpPositionsListUN = SortTheExecutionOfTheCarUtil.devpNoSortUN(basDevpPositionsList);
            List<List<WrkMast>> wrkMastLists = getWrkMastLists(basDevpPositionsListUN);
@@ -191,12 +211,14 @@
            List<WrkMast> wrkMastlistA = new ArrayList<>();
            List<WrkMast> wrkMastlistB = new ArrayList<>();
            for (BasDevpPosition basDevpPosition : basDevpPositionsListUN){
                WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("wrk_sts",1L));
                if (!Cools.isEmpty(wrkMast)){
                    if (SortTheExecutionOfTheCarUtil.devpNoSortbj(basDevpPositionsListUN,wrkMast.getSourceStaNo(),wrkMast.getStaNo())){
                        wrkMastlistA.add(wrkMast);
                    } else {
                        wrkMastlistB.add(wrkMast);
                List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("sta_no", basDevpPosition.getDevNo()).eq("wrk_sts", 1L).orderBy("modi_time",true));
                for (WrkMast wrkMast:wrkMastList){
                    if (!Cools.isEmpty(wrkMast)){
                        if (SortTheExecutionOfTheCarUtil.devpNoSortbj(basDevpPositionsListUN,wrkMast.getSourceStaNo(),wrkMast.getStaNo())){
                            wrkMastlistA.add(wrkMast);
                        } else {
                            wrkMastlistB.add(wrkMast);
                        }
                    }
                }
            }
@@ -214,12 +236,20 @@
        runRgv:
        for (List<WrkMast> wrkMastList : wrkMastLists){
            for (WrkMast wrkMast: wrkMastList){
                log.error("存在任务,RGV号={},任务数据={}", rgvId, JSON.toJSON(wrkMast));
                rgvId++;
                BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", 1L));
                BasCircularShuttle basCircularShuttle = basCircularShuttleService.selectOne(new EntityWrapper<BasCircularShuttle>().eq("rgv_id", rgvId));
                RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, basCircularShuttle.getRgvNo());
                RgvProtocol rgvProtocol = rgvThread.getRgvProtocol();
                if (rgvProtocol == null){
                    continue ;
                }
                List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("rgv_no", rgvProtocol.getRgvNo()).eq("wrk_sts", 2L));
                if (!wrkMasts.isEmpty()){
                    continue ;
                }
                if (rgvProtocol != null
                        && rgvProtocol.modeType == RgvModeType.AUTO
                        && (rgvProtocol.getStatusType() == RgvStatusType.IDLE || rgvProtocol.getStatusType() == RgvStatusType.ROAM)
@@ -254,6 +284,7 @@
                    break runRgv;
                }
            }
        }
    }