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

This commit is contained in:
nieziyan 2023-09-25 19:38:24 +08:00
commit 5b2ca8213b
41 changed files with 1909 additions and 606 deletions

View File

@ -0,0 +1,87 @@
package org.jeecg.common.util;
import org.jeecg.modules.entity.vo.BaseControls;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Objects;
public class GammaReportUtil {
public static void writeFile(BaseControls baseCtrl, String path){
// 创建文件
File file = new File(path);
try {
// 创建PrintWriter对象
PrintWriter out = new PrintWriter(file);
out.println("#AnalyseRange");
String low = String.valueOf(baseCtrl.getRg_low());
String high = String.valueOf(baseCtrl.getRg_high());
out.printf("%" + (low.length() + 15) + "s", low);
out.printf("%" + (high.length() + 15) + "s", high);
out.println("");
out.println("#XCtrl");
format(baseCtrl.getXCtrl(), out);
out.println("#YCtrl");
format(baseCtrl.getYCtrl(), out);
out.println("#YSlope");
format(baseCtrl.getYSlope(), out);
out.println("#Baseline");
format(baseCtrl.getBaseline(), out);
out.println("#StepCounts");
format(baseCtrl.getStepCounts(), out);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
public static void writeFile(List<Double> data, String fileType, String path){
// 创建文件
File file = new File(path);
try {
// 创建PrintWriter对象
PrintWriter out = new PrintWriter(file);
out.println("#" + fileType);
out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n");
format(data, out);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static void format(List<Double> data, PrintWriter out) {
// 每行的数量
int numPerLine = 5;
int i,n = data.size(), nGroupBL = n / numPerLine * numPerLine;
// 计算每列数据中最长的字符串长度
int[] columnWidths = new int[data.size()];
for (i = 0; i < data.size(); i++) {
String col = Objects.isNull(data.get(i)) ? "" : String.valueOf(data.get(i));
columnWidths[i] = Math.max(columnWidths[i], col.length());
}
out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n");
for(i = 0; i < nGroupBL; i++)
{
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", col);
if((i+1) % numPerLine == 0) {
out.println("");
}
}
if(i < n)
{
for(; i<n; ++i){
String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i));
out.printf("%" + (columnWidths[i] + 15) + "s", col);
}
}
out.println("");
}
}

View File

@ -12,9 +12,9 @@ public class AcquisitionBlock implements Serializable {
private String acquisition_start_time; // acquisition start time (hh : mm : ss . s)
private Double acquisition_real_time; // acquisition real time (s)
private double acquisition_real_time; // acquisition real time (s)
private Double acquisition_live_time; // acquisition live time (s)
private double acquisition_live_time; // acquisition live time (s)
public AcquisitionBlock(){
acquisition_start_date="";

View File

@ -17,17 +17,19 @@ public class BaseControls implements Serializable {
private List<Double> YSlope;
private List<Double> Baseline;
private List<Double> StepCounts;
private List<BaseCtrlStack> BaseStack;
public BaseControls(){
rg_low = 1;
rg_high = 1;
ReplotUsed = false;
ReplotNeeded = false;
XCtrl=new LinkedList<>();
YCtrl=new LinkedList<>();
YSlope=new LinkedList<>();
Baseline=new LinkedList<>();
StepCounts=new LinkedList<>();
XCtrl = new LinkedList<>();
YCtrl = new LinkedList<>();
YSlope = new LinkedList<>();
Baseline = new LinkedList<>();
StepCounts = new LinkedList<>();
BaseStack = new LinkedList<>();
}
}

View File

@ -0,0 +1,24 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
@Data
public class BaseCtrlStack implements Serializable {
private List<Double> cx;
private List<Double> cy;
private List<Double> cdy;
public BaseCtrlStack(){
cx = new LinkedList<>();
cy = new LinkedList<>();
cdy = new LinkedList<>();
}
}

View File

@ -10,21 +10,19 @@ import java.util.Date;
@Data
public class ConfigureData implements Serializable {
private Integer sampleId;
private String fileName;
private Double ECutAnalysis_Low;
private Double eCutAnalysis_Low;
private Double ECutAnalysis_High;
private Double eCutAnalysis_High;
private Double EnergyTolerance;
private Double energyTolerance;
private Double PSS_low;
private Double pss_low;
private Double CalibrationPSS_low;
private Double calibrationPSS_low;
private Double CalibrationPSS_high;
private Double calibrationPSS_high;
private Double k_back;
@ -32,16 +30,16 @@ public class ConfigureData implements Serializable {
private Double k_beta;
private Double BaseImprovePSS;
private Double baseImprovePSS;
private Double RiskLevelK;
private Double riskLevelK;
@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
private Date RefTime_act;
private Date refTime_act;
@DateTimeFormat(pattern = "yyyy/MM/dd HH:mm:ss")
@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
private Date RefTime_conc;
private Date refTime_conc;
}

View File

@ -15,7 +15,7 @@ public class GEfficiencyBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (counts in peak/photon emitted)
private Integer record_count;
private int record_count;
public GEfficiencyBlock(){
g_energy = new LinkedList<>();

View File

@ -15,7 +15,7 @@ public class GEnergyBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (channels)
private Integer record_count;
private int record_count;
public GEnergyBlock(){
g_energy = new LinkedList<>();

View File

@ -15,7 +15,7 @@ public class GResolutionBlock implements Serializable {
private List<Double> uncertainty; // uncertainty (keV)
private Integer record_count;
private int record_count;
public GResolutionBlock(){
g_energy = new LinkedList<>();

View File

@ -9,10 +9,10 @@ import java.util.List;
@Data
public class NuclideLines implements Serializable {
public List<String> fullNames; // 核素全名
public List<Double> vEnergy; // 核素的所有γ射线能量
public List<Double> vUncertE;
public List<Double> vYield; // 核素γ射线分支比
public List<Double> vUncertY;
public List<Double> venergy; // 核素的所有γ射线能量
public List<Double> vuncertE;
public List<Double> vyield; // 核素γ射线分支比
public List<Double> vuncertY;
public double halflife;// 单位
public int key_flag; // 记录主射线下标
public int maxYeildIdx;
@ -22,10 +22,10 @@ public class NuclideLines implements Serializable {
key_flag = -1;
halflife = 0;
fullNames=new LinkedList<>();
vEnergy=new LinkedList<>();
vUncertE=new LinkedList<>();
vYield=new LinkedList<>();
vUncertY=new LinkedList<>();
venergy=new LinkedList<>();
vuncertE=new LinkedList<>();
vyield=new LinkedList<>();
vuncertY=new LinkedList<>();
}
}

View File

@ -13,6 +13,10 @@ import java.util.Map;
@JsonIgnoreProperties(ignoreUnknown = true)
public class PHDFile implements Serializable {
private String userId;
private String xmlFilePath;
private boolean isValid; // 是否有效谱
private boolean bAnalyed; // 记录是否被分析

View File

@ -22,7 +22,7 @@ public class SpecSetup implements Serializable {
private double baseImprovePSS;
private double pSS_low;
private double pss_low;
private double k_back;
@ -46,12 +46,12 @@ public class SpecSetup implements Serializable {
public SpecSetup(){
eCutAnalysis_Low = 12.0;
eCutAnalysis_High = 12.0;
eCutAnalysis_High = -9999.0;
energyTolerance = 0.5;
calibrationPSS_high = 10.0;
calibrationPSS_low = 5.0;
baseImprovePSS = 10.0;
pSS_low = 2.7;
pss_low = 2.7;
k_back = 1.25;
k_alpha = 2.576;
k_beta = 1.645;

View File

@ -749,7 +749,7 @@ public class GammaFileUtil {
phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh());
phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow());
phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss());
phd.getUsedSetting().setPSS_low(analySetting.getPssLow());
phd.getUsedSetting().setPss_low(analySetting.getPssLow());
phd.getUsedSetting().setK_back(analySetting.getKBack());
phd.getUsedSetting().setK_alpha(analySetting.getKAlpha());
phd.getUsedSetting().setK_beta(analySetting.getKBeta());
@ -1481,7 +1481,7 @@ public class GammaFileUtil {
phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low());
phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High());
phdSetting.setEnergyTolerance(configureData.getEnergyTolerance());
phdSetting.setPSS_low(configureData.getPSS_low());
phdSetting.setPss_low(configureData.getPss_low());
phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS());
phdSetting.setK_back(configureData.getK_back());
phdSetting.setK_alpha(configureData.getK_alpha());
@ -1528,7 +1528,7 @@ public class GammaFileUtil {
if(newSets.getECutAnalysis_Low() != oldSets.getECutAnalysis_Low()
|| newSets.getECutAnalysis_High() != oldSets.getECutAnalysis_High()
|| newSets.getEnergyTolerance() != oldSets.getEnergyTolerance()
|| newSets.getPSS_low() != oldSets.getCalibrationPSS_low()
|| newSets.getPss_low() != oldSets.getCalibrationPSS_low()
|| newSets.getBaseImprovePSS() != oldSets.getBaseImprovePSS()
|| newSets.getK_back() != oldSets.getK_back()
|| newSets.getK_alpha() != oldSets.getK_alpha()
@ -1603,8 +1603,8 @@ public class GammaFileUtil {
}
FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线
List<Double> vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vYield;
List<Double> vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vyield;
List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率
List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识
for (int i=0; i<vEnergy.size(); i++){
@ -1690,9 +1690,9 @@ public class GammaFileUtil {
ActMda.getVPeakIdx().add(peakIdx+1);
ActMda.getFullNames().add(iter.getValue().fullNames.get(ii));
ActMda.getVEnergy().add(vEnergy.get(ii));
ActMda.getVUncertE().add(iter.getValue().vUncertE.get(ii));
ActMda.getVUncertE().add(iter.getValue().vuncertE.get(ii));
ActMda.getVYield().add(vYield.get(ii));
ActMda.getVUncertY().add(iter.getValue().vUncertY.get(ii));
ActMda.getVUncertY().add(iter.getValue().vuncertY.get(ii));
++fitLineNum;
}
}
@ -1741,14 +1741,14 @@ public class GammaFileUtil {
}
private void FilterNuclideLine(NuclideLines lines, double lowE) {
List<Double> vE = lines.vEnergy;
List<Double> vE = lines.venergy;
for(int i=0, j=0; i<vE.size(); ++i) {
if(vE.get(i) < lowE) {
lines.fullNames.remove(j);
lines.vEnergy.remove(lines.vEnergy.get(0)+j);
lines.vYield.remove(lines.vYield.get(0)+j);
lines.vUncertE.remove(lines.vUncertE.get(0)+j);
lines.vUncertY.remove(lines.vUncertY.get(0)+j);
lines.venergy.remove(lines.venergy.get(0)+j);
lines.vyield.remove(lines.vyield.get(0)+j);
lines.vuncertE.remove(lines.vuncertE.get(0)+j);
lines.vuncertY.remove(lines.vuncertY.get(0)+j);
if(i == lines.key_flag){
lines.key_flag = -1;
} else if(i < lines.key_flag){
@ -1758,8 +1758,8 @@ public class GammaFileUtil {
++j;
}
}
if(lines.key_flag < 0 && lines.vEnergy.size() > 0) {
List<Double> vY = lines.vYield;
if(lines.key_flag < 0 && lines.venergy.size() > 0) {
List<Double> vY = lines.vyield;
lines.maxYeildIdx = 0;
double maxYield = vY.get(0);
for(int ii=1; ii<vY.size(); ++ii) {
@ -1843,10 +1843,10 @@ public class GammaFileUtil {
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVEnergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVUncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVYield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVUncertY().add(nuclideLineList.get(j).getYield_uncert());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYield_uncert());
if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
@ -2489,7 +2489,7 @@ public class GammaFileUtil {
strBuffer.append("ECutAnalysis_High : "+middleData.setting_specSetup.getECutAnalysis_High()+"\n");
strBuffer.append("EnergyTolerance : "+middleData.setting_specSetup.getEnergyTolerance()+"\n");
strBuffer.append("BaseImprovePSS : "+middleData.setting_specSetup.getBaseImprovePSS()+"\n");
strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPSS_low()+"\n");
strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPss_low()+"\n");
strBuffer.append("k_back : "+middleData.setting_specSetup.getK_back()+"\n");
strBuffer.append("k_alpha : "+middleData.setting_specSetup.getK_alpha()+"\n");
strBuffer.append("k_beta : "+middleData.setting_specSetup.getK_beta()+"\n");
@ -2642,7 +2642,7 @@ public class GammaFileUtil {
strBuffer.append(" ECutAnalysis_High: "+middleData.setting_specSetup.getECutAnalysis_High()+"\n");
strBuffer.append(" EnergyTolerance: "+middleData.setting_specSetup.getEnergyTolerance()+"\n");
strBuffer.append(" BaseImprovePSS: "+middleData.setting_specSetup.getBaseImprovePSS()+"\n");
strBuffer.append(" PSS_low: "+middleData.setting_specSetup.getPSS_low()+"\n");
strBuffer.append(" PSS_low: "+middleData.setting_specSetup.getPss_low()+"\n");
strBuffer.append(" k_back: "+middleData.setting_specSetup.getK_back()+"\n");
strBuffer.append(" k_alpha: "+middleData.setting_specSetup.getK_alpha()+"\n");
strBuffer.append(" k_beta: "+middleData.setting_specSetup.getK_beta()+"\n");
@ -3932,7 +3932,7 @@ public class GammaFileUtil {
ReadSpecialNuclides(mapHalflife, vNuclides);
double energyWidth = phd.getUsedSetting().getEnergyTolerance();
List<Double> vEnergy = lines.vEnergy; // 该核素的所有γ射线能量
List<Double> vEnergy = lines.venergy; // 该核素的所有γ射线能量
double maxYield = 0;
int mainPeakIdx = -1; // 记录核素主γ峰的索引下标
@ -3945,9 +3945,9 @@ public class GammaFileUtil {
break;
} else if(vEnergy.get(i) <= energy + energyWidth) {
ActMda.getVEnergy().add(vEnergy.get(i));
ActMda.getVUncertE().add(lines.vUncertE.get(i));
ActMda.getVYield().add(lines.vYield.get(i));
ActMda.getVUncertY().add(lines.vUncertY.get(i));
ActMda.getVUncertE().add(lines.vuncertE.get(i));
ActMda.getVYield().add(lines.vyield.get(i));
ActMda.getVUncertY().add(lines.vuncertY.get(i));
ActMda.getFullNames().add(lines.fullNames.get(i));
ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1);
if(lines.key_flag == i) {

View File

@ -159,7 +159,7 @@ public class FileSourceHandleManager {
}catch (Exception e){
//解析失败会把文件上传到undeal目录
this.ftpUtil.saveFile(spectrumServiceQuotes.getSpectrumPathProperties().getFailPath(),this.fileName,new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
log.error("Parsing the {} file of the undeal directory failed",fileName);
log.error("Parsing the {} file of the filesource directory failed",fileName);
e.printStackTrace();
}finally {
//解析成功或者失败都会删除源文件

View File

@ -2,20 +2,27 @@ 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";
String PHD = "PHD";
String SYSTEMTYPE_B = "B";
String ENERGY_CAL = "energy";
String RESOLUTION_CAL = "Resolution";
String SYSTEMTYPE_G = "G";
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";
String XE_131m = "Xe131m";
String XE_133m = "Xe133m";
String XE_133 = "Xe133";
String XE_135 = "Xe135";
public final static String CH_Contant = "CH(x)";
public final static String E_Contant = "E(x)";
String CH_Contant = "CH(x)";
String E_Contant = "E(x)";
String to_flag = " to ";
String arithmetic_flag = " +/- ";
String and_flag = " and ";
String unit_kev = " keV";
String unit_mbq = " mBq/m3";
}

View File

@ -27,4 +27,11 @@ public interface GardsAnalysesService extends IService<GardsAnalyses> {
public GardsAnalyses create(Integer sampleId, GardsSampleData detSampleData, GardsSampleData gasSampleData, Date beginDate, Date endDate, String logPath, String reportPath);
Integer getIdAnalysis(Integer sampleId);
/**
* 修改分析结束时间
* @param idAnalysis
* @param endTime
*/
void updateAnalysesEndTime(Integer idAnalysis,Date endTime);
}

View File

@ -13,8 +13,9 @@ public interface ISpectrumBaseBlockService {
* 不添加事务注解由调用方手动事务提交
* @param struct
* @param fileName
* @param status
* @return
* @throws Exception
*/
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception;
public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception;
}

View File

@ -13,6 +13,7 @@ import org.jeecg.modules.mapper.GardsAnalysesMapper;
import org.jeecg.modules.service.GardsAnalysesService;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Objects;
/**
* 存储谱数据分析的基本信息
@ -66,4 +67,21 @@ public class GardsAnalysesServiceImpl extends ServiceImpl<GardsAnalysesMapper, G
GardsAnalyses gardsAnalyses = getOne(wrapper);
return ObjectUtil.isNull(gardsAnalyses) ? null : gardsAnalyses.getIdAnalysis();
}
/**
* 修改分析结束时间
* @param idAnalysis
* @param endTime
*/
@DS(value = "ora")
@Override
public void updateAnalysesEndTime(Integer idAnalysis,Date endTime) {
LambdaQueryWrapper<GardsAnalyses> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(GardsAnalyses::getIdAnalysis,idAnalysis);
final GardsAnalyses gardsAnalyses = this.getOne(wrapper);
if(Objects.nonNull(gardsAnalyses)){
gardsAnalyses.setAnalysisEnd(endTime);
this.updateById(gardsAnalyses);
}
}
}

View File

@ -65,19 +65,19 @@ public class GardsCalibrationPairsServiceImpl extends ServiceImpl<GardsCalibrati
*/
@Override
public void createG_EnergyRecord(Integer sampleId, Integer anayId, EnergySpectrumStruct struct) {
if(struct.g_e_record_count > 0){
if(struct.g_record_count > 0){
List<GardsCalibrationPairs> list = Lists.newArrayList();
for (int i=0;i<struct.g_e_record_count;i++){
for (int i=0;i<struct.g_record_count;i++){
GardsCalibrationPairs calibrationPairs = new GardsCalibrationPairs();
calibrationPairs.setSampleId(sampleId);
calibrationPairs.setIdAnalysis(anayId);
calibrationPairs.setSampleType(SYSTEMTYPE_G);
calibrationPairs.setCaltype(EFFICIENCY_CAL);
calibrationPairs.setCaltype(ENERGY_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));
calibrationPairs.setXValue(struct.g_centroid_channel.get(i));
calibrationPairs.setYValue(struct.g_energy.get(i));
calibrationPairs.setUncYValue(struct.g_uncertainty.get(i));
list.add(calibrationPairs);
}

View File

@ -19,7 +19,7 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl<GardsGammaDe
public Map<String, String> mapSetting() {
Map<String, String> paramsMap = list().stream()
.collect(Collectors.toMap(GardsGammaDefaultParams::getName,
GardsGammaDefaultParams::getValue));
v->v.getValue() == null ? "" : v.getValue()));
return paramsMap;
}
}

View File

@ -28,8 +28,6 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
@Override
public void create(BgAnalyseResult analyseResult,Integer sampleId, Integer idAnalysis) {
List<GardsRoiResults> list = Lists.newArrayList();
//C++那边没有补0先加上后续解决后再删除
analyseResult.LC.add(0,0.0D);
for(int i=0;i<analyseResult.ROI.size();i++){
GardsRoiResults roiResults = new GardsRoiResults();
@ -56,24 +54,29 @@ public class GardsRoiResultsServiceImpl extends ServiceImpl<GardsRoiResultsMappe
int seriNo = 0;
//从下标3开始每次加3
for(int i=3;i<analyseResult.s_deduct_d_cts.size();i+=3){
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
seriNo++;
if(seriNo < analyseResult.ROI.size()){
list.get(seriNo).setSNet(analyseResult.s_deduct_d_cts.get(i));
seriNo++;
}
}
seriNo = 0;
//从下标3开始每次加3
for(int i=3;i<analyseResult.g_deduct_d_cts.size();i+=3){
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
if(seriNo < analyseResult.ROI.size()){
list.get(seriNo).setGNet(analyseResult.g_deduct_d_cts.get(i));
seriNo++;
}
}
//从下标1开始第一条记录LC值固定为0
for(int i=1;i<analyseResult.LC.size();i++){
list.get(i).setLc(analyseResult.LC.get(i));
//LC 从下标1开始第一条记录LC值固定为0所以是i+1
for(int i=0;i<analyseResult.LC.size();i++){
list.get(i+1).setLc(analyseResult.LC.get(i));
}
//从下标1开始第一条记录MDC值固定为0
for(int i=1;i<analyseResult.MDC.size();i++){
list.get(i).setMdc(analyseResult.MDC.get(i));
//MDC从下标1开始第一条记录MDC值固定为0所以是i+1
for(int i=0;i<analyseResult.MDC.size();i++){
list.get(i+1).setMdc(analyseResult.MDC.get(i));
}
if(!CollectionUtils.isEmpty(list)){

View File

@ -75,7 +75,7 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
xeResults.setConc(analyseResult.Xe133_con);
xeResults.setConcErr(analyseResult.Xe133_uncer);
xeResults.setMdc(analyseResult.MDC_Xe133);
xeResults.setLc(analyseResult.MDC_Xe133);
xeResults.setLc(analyseResult.LC_Xe133);
xeResults.setNidFlag(analyseResult.XE_133_NID_FLAG);
xeResults.setModdate(new Date());
@ -94,11 +94,11 @@ public class GardsXeResultsServiceImpl extends ServiceImpl<GardsXeResultsMapper,
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.setConc(analyseResult.Xe133m_con);
xeResults.setConcErr(analyseResult.Xe133m_uncer);
xeResults.setMdc(analyseResult.MDC_Xe133m);
xeResults.setLc(analyseResult.LC_Xe133m);
xeResults.setNidFlag(analyseResult.XE_133m_NID_FLAG);
xeResults.setModdate(new Date());
xeResultsList.add(xeResults);

View File

@ -9,7 +9,6 @@ import org.jeecg.modules.base.entity.configuration.GardsDetectors;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.entity.original.GardsSampleAux;
import org.jeecg.modules.base.entity.original.GardsSampleData;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.mapper.GardsDetectorsMapper;
import org.jeecg.modules.mapper.GardsSampleAuxMapper;
import org.jeecg.modules.mapper.GardsSampleDataMapper;
@ -18,8 +17,6 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.ISpectrumBaseBlockService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.text.ParseException;
import java.util.Date;
import java.util.Objects;
@ -40,12 +37,13 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
* 不添加事务注解由调用方手动事务提交
* @param struct
* @param fileName
* @param status
* @return
* @throws Exception
*/
@Override
public GardsSampleData create(EnergySpectrumStruct struct,String fileName) throws Exception {
final GardsSampleData sampleData = this.saveSampleData(struct,fileName);
public GardsSampleData create(EnergySpectrumStruct struct,String fileName,String status) throws Exception {
final GardsSampleData sampleData = this.saveSampleData(struct,fileName,status);
this.saveSampleAux(struct,sampleData);
return sampleData;
}
@ -56,7 +54,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
* @return
* @throws Exception
*/
private GardsSampleData saveSampleData(EnergySpectrumStruct struct,String fileName) throws Exception{
private GardsSampleData saveSampleData(EnergySpectrumStruct struct,String fileName,String status) throws Exception{
Assert.notNull(struct.site_code,"此次解析结构体中的台站“台站代码”为空");
Assert.notNull(struct.detector_code,"此次解析结构体中的台站“探测器代码”为空");
@ -101,7 +99,7 @@ public class SpectrumBaseBlockServiceImpl implements ISpectrumBaseBlockService {
gardsSampleData.setAcquisitionRealSec(struct.acquisition_real_time);
gardsSampleData.setAcquisitionLiveSec(struct.acquisition_live_time);
gardsSampleData.setQuantity(struct.air_volume);
gardsSampleData.setStatus(SampleStatus.UNTREATED.getValue());
gardsSampleData.setStatus(status);
gardsSampleData.setModdate(new Date());
this.sampleDataMapper.insert(gardsSampleData);

View File

@ -0,0 +1,65 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.base.enums.FittingEquation;
import java.util.List;
public abstract class AbstractLogOrReport {
/**
* 获取samplegasdet谱Beta和Gamma的CH(x)E(x)
* @return
*/
protected String calibration(Integer fitting_type, List<Double> fitting_e_c){
String b_fittingEquation = this.getFittingEquation(fitting_type);
for(int i=0;i<fitting_e_c.size();i++){
b_fittingEquation = b_fittingEquation.replace("?"+(i+1),formatToStr6(fitting_e_c.get(i)));
}
return b_fittingEquation;
}
/**
* 获取适合的方程
* @return
*/
protected String getFittingEquation(Integer type){
String rData = null;
switch (type) {
case 1:
rData = FittingEquation.LINER.getDescription();
break;
case 2:
rData = FittingEquation.POLY2.getDescription();
break;
case 3:
rData = FittingEquation.POLY3.getDescription();
break;
case 4:
rData = FittingEquation.GAUSS.getDescription();
break;
case 0:
rData = FittingEquation.DEFAULT.getDescription();
break;
default:
break;
}
return rData;
}
/**
* 格式化值
* @param source
* @return
*/
protected String formatToStr5(Double source){
return String.format("%.5f",source);
}
/**
* 格式化值
* @param source
* @return
*/
protected String formatToStr6(Double source){
return String.format("%.6f",source);
}
}

View File

@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.SampleStatus;
import java.util.Objects;
/**
* 探测器本地谱处理
@ -29,6 +31,8 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
try{
//前置检查
this.preCheck();
//声明日志处理对象
super.initLogObj();
//打印当前处理的能谱类型
super.printCurrDataType();
//解析邮件内容
@ -39,17 +43,21 @@ public class DetbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//处理流程日志
super.handleProcessLog();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
}catch (Exception e){
//异常结束日志
super.exceptionEndLog(e);
//修改状态为解析失败
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到ftp->undeal目录
super.handleParseingFailFile();
throw e;
}finally {
//结束流程日志
super.storageProcessLogEnd();
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}

View File

@ -2,6 +2,8 @@ package org.jeecg.modules.spectrum;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.SampleStatus;
import java.util.Objects;
/**
* 气体谱处理
@ -30,6 +32,8 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
try{
//前置检查
this.preCheck();
//声明日志处理对象
super.initLogObj();
//打印当前处理的能谱类型
super.printCurrDataType();
//解析邮件内容
@ -40,17 +44,21 @@ public class GasbkphdSpectrum extends S_D_Q_G_SpectrumHandler{
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//处理流程日志
super.handleProcessLog();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
}catch (Exception e){
//异常结束日志
super.exceptionEndLog(e);
//修改状态为解析失败
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到ftp->undeal目录
super.handleParseingFailFile();
throw e;
}finally {
//结束流程日志
super.storageProcessLogEnd();
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}

View File

@ -4,9 +4,16 @@ import lombok.Setter;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.SystemType;
import org.jeecg.modules.native_jni.struct.BgAnalyseResult;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.jeecg.modules.service.BlockConstant;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* B谱邮件解析流程日志
@ -14,17 +21,33 @@ import java.nio.charset.StandardCharsets;
public class ParsingProcessLog {
/**
* 日志内容
* 存储日志内容
*/
private StringBuilder log = new StringBuilder();
private StringBuilder storageLog = new StringBuilder();
/**
* 日志存储结束标记
* 分析日志内容
*/
private boolean logStoreEndFlag = false;
private StringBuilder analysisLog = new StringBuilder();
/**
* 日志分析结束标记
* PHD文件是否重复
*/
private boolean logAnalyseEndFlag = false;
@Setter
private boolean fileRepeat = false;
/**
* GasDet文件是否存在
*/
@Setter
private boolean fileNotExist = false;
/**
* 分析数据是否存储成功
*/
@Setter
private boolean analysisDataStoreFlag = false;
/**
* 能谱处理父类
*/
@ -38,7 +61,11 @@ public class ParsingProcessLog {
/**
* 解析过程日志对象
*/
private StorageProcessLog processLog;
private StorageProcessLog storageProcessLog;
/**
* 分析流程日志对象
*/
private AnalyseProcessLog analyseProcessLog;
/**
* 存储过程日志处理
@ -46,7 +73,7 @@ public class ParsingProcessLog {
protected class StorageProcessLog{
private static final String WRITE_INTO_START = "%s Write Data into Database at %s %s";
private static final String APPLICATION_PATH = "ApplicationPath%s,ApplicationName%s,started by RNAUTO at %s";
private static final String APPLICATION_PATH = "ApplicationPath: %s,ApplicationName: %s,started by RNAUTO at %s";
private static final String DATABASE_CONNECTED = "Successfully connected to database,source:%s,user=%s";
private static final String SOURCE_FILE = "SourceFile:%s";
private static final String STANDARD_FILE = "StandardFile:%s";
@ -61,21 +88,27 @@ public class ParsingProcessLog {
/**
* 开始处理存储过程日志
*/
private void start(){
private void handleStorageProcessLog(){
//获取数据源属性
final String oraUsername = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUsername();
final String oraUrl = spectrumHandler.spectrumServiceQuotes.getOraDataSourceProperties().getUrl();
final String startIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.startIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
final String standardFile = spectrumHandler.spectrumServiceQuotes.getFtpProperties().getFtpRootPath() + StringConstant.SLASH + spectrumHandler.ftpSavePath;
log.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
log.append(System.lineSeparator());
log.append(rowFormat(STANDARD_FILE,standardFile));
storageLog.append(titleFormat(WRITE_INTO_START,26, StringConstant.DASH,startIntoDatabaseTime,StringConstant.DASH));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(rowFormat(APPLICATION_PATH,spectrumHandler.getProjectAbsolutePath(),spectrumHandler.getProjectName(),startIntoDatabaseTime));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(rowFormat(DATABASE_CONNECTED,oraUrl.substring(oraUrl.lastIndexOf(":")+1),oraUsername));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(rowFormat(SOURCE_FILE,spectrumHandler.mailFile.getAbsolutePath()));
storageLog.append(System.lineSeparator());
storageLog.append(rowFormat(STANDARD_FILE,standardFile));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
if(fileRepeat){
this.endOfFileRepeat();
}else{
this.end();
}
}
/**
@ -83,10 +116,10 @@ public class ParsingProcessLog {
*/
private void endOfFileRepeat(){
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
storageLog.append(rowFormat(FILE_REPEAT,spectrumHandler.ftpSavePath));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(titleFormat(WRITE_INTO_ERROR,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
@ -94,106 +127,664 @@ public class ParsingProcessLog {
*/
private void end(){
final String endIntoDatabaseTime = DateUtils.formatDate(spectrumHandler.endIntoDatabaseTime, "yyyy-MM-dd HH:mm:ss");
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
log.append(System.lineSeparator());
log.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
log.append(System.lineSeparator());
log.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(rowFormat(INSTANCE_STATUS, SampleStatus.UNTREATED.getValue()));
log.append(System.lineSeparator()).append(System.lineSeparator());
log.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
storageLog.append(rowFormat(DETECTOR_ID,spectrumHandler.sampleData.getDetectorId().toString()));
storageLog.append(System.lineSeparator());
storageLog.append(rowFormat(STATION_ID,spectrumHandler.sampleData.getStationId().toString()));
storageLog.append(System.lineSeparator());
storageLog.append(rowFormat(SAMPLE_ID,spectrumHandler.sampleData.getSampleId().toString()));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(rowFormat(INSTANCE_STATUS,spectrumHandler.status));
storageLog.append(System.lineSeparator()).append(System.lineSeparator());
storageLog.append(titleFormat(WRITE_INTO_SUCCESS,19,StringConstant.DASH,endIntoDatabaseTime,StringConstant.DASH));
storageLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
}
/**
* 分析过程日志
*/
private class AnalyseProcessLog{
private static final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
private static final String titleId = "%s Get DetaId and GasId %s";
private static final String getDetaId = "%s Search DetFile :%s SampleID :%s";
private static final String titleIdEnd = "%s Get DetaId and GasId finished %s";
private static final String titleCalibration = "%s Read calibration data %s";
private static final String setSampleBEnergyChannel = "Reading sample beta energy pairs(sampleID: %s).....";
private static final String setSampleGEnergyChannel = "Reading sample gamma energy pairs(sampleID: %s).....";
private static final String setDetaBEnergyChannel = "Reading DETBK Spectrum beta energy pairs(sampleID: %s).....";
private static final String setDetaGEnergyChannel = "Reading DETBK Spectrum gamma energy pairs(sampleID: %s).....";
private static final String setGasBEnergyChannel = "Reading GASBK Spectrum beta energy pairs(sampleID: %s).....";
private static final String setGasGEnergyChannel = "Reading GASBK Spectrum gamma energy pairs(sampleID: %s)";
private static final String getMeasurementTime = "Reading mesurement information.....";
private static final String dataStore = "Data store %s .....";
private static final String setStatus = "Instance status successfully set to: %s .....";
private static final String anlyseResultsEnd = "%s Sample Analyse Successfully at %s %s";
private static final String dataAnlyseError = "Data Anlyse Error:gas or det file is no exist or is error..";
private static final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s";
private class AnalyseProcessLog extends AbstractLogOrReport implements BlockConstant {
/**
* 开始处理分析过程日志
*/
private void start(){
private void handleAnalysisProcessLog(){
final String anlyseResultsBegin = "%s Sample Analyse Beginning at %s %s";
final String storeResult = "Data store %s .....";
final String storeStatus = "Instance status %s set to: %s.....";
final String analysisResultsEnd = "%s Sample Analyse %s at %s %s";
String storeFlag = "successfully";
final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss");
log.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
final String endAnalysisTime = DateUtils.formatDate(sample_B_Analysis.endAnalysisTime, "yyyy-MM-dd HH:mm:ss");
analysisLog.append(titleFormat(anlyseResultsBegin,26,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
this.setDetAndGasIdLog();
if(fileNotExist){
// Gas谱或Det谱文件找不到异常结束
fileNotExistException();
}else{
this.readCalibrationData();
this.reading_roi_limits();
this.reading_roi_ratios();
this.reading_B_G_Efficiency();
this.NCC_analysis();
}
if(analysisDataStoreFlag == true){
storeFlag = "error";
}
analysisLog.append(rowFormat(storeResult,storeFlag));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(storeStatus,storeFlag,spectrumHandler.status));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(analysisResultsEnd,25,StringConstant.DASH,storeFlag,endAnalysisTime,StringConstant.DASH));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* 处理获取Det和Gas文件日志
*/
private void setDetAndGasIdLog(){
final String titleId = "%s Get DetaId and GasId %s";
log.append(titleFormat(titleId,40,StringConstant.DOT,StringConstant.DOT));
final String title = "%s Get DetaId and GasId %s";
final String detaInfo = "%s Search DetFile :%s SampleID :%s";
final String gasInfo = "%s Search GasFile :%s SampleID :%s";
final String titleEnd = "%s Get DetaId and GasId finished %s";
String detExist = "Error";
String gasExist = "Error";
String detMeasurementId = sample_B_Analysis.sampleStruct.detector_bk_measurement_id;
String gasMeasurementId = sample_B_Analysis.sampleStruct.gas_bk_measurement_id;
String detSampleId = StringConstant.ZERO;
String gasSampleId = StringConstant.ZERO;
if(Objects.nonNull(sample_B_Analysis.detSampleData)){
detExist = "Successfully";
detSampleId = sample_B_Analysis.detSampleData.getSampleId().toString();
}
if(Objects.nonNull(sample_B_Analysis.gasSampleData)){
gasExist = "Successfully";
gasSampleId = sample_B_Analysis.gasSampleData.getSampleId().toString();
}
analysisLog.append(titleFormat(title,40,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(detaInfo,detExist,detMeasurementId,detSampleId));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(gasInfo,gasExist,gasMeasurementId,gasSampleId));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(titleEnd,35,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Gas谱或Det谱文件找不到异常结束
*/
private void fileNotExistException(){
final String dataAnlyseError = "%s Data Anlyse Error:gas or det file is no exist or is error..";
final String anlyseResultsErrorEnd="%s Sample Analyse Error at %s %s";
final String startAnalysisTime = DateUtils.formatDate(sample_B_Analysis.startAnalysisTime, "yyyy-MM-dd HH:mm:ss");
analysisLog.append(rowFormat(dataAnlyseError,startAnalysisTime));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(anlyseResultsErrorEnd,28,StringConstant.DASH,startAnalysisTime,StringConstant.DASH));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* ... Read calibration data ...
*/
private void readCalibrationData(){
final String titleCalibration = "%s Read calibration data %s";
final String titleCalibrationFinished = "%s Read calibration finished %s";
analysisLog.append(titleFormat(titleCalibration,39,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
this.readSampleEnergyPairs();
this.readDetEnergyPairs();
this.readGasEnergyPairs();
this.readingMesurementInformation();
this.readingVolumeData();
analysisLog.append(titleFormat(titleCalibrationFinished,37,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading sample beta/Gamma energy pairs
*/
private void readSampleEnergyPairs(){
final String sampleEnergyPairsTitle = "Reading sample %s energy pairs(sampleID: %s).....";
String format = "Channel : %-11s Energy : %-15s Error : %s";
analysisLog.append(rowFormat(sampleEnergyPairsTitle,"beta",sample_B_Analysis.sampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
for(int i=0;i<struct.b_record_count;i++){
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString(),struct.b_uncertainty.get(i).toString()));
if(i < struct.b_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(sampleEnergyPairsTitle,"gamma",sample_B_Analysis.sampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<struct.g_record_count;i++){
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
if(i < struct.g_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading Det beta/Gamma energy pairs
*/
private void readDetEnergyPairs(){
final String detEnergyPairsTitle = "Reading DETBK Spectrum %s energy pairs(sampleID: %s).....";
String format = "Channel : %-11s Energy : %-15s Error : %s";
analysisLog.append(rowFormat(detEnergyPairsTitle,"beta",sample_B_Analysis.detSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.detStruct;
for(int i=0;i<struct.b_record_count;i++){
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString(),struct.b_uncertainty.get(i).toString()));
if(i < struct.b_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(detEnergyPairsTitle,"gamma",sample_B_Analysis.detSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<struct.g_record_count;i++){
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
if(i < struct.g_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading Gas beta/Gamma energy pairs
*/
private void readGasEnergyPairs(){
final String detEnergyPairsTitle = "Reading GASBK Spectrum %s energy pairs(sampleID: %s).....";
String format = "Channel : %-11s Energy : %-15s Error : %s";
analysisLog.append(rowFormat(detEnergyPairsTitle,"beta",sample_B_Analysis.gasSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.gasStruct;
for(int i=0;i<struct.b_record_count;i++){
analysisLog.append(rowFormat(format,struct.b_channel.get(i).toString(),struct.b_electron_energy.get(i).toString() + unit_kev,struct.b_uncertainty.get(i).toString()));
if(i < struct.b_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(detEnergyPairsTitle,"gamma",sample_B_Analysis.gasSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<struct.g_record_count;i++){
analysisLog.append(rowFormat(format,struct.g_centroid_channel.get(i).toString(),struct.g_energy.get(i).toString(),struct.g_uncertainty.get(i).toString()));
if(i < struct.g_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading mesurement information.....
*/
private void readingMesurementInformation(){
final String title = "Reading mesurement information.....";
final String liveSec = "Acquisition_live_sec[s] : %s";
final String realSec = "Acquisition_real_sec[s] : %s";
final String collTime = "Collection time[s] : %s";
final String gas_acq_liveSec = "GASBK Spectrum acquisition_live_sec[s] : %s";
final String gas_acq_realSec = "GASBK Spectrum acquisition_real_sec[s] : %s";
final String det_acq_liveSec = "DETBK Spectrum acquisition_live_sec[s] : %s";
final String det_acq_realSec = "DETBK Spectrum acquisition_real_sec[s] : %s";
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(liveSec,String.valueOf(sample_B_Analysis.sampleStruct.acquisition_live_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(realSec,String.valueOf(sample_B_Analysis.sampleStruct.acquisition_real_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(collTime,String.valueOf(sample_B_Analysis.sampleStruct.collection_start_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(gas_acq_liveSec,String.valueOf(sample_B_Analysis.gasStruct.acquisition_live_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(gas_acq_realSec,String.valueOf(sample_B_Analysis.gasStruct.acquisition_real_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(det_acq_liveSec,String.valueOf(sample_B_Analysis.detStruct.acquisition_live_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(det_acq_realSec,String.valueOf(sample_B_Analysis.detStruct.acquisition_real_time)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading volume data.....
*/
private void readingVolumeData(){
final String title = "Reading volume data.....";
final String xe_volume = "XE volume[ml] : %s";
final String air_volume = "Air volume[m3] : %s";
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(xe_volume,String.valueOf(sample_B_Analysis.sampleStruct.sample_volume_of_Xe)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(rowFormat(air_volume,String.valueOf(sample_B_Analysis.detStruct.air_volume)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading ROI limits.....
*/
private void reading_roi_limits(){
final String title = "Reading ROI limits.....";
String format = "ROI : %-6s Beta : %-26s Gamma : %s";
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
for(int i=0;i<struct.roi_record_count;i++){
String beta = struct.POI_B_x1.get(i) + to_flag +struct.POI_B_x2.get(i);
String gamma = struct.POI_G_y1.get(i) + to_flag +struct.POI_G_y2.get(i);
analysisLog.append(rowFormat(format,struct.ROI_number.get(i),beta,gamma));
if(i<struct.roi_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading ROI ratios.....
*/
private void reading_roi_ratios(){
final String title = "Reading ROI ratios.....";
String format = "Interference between ROI : %-12s Ratio : %-12s Error : %s";
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
for(int i=0;i<struct.ratio_record_count;i++){
String interference = struct.ROI_num_highter_G_energy_ROI.get(i) + and_flag +struct.ROI_num_lower_G_energy_ROI.get(i);
String ratio = String.valueOf(struct.count_ratio.get(i));
String error = String.valueOf(struct.count_ratio_uncertainty.get(i));
analysisLog.append(rowFormat(format,interference,ratio,error));
if(i<struct.ratio_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Reading b-g Efficiency.....
*/
private void reading_B_G_Efficiency(){
final String title = "Reading b-g Efficiency.....";
final String format = "ROI : %-6s Efficiency : %-12s Error : %s";
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
EnergySpectrumStruct struct = sample_B_Analysis.sampleStruct;
for(int i=0;i<struct.bg_record_count;i++){
String roi = String.valueOf(struct.bg_ROI_number.get(i).intValue());
String efficiency = String.valueOf(struct.bg_efficiency.get(i));
String error = String.valueOf(struct.bg_uncertainty.get(i));
analysisLog.append(rowFormat(format,roi,efficiency,error));
if(i<struct.bg_record_count-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Starting NCC analysis
*/
private void NCC_analysis(){
final String loadNCC = "%s load NCC related data finished %s";
final String startNcc = "%s Starting NCC analysis %s";
final String endNcc = "%s NCC analysis finished %s";
analysisLog.append(titleFormat(loadNCC,35,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(startNcc,39,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
this.sampleEnergyPairCalibration();
this.sample_limits_per_ROI();
this.gasEnergyPairCalibration();
this.gas_limits_per_ROI();
this.detEnergyPairCalibration();
this.det_limits_per_ROI();
this.gross_counts_per_roi();
this.net_counts_per_roi();
this.coll_MDC_per_roi();
this.coll_MDC_per_isotope();
analysisLog.append(titleFormat(endNcc,40,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Sample energy pair calibration
*/
private void sampleEnergyPairCalibration(){
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
final String ch = "energy to channel equation: CH(x) = %s";
final String ex = "channel to energy equation: E(x) = %s";
final String endTitle = "%s energy pair calibration finished %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
final String sampleId = sample_B_Analysis.sampleData.getSampleId().toString();
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Beta:");
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Gamma:");
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Sample Limits per ROI
*/
private void sample_limits_per_ROI(){
final String title = "Limits per ROI (SampleID:%s).....";
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<Integer> b_chan_start = analyseResult.S_ROI_B_Boundary_start;
List<Integer> b_chan_stop = analyseResult.S_ROI_B_Boundary_stop;
List<Integer> g_chan_start = analyseResult.S_ROI_G_Boundary_start;
List<Integer> g_chan_stop = analyseResult.S_ROI_G_Boundary_stop;
List<Integer> roi = analyseResult.S_ROI;
analysisLog.append(rowFormat(title,sample_B_Analysis.sampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
String channels = " channels";
for (int i=0;i<roi.size();i++){
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Gas energy pair calibration
*/
private void gasEnergyPairCalibration(){
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
final String ch = "energy to channel equation: CH(x) = %s";
final String ex = "channel to energy equation: E(x) = %s";
final String endTitle = "%s energy pair calibration finished %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
final String sampleId = sample_B_Analysis.gasSampleData.getSampleId().toString();
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Beta:");
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Gamma:");
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Gas Limits per ROI
*/
private void gas_limits_per_ROI(){
final String title = "Limits per ROI (SampleID:%s).....";
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<Integer> b_chan_start = analyseResult.G_ROI_B_Boundary_start;
List<Integer> b_chan_stop = analyseResult.G_ROI_B_Boundary_stop;
List<Integer> g_chan_start = analyseResult.G_ROI_G_Boundary_start;
List<Integer> g_chan_stop = analyseResult.G_ROI_G_Boundary_stop;
List<Integer> roi = analyseResult.G_ROI;
analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
String channels = " channels";
for (int i=0;i<roi.size();i++){
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Det energy pair calibration
*/
private void detEnergyPairCalibration(){
final String startTitle = "%s Starting energy pair calibration for (SampleID: %s) %s";
final String ch = "energy to channel equation: CH(x) = %s";
final String ex = "channel to energy equation: E(x) = %s";
final String endTitle = "%s energy pair calibration finished %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
final String sampleId = sample_B_Analysis.detSampleData.getSampleId().toString();
analysisLog.append(titleFormat(startTitle,22,StringConstant.DOT,sampleId,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Beta:");
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append("Gamma:");
analysisLog.append(rowFormat(ch,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c)));
analysisLog.append(System.lineSeparator());
analysisLog.append(rowFormat(ex,super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
analysisLog.append(titleFormat(endTitle,22,StringConstant.DOT,StringConstant.DOT));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Det Limits per ROI
*/
private void det_limits_per_ROI(){
final String title = "Limits per ROI (SampleID:%s).....";
final String format = "ROI : %-6s Beta : %-22s Gamma : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<Integer> b_chan_start = analyseResult.G_ROI_B_Boundary_start;
List<Integer> b_chan_stop = analyseResult.G_ROI_B_Boundary_stop;
List<Integer> g_chan_start = analyseResult.G_ROI_G_Boundary_start;
List<Integer> g_chan_stop = analyseResult.G_ROI_G_Boundary_stop;
List<Integer> roi = analyseResult.G_ROI;
analysisLog.append(rowFormat(title,sample_B_Analysis.gasSampleData.getSampleId().toString()));
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
String channels = " channels";
for (int i=0;i<roi.size();i++){
String beta = b_chan_start.get(i) + to_flag +b_chan_stop.get(i) + channels;
String gamma = g_chan_start.get(i) + to_flag +g_chan_stop.get(i);
analysisLog.append(rowFormat(format,roi.get(i).toString(),beta,gamma));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Gross counts per ROI.....
*/
private void gross_counts_per_roi(){
final String title = "Gross counts per ROI.....";
final String format = "ROI : %-6s Sample : %-14s GasBkgnd : %-14s DetBkgnd : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for (int i=0;i<roi.size();i++){
analysisLog.append(rowFormat(format,roi.get(i),s_roi_cts.get(i),g_roi_cts.get(i),d_roi_cts.get(i)));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Net counts and Lc per ROI.....
*/
private void net_counts_per_roi(){
final String title = "Net counts and Lc per ROI.....";
final String format = "ROI : %-6s Net count : %-25s LC : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<Double> roi_net_count = analyseResult.ROI_net_coutns;
List<Double> roi_net_count_err = analyseResult.ROI_net_coutns_err;
List<String> roi = analyseResult.ROI.stream().map(String::valueOf).collect(Collectors.toList());
//此参数需第一位补0
analyseResult.LC_CTS.add(0,0D);
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<roi.size();i++){
String netCountStr = super.formatToStr5(roi_net_count.get(i)) + arithmetic_flag + super.formatToStr5(roi_net_count_err.get(i));
analysisLog.append(rowFormat(format,roi.get(i),netCountStr,lc.get(i)));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Concentration and MDC per ROI.....
*/
private void coll_MDC_per_roi(){
final String title = "Concentration and MDC per ROI.....";
final String format = "ROI : %-6s Conc : %-31s LC : %-19s MDC : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
List<String> con = analyseResult.ROI_con_uncer.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> conErr = analyseResult.ROI_con_uncer_err.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
analyseResult.LC.add(0,0.0D);
analyseResult.MDC.add(0,0.0D);
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<roi.size();i++){
String concc = con.get(i) + arithmetic_flag + conErr.get(i) + unit_mbq;
analysisLog.append(rowFormat(format,roi.get(i),concc,lc.get(i) + unit_mbq,mdc.get(i) + unit_mbq));
if(i<roi.size()-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
/**
* Concentration and MDC per isotope.....
*/
private void coll_MDC_per_isotope(){
final String title = "Concentration and MDC per isotope.....";
final String format = "%-10s Conc : %-32s LC : %-19s MDC : %-19s Nid flag : %s";
BgAnalyseResult analyseResult = sample_B_Analysis.analyseResult;
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer) + unit_mbq,
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer) + unit_mbq,
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer) + unit_mbq,
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer) + unit_mbq};
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe131m) + unit_mbq,
super.formatToStr5(analyseResult.LC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.LC_Xe133) + unit_mbq};
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe131m) + unit_mbq,
super.formatToStr5(analyseResult.MDC_Xe133m) + unit_mbq,super.formatToStr5(analyseResult.MDC_Xe133) + unit_mbq};
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
String xe_133m_nid_flag = analyseResult.Xe133m_con>analyseResult.MDC_Xe133m?"1":"0";
String xe_133_nid_flag = analyseResult.Xe133_con>analyseResult.MDC_Xe133?"1":"0";
String[] nid_flag = {xe_135_nid_flag,xe_131m_nid_flag,xe_133m_nid_flag,xe_133_nid_flag};
analysisLog.append(title);
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
for(int i=0;i<nuclideName.length;i++){
analysisLog.append(rowFormat(format,nuclideName[i],conc[i],uncertainty[i],mdc[i],nid_flag[i]));
if(i<nuclideName.length-1){
analysisLog.append(System.lineSeparator()).append(System.lineSeparator());
}
}
analysisLog.append(System.lineSeparator()).append(System.lineSeparator()).append(System.lineSeparator());
}
}
/**
* 开始存储流程日志
* 处理存储流程日志
* @return
*/
protected void storageProcessLogStart(){
this.processLog = new StorageProcessLog();
this.processLog.start();
private void handleStorageProcessLog(){
this.storageProcessLog = new StorageProcessLog();
this.storageProcessLog.handleStorageProcessLog();
}
/**
* 结束存储流程日志
* 处理分析流程日志
* @return
*/
protected void storageProcessLogEnd(){
if(this.logStoreEndFlag == false){
this.processLog.end();
this.logStoreEndFlag = true;
this.saveLogToFTP();
}
private void handleAnalysisProcessLog(){
this.analyseProcessLog = new AnalyseProcessLog();
this.analyseProcessLog.handleAnalysisProcessLog();
}
/**
* 文件重复异常结束存储流程日志
* 处理所有日志
*/
protected void endOfFileRepeat(){
if(this.logStoreEndFlag == false){
this.processLog.endOfFileRepeat();
this.logStoreEndFlag = true;
this.saveLogToFTP();
protected void handleLog(){
this.handleStorageProcessLog();
if(DataType.SAMPLEPHD.getType().equals(this.spectrumHandler.currDataType.getType()) &&
this.spectrumHandler.sourceData.system_type.equals(SystemType.BETA.getType()) &&
this.fileRepeat == false){
this.handleAnalysisProcessLog();
}
if(Objects.nonNull(this.analysisLog)){
this.storageLog.append(this.analysisLog);
}
this.saveLogToFTP(this.storageLog.toString());
}
/**
* 保存日志到ftp
*/
private void saveLogToFTP(){
private void saveLogToFTP(String log){
//保存日志文件到ftp
final SpectrumPathProperties properties = spectrumHandler.spectrumServiceQuotes.getSpectrumPathProperties();
spectrumHandler.logFilePath = spectrumHandler.getFileSavePath();
spectrumHandler.logFileName = spectrumHandler.mailFile.getName().replace(spectrumHandler.currDataType.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
String logFilePath = properties.getLogPath()+StringConstant.SLASH+spectrumHandler.getFileSavePath();
String logFileName = spectrumHandler.mailFile.getName().replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
spectrumHandler.ftpUtil.saveOrAppendFile(properties.getLogPath()+StringConstant.SLASH+spectrumHandler.logFilePath,spectrumHandler.logFileName,new ByteArrayInputStream(log.toString().getBytes(StandardCharsets.UTF_8)));
}
public static void main(String[] args) {
ParsingProcessLog s = new ParsingProcessLog();
s.storageProcessLogStart();
s.endOfFileRepeat();
System.out.println(s.log.toString());
spectrumHandler.ftpUtil.saveOrAppendFile(logFilePath,logFileName,new ByteArrayInputStream(log.getBytes(StandardCharsets.UTF_8)));
}
/**

View File

@ -1,6 +1,8 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.SampleStatus;
import java.util.Objects;
/**
* QC谱处理
@ -29,6 +31,8 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
try{
//前置检查
this.preCheck();
//声明日志处理对象
super.initLogObj();
//打印当前处理的能谱类型
super.printCurrDataType();
//解析邮件内容
@ -39,17 +43,21 @@ public class QcphdSpectrum extends S_D_Q_G_SpectrumHandler{
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//处理流程日志
super.handleProcessLog();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
}catch (Exception e){
//异常结束日志
super.exceptionEndLog(e);
//修改状态为解析失败
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到ftp->undeal目录
super.handleParseingFailFile();
throw e;
}finally {
//结束流程日志
super.storageProcessLogEnd();
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}

View File

@ -9,6 +9,7 @@ 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.enums.DataType;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.exception.AcquisitionBlockException;
import org.jeecg.modules.exception.FileRepeatException;
@ -51,18 +52,14 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
* 基础数据
*/
protected GardsSampleData sampleData;
/**
* 日志文件路径
*/
protected String logFilePath;
/**
* 日志文件名称
*/
protected String logFileName;
/**
* 流程日志对象
*/
protected ParsingProcessLog parsingProcessLog;
/**
* 能谱文件处理状态默认为未处理
*/
protected String status = SampleStatus.UNTREATED.getValue();
/**
* 前置检查
@ -211,13 +208,15 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
if(Objects.nonNull(query)){
this.sampleData = query;
this.endIntoDatabaseTime = new Date();
//设置文件重复标记为true
this.parsingProcessLog.setFileRepeat(true);
throw new FileRepeatException("file repeat");
}
DataSourceSwitcher.switchToOracle();
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
try{
//存储基础数据
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath);
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.ftpSavePath,status);
//存储其他块数据
for(String labels : spectrumFileLabels){
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
@ -237,6 +236,22 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
}
}
/**
* 修改解析状态
*/
protected void updateStatus(){
this.spectrumServiceQuotes.getSampleDataService().updateStatus(this.status,this.sampleData.getInputFileName());
}
/**
* 声明日志处理对象
*/
protected void initLogObj(){
ParsingProcessLog parsingProcessLog = new ParsingProcessLog();
parsingProcessLog.setSpectrumHandler(this);
this.parsingProcessLog = parsingProcessLog;
}
/**
* 获取项目绝对路径
* @return
@ -268,33 +283,4 @@ public abstract class S_D_Q_G_SpectrumHandler extends SpectrumHandler{
}
return Strings.EMPTY;
}
/**
* 创建流程日志对象处理解析流程日志
*/
protected void handleProcessLog(){
ParsingProcessLog parsingProcessLog = new ParsingProcessLog();
parsingProcessLog.setSpectrumHandler(this);
parsingProcessLog.storageProcessLogStart();
this.parsingProcessLog = parsingProcessLog;
}
/**
* 异常结束日志
* @param e
*/
protected void exceptionEndLog(Exception e){
if(e instanceof FileRepeatException){
this.parsingProcessLog.endOfFileRepeat();
}
}
/**
* 正常结束日志
*/
protected void storageProcessLogEnd(){
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.storageProcessLogEnd();
}
}
}

View File

@ -12,7 +12,6 @@ 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.FittingEquation;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
import org.jeecg.modules.exception.BAnalyseException;
@ -40,38 +39,30 @@ public class Sample_B_Analysis implements BlockConstant {
*/
private static final String ARR_FILE_SUFFIX = ".txt";
private static final String ARR_FILE_NAME_TAIL = "_rpt";
/**
* 正常分析过程日志
*/
private StringBuilder analysesLog = new StringBuilder();
/**
* 分析过程当前状态
*/
private String currAnalysesStatus = null;
/**
* Sample谱结构体数据
*/
private EnergySpectrumStruct sampleStruct = null;
protected EnergySpectrumStruct sampleStruct = null;
/**
* sample谱原始数据
*/
private GardsSampleData sampleData = null;
protected GardsSampleData sampleData = null;
/**
* gas谱结构体数据
*/
private EnergySpectrumStruct gasStruct = null;
protected EnergySpectrumStruct gasStruct = null;
/**
* gas谱原始数据
*/
private GardsSampleData detSampleData = null;
protected GardsSampleData detSampleData = null;
/**
* det谱结构体数据
*/
private EnergySpectrumStruct detStruct = null;
protected EnergySpectrumStruct detStruct = null;
/**
* det谱原始数据
*/
private GardsSampleData gasSampleData = null;
protected GardsSampleData gasSampleData = null;
/**
* sample谱PHD文件临时路径
*/
@ -84,6 +75,15 @@ public class Sample_B_Analysis implements BlockConstant {
* gas谱PHD文件临时路径
*/
private String gasTempFilePath;
/**
* SamplephdSpectrum类->saveFileToFtp()构造的能谱文件ftp保存路径
* 可根据此路径构造log和arr保存路径
*/
protected String ftpSavePath;
/**
* SamplephdSpectrum类->updateSpectrumFileName()构造的能谱文件名称 可根据此路径构造log和arr文件名称
*/
protected String phdFileName;
/**
* 日志文件路径
*/
@ -111,7 +111,7 @@ public class Sample_B_Analysis implements BlockConstant {
/**
* 分析结果
*/
private BgAnalyseResult analyseResult;
protected BgAnalyseResult analyseResult;
/**
* 开始分析时间
*/
@ -120,32 +120,45 @@ public class Sample_B_Analysis implements BlockConstant {
* 结束分析时间
*/
protected Date endAnalysisTime;
/**
* 分析基础数据
*/
protected GardsAnalyses analyses;
/**
* 流程日志对象
*/
protected ParsingProcessLog parsingProcessLog;
public Sample_B_Analysis() {
}
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 Sample_B_Analysis(S_D_Q_G_SpectrumHandler spectrumHandler){
this.sampleData = spectrumHandler.sampleData;
this.sampleTempFilePath = spectrumHandler.mailFile.getAbsolutePath();
this.spectrumServiceQuotes = spectrumHandler.spectrumServiceQuotes;
this.sampleStruct = spectrumHandler.sourceData;
this.ftpUtil = spectrumHandler.ftpUtil;
this.parsingProcessLog = spectrumHandler.parsingProcessLog;
this.ftpSavePath = spectrumHandler.getFileSavePath();
this.phdFileName = spectrumHandler.mailFile.getName();
}
/**
* 执行解析过程
*/
public void start() throws BAnalyseException {
//标记整个分析过程是否分析失败
boolean analyseFail = false;
try{
//修改状态为分析中
this.updateStatus(SampleStatus.IN_PROCESS.getValue());
this.startAnalysisTime = new Date();
//声明分析日志对象
parsingProcessLog.setSample_B_Analysis(this);
//查询detgas数据sampleId,inputFileNamesample数据在构造函数已经传过来
this.queryPHDFile();
//构造报告文件存储路径及文件名称日志文件存储路径及文件名称在原始库存储阶段已存在已经传过来
this.structureArrFilePath();
//构造报告文件存储路径及文件名称日志文件存储路径及文件名称
this.structureLogAndArrFilePath();
//下载det和gas谱PHD文件sample谱PHD文件位置在构造函数已经传过来
this.downloadPHDFile();
//传入sampledet和gas谱PHD文件调用dll进行分析
@ -155,41 +168,35 @@ public class Sample_B_Analysis implements BlockConstant {
//生成报告
Sample_B_Analysis.B_AnalysisReport report = new Sample_B_Analysis.B_AnalysisReport();
report.start();
//修改状态为分析成功
this.updateStatus(SampleStatus.COMPLETE.getValue());
}catch (Exception e){
//修改状态为分析失败
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
analyseFail = true;
e.printStackTrace();
throw new BAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
}finally {
this.endAnalysisTime = new Date();
//如果分析成功并且analyses对象不为空
if(!analyseFail && Objects.nonNull(this.analyses)){
spectrumServiceQuotes.getAnalysesService().updateAnalysesEndTime(this.analyses.getIdAnalysis(),this.endAnalysisTime);
}
//删除下载的det和gas临时文件
this.deleteLocalTemporaryFile();
}
}
/**
* 修改状态
* @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能谱文
//查询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.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
parsingProcessLog.setFileNotExist(true);
this.spectrumServiceQuotes.getSampleDataService().updateStatus(SampleStatus.FAIL.getValue(),this.sampleData.getInputFileName());
throw new FileNotExistException("gas or det file is no exist or is error..");
}
}
@ -197,41 +204,31 @@ public class Sample_B_Analysis implements BlockConstant {
/**
* 创建报告文件路径
*/
private void structureArrFilePath(){
//处理此文件需要保存到ftp服务的路径
//measurement_id切割后的字符数组
String[] arr = this.sampleStruct.measurement_id.split(StringConstant.DASH);
//切割后第一个元素是年第二个是月
final String[] yearMonth = arr[1].split(StringConstant.SLASH);
private void structureLogAndArrFilePath(){
final SpectrumPathProperties properties = this.spectrumServiceQuotes.getSpectrumPathProperties();
//构造报告文件路径
StringBuilder ftpPath = new StringBuilder();
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(yearMonth[0]);
ftpPath.append(StringConstant.SLASH);
ftpPath.append(yearMonth[1]);
ftpPath.append(this.ftpSavePath);
this.arrFilePath = ftpPath.toString();
String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX;
String sourceFileName = this.sampleData.getInputFileName().substring(this.sampleData.getInputFileName().lastIndexOf(StringConstant.SLASH)+1);
this.arrFileName = sourceFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail);
this.arrFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail);
//构造日志文件路径
this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.ftpSavePath;
this.logFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
}
/**
* 调用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) || !analyseResult.analyse_flag){
throw new BAnalyseException("THE PHD file cannot be parsed:"+this.sampleTempFilePath+","+this.gasTempFilePath+","+this.detTempFilePath);
}
@ -263,10 +260,11 @@ public class Sample_B_Analysis implements BlockConstant {
detTempFilePath = this.spectrumServiceQuotes.getTaskProperties().getTemporaryStoragePath()+ File.separator+detFileName;
if(flag){
parsingProcessLog.setFileNotExist(true);
throw new FileNotExistException("gas or det file is no exist or is error..");
}
this.detStruct = EnergySpectrumHandler.getSourceData(detSampleData.getInputFileName());
this.gasStruct = EnergySpectrumHandler.getSourceData(gasSampleData.getInputFileName());
this.detStruct = EnergySpectrumHandler.getSourceData(detTempFilePath);
this.gasStruct = EnergySpectrumHandler.getSourceData(gasTempFilePath);
}
/**
@ -285,7 +283,7 @@ public class Sample_B_Analysis implements BlockConstant {
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
try{
//存储基础数据
final GardsAnalyses analyses = spectrumServiceQuotes.getAnalysesService().create(this.sampleData.getSampleId(),this.detSampleData,
this.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块数据
@ -309,6 +307,8 @@ public class Sample_B_Analysis implements BlockConstant {
//提交事务
spectrumServiceQuotes.getTransactionManager().commit(transactionStatus);
}catch (Exception e){
//设置分析数据存储失败标记
this.parsingProcessLog.setAnalysisDataStoreFlag(false);
//回滚事务
spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus);
throw e;
@ -343,7 +343,7 @@ public class Sample_B_Analysis implements BlockConstant {
/**
* B谱分析报告
*/
private class B_AnalysisReport{
private class B_AnalysisReport extends AbstractLogOrReport{
/**
* 模版内容
*/
@ -483,10 +483,10 @@ public class Sample_B_Analysis implements BlockConstant {
*/
private void handleSampleCalibration() throws IOException {
String[] betaArr = {CH_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_e_c),
E_Contant+this.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
E_Contant+super.calibration(analyseResult.s_b_fitting_type,analyseResult.s_b_fitting_c_e)};
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_e_c),
E_Contant+this.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
E_Contant+super.calibration(analyseResult.s_g_fitting_type,analyseResult.s_g_fitting_c_e)};
this.handleTwoParamFormat("#SAMPLE CALIBRATION",betaArr,gammaArr);
}
@ -515,10 +515,10 @@ public class Sample_B_Analysis implements BlockConstant {
* 处理#DET CALIBRATION 模块
*/
private void handleDetCalibration() throws IOException {
String[] betaArr = {CH_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
String[] betaArr = {CH_Contant+super.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_e_c),
E_Contant+this.calibration(analyseResult.d_b_fitting_type,analyseResult.d_b_fitting_c_e)};
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
String[] gammaArr = {CH_Contant+super.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_e_c),
E_Contant+this.calibration(analyseResult.d_g_fitting_type,analyseResult.d_g_fitting_c_e)};
this.handleTwoParamFormat("#DET CALIBRATION",betaArr,gammaArr);
@ -549,10 +549,10 @@ public class Sample_B_Analysis implements BlockConstant {
*/
private void handleGasCalibration() throws IOException {
String[] betaArr = {CH_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_e_c),
E_Contant+this.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
E_Contant+super.calibration(analyseResult.g_b_fitting_type,analyseResult.g_b_fitting_c_e)};
String[] gammaArr = {CH_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_e_c),
E_Contant+this.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
E_Contant+super.calibration(analyseResult.g_g_fitting_type,analyseResult.g_g_fitting_c_e)};
this.handleTwoParamFormat("#GAS CALIBRATION",betaArr,gammaArr);
}
@ -569,10 +569,9 @@ public class Sample_B_Analysis implements BlockConstant {
List<String> roi = analyseResult.G_ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> beta = Lists.newArrayList();
List<String> gamma = Lists.newArrayList();
String flag = " to ";
for(int i=0;i<roi.size();i++){
beta.add(b_chan_start.get(i)+flag+b_chan_stop.get(i));
gamma.add(g_chan_start.get(i)+flag+g_chan_stop.get(i));
beta.add(b_chan_start.get(i)+to_flag+b_chan_stop.get(i));
gamma.add(g_chan_start.get(i)+to_flag+g_chan_stop.get(i));
}
handleThreeParamFormat("#GAS LIMITS PER ROI",roi,beta,gamma);
}
@ -582,9 +581,9 @@ public class Sample_B_Analysis implements BlockConstant {
*/
private void handleGrossCounts() throws IOException {
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
this.handleFourParamFormat("#GROSS COUNTS PER ROI",roi,s_roi_cts,g_roi_cts,d_roi_cts);
}
@ -599,11 +598,10 @@ public class Sample_B_Analysis implements BlockConstant {
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
//此参数需第一位补0
analyseResult.LC_CTS.add(0,0D);
List<String> lc = analyseResult.LC_CTS.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> netCount = Lists.newArrayList();
String flag = " +/- ";
for(int i=0;i<roi.size();i++){
netCount.add(formatToStr5(roi_net_count.get(i))+flag+formatToStr5(roi_net_count_err.get(i)));
netCount.add(super.formatToStr5(roi_net_count.get(i))+arithmetic_flag+super.formatToStr5(roi_net_count_err.get(i)));
}
this.handleThreeParamFormat("#NET COUNTS AND LC PER ROI",roi,netCount,lc);
}
@ -615,16 +613,13 @@ public class Sample_B_Analysis implements BlockConstant {
List<Double> con = analyseResult.ROI_con_uncer;
List<Double> conErr = analyseResult.ROI_con_uncer_err;
analyseResult.LC.add(0,0.0D);
String flag = " +/- ";
analyseResult.MDC.add(0,0.0D);
List<String> roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList());
List<String> lc = analyseResult.LC.stream().map(v->formatToStr5(v)).collect(Collectors.toList());
List<String> mdc = Lists.newArrayList();//analyseResult.MDC.stream().map(Object::toString).collect(Collectors.toList());
for(int i=0;i<10;i++){
mdc.add("0.0");
}
List<String> lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList());
List<String> conc = Lists.newArrayList();
for(int i=0;i<roi.size();i++){
conc.add(formatToStr5(con.get(i))+flag+formatToStr5(conErr.get(i)));
conc.add(super.formatToStr5(con.get(i))+arithmetic_flag+super.formatToStr5(conErr.get(i)));
}
this.handleFourParamFormat("#CONCENTRATION AND LC PER ROI",roi,conc,lc,mdc);
}
@ -633,19 +628,18 @@ public class Sample_B_Analysis implements BlockConstant {
* #RESULT SUMMARY
*/
private void handleResultSummary() throws IOException {
String flag = " +/- ";
String[] nuclideName = {XE_135,XE_131m,XE_133m,XE_133};
String[] conc = {formatToStr5(analyseResult.Xe135_con)+flag+formatToStr5(analyseResult.Xe135_uncer),
formatToStr5(analyseResult.Xe131m_con)+flag+formatToStr5(analyseResult.Xe131m_uncer),
formatToStr5(analyseResult.Xe133m_con)+flag+formatToStr5(analyseResult.Xe133m_uncer),
formatToStr5(analyseResult.Xe133_con)+flag+formatToStr5(analyseResult.Xe133_uncer)};
String[] conc = {super.formatToStr5(analyseResult.Xe135_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe135_uncer),
super.formatToStr5(analyseResult.Xe131m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe131m_uncer),
super.formatToStr5(analyseResult.Xe133m_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133m_uncer),
super.formatToStr5(analyseResult.Xe133_con) + arithmetic_flag + super.formatToStr5(analyseResult.Xe133_uncer)};
String[] uncertainty = {formatToStr5(analyseResult.LC_Xe135),formatToStr5(analyseResult.LC_Xe131m),
formatToStr5(analyseResult.LC_Xe133m),formatToStr5(analyseResult.LC_Xe133)};
String[] uncertainty = {super.formatToStr5(analyseResult.LC_Xe135),super.formatToStr5(analyseResult.LC_Xe131m),
super.formatToStr5(analyseResult.LC_Xe133m),super.formatToStr5(analyseResult.LC_Xe133)};
String[] mdc = {formatToStr5(analyseResult.MDC_Xe135),formatToStr5(analyseResult.MDC_Xe131m),
formatToStr5(analyseResult.MDC_Xe133m),formatToStr5(analyseResult.MDC_Xe133)};
String[] mdc = {super.formatToStr5(analyseResult.MDC_Xe135),super.formatToStr5(analyseResult.MDC_Xe131m),
super.formatToStr5(analyseResult.MDC_Xe133m),super.formatToStr5(analyseResult.MDC_Xe133)};
String xe_135_nid_flag = analyseResult.Xe135_con>analyseResult.MDC_Xe135?"1":"0";
String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0";
@ -664,46 +658,6 @@ public class Sample_B_Analysis implements BlockConstant {
this.reportTmpFile.delete();
}
/**
* 获取samplegasdet谱Beta和Gamma的CH(x)E(x)
* @return
*/
private String calibration(Integer fitting_type, List<Double> fitting_e_c){
String b_fittingEquation = this.getFittingEquation(fitting_type);
for(int i=0;i<fitting_e_c.size();i++){
b_fittingEquation = b_fittingEquation.replace("?"+(i+1),formatToStr6(fitting_e_c.get(i)));
}
return b_fittingEquation;
}
/**
* 获取适合的方程
* @return
*/
private String getFittingEquation(Integer type){
String rData = null;
switch (type) {
case 1:
rData = FittingEquation.LINER.getDescription();
break;
case 2:
rData = FittingEquation.POLY2.getDescription();
break;
case 3:
rData = FittingEquation.POLY3.getDescription();
break;
case 4:
rData = FittingEquation.GAUSS.getDescription();
break;
case 0:
rData = FittingEquation.DEFAULT.getDescription();
break;
default:
break;
}
return rData;
}
/**
* 处理两个参数的占位符格式化
* 1.#SAMPLE CALIBRATION 模块
@ -811,51 +765,6 @@ public class Sample_B_Analysis implements BlockConstant {
this.reportTmpFile = FileUtil.writeLines(lines,this.reportTmpFile,"utf-8");
}
/**
* 格式化值
* @param source
* @return
*/
private String formatToStr5(Double source){
return String.format("%.5f",source);
}
/**
* 格式化值
* @param source
* @return
*/
private String formatToStr6(Double source){
return String.format("%.6f",source);
}
}
public static void main(String[] args) throws IOException {
Resource resource = new ClassPathResource("template/b_report_template.txt");
final File file = resource.getFile();
// String templateContent = FileUtil.readUtf8String(resource.getFile());
final List<String> lines = FileUtils.readLines(file, "utf-8");
String[] betaArr = {"CH(x) = (-3.33443)+(0.398048)*x+(-0.000124015)x*x","E(x) = (12.0809)+(2.39764)*x+(0.00331138)x*x"};
String[] gammaArr = {"CH(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x","E(x) = (0.879727)+(0.365551)*x+(-2.82212e-05)x*x"};
for(int i=0;i<lines.size();i++){
if(lines.get(i).startsWith("#SAMPLE CALIBRATION")){
//i+1行是行头
//i+2行是占位符所以要删除i+2行返回行格式
final String format = lines.remove(i+2);
for(int j=0;j<betaArr.length;j++){
String copyFormat = new String(format);
StringBuilder line = new StringBuilder();
line.append(String.format(copyFormat,betaArr[j],gammaArr[j]));
//i+2行是占位符已经删除此时添加数据应从i+1行开始
lines.add((i+1+j+1),line.toString());
}
break;
}
}
File localFile = new File("E:\\file\\1.txt");
FileUtil.writeLines(lines,localFile,"utf-8");
}
}

View File

@ -289,7 +289,7 @@ public class Sample_G_Analysis {
infoMap.put("ECutAnalysis_High", middleData.setting_specSetup.getECutAnalysis_High());
infoMap.put("EnergyTolerance", middleData.setting_specSetup.getEnergyTolerance());
infoMap.put("BaseImprovePSS", middleData.setting_specSetup.getBaseImprovePSS());
infoMap.put("PSS_low", middleData.setting_specSetup.getPSS_low());
infoMap.put("PSS_low", middleData.setting_specSetup.getPss_low());
infoMap.put("k_back", middleData.setting_specSetup.getK_back());
infoMap.put("k_alpha", middleData.setting_specSetup.getK_alpha());
infoMap.put("k_beta", middleData.setting_specSetup.getK_beta());
@ -779,7 +779,7 @@ public class Sample_G_Analysis {
setting.setK_beta(Double.parseDouble(k_beta));
String PSS_low = mapSetting.get(Setting.PSS_LOW);
if (StrUtil.isNotBlank(PSS_low))
setting.setPSS_low(Double.parseDouble(PSS_low));
setting.setPss_low(Double.parseDouble(PSS_low));
String RiskLevelK = mapSetting.get(Setting.RISKLEVELK);
if (StrUtil.isNotBlank(RiskLevelK))
setting.setRiskLevelK(Double.parseDouble(RiskLevelK));

View File

@ -1,7 +1,9 @@
package org.jeecg.modules.spectrum;
import org.jeecg.modules.base.enums.DataType;
import org.jeecg.modules.base.enums.SampleStatus;
import org.jeecg.modules.base.enums.SystemType;
import java.util.Objects;
/**
* 样品谱处理
@ -29,6 +31,8 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
try{
//前置检查
this.preCheck();
//声明日志处理对象
super.initLogObj();
//打印当前处理的能谱类型
super.printCurrDataType();
//解析邮件内容
@ -39,19 +43,24 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
super.saveFileToFtp();
//结构体数据入库
super.handlerOriginalData();
//处理流程日志
super.handleProcessLog();
//进行BG(P)谱分析
this.autoAnalysis();
//修改状态为解析完成
super.status = SampleStatus.COMPLETE.getValue();
super.updateStatus();
}catch (Exception e){
//异常结束日志
super.exceptionEndLog(e);
//修改状态为解析失败
super.status = SampleStatus.FAIL.getValue();
super.updateStatus();
//处理解析失败的文件上传到ftp->undeal目录
super.handleParseingFailFile();
throw e;
}finally {
//结束流程日志
super.storageProcessLogEnd();
if(Objects.nonNull(this.parsingProcessLog)){
this.parsingProcessLog.handleLog();
}
//删除本地临时文件
super.deleteLocalTemporaryFile();
}
@ -65,14 +74,16 @@ public class SamplephdSpectrum extends S_D_Q_G_SpectrumHandler{
* @throws Exception
*/
protected void autoAnalysis() throws Exception {
// if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
if(this.sourceData.system_type.equals(SystemType.BETA.getType())){
Sample_B_Analysis bAnalysis = new Sample_B_Analysis(this);
bAnalysis.start();
// Sample_B_Analysis bAnalysis = new Sample_B_Analysis(super.sampleData,super.mailFile.getAbsolutePath(),
// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.logFilePath,super.logFileName);
// super.spectrumServiceQuotes,super.sourceData,super.ftpUtil,super.parsingProcessLog);
// bAnalysis.start();
// }
if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) {
Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData);
sample_g_analysis.analysis();
}
// if (this.sourceData.system_type.equals(SystemType.GAMMA.getType())) {
// Sample_G_Analysis sample_g_analysis = new Sample_G_Analysis(super.sourceData, super.spectrumServiceQuotes, super.sampleData);
// sample_g_analysis.analysis();
// }
}
}

View File

@ -1,9 +1,14 @@
package org.jeecg.common.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.ejml.simple.SimpleMatrix;
import org.jeecg.common.api.vo.Result;
@ -21,6 +26,7 @@ import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@ -101,7 +107,7 @@ public class GammaFileUtil {
//Comment
phd.setOriTotalCmt(struct.comment);
//Collection
if (StringUtils.isNotBlank(struct.collection_start_date) || StringUtils.isNotBlank(struct.collection_start_time) || StringUtils.isNotBlank(struct.collection_stop_date) || StringUtils.isNotBlank(struct.collection_stop_time) || Objects.nonNull(struct.air_volume)) {
if (StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) && StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) {
phd.getCollect().setCollection_start_date(struct.collection_start_date);
phd.getCollect().setCollection_start_time(struct.collection_start_time);
phd.getCollect().setCollection_stop_date(struct.collection_stop_date);
@ -117,7 +123,7 @@ public class GammaFileUtil {
phd.getCollect().setAir_volume(0.0);
}
//Acquisition
if (StringUtils.isNotBlank(struct.acquisition_start_date) || StringUtils.isNotBlank(struct.acquisition_start_time) || Objects.nonNull(struct.acquisition_real_time) || Objects.nonNull(struct.acquisition_live_time)) {
if (StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) {
phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date);
phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time);
phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time);
@ -130,7 +136,7 @@ public class GammaFileUtil {
phd.getAcq().setAcquisition_real_time(0.0);
}
//Processing
if (Objects.nonNull(struct.sample_volume_of_Xe) || Objects.nonNull(struct.uncertainty_1) || Objects.nonNull(struct.Xe_collection_yield) || Objects.nonNull(struct.uncertainty_2) || StringUtils.isNotBlank(struct.archive_bottle_id)) {
if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && StringUtils.isNotBlank(struct.archive_bottle_id)) {
phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe);
phd.getProcess().setUncertainty_1(struct.uncertainty_1);
phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield);
@ -143,7 +149,7 @@ public class GammaFileUtil {
phd.getProcess().setUncertainty_2(0.0);
}
//Sample
if (Objects.nonNull(struct.dimension_1) || Objects.nonNull(struct.dimension_2)) {
if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) {
phd.getSampleBlock().setDimension_1(struct.dimension_1);
phd.getSampleBlock().setDimension_2(struct.dimension_2);
} else {
@ -151,14 +157,14 @@ public class GammaFileUtil {
phd.getSampleBlock().setDimension_2(0.0);
}
//Calibration
if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) {
if (StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)) {
phd.getCalibration().setDate_calibration(struct.date_calibration);
phd.getCalibration().setTime_calibration(struct.time_calibration);
}
//Certificate
if (Objects.nonNull(struct.total_source_activity) || StringUtils.isNotBlank(struct.assay_date) || StringUtils.isNotBlank(struct.assay_time) || StringUtils.isNotBlank(struct.units_activity) || CollectionUtils.isNotEmpty(struct.nuclide_name)
|| CollectionUtils.isNotEmpty(struct.half_life_time) || CollectionUtils.isNotEmpty(struct.time_unit) || CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) || CollectionUtils.isNotEmpty(struct.uncertainty)
|| CollectionUtils.isNotEmpty(struct.cer_g_energy) || CollectionUtils.isNotEmpty(struct.g_intensity) || CollectionUtils.isNotEmpty(struct.electron_decay_mode) || CollectionUtils.isNotEmpty(struct.maximum_energy) || CollectionUtils.isNotEmpty(struct.intensity_b_particle) || Objects.nonNull(struct.record_count)) {
if (Objects.nonNull(struct.total_source_activity) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name)
&& CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty)
&& CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) {
phd.getCertificate().setTotal_source_activity(struct.total_source_activity);
phd.getCertificate().setAssay_date(struct.assay_date);
phd.getCertificate().setAssay_time(struct.assay_time);
@ -176,7 +182,7 @@ public class GammaFileUtil {
phd.getCertificate().setRecord_count(struct.record_count);
}
//g_Spectrum
if (Objects.nonNull(struct.num_g_channel) || Objects.nonNull(struct.g_energy_span) || Objects.nonNull(struct.g_begin_channel) || CollectionUtils.isNotEmpty(struct.g_counts)) {
if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) {
phd.getSpec().setNum_g_channel(struct.num_g_channel);
phd.getSpec().setG_energy_span(struct.g_energy_span);
phd.getSpec().setBegin_channel(struct.g_begin_channel);
@ -192,7 +198,7 @@ public class GammaFileUtil {
}
}
//g_Energy
if (CollectionUtils.isNotEmpty(struct.g_energy) || CollectionUtils.isNotEmpty(struct.g_centroid_channel) || CollectionUtils.isNotEmpty(struct.g_uncertainty) || Objects.nonNull(struct.g_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) {
GEnergyBlock gEnergyBlock = new GEnergyBlock();
gEnergyBlock.setG_energy(struct.g_energy);
gEnergyBlock.setCentroid_channel(struct.g_centroid_channel);
@ -201,7 +207,7 @@ public class GammaFileUtil {
phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock);
}
//g_Resolution
if (CollectionUtils.isNotEmpty(struct.g_r_energy) || CollectionUtils.isNotEmpty(struct.g_r_FWHM) || CollectionUtils.isNotEmpty(struct.g_r_uncertainty) || Objects.nonNull(struct.g_r_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) {
GResolutionBlock gResolutionBlock = new GResolutionBlock();
gResolutionBlock.setG_energy(struct.g_r_energy);
gResolutionBlock.setFWHM(struct.g_r_FWHM);
@ -210,7 +216,7 @@ public class GammaFileUtil {
phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock);
}
//g_Efficiency
if (CollectionUtils.isNotEmpty(struct.g_e_energy) || CollectionUtils.isNotEmpty(struct.g_e_efficiency) || CollectionUtils.isNotEmpty(struct.g_e_uncertainty) || Objects.nonNull(struct.g_e_record_count)) {
if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) {
GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock();
gEfficiencyBlock.setG_energy(struct.g_e_energy);
gEfficiencyBlock.setEfficiency(struct.g_e_efficiency);
@ -219,7 +225,7 @@ public class GammaFileUtil {
phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock);
}
//TotalEff
if (CollectionUtils.isNotEmpty(struct.t_g_energy) || CollectionUtils.isNotEmpty(struct.total_efficiency) || CollectionUtils.isNotEmpty(struct.t_uncertainty) || Objects.nonNull(struct.t_record_count)) {
if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) {
TotaleffBlock totaleffBlock = new TotaleffBlock();
totaleffBlock.setG_energy(struct.t_g_energy);
totaleffBlock.setTotal_efficiency(struct.total_efficiency);
@ -235,7 +241,9 @@ public class GammaFileUtil {
}
phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"));
phd.setUsedSetting(phd.getSetting());
SpecSetup usedSetting = new SpecSetup();
BeanUtils.copyProperties(phd.getSetting(), usedSetting);
phd.setUsedSetting(usedSetting);
phd.setBAnalyed(false);
phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"));
@ -287,8 +295,11 @@ public class GammaFileUtil {
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
//调用FileUtils的readLines方法获取文件的所有行数据
List<String> readLines = FileUtils.readLines(file, "UTF-8");
//得到行数据处理后的数据结果
List<Double> vData = ReadLcScacInfo(readLines);
//将数据结果赋值给 phdFile的vLc
phd.setVLc(vData);
}
} catch (IOException e) {
@ -328,8 +339,11 @@ public class GammaFileUtil {
File file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
//调用FileUtils的readLines方法获取文件的所有行数据
List<String> readLines = FileUtils.readLines(file, "UTF-8");
//得到行数据处理后的数据结果
List<Double> vData = ReadLcScacInfo(readLines);
//将数据结果赋值给 phdFile的vScac
phd.setVScac(vData);
}
} catch (IOException e) {
@ -363,12 +377,12 @@ public class GammaFileUtil {
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
ftpClient.changeWorkingDirectory(pathName);
String baselineFileName = "RNAUTO_"+subFileName + ".baseline";
//获取ftp的文件流数据
inputStream = ftpClient.retrieveFileStream(baselineFileName);
if (Objects.nonNull(inputStream)){
long start = System.currentTimeMillis();
//调用处理BaseCtrl的方法
ReadBaseCtrlInfo(phd, inputStream);
long end = System.currentTimeMillis();
System.out.println(end-start);
//将phdFile的BaseCtrls的BaseLine部分数据 赋值给 phdFile的vBase
phd.setVBase(phd.getBaseCtrls().getBaseline());
}
} catch (IOException e) {
@ -389,32 +403,52 @@ public class GammaFileUtil {
}
public List<Double> ReadLcScacInfo(List<String> readLines) {
//声明一个结果集合
List<Double> vData = new LinkedList<>();
//遍历行数据
for (int i=0; i< readLines.size(); i++){
//读取当前行数据
String line = readLines.get(i);
//判断当前行是否包含# 如果包含则进入
if (line.contains("#")){
//声明下一行的下标
int j=i+1;
//读取当前行的下一行的数据
line = readLines.get(j);
//将下一行的数据赋给一个 新的行数据
String line1 = line;
//遍历判断 下标不是行数据的最后一行 行数据不为空
while (j != readLines.size()-1 && StringUtils.isNotBlank(line) ){
//行下标+1
j++;
//读取下一行数据
line = readLines.get(j);
//判断下一行数据是否包含#
if (!line.contains("#")){
//不包含#则将当前行数据 拼接到 行数据
line1 += StringPool.SPACE + line;
}else {
}else {//否则结束循环
break;
}
}
//所有行数据 去掉首位空位符
line1 = line1.trim();
//行数据根据任意形式空格切割成数组
List<String> strList = Arrays.asList(line1.split("\\s+"));
//如果数据量小于2 跳过本次循环 继续下一行读取
if(strList.size() < 2){
continue;
}
//遍历行数据数组
for(int k=1; k<strList.size(); k++) {
//如果数据不为空 数据不匹配任意大小写的nan
if (StringUtils.isNotBlank(strList.get(k)) && !strList.get(k).equalsIgnoreCase("nan")){
//数据转换成double形式 并存入返回结果数组中
double d = Double.valueOf(strList.get(k));
vData.add(d);
} else if (StringUtils.isNotBlank(strList.get(k)) && strList.get(k).equalsIgnoreCase("nan")) {
//如果数据不为空 数据匹配任意大小写的nan
//结果数组中补充0.0
vData.add(0.0);
}
}
@ -425,54 +459,91 @@ public class GammaFileUtil {
public void ReadBaseCtrlInfo(PHDFile phd, InputStream in) {
try {
//读取流数据
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
//声明行数据 字符串对象
String line ;
//声明标题名称对象
String block_name = null;
//声明一个map 按照标题名称 分别存储对应的数据集合
HashMap<String, List<Double>> map = new HashMap<>();
//判断当前行数据是否为空
while (null != (line = reader.readLine())) {
//如果当前行包含#
if (line.contains("#")) {
//将当前行数据去掉前后空字符并赋值给标题名称对象
block_name = line.trim();
//向map中加入当前标题名称 初始化集合信息
map.put(block_name, new LinkedList<>());
continue;
}
//根据当前标题名称读取集合数据
List<Double> data = map.get(block_name);
//对当前行数据使用任意空格符切割数据
String[] split = line.split("\\s+");
//遍历数组
for(String str : split) {
//如果当前当前数据不为空 数据不匹配任意大小写的nan
if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){
//当前数据转为double 存入到集合中
double d = Double.parseDouble(str);
data.add(d);
} else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) {
//如果当前数据不为空 数据匹配任意大小写的nan
//将0.0填充到 double中
data.add(0.0);
}
}
}
//判断map是否含有#AnalyseRange
if(map.containsKey("#AnalyseRange")) {
//根据#AnalyseRange获取对应的集合信息
List<Double> vTemp = map.get("#AnalyseRange");
//如果集合大小等于2
if(vTemp.size() == 2) {
//集合中第一个赋值给 phdFile的baseCtrls的rg_low
phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue());
//集合中第二个赋值给 phdFile的baseCtrls的rg_high
phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue());
}
}
//判断map是否含有#XCtrl
if(map.containsKey("#XCtrl")) {
//根据#XCtrl获取对应的集合信息
List<Double> vTemp = map.get("#XCtrl");
//将集合数据 赋值给 phdFile的BaseCtrls的xCtrl
phd.getBaseCtrls().setXCtrl(vTemp);
}
//判断map是否含有#YCtrl
if(map.containsKey("#YCtrl")) {
//根据#YCtrl获取集合信息
List<Double> vTemp = map.get("#YCtrl");
//将集合信息赋值给 phdFile的BaseCtrls的yCtrl
phd.getBaseCtrls().setYCtrl(vTemp);
}
//判断map是否含有#YSlope
if(map.containsKey("#YSlope")) {
//根据#YSlope获取集合信息
List<Double> vTemp = map.get("#YSlope");
//将集合信息赋值给 phdFile的BaseCtrls的ySlope
phd.getBaseCtrls().setYSlope(vTemp);
}
//判断map是否含有#Baseline
if(map.containsKey("#Baseline")) {
//根据#Baseline获取集合数据
List<Double> vTemp = map.get("#Baseline");
//截取集合 下标1到末尾的数据
List<Double> list = vTemp.subList(1, vTemp.size());
//将截取后的数据 赋值给 phdFile的BaseCtrls的Baseline
phd.getBaseCtrls().setBaseline(list);
}
//判断map是否含有#StepCounts
if(map.containsKey("#StepCounts")) {
//根据#StepCounts获取集合数据
List<Double> vTemp = map.get("#StepCounts");
//截取集合 下标1到末尾的数据
List<Double> list = vTemp.subList(1, vTemp.size());
//将截取后的数据 赋值给 phdFile的BaseCtrls
phd.getBaseCtrls().setStepCounts(list);
}
} catch (IOException e) {
@ -742,7 +813,7 @@ public class GammaFileUtil {
phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh());
phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow());
phd.getUsedSetting().setBaseImprovePSS(analySetting.getBaseimprovepss());
phd.getUsedSetting().setPSS_low(analySetting.getPssLow());
phd.getUsedSetting().setPss_low(analySetting.getPssLow());
phd.getUsedSetting().setK_back(analySetting.getKBack());
phd.getUsedSetting().setK_alpha(analySetting.getKAlpha());
phd.getUsedSetting().setK_beta(analySetting.getKBeta());
@ -778,26 +849,40 @@ public class GammaFileUtil {
public List<String> Qcstate(PHDFile phd) {
// Collection Time Acq Time Decay Time SampVol Be7-FWHM Ba140-MDC Xe133-MDC
List<String> qcState = new LinkedList<>();
//初始化七个状态颜色为 灰色
for (int i=0;i<7; i++){
qcState.add("GRAY");
}
//判断 phdFile下QcItems大小是否小于等于5
if(phd.getQcItems().size() <= 5) {
this.RunQC(phd);
//执行判断QC状态方法
RunQC(phd);
}
//判断 QcItems的col_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED
qcState.set(0, phd.getQcItems().get("col_time").isBPass()?"BLUE":"RED");
//判断 QcItems的acq_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED
qcState.set(1, phd.getQcItems().get("acq_time").isBPass()?"BLUE":"RED");
//判断 QcItems的decay_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED
qcState.set(2, phd.getQcItems().get("decay_time").isBPass()?"BLUE":"RED");
//判断 QcItems的samp_vol的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED
qcState.set(3, phd.getQcItems().get("samp_vol").isBPass()?"BLUE":"RED");
//判断当前文件系统类型是否匹配 P
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
//如果匹配P 判断 QcItems的Be7-FWHM数据是否为空
if(Objects.nonNull(phd.getQcItems().get("Be7-FWHM"))) {
//不为空 判断 QcItems的Be7-FWHM的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED
qcState.set(4, phd.getQcItems().get("Be7-FWHM").isBPass()?"BLUE":"RED");
}
//如果匹配P 判断 QcItems的Ba140-MDC数据是否为空
if(Objects.nonNull(phd.getQcItems().get("Ba140-MDC"))) {
//不为空 判断 QcItems的Ba140-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED
qcState.set(5, phd.getQcItems().get("Ba140-MDC").isBPass()?"BLUE":"RED");
}
} else if(phd.getHeader().getSystem_type().equalsIgnoreCase("G")) {
//判断当前文件系统类型是否匹配 G
//如果匹配G 判断 QcItems的Xe133-MDC数据是否为空
if(Objects.nonNull(phd.getQcItems().get("Xe133-MDC"))) {
//不为空 判断 QcItems的Xe133-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED
qcState.set(6, phd.getQcItems().get("Xe133-MDC").isBPass()?"BLUE":"RED");
}
}
@ -805,64 +890,99 @@ public class GammaFileUtil {
}
public void RunQC(PHDFile phd) {
//调用dll库
System.loadLibrary("GammaAnaly");
try {
//获取phdFile的 采集开始时间
Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time());
//获取phdFile的 采集结束时间
Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time());
//获取phdFile的 分析开始时间
Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time());
//计算得到采集耗时
double collect_hour = (end.getTime()/1000 - start.getTime()/1000) / 3600.0;
//获取 实际分析时长
double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0;
//计算得到衰减耗时
double Decay_hour = (acq.getTime()/1000 - end.getTime()/1000) / 3600.0;
//声明一个double数据
Double ener_Be7 = 0.0;
//声明一个map用于存储计算数据
Map<String, Double> vMdcInfoMap = new HashMap<>();
//声明一个数组存储计算数据
List<Double> vMdcInfo = new LinkedList<>();
//声明一个数组存储QcItems数据
Map<String, QcCheckItem> qcItems = new LinkedHashMap<>();
if(!this.ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) {
//调用方法 读取文件信息 判断QC数据
if(!ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) {
String WARNING = "Read QC Flags from SystemManager.xml Failed!";
}
//判断map是否为空
if (CollectionUtils.isNotEmpty(vMdcInfoMap)) {
//根据键值按顺序向数组中插入数据
vMdcInfo.add(vMdcInfoMap.get("0"));
vMdcInfo.add(vMdcInfoMap.get("1"));
vMdcInfo.add(vMdcInfoMap.get("2"));
}
//获取QcItem中col_time数据
QcCheckItem colTime = qcItems.get("col_time");
//将采集耗时 赋值给 colTime
colTime.setValue(collect_hour);
//将数据存入QcItems的map中
qcItems.put("col_time", colTime);
//获取QcItem中acq_time数据
QcCheckItem acqTime = qcItems.get("acq_time");
//将实际分析时长 赋值给 acqTime
acqTime.setValue(acq_hour);
//将数据存入QcItems的map中
qcItems.put("acq_time", acqTime);
//获取QcItem中decay_time数据
QcCheckItem decayTime = qcItems.get("decay_time");
//将衰减耗时 赋值给 decayTime
decayTime.setValue(Decay_hour);
//将数据存入QcItems的map中
qcItems.put("decay_time", decayTime);
//获取QcItem中samp_vol数据
QcCheckItem sampVol = qcItems.get("samp_vol");
//将phdFile的Collect的air_volume赋值给
sampVol.setValue(phd.getCollect().getAir_volume());
//将数据存入QcItems的map中
qcItems.put("samp_vol", sampVol);
//获取QcItem中decay_time数据
QcCheckItem airFlow = qcItems.get("airFlow");
airFlow.setValue(phd.getCollect().getAir_volume() / collect_hour);
//将数据存入QcItems的map中
qcItems.put("airFlow", airFlow);
//判断phdFile的valid参数是否为true phdFile的vBase集合大小是否等于phdFile的Spec的num_g_channel数据
if(phd.isValid() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) {
//判断system_type是否匹配P
if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) {
//声明一个energy集合
List<Double> energy = new LinkedList<>();
//集合增加数据
energy.add(ener_Be7);
//调用算法计算
CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP());
//获取计算结果的counts赋值给 fwhm集合
List<Double> fwhm = calValuesOut.counts;
//获取QcItems中Be7-FWHM数据
QcCheckItem be7 = qcItems.get("Be7-FWHM");
//将计算结果的第一个数据赋值给 be7
be7.setValue(fwhm.get(0));
//将数据存入QcItems的map中
qcItems.put("Be7-FWHM", be7);
//获取QcItems中Ba140-MDC数据
QcCheckItem Ba140 = qcItems.get("Ba140-MDC");
//调用CalculateMDC得到Ba140的数据
Ba140.setValue(CalculateMDC(phd, vMdcInfo, 1.0));
//将数据存入QcItems的map中
qcItems.put("Ba140-MDC", Ba140);
} else {
//获取QcItems中Xe133-MDC数据
QcCheckItem Xe133 = qcItems.get("Xe133-MDC");
//调用CalculateMDC得到Xe133的数据
Xe133.setValue(CalculateMDC(phd, vMdcInfo, 1.0));
//将数据存入QcItems的map中
qcItems.put("Xe133-MDC", Xe133);
}
}
@ -1186,8 +1306,8 @@ public class GammaFileUtil {
if(m_nSChan == 0) {
m_vCount.add(0L);
}
ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec"));
ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec"));
ChartData shadowEnergyChart = Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec"));
ChartData shadowChannelChart = Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec"));
map.put("shadowEnergyChart", shadowEnergyChart);
map.put("shadowChannelChart", shadowChannelChart);
List<ChartData> allData = AllData(false, phd, m_vCount, m_nCount, colorMap);
@ -1469,26 +1589,11 @@ public class GammaFileUtil {
return datalist;
}
public boolean AnalyseData(PHDFile phd, ConfigureData configureData, List<String> nuclides, boolean bSingle) {
//调用方法判断是否修改了参数
if (Objects.nonNull(configureData)){
SpecSetup phdSetting = phd.getSetting();
phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low());
phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High());
phdSetting.setEnergyTolerance(configureData.getEnergyTolerance());
phdSetting.setPSS_low(configureData.getPSS_low());
phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS());
phdSetting.setK_back(configureData.getK_back());
phdSetting.setK_alpha(configureData.getK_alpha());
phdSetting.setK_beta(configureData.getK_beta());
phdSetting.setRiskLevelK(configureData.getRiskLevelK());
phdSetting.setRefTime_act(configureData.getRefTime_act());
phdSetting.setRefTime_conc(configureData.getRefTime_conc());
}
public int AnalyseData(PHDFile phd, List<String> nuclides) {
int change = SettingChanged(phd);
if(change == 0 && phd.getVPeak().size() > 0) return false;
else if(change == -1) {
if(change == 0 && phd.getVPeak().size() > 0) {
return change;
} else if(change == -1) {
phd.setUsedEffi(phd.getNewEffi());
phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi()));
phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi()));
@ -1496,24 +1601,165 @@ public class GammaFileUtil {
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
NuclidesIdent(phd, nuclideLinesMap);
RunQC(phd);
String Warning = "Finish three tasks:\n"+
"\t1.Update efficiencies of all peaks;\n"+
"\t2.Identify nuclides again;\n"+
"\t3.Test QC again.";
} else {
if(bSingle) {
// AnalyseFlowChart flow_dlg(this);
// flow_dlg.exec();
} else {
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
// AnalyseSpectrum(phd, nuclideLinesMap);
}
Map<String, NuclideLines> nuclideLinesMap = GetNuclideLines(nuclides);
AnalyseSpectrum(phd, nuclideLinesMap);
}
return true;
return change;
}
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> map){
return false;
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
System.loadLibrary("GammaAnaly");
//解析获取临时文件信息
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String nuclideLinesMap = mapper.writeValueAsString(mapLines);
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath());
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
boolean value = (boolean) entry.getValue();
phd.setBAnalyed(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapTotEPara(value);
}
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_stepRatio(value);
}
if (entry.getKey().equalsIgnoreCase("para_tail")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tail(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRight")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRight(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRightAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("newEner")) {
String value = (String) entry.getValue();
phd.setNewEner(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
Map<String, GEnergyBlock> value = (Map<String, GEnergyBlock>) entry.getValue();
phd.setMapEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
Map<String, GResolutionBlock> value = (Map<String, GResolutionBlock>) entry.getValue();
phd.setMapResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVEnergy(value);
}
if (entry.getKey().equalsIgnoreCase("vBase")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVBase(value);
}
if (entry.getKey().equalsIgnoreCase("vLc")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVLc(value);
}
if (entry.getKey().equalsIgnoreCase("vScac")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVScac(value);
}
if (entry.getKey().equalsIgnoreCase("vPeak")) {
List<PeakInfo> value = (List<PeakInfo>) entry.getValue();
phd.setVPeak(value);
}
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class);
phd.setBaseCtrls(value);
}
if (entry.getKey().equalsIgnoreCase("usedEner")) {
String value = (String) entry.getValue();
phd.setUsedEner(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class);
phd.setUsedEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedReso")) {
String value = (String) entry.getValue();
phd.setUsedReso(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class);
phd.setUsedResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
String value = (String) entry.getValue();
phd.setUsedEffi(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class);
phd.setUsedEffiKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
String value = (String) entry.getValue();
phd.setUsedTotE(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class);
phd.setUsedTotEKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedTotEPara(value);
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
for (PeakInfo peak:phd.getVPeak()) {
if (StringUtils.isBlank(peak.recoilBetaChan)) {
peak.recoilBetaChan = "1";
}
if (StringUtils.isBlank(peak.recoilDeltaChan)) {
peak.recoilDeltaChan = "1";
}
}
//重新分析各峰值对应的核素信息
NuclidesIdent(phd, mapLines);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return true;
}
public int SettingChanged(PHDFile phd) {
@ -1523,7 +1769,7 @@ public class GammaFileUtil {
if(newSets.getECutAnalysis_Low() != oldSets.getECutAnalysis_Low()
|| newSets.getECutAnalysis_High() != oldSets.getECutAnalysis_High()
|| newSets.getEnergyTolerance() != oldSets.getEnergyTolerance()
|| newSets.getPSS_low() != oldSets.getCalibrationPSS_low()
|| newSets.getPss_low() != oldSets.getPss_low()
|| newSets.getBaseImprovePSS() != oldSets.getBaseImprovePSS()
|| newSets.getK_back() != oldSets.getK_back()
|| newSets.getK_alpha() != oldSets.getK_alpha()
@ -1537,7 +1783,9 @@ public class GammaFileUtil {
List<Double> old_ener = phd.getUsedEnerPara().getP();
List<Double> new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP();
if(old_ener.size() != new_ener.size()) return 1;
if(old_ener.size() != new_ener.size()) {
return 1;
}
for(int i=0; i<old_ener.size(); ++i) {
if(Math.abs(old_ener.get(i) - new_ener.get(i)) > 1E-6){
return 1;
@ -1546,7 +1794,9 @@ public class GammaFileUtil {
List<Double> old_reso = phd.getUsedResoPara().getP();
List<Double> new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP();
if(old_reso.size() != new_reso.size()) return 1;
if(old_reso.size() != new_reso.size()) {
return 1;
}
for(int i=0; i<old_reso.size(); ++i) {
if(Math.abs(old_reso.get(i) - new_reso.get(i)) > 1E-6){
return 1;
@ -1555,7 +1805,9 @@ public class GammaFileUtil {
List<Double> old_effi = phd.getUsedEffiPara().getP();
List<Double> new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP();
if(old_effi.size() != new_effi.size()) return -1;
if(old_effi.size() != new_effi.size()) {
return -1;
}
for(int i=0; i<old_effi.size(); ++i) {
if(Math.abs(old_effi.get(i) - new_effi.get(i)) > 1E-6){
return -1;
@ -1598,8 +1850,8 @@ public class GammaFileUtil {
}
FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线
List<Double> vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vYield;
List<Double> vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量
List<Double> vYield = iter.getValue().vyield;
List<Double> vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率
List<Integer> vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识
for (int i=0; i<vEnergy.size(); i++){
@ -1685,9 +1937,9 @@ public class GammaFileUtil {
ActMda.getVPeakIdx().add(peakIdx+1);
ActMda.getFullNames().add(iter.getValue().fullNames.get(ii));
ActMda.getVEnergy().add(vEnergy.get(ii));
ActMda.getVUncertE().add(iter.getValue().vUncertE.get(ii));
ActMda.getVUncertE().add(iter.getValue().vuncertE.get(ii));
ActMda.getVYield().add(vYield.get(ii));
ActMda.getVUncertY().add(iter.getValue().vUncertY.get(ii));
ActMda.getVUncertY().add(iter.getValue().vuncertY.get(ii));
++fitLineNum;
}
}
@ -1736,14 +1988,14 @@ public class GammaFileUtil {
}
private void FilterNuclideLine(NuclideLines lines, double lowE) {
List<Double> vE = lines.vEnergy;
List<Double> vE = lines.venergy;
for(int i=0, j=0; i<vE.size(); ++i) {
if(vE.get(i) < lowE) {
lines.fullNames.remove(j);
lines.vEnergy.remove(lines.vEnergy.get(0)+j);
lines.vYield.remove(lines.vYield.get(0)+j);
lines.vUncertE.remove(lines.vUncertE.get(0)+j);
lines.vUncertY.remove(lines.vUncertY.get(0)+j);
lines.venergy.remove(lines.venergy.get(0)+j);
lines.vyield.remove(lines.vyield.get(0)+j);
lines.vuncertE.remove(lines.vuncertE.get(0)+j);
lines.vuncertY.remove(lines.vuncertY.get(0)+j);
if(i == lines.key_flag){
lines.key_flag = -1;
} else if(i < lines.key_flag){
@ -1753,8 +2005,8 @@ public class GammaFileUtil {
++j;
}
}
if(lines.key_flag < 0 && lines.vEnergy.size() > 0) {
List<Double> vY = lines.vYield;
if(lines.key_flag < 0 && lines.venergy.size() > 0) {
List<Double> vY = lines.vyield;
lines.maxYeildIdx = 0;
double maxYield = vY.get(0);
for(int ii=1; ii<vY.size(); ++ii) {
@ -1838,10 +2090,10 @@ public class GammaFileUtil {
List<NuclideLine> nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name);
for(int j=0;j<nuclideLineList.size();j++) {
nlines.getFullNames().add(nuclideLineList.get(j).getFullName());
nlines.getVEnergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVUncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVYield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVUncertY().add(nuclideLineList.get(j).getYield_uncert());
nlines.getVenergy().add(nuclideLineList.get(j).getEnergy());
nlines.getVuncertE().add(nuclideLineList.get(j).getEnergy_uncert());
nlines.getVyield().add(nuclideLineList.get(j).getYield() / 100);
nlines.getVuncertY().add(nuclideLineList.get(j).getYield_uncert());
if(Objects.nonNull(nuclideLineList.get(j).getKey_flag()) && nuclideLineList.get(j).getKey_flag().intValue() > 0) {
nlines.key_flag = j;
nlines.maxYeildIdx = j;
@ -2376,11 +2628,11 @@ public class GammaFileUtil {
public String GetReportContent(PHDFile phd, boolean bLog) {
GStoreMiddleProcessData middleData = new GStoreMiddleProcessData();
this.GetInterMiddlData(phd, "", middleData);
GetInterMiddlData(phd, "", middleData);
if(bLog) {
return this.GetLogContent(middleData);
return GetLogContent(middleData);
} else {
return this.GetReportContent(middleData);
return GetReportContent(middleData);
}
}
@ -2484,7 +2736,7 @@ public class GammaFileUtil {
strBuffer.append("ECutAnalysis_High : "+middleData.setting_specSetup.getECutAnalysis_High()+"\n");
strBuffer.append("EnergyTolerance : "+middleData.setting_specSetup.getEnergyTolerance()+"\n");
strBuffer.append("BaseImprovePSS : "+middleData.setting_specSetup.getBaseImprovePSS()+"\n");
strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPSS_low()+"\n");
strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPss_low()+"\n");
strBuffer.append("k_back : "+middleData.setting_specSetup.getK_back()+"\n");
strBuffer.append("k_alpha : "+middleData.setting_specSetup.getK_alpha()+"\n");
strBuffer.append("k_beta : "+middleData.setting_specSetup.getK_beta()+"\n");
@ -2641,7 +2893,7 @@ public class GammaFileUtil {
strBuffer.append(" ECutAnalysis_High: "+middleData.setting_specSetup.getECutAnalysis_High()+"\n");
strBuffer.append(" EnergyTolerance: "+middleData.setting_specSetup.getEnergyTolerance()+"\n");
strBuffer.append(" BaseImprovePSS: "+middleData.setting_specSetup.getBaseImprovePSS()+"\n");
strBuffer.append(" PSS_low: "+middleData.setting_specSetup.getPSS_low()+"\n");
strBuffer.append(" PSS_low: "+middleData.setting_specSetup.getPss_low()+"\n");
strBuffer.append(" k_back: "+middleData.setting_specSetup.getK_back()+"\n");
strBuffer.append(" k_alpha: "+middleData.setting_specSetup.getK_alpha()+"\n");
strBuffer.append(" k_beta: "+middleData.setting_specSetup.getK_beta()+"\n");
@ -3941,7 +4193,7 @@ public class GammaFileUtil {
ReadSpecialNuclides(mapHalflife, vNuclides);
double energyWidth = phd.getUsedSetting().getEnergyTolerance();
List<Double> vEnergy = lines.vEnergy; // 该核素的所有γ射线能量
List<Double> vEnergy = lines.venergy; // 该核素的所有γ射线能量
double maxYield = 0;
int mainPeakIdx = -1; // 记录核素主γ峰的索引下标
@ -3954,9 +4206,9 @@ public class GammaFileUtil {
break;
} else if(vEnergy.get(i) <= energy + energyWidth) {
ActMda.getVEnergy().add(vEnergy.get(i));
ActMda.getVUncertE().add(lines.vUncertE.get(i));
ActMda.getVYield().add(lines.vYield.get(i));
ActMda.getVUncertY().add(lines.vUncertY.get(i));
ActMda.getVUncertE().add(lines.vuncertE.get(i));
ActMda.getVYield().add(lines.vyield.get(i));
ActMda.getVUncertY().add(lines.vuncertY.get(i));
ActMda.getFullNames().add(lines.fullNames.get(i));
ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1);
if(lines.key_flag == i) {
@ -4160,4 +4412,42 @@ public class GammaFileUtil {
return datalist;
}
public File analyzeFile(String path, String fileName) {
//连接ftp
FTPClient ftpClient = ftpUtil.LoginFTP();
InputStream inputStream = null;
File file = null;
try {
//被动模式
ftpClient.enterLocalPassiveMode();
//设置文件类型--二进制文件
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
//
ftpClient.setControlEncoding("UTF-8");
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
//切换文件路径
ftpClient.changeWorkingDirectory(path);
inputStream = ftpClient.retrieveFileStream(fileName);
if (Objects.nonNull(inputStream)){
file = File.createTempFile("tmp", null);
//将ftp文件的输入流复制给临时文件
FileUtils.copyInputStreamToFile(inputStream, file);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
if (Objects.nonNull(ftpClient)){
ftpClient.disconnect();
}
if (Objects.nonNull(inputStream)){
inputStream.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return file;
}
}

View File

@ -77,8 +77,17 @@ public class UserTaskUtil {
return flag;
}
/**
* 根据用户名获取用户相关权限信息
* @param userName
* @return
*/
public List<String> findRoleCodeByUserName(String userName){
return userTaskService.findRoleCodeByUserName(userName);
}
public SysUser findUserByName(String userName) {
return userTaskService.findUserByName(userName);
}
}

View File

@ -43,18 +43,19 @@ public class GammaController {
@GetMapping("analysisProcess")
@ApiOperation(value = "分析进度", notes = "分析进度")
public void message(String message) {
Result<SysUser> user = systemClient.getUserData();
// Result<SysUser> user = systemClient.getUserData();
BaseMap params = new BaseMap();
params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER);
params.put("userId", user.getResult().getId());
params.put("userId", "message.userId");
// userId, fileName, process
params.put("message", message);
// 通过 redis 订阅发送 websocket 消息
redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);;
}
@GetMapping("testFun")
public Result testFun(String fileName){
return gammaService.testFun(fileName);
public Result testFun(String fileName,HttpServletRequest request){
return gammaService.testFun(fileName, request);
}
@GetMapping("gammaByDB")
@ -83,10 +84,15 @@ public class GammaController {
return gammaService.configure(sampleId, fileName);
}
@PostMapping("configureSave")
public Result configureSave(@RequestBody ConfigureData configureData) {
return gammaService.configureSave(configureData);
}
@PostMapping("Reprocessing")
@ApiOperation(value = "analyze菜单下Reprocessing页面数据", notes = "analyze菜单下Reprocessing页面数据")
public Result Reprocessing(@RequestBody ConfigureData configureData, HttpServletRequest request) {
return gammaService.Reprocessing(configureData, request);
public Result Reprocessing(String fileName, HttpServletRequest request) {
return gammaService.Reprocessing(fileName, request);
}
@GetMapping("InteractiveTool")
@ -242,6 +248,12 @@ public class GammaController {
return gammaService.callDataEnergy(file, sampleFileName, width, currentText);
}
@PutMapping("setCurrentEnergy")
@ApiOperation(value = "Energy Calibration页面set to current按钮", notes = "Energy Calibration页面set to current按钮")
public Result setCurrentEnergy(String fileName, String currentName) {
return gammaService.setCurrentEnergy(fileName, currentName);
}
@GetMapping("resolutionCalibration")
@ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据")
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) {
@ -272,6 +284,12 @@ public class GammaController {
return gammaService.callDataResolution(file, sampleFileName, width, currentText);
}
@PutMapping("setCurrentResolution")
@ApiOperation(value = "Resolution Calibration页面set to current按钮", notes = "Resolution Calibration页面set to current按钮")
public Result setCurrentResolution(String fileName, String currentName) {
return gammaService.setCurrentResolution(fileName, currentName);
}
@GetMapping("EfficiencyCalibration")
@ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据")
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) {
@ -302,6 +320,12 @@ public class GammaController {
return gammaService.callDataEfficiency(file, sampleFileName, width, currentText);
}
@PutMapping("setCurrentEfficiency")
@ApiOperation(value = "Efficiency Calibration页面set to current按钮", notes = "Efficiency Calibration页面set to current按钮")
public Result setCurrentEfficiency(String fileName, String currentName) {
return gammaService.setCurrentEfficiency(fileName, currentName);
}
@GetMapping("NuclideLibrary")
@ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据")
public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {

View File

@ -64,6 +64,8 @@ public class PeakInfo implements Serializable {
public PeakInfo(){
nuclides = new LinkedList<>();
comments = "";
recoilBetaChan = "1";
recoilDeltaChan = "1";
}
}

View File

@ -1,13 +1,11 @@
package org.jeecg.modules.native_jni;
import com.alibaba.fastjson.JSON;
import org.jeecg.modules.entity.vo.PeakInfo;
import org.jeecg.modules.entity.vo.StructInsertInput;
import org.jeecg.modules.entity.vo.StructInsertOutput;
import org.jeecg.modules.native_jni.struct.CalValuesOut;
import java.util.List;
import java.util.Map;
public class CalValuesHandler {
@ -27,22 +25,6 @@ public class CalValuesHandler {
public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List<Double> vCentroid, List<Double> vFwhmCh, List<Double> vTail, List<Double> vUpperTail);
public static native List<Double> calValues(int cal, int m_nChans);
public static native List<Double> GetFwhmcAll(int m_nChans);
public static native List<Double> calculateLC(List<Double> BaseLine, List<Double> FwhmcAll, double RiskLevelK);
public static native List<Double> calculateSCAC(List<Double> Spectrum, List<Double> BaseLine, List<Double> FwhmcAll);
public static native boolean armaAny(List<Double> Spectrum);
public static native String calUpdate(String dataType, List<Double> certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta);
public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta, List<PeakInfo> Peaks);
public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow);
public static native String fitPeakFull();
public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath);
}

View File

@ -3,6 +3,7 @@ package org.jeecg.modules.service;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.entity.vo.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
@ -13,7 +14,7 @@ public interface IGammaService{
Result initValue(Integer sampleId, String dbName, HttpServletRequest request);
Result testFun(String fileName);
Result testFun(String fileName, HttpServletRequest request);
Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request);
@ -25,7 +26,9 @@ public interface IGammaService{
Result configure(Integer sampleId, String fileName);
Result Reprocessing(ConfigureData configureData, HttpServletRequest request);
Result configureSave(ConfigureData configureData);
Result Reprocessing(String fileName, HttpServletRequest request);
Result InteractiveTool(Integer sampleId, String fileName, HttpServletRequest request);
@ -79,6 +82,8 @@ public interface IGammaService{
Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText);
Result setCurrentEnergy(String fileName, String currentName);
Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width);
Result changeDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width);
@ -89,6 +94,8 @@ public interface IGammaService{
Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText);
Result setCurrentResolution(String fileName, String currentName);
Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width);
Result changeDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width);
@ -99,6 +106,8 @@ public interface IGammaService{
Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText);
Result setCurrentEfficiency(String fileName, String currentName);
Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request);
Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request);

View File

@ -8,13 +8,18 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.cache.Cache;
import org.apache.commons.net.ftp.FTPClient;
import org.codehaus.jettison.json.JSONString;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.cache.LocalCache;
import org.jeecg.common.constant.DateConstant;
@ -23,6 +28,7 @@ import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
import org.jeecg.modules.base.entity.postgre.SysUser;
import org.jeecg.modules.base.enums.ExportTemplate;
import org.jeecg.modules.base.enums.RoleType;
import org.jeecg.modules.entity.vo.*;
@ -30,6 +36,7 @@ import org.jeecg.modules.entity.*;
import org.jeecg.modules.mapper.SpectrumAnalysisMapper;
import org.jeecg.modules.native_jni.CalValuesHandler;
import org.jeecg.modules.service.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -77,6 +84,8 @@ public class GammaServiceImpl implements IGammaService {
private FTPUtil ftpUtil;
@Value("${ZeroTime}")
private String ZeroTimeStr;
@Value("${parameter.filePath}")
private String parameterFilePath;
@Autowired
private IGardsAnalysesSpectrumService analysesSpectrumService;
@Autowired
@ -113,6 +122,7 @@ public class GammaServiceImpl implements IGammaService {
@Override
public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) {
Result result = new Result();
//
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = new PHDFile();
@ -144,40 +154,188 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result testFun(String fileName) {
public Result testFun(String fileName, HttpServletRequest request) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
Map<String, Object> map = new HashMap<>();
System.loadLibrary("GammaAnaly");
// List<Double> baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size());
// map.put("baseInfo_s_Energy", baseInfo_s_Energy);
// List<Double> baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size());
// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll);
// List<Double> baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK());
// map.put("baseInfo_s_Lc", baseInfo_s_Lc);
// List<Double> values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts());
// List<Double> baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll);
// map.put("baseInfo_s_Scac", baseInfo_s_Scac);
// boolean armaAny = CalValuesHandler.armaAny(values);
// map.put("armaAny", armaAny);
String dataType = phd.getMsgInfo().getData_type().substring(0, 1);
List<Double> gEnergy = phd.getCertificate().getG_energy();
String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta());
map.put("calUpdateStr", calUpdateStr);
// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(),
// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak());
phd.setUserId("1");
phd.setXmlFilePath(parameterFilePath);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
String userName = JwtUtil.getUserNameByToken(request);
//查询当前用户关联的核素信息
List<String> nuclides = new LinkedList<>();
//从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase());
if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
Map<String, NuclideLines> nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides);
//解析获取临时文件信息
File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName);
ObjectMapper mapper = new ObjectMapper();
try {
String phdStr = mapper.writeValueAsString(phd);
String mapLines = mapper.writeValueAsString(nuclideLinesMap);
String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath());
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
boolean value = (boolean) entry.getValue();
phd.setBAnalyed(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapEffiPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("mapTotEPara")) {
Map<String, ParameterInfo> value = (Map<String, ParameterInfo>) entry.getValue();
phd.setMapTotEPara(value);
}
if (entry.getKey().equalsIgnoreCase("para_stepRatio")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_stepRatio(value);
}
if (entry.getKey().equalsIgnoreCase("para_tail")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tail(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRight")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRight(value);
}
if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setPara_tailRightAlpha(value);
}
if (entry.getKey().equalsIgnoreCase("newEner")) {
String value = (String) entry.getValue();
phd.setNewEner(value);
}
if (entry.getKey().equalsIgnoreCase("mapEnerKD")) {
Map<String, GEnergyBlock> value = (Map<String, GEnergyBlock>) entry.getValue();
phd.setMapEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("mapResoKD")) {
Map<String, GResolutionBlock> value = (Map<String, GResolutionBlock>) entry.getValue();
phd.setMapResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("vEnergy")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVEnergy(value);
}
if (entry.getKey().equalsIgnoreCase("vBase")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVBase(value);
}
if (entry.getKey().equalsIgnoreCase("vLc")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVLc(value);
}
if (entry.getKey().equalsIgnoreCase("vScac")) {
List<Double> value = (List<Double>) entry.getValue();
phd.setVScac(value);
}
if (entry.getKey().equalsIgnoreCase("vPeak")) {
List<PeakInfo> value = (List<PeakInfo>) entry.getValue();
phd.setVPeak(value);
}
if (entry.getKey().equalsIgnoreCase("baseCtrls")) {
BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class);
phd.setBaseCtrls(value);
}
if (entry.getKey().equalsIgnoreCase("usedEner")) {
String value = (String) entry.getValue();
phd.setUsedEner(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerKD")) {
GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class);
phd.setUsedEnerKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEnerPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEnerPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedReso")) {
String value = (String) entry.getValue();
phd.setUsedReso(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoKD")) {
GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class);
phd.setUsedResoKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedResoPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedResoPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffi")) {
String value = (String) entry.getValue();
phd.setUsedEffi(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiKD")) {
GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class);
phd.setUsedEffiKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedEffiPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedEffiPara(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotE")) {
String value = (String) entry.getValue();
phd.setUsedTotE(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEKD")) {
TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class);
phd.setUsedTotEKD(value);
}
if (entry.getKey().equalsIgnoreCase("usedTotEPara")) {
ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class);
phd.setUsedTotEPara(value);
}
}
BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting());
for (PeakInfo peak:phd.getVPeak()) {
if (StringUtils.isBlank(peak.recoilBetaChan)) {
peak.recoilBetaChan = "1";
}
if (StringUtils.isBlank(peak.recoilDeltaChan)) {
peak.recoilDeltaChan = "1";
}
}
result.setResult(phd);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
result.setSuccess(true);
result.setResult(map);
return result;
}
@Override
public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) {
Result result = new Result();
//通过token获取用户名
String userName = JwtUtil.getUserNameByToken(request);
//声明一个接收最后返回结果的map
Map<String, Object> map = new HashMap<>();
//加载本地缓存信息
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
//声明phd实体类
PHDFile phd = new PHDFile();
//读取文件内容
//根据sampleId获取sample文件路径
@ -186,16 +344,21 @@ public class GammaServiceImpl implements IGammaService {
result.error500("样品文件不存在!");
return result;
}
//切割数据库存储的文件路径获取路径信息
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
//切割数据库存储的文件路径获取文件名称
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
//调用加载文件的方法 传入文件路径文件名称全局变量phd响应结果result
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result);
//如果文件加载失败 返回失败原因
if (!flag){
return result;
}
//声明基础数组信息
//加载phd数据所需的lcscacbaseline数据
gammaFileUtil.SetBaseInfo(phd);
//从数据库中读取相关信息
//从数据库中读取phd其他相关信息
boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result);
//判断数据库信息是否读取正常
if (!bRet){
return result;
}
@ -213,7 +376,9 @@ public class GammaServiceImpl implements IGammaService {
map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time()));
double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time();
map.put("dead_time", String.format("%.2f", deadTime*100));
// 更新页面折线图信息
gammaFileUtil.UpdateChart(phd, map, colorMap);
//将当前加载的phd信息加入到缓存中 文件名称作为缓存信息的key
phdCache.put(fileName, phd);
localCache.setPHDCache(phdCache);
result.setSuccess(true);
@ -327,7 +492,7 @@ public class GammaServiceImpl implements IGammaService {
map.put("edit_ps_low", setup.getECutAnalysis_Low());
map.put("edit_ps_high", setup.getECutAnalysis_High());
map.put("edit_energy", setup.getEnergyTolerance());
map.put("edit_pss_low", setup.getPSS_low());
map.put("edit_pss_low", setup.getPss_low());
map.put("edit_cal_low", setup.getCalibrationPSS_low());
map.put("edit_cal_high", setup.getCalibrationPSS_high());
map.put("checkBox_updateCal", setup.isBUpdateCal());
@ -350,7 +515,7 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result Reprocessing(ConfigureData configureData, HttpServletRequest request) {
public Result configureSave(ConfigureData configureData) {
Result result = new Result();
String fileName = configureData.getFileName();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
@ -359,7 +524,39 @@ public class GammaServiceImpl implements IGammaService {
result.error500("请先选择解析文件!");
return result;
}
SpecSetup phdSetting = phd.getSetting();
phdSetting.setECutAnalysis_Low(configureData.getECutAnalysis_Low());
phdSetting.setECutAnalysis_High(configureData.getECutAnalysis_High());
phdSetting.setEnergyTolerance(configureData.getEnergyTolerance());
phdSetting.setPss_low(configureData.getPss_low());
phdSetting.setBaseImprovePSS(configureData.getBaseImprovePSS());
phdSetting.setK_back(configureData.getK_back());
phdSetting.setK_alpha(configureData.getK_alpha());
phdSetting.setK_beta(configureData.getK_beta());
phdSetting.setRiskLevelK(configureData.getRiskLevelK());
phdSetting.setRefTime_act(configureData.getRefTime_act());
phdSetting.setRefTime_conc(configureData.getRefTime_conc());
result.success("保存成功");
return result;
}
@Override
public Result Reprocessing(String fileName, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
//获取当前用户信息
SysUser user = userTaskUtil.findUserByName(userName);
if (Objects.nonNull(user)) {
phd.setUserId(user.getId());
}
//赋值xml文件存放路径
phd.setXmlFilePath(parameterFilePath);
//获取当前角色的颜色配置
Map<String, String> colorMap = sysUserColorService.initColor(userName);
//查询当前用户关联的核素信息
@ -369,28 +566,27 @@ public class GammaServiceImpl implements IGammaService {
if (CollectionUtils.isEmpty(nuclides)){
nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase());
}
boolean flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, true);
if (flag){
Map<String, Object> map = new HashMap<>();
phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low());
phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High());
phd.getUsedSetting().setEnergyTolerance(configureData.getEnergyTolerance());
phd.getUsedSetting().setPSS_low(configureData.getPSS_low());
phd.getUsedSetting().setBaseImprovePSS(configureData.getBaseImprovePSS());
phd.getUsedSetting().setK_back(configureData.getK_back());
phd.getUsedSetting().setK_alpha(configureData.getK_alpha());
phd.getUsedSetting().setK_beta(configureData.getK_beta());
phd.getUsedSetting().setRiskLevelK(configureData.getRiskLevelK());
phd.getUsedSetting().setRefTime_act(configureData.getRefTime_act());
phd.getUsedSetting().setRefTime_conc(configureData.getRefTime_conc());
gammaFileUtil.UpdateChart(phd, map, colorMap);
result.setSuccess(true);
result.setResult(map);
}else {
//分析文件数据
int flag = gammaFileUtil.AnalyseData(phd, nuclides);
if (flag == 0){
String warning = "The spectrum needn't Analyed. Maybe:\n"+
"1. It has already Analyed.\n"+
"2. You didn't change any setting or calibration.";
result.error500(warning);
} else if (flag == -1){
String warning = "Finish three tasks:\n"+
"\t1.Update efficiencies of all peaks;\n"+
"\t2.Identify nuclides again;\n"+
"\t3.Test QC again.";
result.error500(warning);
} else {
Map<String, Object> map = new HashMap<>();
gammaFileUtil.UpdateChart(phd, map, colorMap);
// 更新 QC Flags 状态
List<String> qcstate = gammaFileUtil.Qcstate(phd);
map.put("QCFlag", qcstate);
result.setSuccess(true);
result.setResult(map);
}
return result;
}
@ -440,6 +636,8 @@ public class GammaServiceImpl implements IGammaService {
map.put("energy", phd.getVEnergy());
//赋值BaseCtrls
map.put("BaseCtrls", phd.getBaseCtrls());
//FitBaseLine颜色
map.put("FitBaseLine", colorMap.get("Color_Fitbase"));
result.setSuccess(true);
result.setResult(map);
return result;
@ -1468,6 +1666,24 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public Result setCurrentEnergy(String fileName, String currentName) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
if (StringUtils.isNotBlank(currentName)) {
phd.setNewEner(currentName);
}
phdCache.put(fileName, phd);
localCache.setPHDCache(phdCache);
result.success("修改成功");
return result;
}
@Override
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) {
Result result = new Result();
@ -1702,6 +1918,24 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public Result setCurrentResolution(String fileName, String currentName) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
if (StringUtils.isNotBlank(currentName)) {
phd.setNewReso(currentName);
}
phdCache.put(fileName, phd);
localCache.setPHDCache(phdCache);
result.success("修改成功");
return result;
}
@Override
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) {
Result result = new Result();
@ -1958,6 +2192,24 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public Result setCurrentEfficiency(String fileName, String currentName) {
Result result = new Result();
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
if (Objects.isNull(phd)){
result.error500("请先选择解析文件!");
return result;
}
if (StringUtils.isNotBlank(currentName)) {
phd.setNewEffi(currentName);
}
phdCache.put(fileName, phd);
localCache.setPHDCache(phdCache);
result.success("修改成功");
return result;
}
@Override
public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {
Result result = new Result();

View File

@ -25,7 +25,7 @@ public class GardsAnalySettingSpectrumServiceImpl extends ServiceImpl<GardsAnaly
analySetting.setCalibrationpssHigh(phd.getUsedSetting().getCalibrationPSS_high());
analySetting.setCalibrationpssLow(phd.getUsedSetting().getCalibrationPSS_low());
analySetting.setBaseimprovepss(phd.getUsedSetting().getBaseImprovePSS());
analySetting.setPssLow(phd.getUsedSetting().getPSS_low());
analySetting.setPssLow(phd.getUsedSetting().getPss_low());
analySetting.setKBack(phd.getUsedSetting().getK_back());
analySetting.setKAlpha(phd.getUsedSetting().getK_alpha());
analySetting.setKBeta(phd.getUsedSetting().getK_beta());

View File

@ -76,10 +76,10 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl<GardsNuclLinesLibM
nuclideLines = result.containsKey(lib.getName()) ? result.get(lib.getName()) : new NuclideLines();
nuclideLines.getFullNames().add(lib.getFullName());
nuclideLines.getVEnergy().add(lib.getEnergy());
nuclideLines.getVUncertE().add(lib.getEnergyUncert());
nuclideLines.getVYield().add(lib.getYield() / 100);
nuclideLines.getVUncertY().add(lib.getYieldUncert());
nuclideLines.getVenergy().add(lib.getEnergy());
nuclideLines.getVuncertE().add(lib.getEnergyUncert());
nuclideLines.getVyield().add(lib.getYield() / 100);
nuclideLines.getVuncertY().add(lib.getYieldUncert());
int keyFlag = lib.getKeyFlag();
if (keyFlag > 0){

View File

@ -15,5 +15,5 @@ spring:
config:
import:
- optional:nacos:jeecg.yaml
- optional:nacos:jeecg-@profile.name@-pbl.yaml
- optional:nacos:jeecg-@profile.name@.yaml