From 550a1a7dfdcb742dd5eb0c6292175ed47f181ad3 Mon Sep 17 00:00:00 2001 From: cuikaidong <ckd2942379034@163.com> Date: 星期三, 20 八月 2025 09:27:23 +0800 Subject: [PATCH] 麒麟系统适配ftp,标准参数修改 --- lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/iot/service/impl/ServerDeployServiceImpl.java | 67 +++++++++++++++++++++------------ 1 files changed, 42 insertions(+), 25 deletions(-) diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/iot/service/impl/ServerDeployServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/iot/service/impl/ServerDeployServiceImpl.java index c30890e..2f0cc35 100644 --- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/iot/service/impl/ServerDeployServiceImpl.java +++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/iot/service/impl/ServerDeployServiceImpl.java @@ -1,16 +1,15 @@ package org.jeecg.modules.iot.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.iot.entity.*; -import org.jeecg.modules.iot.service.*; -import org.jeecg.modules.iot.util.FtpUtil; import org.jeecg.modules.iot.mapper.ServerDeployMapper; import org.jeecg.modules.iot.mqtt.config.MqttCustomerClient; +import org.jeecg.modules.iot.service.*; import org.jeecg.modules.iot.util.FileUtil; +import org.jeecg.modules.iot.util.FtpUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Lazy; @@ -26,7 +25,9 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -39,9 +40,12 @@ */ @Service public class ServerDeployServiceImpl extends ServiceImpl<ServerDeployMapper, ServerDeploy> implements IServerDeployService { - + @Autowired + private FtpUtil ftpUtil; @Value("${ftp.address}") private String ftpAddress; + @Value("${operatingSystem}") + private String operatingSystem; @Autowired private IInfluxdbDeployService influxdbDeployService; @Autowired @@ -104,7 +108,7 @@ @Transactional(rollbackFor = Exception.class) public Result<?> addDeployDocument(String id) { // 楠岃瘉FTP杩炴帴 - boolean isConnected = FtpUtil.testFtpConnection(); + boolean isConnected = ftpUtil.testFtpConnection(); if (!isConnected) { return Result.error("FTP杩炴帴澶辫触锛岃妫�鏌ラ厤缃紒"); } @@ -248,9 +252,9 @@ tagInfo.setAttribute("Name", r.getParameterName()); tagInfo.setAttribute("Address", r.getAddress()); tagInfo.setAttribute("DataType", r.getParameterType()); - if (r.getReadWriteType().equals("鍙")){ + if (r.getReadWriteType().equals("鍙")) { tagInfo.setAttribute("ReadOrWrite", "R"); - }else{ + } else { tagInfo.setAttribute("ReadOrWrite", "R/W"); } tagInfo.setAttribute("Describe", r.getParameterDescribe()); @@ -322,9 +326,9 @@ // 鍒涘缓xml鏂囦欢骞跺啓鍏ュ唴瀹� tf.transform(new DOMSource(document), new StreamResult(new File("/iot/" + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/CollectionConfiguration.lmx"))); // 鍒涘缓鍐欏簱琛ㄧ粨鏋勬煡璇㈣櫄璁惧鍒楄〃锛屽鍔犺澶囪〃 - equipmentService.createEmptyEquipmentTable(serverDeploy.getDeployIssueTime(),serverDeploy.getId()); + equipmentService.createEmptyEquipmentTable(serverDeploy.getDeployIssueTime(), serverDeploy.getId()); // 鏌ヨ铏氳澶囧弬鏁帮紝澧炲姞瀛楁 - emptyParameterService.createEmptyEmptyField(serverDeploy.getDeployIssueTime(),serverDeploy.getId()); + emptyParameterService.createEmptyEmptyField(serverDeploy.getDeployIssueTime(), serverDeploy.getId()); } catch (Exception e) { e.printStackTrace(); return Result.error("閰嶇疆鏂囦欢鐢熸垚澶辫触"); @@ -334,28 +338,41 @@ serverDeploy.setDeployIssueTime(new Date()); baseMapper.updateById(serverDeploy); // 鐢熸垚鏈湴鏂囦欢澶� -// FileUtil.createDir("D:/iot/" + serverDeploy.getServerCode() + "/deploy/" + formattedDate); - FileUtil.createDir(ftpAddress + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/script"); + // 鐢熸垚鏈湴鏂囦欢澶� + FileUtil.createDir(ftpAddress + serverDeploy.getServerCode() + "/deploy/" + formattedDate); + MqttParameter mqttParameter = new MqttParameter(); // 涓婁紶鍒癴tp - String basePath = "/deploy"; // FTP鏈嶅姟鍣ㄥ熀纭�鐩綍 - String filePath = serverDeploy.getServerCode() + "/deploy/" + formattedDate; // FTP鏈嶅姟鍣ㄦ枃浠跺瓨鏀捐矾寰勩�備緥濡傚垎鏃ユ湡瀛樻斁锛�/2015/01/01銆傛枃浠剁殑璺緞涓篵asePath+filePath - String filename = "CollectionConfiguration.lmx";// 涓婁紶鍒癋TP鏈嶅姟鍣ㄤ笂鐨勬枃浠跺悕 - //鍒涘缓涓�涓緭鍏ユ祦 - try { - FileInputStream fileInputStream = new FileInputStream(ftpAddress + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/CollectionConfiguration.lmx"); - FtpUtil.uploadFile(basePath, filePath, filename, fileInputStream); - } catch (FileNotFoundException e) { - e.printStackTrace(); + if (operatingSystem.equals("windows")) { + String basePath = "/deploy"; // FTP鏈嶅姟鍣ㄥ熀纭�鐩綍 + String filePath = "/" + serverDeploy.getServerCode() + "/deploy/" + formattedDate; // FTP鏈嶅姟鍣ㄦ枃浠跺瓨鏀捐矾寰勩�備緥濡傚垎鏃ユ湡瀛樻斁锛�/2015/01/01銆傛枃浠剁殑璺緞涓篵asePath+filePath + String filename = "CollectionConfiguration.lmx";// 涓婁紶鍒癋TP鏈嶅姟鍣ㄤ笂鐨勬枃浠跺悕 + //鍒涘缓涓�涓緭鍏ユ祦 + try { + FileInputStream fileInputStream = new FileInputStream(ftpAddress + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/CollectionConfiguration.lmx"); + ftpUtil.uploadFile(basePath, filePath, filename, fileInputStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + mqttParameter.setParameter4(basePath + "/" + filePath); + } else { + String basePath = "/iot"; // FTP鏈嶅姟鍣ㄥ熀纭�鐩綍 + String filePath = "/deploy/" + serverDeploy.getServerCode() + "/deploy/" + formattedDate; // FTP鏈嶅姟鍣ㄦ枃浠跺瓨鏀捐矾寰勩�備緥濡傚垎鏃ユ湡瀛樻斁锛�/2015/01/01銆傛枃浠剁殑璺緞涓篵asePath+filePath + String filename = "CollectionConfiguration.lmx";// 涓婁紶鍒癋TP鏈嶅姟鍣ㄤ笂鐨勬枃浠跺悕 + //鍒涘缓涓�涓緭鍏ユ祦 + try { + FileInputStream fileInputStream = new FileInputStream(ftpAddress + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/CollectionConfiguration.lmx"); + ftpUtil.uploadFileKylin(basePath, filePath, filename, fileInputStream); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + mqttParameter.setParameter4(filePath); } // 瀛樺偍鑴氭湰锛屽鍒舵暣涓枃浠跺す - FtpUtil.uploadFolder(new File(ftpAddress+serverDeploy.getServerCode()+"/script/"), "/deploy/"+serverDeploy.getServerCode()+"/deploy/"+formattedDate+"/script"); - // 鐢熸垚鑴氭湰 + ftpUtil.uploadFolderKylin(new File(ftpAddress + serverDeploy.getServerCode() + "/script/"), "/deploy/" + serverDeploy.getServerCode() + "/deploy/" + formattedDate + "/script"); // 鍙戦�侀厤缃枃浠剁増淇″彿 - MqttParameter mqttParameter = new MqttParameter(); mqttParameter.setId(serverDeploy.getServerCode()); mqttParameter.setType("version"); mqttParameter.setParameter2(formattedDate); - mqttParameter.setParameter4(basePath +"/" +filePath); mqttCustomerClient.pushlish(2, false, serverDeploy.getServerCode(), mqttParameter); return Result.ok("閰嶇疆鏂囦欢鐢熸垚鎴愬姛"); } -- Gitblit v1.9.3