自动处理模块增加gamma部分相关存储mdc计算结果方法及处理代码
计算mdc公式部分公式延用调用C++的方式获取结果
This commit is contained in:
parent
b2c85bcd45
commit
5ffe064aca
|
@ -0,0 +1,9 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsMDC;
|
||||
|
||||
@Mapper
|
||||
public interface GardsMDCAutoMapper extends BaseMapper<GardsMDC> {
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.jeecg.modules.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsMDC;
|
||||
|
||||
public interface GardsMDCAutoService extends IService<GardsMDC> {
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.jeecg.modules.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.base.entity.rnauto.GardsMDC;
|
||||
import org.jeecg.modules.mapper.GardsMDCAutoMapper;
|
||||
import org.jeecg.modules.service.GardsMDCAutoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@DS("ora")
|
||||
public class GardsMDCAutoServiceImpl extends ServiceImpl<GardsMDCAutoMapper, GardsMDC> implements GardsMDCAutoService {
|
||||
}
|
|
@ -7,6 +7,7 @@ import cn.hutool.core.io.FileUtil;
|
|||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -33,6 +34,12 @@ import org.jeecg.modules.file.FileOperation;
|
|||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.w3c.dom.*;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -158,12 +165,13 @@ public class Sample_G_Analysis {
|
|||
if (this.systemType.equals(SpectrumSystemType.G.name())) {
|
||||
nuclideLibs = this.getNuclideLinesG();
|
||||
}
|
||||
|
||||
//读取参数内容
|
||||
readMDCParameter(phdFile);
|
||||
// 执行分析业务代码
|
||||
gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType(), "");
|
||||
|
||||
// 数据插入数据库
|
||||
this.storageDataToDatabase(middleData, phdFile.getQcItems());
|
||||
this.storageDataToDatabase(phdFile, middleData, phdFile.getQcItems());
|
||||
|
||||
// 生成日志文件
|
||||
writeLog(middleData.getAnalyses_LogPath(), middleData);
|
||||
|
@ -196,6 +204,69 @@ public class Sample_G_Analysis {
|
|||
log.info("Gamma自动处理分析--End");
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取计算MDC参数文件方法
|
||||
*/
|
||||
public void readMDCParameter(PHDFile phd) {
|
||||
//存储文件结果用的map
|
||||
Map<String, CalMDCInfo> mdcInfoMap = new TreeMap<>();
|
||||
//配置文件路径
|
||||
String filePath = parameterProperties.getFilePath()+ File.separator + "MDCParameter.xml";
|
||||
try {
|
||||
//创建一个文档解析器工厂
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
//创建文档解析器
|
||||
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
|
||||
//读取xml文件生成一个文档
|
||||
Document document = documentBuilder.parse(filePath);
|
||||
if (Objects.nonNull(document)){
|
||||
//获取文档的根元素
|
||||
Element element = document.getDocumentElement();
|
||||
//获取根元素的子节点
|
||||
NodeList docChildNodes = element.getChildNodes();
|
||||
//判断文件内的节点是否大于0
|
||||
if (Objects.nonNull(docChildNodes) && docChildNodes.getLength() > 0) {
|
||||
//遍历文件节点读取内容
|
||||
for (int i=0; i<docChildNodes.getLength(); i++) {
|
||||
//获取节点信息
|
||||
Node node = docChildNodes.item(i);
|
||||
//判断节点名称是否是item
|
||||
if (node.getNodeName().equalsIgnoreCase("item")) {
|
||||
//获取节点属性信息
|
||||
NamedNodeMap attributes = node.getAttributes();
|
||||
//判断节点属性信息是否为空
|
||||
if (Objects.nonNull(attributes)) {
|
||||
CalMDCInfo info = new CalMDCInfo();
|
||||
//遍历属性信息
|
||||
for (int j=0; j<attributes.getLength(); j++) {
|
||||
//根据顺序读取属性
|
||||
Node attribute = attributes.item(j);
|
||||
if (attribute.getNodeName().equalsIgnoreCase("nuclide_name")) {
|
||||
info.setNuclideName(attribute.getNodeValue());
|
||||
} else if (attribute.getNodeName().equalsIgnoreCase("halflife")) {
|
||||
info.setHalflife(Double.valueOf(attribute.getNodeValue()));
|
||||
}
|
||||
}
|
||||
if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(info.getNuclideName()) && Objects.nonNull(info.getHalflife())) {
|
||||
mdcInfoMap.put(info.getNuclideName(), info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
phd.setMdcInfoMap(mdcInfoMap);
|
||||
}
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SAXException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分析成功数据发送到Redis
|
||||
*/
|
||||
|
@ -222,7 +293,7 @@ public class Sample_G_Analysis {
|
|||
}
|
||||
}
|
||||
|
||||
private void storageDataToDatabase(GStoreMiddleProcessData middleData, Map<String, QcCheckItem> qcItems){
|
||||
private void storageDataToDatabase(PHDFile phdFile, GStoreMiddleProcessData middleData, Map<String, QcCheckItem> qcItems){
|
||||
//如果数据已经存储,不在重复存储
|
||||
final Integer idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId());
|
||||
if(Objects.nonNull(idAnalysis)){
|
||||
|
@ -251,6 +322,8 @@ public class Sample_G_Analysis {
|
|||
saveNuclIded(middleData, sampleId, IdAnalysis);
|
||||
/* Gards_Qc_Check 数据表保存 */
|
||||
saveQcCheck(middleData, sampleId, IdAnalysis, qcItems);
|
||||
/* GARDS_MDC 数据表保存 */
|
||||
saveMDC(sampleId, idAnalysis, phdFile.getMdcInfoMap());
|
||||
//提交事务
|
||||
serviceQuotes.getTransactionManager().commit(transactionStatus);
|
||||
} catch (Exception e) {
|
||||
|
@ -796,6 +869,31 @@ public class Sample_G_Analysis {
|
|||
}
|
||||
}
|
||||
|
||||
public void saveMDC(Integer sampleId, Integer IdAnalysis, Map<String, CalMDCInfo> mdcInfoMap) {
|
||||
List<GardsMDC> mdcList = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(mdcInfoMap)) {
|
||||
for (CalMDCInfo mdcInfo :mdcInfoMap.values()) {
|
||||
GardsMDC mdc = new GardsMDC();
|
||||
mdc.setIdAnalysis(IdAnalysis);
|
||||
mdc.setSampleId(sampleId);
|
||||
mdc.setNuclideName(mdcInfo.getNuclideName());
|
||||
mdc.setEnergy(mdcInfo.getEnergy());
|
||||
mdc.setYield(mdcInfo.getYield());
|
||||
mdc.setEfficiency(mdcInfo.getEfficiency());
|
||||
if (Objects.nonNull(mdcInfo.getMdc()) && Double.isFinite(mdcInfo.getMdc())) {
|
||||
mdc.setMdc(mdcInfo.getMdc());
|
||||
} else {
|
||||
mdc.setMdc(null);
|
||||
}
|
||||
mdc.setMdcErr(null);
|
||||
mdcList.add(mdc);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(mdcList)) {
|
||||
serviceQuotes.getGardsMDCAutoService().saveBatch(mdcList);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, NuclideLines> getNuclideLinesG() {
|
||||
redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class);
|
||||
Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G");
|
||||
|
|
|
@ -63,6 +63,8 @@ public class SpectrumServiceQuotes {
|
|||
|
||||
private final GardsQcCheckAutoService gardsQcCheckAutoService;
|
||||
|
||||
private final GardsMDCAutoService gardsMDCAutoService;
|
||||
|
||||
private final GardsXeResultsService xeResultsService;
|
||||
|
||||
private final GardsRoiResultsService roiResultsService;
|
||||
|
|
|
@ -3116,6 +3116,16 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
String anylseEnd;
|
||||
anylseBegin = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss");
|
||||
bRet = AnalyseSpectrum(fileAnlyse,nucline);
|
||||
if (CollectionUtils.isEmpty(fileAnlyse.getEfficiencyParam())) {
|
||||
fileAnlyse.setEfficiencyParam(fileAnlyse.getUsedEffiPara().getP());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(fileAnlyse.getEfficiencyEnergy())) {
|
||||
fileAnlyse.setEfficiencyEnergy(fileAnlyse.getUsedEffiKD().getG_energy());
|
||||
}
|
||||
if (Objects.isNull(fileAnlyse.getEfficiencyCurRow())) {
|
||||
fileAnlyse.setEfficiencyCurRow(0);
|
||||
}
|
||||
getNuclideMDCValue(fileAnlyse, fileAnlyse.getMdcInfoMap(), nucline);
|
||||
anylseEnd = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss");
|
||||
middleData.analyses_analysisBegin = anylseBegin;
|
||||
middleData.analyses_analysisEnd = anylseEnd;
|
||||
|
@ -4609,34 +4619,45 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
switch(funId) {
|
||||
case 1: // Interpolation: y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x<x(i+1)
|
||||
if(p_size == 2 * e_size && p_size >= 4) {
|
||||
int i = phd.getEfficiencyCurRow();
|
||||
if(i < 0 || i >= e_size) break;
|
||||
|
||||
double y1, y0, x1, x0;
|
||||
if(i < e_size - 1) {
|
||||
y1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+3))));
|
||||
y0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+1))));
|
||||
x1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+2))));
|
||||
x0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2))));
|
||||
} else {
|
||||
y1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+1))));
|
||||
y0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2-1))));
|
||||
x1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2))));
|
||||
x0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2-2))));
|
||||
}
|
||||
for (int j=0; j<nuclideLines.fullNames.size(); j++) {
|
||||
List<Double> effList = CalValuesHandler.calFcnEval(nuclideLines.venergy, phd.getEfficiencyParam()).counts;
|
||||
for (int j=0; j<effList.size(); j++) {
|
||||
//获取峰核素能量值
|
||||
Double energy = nuclideLines.venergy.get(j);
|
||||
Double eff = effList.get(j);
|
||||
Double yield = nuclideLines.vyield.get(j);
|
||||
//能量不为空
|
||||
if (Objects.nonNull(energy) && Objects.nonNull(yield)) {
|
||||
double eff = y0 + (y1 - y0) * (energy - x0) / (x1 - x0);
|
||||
if (Double.isFinite(eff)) {
|
||||
double efficiency = eff * yield;
|
||||
efficiencies.add(efficiency);
|
||||
}
|
||||
if (Double.isFinite(eff)) {
|
||||
double efficiency = eff * yield;
|
||||
efficiencies.add(efficiency);
|
||||
}
|
||||
}
|
||||
// int i = phd.getEfficiencyCurRow();
|
||||
// if(i < 0 || i >= e_size) break;
|
||||
//
|
||||
// double y1, y0, x1, x0;
|
||||
// if(i < e_size - 1) {
|
||||
// y1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+3))));
|
||||
// y0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+1))));
|
||||
// x1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+2))));
|
||||
// x0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2))));
|
||||
// } else {
|
||||
// y1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2+1))));
|
||||
// y0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2-1))));
|
||||
// x1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2))));
|
||||
// x0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i*2-2))));
|
||||
// }
|
||||
// for (int j=0; j<nuclideLines.fullNames.size(); j++) {
|
||||
// //获取峰核素能量值
|
||||
// Double energy = nuclideLines.venergy.get(j);
|
||||
// Double yield = nuclideLines.vyield.get(j);
|
||||
// //能量不为空
|
||||
// if (Objects.nonNull(energy) && Objects.nonNull(yield)) {
|
||||
// double eff = y0 + (y1 - y0) * (energy - x0) / (x1 - x0);
|
||||
// if (Double.isFinite(eff)) {
|
||||
// double efficiency = eff * yield;
|
||||
// efficiencies.add(efficiency);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// equation += "Efficiency = "+y0+" + ("+y1+"-"+y0+") * (E - "+x0+") / ("+x1+" - "+x0+")";
|
||||
}
|
||||
break;
|
||||
|
@ -4713,33 +4734,44 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
break;
|
||||
case 8: // Polynomial in log(y) against log(1/x): log(y) = a0 + a1*log(c/x) + a2*log(c/x)^2 + a3*log(c/x)^3 + a4*log(c/x)^4
|
||||
if(p_size >= 3) {
|
||||
for (int j=0; j<nuclideLines.fullNames.size(); j++) {
|
||||
List<Double> effList = CalValuesHandler.calFcnEval(nuclideLines.venergy, phd.getEfficiencyParam()).counts;
|
||||
for (int j=0; j<effList.size(); j++) {
|
||||
//获取峰核素能量值
|
||||
Double energy = nuclideLines.venergy.get(j);
|
||||
Double eff = effList.get(j);
|
||||
Double yield = nuclideLines.vyield.get(j);
|
||||
double C = Math.round(phd.getEfficiencyParam().get(phd.getEfficiencyParam().size() - 1));
|
||||
//能量不为空
|
||||
if (Objects.nonNull(energy) && Objects.nonNull(yield)) {
|
||||
double paramA = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(1))));
|
||||
double paramB = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(2)))) * Math.log(C/energy);
|
||||
if (Double.isNaN(paramB)) {
|
||||
paramB = 0;
|
||||
}
|
||||
double param = paramA + paramB;
|
||||
for(int i=3; i<=p_size; i++) {
|
||||
double paramC = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i)))) * Math.pow(Math.log(C/energy), (i-1));
|
||||
if (Double.isNaN(paramC)) {
|
||||
paramC = 0;
|
||||
}
|
||||
param += paramC;
|
||||
}
|
||||
double eff = Math.pow(Math.E, param);
|
||||
if (Double.isFinite(eff)) {
|
||||
double efficiency = eff * yield;
|
||||
efficiencies.add(efficiency);
|
||||
}
|
||||
if (Double.isFinite(eff)) {
|
||||
double efficiency = eff * yield;
|
||||
efficiencies.add(efficiency);
|
||||
}
|
||||
}
|
||||
// for (int j=0; j<nuclideLines.fullNames.size(); j++) {
|
||||
// //获取峰核素能量值
|
||||
// Double energy = nuclideLines.venergy.get(j);
|
||||
// Double yield = nuclideLines.vyield.get(j);
|
||||
// double C = Math.round(phd.getEfficiencyParam().get(phd.getEfficiencyParam().size() - 1));
|
||||
// //能量不为空
|
||||
// if (Objects.nonNull(energy) && Objects.nonNull(yield)) {
|
||||
// double paramA = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(1))));
|
||||
// double paramB = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(2)))) * Math.log(C/energy);
|
||||
// if (Double.isNaN(paramB)) {
|
||||
// paramB = 0;
|
||||
// }
|
||||
// double param = paramA + paramB;
|
||||
// for(int i=3; i<=p_size; i++) {
|
||||
// double paramC = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i)))) * Math.pow(Math.log(C/energy), (i-1));
|
||||
// if (Double.isNaN(paramC)) {
|
||||
// paramC = 0;
|
||||
// }
|
||||
// param += paramC;
|
||||
// }
|
||||
// double eff = Math.pow(Math.E, param);
|
||||
// if (Double.isFinite(eff)) {
|
||||
// double efficiency = eff * yield;
|
||||
// efficiencies.add(efficiency);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// equation += "log(Efficiency) = "+NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(1)))+" + "+NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(2)))+" * log(C/E)";
|
||||
// for(int i=3; i<=p_size; i++) {
|
||||
// equation += " + "+NumberFormatUtil.numberFormat(String.valueOf(phd.getEfficiencyParam().get(i)))+" * log(C/E)<sup style=\"vertical-align:super;\">"+(i-1)+"</sup>";
|
||||
|
|
Loading…
Reference in New Issue
Block a user