diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java index a9d252e49..708190984 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java @@ -31,17 +31,20 @@ public class JnaCallDllOrSo { //linux操作系统 this.nameDll = "lib" + name + "_dll"; suffix = ".so"; -// this.path = "/usr/local/jarfiles/advanceboot/BOOT-INF/classes/"; - //this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); } else { this.nameDll = name; -// this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); } - File tempFile; + File dockerFile = new File("/usr/local/dllFile/".concat(this.nameDll.concat(suffix))); + if(dockerFile.exists()){ + this.path = dockerFile.getAbsolutePath(); + }else { + dockerFile.mkdirs(); + dockerFile.createNewFile(); + } + try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(this.nameDll.concat(suffix))) { - tempFile = File.createTempFile(this.nameDll, suffix); - try (FileOutputStream outputStream = new FileOutputStream(tempFile)) { + try (FileOutputStream outputStream = new FileOutputStream(dockerFile)) { byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { @@ -49,9 +52,7 @@ public class JnaCallDllOrSo { } } } - this.path = tempFile.getAbsolutePath(); - System.out.println(1); - System.out.println(1); + this.path = dockerFile.getAbsolutePath(); } catch (Exception e) { log.error(e.getMessage()); } @@ -62,8 +63,6 @@ public class JnaCallDllOrSo { public String getStrpath() { return this.path; -// String aa = this.path + this.nameDll; -// return aa.replace("/", File.separator); } public void setPath() { diff --git a/pqs-influx/src/test/java/com/njcn/influx/DemoTest.java b/pqs-influx/src/test/java/com/njcn/influx/DemoTest.java index 881cbd8d5..ca7ae53d8 100644 --- a/pqs-influx/src/test/java/com/njcn/influx/DemoTest.java +++ b/pqs-influx/src/test/java/com/njcn/influx/DemoTest.java @@ -1,47 +1,47 @@ -package com.njcn.influx; - -import com.njcn.influx.imapper.CldStatisticsFlowMapper; -import com.njcn.influx.pojo.dto.StatisticalDataDTO; -import com.njcn.influx.pojo.po.DataV; -import com.njcn.influx.service.CommonService; -import com.njcn.influx.service.DataFlickerService; -import com.njcn.influx.service.IDataVService; -import lombok.SneakyThrows; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.List; - -/** - * @author hongawen - * @version 1.0.0 - * @date 2021年12月14日 12:55 - */ -public class DemoTest extends BaseJunitTest { - - @Autowired - private CldStatisticsFlowMapper cldStatisticsFlowMapper; - - @Autowired - private DataFlickerService dataFlickerService; - - @Autowired - private IDataVService dataVService; - - @Autowired - private CommonService commonService; - - @SneakyThrows - @Test - public void test() { -// dataFlickerService.getDataFlicker("ff2d9674c1f1ecce7f33a5bf17fc4f2d","2023-05-02 00:00:00","2023-05-02 23:59:59"); -// List ss = dataVService.getDataV("ff2d9674c1f1ecce7f33a5bf17fc4f2d", "2023-05-02 00:00:00", "2023-05-02 23:59:59"); -// System.out.println(ss); - - StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData("4","data_harmpower_p","W","A","max"); - System.out.println("statisticalDataDTO==:" + statisticalDataDTO); - - - } - -} +//package com.njcn.influx; +// +//import com.njcn.influx.imapper.CldStatisticsFlowMapper; +//import com.njcn.influx.pojo.dto.StatisticalDataDTO; +//import com.njcn.influx.pojo.po.DataV; +//import com.njcn.influx.service.CommonService; +//import com.njcn.influx.service.DataFlickerService; +//import com.njcn.influx.service.IDataVService; +//import lombok.SneakyThrows; +//import org.junit.Test; +//import org.springframework.beans.factory.annotation.Autowired; +// +//import java.util.List; +// +///** +// * @author hongawen +// * @version 1.0.0 +// * @date 2021年12月14日 12:55 +// */ +//public class DemoTest extends BaseJunitTest { +// +// @Autowired +// private CldStatisticsFlowMapper cldStatisticsFlowMapper; +// +// @Autowired +// private DataFlickerService dataFlickerService; +// +// @Autowired +// private IDataVService dataVService; +// +// @Autowired +// private CommonService commonService; +// +// @SneakyThrows +// @Test +// public void test() { +//// dataFlickerService.getDataFlicker("ff2d9674c1f1ecce7f33a5bf17fc4f2d","2023-05-02 00:00:00","2023-05-02 23:59:59"); +//// List ss = dataVService.getDataV("ff2d9674c1f1ecce7f33a5bf17fc4f2d", "2023-05-02 00:00:00", "2023-05-02 23:59:59"); +//// System.out.println(ss); +// +// StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData("4","data_harmpower_p","W","A","max"); +// System.out.println("statisticalDataDTO==:" + statisticalDataDTO); +// +// +// } +// +//}