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,8 +41,6 @@ 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);
|
||||||
|
@ -816,6 +815,37 @@ public class PHDFileUtil {
|
||||||
return struct;
|
return struct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
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());
|
||||||
|
|
|
@ -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,7 +92,10 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user