diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/GetBalanceUtils.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/GetBalanceUtils.java index d379d7962..e44d408c1 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/GetBalanceUtils.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/GetBalanceUtils.java @@ -1,5 +1,6 @@ package com.njcn.advance.utils; +import cn.hutool.core.date.TimeInterval; import com.njcn.advance.pojo.bo.QtIdxArray; import com.njcn.advance.pojo.bo.QvvrDataStruct; import com.njcn.advance.pojo.dto.BalanceInfo; @@ -43,18 +44,15 @@ public class GetBalanceUtils { // 如果newList为空则不带入dll计算 if (newList.size() > 0) { packageData(newList, qvvrDataStruct); - JnaCallDllOrSo jnaCallDll = new JnaCallBalance("qvvr_balance.dll"); + JnaCallDllOrSo jnaCallDll = new JnaCallBalance("qvvr_balance"); System.out.println("路径>>>>>>>"+jnaCallDll.getStrpath()); - jnaCallDll.setPath(); - - System.out.println("路径++++"+jnaCallDll.getStrpath()); // 计算暂降综合评估 try { JnaCallBalance.Balancelibrary INSTANTCE = JnaCallBalance.Balancelibrary.INSTANTCE; - - + TimeInterval timeInterval = new TimeInterval(); INSTANTCE.qvvr_fun_cause(qvvrDataStruct); + System.out.println("dll算法时长:+++++++++++"+timeInterval); } catch (Exception e) { e.printStackTrace(); return; 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 a217fb83e..2fc59f116 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 @@ -16,24 +16,23 @@ public class JnaCallDllOrSo { private String path = ""; private String pathDll = ""; private String nameDll; + public static String jarPath = ""; public JnaCallDllOrSo(String name) { super(); - this.nameDll = name; - try { - // 获取当前操作系统的类型 String os = System.getProperty("os.name"); // windows操作系统为1 否则为0 int beginIndex = os != null && os.startsWith("Windows") ? 1 : 0; if(beginIndex == 0){ //linux操作系统 + this.nameDll = name+".os"; this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); }else { + this.nameDll = name+".dll"; this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); } - System.out.println("初始化路径************"+this.path); } catch (UnsupportedEncodingException e) { log.error(e.getMessage()); @@ -43,59 +42,9 @@ public class JnaCallDllOrSo { } } - public String packagePath(String path) { - return path + "/" + this.nameDll; - } - public boolean judgeFileType() { //判断打包方式是否为jar方式 - String pathPackage = this.getClass().getPackage().toString().replaceAll("package ", "/"); - pathPackage = pathPackage.replace('.', '/'); - this.pathDll = packagePath(path + pathPackage); - this.pathDll = path + pathPackage + "/" + this.nameDll; - //如果dll在jar包内部返回true,否则返回true - return path.endsWith(".jar"); - } - - public boolean exitFile() {//判断dll文件是否存在 - File file = new File(packagePath(JnaCallDllOrSo.jarPath)); - return file.exists() || file.isFile(); - } - - public void copyDll2Path() {//复制jar包中的dll到指定位置 - InputStream is = this.getClass().getResourceAsStream(nameDll); - File file = new File(packagePath(JnaCallDllOrSo.jarPath)); - byte[] bytes = new byte[1024]; - int readBytes; - - try { - OutputStream os = new FileOutputStream(file); - while ((readBytes = is.read(bytes)) != -1) { - os.write(bytes, 0, readBytes); - } - os.close(); - } catch (FileNotFoundException e) { - log.error(e.getMessage()); - } catch (IOException e) { - log.error(e.getMessage()); - } finally { - try { - is.close(); - } catch (IOException e) { - log.error(e.getMessage()); - } - } - } public String getStrpath() { - /* if (judgeFileType()) { - if (!exitFile()) { - copyDll2Path(); - } - - return packagePath(JnaCallDllOrSo.jarPath); - } else { - return this.pathDll; - }*/ String aa = this.path+this.nameDll; String bb= aa.replace("/", File.separator); return bb;