Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-08-16 08:48:09 +08:00
commit 5fd4e44a6c
13 changed files with 677 additions and 111 deletions

View File

@ -83,7 +83,7 @@ public class GardsNuclLinesIded implements Serializable {
* 该峰处的探测效率不确定度
*/
@TableField(value = "UNEFFIC")
private Double uncEffic;
private Double unEffic;
/**
* 利用该峰计算得到的最小可探测活度
*/

View File

@ -56,4 +56,5 @@ public class GardsRoiChannels implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
}

View File

@ -96,4 +96,5 @@ public class GardsRoiResults implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
}

View File

@ -82,7 +82,7 @@ public class GardsNuclLinesIded implements Serializable {
* 该峰处的探测效率不确定度
*/
@TableField(value = "UNEFFIC")
private Double uncEffic;
private Double unEffic;
/**
* 利用该峰计算得到的最小可探测活度
*/

View File

@ -265,6 +265,7 @@ public class PHDFileUtil {
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败!");
}
InputStream iStream= null;
try {
ftpClient.enterLocalPassiveMode();
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
@ -282,15 +283,12 @@ public class PHDFileUtil {
for (FTPFile ftpFile:ftpFiles) {
if (ftpFile.getName().equals(fileName)){
//读取ftp文件的输入流
InputStream iStream=ftpClient.retrieveFileStream(ftpFile.getName());
iStream=ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(iStream, file);
List<String> allLines = FileUtils.readLines(file, ftpUtil.getEncoding());
if (Objects.nonNull(iStream)){
iStream.close();
}
return allLines;
}
}
@ -300,7 +298,12 @@ public class PHDFileUtil {
throw new RuntimeException(e);
} finally {
try {
ftpClient.disconnect();
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(iStream)){
iStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -5,10 +5,7 @@ import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
import org.jeecg.modules.entity.vo.AnalyseData;
import org.jeecg.modules.entity.vo.FittingBody;
import org.jeecg.modules.entity.vo.SeriseData;
import org.jeecg.modules.entity.vo.StatisticsQueryData;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.service.ISpectrumAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
@ -66,8 +63,8 @@ public class SpectrumAnalysesController {
@GetMapping("viewRRR")
@ApiOperation(value = "查看RRR报告", notes = "查看RRR报告")
public void viewRRR(Integer sampleId, HttpServletResponse response){
spectrumAnalysisService.viewRRR(sampleId, response);
public Result viewRRR(String dbName, Integer sampleId, boolean sampleData, boolean GasBgData, boolean DetBgData, boolean QCData, boolean bGammaEnergyValid, boolean bBetaEnergyValid){
return spectrumAnalysisService.viewRRR(dbName, sampleId, sampleData, GasBgData, DetBgData, QCData, bGammaEnergyValid, bBetaEnergyValid);
}
@GetMapping("viewSpectrum")

View File

@ -0,0 +1,54 @@
package org.jeecg.modules.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class GardsROIChannelsSpectrum implements Serializable {
/**
* 样品id
*/
private Integer sampleId;
/**
* 感兴趣区ID号
*/
private Integer roi;
/**
* 分析ID号
*/
private Integer idAnalysis;
/**
* 感兴趣区的β能量起始值
*/
private Integer bChanStart;
/**
* 感兴趣区的β能量结束值
*/
private Integer bChanStop;
/**
* 感兴趣区的γ能量起始值
*/
private Integer gChanStart;
/**
* 感兴趣区的γ能量结束值
*/
private Integer gChanStop;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
}

View File

@ -0,0 +1,93 @@
package org.jeecg.modules.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
public class GardsROIResultsSpectrum implements Serializable {
/**
* 样品id
*/
private Integer sampleId;
/**
* 感兴趣区ID号
*/
private Integer roi;
/**
* 分析ID号
*/
private Integer idAnalysis;
/**
* 样品谱感兴趣区总计数
*/
private Double sGross;
/**
* 气体本底谱感兴趣区总计数
*/
private Double gGross;
/**
* 探测器本底谱感兴趣区总计数
*/
private Double bGross;
/**
* 样品谱感兴趣区净计数
*/
private Double sNet;
/**
* 气体本底谱感兴趣区净计数
*/
private Double gNet;
/**
* 感兴趣区净计数
*/
private Double net;
/**
* 感兴趣区净计数不确定度
*/
private Double netErr;
/**
* 感兴趣区活度浓度
*/
private Double conc;
/**
* 感兴趣区活度浓度不确定度
*/
private Double concErr;
/**
* 感兴趣区LC
*/
private Double lc;
/**
* 感兴趣区MDC
*/
private Double mdc;
/**
* 感兴趣区识别标示1识别到0未识别到
*/
private Integer nidFlag;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date moddate;
}

View File

@ -71,4 +71,15 @@ public interface SpectrumAnalysisMapper {
List<String> UserNuclide(@Param(value = "systemType") String systemType, @Param(value = "userName") String userName);
Integer getAnalysisID(@Param(value = "dbName") String dbName, @Param(value = "sampleId") Integer sampleId);
GardsCalibrationSpectrum ReadGammaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
GardsCalibrationSpectrum ReadBetaCalibrationParam(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
List<GardsROIChannelsSpectrum> ReadROIChannels(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
List<GardsROIResultsSpectrum> ReadROIResults(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
List<GardsXeResultsSpectrum> ReadXeResults(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId);
}

View File

@ -433,7 +433,7 @@
ACTIVITY,
UNCACTIVITY,
EFFIC,
UNEFFIC,
UNEFFIC ,
MDA,
KEY_FLAG,
MDC,
@ -491,4 +491,98 @@
SELECT nuclide_name FROM sys_default_nuclide where use_type = 3 and nuclide_type = #{systemType} and create_by = #{userName}
</select>
<select id="getAnalysisID" resultType="java.lang.Integer">
SELECT ANALYSIS_DB.IDANALYSIS FROM ${dbName}.GARDS_ANALYSES ANALYSIS_DB WHERE ANALYSIS_DB.SAMPLE_ID = #{sampleId}
</select>
<select id="ReadGammaCalibrationParam" resultType="org.jeecg.modules.entity.GardsCalibrationSpectrum">
SELECT
SAMPLE_DATA.DATA_TYPE,
CALIBRATION.COEFF1,
CALIBRATION.COEFF2,
CALIBRATION.COEFF3
FROM
${dbName}.GARDS_CALIBRATION CALIBRATION,
ORIGINAL.GARDS_SAMPLE_DATA SAMPLE_DATA
WHERE
SAMPLE_DATA.SAMPLE_ID = CALIBRATION.SAMPLE_ID
AND CALIBRATION.SAMPLE_TYPE = 'G'
AND CALIBRATION.IDANALYSIS = #{idAnalysis}
AND CALIBRATION.SAMPLE_ID = #{sampleId}
</select>
<select id="ReadBetaCalibrationParam" resultType="org.jeecg.modules.entity.GardsCalibrationSpectrum">
SELECT
SAMPLE_DATA.DATA_TYPE,
CALIBRATION.COEFF1,
CALIBRATION.COEFF2,
CALIBRATION.COEFF3
FROM
${dbName}.GARDS_CALIBRATION CALIBRATION,
ORIGINAL.GARDS_SAMPLE_DATA SAMPLE_DATA
WHERE
SAMPLE_DATA.SAMPLE_ID = CALIBRATION.SAMPLE_ID
AND CALIBRATION.SAMPLE_TYPE = 'B'
AND CALIBRATION.IDANALYSIS = #{idAnalysis}
AND CALIBRATION.SAMPLE_ID = #{sampleId}
</select>
<select id="ReadROIChannels" resultType="org.jeecg.modules.entity.GardsROIChannelsSpectrum">
SELECT
DISTINCT
SAMPLE_DATA.DATA_TYPE,
ROI_CHANNELS.ROI,
ROI_CHANNELS.B_CHAN_START,
ROI_CHANNELS.B_CHAN_STOP,
ROI_CHANNELS.G_CHAN_START,
ROI_CHANNELS.G_CHAN_STOP
FROM
${dbName}.GARDS_ROI_CHANNELS ROI_CHANNELS,
ORIGINAL.GARDS_SAMPLE_DATA SAMPLE_DATA
WHERE
ROI_CHANNELS.SAMPLE_ID = SAMPLE_DATA.SAMPLE_ID
AND ROI_CHANNELS.IDANALYSIS = #{idAnalysis}
AND ROI_CHANNELS.SAMPLE_ID = #{sampleId}
ORDER BY ROI_CHANNELS.ROI ASC
</select>
<select id="ReadROIResults" resultType="org.jeecg.modules.entity.GardsROIResultsSpectrum">
SELECT
DISTINCT
ROI_RESULTS.ROI,
ROI_RESULTS.S_GROSS,
ROI_RESULTS.G_GROSS,
ROI_RESULTS.B_GROSS,
ROI_RESULTS.S_NET,
ROI_RESULTS.G_NET,
ROI_RESULTS.NET,
ROI_RESULTS.NET_ERR,
ROI_RESULTS.CONC,
ROI_RESULTS.CONC_ERR,
ROI_RESULTS.LC,
ROI_RESULTS.MDC,
ROI_RESULTS.NID_FLAG
FROM
${dbName}.GARDS_ROI_RESULTS ROI_RESULTS
WHERE
ROI_RESULTS.IDANALYSIS = #{idAnalysis}
AND ROI_RESULTS.SAMPLE_ID = #{sampleId}
ORDER BY ROI_RESULTS.ROI ASC
</select>
<select id="ReadXeResults" resultType="org.jeecg.modules.entity.GardsXeResultsSpectrum">
SELECT
XE_RESULTS.NUCLIDE_NAME,
XE_RESULTS.CONC,
XE_RESULTS.CONC_ERR,
XE_RESULTS.MDC,
XE_RESULTS.NID_FLAG,
XE_RESULTS.LC
FROM
${dbName}.GARDS_XE_RESULTS XE_RESULTS
WHERE
XE_RESULTS.IDANALYSIS = #{idAnalysis}
AND XE_RESULTS.SAMPLE_ID = #{sampleId}
</select>
</mapper>

View File

@ -6,6 +6,7 @@ import org.jeecg.modules.entity.GardsSampleDataSpectrum;
import org.jeecg.modules.entity.vo.AnalyseData;
import org.jeecg.modules.entity.vo.SeriseData;
import org.jeecg.modules.entity.vo.StatisticsQueryData;
import org.jeecg.modules.entity.vo.TableWidget;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -26,7 +27,7 @@ public interface ISpectrumAnalysisService {
void viewARR(Integer sampleId, HttpServletResponse response);
void viewRRR(Integer sampleId, HttpServletResponse response);
Result viewRRR(String dbName, Integer sampleId, boolean sampleData, boolean GasBgData, boolean DetBgData, boolean QCData, boolean bGammaEnergyValid, boolean bBetaEnergyValid);
Result viewSpectrum(Integer sampleId);

View File

@ -15,8 +15,7 @@ import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.entity.GardsSampleDataSpectrum;
import org.jeecg.modules.entity.GardsXeResultsSpectrum;
import org.jeecg.modules.entity.*;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
@ -234,6 +233,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败");
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -250,15 +250,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
map = phdFileUtil.getSourceData(file.getAbsolutePath(), fileName, xeDataList, sampleId, status);
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -267,6 +264,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -298,6 +298,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -315,7 +316,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -332,6 +333,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -367,6 +371,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败");
}
InputStream inputStream = null;
ServletOutputStream outputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -383,20 +389,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
ServletOutputStream outputStream = response.getOutputStream();
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
// 将文件输出流写入到输出流中
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
if (ObjectUtil.isNotNull(outputStream)){
outputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -405,6 +405,12 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
if (ObjectUtil.isNotNull(outputStream)){
outputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -412,61 +418,346 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
@Override
public void viewRRR(Integer sampleId, HttpServletResponse response) {
//获取自动处理生成的报告地址
String reportPath = spectrumAnalysisMapper.viewRRR(sampleId);
if (StringUtils.isBlank(reportPath)){
throw new RuntimeException("人工交互分析生成报告不存在!");
public Result viewRRR(String dbName, Integer sampleId,
boolean sampleData, boolean GasBgData,
boolean DetBgData, boolean QCData,
boolean bGammaEnergyValid, boolean bBetaEnergyValid) {
Result result = new Result();
//GetAnalysisID sample_id
if (dbName.equalsIgnoreCase("auto")){
dbName = "RNAUTO";
}else if (dbName.equalsIgnoreCase("man")){
dbName = "RNMAN";
}
String pathName = reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH));
String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt";
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败");
}
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName;
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ftpFiles)){
throw new RuntimeException("ftp下对应的报告文件不存在");
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
ServletOutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
int bytesRead;
// 将文件输出流写入到输出流中
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
Integer analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId);
SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath("RNAUTO.GARDS_ANALYSES", sampleId);
Information information = new Information();
//sampleFile 相关数据
if (Objects.nonNull(dbSpectrumFilePath)){
if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())){
String filePath = dbSpectrumFilePath.getSampleFilePath();
String pathName = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH)+1);
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
result.error500("ftp连接失败");
return result;
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
if (ObjectUtil.isNotNull(outputStream)){
outputStream.close();
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName;
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ftpFiles)){
result.error500("ftp下对应文件不存在");
return result;
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
//加载dll工具库
System.loadLibrary("ReadPHDFile");
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
information.setSample_measid_name(struct.measurement_id);
information.setSample_det_measid_name(struct.detector_bk_measurement_id);
information.setSample_gas_measid_name(struct.gas_bk_measurement_id);
information.setSit_det_code(struct.site_code);
information.setSample_type(struct.system_type);
information.setGeometry(struct.sample_geometry);
information.setSpectral_qualifie(struct.spectrum_quantity);
String transmit_dtg_str=struct.transmit_date+" "+struct.transmit_time;
Date transmit_dtg = DateUtils.parseDate(transmit_dtg_str.substring(0, transmit_dtg_str.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
information.setTransmit_dtg(transmit_dtg);
information.setDetect_code(struct.detector_code);
information.setMeasurementID(struct.measurement_id.replace("\\","/"));
information.setBkgdMeasurementID(struct.detector_bk_measurement_id.replace("\\","/"));
information.setGasBkgdMeasurementID(struct.gas_bk_measurement_id.replace("\\","/"));
information.setSampleRefId(struct.sample_ref_id);
String collect_start_str = struct.collection_start_date+" "+struct.collection_start_time;
Date collect_start = DateUtils.parseDate(collect_start_str.substring(0, collect_start_str.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
information.setCollect_start(collect_start);
String collect_stop_str = struct.collection_stop_date+" "+struct.collection_stop_time;
Date collect_stop = DateUtils.parseDate(collect_stop_str.substring(0, collect_stop_str.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
information.setCollect_stop(collect_stop);
information.setS_xe_stable_volume(struct.air_volume);
String acquisition_start_str = struct.acquisition_start_date+" "+struct.acquisition_start_time;
Date acquisition_start = DateUtils.parseDate(acquisition_start_str.substring(0, acquisition_start_str.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss");
information.setAcquisition_start(acquisition_start);
double dataTime = acquisition_start.getTime()/1000;
dataTime = dataTime + struct.acquisition_live_time;
String acquisition_stop_str = DateUtils.formatDate(new Date((long) (dataTime * 1000)), "yyyy-MM-dd HH:mm:ss");
Date acquisition_stop = DateUtils.parseDate(acquisition_stop_str, "yyyy-MM-dd HH:mm:ss");
information.setAcquisition_stop(acquisition_stop);
information.setAcquisition_real_sec(struct.acquisition_real_time);
information.setAcquisition_live_sec(struct.acquisition_live_time);
information.setS_volume_of_Xe(struct.sample_volume_of_Xe);
}
} catch (IOException e) {
throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())){
String filePath = dbSpectrumFilePath.getGasBgFilePath();
String pathName = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH)+1);
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName;
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ftpFiles)){
result.error500("ftp下对应文件不存在");
return result;
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
//加载dll工具库
System.loadLibrary("ReadPHDFile");
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
information.setGas_measid_name(struct.measurement_id);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())){
String filePath = dbSpectrumFilePath.getDetBgFilePath();
String pathName = filePath.substring(0, filePath.lastIndexOf(StringPool.SLASH));
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH)+1);
FTPClient ftpClient = ftpUtil.LoginFTP();
if (Objects.isNull(ftpClient)){
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName;
ftpClient.changeWorkingDirectory(pathName);
List<FTPFile> ftpFiles = Arrays.asList(ftpClient.listFiles());
ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(ftpFiles)){
result.error500("ftp下对应文件不存在");
return result;
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
//加载dll工具库
System.loadLibrary("ReadPHDFile");
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
information.setDet_measid_name(struct.measurement_id);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (ObjectUtil.isNotNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
//#SAMPLE: LIMITS PER ROI GAMMA
GardsCalibrationSpectrum gammaCalibrationParam = spectrumAnalysisMapper.ReadGammaCalibrationParam(dbName, analysisID, sampleId);
//#SAMPLE: LIMITS PER ROI BETA
GardsCalibrationSpectrum betaCalibrationParam = spectrumAnalysisMapper.ReadBetaCalibrationParam(dbName, analysisID, sampleId);
//#SAMPLE: LIMITS PER ROI
List<GardsROIChannelsSpectrum> channelsSpectrums = spectrumAnalysisMapper.ReadROIChannels(dbName, analysisID, sampleId);
//#GROSS COUNTS PER ROI
List<GardsROIResultsSpectrum> resultsSpectrums = spectrumAnalysisMapper.ReadROIResults(dbName, analysisID, sampleId);
//#RESULT SUMMARY
List<GardsXeResultsSpectrum> xeResultsSpectrums = spectrumAnalysisMapper.ReadXeResults(dbName, analysisID, sampleId);
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("CNL06 GENERATED REPORT").append("\n");
strBuffer.append("REVIEWED RADIONUCLIDE REPORT").append("\n");
strBuffer.append("(Noble Gas Version)").append("\n");
strBuffer.append("Creation Date "+DateUtils.formatDate(new Date(), "yyyy/MM/dd-HH:mm:ss")).append("\n");
strBuffer.append("\n");
strBuffer.append("#FILE INFORMATION").append("\n");
strBuffer.append(" SampleMeasID: ").append(information.getMeasurementID()).append("\n");
strBuffer.append(" GASBKMeasID: ").append(information.getGasBkgdMeasurementID()).append("\n");
strBuffer.append(" SRID: ").append(information.getSampleRefId()).append("\n");
strBuffer.append(" Detector Type: ").append("3D b-g").append("\n");
strBuffer.append("\n");
strBuffer.append("#COLLECTION INFORMATION").append("\n");
strBuffer.append(" Station CODE: ").append(information.getSit_det_code()).append("\n");
strBuffer.append(" Detector CODE: ").append(information.getDetect_code()).append("\n");
strBuffer.append(" Collection Start: ").append(information.getCollect_start()).append("\n");
strBuffer.append(" Collection Stop: ").append(information.getCollect_stop()).append("\n");
strBuffer.append(" Collection TIME(h): ").append((information.getCollect_stop().getTime()/1000-information.getCollect_start().getTime()/1000)/3600).append("\n");
strBuffer.append(" Air Volume[cm3]: ").append(information.getS_xe_stable_volume()).append("\n");
strBuffer.append(" Xe Volume[cm3]: ").append(information.getS_volume_of_Xe()).append("\n");
strBuffer.append("\n");
strBuffer.append("#ACQUISITION INFORMATION").append("\n");
strBuffer.append(" Acquisition Start: ").append(information.getAcquisition_start()).append("\n");
strBuffer.append(" Acq Real Time(s): ").append(information.getAcquisition_real_sec()).append("\n");
strBuffer.append(" Acq Live Time: ").append(information.getAcquisition_live_sec()).append("\n");
strBuffer.append("\n");
strBuffer.append("#SOFTWARE").append("\n");
strBuffer.append(" version: ").append("1.0.1").append("\n");
strBuffer.append("\n");
strBuffer.append("#SAMPLE Old CALIBRATION").append("\n");
strBuffer.append(" Old Beta Old Gamma ").append("\n");
if (sampleData){
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}else {
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}
strBuffer.append("\n");
strBuffer.append("#SAMPLE New CALIBRATION").append("\n");
strBuffer.append(" New Beta New Gamma ").append("\n");
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = ("+betaCalibrationParam.getCoeff1()+")+("+betaCalibrationParam.getCoeff2()+")*x+("+betaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n");
strBuffer.append("\n");
strBuffer.append("#SAMPLE: LIMITS PER ROI").append("\n");
strBuffer.append(" Roi Beta Gamma ").append("\n");
for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) {
strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n");
}
strBuffer.append("\n");
strBuffer.append("#DET Old CALIBRATION").append("\n");
strBuffer.append(" Old Beta Old Gamma ").append("\n");
if (DetBgData){
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}else {
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}
strBuffer.append("\n");
strBuffer.append("#DET New CALIBRATION").append("\n");
strBuffer.append(" New Beta New Gamma ").append("\n");
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n");
strBuffer.append("\n");
strBuffer.append("#DET: LIMITS PER ROI").append("\n");
strBuffer.append(" Roi Beta Gamma ").append("\n");
for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) {
strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n");
}
strBuffer.append("\n");
strBuffer.append("#GAS Old CALIBRATION").append("\n");
strBuffer.append(" Old Beta Old Gamma ").append("\n");
if (GasBgData){
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}else {
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = (?1)+(?2)*x+(?3)x*x ").append(" E(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
}
strBuffer.append("\n");
strBuffer.append("#GAS New CALIBRATION").append("\n");
strBuffer.append(" New Beta New Gamma ").append("\n");
strBuffer.append(" CH(x) = (?1)+(?2)*x+(?3)x*x ").append(" CH(x) = (?1)+(?2)*x+(?3)x*x").append("\n");
strBuffer.append(" E(x) = ("+betaCalibrationParam.getCoeff1()+")+("+betaCalibrationParam.getCoeff2()+")*x+("+betaCalibrationParam.getCoeff3()+")x*x ").append(" E(x) = ("+gammaCalibrationParam.getCoeff1()+")+("+gammaCalibrationParam.getCoeff2()+")*x+("+gammaCalibrationParam.getCoeff3()+")x*x").append("\n");
strBuffer.append("\n");
strBuffer.append("#GAS: LIMITS PER ROI").append("\n");
strBuffer.append(" Roi Beta Gamma ").append("\n");
for (GardsROIChannelsSpectrum channelsSpectrum:channelsSpectrums) {
strBuffer.append(" "+channelsSpectrum.getRoi()+" "+channelsSpectrum.getBChanStart()+"to"+channelsSpectrum.getBChanStop()+" "+channelsSpectrum.getGChanStart()+"to"+channelsSpectrum.getGChanStop()).append("\n");
}
strBuffer.append("\n");
strBuffer.append("#GROSS COUNTS PER ROI").append("\n");
strBuffer.append(" Roi Sample GasBkgnd DetBkgnd ").append("\n");
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums) {
strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getSGross()+" "+resultsSpectrum.getGGross()+" "+resultsSpectrum.getBGross()+"").append("\n");
}
strBuffer.append("\n");
strBuffer.append("#NET COUNTS AND LC PER ROI").append("\n");
strBuffer.append(" Roi Net count ").append("\n");
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getNet()+" +/- "+Math.sqrt(resultsSpectrum.getNetErr())).append("\n");
}
strBuffer.append("\n");
strBuffer.append("#CONCENTRATION AND LC PER ROI").append("\n");
strBuffer.append(" Roi Conc(mBq/m3) LC(mBq/m3) MDC(mBq/m3): ");
for (GardsROIResultsSpectrum resultsSpectrum:resultsSpectrums){
strBuffer.append(" "+resultsSpectrum.getRoi()+" "+resultsSpectrum.getConcErr()+" +/- "+resultsSpectrum.getConcErr()+" "+resultsSpectrum.getLc()+" "+resultsSpectrum.getMdc()).append("\n");
}
strBuffer.append("\n");
strBuffer.append("#RESULT SUMMARY").append("\n");
strBuffer.append(" Nuclide Name Conc LC MDC NID Flag ").append("\n");
for (GardsXeResultsSpectrum xeResultsSpectrum:xeResultsSpectrums) {
strBuffer.append(" "+xeResultsSpectrum.getNuclideName()+" "+xeResultsSpectrum.getConc()+" +/- "+xeResultsSpectrum.getConcErr()+" "+xeResultsSpectrum.getLc()+" "+xeResultsSpectrum.getMdc()+" "+xeResultsSpectrum.getNidFlag()).append("\n");
}
strBuffer.append("\n");
result.setSuccess(true);
result.setResult(strBuffer);
return result;
}
@Override
@ -515,6 +806,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -532,7 +824,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile ftpFile = ftpFiles.get(0);
if (Objects.nonNull(ftpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
inputStream = ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -596,6 +888,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -635,7 +930,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -656,7 +951,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile sampleFtpFile = sampleFtpFiles.get(0);
if (Objects.nonNull(sampleFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -688,9 +983,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}else {
qcResult.setXenonVolumeStatus("Failed");
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -701,6 +993,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -712,6 +1007,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -732,7 +1028,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile gasBgFtpFile = gasBgFtpFiles.get(0);
if (Objects.nonNull(gasBgFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(gasBgFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(gasBgFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -744,9 +1040,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}else {
qcResult.setGasBgValueAndStatus(false);
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -755,6 +1048,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -766,6 +1062,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -786,7 +1083,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile detBgFtpFile = detBgFtpFiles.get(0);
if (Objects.nonNull(detBgFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(detBgFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(detBgFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -798,9 +1095,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}else {
qcResult.setDetBgValueAndStatus(false);
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -809,6 +1103,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -840,6 +1137,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
//查询数据库中结果的Xe数据
List<GardsXeResultsSpectrum> xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId);
try {
@ -862,7 +1160,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile sampleFtpFile = sampleFtpFiles.get(0);
if (Objects.nonNull(sampleFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -910,9 +1208,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
rlrDataValues.setXe135_MDC(String.valueOf(xe135.getMdc()));
rlrDataValues.setXe135_LC(String.valueOf(xe135.getLc()));
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
}
} catch (IOException e) {
@ -922,6 +1217,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -943,6 +1241,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
if (StringUtils.isNotBlank(dbQcFilePath)){
String qcPathName = dbQcFilePath.substring(0, dbQcFilePath.lastIndexOf(StringPool.SLASH));
@ -957,7 +1256,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile qcFtpFile = qcFtpFiles.get(0);
if (Objects.nonNull(qcFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -1042,9 +1341,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
map.put("min", min);
map.put("max", max);
map.put("gammaSpectrum", seriseDataList);
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
}
} catch (IOException e) {
@ -1054,6 +1350,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -1075,6 +1374,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -1095,7 +1395,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile qcFtpFile = qcFtpFiles.get(0);
if (Objects.nonNull(qcFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -1183,9 +1483,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
fittingParaToUiStr.add(String.valueOf(para));
}
map.put("EToC", fittingParaToUiStr);
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
}
} catch (IOException e) {
@ -1195,6 +1492,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -1216,6 +1516,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
if (StringUtils.isNotBlank(sampleFilePath)){
String samplePathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
String sampleFileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
@ -1237,7 +1538,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
FTPFile sampleFtpFile = sampleFtpFiles.get(0);
if (Objects.nonNull(sampleFtpFile)){
//获取ftp文件的输入流
InputStream inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(sampleFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//ftp文件输入流复制给临时文件
@ -1309,9 +1610,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
betaProjectedSeriseData.add(temp);
}
map.put("betaProjectedSeriseData", betaProjectedSeriseData);
if (Objects.nonNull(inputStream)){
inputStream.close();
}
}
} catch (IOException e) {
throw new RuntimeException(e);
@ -1320,6 +1618,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -1814,6 +2115,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
result.error500("ftp连接失败");
return result;
}
InputStream inputStream = null;
try {
//切换被动模式
ftpClient.enterLocalPassiveMode();
@ -1834,7 +2136,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
}
FTPFile qcFtpFile = qcFtpFiles.get(0);
if (Objects.nonNull(qcFtpFile)){
InputStream inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
inputStream = ftpClient.retrieveFileStream(qcFtpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -1867,6 +2169,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -45,6 +45,7 @@ public class ReadLineUtil {
if (Objects.isNull(ftpClient)){
throw new RuntimeException("ftp连接失败!");
}
InputStream iStream = null;
try {
ftpClient.enterLocalPassiveMode();
String fileName = filePath.substring(filePath.lastIndexOf(StringPool.SLASH) + 1);
@ -62,7 +63,7 @@ public class ReadLineUtil {
for (FTPFile ftpFile:ftpFiles) {
if (ftpFile.getName().equals(fileName)){
//读取ftp文件的输入流
InputStream iStream=ftpClient.retrieveFileStream(ftpFile.getName());
iStream=ftpClient.retrieveFileStream(ftpFile.getName());
//声明一个临时文件
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
@ -88,7 +89,12 @@ public class ReadLineUtil {
throw new RuntimeException(e);
} finally {
try {
ftpClient.disconnect();
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(iStream)){
iStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}