PHDFileUtil新增解析文件方法
上传文件名称格式化 去掉Extrapolation分析方法的todo
This commit is contained in:
parent
774dc70ab6
commit
3ff927c9bf
|
@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
@ -40,10 +41,8 @@ public class PHDFileUtil {
|
||||||
private FTPUtil ftpUtil;
|
private FTPUtil ftpUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private NameStandUtil nameStandUtil;
|
private NameStandUtil nameStandUtil;
|
||||||
@Autowired
|
|
||||||
private SpectrumPathProperties spectrumPathProperties;
|
|
||||||
|
|
||||||
public Map<String, Object> getSourceData(String filePath, Integer sampleId, String status){
|
public Map<String, Object> getSourceData(String filePath, Integer sampleId, String status) {
|
||||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(filePath);
|
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(filePath);
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
|
@ -259,7 +258,7 @@ public class PHDFileUtil {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> readLine(String filePath){
|
public List<String> readLine(String filePath) {
|
||||||
String parameterFilePath = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
|
String parameterFilePath = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
|
||||||
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
|
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||||
//连接ftp
|
//连接ftp
|
||||||
|
@ -310,7 +309,7 @@ public class PHDFileUtil {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getLightColor(Map<String, Object> sampleMap, Map<String, Object> gasBgMap, Map<String, Object> detBgMap, Map<String, Object> qcMap){
|
public void getLightColor(Map<String, Object> sampleMap, Map<String, Object> gasBgMap, Map<String, Object> detBgMap, Map<String, Object> qcMap) {
|
||||||
SpectrumData sampleSpectrumData = (SpectrumData)sampleMap.get("spectrumData");
|
SpectrumData sampleSpectrumData = (SpectrumData)sampleMap.get("spectrumData");
|
||||||
SpectrumData gasBgSpectrumData = (SpectrumData)gasBgMap.get("spectrumData");
|
SpectrumData gasBgSpectrumData = (SpectrumData)gasBgMap.get("spectrumData");
|
||||||
SpectrumData detBgSpectrumData = (SpectrumData)detBgMap.get("spectrumData");
|
SpectrumData detBgSpectrumData = (SpectrumData)detBgMap.get("spectrumData");
|
||||||
|
@ -449,7 +448,7 @@ public class PHDFileUtil {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getFileData(String filePath, String sampleFileName){
|
public Map<String, String> getFileData(String filePath, String sampleFileName) {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
//连接ftp 获取ftp文件数据
|
//连接ftp 获取ftp文件数据
|
||||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||||
|
@ -514,7 +513,7 @@ public class PHDFileUtil {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String NameStandardBy(String filePath, String fileName){
|
public String NameStandardBy(String filePath, String fileName) {
|
||||||
//连接ftp
|
//连接ftp
|
||||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
|
@ -585,7 +584,7 @@ public class PHDFileUtil {
|
||||||
return path.toString();
|
return path.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> FileNameByStandardForm(String filePath, String sampleFileName){
|
public List<String> FileNameByStandardForm(String filePath, String sampleFileName) {
|
||||||
//用于最后的结果
|
//用于最后的结果
|
||||||
List<String> fileNames = new LinkedList<>();
|
List<String> fileNames = new LinkedList<>();
|
||||||
String station = sampleFileName.substring(0, 9);
|
String station = sampleFileName.substring(0, 9);
|
||||||
|
@ -816,7 +815,38 @@ public class PHDFileUtil {
|
||||||
return struct;
|
return struct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GardsXeResultsSpectrum> analyzeQCResultXe(File sampleTmp, File gasTmp, File detTmp){
|
public EnergySpectrumStruct analyzeFileSourceData(File uploadFile) {
|
||||||
|
EnergySpectrumStruct struct = null;
|
||||||
|
InputStream inputStream = null;
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
inputStream = new FileInputStream(uploadFile);
|
||||||
|
if (Objects.nonNull(inputStream)){
|
||||||
|
//声明一个临时文件
|
||||||
|
file = File.createTempFile("betaGamma", null);
|
||||||
|
//将ftp文件的输入流复制给临时文件
|
||||||
|
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||||
|
struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (Objects.nonNull(inputStream)){
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(file)) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return struct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<GardsXeResultsSpectrum> analyzeQCResultXe(File sampleTmp, File gasTmp, File detTmp) {
|
||||||
//调用动态库解析文件
|
//调用动态库解析文件
|
||||||
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());
|
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());
|
||||||
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
|
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
|
||||||
|
@ -851,7 +881,7 @@ public class PHDFileUtil {
|
||||||
return xeResultsSpectrumList;
|
return xeResultsSpectrumList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> analyze(File sampleTmp, File gasTmp, File detTmp){
|
public Map<String, Object> analyze(File sampleTmp, File gasTmp, File detTmp) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
//调用动态库解析文件
|
//调用动态库解析文件
|
||||||
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());
|
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());
|
||||||
|
|
|
@ -148,7 +148,6 @@ public class SpectrumAnalysesController {
|
||||||
return spectrumAnalysisService.viewExtrapolation(sampleId, sampleFileName, request);
|
return spectrumAnalysisService.viewExtrapolation(sampleId, sampleFileName, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo--功能不明确待完成
|
|
||||||
@PostMapping("analyseExtrapolation")
|
@PostMapping("analyseExtrapolation")
|
||||||
public Result analyseExtrapolation(@RequestBody AnalyseExtInfo extInfo, HttpServletRequest request) {
|
public Result analyseExtrapolation(@RequestBody AnalyseExtInfo extInfo, HttpServletRequest request) {
|
||||||
return spectrumAnalysisService.analyseExtrapolation(extInfo, request);
|
return spectrumAnalysisService.analyseExtrapolation(extInfo, request);
|
||||||
|
|
|
@ -17,10 +17,13 @@ import org.jeecg.common.constant.enums.FileTypeEnum;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.FTPUtil;
|
import org.jeecg.common.util.FTPUtil;
|
||||||
|
import org.jeecg.common.util.NameStandUtil;
|
||||||
|
import org.jeecg.common.util.PHDFileUtil;
|
||||||
import org.jeecg.common.util.PageUtil;
|
import org.jeecg.common.util.PageUtil;
|
||||||
import org.jeecg.modules.base.comparator.FileComparator;
|
import org.jeecg.modules.base.comparator.FileComparator;
|
||||||
import org.jeecg.modules.base.dto.FileDto;
|
import org.jeecg.modules.base.dto.FileDto;
|
||||||
import org.jeecg.modules.base.bizVo.FileVo;
|
import org.jeecg.modules.base.bizVo.FileVo;
|
||||||
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
import org.jeecg.modules.service.ISpectrumFileService;
|
import org.jeecg.modules.service.ISpectrumFileService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -42,6 +45,10 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
|
||||||
private FTPUtil ftpUtil;
|
private FTPUtil ftpUtil;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpectrumPathProperties spectrumPathProperties;
|
private SpectrumPathProperties spectrumPathProperties;
|
||||||
|
@Autowired
|
||||||
|
private PHDFileUtil phdFileUtil;
|
||||||
|
@Autowired
|
||||||
|
private NameStandUtil nameStandUtil;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> upload(MultipartFile file) {
|
public Result<?> upload(MultipartFile file) {
|
||||||
|
@ -85,9 +92,12 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
|
||||||
if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
|
if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
|
||||||
// 上传所有文件
|
// 上传所有文件
|
||||||
for (File oneFile : fileList) {
|
for (File oneFile : fileList) {
|
||||||
String fullFilePath = filePath + slash + oneFile.getName();
|
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(oneFile);
|
||||||
|
String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time));
|
||||||
|
String fileName = oneFile.getName().substring(0, 23)+suffix;
|
||||||
|
String fullFilePath = filePath + slash + fileName;
|
||||||
FileInputStream local = new FileInputStream(oneFile);
|
FileInputStream local = new FileInputStream(oneFile);
|
||||||
ftpClient.storeFile(fullFilePath,local);
|
ftpClient.storeFile(fullFilePath, local);
|
||||||
}
|
}
|
||||||
return Result.OK(Prompt.UPLOAD_SUCC);
|
return Result.OK(Prompt.UPLOAD_SUCC);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user