文件转换SPC转成IMS接口生成的文件名称修改

文件上传时错误的文件名称获取不到文件问题修改
loadFromFile接口加载文件时,文件不存在情况下提示内容错误问题修改
This commit is contained in:
qiaoqinzheng 2023-12-13 17:43:45 +08:00
parent 645ada9f9f
commit ddeeef4094
3 changed files with 7 additions and 3 deletions

View File

@ -65,11 +65,11 @@ public class GammaFileUtil extends AbstractLogOrReport {
phd.setFilename(fileName);
String fromPath = pathName + StringPool.SLASH + fileName;
File file = ftpUtil.downloadFile(fromPath, "betaGamma");
phd.setTmpFilePath(file.getAbsolutePath());
if (Objects.isNull(file)) {
result.error500("ftp file can't find");
return false;
}
phd.setTmpFilePath(file.getAbsolutePath());
try {
//读取文件信息
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());

View File

@ -5281,7 +5281,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
@Override
public void SpcToIms(FileData datas, MultipartFile file, HttpServletResponse response) {
String SpcName = file.getOriginalFilename();
String ImsName = SpcName.substring(0, SpcName.length() - 4) + ".PHD";
File spcFile = null;
InputStream inputStream = null;
// 导出数据内容到txt文本
@ -5293,6 +5292,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (!fileFtransitUtil.ReadSPC(spcFile, datas)) return;
String imsValue = fileFtransitUtil.WriteIMS(datas);
String suffix = nameStandUtil.GetSuffix(datas.getData_type(), datas.getQuantity(), String.valueOf(datas.getAcq_live()));
String ImsName = datas.getDetector()+StringPool.DASH+datas.getAcq_date().replace(StringPool.SLASH, StringPool.EMPTY)+StringPool.UNDERSCORE+
datas.getAcq_time().substring(0, 5).replace(StringPool.COLON, StringPool.EMPTY)+ suffix;
// 设置响应类型
response.setContentType("application/octet-stream");
// 解决中文不能生成文件

View File

@ -106,7 +106,9 @@ public class SpectrumFileServiceImpl implements ISpectrumFileService {
if (!regexPattern.matcher(fileName).find() && !regexPattern1.matcher(fileName).find()) {
EnergySpectrumStruct struct = phdFileUtil.analyzeFileSourceData(oneFile);
String suffix = nameStandUtil.GetSuffix(struct.data_type, struct.spectrum_quantity, String.valueOf(struct.acquisition_live_time));
fileName = oneFile.getName().substring(0, 23)+suffix;
String filePreffix = struct.detector_code + StringPool.DASH + struct.acquisition_start_date.replace(StringPool.SLASH, StringPool.EMPTY)+StringPool.UNDERSCORE
+ struct.acquisition_start_time.substring(0, 5).replace(StringPool.COLON, StringPool.EMPTY);
fileName = filePreffix+suffix;
}
String fullFilePath = rootPath + filePath + slash + fileName;
FileInputStream local = new FileInputStream(oneFile);