#
whycq
2024-12-27 dffb5d9f57b6c4782e80ba7b7186ff9d43cfde40
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -21,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;
@@ -47,6 +48,9 @@
    private BasCircularShuttleService basCircularShuttleService;
    @Autowired
    private WrkMastService wrkMastService;
    @Value("${constant-parameters.perimeter}")
    private Long perimeter;
    /**
     * 站点任务检测  更新小车位置信息
     */
@@ -56,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;
@@ -86,8 +90,11 @@
                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;
@@ -170,12 +177,12 @@
     */
    public synchronized void DevpTaskNoRun() {
        try{
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time",false));
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 1L).orderBy("modi_time",true));
            if (wrkMasts.isEmpty()){
                return;
            }
            long differenceInSeconds = TimeCalculatorUtils.differenceInSeconds(wrkMasts.get(0).getModiTime(), new Date());
            if (differenceInSeconds<=5){
            long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(wrkMasts.get(0).getModiTime(), new Date());
            if (differenceInSeconds<=100){
                return;
            }
@@ -185,8 +192,8 @@
            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);
@@ -204,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);
                        }
                    }
                }
            }
@@ -227,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)
@@ -267,6 +284,7 @@
                    break runRgv;
                }
            }
        }
    }