fix:1.完成B分析功能数据存储功能

This commit is contained in:
panbaolin 2023-09-07 09:32:26 +08:00
parent 61f328d577
commit 919bae79f7
37 changed files with 1314 additions and 241 deletions

View File

@ -212,9 +212,8 @@ public class EmailServiceManager {
public void getMailContent(@NotNull Part part, StringBuilder content) throws MessagingException, IOException { public void getMailContent(@NotNull Part part, StringBuilder content) throws MessagingException, IOException {
if(part.isMimeType(MailContentType.PLAIN.getContentType())){ if(part.isMimeType(MailContentType.PLAIN.getContentType())){
content.append(part.getContent()); content.append(part.getContent());
}else if(part.isMimeType(MailContentType.HTML.getContentType())){
content.append(part.getContent());
}else if(part.isMimeType("multipart/*")){ }else if(part.isMimeType("multipart/*")){
System.out.println(part.getContentType());
Multipart multipart = (Multipart) part.getContent(); Multipart multipart = (Multipart) part.getContent();
for(int i=0;i<multipart.getCount();i++) { for(int i=0;i<multipart.getCount();i++) {
final Part bodyPart = multipart.getBodyPart(i); final Part bodyPart = multipart.getBodyPart(i);

View File

@ -0,0 +1,24 @@
package org.jeecg.common.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "software")
public class SoftwareProperties {
/**
* 软件名称
*/
private String swName;
/**
* 软件版本
*/
private String swVersion;
/**
* 分析员
*/
private String analyst;
}

View File

@ -31,6 +31,11 @@ public class SpectrumPathProperties implements Serializable {
*/ */
private String logPath; private String logPath;
/**
* 报告文件存储路径
*/
private String arrPath;
/** /**
* 用户上传文件路径 * 用户上传文件路径
*/ */

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.exception;
/**
* B谱分析异常
*/
public class BAnalyseException extends Exception{
/**
* Constructs a new exception with the specified detail message. The
* cause is not initialized, and may subsequently be initialized by
* a call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public BAnalyseException(String message) {
super(message);
}
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.exception;
/**
* PHD文件读取异常
*/
public class PHD_ReadException extends Exception{
/**
* Constructs a new exception with the specified detail message. The
* cause is not initialized, and may subsequently be initialized by
* a call to {@link #initCause}.
*
* @param message the detail message. The detail message is saved for
* later retrieval by the {@link #getMessage()} method.
*/
public PHD_ReadException(String message) {
super(message);
}
}

View File

@ -2,14 +2,14 @@ package org.jeecg.modules.ftp;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.ftp.*; import org.apache.commons.net.ftp.*;
import org.jeecg.common.constant.StringConstant;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Objects;
@Slf4j @Slf4j
public class FTPUtils { public class FTPUtils {
@ -32,6 +32,11 @@ public class FTPUtils {
client.login(userName, password); client.login(userName, password);
// 切换为本地被动模式可以解决FTP上传后文件为空的问题但需要服务器将FTP服务添加至防火墙白名单 // 切换为本地被动模式可以解决FTP上传后文件为空的问题但需要服务器将FTP服务添加至防火墙白名单
client.enterLocalPassiveMode(); client.enterLocalPassiveMode();
//设置文件client参数
this.client.setFileType(FTPClient.BINARY_FILE_TYPE);
this.client.setControlEncoding(this.encoding);
this.client.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//判断是否连接成功 //判断是否连接成功
int reply = client.getReplyCode(); int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) { if (!FTPReply.isPositiveCompletion(reply)) {
@ -50,38 +55,36 @@ public class FTPUtils {
* @param localPath * @param localPath
* @throws IOException * @throws IOException
*/ */
public void downloadFTPFile(String ftpFilePath,String fileName,String localPath) throws IOException { public boolean 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); this.checkDirectory(ftpFilePath);
System.out.println(this.client.printWorkingDirectory()); InputStream inputStream = null;
String absolutePath = this.ftpRootPath+StringConstant.SLASH+ftpFilePath; try{
final FTPFile[] ftpFiles = this.client.listFiles(null, file -> { final FTPFile[] ftpFiles = this.client.listFiles(fileName);
if (fileName.equals(file.getName())) { if(ArrayUtils.isNotEmpty(ftpFiles)){
return true; inputStream = this.client.retrieveFileStream(fileName);
} if(Objects.nonNull(inputStream)){
return false; FileUtil.writeFromStream(inputStream,localPath+File.separator+fileName);
}); return true;
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();
} }
}else {
log.warn("{}不存在",fileName);
}
}catch (Exception e){
e.printStackTrace();
return false;
}finally {
if(Objects.nonNull(inputStream)){
inputStream.close();
this.client.completePendingCommand();
} }
} }
return false;
} }
/** /**
* 检查目录是否存在不存在则创建支持递归创建 * 检查目录是否存在不存在则创建支持递归创建
* @param path 目录路径 * @param path 目录路径
* @return 返回值true/false * @return 返回值true/false
* @throws IOException
*/ */
private boolean checkDirectory(String path){ private boolean checkDirectory(String path){
try{ try{
@ -114,6 +117,12 @@ public class FTPUtils {
return true; return true;
} }
public static void main(String[] args) throws IOException {
FTPUtils ftp = new FTPUtils("8.141.87.165",21,"rmsops","cnndc010","utf-8","/");
// ftp.saveFile("log/Soh/2023/08","GBX68_RMSSOH-20230731_152800.0.log",new ByteArrayInputStream((System.lineSeparator()+"ssssssssssss").getBytes(StandardCharsets.UTF_8)));
ftp.downloadFTPFile("/savefile/Spectrum/Xenon/Sauna/Gasbkphd/2023/09","AUX09_003-20151224_0655_G_FULL_40182.873.PHD","E:\\file");
}
/** /**
* 写入文件若文件或文件目录不存在则自行创建 * 写入文件若文件或文件目录不存在则自行创建
* @param filePath 文件路径 * @param filePath 文件路径
@ -125,9 +134,12 @@ public class FTPUtils {
try{ try{
final boolean flag = this.checkDirectory(filePath); final boolean flag = this.checkDirectory(filePath);
if(flag){ if(flag){
client.setFileType(FTP.BINARY_FILE_TYPE); final FTPFile[] ftpFiles = this.client.listFiles(fileName);
String encodedName = new String(fileName.getBytes(StandardCharsets.UTF_8),StandardCharsets.ISO_8859_1); if(ArrayUtils.isEmpty(ftpFiles)){
return client.storeFile(encodedName, inputStream); return client.storeFile(fileName, inputStream);
}else{
return client.appendFile(fileName,inputStream);
}
} }
}catch (IOException e){ }catch (IOException e){
log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage()); log.error("{}文件创建失败,原因为:{}",filePath+"/"+fileName,e.getMessage());
@ -201,6 +213,7 @@ public class FTPUtils {
public void close(){ public void close(){
try{ try{
if (client != null){ if (client != null){
client.logout();
client.disconnect(); client.disconnect();
} }
}catch (IOException e){ }catch (IOException e){

View File

@ -1,7 +1,12 @@
package org.jeecg.modules.mapper; package org.jeecg.modules.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration; import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
public interface GardsCalibrationMapper extends BaseMapper<GardsCalibration> { public interface GardsCalibrationMapper extends BaseMapper<GardsCalibration> {
@InterceptorIgnore(tenantLine = "true")
public int create(@Param("calibration") GardsCalibration calibration);
} }

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.GardsRoiChannels;
public interface GardsRoiChannelsMapper extends BaseMapper<GardsRoiChannels> {
}

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.GardsRoiResults;
public interface GardsRoiResultsMapper extends BaseMapper<GardsRoiResults> {
}

View File

@ -9,22 +9,10 @@ import org.jeecg.modules.base.entity.original.GardsSampleData;
public interface GardsSampleDataMapper extends BaseMapper<GardsSampleData> { public interface GardsSampleDataMapper extends BaseMapper<GardsSampleData> {
@Select(value = "select " + @Select(value = "select " +
"gsd.SAMPLE_ID,gsd.input_file_name " + "gsd.SAMPLE_ID as sampleId,gsd.input_file_name as inputFileName " +
"from GARDS_SAMPLE_AUX gsa inner join GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " + "from ORIGINAL.GARDS_SAMPLE_AUX gsa inner join ORIGINAL.GARDS_SAMPLE_DATA gsd on gsa.sample_id = gsd.sample_id " +
"where gsa.measurement_id = #{measurementId} and gsd.data_type=#{dataType}") "where gsa.measurement_id = #{measurementId} and gsd.data_type=#{dataType}")
public GardsSampleData getSampleInputFileName(@Param("measurementId") String measurementId,@Param("dataType") String dataType); public GardsSampleData getSampleIdAndInputFileName(@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}") @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); public int updateStatus(@Param("status") String status,@Param("inputFileName") String inputFileName);

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.GardsXeResults;
public interface GardsXeResultsMapper extends BaseMapper<GardsXeResults> {
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.mapper.GardsCalibrationMapper">
<insert id="create" parameterType="org.jeecg.modules.base.entity.rnauto.GardsCalibration">
insert into RNAUTO.GARDS_CALIBRATION(
SAMPLE_ID,
IDANALYSIS,
SAMPLE_TYPE,
CALTYPE,
FUNCTION,
FUNCTIONDEF,
STARTOFRANGE,
ENDOFRANGE,
coeff1,
coeff2,
coeff3,
moddate)
values(
#{calibration.sampleId},
#{calibration.idAnalysis},
#{calibration.sampleType},
#{calibration.calType},
#{calibration.function},
#{calibration.functionDef},
#{calibration.startOfRange},
#{calibration.endOfRange},
#{calibration.coeff1},
#{calibration.coeff2},
#{calibration.coeff3},
#{calibration.moddate})
</insert>
</mapper>

View File

@ -3,29 +3,92 @@ package org.jeecg.modules.native_jni.struct;
import java.util.List; import java.util.List;
public class BgAnalyseResult { public class BgAnalyseResult {
/************************** BgMDCPara **************************/ /************************** GARDS_XE_RESULTS START**************************/
/** MDC XE135 */ /************************** XE_131m **************************/
public double MDC_Xe135;
/** MDC XE131m */
public double MDC_Xe131m;
/** MDC XE133m*/
public double MDC_Xe133m;
/** MDC XE133 */
public double MDC_Xe133;
public List<Double> MDC;
public List<Double> MDC_CTS;
/************************** BgXeConUncer **************************/
/** 135不浓度 */
public double Xe135_con;
/** 135不确定度 */
public double Xe135_uncer;
public double Xe131m_con; public double Xe131m_con;
public double Xe131m_uncer; public double Xe131m_uncer;
public double Xe133m_con; public double MDC_Xe131m;
public double Xe133m_uncer; public double LC_Xe131m;
public int XE_131m_NID_FLAG;
/************************** XE_133 **************************/
public double Xe133_con; public double Xe133_con;
public double Xe133_uncer; public double Xe133_uncer;
public double MDC_Xe133;
public double LC_Xe133;
public int XE_133_NID_FLAG;
/************************** XE_133m **************************/
public double Xe133m_con;
public double Xe133m_uncer;
public double MDC_Xe133m;
public double LC_Xe133m;
public int XE_133m_NID_FLAG;
/************************** XE_135 **************************/
public double Xe135_con;
public double Xe135_uncer;
public double MDC_Xe135;
public double LC_Xe135;
public int XE_135_NID_FLAG;
/************************** GARDS_XE_RESULTS end **************************/
/************************** GARDS_ROI_RESULTS START**************************/
public List<Integer> ROI;
public List<Double> LC;
public List<Double> s_roi_cts;
public List<Double> g_roi_cts;
public List<Double> d_roi_cts;
public List<Double> s_deduct_d_cts;
public List<Double> g_deduct_d_cts;
public List<Double> ROI_net_coutns;
public List<Double> ROI_net_coutns_err;
public List<Double> ROI_con_uncer;
public List<Double> ROI_con_uncer_err;
public List<Double> MDC;
public List<Integer> dNidFlag;
/************************** GARDS_ROI_RESULTS end **************************/
/************************** GARDS_CALIBRATION START**************************/
public List<Double> s_b_fitting_e_c;
public int s_b_fitting_type;
public String s_b_fitting_type_def;
public List<Double> s_g_fitting_e_c;
public int s_g_fitting_type;
public String s_g_fitting_type_def;
public List<Double> g_b_fitting_e_c;
public int g_b_fitting_type;
public String g_b_fitting_type_def;
public List<Double> g_g_fitting_e_c;
public int g_g_fitting_type;
public String g_g_fitting_type_def;
public List<Double> d_b_fitting_e_c;
public int d_b_fitting_type;
public String d_b_fitting_type_def;
public List<Double> d_g_fitting_e_c;
public int d_g_fitting_type;
public String d_g_fitting_type_def;
/************************** GARDS_CALIBRATION end **************************/
/************************** GARDS_ROI_CHANNELS START**************************/
public List<Integer> S_ROI;
public List<Integer> S_ROI_B_Boundary_start;
public List<Integer> S_ROI_B_Boundary_stop;
public List<Integer> S_ROI_G_Boundary_start;
public List<Integer> S_ROI_G_Boundary_stop;
public List<Integer> G_ROI;
public List<Integer> G_ROI_B_Boundary_start;
public List<Integer> G_ROI_B_Boundary_stop;
public List<Integer> G_ROI_G_Boundary_start;
public List<Integer> G_ROI_G_Boundary_stop;
public List<Integer> D_ROI;
public List<Integer> D_ROI_B_Boundary_start;
public List<Integer> D_ROI_B_Boundary_stop;
public List<Integer> D_ROI_G_Boundary_start;
public List<Integer> D_ROI_G_Boundary_stop;
/************************** GARDS_ROI_CHANNELS end **************************/
/** /**
* 分析结果标记true成功false失败 * 分析结果标记true成功false失败
@ -36,23 +99,76 @@ public class BgAnalyseResult {
*/ */
public String error_log; public String error_log;
@Override @Override
public String toString() { public String toString() {
return "BgAnalyseResult{" + return "BgAnalyseResult{" +
"MDC_Xe135=" + MDC_Xe135 + "Xe131m_con=" + Xe131m_con +
", MDC_Xe131m=" + MDC_Xe131m +
", MDC_Xe133m=" + MDC_Xe133m +
", MDC_Xe133=" + MDC_Xe133 +
", MDC=" + MDC +
", MDC_CTS=" + MDC_CTS +
", Xe135_con=" + Xe135_con +
", Xe135_uncer=" + Xe135_uncer +
", Xe131m_con=" + Xe131m_con +
", Xe131m_uncer=" + Xe131m_uncer + ", Xe131m_uncer=" + Xe131m_uncer +
", Xe133m_con=" + Xe133m_con + ", MDC_Xe131m=" + MDC_Xe131m +
", Xe133m_uncer=" + Xe133m_uncer + ", LC_Xe131m=" + LC_Xe131m +
", XE_131m_NID_FLAG=" + XE_131m_NID_FLAG +
", Xe133_con=" + Xe133_con + ", Xe133_con=" + Xe133_con +
", Xe133_uncer=" + Xe133_uncer + ", Xe133_uncer=" + Xe133_uncer +
", MDC_Xe133=" + MDC_Xe133 +
", LC_Xe133=" + LC_Xe133 +
", XE_133_NID_FLAG=" + XE_133_NID_FLAG +
", Xe133m_con=" + Xe133m_con +
", Xe133m_uncer=" + Xe133m_uncer +
", MDC_Xe133m=" + MDC_Xe133m +
", LC_Xe133m=" + LC_Xe133m +
", XE_133m_NID_FLAG=" + XE_133m_NID_FLAG +
", Xe135_con=" + Xe135_con +
", Xe135_uncer=" + Xe135_uncer +
", MDC_Xe135=" + MDC_Xe135 +
", LC_Xe135=" + LC_Xe135 +
", XE_135_NID_FLAG=" + XE_135_NID_FLAG +
", ROI=" + ROI +
", LC=" + LC +
", s_roi_cts=" + s_roi_cts +
", g_roi_cts=" + g_roi_cts +
", d_roi_cts=" + d_roi_cts +
", s_deduct_d_cts=" + s_deduct_d_cts +
", g_deduct_d_cts=" + g_deduct_d_cts +
", ROI_net_coutns=" + ROI_net_coutns +
", ROI_net_coutns_err=" + ROI_net_coutns_err +
", ROI_con_uncer=" + ROI_con_uncer +
", ROI_con_uncer_err=" + ROI_con_uncer_err +
", MDC=" + MDC +
", dNidFlag=" + dNidFlag +
", s_b_fitting_e_c=" + s_b_fitting_e_c +
", s_b_fitting_type=" + s_b_fitting_type +
", s_b_fitting_type_def='" + s_b_fitting_type_def + '\'' +
", s_g_fitting_e_c=" + s_g_fitting_e_c +
", s_g_fitting_type=" + s_g_fitting_type +
", s_g_fitting_type_def='" + s_g_fitting_type_def + '\'' +
", g_b_fitting_e_c=" + g_b_fitting_e_c +
", g_b_fitting_type=" + g_b_fitting_type +
", g_b_fitting_type_def='" + g_b_fitting_type_def + '\'' +
", g_g_fitting_e_c=" + g_g_fitting_e_c +
", g_g_fitting_type=" + g_g_fitting_type +
", g_g_fitting_type_def='" + g_g_fitting_type_def + '\'' +
", d_b_fitting_e_c=" + d_b_fitting_e_c +
", d_b_fitting_type=" + d_b_fitting_type +
", d_b_fitting_type_def='" + d_b_fitting_type_def + '\'' +
", d_g_fitting_e_c=" + d_g_fitting_e_c +
", d_g_fitting_type=" + d_g_fitting_type +
", d_g_fitting_type_def='" + d_g_fitting_type_def + '\'' +
", S_ROI=" + S_ROI +
", S_ROI_B_Boundary_start=" + S_ROI_B_Boundary_start +
", S_ROI_B_Boundary_stop=" + S_ROI_B_Boundary_stop +
", S_ROI_G_Boundary_start=" + S_ROI_G_Boundary_start +
", S_ROI_G_Boundary_stop=" + S_ROI_G_Boundary_stop +
", G_ROI=" + G_ROI +
", G_ROI_B_Boundary_start=" + G_ROI_B_Boundary_start +
", G_ROI_B_Boundary_stop=" + G_ROI_B_Boundary_stop +
", G_ROI_G_Boundary_start=" + G_ROI_G_Boundary_start +
", G_ROI_G_Boundary_stop=" + G_ROI_G_Boundary_stop +
", D_ROI=" + D_ROI +
", D_ROI_B_Boundary_start=" + D_ROI_B_Boundary_start +
", D_ROI_B_Boundary_stop=" + D_ROI_B_Boundary_stop +
", D_ROI_G_Boundary_start=" + D_ROI_G_Boundary_start +
", D_ROI_G_Boundary_stop=" + D_ROI_G_Boundary_stop +
", analyse_flag=" + analyse_flag + ", analyse_flag=" + analyse_flag +
", error_log='" + error_log + '\'' + ", error_log='" + error_log + '\'' +
'}'; '}';

View File

@ -9,5 +9,10 @@ public interface BlockConstant {
public final static String SYSTEMTYPE_G = "G"; public final static String SYSTEMTYPE_G = "G";
public final static String EFFICIENCY_CAL ="efficiency"; public final static String EFFICIENCY_CAL ="efficiency";
public final static String XE_131m = "Xe131m";
public final static String XE_133m = "Xe133m";
public final static String XE_133 = "Xe133";
public final static String XE_135 = "Xe135";
} }

View File

@ -1,9 +1,12 @@
package org.jeecg.modules.service; package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses; import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import java.util.Date;
/** /**
* 存储谱数据分析的基本信息 * 存储谱数据分析的基本信息
*/ */
@ -12,10 +15,16 @@ public interface GardsAnalysesService extends IService<GardsAnalyses> {
/** /**
* 存储谱数据分析的基本信息 * 存储谱数据分析的基本信息
* 不提交事务由调用方手动统一提交事务 * 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId * @param sampleId
* @param detSampleData
* @param gasSampleData
* @param beginDate 分析开始时间
* @param endDate 分析结束时间
* @param logPath
* @param reportPath
* @return
*/ */
public void create(BgAnalyseResult analyseResult,Integer sampleId); public GardsAnalyses create(Integer sampleId, GardsSampleData detSampleData, GardsSampleData gasSampleData, Date beginDate, Date endDate, String logPath, String reportPath);
Integer getIdAnalysis(Integer sampleId); Integer getIdAnalysis(Integer sampleId);
} }

View File

@ -2,11 +2,20 @@ package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsCalibration; import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
/** /**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果 * 存储数据分析过程中能量分辨率和效率刻度的拟合结果
*/ */
public interface GardsCalibrationService extends IService<GardsCalibration> { public interface GardsCalibrationService extends IService<GardsCalibration> {
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param anayId
*/
public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId);
} }

View File

@ -0,0 +1,20 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsRoiChannels;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
/**
* 存储β-γ符合谱中感兴趣区道址边界数据
*/
public interface GardsRoiChannelsService extends IService<GardsRoiChannels> {
/**
* 存储β-γ符合谱中感兴趣区道址边界数据
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis);
}

View File

@ -0,0 +1,20 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsRoiResults;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
/**
* 存储β-γ符合谱中分析过程中的有关感兴趣区ROI计算的中间结果
*/
public interface GardsRoiResultsService extends IService<GardsRoiResults> {
/**
* 存储β-γ符合谱中分析过程中的有关感兴趣区ROI计算的中间结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis);
}

View File

@ -13,28 +13,12 @@ public interface GardsSampleDataService extends IService<GardsSampleData> {
public boolean fileExist(String inputFileName); public boolean fileExist(String inputFileName);
/** /**
* 获取Sample谱文件保存路径 * 获取谱文件保存路径
* @param measurementId * @param measurementId
* @param dataType * @param dataType
* @return * @return
*/ */
public GardsSampleData getSampleInputFileName(String measurementId,String dataType); public GardsSampleData getSampleIdAndInputFileName(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);
/** /**
* 修改能谱处理状态 * 修改能谱处理状态

View File

@ -0,0 +1,20 @@
package org.jeecg.modules.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
/**
* 存储β-γ符合谱最终分析结果
*/
public interface GardsXeResultsService extends IService<GardsXeResults> {
/**
* 存储β-γ符合谱最终分析结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer idAnalysis);
}

View File

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

View File

@ -70,6 +70,7 @@ public class GardsCalibrationPairsServiceImpl extends ServiceImpl<GardsCalibrati
for (int i=0;i<struct.g_e_record_count;i++){ for (int i=0;i<struct.g_e_record_count;i++){
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs(); GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
calibrationPairs.setSampleId(sampleId); calibrationPairs.setSampleId(sampleId);
calibrationPairs.setIdAnalysis(anayId);
calibrationPairs.setSampleType(SYSTEMTYPE_G); calibrationPairs.setSampleType(SYSTEMTYPE_G);
calibrationPairs.setCaltype(EFFICIENCY_CAL); calibrationPairs.setCaltype(EFFICIENCY_CAL);
calibrationPairs.setInput(PHD); calibrationPairs.setInput(PHD);

View File

@ -6,12 +6,203 @@ import org.jeecg.modules.base.entity.rnauto.GardsCalibration;
import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs; import org.jeecg.modules.base.entity.rnauto.GardsCalibrationPairs;
import org.jeecg.modules.mapper.GardsCalibrationMapper; import org.jeecg.modules.mapper.GardsCalibrationMapper;
import org.jeecg.modules.mapper.GardsCalibrationPairsMapper; import org.jeecg.modules.mapper.GardsCalibrationPairsMapper;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.service.BlockConstant;
import org.jeecg.modules.service.GardsCalibrationService; import org.jeecg.modules.service.GardsCalibrationService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
@Service @Service
@DS("ora") @DS("ora")
public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMapper, GardsCalibration> implements GardsCalibrationService { public class GardsCalibrationServiceImpl extends ServiceImpl<GardsCalibrationMapper, GardsCalibration> implements GardsCalibrationService, BlockConstant {
private final static int START_RANGE = 0;
private final static int END_RANGE = 1;
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param anayId
*/
@Override
public void create(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId){
this.saveSampleB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveSampleG_EnergyRecord(analyseResult,sampleId,anayId);
this.saveGasB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveGasG_EnergyRecord(analyseResult,sampleId,anayId);
this.saveDetB_EnergyRecord(analyseResult,sampleId,anayId);
this.saveDetG_EnergyRecord(analyseResult,sampleId,anayId);
}
/**
* 保存 B_Energy 块信息
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveSampleB_EnergyRecord(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_B);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.s_b_fitting_type);
calibration.setFunctionDef(analyseResult.s_b_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.s_b_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.s_b_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.s_b_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* G_Energy能道存储
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveSampleG_EnergyRecord(BgAnalyseResult analyseResult,Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_G);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.s_g_fitting_type);
calibration.setFunctionDef(analyseResult.s_g_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.s_g_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.s_g_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.s_g_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* B_Energy
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveGasB_EnergyRecord(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_B);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.g_b_fitting_type);
calibration.setFunctionDef(analyseResult.g_b_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.g_b_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.g_b_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.g_b_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* G_Energy能道存储
*
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveGasG_EnergyRecord(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_G);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.g_g_fitting_type);
calibration.setFunctionDef(analyseResult.g_g_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.g_g_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.g_g_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.g_g_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* B_Energy
*
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveDetB_EnergyRecord(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_B);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.d_b_fitting_type);
calibration.setFunctionDef(analyseResult.d_b_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.d_b_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.d_b_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.d_b_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
/**
* 存储数据分析过程中能量分辨率和效率刻度的拟合结果
* 不提交事务由调用方手动统一提交事务
* G_Energy能道存储
*
* @param analyseResult
* @param sampleId
* @param anayId
*/
private void saveDetG_EnergyRecord(BgAnalyseResult analyseResult, Integer sampleId, Integer anayId) {
GardsCalibration calibration = new GardsCalibration();
calibration.setSampleId(sampleId);
calibration.setIdAnalysis(anayId);
calibration.setSampleType(SYSTEMTYPE_G);
calibration.setCalType(ENERGY_CAL);
calibration.setFunction(analyseResult.d_g_fitting_type);
calibration.setFunctionDef(analyseResult.d_g_fitting_type_def);
calibration.setStartOfRange(START_RANGE);
calibration.setEndOfRange(END_RANGE);
calibration.setCoeff1(analyseResult.d_g_fitting_e_c.get(0));
calibration.setCoeff2(analyseResult.d_g_fitting_e_c.get(1));
calibration.setCoeff3(analyseResult.d_g_fitting_e_c.get(2));
calibration.setModdate(new Date());
this.baseMapper.create(calibration);
}
// public static void main(String[] args) {
// System.loadLibrary("ReadPHDFile");
// String sampleTempFilePath = "E:\\file\\AUX09_003-20151224_1855_S_FULL_40184.505.PHD";
// String gasTempFilePath = "E:\\file\\AUX09_003-20151224_0655_G_FULL_40182.873.PHD";
// String detTempFilePath = "E:\\file\\AUX09_003-20150527_0425_D_FULL_259449.672.PHD";
// BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(sampleTempFilePath,gasTempFilePath,detTempFilePath);
// System.out.println(analyseResult);
// }
} }

View File

@ -0,0 +1,104 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.rnauto.GardsRoiChannels;
import org.jeecg.modules.mapper.GardsRoiChannelsMapper;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.service.GardsRoiChannelsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
* 存储β-γ符合谱中感兴趣区道址边界数据
*/
@Service
public class GardsRoiChannelsServiceImpl extends ServiceImpl<GardsRoiChannelsMapper, GardsRoiChannels> implements GardsRoiChannelsService {
/**
* 存储β-γ符合谱中感兴趣区道址边界数据
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
List<GardsRoiChannels> roiChannelsList = Lists.newArrayList();
this.saveSampleRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList);
this.saveGasRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList);
this.saveDetRoiChannels(analyseResult,sampleId,idAnalysis,roiChannelsList);
if(!CollectionUtils.isEmpty(roiChannelsList)){
this.saveBatch(roiChannelsList);
}
}
/**
* 存储sample谱RoiChannels数据
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
private void saveSampleRoiChannels(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis,List<GardsRoiChannels> roiChannelsList) {
for(int i=0;i<analyseResult.S_ROI.size();i++){
GardsRoiChannels roiChannel = new GardsRoiChannels();
roiChannel.setSampleId(sampleId);
roiChannel.setIdAnalysis(idAnalysis);
roiChannel.setRoi(analyseResult.S_ROI.get(i));
roiChannel.setBChanStart(analyseResult.S_ROI_B_Boundary_start.get(i));
roiChannel.setBChanStop(analyseResult.S_ROI_B_Boundary_stop.get(i));
roiChannel.setGChanStart(analyseResult.S_ROI_G_Boundary_start.get(i));
roiChannel.setGChanStop(analyseResult.S_ROI_G_Boundary_stop.get(i));
roiChannel.setModdate(new Date());
roiChannelsList.add(roiChannel);
}
}
/**
* 存储gas谱RoiChannels数据
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
private void saveGasRoiChannels(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis,List<GardsRoiChannels> roiChannelsList) {
for(int i=0;i<analyseResult.G_ROI.size();i++){
GardsRoiChannels roiChannel = new GardsRoiChannels();
roiChannel.setSampleId(sampleId);
roiChannel.setIdAnalysis(idAnalysis);
roiChannel.setRoi(analyseResult.G_ROI.get(i));
roiChannel.setBChanStart(analyseResult.G_ROI_B_Boundary_start.get(i));
roiChannel.setBChanStop(analyseResult.G_ROI_B_Boundary_stop.get(i));
roiChannel.setGChanStart(analyseResult.G_ROI_G_Boundary_start.get(i));
roiChannel.setGChanStop(analyseResult.G_ROI_G_Boundary_stop.get(i));
roiChannel.setModdate(new Date());
roiChannelsList.add(roiChannel);
}
}
/**
* 存储Det谱RoiChannels数据
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
private void saveDetRoiChannels(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis,List<GardsRoiChannels> roiChannelsList) {
for(int i=0;i<analyseResult.D_ROI.size();i++){
GardsRoiChannels roiChannel = new GardsRoiChannels();
roiChannel.setSampleId(sampleId);
roiChannel.setIdAnalysis(idAnalysis);
roiChannel.setRoi(analyseResult.D_ROI.get(i));
roiChannel.setBChanStart(analyseResult.D_ROI_B_Boundary_start.get(i));
roiChannel.setBChanStop(analyseResult.D_ROI_B_Boundary_stop.get(i));
roiChannel.setGChanStart(analyseResult.D_ROI_G_Boundary_start.get(i));
roiChannel.setGChanStop(analyseResult.S_ROI_G_Boundary_stop.get(i));
roiChannel.setModdate(new Date());
roiChannelsList.add(roiChannel);
}
}
}

View File

@ -0,0 +1,101 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.compress.utils.Lists;
import org.jeecg.modules.base.entity.rnauto.GardsRoiResults;
import org.jeecg.modules.mapper.GardsRoiResultsMapper;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.service.GardsRoiResultsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.awt.geom.Arc2D;
import java.util.Date;
import java.util.List;
/**
* 存储β-γ符合谱中分析过程中的有关感兴趣区ROI计算的中间结果
*/
@Service
public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMapper, GardsRoiResults> implements GardsRoiResultsService {
/**
* 存储β-γ符合谱中分析过程中的有关感兴趣区ROI计算的中间结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
List<GardsRoiResults> list = Lists.newArrayList();
for(int i=0;i<analyseResult.ROI.size();i++){
GardsRoiResults roiResults = new GardsRoiResults();
roiResults.setSampleId(sampleId);
roiResults.setIdAnalysis(idAnalysis);
roiResults.setRoi(analyseResult.ROI.get(i));
roiResults.setSGross(analyseResult.s_roi_cts.get(i));
roiResults.setGGross(analyseResult.g_roi_cts.get(i));
roiResults.setBGross(analyseResult.d_roi_cts.get(i));
roiResults.setSNet(analyseResult.s_deduct_d_cts.get(i));
roiResults.setGNet(analyseResult.g_deduct_d_cts.get(i));
roiResults.setNet(0D);
roiResults.setNetErr(0D);
roiResults.setConc(0D);
roiResults.setConcErr(0D);
roiResults.setLc(0D);
roiResults.setMdc(0D);
roiResults.setNidFlag(0);
roiResults.setModdate(new Date());
list.add(roiResults);
}
//从下班1开始第一条记录NET值固定为0
for(int i=1;i<analyseResult.ROI_net_coutns.size();i++){
list.get(i).setNet(analyseResult.ROI_net_coutns.get(i));
}
//从下班1开始第一条记录NETERR值固定为0
for(int i=1;i<analyseResult.ROI_net_coutns_err.size();i++){
list.get(i).setNetErr(analyseResult.ROI_net_coutns_err.get(i));
}
//从下班1开始第一条记录CONC值固定为0
for(int i=1;i<analyseResult.ROI_con_uncer.size();i++){
list.get(i).setConc(analyseResult.ROI_con_uncer.get(i));
}
//从下班1开始第一条记录CONCERR值固定为0
for(int i=1;i<analyseResult.ROI_con_uncer_err.size();i++){
list.get(i).setConcErr(analyseResult.ROI_con_uncer_err.get(i));
}
//从下班1开始第一条记录LC值固定为0
for(int i=1;i<analyseResult.LC.size();i++){
list.get(i).setLc(analyseResult.LC.get(i));
}
//从下班1开始第一条记录MDC值固定为0
// for(int i=1;i<analyseResult.MDC.size();i++){
// list.get(i).setMdc(0D);
// }
//如果CONC大于MDC则NID_FLAG值为1否则为0
//感兴趣区识别标示1识别到0未识别到
for(int i=0;i<analyseResult.MDC.size();i++){
// if(i < analyseResult.ROI_con_uncer.size()){
// if(analyseResult.ROI_con_uncer.get(i) > analyseResult.MDC.get(i)){
// list.get(i).setNidFlag(1);
// }else {
// list.get(i).setNidFlag(0);
// }
// }
list.get(i).setNidFlag(0);
}
if(!CollectionUtils.isEmpty(list)){
this.saveBatch(list);
}
}
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.mapper.GardsSampleDataMapper; import org.jeecg.modules.mapper.GardsSampleDataMapper;
import org.jeecg.modules.service.GardsSampleDataService; import org.jeecg.modules.service.GardsSampleDataService;
@ -26,43 +27,18 @@ public class GardsSampleDataServiceImpl extends ServiceImpl<GardsSampleDataMappe
queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName); queryWrapper.eq(GardsSampleData::getInputFileName,inputFileName);
queryWrapper.select(GardsSampleData::getSampleId); queryWrapper.select(GardsSampleData::getSampleId);
final GardsSampleData sampleData = this.getOne(queryWrapper); final GardsSampleData sampleData = this.getOne(queryWrapper);
return Objects.nonNull(sampleData); return Objects.nonNull(sampleData) && StringUtils.isNotBlank(sampleData.getInputFileName());
} }
/** /**
* 获取Sample谱文件保存路径 * 获取谱文件保存路径
*
* @param measurementId * @param measurementId
* @param dataType * @param dataType
* @return * @return
*/ */
@Override @Override
public GardsSampleData getSampleInputFileName(String measurementId, String dataType) { public GardsSampleData getSampleIdAndInputFileName(String measurementId, String dataType) {
return this.baseMapper.getSampleInputFileName(measurementId, dataType); return this.baseMapper.getSampleIdAndInputFileName(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);
} }
/** /**

View File

@ -0,0 +1,128 @@
package org.jeecg.modules.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import org.jeecg.modules.base.entity.rnauto.GardsXeResults;
import org.jeecg.modules.mapper.GardsXeResultsMapper;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.service.BlockConstant;
import org.jeecg.modules.service.GardsXeResultsService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
/**
* 存储β-γ符合谱最终分析结果
*/
@Service
public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper, GardsXeResults> implements GardsXeResultsService, BlockConstant {
/**
* 存储β-γ符合谱最终分析结果
* 不提交事务由调用方手动统一提交事务
* @param analyseResult
* @param sampleId
* @param idAnalysis
*/
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
List<GardsXeResults> xeResultsList = Lists.newArrayList();
this.saveXE_131m(analyseResult,sampleId,idAnalysis,XE_131m,xeResultsList);
this.saveXE_133(analyseResult,sampleId,idAnalysis,XE_133,xeResultsList);
this.saveXE_133m(analyseResult,sampleId,idAnalysis,XE_133m,xeResultsList);
this.saveXE_135(analyseResult,sampleId,idAnalysis,XE_135,xeResultsList);
if(!CollectionUtils.isEmpty(xeResultsList)){
this.saveBatch(xeResultsList);
}
}
/**
* 保存XE_131m
* @param analyseResult
* @param sampleId
* @param idAnalysis
* @param nuclideName
*/
private void saveXE_131m(BgAnalyseResult analyseResult,Integer sampleId,Integer idAnalysis,String nuclideName,List<GardsXeResults> xeResultsList){
GardsXeResults xeResults = new GardsXeResults();
xeResults.setSampleId(sampleId);
xeResults.setIdAnalysis(idAnalysis);
xeResults.setNuclideName(nuclideName);
xeResults.setConc(analyseResult.Xe131m_con);
xeResults.setConcErr(analyseResult.Xe131m_uncer);
xeResults.setMdc(analyseResult.MDC_Xe131m);
xeResults.setLc(analyseResult.LC_Xe131m);
xeResults.setNidFlag(analyseResult.XE_131m_NID_FLAG);
xeResults.setModdate(new Date());
xeResultsList.add(xeResults);
}
/**
* 保存XE_133
* @param analyseResult
* @param sampleId
* @param idAnalysis
* @param nuclideName
*/
private void saveXE_133(BgAnalyseResult analyseResult,Integer sampleId,Integer idAnalysis,String nuclideName,List<GardsXeResults> xeResultsList){
GardsXeResults xeResults = new GardsXeResults();
xeResults.setSampleId(sampleId);
xeResults.setIdAnalysis(idAnalysis);
xeResults.setNuclideName(nuclideName);
xeResults.setConc(analyseResult.Xe133_con);
xeResults.setConcErr(analyseResult.Xe133_uncer);
xeResults.setMdc(analyseResult.MDC_Xe133);
xeResults.setLc(analyseResult.MDC_Xe133);
xeResults.setNidFlag(analyseResult.XE_133_NID_FLAG);
xeResults.setModdate(new Date());
xeResultsList.add(xeResults);
}
/**
* 保存XE_133m
* @param analyseResult
* @param sampleId
* @param idAnalysis
* @param nuclideName
*/
private void saveXE_133m(BgAnalyseResult analyseResult,Integer sampleId,Integer idAnalysis,String nuclideName,List<GardsXeResults> xeResultsList){
GardsXeResults xeResults = new GardsXeResults();
xeResults.setSampleId(sampleId);
xeResults.setIdAnalysis(idAnalysis);
xeResults.setNuclideName(nuclideName);
xeResults.setConc(analyseResult.Xe131m_con);
xeResults.setConcErr(analyseResult.Xe131m_uncer);
xeResults.setMdc(analyseResult.MDC_Xe131m);
xeResults.setLc(analyseResult.LC_Xe131m);
xeResults.setNidFlag(analyseResult.XE_131m_NID_FLAG);
xeResults.setModdate(new Date());
xeResultsList.add(xeResults);
}
/**
* 保存XE_135
* @param analyseResult
* @param sampleId
* @param idAnalysis
* @param nuclideName
*/
private void saveXE_135(BgAnalyseResult analyseResult,Integer sampleId,Integer idAnalysis,String nuclideName,List<GardsXeResults> xeResultsList){
GardsXeResults xeResults = new GardsXeResults();
xeResults.setSampleId(sampleId);
xeResults.setIdAnalysis(idAnalysis);
xeResults.setNuclideName(nuclideName);
xeResults.setConc(analyseResult.Xe135_con);
xeResults.setConcErr(analyseResult.Xe135_uncer);
xeResults.setMdc(analyseResult.MDC_Xe135);
xeResults.setLc(analyseResult.LC_Xe135);
xeResults.setNidFlag(analyseResult.XE_135_NID_FLAG);
xeResults.setModdate(new Date());
xeResultsList.add(xeResults);
}
}

View File

@ -93,8 +93,8 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
if(StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time)){ if(StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time)){
gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+" "+struct.acquisition_start_time)); gardsSampleData.setAcquisitionStart(DateUtils.parseDate(struct.acquisition_start_date+" "+struct.acquisition_start_time));
} }
if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_real_time > 0){ if(Objects.nonNull(gardsSampleData.getAcquisitionStart()) && struct.acquisition_live_time > 0){
Date acquisitionStop = new Date((long) (gardsSampleData.getAcquisitionStart().getTime()+struct.acquisition_real_time)); Date acquisitionStop = new Date((long) (gardsSampleData.getAcquisitionStart().getTime()+(struct.acquisition_live_time*1000)));
gardsSampleData.setAcquisitionStop(acquisitionStop); gardsSampleData.setAcquisitionStop(acquisitionStop);
} }
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time); gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);

View File

@ -7,6 +7,7 @@ import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.original.GardsAlertData; import org.jeecg.modules.base.entity.original.GardsAlertData;
import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.exception.PHD_ReadException;
import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct; import org.jeecg.modules.native_jni.struct.AlertSpectrumStruct;
@ -81,10 +82,10 @@ public class AlertSpectrum extends SpectrumHandler{
* 调用dll解析邮件 * 调用dll解析邮件
*/ */
@Override @Override
protected void parseingEmail() { protected void parseingEmail() throws Exception {
final AlertSpectrumStruct sourceData = EnergySpectrumHandler.getAlertSourceData(mailFile.getAbsolutePath()); final AlertSpectrumStruct sourceData = EnergySpectrumHandler.getAlertSourceData(mailFile.getAbsolutePath());
if(Objects.isNull(sourceData)){ if(Objects.isNull(sourceData)){
throw new RuntimeException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath()); throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath());
} }
this.sourceData = sourceData; this.sourceData = sourceData;
} }

View File

@ -8,6 +8,7 @@ import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.entity.original.GardsSohData; import org.jeecg.modules.base.entity.original.GardsSohData;
import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.exception.AirSamplerFlowException; import org.jeecg.modules.exception.AirSamplerFlowException;
import org.jeecg.modules.exception.PHD_ReadException;
import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct; import org.jeecg.modules.native_jni.struct.SOHSpectrumStruct;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -80,10 +81,10 @@ public class HealthStatusSpectrum extends SpectrumHandler{
* 调用dll解析邮件 * 调用dll解析邮件
*/ */
@Override @Override
protected void parseingEmail() { protected void parseingEmail() throws Exception {
final SOHSpectrumStruct sourceData = EnergySpectrumHandler.getSOHSourceData(mailFile.getAbsolutePath()); final SOHSpectrumStruct sourceData = EnergySpectrumHandler.getSOHSourceData(mailFile.getAbsolutePath());
if(Objects.isNull(sourceData)){ if(Objects.isNull(sourceData)){
throw new RuntimeException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath()); throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath());
} }
if(sourceData.af_record_count <= 0 || sourceData.af_start_date.size() < 0 || sourceData.af_start_time.size() < 0){ if(sourceData.af_record_count <= 0 || sourceData.af_start_date.size() < 0 || sourceData.af_start_time.size() < 0){
throw new AirSamplerFlowException("ariSamplerFlow data error"); throw new AirSamplerFlowException("ariSamplerFlow data error");

View File

@ -80,7 +80,7 @@ public class MetSpectrum extends SpectrumHandler{
* 调用dll解析邮件 * 调用dll解析邮件
*/ */
@Override @Override
protected void parseingEmail() { protected void parseingEmail() throws Exception{
final MetSpectrumStruct sourceData = EnergySpectrumHandler.getMetSourceData(mailFile.getAbsolutePath()); final MetSpectrumStruct sourceData = EnergySpectrumHandler.getMetSourceData(mailFile.getAbsolutePath());
if(Objects.isNull(sourceData)){ if(Objects.isNull(sourceData)){
throw new RuntimeException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath()); throw new RuntimeException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath());

View File

@ -12,6 +12,7 @@ import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.exception.AcquisitionBlockException; import org.jeecg.modules.exception.AcquisitionBlockException;
import org.jeecg.modules.exception.FileRepeatException; import org.jeecg.modules.exception.FileRepeatException;
import org.jeecg.modules.exception.HeaderBlockException; import org.jeecg.modules.exception.HeaderBlockException;
import org.jeecg.modules.exception.PHD_ReadException;
import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBlockService; import org.jeecg.modules.service.ISpectrumBlockService;
@ -49,6 +50,14 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
* 基础数据 * 基础数据
*/ */
protected GardsSampleData sampleData; protected GardsSampleData sampleData;
/**
* 日志文件路径
*/
protected String logFilePath;
/**
* 日志文件名称
*/
protected String logFileName;
/** /**
* 前置检查 * 前置检查
@ -80,10 +89,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
* 调用dll解析邮件 * 调用dll解析邮件
*/ */
@Override @Override
protected void parseingEmail() { protected void parseingEmail() throws Exception {
final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(mailFile.getAbsolutePath()); final EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(mailFile.getAbsolutePath());
if(Objects.isNull(sourceData)){ if(Objects.isNull(sourceData)){
throw new RuntimeException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath()); throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+this.mailFile.getAbsolutePath());
} }
this.sourceData = sourceData; this.sourceData = sourceData;
} }
@ -182,7 +191,7 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
} }
} }
//提交事务 //提交事务
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus); this.spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
this.endIntoDatabaseTime = new Date(); this.endIntoDatabaseTime = new Date();
}catch (Exception e){ }catch (Exception e){
//回滚事务 //回滚事务
@ -225,9 +234,10 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
logContent.append("------------------- ").append("Write Data into Database Successfully at ").append(DateUtils.formatDate(this.endIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" --------------------"); logContent.append("------------------- ").append("Write Data into Database Successfully at ").append(DateUtils.formatDate(this.endIntoDatabaseTime,"yyyy-MM-dd HH:mm:ss")).append(" --------------------");
//保存日志文件到ftp //保存日志文件到ftp
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties(); final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
final String ftpPath = properties.getLogPath()+StringConstant.SLASH+this.getFileSavePath(); this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.getFileSavePath();
final String fileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX); this.logFileName = super.mailFile.getName().replace(this.currDataType.getSuffix(),LOG_FILE_SUFFIX);
super.ftpUtil.saveFile(ftpPath,fileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8)));
super.ftpUtil.saveFile(logFilePath,logFileName,new ByteArrayInputStream(logContent.toString().getBytes(StandardCharsets.UTF_8)));
} }
/** /**

View File

@ -0,0 +1,299 @@
package org.jeecg.modules.spectrum;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.entity.rnauto.GardsAnalyses;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.DataTypeAbbr;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.exception.BAnalyseException;
import org.jeecg.modules.exception.FileNotExistException;
import org.jeecg.modules.ftp.FTPUtils;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.springframework.transaction.TransactionStatus;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Date;
import java.util.Objects;
/**
* B谱分析过程
*/
public class Sample_B_Analysis {
/**
* 报告文件后缀
*/
private static final String ARR_FILE_SUFFIX = ".txt";
/**
* 正常分析过程日志
*/
private StringBuilder analysesLog = new StringBuilder();
/**
* 分析过程当前状态
*/
private String currAnalysesStatus = null;
/**
* Sample谱结构体数据
*/
private EnergySpectrumStruct sampleStruct = null;
/**
* sample谱原始数据
*/
private GardsSampleData sampleData = null;
/**
* gas谱原始数据
*/
private GardsSampleData detSampleData = null;
/**
* det谱原始数据
*/
private GardsSampleData gasSampleData = null;
/**
* sample谱PHD文件临时路径
*/
private String sampleTempFilePath;
/**
* det谱PHD文件临时路径
*/
private String detTempFilePath;
/**
* gas谱PHD文件临时路径
*/
private String gasTempFilePath;
/**
* 日志文件路径
*/
private String logFilePath;
/**
* 日志文件名称
*/
private String logFileName;
/**
* 报告文件路径
*/
private String arrFilePath;
/**
* 报告文件名称
*/
private String arrFileName;
/**
* spring bean引用
*/
private SpectrumServiceQuotes spectrumServiceQuotes;
/**
* ftp工具
*/
private FTPUtils ftpUtil;
/**
* 分析结果
*/
private BgAnalyseResult analyseResult;
/**
* 开始分析时间
*/
private Date startAnalysisTime;
/**
* 结束分析时间
*/
private Date endAnalysisTime;
public Sample_B_Analysis(GardsSampleData sampleData,String sampleTempFilePath,SpectrumServiceQuotes spectrumServiceQuotes,
EnergySpectrumStruct sampleStruct,FTPUtils ftpUtil,String logFilePath,String logFileName){
this.sampleData = sampleData;
this.sampleTempFilePath = sampleTempFilePath;
this.spectrumServiceQuotes = spectrumServiceQuotes;
this.sampleStruct = sampleStruct;
this.ftpUtil = ftpUtil;
this.logFilePath = logFilePath;
this.logFileName = logFileName;
}
/**
* 执行解析过程
*/
public void start(){
try {
//修改状态为解析中
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
//查询detgas数据sampleId,inputFileNamesample数据在构造函数已经传过来
this.queryPHDFile();
//构造报告文件存储路径及文件名称日志文件存储路径及文件名称在原始库存储阶段已存在已经传过来
this.structureArrFilePath();
//下载det和gas谱PHD文件sample谱PHD文件位置在构造函数已经传过来
this.downloadPHDFile();
//传入sampledet和gas谱PHD文件调用dll进行分析
this.autoAnalyse();
//存储数据
this.storageDataToDatabase();
//删除下载的det和gas临时文件
this.deleteLocalTemporaryFile();
}catch (Exception e){
e.printStackTrace();
}
}
/**
* 修改状态为解析中
* @param analysesStatus
*/
private void updateStatus(String analysesStatus){
this.currAnalysesStatus = analysesStatus;
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName());
}
/**
* 查询detgas数据sample在构造函数已经传过来
* @throws FileNotExistException
*/
private void queryPHDFile() throws FileNotExistException {
//查询det和gas能谱文件
this.detSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType());
this.gasSampleData = spectrumServiceQuotes.getSampleDataService().getSampleIdAndInputFileName(this.sampleStruct.gas_bk_measurement_id, DataTypeAbbr.GASBKPHD.getType());
//如果找不到sampledetgas谱文件数据则解析失败修改记录状态
if(StringUtils.isEmpty(this.sampleData.getInputFileName()) || Objects.isNull(this.detSampleData) || StringUtils.isEmpty(this.detSampleData.getInputFileName()) || Objects.isNull(this.gasSampleData) || StringUtils.isEmpty(this.gasSampleData.getInputFileName())){
this.currAnalysesStatus = SampleStatus.FAIL.getValue();
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,this.sampleData.getInputFileName());
throw new FileNotExistException("gas or det file is no exist or is error..");
}
}
/**
* 创建报告文件路径
*/
private void structureArrFilePath(){
//处理此文件需要保存到ftp服务的路径
final int year = LocalDate.now().getYear();
final int month = LocalDate.now().getMonth().getValue();
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
StringBuilder ftpPath = new StringBuilder();
ftpPath.append(properties.getRootPath());
ftpPath.append(StringConstant.SLASH);
ftpPath.append(properties.getArrPath());
ftpPath.append(StringConstant.SLASH);
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.system_type));
ftpPath.append(StringConstant.SLASH);
ftpPath.append(properties.getFilePathMap().get(this.sampleStruct.data_type));
ftpPath.append(StringConstant.SLASH);
ftpPath.append(year);
ftpPath.append(StringConstant.SLASH);
ftpPath.append(month>=10?month:"0"+month);
this.arrFilePath = ftpPath.toString();
final String filePath = this.sampleData.getInputFileName().replace(DataType.SAMPLEPHD.getSuffix(), ARR_FILE_SUFFIX);
this.arrFileName = filePath.substring(filePath.lastIndexOf(StringConstant.SLASH)+1);
}
/**
* 调用dll库的分析B谱结果
*/
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
this.startAnalysisTime = new Date();
System.out.println("sam:"+this.sampleTempFilePath);
System.out.println("gas:"+this.gasTempFilePath);
System.out.println("det:"+this.detTempFilePath);
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
System.out.println(analyseResult);
this.endAnalysisTime = new Date();
if(Objects.isNull(analyseResult)){
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
}
this.analyseResult = analyseResult;
}
/**
* 下载det和gas谱PHD文件sample谱PHD文件位置在构造函数已经传过来
* @throws IOException
*/
private void downloadPHDFile() throws IOException, FileNotExistException {
boolean flag = false;
//下载gas谱PHD文件到本地临时路径
String gasFileName = gasSampleData.getInputFileName().substring(gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
String gasFileFTPPath = gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
boolean gasFlag = ftpUtil.downloadFTPFile(gasFileFTPPath,gasFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
if(!gasFlag){
flag = true;
}
gasTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+File.separator+gasFileName;
//下载det谱PHD文件到本地临时路径
final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
String detFileFTPPath = detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
boolean detFlag = ftpUtil.downloadFTPFile(detFileFTPPath,detFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
if(!detFlag){
flag = true;
}
detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName;
if(flag){
throw new FileNotExistException("gas or det file is no exist or is error..");
}
}
/**
* 数据入库
*/
private void storageDataToDatabase(){
String logFileRelativePath = this.logFilePath+StringConstant.SLASH+this.logFileName;
String arrFileRelativePath = this.arrFilePath+StringConstant.SLASH+this.arrFileName;
DataSourceSwitcher.switchToOracle();
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
try{
//存储基础数据
final GardsAnalyses analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData,
this.gasSampleData,this.startAnalysisTime,this.endAnalysisTime,logFileRelativePath,arrFileRelativePath);
//调用原始数据dll获取gasdet谱数据入库sample已有数据直接入库
//存储sample谱B_Energy和G_Energy块数据
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),sampleStruct);
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(sampleData.getSampleId(),analyses.getIdAnalysis(),sampleStruct);
//存储det谱B_Energy和G_Energy块数据
final EnergySpectrumStruct detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),detStruct);
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(detSampleData.getSampleId(),analyses.getIdAnalysis(),detStruct);
//存储gas谱B_Energy和G_Energy块数据
final EnergySpectrumStruct gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
spectrumServiceQuotes.getGardsCalibrationPairsService().createB_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),gasStruct);
spectrumServiceQuotes.getGardsCalibrationPairsService().createG_EnergyRecord(gasSampleData.getSampleId(),analyses.getIdAnalysis(),gasStruct);
//存储gards_calibration表数据sampledetgas谱B_Energy和G_Energy块数据
spectrumServiceQuotes.getGardsCalibrationService().create(this.analyseResult,gasSampleData.getSampleId(),analyses.getIdAnalysis());
//gards_roi_channels数据表存储sampledetgas谱数据
spectrumServiceQuotes.getRoiChannelsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis());
//gards_Xe_results数据表XE_131mXE_133XE_133mXE_135数据
spectrumServiceQuotes.getXeResultsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis());
//gards_ roi_results数据表
spectrumServiceQuotes.getRoiResultsService().create(this.analyseResult,sampleData.getSampleId(),analyses.getIdAnalysis());
//提交事务
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
}catch (Exception e){
//回滚事务
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
throw e;
}finally {
DataSourceSwitcher.clearDataSource();
}
}
/**
* 删除下载的det和gas临时文件
*/
private void deleteLocalTemporaryFile(){
File detFile = new File(this.detTempFilePath);
if(detFile.exists() && detFile.isFile()){
detFile.delete();
}
File gasFile = new File(this.gasTempFilePath);
if(gasFile.exists() && gasFile.isFile()){
gasFile.delete();
}
}
}

View File

@ -1,33 +1,13 @@
package org.jeecg.modules.spectrum; package org.jeecg.modules.spectrum;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.DataTypeAbbr; import org.jeecg.modules.base.enums.SystemType;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.exception.FileNotExistException;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
/** /**
* 样品谱处理 * 样品谱处理
*/ */
public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
/**
* 正常分析过程日志
*/
private StringBuilder analysesLog = new StringBuilder();
/**
* 分析过程当前状态
*/
private String currAnalysesStatus = null;
/** /**
* 设置过滤链路 * 设置过滤链路
*/ */
@ -60,78 +40,26 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
super.handlerOriginalData(); super.handlerOriginalData();
//保存email日志 //保存email日志
super.saveEmailLog(); super.saveEmailLog();
//把原始库流程日志写入ftp日志文件
super.saveLogToFtp();
//进行BG(P)谱分析
this.autoAnalysis();
//删除本地临时文件 //删除本地临时文件
super.deleteLocalTemporaryFile(); super.deleteLocalTemporaryFile();
//把流程日志写入ftp日志文件
super.saveLogToFtp();
}else{ }else{
super.next.handler(); super.next.handler();
} }
} }
/** /**
* 处理分析结果 * 进行BG(P)谱分析
* * @throws Exception
* @param struct
*/ */
protected void handlerAnalysisResult() throws FileNotExistException, IOException { protected void autoAnalysis() throws Exception {
if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
final String sampleFilePath = super.ftpSavePath; Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
String detFilePath = null; super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.logFilePath,super.logFileName);
String gasFilePath = null; bAnalysis.start();
//修改状态为解析中
this.currAnalysesStatus = SampleStatus.IN_PROCESS.getValue();
super.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,sampleFilePath);
//查询det和gas能谱文件
GardsSampleData detSampleData = super.spectrumServiceQuotes.getSampleDataService().getDetInputFileName(super.sourceData.detector_bk_measurement_id, DataTypeAbbr.DETBKPHD.getType());
GardsSampleData gasSampleData = super.spectrumServiceQuotes.getSampleDataService().getGasInputFileName(super.sourceData.gas_bk_measurement_id, DataTypeAbbr.GASBKPHD.getType());
//如果找不到sampledetgas谱文件数据则解析失败修改记录状态
if(StringUtils.isEmpty(sampleFilePath) || Objects.isNull(detSampleData) || StringUtils.isEmpty(detSampleData.getInputFileName()) || Objects.isNull(gasSampleData) || StringUtils.isEmpty(gasSampleData.getInputFileName())){
this.currAnalysesStatus = SampleStatus.FAIL.getValue();
super.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,sampleFilePath);
throw new FileNotExistException("gas or det file is no exist or is error..");
} }
//下载det谱PHD文件到本地临时路径
final String detFileName = detSampleData.getInputFileName().substring(detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
detFilePath = detSampleData.getInputFileName().substring(0, detSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
ftpUtil.downloadFTPFile(detFilePath,detFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
detFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+File.separator+detFileName;
//下载gas谱PHD文件到本地临时路径
String gasFileName = gasSampleData.getInputFileName().substring(gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH) + 1);
gasFilePath = gasSampleData.getInputFileName().substring(0, gasSampleData.getInputFileName().lastIndexOf(StringConstant.SLASH));
ftpUtil.downloadFTPFile(gasFilePath,gasFileName,this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath());
gasFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+File.separator+gasFileName;
//分析结果
final BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(sampleFilePath, gasFilePath, detFilePath);
System.out.println(analyseResult);
if(Objects.nonNull(analyseResult) && analyseResult.analyse_flag){
//存储数据
super.spectrumServiceQuotes.getAnalysesService().create(analyseResult,super.sampleData.getSampleId());
//修改分析状态为已完成
this.currAnalysesStatus = SampleStatus.COMPLETE.getValue();
super.spectrumServiceQuotes.getSampleDataService().updateStatus(this.currAnalysesStatus,sampleFilePath);
//调用原始数据dll获取gasdet谱数据入库sample已有数据直接入库 EnergySpectrumHandler.getSourceData()
//存储gards_calibration表数据sampledetgas谱数据
//存储GARDS_ROI_CHANNELS表数据sampledetgas谱数据-乔钦政那边已和周雨涵调试过
//gards_ Xe_results数据表
}
}
/**
* 下载FTP文件到临时目录
* @param filePath
*/
private void downFTPFileToTemporaryDirectory(String filePath){
} }
} }

View File

@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.email.EmailProperties; import org.jeecg.modules.email.EmailProperties;
import org.jeecg.modules.exception.PHD_ReadException;
import org.jeecg.modules.ftp.FTPUtils; import org.jeecg.modules.ftp.FTPUtils;
import javax.mail.Message; import javax.mail.Message;
import java.io.File; import java.io.File;
@ -94,7 +95,7 @@ public abstract class SpectrumHandler extends Chain{
/** /**
* 调用dll解析邮件 * 调用dll解析邮件
*/ */
protected abstract void parseingEmail(); protected abstract void parseingEmail() throws Exception;
/** /**
* 保存能谱文件到ftp * 保存能谱文件到ftp

View File

@ -95,7 +95,7 @@ public class SpectrumParsingActuator implements Runnable{
mailContent = new StringBuilder(); mailContent = new StringBuilder();
emailServiceManager.getMailContent(message,mailContent); emailServiceManager.getMailContent(message,mailContent);
//所有邮件都需以.eml格式存储到ftp eml文件夹中 //所有邮件都需以.eml格式存储到ftp eml文件夹中
downloadEmailToFtp(); // downloadEmailToFtp();
//判断是否是IMS2.0协议文件 //判断是否是IMS2.0协议文件
if(checkMailContent(mailContent,subject)){ if(checkMailContent(mailContent,subject)){
SpectrumHandler spectrumHandler = new SamplephdSpectrum(); SpectrumHandler spectrumHandler = new SamplephdSpectrum();

View File

@ -59,4 +59,11 @@ public class SpectrumServiceQuotes {
private final GardsNuclLinesIdedAutoService gardsNuclLinesIdedAutoService; private final GardsNuclLinesIdedAutoService gardsNuclLinesIdedAutoService;
private final GardsQcCheckAutoService gardsQcCheckAutoService; private final GardsQcCheckAutoService gardsQcCheckAutoService;
private final GardsXeResultsService xeResultsService;
private final GardsRoiResultsService roiResultsService;
private final GardsRoiChannelsService roiChannelsService;
} }