PHDFileUtil新增解析文件方法

上传文件名称格式化
去掉Extrapolation分析方法的todo
This commit is contained in:
qiaoqinzheng 2023-10-19 11:21:41 +08:00
parent 774dc70ab6
commit 3ff927c9bf
3 changed files with 52 additions and 13 deletions

View File

@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
@ -40,10 +41,8 @@ public class PHDFileUtil {
private FTPUtil ftpUtil;
@Autowired
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);
Map<String, Object> map = new HashMap<>();
try {
@ -259,7 +258,7 @@ public class PHDFileUtil {
return map;
}
public List<String> readLine(String filePath){
public List<String> readLine(String filePath) {
String parameterFilePath = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
//连接ftp
@ -310,7 +309,7 @@ public class PHDFileUtil {
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 gasBgSpectrumData = (SpectrumData)gasBgMap.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<>();
//连接ftp 获取ftp文件数据
FTPClient ftpClient = ftpUtil.LoginFTP();
@ -514,7 +513,7 @@ public class PHDFileUtil {
return map;
}
public String NameStandardBy(String filePath, String fileName){
public String NameStandardBy(String filePath, String fileName) {
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
InputStream inputStream = null;
@ -585,7 +584,7 @@ public class PHDFileUtil {
return path.toString();
}
public List<String> FileNameByStandardForm(String filePath, String sampleFileName){
public List<String> FileNameByStandardForm(String filePath, String sampleFileName) {
//用于最后的结果
List<String> fileNames = new LinkedList<>();
String station = sampleFileName.substring(0, 9);
@ -816,7 +815,38 @@ public class PHDFileUtil {
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());
List<GardsXeResultsSpectrum> xeResultsSpectrumList = new LinkedList<>();
@ -851,7 +881,7 @@ public class PHDFileUtil {
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<>();
//调用动态库解析文件
BgAnalyseResult bgAnalyseResult = EnergySpectrumHandler.bgAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath());

View File

@ -148,7 +148,6 @@ public class SpectrumAnalysesController {
return spectrumAnalysisService.viewExtrapolation(sampleId, sampleFileName, request);
}
//todo--功能不明确待完成
@PostMapping("analyseExtrapolation")
public Result analyseExtrapolation(@RequestBody AnalyseExtInfo extInfo, HttpServletRequest request) {
return spectrumAnalysisService.analyseExtrapolation(extInfo, request);

View File

@ -17,10 +17,13 @@ import org.jeecg.common.constant.enums.FileTypeEnum;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.vo.LoginUser;
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.modules.base.comparator.FileComparator;
import org.jeecg.modules.base.dto.FileDto;
import org.jeecg.modules.base.bizVo.FileVo;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -42,6 +45,10 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
private FTPUtil ftpUtil;
@Autowired
private SpectrumPathProperties spectrumPathProperties;
@Autowired
private PHDFileUtil phdFileUtil;
@Autowired
private NameStandUtil nameStandUtil;
@Override
public Result<?> upload(MultipartFile file) {
@ -85,9 +92,12 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
if (!created) return Result.error(Prompt.DIR_CREATE_FAIL + filePath);
// 上传所有文件
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);
ftpClient.storeFile(fullFilePath,local);
ftpClient.storeFile(fullFilePath, local);
}
return Result.OK(Prompt.UPLOAD_SUCC);
} catch (IOException e) {