#
Junjie
11 小时以前 7a546480f6ddfaee1366f280981a002a08412c11
#
1个文件已添加
13个文件已修改
532 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OpenController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/utils/NavigateUtils.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/config/FakeTaskNoAreaInitializer.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/WrkIoType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/StationObjModel.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/ZyStationConnectDriver.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java 381 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/network/real/ZyStationRealConnect.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/plugin/FakeProcess.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationThread.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/map/上海临港哥斯拉项目.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OpenController.java
@@ -69,8 +69,8 @@
        if (param == null) {
            return R.error("参数不能为空");
        }
        boolean result = commonService.createInTask(param);
        if (result) {
        WrkMast wrkMast = commonService.createInTask(param);
        if (wrkMast != null) {
            return R.ok();
        }
        return R.error("生成入库任务失败");
src/main/java/com/zy/common/service/CommonService.java
@@ -184,7 +184,7 @@
    }
    //入库任务
    public boolean createInTask(CreateInTaskParam param) {
    public WrkMast createInTask(CreateInTaskParam param) {
        Date now = new Date();
        LocMast locMast = locMastService.queryByLoc(param.getLocNo());
        if (null == locMast) {
@@ -234,7 +234,7 @@
        //缓存记录当前命令堆垛机编号
        redisUtil.set(RedisKeyType.CURRENT_CIRCLE_TASK_CRN_NO.key, crnNo, 60 * 60 * 24);
        return true;
        return wrkMast;
    }
    //出库任务
src/main/java/com/zy/common/utils/NavigateUtils.java
@@ -50,13 +50,10 @@
        }
        News.info("[WCS Debug] ç«™ç‚¹è·¯å¾„计算完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        if (allList.size() > 1) {
            System.out.println(JSON.toJSONString(allList));
        }
        startTime = System.currentTimeMillis();
        News.info("[WCS Debug] ç«™ç‚¹è·¯å¾„权重开始分析,startStationId={},endStationId={}", startStationId, endStationId);
        List<NavigateNode> list = findStationBestPath(allList);
        News.info("[WCS Debug] ç«™ç‚¹è·¯å¾„权重分析结束,startStationId={},endStationId={}", startStationId, endStationId);
        News.info("[WCS Debug] ç«™ç‚¹è·¯å¾„权重分析完成,耗时:{}ms", System.currentTimeMillis() - startTime);
        //去重
        HashSet<Integer> set = new HashSet<>();
src/main/java/com/zy/core/config/FakeTaskNoAreaInitializer.java
New file
@@ -0,0 +1,38 @@
package com.zy.core.config;
import com.alibaba.fastjson.JSON;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.WrkLastno;
import com.zy.asrs.service.WrkLastnoService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.WrkIoType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.HashMap;
@Component
public class FakeTaskNoAreaInitializer {
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private WrkLastnoService wrkLastnoService;
    @PostConstruct
    public void init() {
        WrkLastno wrkLastno = wrkLastnoService.selectById(WrkIoType.FAKE_TASK_NO.id);
        if (Cools.isEmpty(wrkLastno)) {
            throw new CoolException("数据异常,请联系管理员");
        }
        HashMap<String, Object> map = new HashMap<>();
        map.put("start", wrkLastno.getSNo());
        map.put("end", wrkLastno.getENo());
        redisUtil.set(RedisKeyType.FAKE_TASK_NO_AREA.key, JSON.toJSONString(map));
    }
}
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -16,6 +16,7 @@
    LOG_LIMIT("log_limit_"),
    SYSTEM_CONFIG_MAP("system_config_map"),
    FAKE_TASK_NO_AREA("fake_task_no_area"),
    LOC_MAP_BASE("loc_map_base"),
    LOC_MAST_MAP_LIST("loc_mast_map_list"),
@@ -30,6 +31,8 @@
    CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT("check_out_station_stay_time_out_limit_"),
    CHECK_IN_STATION_STAY_TIME_OUT_LIMIT("check_in_station_stay_time_out_limit_"),
    CRN_IO_EXECUTE_FINISH_LIMIT("crn_io_execute_finish_limit_"),
    STATION_IN_EXECUTE_LIMIT("station_in_execute_limit_"),
    STATION_OUT_EXECUTE_LIMIT("station_out_execute_limit_"),
    CURRENT_CIRCLE_TASK_CRN_NO("current_circle_task_crn_no_"),
    AI_CHAT_HISTORY("ai_chat_history_"),
src/main/java/com/zy/core/enums/WrkIoType.java
@@ -9,6 +9,7 @@
    LOC_MOVE(201, "移库任务"),
    PREVIEW_LIFT_MOVE(98, "提升机预调度移动任务"),
    MANUAL(99, "手动任务"),
    FAKE_TASK_NO(9999, "仿真随机工作号"),
    ;
    WrkIoType(int id, String desc) {
src/main/java/com/zy/core/model/StationObjModel.java
@@ -15,4 +15,6 @@
    private Integer deviceLev;
    private StationObjModel barcodeStation;
}
src/main/java/com/zy/core/network/ZyStationConnectDriver.java
@@ -1,6 +1,7 @@
package com.zy.core.network;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.common.utils.RedisUtil;
import com.zy.core.ThreadHandler;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.command.StationCommand;
@@ -23,12 +24,14 @@
    private boolean connected = false;
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private ZyStationConnectApi zyStationConnectApi;
    private volatile boolean closed = false;
    private ScheduledExecutorService executor;
    public ZyStationConnectDriver(DeviceConfig deviceConfig) {
    public ZyStationConnectDriver(DeviceConfig deviceConfig, RedisUtil redisUtil) {
        this.deviceConfig = deviceConfig;
        this.redisUtil = redisUtil;
    }
    @Override
@@ -39,9 +42,9 @@
    @Override
    public boolean connect() {
        if (deviceConfig.getFake() == 0) {
            zyStationConnectApi = new ZyStationRealConnect(deviceConfig);
            zyStationConnectApi = new ZyStationRealConnect(deviceConfig, redisUtil);
        } else {
            zyStationConnectApi = new ZyStationFakeConnect(deviceConfig);
            zyStationConnectApi = new ZyStationFakeConnect(deviceConfig, redisUtil);
        }
        boolean connect = zyStationConnectApi.connect();
src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -6,31 +6,37 @@
import com.zy.asrs.entity.DeviceConfig;
import com.zy.common.model.NavigateNode;
import com.zy.common.utils.NavigateUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.command.StationCommand;
import com.zy.core.network.api.ZyStationConnectApi;
import com.zy.core.network.entity.ZyStationStatusEntity;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Supplier;
/**
 * è¾“送站假连接(模拟)
 */
public class ZyStationFakeConnect implements ZyStationConnectApi {
    private List<ZyStationStatusEntity> statusList = new ArrayList<>();
    private final List<ZyStationStatusEntity> statusList = new CopyOnWriteArrayList<>();
    private static int LOCK_STATION = 0;
    private final DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    // å…è®¸å¹¶è¡Œæ‰§è¡Œå¤šä¸ªå‘½ä»¤ä»»åŠ¡ï¼ˆå›ºå®šçº¿ç¨‹æ± ï¼‰ã€‚å¦‚éœ€æ›´é«˜å¹¶å‘å¯è°ƒæ•´å¤§å°ã€‚
    private final ExecutorService executor = Executors
            .newFixedThreadPool(9999);
    public ZyStationFakeConnect(DeviceConfig deviceConfig) {
    public ZyStationFakeConnect(DeviceConfig deviceConfig, RedisUtil redisUtil) {
        this.deviceConfig = deviceConfig;
        this.redisUtil = redisUtil;
    }
    @Override
@@ -47,18 +53,20 @@
    @Override
    public List<ZyStationStatusEntity> getStatus() {
        if (this.statusList.isEmpty()) {
            this.statusList = JSON.parseArray(deviceConfig.getFakeInitStatus(), ZyStationStatusEntity.class);
            for (ZyStationStatusEntity status : this.statusList) {
                status.setAutoing(true);// æ¨¡æ‹Ÿè‡ªåŠ¨è¿è¡Œ
                status.setLoading(false);// æ¨¡æ‹Ÿæœ‰ç‰©
                status.setInEnable(true);// æ¨¡æ‹Ÿå¯å…¥
                status.setOutEnable(true);// æ¨¡æ‹Ÿå¯å‡º
                status.setEmptyMk(false);// æ¨¡æ‹Ÿç©ºæ¿ä¿¡å·
                status.setFullPlt(false);// æ¨¡æ‹Ÿæ»¡æ‰˜ç›˜
                status.setPalletHeight(0);// æ¨¡æ‹Ÿæ‰˜ç›˜é«˜åº¦ä¸º0
                status.setError(0);// æ¨¡æ‹Ÿæ— æŠ¥è­¦
                status.setBarcode("");// æ¨¡æ‹Ÿæ— æ¡ç 
            List<ZyStationStatusEntity> init = JSON.parseArray(deviceConfig.getFakeInitStatus(), ZyStationStatusEntity.class);
            if (init != null) {
                statusList.addAll(init);
                for (ZyStationStatusEntity status : this.statusList) {
                    status.setAutoing(true);// æ¨¡æ‹Ÿè‡ªåŠ¨è¿è¡Œ
                    status.setLoading(false);// æ¨¡æ‹Ÿæœ‰ç‰©
                    status.setInEnable(true);// æ¨¡æ‹Ÿå¯å…¥
                    status.setOutEnable(true);// æ¨¡æ‹Ÿå¯å‡º
                    status.setEmptyMk(false);// æ¨¡æ‹Ÿç©ºæ¿ä¿¡å·
                    status.setFullPlt(false);// æ¨¡æ‹Ÿæ»¡æ‰˜ç›˜
                    status.setPalletHeight(0);// æ¨¡æ‹Ÿæ‰˜ç›˜é«˜åº¦ä¸º0
                    status.setError(0);// æ¨¡æ‹Ÿæ— æŠ¥è­¦
                    status.setBarcode("");// æ¨¡æ‹Ÿæ— æ¡ç 
                }
            }
        }
@@ -82,6 +90,7 @@
        Integer taskNo = command.getTaskNo();
        Integer stationId = command.getStationId();
        Integer targetStationId = command.getTargetStaNo();
        boolean generateBarcode = false;
        if(taskNo == 0 && targetStationId == 0){
            //清空站点
@@ -89,10 +98,10 @@
            return;
        }
        if (taskNo == 9999 && targetStationId == 0) {
        //任务号属于仿真入库任务号
        if (checkTaskNoInArea(taskNo)) {
            //生成仿真数据
            generateFakeData(stationId, taskNo);
            return;
            generateBarcode = true;
        }
        if (taskNo == 9998 && targetStationId == 0) {
@@ -101,29 +110,19 @@
            return;
        }
        if (taskNo > 0 && taskNo != 9999 && taskNo != 9998 && stationId == targetStationId) {
            //下发任务数据-不允许只是下发数据
            generateStationData(taskNo, stationId, targetStationId);
        }
        String startLev = String.valueOf(stationId).substring(0, 1);
        String endLev = String.valueOf(targetStationId).substring(0, 1);
        if (startLev.equals(endLev)) {
            currentLevCommand(command);
            currentLevCommand(command, generateBarcode);
        }else {
            diffLevCommand(command);
            diffLevCommand(command, generateBarcode);
        }
    }
    private void generateFakeData(Integer stationId, Integer taskNo) {
        ZyStationStatusEntity status = statusList.stream()
                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
        if (status == null) {
            return;
        }
        String barcodeTime = String.valueOf(System.currentTimeMillis());
        String barcode = barcodeTime.substring(5);
        status.setTaskNo(taskNo);
        status.setLoading(true);
        status.setBarcode(barcode);
    }
    private void generateFakeOutStationData(Integer stationId) {
@@ -133,7 +132,22 @@
            return;
        }
        status.setLoading(true);
        synchronized (status) {
            status.setLoading(true);
        }
    }
    private void generateStationData(Integer taskNo, Integer stationId, Integer targetStationId) {
        ZyStationStatusEntity status = statusList.stream()
                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
        if (status == null) {
            return;
        }
        synchronized (status) {
            status.setTaskNo(taskNo);
            status.setTargetStaNo(targetStationId);
        }
    }
    private void resetStation(Integer stationId) {
@@ -143,12 +157,14 @@
            return;
        }
        status.setTaskNo(0);
        status.setLoading(false);
        status.setBarcode("");
        synchronized (status) {
            status.setTaskNo(0);
            status.setLoading(false);
            status.setBarcode("");
        }
    }
    private void currentLevCommand(StationCommand command) {
    private void currentLevCommand(StationCommand command, boolean generateBarcode) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
            return;
@@ -172,10 +188,10 @@
            return;
        }
        stationMove(navigateNodes, taskNo, targetStationId, false);
        stationMove(navigateNodes, taskNo, targetStationId, false, generateBarcode);
    }
    private void diffLevCommand(StationCommand command) {
    private void diffLevCommand(StationCommand command, boolean generateBarcode) {
        NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class);
        if (navigateUtils == null) {
            return;
@@ -247,75 +263,75 @@
            return;
        }
        stationMove(navigateNodes, taskNo, stationId, true);
        stationMove(targetNavigateNodes, taskNo, targetStationId, false);
        stationMove(navigateNodes, taskNo, stationId, true, generateBarcode);
        stationMove(targetNavigateNodes, taskNo, targetStationId, false, generateBarcode);
    }
    private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData) {
    private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData, boolean generateBarcode) {
        Integer lastStationId = null;
        for (int i = 0; i < navigateNodes.size(); i++) {
        int i = 0;
        while (i < navigateNodes.size()) {
            NavigateNode navigateNode = navigateNodes.get(i);
            JSONObject valueObject = JSON.parseObject(navigateNode.getNodeValue());
            Integer currentStationId = valueObject.getInteger("stationId");
            ZyStationStatusEntity status = statusList.stream()
                    .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
            if (status == null) {
                continue;
            Integer nextStationId = null;
            try {
                NavigateNode nextNode = navigateNodes.get(i + 1);
                JSONObject nextValueObject = JSON.parseObject(nextNode.getNodeValue());
                nextStationId = nextValueObject.getInteger("stationId");
            } catch (Exception e) {
            }
            try {
                while (!Thread.currentThread().isInterrupted()) {
                    ZyStationStatusEntity nextStatus = statusList.stream()
                            .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
                    if (nextStatus == null) {
            if (nextStationId != null) {
            }
            if (i == 0) {
                boolean result = initStationMove(taskNo, currentStationId, taskNo, targetStationId, true, null);
                if (!result) {
                    continue;
                }
                sleep(1000);
            }
            if(nextStationId != null) {
                boolean result = stationMoveToNext(taskNo, currentStationId, nextStationId, taskNo, targetStationId);
                if (!result) {
                    continue;
                }
                lastStationId = currentStationId;
            }
            i++;
            sleep(1000);
        }
        if (generateBarcode) {
            if (lastStationId != null) {
                while (true) {
                    boolean result = generateStationBarcode(taskNo, targetStationId);
                    sleep(1000);
                    if (!result) {
                        continue;
                    }
                    if (nextStatus.getTaskNo() == 0 || nextStatus.getTaskNo() == 9999) {
                        break;
                    }
                    sleep(100);
                }
            } catch (Exception e) {
                continue;
            }
            if (lastStationId != null) {
                Integer finalLastStationId = lastStationId;
                ZyStationStatusEntity lastStatus = statusList.stream()
                        .filter(item -> item.getStationId().equals(finalLastStationId)).findFirst().orElse(null);
                if (lastStatus != null) {
                    synchronized (lastStatus) {
                        lastStatus.setTaskNo(0);
                        lastStatus.setTargetStaNo(0);
                        lastStatus.setLoading(false);
                    }
                    break;
                }
            }
            synchronized (status) {
                status.setTaskNo(taskNo);
                status.setTargetStaNo(targetStationId);
                status.setLoading(true);
            }
            lastStationId = currentStationId;
            sleep(1000);
        }
        if (clearData) {
            sleep(10000);
            if (lastStationId != null) {
                Integer finalLastStationId = lastStationId;
                ZyStationStatusEntity lastStatus = statusList.stream()
                        .filter(item -> item.getStationId().equals(finalLastStationId)).findFirst().orElse(null);
                if (lastStatus != null) {
                    synchronized (lastStatus) {
                        lastStatus.setTaskNo(0);
                        lastStatus.setTargetStaNo(0);
                        lastStatus.setLoading(false);
                while (true) {
                    boolean result = clearStation(taskNo, targetStationId);
                    sleep(1000);
                    if (!result) {
                        continue;
                    }
                    break;
                }
            }
        }
@@ -328,4 +344,181 @@
            e.printStackTrace();
        }
    }
}
    public synchronized boolean setLockStation(Integer uuid) {
        if (LOCK_STATION == 0) {
            LOCK_STATION = uuid;
            return true;
        }else {
            if(LOCK_STATION == uuid) {
                return true;
            }
        }
        return false;
    }
    public synchronized boolean releaseLockStation(Integer uuid) {
        if (LOCK_STATION != uuid) {
            return false;
        }
        LOCK_STATION = 0;
        return true;
    }
    public synchronized boolean updateStationData(Integer lockTaskNo, Integer stationId, Integer taskNo, Integer targetStaNo, Boolean isLoading, String barcode) {
        if (LOCK_STATION != lockTaskNo) {
            return false;
        }
        ZyStationStatusEntity currentStatus = statusList.stream()
                .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null);
        if (currentStatus == null) {
            return false;
        }
        if (taskNo != null) {
            currentStatus.setTaskNo(taskNo);
        }
        if (targetStaNo != null) {
            currentStatus.setTargetStaNo(targetStaNo);
        }
        if (isLoading != null) {
            currentStatus.setLoading(isLoading);
        }
        if (barcode != null) {
            currentStatus.setBarcode(barcode);
        }
        return true;
    }
    public synchronized boolean initStationMove(Integer lockTaskNo, Integer currentStationId, Integer taskNo, Integer targetStationId, Boolean isLoading, String barcode) {
        boolean executeResult = lockExecute(lockTaskNo, () -> {
            ZyStationStatusEntity currentStatus = statusList.stream()
                .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
            if (currentStatus == null) {
                return false;
            }
            if(currentStatus.getTaskNo().equals(taskNo)) {
                return true;
            }
            if (currentStatus.getTaskNo() > 0 || currentStatus.isLoading()) {
                return false;
            }
            boolean result = updateStationData(taskNo, currentStationId, taskNo, targetStationId, isLoading, barcode);
            if (!result) {
                return false;
            }
            return true;
        });
        return executeResult;
    }
    public synchronized boolean stationMoveToNext(Integer lockTaskNo, Integer currentStationId, Integer nextStationId, Integer taskNo, Integer targetStaNo) {
        boolean executeResult = lockExecute(lockTaskNo, () -> {
            ZyStationStatusEntity currentStatus = statusList.stream()
                    .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
            ZyStationStatusEntity nextStatus = statusList.stream()
                    .filter(item -> item.getStationId().equals(nextStationId)).findFirst().orElse(null);
            if (currentStatus == null || nextStatus == null) {
                return false;
            }
            if (nextStatus.getTaskNo() > 0 || nextStatus.isLoading()) {
                return false;
            }
            boolean result = updateStationData(lockTaskNo, nextStationId, taskNo, targetStaNo, true, null);
            if (!result) {
                return false;
            }
            boolean result2 = updateStationData(lockTaskNo, currentStationId, 0, 0, false, null);
            if (!result2) {
                return false;
            }
            return true;
        });
        return executeResult;
    }
    public synchronized boolean generateStationBarcode(Integer lockTaskNo, Integer currentStationId) {
        boolean executeResult = lockExecute(lockTaskNo, () -> {
            ZyStationStatusEntity currentStatus = statusList.stream()
                    .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
            if (currentStatus == null) {
                return false;
            }
            String barcodeTime = String.valueOf(System.currentTimeMillis());
            String barcode = barcodeTime.substring(5);
            boolean result = updateStationData(lockTaskNo, currentStationId, null, null, null, barcode);
            if (!result) {
                return false;
            }
            return true;
        });
        return executeResult;
    }
    public synchronized boolean clearStation(Integer lockTaskNo, Integer currentStationId) {
        boolean executeResult = lockExecute(lockTaskNo, () -> {
            ZyStationStatusEntity currentStatus = statusList.stream()
                    .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
            if (currentStatus == null) {
                return false;
            }
            boolean result = updateStationData(lockTaskNo, currentStationId, 0, 0, false, "");
            if (!result) {
                return false;
            }
            return true;
        });
        return executeResult;
    }
    public synchronized boolean lockExecute(Integer taskNo, Supplier<Boolean> function) {
        if (!setLockStation(taskNo)) {
            return false;
        }
        boolean result = function.get();
        releaseLockStation(taskNo);
        return result;
    }
    private synchronized boolean checkTaskNoInArea(Integer taskNo) {
        Object fakeTaskNoAreaObj = redisUtil.get(RedisKeyType.FAKE_TASK_NO_AREA.key);
        if (fakeTaskNoAreaObj == null) {
            return false;
        }
        JSONObject data = JSON.parseObject(String.valueOf(fakeTaskNoAreaObj));
        Integer start = data.getInteger("start");
        Integer end = data.getInteger("end");
        if(taskNo >= start && taskNo <= end) {
            return true;
        }
        return false;
    }
}
src/main/java/com/zy/core/network/real/ZyStationRealConnect.java
@@ -4,6 +4,7 @@
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
import com.zy.common.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSON;
@@ -36,9 +37,11 @@
    private List<ZyStationStatusEntity> barcodeStatusList;
    private SiemensS7Net siemensNet;
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    public ZyStationRealConnect(DeviceConfig deviceConfig) {
    public ZyStationRealConnect(DeviceConfig deviceConfig, RedisUtil redisUtil) {
        this.deviceConfig = deviceConfig;
        this.redisUtil = redisUtil;
    }
    @Override
src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.zy.asrs.domain.param.CreateInTaskParam;
import com.zy.asrs.domain.param.CreateOutTaskParam;
import com.zy.asrs.entity.*;
@@ -145,8 +146,8 @@
                    continue;
                }
                Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
                if (object != null) {
                Object lock = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
                if(lock != null){
                    continue;
                }
@@ -155,9 +156,9 @@
                        && !stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0
                ) {
                    StationCommand command = stationThread.getMoveCommand(9999, stationId, 0, 0);
                    StationCommand command = stationThread.getMoveCommand(commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId, entity.getBarcodeStation().getStationId(), 0);
                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 10);
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 5);
                }
            }
        }
@@ -186,7 +187,7 @@
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            List<StationObjModel> list = basDevp.getInStationList$();
            List<StationObjModel> list = basDevp.getBarcodeStationList$();
            for (StationObjModel model : list) {
                Integer stationId = model.getStationId();
                if(!stationMap.containsKey(stationId)){
@@ -203,11 +204,15 @@
                    return;
                }
                //满足自动、有物、工作号9999,生成入库数据
                //满足自动、有物、有工作号,生成入库数据
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 9999
                        && stationProtocol.getTaskNo() > 0
                ) {
                    if (Cools.isEmpty(stationProtocol.getBarcode())) {
                        continue;
                    }
                    //检测任务是否生成
                    List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                    if (!wrkMasts.isEmpty()) {
@@ -238,8 +243,14 @@
                    taskParam.setStaNo(targetStationId);
                    taskParam.setLocNo(locMast.getLocNo());
                    taskParam.setBarcode(stationProtocol.getBarcode());
                    boolean result = commonService.createInTask(taskParam);
                    WrkMast wrkMast = commonService.createInTask(taskParam);
                    StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
                    if(command == null){
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                    }
                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId, "lock", 5);
                }
            }
@@ -308,7 +319,7 @@
                    taskParam.setStaNo(stationId);
                    taskParam.setLocNo(locMast.getLocNo());
                    boolean result = commonService.createOutTask(taskParam);
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 15);
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 10);
                }
            }
        }
@@ -332,7 +343,7 @@
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            List<StationObjModel> list = basDevp.getInStationList$();
            List<StationObjModel> list = basDevp.getBarcodeStationList$();
            for (StationObjModel entity : list) {
                Integer stationId = entity.getStationId();
                if(!stationMap.containsKey(stationId)){
@@ -344,11 +355,15 @@
                    continue;
                }
                //满足自动、有物、工作号9999,生成入库数据
                //满足自动、有物、有工作号,生成入库数据
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 9999
                        && stationProtocol.getTaskNo() > 0
                ) {
                    if (Cools.isEmpty(stationProtocol.getBarcode())) {
                        continue;
                    }
                    //检测任务是否生成
                    List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                    if (!wrkMasts.isEmpty()) {
@@ -382,7 +397,7 @@
                        continue;
                    }
                    redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 15);
                    redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 5);
                    HashMap<String, Object> requestParam = new HashMap<>();
                    String response = null;
@@ -407,8 +422,14 @@
                            taskParam.setLocNo(dto.getLocNo());
                            taskParam.setTaskPri(dto.getTaskPri());
                            taskParam.setBarcode(stationProtocol.getBarcode());
                            boolean result = commonService.createInTask(taskParam);
                            WrkMast wrkMast = commonService.createInTask(taskParam);
                            StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, stationId, 0);
                            if(command == null){
                                News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                continue;
                            }
                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            News.info("请求WMS接口成功!!!url:{};request:{};response:{}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
                        } else {
                            News.error("请求WMS接口失败!!!url:{};request:{};response:{}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
src/main/java/com/zy/core/thread/impl/ZyStationThread.java
@@ -181,7 +181,7 @@
    @Override
    public boolean connect() {
        zyStationConnectDriver = new ZyStationConnectDriver(deviceConfig);
        zyStationConnectDriver = new ZyStationConnectDriver(deviceConfig, redisUtil);
        zyStationConnectDriver.start();
        DeviceConnectPool.put(SlaveType.Devp, deviceConfig.getDeviceNo(), zyStationConnectDriver);
        return true;
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -11,9 +11,11 @@
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
import com.zy.common.service.CommonService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.RedisKeyType;
import com.zy.core.enums.SlaveType;
import com.zy.core.enums.WrkStsType;
import com.zy.core.model.StationObjModel;
@@ -39,6 +41,8 @@
    private CommonService commonService;
    @Autowired
    private BasCrnpService basCrnpService;
    @Autowired
    private RedisUtil redisUtil;
    //执行输送站点入库任务
    public synchronized void stationInExecute() {
@@ -51,7 +55,7 @@
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            List<StationObjModel> list = basDevp.getInStationList$();
            List<StationObjModel> list = basDevp.getBarcodeStationList$();
            for (StationObjModel entity : list) {
                Integer stationId = entity.getStationId();
                if(!stationMap.containsKey(stationId)){
@@ -63,10 +67,15 @@
                    continue;
                }
                //满足自动、有物、工作号9999
                Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
                if(lock != null){
                    continue;
                }
                //满足自动、有物、有工作号
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 9999
                        && stationProtocol.getTaskNo() > 0
                ) {
                    //检测任务是否生成
                    WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
@@ -75,6 +84,11 @@
                    }
                    if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
                        continue;
                    }
                    if (!wrkMast.getWrkNo().equals(stationProtocol.getTaskNo())) {
                        News.taskInfo(stationProtocol.getStationId(), "输送站点工作号:{}与条码搜索到的任务工作号:{}不一致", stationProtocol.getTaskNo(), wrkMast.getWrkNo());
                        continue;
                    }
@@ -105,6 +119,7 @@
                    if (wrkMastService.updateById(wrkMast)) {
                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                        News.info("输送站点入库命令下发成功,站点号={},工作号={},命令数据={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
                    }
                }
            }
@@ -138,6 +153,11 @@
                    continue;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
                if (lock != null) {
                    continue;
                }
                //满足自动、有物、工作号0
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
@@ -155,6 +175,7 @@
                    if (wrkMastService.updateById(wrkMast)) {
                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                        News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                    }
                }
            }
src/main/resources/map/ÉϺ£ÁÙ¸Û¸ç˹À­ÏîÄ¿.xlsx
Binary files differ