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

This commit is contained in:
nieziyan 2023-08-30 17:19:48 +08:00
commit e8a2b70334
16 changed files with 391 additions and 69 deletions

View File

@ -1,11 +1,12 @@
package org.jeecg.modules.base.entity.rnauto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@ -20,7 +21,7 @@ public class GardsAnalyses implements Serializable {
/**
* 分析ID号
*/
@TableField(value = "IDANALYSIS")
@TableId(value = "IDANALYSIS",type = IdType.AUTO)
private Integer idAnalysis;
/**
* 样品id

View File

@ -61,7 +61,7 @@ public class GardsCalibrationPairs implements Serializable {
* y值不确定度
*/
@TableField(value = "UNCYVALUE")
private String uncYValue;
private Double uncYValue;
@TableField(value = "MODDATE")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@ -0,0 +1,25 @@
package org.jeecg.modules.base.enums;
/**
* 分析类型
*/
public enum AnalysesType {
/**
* 样品谱未处理
*/
REVIEWED("Reviewed"),
/**
* 样品谱成功的被自动处理
*/
AUTO("Auto");
public String value;
AnalysesType(String value) {
this.value = value;
}
public String getValue(){
return this.value;
}
}

View File

@ -1,20 +1,15 @@
package org.jeecg.modules.ftp;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.net.ftp.*;
import org.jeecg.common.constant.StringConstant;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
@Slf4j
public class FTPUtils {
@ -50,66 +45,35 @@ public class FTPUtils {
/**
* 下载ftp服务文件
* @param localPath
* @param ftpFilePath
* @param fileName
* @param response
* @param localPath
* @throws IOException
*/
public void downloadFTPFile(String localPath, String fileName, HttpServletResponse response) {
InputStream in = null;
ServletOutputStream out = null;
//传输模式
try {
List<String> paths = Arrays.asList(localPath.split("/"));
if (CollectionUtils.isNotEmpty(paths)){
for (String workPath:paths) {
//切换工作文件路径
client.changeWorkingDirectory(workPath);
}
public void downloadFTPFile(String ftpFilePath,String fileName,String localPath) throws IOException {
//设置文件client参数
this.client.setFileType(FTPClient.BINARY_FILE_TYPE);
this.client.setControlEncoding(this.encoding);
this.client.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
this.checkDirectory(ftpFilePath);
System.out.println(this.client.printWorkingDirectory());
String absolutePath = this.ftpRootPath+StringConstant.SLASH+ftpFilePath;
final FTPFile[] ftpFiles = this.client.listFiles(null, file -> {
if (fileName.equals(file.getName())) {
return true;
}
client.enterLocalPassiveMode();
client.setFileType(FTPClient.BINARY_FILE_TYPE);
// 设置编码当文件中存在中文且上传后文件乱码时可使用此配置项
client.setControlEncoding(encoding);
client.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
List<FTPFile> ftpFiles = Arrays.asList(client.listFiles());
if (CollectionUtils.isNotEmpty(ftpFiles)){
for (FTPFile ftpFile:ftpFiles) {
if (ftpFile.getName().equals(fileName)){
in = client.retrieveFileStream(new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
}
return false;
});
for(FTPFile file : ftpFiles){
InputStream inputStream = null;
try{
inputStream = this.client.retrieveFileStream(new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName);
}catch (Exception e){
if(null != inputStream){
inputStream.close();
}
}
//重置响应信息
response.reset();
//设置响应类型
response.setContentType("application/download");
//解决中文不能生成文件
response.setHeader("Content-Disposition", "attachment; fileName=" + URLEncoder.encode(fileName,"UTF-8"));
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
//获取输出流
out = response.getOutputStream();
//声明一个长度参数
int len;
//声明字节数组
byte[] bytes = new byte[1024];
//判断如果输入流的字节长度不等于-1进行字节数组内容的读取
while ((len = in.read(bytes)) != -1) {
out.write(bytes, 0, len);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
out.flush();
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
public interface GardsAnalysesMapper extends BaseMapper<GardsAnalyses> {
}

View File

@ -0,0 +1,7 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
public interface GardsCalibrationMapper extends BaseMapper<GardsCalibration> {
}

View File

@ -0,0 +1,8 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
public interface GardsCalibrationPairsMapper extends BaseMapper<GardsCalibrationPairs> {
}

View File

@ -1,8 +1,31 @@
package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.base.entity.original.GardsSampleData;
public interface GardsSampleDataMapper extends BaseMapper<GardsSampleData> {
@Select(value = "select " +
"gsd.SAMPLE_ID,gsd.input_file_name " +
"from GARDS_SAMPLE_AUX gsa inner join GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " +
"where gsa.measurement_id = #{measurementId} and gsd.data_type=#{dataType}")
public GardsSampleData getSampleInputFileName(@Param("measurementId") String measurementId,@Param("dataType") String dataType);
@Select(value = "select " +
"gsd.SAMPLE_ID,gsd.input_file_name " +
"from GARDS_SAMPLE_AUX gsa inner join GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " +
"where gsa.bkgd_measurement_id = #{bkgdMeasurementId} and gsd.data_type=#{dataType}")
public GardsSampleData getDetInputFileName(@Param("bkgdMeasurementId") String bkgdMeasurementId,@Param("dataType") String dataType);
@Select(value = "select " +
"gsd.SAMPLE_ID,gsd.input_file_name " +
"from GARDS_SAMPLE_AUX gsa inner join GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " +
"where gsa.gas_bkgd_measurement_id = #{gasMeasurementId} and gsd.data_type=#{dataType}")
public GardsSampleData getGasInputFileName(@Param("gasMeasurementId") String gasMeasurementId,@Param("dataType") String dataType);
@Update(value = "UPDATE ORIGINAL.GARDS_SAMPLE_DATA SET STATUS=#{status} WHERE INPUT_FILE_NAME=#{inputFileName}")
public int updateStatus(@Param("status") String status,@Param("inputFileName") String inputFileName);
}

View File

@ -0,0 +1,13 @@
package org.jeecg.modules.service;
public interface BlockConstant {
public final static String PHD = "PHD";
public final static String SYSTEMTYPE_B = "B";
public final static String ENERGY_CAL = "energy";
public final static String RESOLUTION_CAL = "Resolution";
public final static String SYSTEMTYPE_G = "G";
public final static String EFFICIENCY_CAL ="efficiency";
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
/**
* 存储谱数据分析的基本信息
*/
public interface GardsAnalysesService extends IService<GardsAnalyses> {
/**
* 存储谱数据分析的基本信息
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
*/
public void create(BgAnalyseResult analyseResult,Integer sampleId);
}

View File

@ -0,0 +1,33 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
*/
public interface GardsCalibrationPairsService extends IService<GardsCalibrationPairs> {
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
* B_Energy能道存储
* 不提交事务由调用方手动统一提交事务
* @param sampleId
* @param anayId
* @param struct
*/
public void createB_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct);
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
* G_Energy能道存储
* 不提交事务由调用方手动统一提交事务
* @param sampleId
* @param anayId
* @param struct
*/
public void createG_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct);
}

View File

@ -0,0 +1,12 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
*/
public interface GardsCalibrationService extends IService<GardsCalibration> {
}

View File

@ -11,4 +11,35 @@ public interface GardsSampleDataService extends IService<GardsSampleData> {
* @return
*/
public boolean fileExist(String inputFileName);
/**
* 获取Sample谱文件保存路径
* @param measurementId
* @param dataType
* @return
*/
public GardsSampleData getSampleInputFileName(String measurementId,String dataType);
/**
* 获取Det谱文件保存路径
* @param bkgdMeasurementId
* @param dataType
* @return
*/
public GardsSampleData getDetInputFileName(String bkgdMeasurementId,String dataType);
/**
* 获取Gas谱文件保存路径
* @param gasMeasurementId
* @param dataType
* @return
*/
public GardsSampleData getGasInputFileName(String gasMeasurementId,String dataType);
/**
* 修改能谱处理状态
* @param status
* @param inputFileName
*/
public void updateStatus(String status,String inputFileName);
}

View File

@ -0,0 +1,41 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.base.enums.AnalysesType;
import org.jeecg.modules.mapper.GardsAnalysesMapper;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.service.GardsAnalysesService;
import org.springframework.stereotype.Service;
/**
* 存储谱数据分析的基本信息
*/
@Service
public class GardsAnalysesServiceImpl extends ServiceImpl<GardsAnalysesMapper, GardsAnalyses> implements GardsAnalysesService {
/**
* 存储谱数据分析的基本信息
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
*/
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId) {
GardsAnalyses analyses = new GardsAnalyses();
analyses.setSampleId(sampleId);
analyses.setAnalysisBegin(null);//分析开始时间java控制
analyses.setAnalysisEnd(null);//分析结束时间java控制
analyses.setType(AnalysesType.AUTO.getValue());//类型java控制
analyses.setSoftware(null);//使用的软件名称,配置文件配置
analyses.setSwVersion(null);//软件版本号配置文件配置
analyses.setAnalyst(null);//分析员名称配置文件配置
analyses.setCategory(1);//按C++代码写死的1该字段是分级结果张博士还没有想好数据要不要分级1,2,3,4
analyses.setComments("test");//按C++代码写死的test
analyses.setUsedgasphd(null);//gas谱的phd文件ftp路径
analyses.setUseddetphd(null);//det谱的phd文件ftp路径
analyses.setUsedgasphdId(null);//gas谱的sampleId
analyses.setUseddetphdId(null);//det谱的sampleId
analyses.setLogPath(null);//解析过程日志ftp路径
analyses.setReportPath(null);//报告ftp路径
}
}

View File

@ -0,0 +1,88 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.jeecg.modules.base.entity.original.GardsCalibrationPairsOrig;
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
import org.jeecg.modules.mapper.GardsCalibrationPairsMapper;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.BlockConstant;
import org.jeecg.modules.service.GardsCalibrationPairsService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
*/
@Service
public class GardsCalibrationPairsServiceImpl extends ServiceImpl<GardsCalibrationPairsMapper, GardsCalibrationPairs> implements GardsCalibrationPairsService, BlockConstant {
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
* B_Energy能道存储
* 不提交事务由调用方手动统一提交事务
* @param sampleId
* @param anayId
* @param struct
*/
@Override
public void createB_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct) {
if(struct.b_record_count > 0){
List<GardsCalibrationPairs> list = Lists.newArrayList();
for (int i=0;i<struct.b_record_count;i++){
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
calibrationPairs.setSampleId(sampleId);
calibrationPairs.setIdAnalysis(anayId);
calibrationPairs.setSampleType(SYSTEMTYPE_B);
calibrationPairs.setCaltype(ENERGY_CAL);
calibrationPairs.setInput(PHD);
calibrationPairs.setIdCalPoint(i);
calibrationPairs.setXValue(struct.b_channel.get(i));
calibrationPairs.setYValue(struct.b_electron_energy.get(i));
calibrationPairs.setDecayMode(struct.b_decay_mode.get(i));
calibrationPairs.setUncYValue(struct.b_uncertainty.get(i));
calibrationPairs.setModdate(new Date());
list.add(calibrationPairs);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
/**
* 存储数据分析过程中能量分辨率和效率刻度实际使用的刻度点数据
* G_Energy能道存储
* 不提交事务由调用方手动统一提交事务
*
* @param sampleId
* @param anayId
* @param struct
*/
@Override
public void createG_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct) {
if(struct.g_e_record_count > 0){
List<GardsCalibrationPairs> list = Lists.newArrayList();
for (int i=0;i<struct.g_e_record_count;i++){
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
calibrationPairs.setSampleId(sampleId);
calibrationPairs.setSampleType(SYSTEMTYPE_G);
calibrationPairs.setCaltype(EFFICIENCY_CAL);
calibrationPairs.setInput(PHD);
calibrationPairs.setIdCalPoint(i);
calibrationPairs.setXValue(struct.g_e_energy.get(i));
calibrationPairs.setYValue(struct.g_e_efficiency.get(i));
calibrationPairs.setUncYValue(struct.g_e_uncertainty.get(i));
list.add(calibrationPairs);
}
if(CollectionUtils.isNotEmpty(list)){
this.saveBatch(list);
}
}
}
}

View File

@ -1,14 +1,16 @@
package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsSampleDataMapper;
import org.jeecg.modules.service.GardsSampleDataService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
@DS("ora")
@Service
public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMapper, GardsSampleData> implements GardsSampleDataService {
@ -26,4 +28,52 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
final GardsSampleData sampleData = this.getOne(queryWrapper);
return Objects.nonNull(sampleData);
}
/**
* 获取Sample谱文件保存路径
*
* @param measurementId
* @param dataType
* @return
*/
@Override
public GardsSampleData getSampleInputFileName(String measurementId, String dataType) {
return this.baseMapper.getSampleInputFileName(measurementId, dataType);
}
/**
* 获取Det谱文件保存路径
*
* @param bkgdMeasurementId
* @param dataType
* @return
*/
@Override
public GardsSampleData getDetInputFileName(String bkgdMeasurementId, String dataType) {
return this.baseMapper.getDetInputFileName(bkgdMeasurementId,dataType);
}
/**
* 获取Gas谱文件保存路径
*
* @param gasMeasurementId
* @param dataType
* @return
*/
@Override
public GardsSampleData getGasInputFileName(String gasMeasurementId, String dataType) {
return this.baseMapper.getGasInputFileName(gasMeasurementId,dataType);
}
/**
* 修改能谱处理状态
*
* @param status
* @param inputFileName
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void updateStatus(String status, String inputFileName) {
this.baseMapper.updateStatus(status,inputFileName);
}
}