#
luxiaotao1123
2024-12-18 93d8a38f9fd0746b9ce6ac7541bf2b8b48f7c63c
#
1个文件已修改
35 ■■■■■ 已修改文件
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/AvoidWaveCalculator.java
@@ -85,6 +85,26 @@
        });
    }
    private File pythonFile = null;
    private File loadPythonFile() {
        File scriptFile = null;
        try {
            Resource resource = new ClassPathResource("agv.py");
            InputStream is = resource.getInputStream();
            scriptFile = File.createTempFile("agv", ".py");
            scriptFile.deleteOnExit();
            Files.copy(is, scriptFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
            scriptFile.setExecutable(true);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return scriptFile;
    }
    public void calcWaveScope() {
        Integer lev = MapDataDispatcher.MAP_DEFAULT_LEV;
        boolean lockAcquired = false;
@@ -102,20 +122,13 @@
            AgvModel agvModel = agvModelService.selectByType(AgvModelType.CTU_BOX_TRANSPORT_AGV.toString());    // can be optimized
            Double avoidDistance = MapDataUtils.getVehicleWaveSafeDistance(agvModel.getDiameter(), MapDataConstant.MAX_DISTANCE_BETWEEN_ADJACENT_AGV_FACTOR);
            Resource resource = new ClassPathResource("agv.py");
            File tempScript = null;
            InputStream is = resource.getInputStream();
            tempScript = File.createTempFile("agv", ".py");
            tempScript.deleteOnExit();
            Files.copy(is, tempScript.toPath(), StandardCopyOption.REPLACE_EXISTING);
            tempScript.setExecutable(true);
            if (null == pythonFile) {
                pythonFile = loadPythonFile();
            }
            ProcessBuilder processBuilder = new ProcessBuilder(
                    "python" // 或者 "python3" 取决于系统配置
                    , tempScript.getAbsolutePath()
                    , pythonFile.getAbsolutePath()
                    , String.valueOf(avoidDistance)
                    , redisProperties.getHost()
                    , redisProperties.getPassword()