xieb
2024-04-11 06344d06ee31d3cad0616b66d10d750f0f15e238
src/main/java/com/dji/sample/patches/xml/utils/CreateWaylineFileUtils.java
@@ -18,20 +18,11 @@
@Slf4j
public class CreateWaylineFileUtils {
    @Value("${xml.temple.template}")
    static String templeFilePath;
    @Value("${xml.temple.waylines}")
    static String waylineFilePath;
    @Value("${xml.target.template}")
    static String targetTempleFilePath;
    @Value("${xml.target.waylines}")
    static String targetWaylineFilePath;
    /**
     * 生成航线文件
     * @param xmlModel
     */
    public static void createWaylineFile(XMLTemplateModel xmlModel) {
    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");
@@ -52,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));
            // 如果目标文件目录不存在创建