feat:整合FtpDownFile
This commit is contained in:
parent
7ed2207730
commit
f4cdad297e
|
@ -1,7 +1,9 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
@ -13,6 +15,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -303,4 +306,60 @@ public class FTPUtil {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public File fTPFile(String fromPath, String toPath) {
|
||||
FTPClient ftpClient = null;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
ftpClient = LoginFTP();
|
||||
// 切换被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
inputStream = ftpClient.retrieveFileStream(fromPath);
|
||||
// 声明一个临时文件
|
||||
File tempFile = File.createTempFile(toPath, null);
|
||||
// 将FTP文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, tempFile);
|
||||
return tempFile;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(ftpClient))
|
||||
ftpClient.disconnect();
|
||||
if (ObjectUtil.isNotNull(inputStream))
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InputStream fTPFileStream(String fromPath) {
|
||||
FTPClient ftpClient = null;
|
||||
try {
|
||||
ftpClient = LoginFTP();
|
||||
// 切换被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
return ftpClient.retrieveFileStream(fromPath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (ObjectUtil.isNotNull(ftpClient))
|
||||
ftpClient.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package org.jeecg.config.mybatis;
|
||||
|
||||
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
||||
|
||||
/**
|
||||
* 数据源切换器
|
||||
*/
|
||||
public class DSSwitcher {
|
||||
|
||||
private final static String ORACLE = "ora";
|
||||
|
||||
private final static String PGSQL = "master";
|
||||
|
||||
public static void switchToOracle(){
|
||||
DynamicDataSourceContextHolder.push(ORACLE);
|
||||
}
|
||||
|
||||
public static void switchToPGSql(){
|
||||
DynamicDataSourceContextHolder.push(PGSQL);
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
DynamicDataSourceContextHolder.clear();
|
||||
}
|
||||
}
|
|
@ -63,4 +63,10 @@ public class SysDatabaseController {
|
|||
List<SourceDto> sourceDtos = sysDatabaseService.listAll();
|
||||
return Result.OK(sourceDtos);
|
||||
}
|
||||
|
||||
@GetMapping("dbNames")
|
||||
@ApiOperation(value = "数据库名列表",notes = "数据库名列表")
|
||||
public Result<?> dbNames(@RequestParam String dbType){
|
||||
return Result.OK(sysDatabaseService.dbNames(dbType));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,10 @@ public interface SysDatabaseMapper extends BaseMapper<SysDatabase> {
|
|||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||
|
||||
List<DatabaseDto> findPage(Map<String,Object> params);
|
||||
|
||||
List<String> dbNamesPG();
|
||||
|
||||
List<String> dbNamesMY();
|
||||
|
||||
List<String> dbNamesOR();
|
||||
}
|
||||
|
|
|
@ -18,10 +18,4 @@ public interface SysServerMapper extends BaseMapper<SysServer> {
|
|||
List<SourceDto> pageAll(String itemName);
|
||||
|
||||
List<AlarmInfo> alarmInfo(String sourceId);
|
||||
|
||||
List<String> dbNamesPG();
|
||||
|
||||
List<String> dbNamesMY();
|
||||
|
||||
List<String> dbNamesOR();
|
||||
}
|
||||
|
|
|
@ -72,14 +72,4 @@
|
|||
WHERE r.source_id = #{sourceId}
|
||||
ORDER BY l.alarm_start_date DESC
|
||||
</select>
|
||||
<select id="dbNamesPG" resultType="java.lang.String">
|
||||
SELECT datname FROM pg_database WHERE datistemplate = false;
|
||||
</select>
|
||||
<select id="dbNamesMY" resultType="java.lang.String">
|
||||
SHOW DATABASES;
|
||||
</select>
|
||||
<select id="dbNamesOR" resultType="java.lang.String">
|
||||
SELECT username FROM all_users;
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -50,5 +50,13 @@
|
|||
LIMIT #{pageSize} OFFSET #{pageStart}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="dbNamesPG" resultType="java.lang.String">
|
||||
SELECT datname FROM pg_database WHERE datistemplate = false;
|
||||
</select>
|
||||
<select id="dbNamesMY" resultType="java.lang.String">
|
||||
SHOW DATABASES;
|
||||
</select>
|
||||
<select id="dbNamesOR" resultType="java.lang.String">
|
||||
SELECT username FROM all_users;
|
||||
</select>
|
||||
</mapper>
|
|
@ -24,4 +24,6 @@ public interface ISysDatabaseService extends IService<SysDatabase> {
|
|||
Result findAlarmHistory(SourceVo sourceVo);
|
||||
|
||||
List<SourceDto> listAll();
|
||||
|
||||
List<String> dbNames(String dbType);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,4 @@ public interface ISysServerService extends IService<SysServer> {
|
|||
Result<?> details_BasicInfo(String hostId);
|
||||
|
||||
Result<?> details_AlarmInfo(String sourceId, Integer pageNo, Integer pageSize);
|
||||
|
||||
List<String> dbNames();
|
||||
}
|
||||
|
|
|
@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.QueryRequest;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
import org.jeecg.common.constant.DictConstant;
|
||||
import org.jeecg.common.constant.Prompt;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.config.mybatis.DSSwitcher;
|
||||
import org.jeecg.modules.base.dto.DatabaseDto;
|
||||
import org.jeecg.modules.base.dto.SourceDto;
|
||||
import org.jeecg.modules.base.entity.postgre.SysDatabase;
|
||||
|
@ -178,4 +180,25 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
|
|||
return sourceDtos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> dbNames(String dbType) {
|
||||
List<String> dbNames = new ArrayList<>();
|
||||
switch (dbType){
|
||||
case DataBaseConstant.DB_TYPE_ORACLE:
|
||||
DSSwitcher.switchToOracle();
|
||||
dbNames = baseMapper.dbNamesOR();
|
||||
DSSwitcher.clear();
|
||||
break;
|
||||
case DataBaseConstant.DB_TYPE_POSTGRESQL:
|
||||
dbNames = baseMapper.dbNamesPG();
|
||||
break;
|
||||
case DataBaseConstant.DB_TYPE_MYSQL:
|
||||
// ...
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return dbNames;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -304,10 +304,4 @@ public class SysServerServiceImpl extends ServiceImpl<SysServerMapper, SysServer
|
|||
page.setRecords(records);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> dbNames() {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,8 @@ import org.jeecg.common.constant.*;
|
|||
import org.jeecg.common.constant.enums.SpectrumSystemType;
|
||||
import org.jeecg.common.properties.ParameterProperties;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.GammaFileUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.modules.base.bizVo.AttributeItemVo;
|
||||
import org.jeecg.common.util.MyLogFormatUtil;
|
||||
import org.jeecg.modules.base.dto.*;
|
||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||
import org.jeecg.modules.base.entity.rnauto.*;
|
||||
|
@ -61,6 +58,8 @@ public class Sample_G_Analysis {
|
|||
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
private FTPUtil ftpUtil;
|
||||
|
||||
/**
|
||||
* 系统类型
|
||||
*/
|
||||
|
@ -124,9 +123,10 @@ public class Sample_G_Analysis {
|
|||
PHDFile phdFile = new PHDFile();
|
||||
phdFile.setXmlFilePath(parameterProperties.getFilePath());
|
||||
// 解析PHD文件
|
||||
spectrumPathProperties = ApplicationContextUtil.getContext().getBean(SpectrumPathProperties.class);
|
||||
spectrumPathProperties = SpringContextUtils.getBean(SpectrumPathProperties.class);
|
||||
ftpUtil = SpringContextUtils.getBean(FTPUtil.class);
|
||||
String sampleFilePath = sampleData.getInputFileName();
|
||||
String pathName = File.separator + spectrumPathProperties.getSaveFilePath() + File.separator +
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + File.separator +
|
||||
sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.net.ftp.FTP;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
import org.ejml.simple.SimpleMatrix;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.properties.ParameterProperties;
|
||||
|
@ -30,7 +29,6 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
|||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
|
@ -41,8 +39,6 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -64,209 +60,177 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
public boolean loadFile(String pathName, String fileName, PHDFile phd, Result result) {
|
||||
phd.setFilepath(pathName);
|
||||
phd.setFilename(fileName);
|
||||
//连接ftp
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if (Objects.isNull(ftpClient)){
|
||||
result.error500("ftp connection failed!");
|
||||
return false;
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
File file = null;
|
||||
String fromPath = pathName + File.separator + fileName;
|
||||
File file = ftpUtil.fTPFile(fromPath, "betaGamma");
|
||||
try {
|
||||
//切换被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
ftpClient.changeWorkingDirectory(pathName);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
//声明一个临时文件
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
//读取文件信息
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
//MsgInfo
|
||||
phd.getMsgInfo().setMsg_id(struct.msg_id);
|
||||
phd.getMsgInfo().setMsg_type(struct.msg_type);
|
||||
phd.getMsgInfo().setData_type(struct.data_type);
|
||||
//Header
|
||||
phd.getHeader().setDesignator(struct.designator);
|
||||
phd.getHeader().setSite_code(struct.site_code);
|
||||
phd.getHeader().setDetector_code(struct.detector_code);
|
||||
phd.getHeader().setSystem_type(struct.system_type);
|
||||
phd.getHeader().setSample_geometry(struct.sample_geometry);
|
||||
phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity);
|
||||
phd.getHeader().setSample_ref_id(struct.sample_ref_id);
|
||||
phd.getHeader().setMeasurement_id(struct.measurement_id);
|
||||
phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id);
|
||||
phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id);
|
||||
phd.getHeader().setTransmit_date(struct.transmit_date);
|
||||
phd.getHeader().setTransmit_time(struct.transmit_time);
|
||||
//Comment
|
||||
phd.setOriTotalCmt(struct.comment);
|
||||
//Collection
|
||||
if (StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) && StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) {
|
||||
phd.getCollect().setCollection_start_date(struct.collection_start_date);
|
||||
phd.getCollect().setCollection_start_time(struct.collection_start_time);
|
||||
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
|
||||
phd.getCollect().setCollection_stop_time(struct.collection_stop_time);
|
||||
phd.getCollect().setAir_volume(struct.air_volume);
|
||||
if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0");
|
||||
}
|
||||
if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0");
|
||||
}
|
||||
} else {
|
||||
phd.getCollect().setAir_volume(0.0);
|
||||
//读取文件信息
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
//MsgInfo
|
||||
phd.getMsgInfo().setMsg_id(struct.msg_id);
|
||||
phd.getMsgInfo().setMsg_type(struct.msg_type);
|
||||
phd.getMsgInfo().setData_type(struct.data_type);
|
||||
//Header
|
||||
phd.getHeader().setDesignator(struct.designator);
|
||||
phd.getHeader().setSite_code(struct.site_code);
|
||||
phd.getHeader().setDetector_code(struct.detector_code);
|
||||
phd.getHeader().setSystem_type(struct.system_type);
|
||||
phd.getHeader().setSample_geometry(struct.sample_geometry);
|
||||
phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity);
|
||||
phd.getHeader().setSample_ref_id(struct.sample_ref_id);
|
||||
phd.getHeader().setMeasurement_id(struct.measurement_id);
|
||||
phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id);
|
||||
phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id);
|
||||
phd.getHeader().setTransmit_date(struct.transmit_date);
|
||||
phd.getHeader().setTransmit_time(struct.transmit_time);
|
||||
//Comment
|
||||
phd.setOriTotalCmt(struct.comment);
|
||||
//Collection
|
||||
if (StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) && StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) {
|
||||
phd.getCollect().setCollection_start_date(struct.collection_start_date);
|
||||
phd.getCollect().setCollection_start_time(struct.collection_start_time);
|
||||
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
|
||||
phd.getCollect().setCollection_stop_time(struct.collection_stop_time);
|
||||
phd.getCollect().setAir_volume(struct.air_volume);
|
||||
if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0");
|
||||
}
|
||||
//Acquisition
|
||||
if (StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
|
||||
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
|
||||
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
|
||||
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
|
||||
phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time);
|
||||
if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) {
|
||||
phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0");
|
||||
}
|
||||
} else {
|
||||
phd.getAcq().setAcquisition_live_time(0.0);
|
||||
phd.getAcq().setAcquisition_real_time(0.0);
|
||||
if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) {
|
||||
phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0");
|
||||
}
|
||||
//Processing
|
||||
if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && StringUtils.isNotBlank(struct.archive_bottle_id)) {
|
||||
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
|
||||
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
|
||||
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
|
||||
phd.getProcess().setUncertainty_2(struct.uncertainty_2);
|
||||
phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id);
|
||||
} else {
|
||||
phd.getProcess().setSample_volume_of_Xe(0.0);
|
||||
phd.getProcess().setXe_collection_yield(0.0);
|
||||
phd.getProcess().setUncertainty_1(0.0);
|
||||
phd.getProcess().setUncertainty_2(0.0);
|
||||
}
|
||||
//Sample
|
||||
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
|
||||
phd.getSampleBlock().setDimension_1(struct.dimension_1);
|
||||
phd.getSampleBlock().setDimension_2(struct.dimension_2);
|
||||
} else {
|
||||
phd.getSampleBlock().setDimension_1(0.0);
|
||||
phd.getSampleBlock().setDimension_2(0.0);
|
||||
}
|
||||
//Calibration
|
||||
if (StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)) {
|
||||
phd.getCalibration().setDate_calibration(struct.date_calibration);
|
||||
phd.getCalibration().setTime_calibration(struct.time_calibration);
|
||||
}
|
||||
//Certificate
|
||||
if (Objects.nonNull(struct.total_source_activity) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name)
|
||||
&& CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
|
||||
&& CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
|
||||
phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
|
||||
phd.getCertificate().setAssay_date(struct.assay_date);
|
||||
phd.getCertificate().setAssay_time(struct.assay_time);
|
||||
phd.getCertificate().setUnits_activity(struct.units_activity);
|
||||
phd.getCertificate().setNuclide_name(struct.nuclide_name);
|
||||
phd.getCertificate().setHalf_life_time(struct.half_life_time);
|
||||
phd.getCertificate().setTime_unit(struct.time_unit);
|
||||
phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay);
|
||||
phd.getCertificate().setUncertainty(struct.uncertainty);
|
||||
phd.getCertificate().setG_energy(struct.cer_g_energy);
|
||||
phd.getCertificate().setG_intensity(struct.g_intensity);
|
||||
phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode);
|
||||
phd.getCertificate().setMaximum_energy(struct.maximum_energy);
|
||||
phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle);
|
||||
phd.getCertificate().setRecord_count(struct.record_count);
|
||||
}
|
||||
//g_Spectrum
|
||||
if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
|
||||
phd.getSpec().setNum_g_channel(struct.num_g_channel);
|
||||
phd.getSpec().setG_energy_span(struct.g_energy_span);
|
||||
phd.getSpec().setBegin_channel(struct.g_begin_channel);
|
||||
phd.getSpec().setCounts(struct.g_counts);
|
||||
int i = 0;
|
||||
for (; i < phd.getSpec().getNum_g_channel(); i++) {
|
||||
if (phd.getSpec().getCounts().get(i) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == phd.getSpec().getNum_g_channel()) {
|
||||
phd.setValid(false);
|
||||
}
|
||||
}
|
||||
//g_Energy
|
||||
if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
|
||||
GEnergyBlock gEnergyBlock = new GEnergyBlock();
|
||||
gEnergyBlock.setG_energy(struct.g_energy);
|
||||
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
|
||||
gEnergyBlock.setUncertainty(struct.g_uncertainty);
|
||||
gEnergyBlock.setRecord_count(struct.g_record_count);
|
||||
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
|
||||
}
|
||||
//g_Resolution
|
||||
if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
|
||||
GResolutionBlock gResolutionBlock = new GResolutionBlock();
|
||||
gResolutionBlock.setG_energy(struct.g_r_energy);
|
||||
gResolutionBlock.setFWHM(struct.g_r_FWHM);
|
||||
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
|
||||
gResolutionBlock.setRecord_count(struct.g_r_record_count);
|
||||
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
|
||||
}
|
||||
//g_Efficiency
|
||||
if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
|
||||
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
|
||||
gEfficiencyBlock.setG_energy(struct.g_e_energy);
|
||||
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
|
||||
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
|
||||
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
|
||||
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
|
||||
}
|
||||
//TotalEff
|
||||
if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
|
||||
TotaleffBlock totaleffBlock = new TotaleffBlock();
|
||||
totaleffBlock.setG_energy(struct.t_g_energy);
|
||||
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
|
||||
totaleffBlock.setUncertainty(struct.t_uncertainty);
|
||||
totaleffBlock.setRecord_count(struct.t_record_count);
|
||||
phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock);
|
||||
}
|
||||
|
||||
// 初始化默认分析设置
|
||||
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
|
||||
phd.getSetting().setECutAnalysis_Low(35.0);
|
||||
phd.getSetting().setBUpdateCal(true);
|
||||
}
|
||||
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
|
||||
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
|
||||
SpecSetup usedSetting = new SpecSetup();
|
||||
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
|
||||
phd.setUsedSetting(usedSetting);
|
||||
|
||||
phd.setBAnalyed(false);
|
||||
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
|
||||
} else {
|
||||
phd.getCollect().setAir_volume(0.0);
|
||||
}
|
||||
}catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ParseException e) {
|
||||
//Acquisition
|
||||
if (StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
|
||||
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
|
||||
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
|
||||
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
|
||||
phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time);
|
||||
if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) {
|
||||
phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0");
|
||||
}
|
||||
} else {
|
||||
phd.getAcq().setAcquisition_live_time(0.0);
|
||||
phd.getAcq().setAcquisition_real_time(0.0);
|
||||
}
|
||||
//Processing
|
||||
if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && StringUtils.isNotBlank(struct.archive_bottle_id)) {
|
||||
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
|
||||
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
|
||||
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
|
||||
phd.getProcess().setUncertainty_2(struct.uncertainty_2);
|
||||
phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id);
|
||||
} else {
|
||||
phd.getProcess().setSample_volume_of_Xe(0.0);
|
||||
phd.getProcess().setXe_collection_yield(0.0);
|
||||
phd.getProcess().setUncertainty_1(0.0);
|
||||
phd.getProcess().setUncertainty_2(0.0);
|
||||
}
|
||||
//Sample
|
||||
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
|
||||
phd.getSampleBlock().setDimension_1(struct.dimension_1);
|
||||
phd.getSampleBlock().setDimension_2(struct.dimension_2);
|
||||
} else {
|
||||
phd.getSampleBlock().setDimension_1(0.0);
|
||||
phd.getSampleBlock().setDimension_2(0.0);
|
||||
}
|
||||
//Calibration
|
||||
if (StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)) {
|
||||
phd.getCalibration().setDate_calibration(struct.date_calibration);
|
||||
phd.getCalibration().setTime_calibration(struct.time_calibration);
|
||||
}
|
||||
//Certificate
|
||||
if (Objects.nonNull(struct.total_source_activity) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name)
|
||||
&& CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
|
||||
&& CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
|
||||
phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
|
||||
phd.getCertificate().setAssay_date(struct.assay_date);
|
||||
phd.getCertificate().setAssay_time(struct.assay_time);
|
||||
phd.getCertificate().setUnits_activity(struct.units_activity);
|
||||
phd.getCertificate().setNuclide_name(struct.nuclide_name);
|
||||
phd.getCertificate().setHalf_life_time(struct.half_life_time);
|
||||
phd.getCertificate().setTime_unit(struct.time_unit);
|
||||
phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay);
|
||||
phd.getCertificate().setUncertainty(struct.uncertainty);
|
||||
phd.getCertificate().setG_energy(struct.cer_g_energy);
|
||||
phd.getCertificate().setG_intensity(struct.g_intensity);
|
||||
phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode);
|
||||
phd.getCertificate().setMaximum_energy(struct.maximum_energy);
|
||||
phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle);
|
||||
phd.getCertificate().setRecord_count(struct.record_count);
|
||||
}
|
||||
//g_Spectrum
|
||||
if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
|
||||
phd.getSpec().setNum_g_channel(struct.num_g_channel);
|
||||
phd.getSpec().setG_energy_span(struct.g_energy_span);
|
||||
phd.getSpec().setBegin_channel(struct.g_begin_channel);
|
||||
phd.getSpec().setCounts(struct.g_counts);
|
||||
int i = 0;
|
||||
for (; i < phd.getSpec().getNum_g_channel(); i++) {
|
||||
if (phd.getSpec().getCounts().get(i) > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == phd.getSpec().getNum_g_channel()) {
|
||||
phd.setValid(false);
|
||||
}
|
||||
}
|
||||
//g_Energy
|
||||
if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
|
||||
GEnergyBlock gEnergyBlock = new GEnergyBlock();
|
||||
gEnergyBlock.setG_energy(struct.g_energy);
|
||||
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
|
||||
gEnergyBlock.setUncertainty(struct.g_uncertainty);
|
||||
gEnergyBlock.setRecord_count(struct.g_record_count);
|
||||
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
|
||||
}
|
||||
//g_Resolution
|
||||
if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
|
||||
GResolutionBlock gResolutionBlock = new GResolutionBlock();
|
||||
gResolutionBlock.setG_energy(struct.g_r_energy);
|
||||
gResolutionBlock.setFWHM(struct.g_r_FWHM);
|
||||
gResolutionBlock.setUncertainty(struct.g_r_uncertainty);
|
||||
gResolutionBlock.setRecord_count(struct.g_r_record_count);
|
||||
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
|
||||
}
|
||||
//g_Efficiency
|
||||
if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
|
||||
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
|
||||
gEfficiencyBlock.setG_energy(struct.g_e_energy);
|
||||
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
|
||||
gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty);
|
||||
gEfficiencyBlock.setRecord_count(struct.g_e_record_count);
|
||||
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
|
||||
}
|
||||
//TotalEff
|
||||
if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
|
||||
TotaleffBlock totaleffBlock = new TotaleffBlock();
|
||||
totaleffBlock.setG_energy(struct.t_g_energy);
|
||||
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
|
||||
totaleffBlock.setUncertainty(struct.t_uncertainty);
|
||||
totaleffBlock.setRecord_count(struct.t_record_count);
|
||||
phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock);
|
||||
}
|
||||
|
||||
// 初始化默认分析设置
|
||||
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
|
||||
phd.getSetting().setECutAnalysis_Low(35.0);
|
||||
phd.getSetting().setBUpdateCal(true);
|
||||
}
|
||||
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
|
||||
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
|
||||
SpecSetup usedSetting = new SpecSetup();
|
||||
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
|
||||
phd.setUsedSetting(usedSetting);
|
||||
|
||||
phd.setBAnalyed(false);
|
||||
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
|
||||
|
||||
}catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (Objects.nonNull(file))
|
||||
file.delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
result.error500("Sample file does not exist!");
|
||||
return result;
|
||||
}
|
||||
String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
|
||||
if (!flag) {
|
||||
|
@ -166,7 +166,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
}
|
||||
lastName = fileName;
|
||||
} else {
|
||||
String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
String fileName = samfileName;
|
||||
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
|
||||
if (!flag) {
|
||||
|
@ -425,7 +425,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
// 切割数据库存储的文件路径获取路径信息
|
||||
String pathName = StringPool.SLASH + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
// 切割数据库存储的文件路径获取文件名称
|
||||
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH) + 1);
|
||||
// 声明phd实体类
|
||||
|
@ -776,7 +776,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
Map<String, Object> map = new HashMap<>();
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
// 上传文件路径
|
||||
String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
String path = ftpUtil.getFtpRootPath() + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
// 获取当前角色的颜色配置
|
||||
Map<String, String> colorMap = sysUserColorService.initColor(userName);
|
||||
PHDFile phd = phdCache.getIfPresent(fileName + "-" + userName);
|
||||
|
|
Loading…
Reference in New Issue
Block a user