beta人工交互分析数据库加载接口增加字段analyst
This commit is contained in:
parent
f3b5fe9bb0
commit
f94c24cc78
|
@ -156,6 +156,9 @@ public class PHDFile implements Serializable {
|
|||
private Map<String, NuclideActMda> mapNucActMda;
|
||||
|
||||
public PHDFile() {
|
||||
userId = "";
|
||||
xmlFilePath = "";
|
||||
tmpFilePath = "";
|
||||
bAnalyed = false;
|
||||
isValid = true;
|
||||
analy_start_time = "";
|
||||
|
|
|
@ -45,8 +45,8 @@ public class SpectrumAnalysesController {
|
|||
|
||||
@GetMapping("getDBSpectrumChart")
|
||||
@ApiOperation(value = "查询折线图相关信息接口", notes = "查询折线图相关信息接口")
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, request);
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
return spectrumAnalysisService.getDBSpectrumChart(dbName, sampleId, analyst, request);
|
||||
}
|
||||
|
||||
@GetMapping("getFileSpectrumChart")
|
||||
|
|
|
@ -212,6 +212,10 @@ public class BetaDataFile implements Serializable {
|
|||
private List<GardsCalibrationPairsSpectrum> betaCalibrationPairsList;
|
||||
|
||||
public BetaDataFile() {
|
||||
sampleTmpPath = "";
|
||||
gasTmpPath = "";
|
||||
detTmpPath = "";
|
||||
qcTmpPath = "";
|
||||
sampleFilePathName = "";
|
||||
sampleFileName = "";
|
||||
gasFilePathName = "";
|
||||
|
|
|
@ -20,7 +20,7 @@ public interface ISpectrumAnalysisService {
|
|||
|
||||
Result getFilesBySampleFile(String fileName, HttpServletRequest request);
|
||||
|
||||
Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request);
|
||||
Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
|
||||
|
||||
Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request);
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, HttpServletRequest request) {
|
||||
public Result getDBSpectrumChart(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
//获取当前的用户名称
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
|
@ -349,7 +349,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
roiResultsSpectrumList = spectrumAnalysisMapper.ReadROIResults("RNAUTO", analysisID, sampleId);
|
||||
} else if (dbName.equalsIgnoreCase("man")){
|
||||
dbName = "RNMAN";
|
||||
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName);
|
||||
analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, analyst);
|
||||
gammaCalibrationPairsList = spectrumAnalysisMapper.ReadGammaFitChannelEnergy(analysisID, sampleId);
|
||||
betaCalibrationPairsList = spectrumAnalysisMapper.ReadBetaFitChannelEnergy(analysisID, sampleId);
|
||||
xeResultsSpectrumList = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId);
|
||||
|
|
|
@ -37,49 +37,21 @@ public class ReadLineUtil {
|
|||
private String encoding;
|
||||
|
||||
public Map<String, Object> readLine(String filePath, String header){
|
||||
//连接ftp
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
//判断ftp是否连接成功
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException("ftp connection failed!");
|
||||
}
|
||||
InputStream iStream = null;
|
||||
File file = null;
|
||||
try {
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||
String parameterFilePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
|
||||
filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
|
||||
file = ftpUtil.downloadFile(filePath, "betaGamma");
|
||||
//判断文件路径是否为空
|
||||
if (StringUtils.isNotBlank(parameterFilePath)){
|
||||
//在当前工作路径下读取文件
|
||||
ftpClient.changeWorkingDirectory(parameterFilePath);
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding(encoding);
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
|
||||
if (CollectionUtils.isNotEmpty(ftpFiles)){
|
||||
for (FTPFile ftpFile:ftpFiles) {
|
||||
if (ftpFile.getName().equals(fileName)){
|
||||
//读取ftp文件的输入流
|
||||
iStream=ftpClient.retrieveFileStream(ftpFile.getName());
|
||||
//声明一个临时文件
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(iStream, file);
|
||||
List<String> allLines = FileUtils.readLines(file, encoding);
|
||||
if (CollectionUtils.isNotEmpty(allLines)) {
|
||||
//遍历所有的行
|
||||
for (String nowLine:allLines) {
|
||||
//判断当前行是否含有传递的头部信息
|
||||
if (nowLine.contains(header)){
|
||||
List<String> otherLines = allLines.subList(allLines.indexOf(nowLine)+1, allLines.size());
|
||||
Map<String, Object> map = this.readValue(otherLines, header);
|
||||
iStream.close();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(file)){
|
||||
List<String> allLines = FileUtils.readLines(file, encoding);
|
||||
if (CollectionUtils.isNotEmpty(allLines)) {
|
||||
//遍历所有的行
|
||||
for (String nowLine:allLines) {
|
||||
//判断当前行是否含有传递的头部信息
|
||||
if (nowLine.contains(header)){
|
||||
List<String> otherLines = allLines.subList(allLines.indexOf(nowLine)+1, allLines.size());
|
||||
Map<String, Object> map = this.readValue(otherLines, header);
|
||||
return map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,18 +59,8 @@ public class ReadLineUtil {
|
|||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (Objects.nonNull(iStream)){
|
||||
iStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
|
@ -181,51 +143,38 @@ public class ReadLineUtil {
|
|||
}
|
||||
|
||||
public Result readFtpFile(String filePath, HttpServletResponse response){
|
||||
// 连接FTP
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
// 判断FTP是否连接成功
|
||||
if (Objects.isNull(ftpClient)){
|
||||
throw new RuntimeException(Prompt.FTP_ERR);
|
||||
}
|
||||
|
||||
OutputStream outputStream = null;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
filePath = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + filePath;
|
||||
// 切换工作目录为 /
|
||||
ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);
|
||||
|
||||
// 判断FTP服务器上是否存在此文件
|
||||
String[] files = ftpClient.listNames(filePath);
|
||||
if (ArrayUtil.isEmpty(files)){
|
||||
String message = "File ["+filePath+"] does not exist!";
|
||||
log.error(message);
|
||||
return Result.error(message);
|
||||
}
|
||||
|
||||
// 存在多个文件名表示此路径为目录而非文件
|
||||
if (ArrayUtil.length(files) > 1){
|
||||
String message = "["+filePath+"] There are multiple files, possibly one directory!";
|
||||
log.error(message);
|
||||
return Result.error(message);
|
||||
}
|
||||
|
||||
// // 切换工作目录为 /
|
||||
// ftpClient.changeWorkingDirectory(SymbolConstant.SINGLE_SLASH);
|
||||
// // 判断FTP服务器上是否存在此文件
|
||||
// String[] files = ftpClient.listNames(filePath);
|
||||
// if (ArrayUtil.isEmpty(files)){
|
||||
// String message = "File ["+filePath+"] does not exist!";
|
||||
// log.error(message);
|
||||
// return Result.error(message);
|
||||
// }
|
||||
// // 存在多个文件名表示此路径为目录而非文件
|
||||
// if (ArrayUtil.length(files) > 1){
|
||||
// String message = "["+filePath+"] There are multiple files, possibly one directory!";
|
||||
// log.error(message);
|
||||
// return Result.error(message);
|
||||
// }
|
||||
// 获取文件名
|
||||
String fileName = FileUtil.getName(filePath);
|
||||
|
||||
// 在当前工作路径下读取文件
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding(encoding);
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
inputStream = ftpClient.retrieveFileStream(filePath);
|
||||
// // 在当前工作路径下读取文件
|
||||
// ftpClient.enterLocalPassiveMode();
|
||||
// ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
// ftpClient.setControlEncoding(encoding);
|
||||
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
inputStream = ftpUtil.downloadFileStream(filePath);
|
||||
outputStream = ExportUtil.stream(response,fileName);
|
||||
|
||||
// 缓冲区大小
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
|
||||
// 将文件输出流写入到输出流中
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
|
@ -236,9 +185,12 @@ public class ReadLineUtil {
|
|||
return Result.error(e.getMessage());
|
||||
}finally {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(inputStream))inputStream.close();
|
||||
if (ObjectUtil.isNotNull(outputStream))outputStream.close();
|
||||
ftpClient.disconnect();
|
||||
if (ObjectUtil.isNotNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
if (ObjectUtil.isNotNull(outputStream)) {
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user