gamma新增测试dll方法
This commit is contained in:
parent
751c5d8cf2
commit
6d64193002
|
@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPFile;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
|
@ -366,12 +365,10 @@ public class GammaFileUtil {
|
|||
String baselineFileName = "RNAUTO_"+subFileName + ".baseline";
|
||||
inputStream = ftpClient.retrieveFileStream(baselineFileName);
|
||||
if (Objects.nonNull(inputStream)){
|
||||
//声明一个临时文件
|
||||
File file = File.createTempFile("tmp", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
List<String> readLines = FileUtils.readLines(file, "UTF-8");
|
||||
ReadBaseCtrlInfo(phd,readLines);
|
||||
long start = System.currentTimeMillis();
|
||||
ReadBaseCtrlInfo(phd, inputStream);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println(end-start);
|
||||
phd.setVBase(phd.getBaseCtrls().getBaseline());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -426,61 +423,7 @@ public class GammaFileUtil {
|
|||
return vData;
|
||||
}
|
||||
|
||||
public void ReadBaseCtrlInfo(PHDFile phd, List<String> readLines) {
|
||||
for (int i=0; i< readLines.size(); i++){
|
||||
String line = readLines.get(i);
|
||||
if (line.contains("#")){
|
||||
String block_name = line.trim();
|
||||
int j=i+1;
|
||||
line = readLines.get(j);
|
||||
String block_data = line;
|
||||
while(j!= readLines.size()-1 && StringUtils.isNotBlank(line)) {
|
||||
j++;
|
||||
line = readLines.get(j);
|
||||
if (!line.contains("#")){
|
||||
block_data += StringPool.SPACE + line;
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i=j-1;
|
||||
block_data = block_data.trim();
|
||||
List<String> str_list = Arrays.asList(block_data.split("\\s+"));
|
||||
if(str_list.size() < 1){
|
||||
continue;
|
||||
}
|
||||
List<Double> vTemp = new LinkedList<>();
|
||||
for(String str:str_list) {
|
||||
if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){
|
||||
double d = Double.valueOf(str);
|
||||
vTemp.add(d);
|
||||
} else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) {
|
||||
vTemp.add(0.0);
|
||||
}
|
||||
}
|
||||
if(block_name.contains("#AnalyseRange")) {
|
||||
if(vTemp.size() == 2) {
|
||||
phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue());
|
||||
phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue());
|
||||
}
|
||||
} else if(block_name.contains("#XCtrl")) {
|
||||
phd.getBaseCtrls().setXCtrl(vTemp);
|
||||
} else if(block_name.contains("#YCtrl")) {
|
||||
phd.getBaseCtrls().setYCtrl(vTemp);
|
||||
} else if(block_name.contains("#YSlope")) {
|
||||
phd.getBaseCtrls().setYSlope(vTemp);
|
||||
} else if(block_name.contains("#Baseline")) {
|
||||
List<Double> list = vTemp.subList(1, vTemp.size());
|
||||
phd.getBaseCtrls().setBaseline(list);
|
||||
} else if(block_name.contains("#StepCounts")) {
|
||||
List<Double> list = vTemp.subList(1, vTemp.size());
|
||||
phd.getBaseCtrls().setStepCounts(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadBaseCtrlInfo(PHDFile phd, InputStream in){
|
||||
public void ReadBaseCtrlInfo(PHDFile phd, InputStream in) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
|
||||
String line ;
|
||||
|
@ -509,20 +452,25 @@ public class GammaFileUtil {
|
|||
phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue());
|
||||
phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue());
|
||||
}
|
||||
} else if(map.containsKey("#XCtrl")) {
|
||||
}
|
||||
if(map.containsKey("#XCtrl")) {
|
||||
List<Double> vTemp = map.get("#XCtrl");
|
||||
phd.getBaseCtrls().setXCtrl(vTemp);
|
||||
} else if(map.containsKey("#YCtrl")) {
|
||||
}
|
||||
if(map.containsKey("#YCtrl")) {
|
||||
List<Double> vTemp = map.get("#YCtrl");
|
||||
phd.getBaseCtrls().setYCtrl(vTemp);
|
||||
} else if(map.containsKey("#YSlope")) {
|
||||
}
|
||||
if(map.containsKey("#YSlope")) {
|
||||
List<Double> vTemp = map.get("#YSlope");
|
||||
phd.getBaseCtrls().setYSlope(vTemp);
|
||||
} else if(map.containsKey("#Baseline")) {
|
||||
}
|
||||
if(map.containsKey("#Baseline")) {
|
||||
List<Double> vTemp = map.get("#Baseline");
|
||||
List<Double> list = vTemp.subList(1, vTemp.size());
|
||||
phd.getBaseCtrls().setBaseline(list);
|
||||
} else if(map.containsKey("#StepCounts")) {
|
||||
}
|
||||
if(map.containsKey("#StepCounts")) {
|
||||
List<Double> vTemp = map.get("#StepCounts");
|
||||
List<Double> list = vTemp.subList(1, vTemp.size());
|
||||
phd.getBaseCtrls().setStepCounts(list);
|
||||
|
@ -2761,6 +2709,14 @@ public class GammaFileUtil {
|
|||
return strBuffer.toString();
|
||||
}
|
||||
|
||||
public List<Double> DoubleLimit_L(List<Long> data) {
|
||||
List<Double> rData = new LinkedList<>();
|
||||
for(int pos=0;pos<data.size();pos++) {
|
||||
rData.add(Double.valueOf(String.valueOf(data.get(pos))));
|
||||
}
|
||||
return rData;
|
||||
}
|
||||
|
||||
public List<String> DoubleLimit(List data) {
|
||||
List<String> rData = new LinkedList<>();
|
||||
for(int pos=0;pos<data.size();pos++) {
|
||||
|
|
|
@ -28,6 +28,11 @@ public class GammaController {
|
|||
return gammaService.initValue(sampleId, dbName, request);
|
||||
}
|
||||
|
||||
@GetMapping("testFun")
|
||||
public Result testFun(String fileName){
|
||||
return gammaService.testFun(fileName);
|
||||
}
|
||||
|
||||
@GetMapping("gammaByDB")
|
||||
public Result gammaByDB(Integer sampleId, String dbName, HttpServletRequest request){
|
||||
return gammaService.gammaByDB(dbName, sampleId, request);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.native_jni;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.jeecg.modules.entity.vo.PeakInfo;
|
||||
import org.jeecg.modules.entity.vo.StructInsertInput;
|
||||
import org.jeecg.modules.entity.vo.StructInsertOutput;
|
||||
|
@ -38,9 +39,9 @@ public class CalValuesHandler {
|
|||
|
||||
public static native String calUpdate(String dataType, List<Double> certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta);
|
||||
|
||||
public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta);
|
||||
public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta, List<PeakInfo> Peaks);
|
||||
|
||||
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta);
|
||||
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow);
|
||||
|
||||
public static native String fitPeakFull();
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ public interface IGammaService{
|
|||
|
||||
Result initValue(Integer sampleId, String dbName, HttpServletRequest request);
|
||||
|
||||
Result testFun(String fileName);
|
||||
|
||||
Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request);
|
||||
|
||||
Result gammaByFile(String fileName, HttpServletRequest request);
|
||||
|
|
|
@ -143,6 +143,35 @@ public class GammaServiceImpl implements IGammaService {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result testFun(String fileName) {
|
||||
Result result = new Result();
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
System.loadLibrary("GammaAnaly");
|
||||
// List<Double> baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size());
|
||||
// map.put("baseInfo_s_Energy", baseInfo_s_Energy);
|
||||
// List<Double> baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size());
|
||||
// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll);
|
||||
// List<Double> baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK());
|
||||
// map.put("baseInfo_s_Lc", baseInfo_s_Lc);
|
||||
// List<Double> values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts());
|
||||
// List<Double> baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll);
|
||||
// map.put("baseInfo_s_Scac", baseInfo_s_Scac);
|
||||
// boolean armaAny = CalValuesHandler.armaAny(values);
|
||||
// map.put("armaAny", armaAny);
|
||||
String dataType = phd.getMsgInfo().getData_type().substring(0, 1);
|
||||
List<Double> gEnergy = phd.getCertificate().getG_energy();
|
||||
String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta());
|
||||
map.put("calUpdateStr", calUpdateStr);
|
||||
// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(),
|
||||
// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
|
@ -1851,7 +1880,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
String fileName = file.getOriginalFilename();
|
||||
//从最后一个。切割文件名称 获取文件名称后缀
|
||||
String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT));
|
||||
if (fileSuffix.equalsIgnoreCase(".eft")) {
|
||||
if (fileSuffix.equalsIgnoreCase(".eft") || fileSuffix.equalsIgnoreCase(".ent")) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<Double> m_vCurEffi = new LinkedList<>();
|
||||
List<Double> m_vCurEnergy = new LinkedList<>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user