beta功能查询条件数据接口参数内容修改,返回当前用户当天关注台站及探测器信息,勾选allUser返回全部台站,探测器信息

gamma功能加载主页面数据接口增加字段analyst获取对应分析员的分析结果
web模块增加downloadFile方法用于下载sample及sample相关分析谱文件
mapper类缺少注解问题修改
This commit is contained in:
qiaoqinzheng 2023-11-14 14:58:57 +08:00
parent 4f29d3235c
commit bbfd2c477b
22 changed files with 295 additions and 59 deletions

View File

@ -437,6 +437,8 @@ public class FTPUtil {
public File downloadFile(String fromPath, String toPath) {
FTPClient ftpClient = null;
InputStream inputStream = null;
// 声明一个临时文件
File tempFile = null;
try {
ftpClient = LoginFTP();
// 切换被动模式
@ -446,10 +448,11 @@ public class FTPUtil {
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
inputStream = ftpClient.retrieveFileStream(fromPath);
// 声明一个临时文件
File tempFile = File.createTempFile(toPath, null);
if (Objects.nonNull(inputStream)) {
tempFile = File.createTempFile(toPath, null);
// 将FTP文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, tempFile);
}
return tempFile;
} catch (IOException e) {
e.printStackTrace();

View File

@ -32,8 +32,8 @@ public class GammaController {
@GetMapping("initValue")
@ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据")
public Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, fileName, request);
public Result initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request) {
return gammaService.initValue(sampleId, dbName, analyst, fileName, request);
}
@ -43,8 +43,8 @@ public class GammaController {
}
@GetMapping("gammaByDB")
public Result gammaByDB(Integer sampleId, String dbName, HttpServletRequest request){
return gammaService.gammaByDB(dbName, sampleId, request);
public Result gammaByDB(Integer sampleId, String dbName, String analyst, HttpServletRequest request){
return gammaService.gammaByDB(dbName, sampleId, analyst, request);
}
@GetMapping("gammaByFile")

View File

@ -26,8 +26,8 @@ public class SpectrumAnalysesController {
@GetMapping("getDBSearchList")
@ApiOperation(value = "查询查询条件数据接口", notes = "查询查询条件数据接口")
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String dbName, String[] menuTypes) {
return spectrumAnalysisService.getDBSearchList(request, AllUsers, dbName, menuTypes);
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers) {
return spectrumAnalysisService.getDBSearchList(request, AllUsers);
}
@GetMapping("getDBSpectrumList")

View File

@ -31,6 +31,9 @@ public class GardsSampleDataSpectrum extends GardsSampleData {
@TableField(exist = false)
private String dbName;
@TableField(exist = false)
private String analyst;
@TableField(exist = false)
@Excel(name = "NO" ,orderNum = "1")
private Integer no;

View File

@ -12,11 +12,11 @@ import java.util.List;
public interface IGammaService{
Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request);
Result initValue(Integer sampleId, String dbName, String analyst, String fileName, HttpServletRequest request);
Result testFun(String fileName, HttpServletRequest request);
Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request);
Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request);
Result gammaByFile(String fileName, HttpServletRequest request);

View File

@ -14,7 +14,7 @@ import java.util.List;
public interface ISpectrumAnalysisService {
Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String dbName, String[] menuTypes);
Result getDBSearchList(HttpServletRequest request, boolean AllUsers);
Result getDBSpectrumList(QueryRequest queryRequest, GardsSampleDataSpectrum gardsSampleData, String dbName, String[] menuTypes, boolean AllUsers, boolean CollectStopB, boolean AcqStartB, Date startDate, Date endDate, HttpServletRequest request);

View File

@ -140,7 +140,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
private IGardsAnalySettingSpectrumService analySettingSpectrumService;
@Override
public Result initValue(Integer sampleId, String dbName, String samfileName, HttpServletRequest request) {
public Result initValue(Integer sampleId, String dbName, String analyst, String samfileName, HttpServletRequest request) {
Result result = new Result();
//获取用户名
String userName = JwtUtil.getUserNameByToken(request);
@ -168,7 +168,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (dbName.equals("auto")) {
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
} else if (dbName.equals("man")) {
gammaFileUtil.SetBaseInfo(phd, userName);
gammaFileUtil.SetBaseInfo(phd, analyst);
}
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
@ -433,7 +433,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
@Override
public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) {
public Result gammaByDB(String dbName, Integer sampleId, String analyst, HttpServletRequest request) {
Result result = new Result();
// 通过token获取用户名
String userName = JwtUtil.getUserNameByToken(request);
@ -466,7 +466,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
if (dbName.equals("auto")) {
gammaFileUtil.SetBaseInfo(phd, "RNAUTO");
} else if (dbName.equals("man")) {
gammaFileUtil.SetBaseInfo(phd, userName);
gammaFileUtil.SetBaseInfo(phd, analyst);
}
// 从数据库中读取phd其他相关信息
boolean bRet = getResultFromDB(dbName, userName, sampleId, phd, result);
@ -1459,13 +1459,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
if (!tablePeaksList.get(j).isNetAreaB()) {
Af.add(Integer.valueOf(tablePeaksList.get(j).getLab()));
Af.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
}
if (!tablePeaksList.get(j).isCentroid()) {
Cf.add(Integer.valueOf(tablePeaksList.get(j).getLab()));
Cf.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
}
if (!tablePeaksList.get(j).isFwhmB()) {
Ff.add(Integer.valueOf(tablePeaksList.get(j).getLab()));
Ff.add(Integer.valueOf(tablePeaksList.get(j).getLab())-1);
}
}
ObjectMapper mapper = new ObjectMapper();

View File

@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.cache.Cache;
import io.swagger.models.auth.In;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.shiro.SecurityUtils;
@ -108,26 +109,20 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
@Autowired
private IGardsHistogramSpectrumService histogramService;
@Autowired
private JdbcTemplate jdbcTemplate;
@Override
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers, String dbName, String[] menuTypes) {
public Result getDBSearchList(HttpServletRequest request, boolean AllUsers) {
Result result = new Result();
Map<String, List<String>> map = new HashMap<>();
List<String> menuTypeList = Arrays.asList(menuTypes);
//查询谱对应的台站类型
if (CollectionUtils.isEmpty(menuTypeList)){
result.error500("The spectrum type cannot be empty");
return result;
}
List<String> stationTypes = sysDictService.findStationType(menuTypeList);
if (CollectionUtils.isEmpty(stationTypes)) {
result.error500("Please add the station type corresponding to the current system type in the data dictionary");
return result;
}
//获取台站编码
List<String> stationCodes = new LinkedList<>();
List<String> detectorCodes = new LinkedList<>();
//根据台站id查询台站名称
Map<String, String> stationMap = (Map<String, String>)redisUtil.get("stationMap");
//从redis中获取探测器信息
Map<Integer, String> detectorInfoMap = (Map<Integer, String>)redisUtil.get("detectorsMap");
//获取台站信息
List<String> userStations = new LinkedList<>();
//如果没有勾选AllUsers
if (Objects.nonNull(AllUsers) && !AllUsers){
@ -137,23 +132,43 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
return result;
}
userStations = userTaskUtil.findUserStation(userName);
//判断当前用户在当天是否有排班任务的台站信息
if (CollectionUtils.isNotEmpty(userStations)) {
if (CollectionUtils.isNotEmpty(stationMap)){
for (Map.Entry<String, String> entry:stationMap.entrySet()) {
if (userStations.contains(entry.getKey())) {
stationCodes.add(entry.getValue());
}
if (dbName.equalsIgnoreCase("auto")){
dbName = "RNAUTO.GARDS_ANALYSES";
}else if (dbName.equalsIgnoreCase("man")){
dbName = "RNMAN.GARDS_ANALYSES";
}else {
result.error500("The database type does not exist");
return result;
}
List<GardsSampleDataSpectrum> sampleData = spectrumAnalysisMapper.getDBSearchList(dbName, stationTypes, userStations, AllUsers);
//获取台站编码
List<String> stationCodes = new LinkedList<>();
List<String> detectorCodes = new LinkedList<>();
if (CollectionUtils.isNotEmpty(sampleData)){
stationCodes = sampleData.stream().map(GardsSampleDataSpectrum::getStationName).distinct().collect(Collectors.toList());
detectorCodes = sampleData.stream().map(GardsSampleDataSpectrum::getDetectorsName).distinct().collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(detectorInfoMap)) {
for (Map.Entry<Integer, String> entry:detectorInfoMap.entrySet()) {
if (String.valueOf(entry.getKey()).length() <= 3) {
if (userStations.contains(String.valueOf(entry.getKey()))) {
detectorCodes.add(entry.getValue());
}
} else {
if (userStations.contains(String.valueOf(entry.getKey()).substring(0, 3))) {
detectorCodes.add(entry.getValue());
}
}
}
}
}
} else {
if (CollectionUtils.isNotEmpty(stationMap)) {
for (Map.Entry<String, String> entry: stationMap.entrySet()) {
stationCodes.add(entry.getValue());
}
}
if (CollectionUtils.isNotEmpty(detectorInfoMap)) {
for (Map.Entry<Integer, String> entry: detectorInfoMap.entrySet()) {
detectorCodes.add(entry.getValue());
}
}
}
stationCodes = stationCodes.stream().sorted().collect(Collectors.toList());
detectorCodes = detectorCodes.stream().sorted().collect(Collectors.toList());
map.put("stationCode", stationCodes);
map.put("detectorCode", detectorCodes);
result.setSuccess(true);
@ -191,9 +206,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
String tempDBName = dbName;
if (dbName.equalsIgnoreCase("auto")){
dbName = "RNAUTO.GARDS_ANALYSES";
}else if (dbName.equalsIgnoreCase("man")){
} else if (dbName.equalsIgnoreCase("man")){
dbName = "RNMAN.GARDS_ANALYSES";
}else {
} else {
result.error500("The database type does not exist");
return result;
}

View File

@ -105,6 +105,12 @@ public class WebStatisticsController {
return readLineUtil.readFtpFile(filePath,response);
}
@GetMapping("downloadFile")
@ApiOperation("查看Radionuclide的文件")
public void downloadFile(@RequestParam Integer sampleId, HttpServletResponse response){
gardsSampleDataWebService.downloadFile(sampleId, response);
}
@GetMapping("sohFile")
@ApiOperation(value = "查看RMSSHO的文件",notes = "查看RMSSHO的文件")
public Result sohFile(@RequestParam Integer sohId,

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsBgEfficiencyPairs;
@Mapper
public interface GardsBgEfficiencyPairsMapper extends BaseMapper<GardsBgEfficiencyPairs> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
@Mapper
public interface GardsCalibrationPairsOrigMapper extends BaseMapper<GardsCalibrationPairsOrig> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsHistogram;
@Mapper
public interface GardsHistogramMapper extends BaseMapper<GardsHistogram> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsRoiLimits;
@Mapper
public interface GardsRoiLimitsMapper extends BaseMapper<GardsRoiLimits> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsSampleCertLine;
@Mapper
public interface GardsSampleCertLineMapper extends BaseMapper<GardsSampleCertLine> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsSampleCert;
@Mapper
public interface GardsSampleCertMapper extends BaseMapper<GardsSampleCert> {
}

View File

@ -3,8 +3,10 @@ package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.vo.SpectrumFileRecord;
import java.util.List;
@ -17,4 +19,12 @@ public interface GardsSampleDataWebMapper extends BaseMapper<GardsSampleDataWeb>
Page<GardsSampleDataWeb> findParticulatePage(String dataType, String spectralQualifie, String startDate, String endDate, List<Integer> stationIdList, Page<GardsSampleDataWeb> page);
Integer getAnalysisID(@Param(value = "sampleId") Integer sampleId);
SpectrumFileRecord getDBSpectrumFilePath(Integer sampleId, Integer analysisID);
String getQCFilePath(String siteDetCode, String collectStartStr);
Integer getSampleId(@Param(value = "filePathName") String filePathName);
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsSampleDescription;
@Mapper
public interface GardsSampleDescriptionMapper extends BaseMapper<GardsSampleDescription> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsSampleRatios;
@Mapper
public interface GardsSampleRatiosMapper extends BaseMapper<GardsSampleRatios> {
}

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.base.entity.original.GardsSpectrum;
@Mapper
public interface GardsSpectrumMapper extends BaseMapper<GardsSpectrum> {
}

View File

@ -126,4 +126,44 @@
ORDER BY ACQUISITION_START DESC
</select>
<select id="getAnalysisID" resultType="java.lang.Integer">
SELECT ANALYSIS_DB.IDANALYSIS FROM RNAUTO.GARDS_ANALYSES ANALYSIS_DB WHERE ANALYSIS_DB.SAMPLE_ID = #{sampleId} and ANALYST = 'RNAUTO'
</select>
<select id="getDBSpectrumFilePath" resultType="org.jeecg.modules.entity.vo.SpectrumFileRecord">
SELECT
org_sample.SAMPLE_ID sampleId,
org_sample.INPUT_FILE_NAME sampleFilePath,
analyses.USEDGASPHD gasBgFilePath,
analyses.USEDDETPHD detBgFilePath,
analyses.LOG_PATH logFilePath,
analyses.REPORT_PAHT reportFilePath,
TRIM(org_sample.SITE_DET_CODE) siteDetCode,
org_sample.COLLECT_START collectStart
FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample,
RNAUTO.GARDS_ANALYSES analyses
<where>
analyses.SAMPLE_ID = #{sampleId}
AND analyses.IDANALYSIS = #{analysisID}
AND org_sample.SAMPLE_ID=analyses.SAMPLE_ID
</where>
</select>
<select id="getQCFilePath" resultType="java.lang.String">
SELECT org_sample_data.INPUT_FILE_NAME
FROM ORIGINAL.GARDS_SAMPLE_DATA org_sample_data
<where>
org_sample_data.ACQUISITION_START=
(SELECT MAX(qc_samples.ACQUISITION_START) FROM ORIGINAL.GARDS_SAMPLE_DATA qc_samples WHERE qc_samples.SITE_DET_CODE= '${siteDetCode}'
AND qc_samples.DATA_TYPE='Q'
AND qc_samples.SPECTRAL_QUALIFIE='FULL'
AND qc_samples.ACQUISITION_START &lt;= TO_DATE('${collectStartStr}', 'YYYY-MM-DD hh24:mi:ss'))
AND org_sample_data.SITE_DET_CODE= '${siteDetCode}'
</where>
</select>
<select id="getSampleId" resultType="java.lang.Integer">
SELECT SAMPLE_ID FROM ORIGINAL.GARDS_SAMPLE_DATA WHERE INPUT_FILE_NAME = #{filePathName}
</select>
</mapper>

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.swagger.models.auth.In;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.entity.GardsSampleDataWeb;
@ -33,6 +34,7 @@ public interface IGardsSampleDataWebService extends IService<GardsSampleDataWeb>
Result sampleInfo(Integer sampleId);
void downloadFile(Integer sampleId, HttpServletResponse response);
GardsSampleDataWeb getOneSample(Integer sampleId);

View File

@ -5,23 +5,26 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.jeecg.common.api.QueryRequest;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.enums.SampleFileHeader;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.common.util.ReadLineUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.modules.base.entity.original.*;
import org.jeecg.modules.entity.GardsSampleDataWeb;
import org.jeecg.modules.entity.data.*;
import org.jeecg.modules.entity.vo.SpectrumFileRecord;
import org.jeecg.modules.mapper.*;
import org.jeecg.modules.service.IGardsSampleDataWebService;
import org.jeecgframework.poi.excel.ExcelExportUtil;
@ -30,8 +33,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.net.URLEncoder;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@ -66,6 +69,12 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
private GardsSampleCertLineMapper gardsSampleCertLineMapper;
@Autowired
private ReadLineUtil readLineUtil;
@Autowired
private FTPUtil ftpUtil;
@Autowired
private SpectrumPathProperties spectrumPathProperties;
@Autowired
private ParameterProperties parameterProperties;
@Override
public Result findParticulatePage(QueryRequest queryRequest, Integer[] stationIds, String dataType, String spectralQualifie, Date startTime,Date endTime) {
@ -167,6 +176,136 @@ public class GardsSampleDataWebServiceImpl extends ServiceImpl<GardsSampleDataWe
return Result.OK(report);
}
@Override
public void downloadFile(Integer sampleId, HttpServletResponse response) {
//创建一个zip文件 将需要压缩进去的文件都压缩到zip中
File zipFile = null;
FileInputStream inputStream = null;
OutputStream outputStream = null;
//samplegasdetqc的临时文件
File sampleFile = null;
InputStream sampleStream = null;
File gasFile = null;
InputStream gasStream = null;
File detFile = null;
InputStream detStream = null;
File qcFile = null;
InputStream qcStream = null;
try {
//根据sampleId查询自动处理库获取相应分析id
Integer analysisID = this.baseMapper.getAnalysisID(sampleId);
if (Objects.nonNull(analysisID)) {
//根据sampleId和分析id查询数据库文件信息
SpectrumFileRecord dbSpectrumFilePath = this.baseMapper.getDBSpectrumFilePath(sampleId, analysisID);
if (Objects.nonNull(dbSpectrumFilePath)) {
//判断临时存放压缩包位置是否存在
File dir = new File(parameterProperties.getLogFilePath());
if (!dir.exists()) {
dir.mkdirs();
}
//获取sample文件路径 截取sample文件名称 将PHD改为zip
String zipFileName = dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH) + 1).replace("PHD", "zip");
//获取分析表中的采集开始时间
String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss");
//根据探测器信息以及采集开始时间查询对应的qc文件路径
String dbQcFilePath = this.baseMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr);
//根据各路径返回samplegasdetqc对应的文件sampleId
if (StringUtils.isNotBlank(dbSpectrumFilePath.getSampleFilePath())) {
sampleStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath()+ StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath());
if (Objects.nonNull(sampleStream)) {
sampleFile = new File(parameterProperties.getLogFilePath() + StringPool.SLASH + dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH) + 1));
FileUtils.copyInputStreamToFile(sampleStream, sampleFile);
}
}
if (StringUtils.isNotBlank(dbSpectrumFilePath.getGasBgFilePath())) {
gasStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath()+ StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath());
if (Objects.nonNull(gasStream)) {
gasFile = new File(parameterProperties.getLogFilePath() + StringPool.SLASH + dbSpectrumFilePath.getGasBgFilePath().substring(dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH) + 1));
FileUtils.copyInputStreamToFile(gasStream, gasFile);
}
}
if (StringUtils.isNotBlank(dbSpectrumFilePath.getDetBgFilePath())) {
detStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath()+ StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath());
if (Objects.nonNull(detStream)) {
detFile = new File(parameterProperties.getLogFilePath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH) + 1));
FileUtils.copyInputStreamToFile(detStream, detFile);
}
}
if (StringUtils.isNotBlank(dbQcFilePath)) {
qcStream = ftpUtil.downloadFileStream(ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath()+ StringPool.SLASH + dbQcFilePath);
if (Objects.nonNull(qcStream)) {
qcFile = new File(parameterProperties.getLogFilePath() + StringPool.SLASH + dbQcFilePath.substring(dbQcFilePath.lastIndexOf(StringPool.SLASH) + 1));
FileUtils.copyInputStreamToFile(qcStream, qcFile);
}
}
if (Objects.nonNull(sampleFile) || Objects.nonNull(gasFile) || Objects.nonNull(detFile) ||Objects.nonNull(qcFile)) {
//创建zip的临时文件
zipFile = File.createTempFile("betaGammaZip", null);
File zip = ZipUtil.zip(zipFile, true, sampleFile, gasFile, detFile, qcFile);
//获取压缩文件的文件输入流
inputStream = new FileInputStream(zip);
//重置响应信息
response.reset();
//设置响应类型
response.setContentType("application/download");
//解决中文不能生成文件
response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(zipFileName,"UTF-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
//获取响应流的输出流
outputStream = response.getOutputStream();
//定义一个字节大小
byte[] buffer = new byte[1024];
int bytesRead;
// 将文件输出流写入到输出流中
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(sampleFile)) {
sampleFile.delete();
}
if (Objects.nonNull(sampleStream)) {
sampleStream.close();
}
if (Objects.nonNull(gasFile)) {
gasFile.delete();
}
if (Objects.nonNull(gasStream)) {
gasStream.close();
}
if (Objects.nonNull(detFile)) {
detFile.delete();
}
if (Objects.nonNull(detStream)) {
detStream.close();
}
if (Objects.nonNull(qcFile)) {
qcFile.delete();
}
if (Objects.nonNull(qcStream)) {
qcStream.close();
}
if (Objects.nonNull(zipFile)) {
zipFile.delete();
}
if (Objects.nonNull(inputStream)) {
inputStream.close();
}
if (Objects.nonNull(outputStream)) {
outputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
private void findInfo(Integer sampleId, Report report) {
//声明多个对象 分别封装独立的信息
GeneralInformation generalInformation = new GeneralInformation();