From 4823c5e11353a5bde4d8837c3e5ff33f7e1ba12b Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Thu, 11 Apr 2024 11:40:31 +0800
Subject: [PATCH] 图斑配置

---
 src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java b/src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java
index c64ff26..a503b0c 100644
--- a/src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java
+++ b/src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java
@@ -3,6 +3,7 @@
 import com.dji.sample.patches.xml.mode.XMLTemplateModel;
 import freemarker.template.Configuration;
 import freemarker.template.Template;
+import org.springframework.beans.factory.annotation.Value;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.*;
@@ -21,9 +22,14 @@
      * 生成航线文件
      * @param xmlModel
      */
-    public static void createWaylineFile(XMLTemplateModel xmlModel) {
-        xml2XmlDoc(xmlModel, "src\\main\\resources\\template\\template.xml", "src\\main\\resources\\template\\wpmz\\template.kml");
-        xml2XmlDoc(xmlModel, "src\\main\\resources\\template\\waylines.xml", "src\\main\\resources\\template\\wpmz\\waylines.wpml");
+    public static void createWaylineFile(XMLTemplateModel xmlModel,String templeFilePath,String targetTempleFilePath,String waylineFilePath,String targetWaylineFilePath) {
+
+
+//        xml2XmlDoc(xmlModel, "home\\drone\\server\\template\\template.xml", "home\\drone\\server\\template\\wpmz\\template.kml");
+//        xml2XmlDoc(xmlModel, "home\\drone\\server\\template\\waylines.xml", "home\\drone\\server\\template\\wpmz\\waylines.wpml");
+
+        xml2XmlDoc(xmlModel, templeFilePath, targetTempleFilePath);
+        xml2XmlDoc(xmlModel, waylineFilePath, targetWaylineFilePath);
     }
 
     /**
@@ -37,12 +43,12 @@
         Writer out = null;
         try {
             // 将模板文件路径拆分为文件夹路径和文件名称
-            String tempLetDir = templetFilePath.substring(0, templetFilePath.lastIndexOf("\\"));
+            String tempLetDir = templetFilePath.substring(0, templetFilePath.lastIndexOf("/"));
             // 注意:templetFilePath.lastIndexOf("/")中,有的文件分隔符为:\ 要注意文件路径的分隔符
-            String templetName = templetFilePath.substring(templetFilePath.lastIndexOf("\\") + 1);
+            String templetName = templetFilePath.substring(templetFilePath.lastIndexOf("/") + 1);
             // 将目标文件保存路径拆分为文件夹路径和文件名称
-            String targetDir = targetFilePath.substring(0, targetFilePath.lastIndexOf("\\"));
-            String targetName = targetFilePath.substring(targetFilePath.lastIndexOf("\\") + 1);
+            String targetDir = targetFilePath.substring(0, targetFilePath.lastIndexOf("/"));
+            String targetName = targetFilePath.substring(targetFilePath.lastIndexOf("/") + 1);
             Configuration configuration = new Configuration();
             configuration.setDefaultEncoding(String.valueOf(StandardCharsets.UTF_8));
             // 如果目标文件目录不存在创建

--
Gitblit v1.9.3