添加根据台站类型获取QC参数

This commit is contained in:
duwenyuan 2025-07-15 11:06:10 +08:00
parent a16c039a9c
commit 21b473e036

View File

@ -19,6 +19,7 @@ import org.jeecg.common.properties.ParameterProperties;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
import org.jeecg.modules.base.entity.configuration.GardsStations;
import org.jeecg.modules.base.enums.CalName;
import org.jeecg.modules.base.enums.CalType;
import org.jeecg.modules.base.enums.MiddleDataType;
@ -535,9 +536,16 @@ public class GammaFileUtil extends AbstractLogOrReport {
//声明一个数组存储QcItems数据
Map<String, QcCheckItem> qcItems = new TreeMap<>();
//调用方法 读取文件信息 判断QC数据
if(!ReadQCLimit(qcItems, vMdcInfoMap, Be7Value, phd.getHeader().getSystem_type().toUpperCase())) {
//if (!ReadQCLimit(qcItems, vMdcInfoMap, Be7Value, phd.getHeader().getSystem_type().toUpperCase())) {
// String WARNING = "Read QC Flags from SystemManager.xml Failed!";
//}
String stationCode = phd.getHeader().getSite_code();
GardsStations stationInfo = getStationInfo(stationCode);
String stationType = stationInfo.getEfficCalculType();
if (!ReadQCLimitByStationType(qcItems, vMdcInfoMap, Be7Value, stationType, stationCode)) {
String WARNING = "Read QC Flags from SystemManager.xml Failed!";
}
//判断map是否为空
if (CollectionUtils.isNotEmpty(vMdcInfoMap)) {
//根据键值按顺序向数组中插入数据
@ -906,6 +914,129 @@ public class GammaFileUtil extends AbstractLogOrReport {
return true;
}
//region 添加根据台站类型获取QC参数
public boolean ReadQCLimitByStationType(Map<String, QcCheckItem> qcItems, Map<String, Double> vMdcInfoMap,
List<Double> Be7Value, String systemType, String stationCode) {
try {
String filePath = parameterProperties.getFilePath() + File.separator + "parameter.xml";
log.info("filePath:" + filePath);
//创建一个文档解析器工厂
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//创建文档解析器
DocumentBuilder documentBuilder = factory.newDocumentBuilder();
//读取xml文件生成一个文档
Document document = documentBuilder.parse(filePath);
log.info("stationCode:" + stationCode);
log.info("document:" + document);
log.info("systemType:" + systemType);
if (StringUtils.isBlank(stationCode) || Objects.isNull(document)) {
return false;
}
//获取文档的根元素
Element element = document.getDocumentElement();
log.info("获取文档的根元素:" + element);
if (stationCode.charAt(2) == 'X' && systemType.equals("SPALAX")) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX
NodeList nodes = element.getElementsByTagName("QCFlags-SPALAX");
log.info("第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 QCFlags-SPALAX:" + nodes);
for (int i = 0; i < nodes.getLength(); i++) {
parseQCFlags(nodes.item(i), qcItems, vMdcInfoMap, Be7Value);
}
} else if (stationCode.charAt(2) == 'X' && systemType.equals("SPALAX_PLC")) {
//切割台站编码 如果 第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 SPALAX-PLC
NodeList nodes = element.getElementsByTagName("QCFlags-SPALAX-PLC");
log.info("第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 QCFlags-SPALAX-PLC:" + nodes);
for (int i = 0; i < nodes.getLength(); i++) {
parseQCFlags(nodes.item(i), qcItems, vMdcInfoMap, Be7Value);
}
} else if (stationCode.charAt(2) == 'P') {
//切割台站编码 如果 第三个字符是 P
NodeList nodes = element.getElementsByTagName("QCFlags-P");
log.info("第三个字符是 X 并且 EFFIC_CALCUL_TYPE类型是 QCFlags-P:" + nodes);
for (int i = 0; i < nodes.getLength(); i++) {
parseQCFlags(nodes.item(i), qcItems, vMdcInfoMap, Be7Value);
}
}
log.info("col_time:" + qcItems.get("col_time"));
} catch (ParserConfigurationException | IOException | SAXException e) {
throw new RuntimeException(e);
}
return true;
}
private static void parseQCFlags(Node node, Map<String, QcCheckItem> qcItems, Map<String, Double> vMdcInfoMap, List<Double> Be7Value) {
Node childNode = node.getFirstChild();
QcCheckItem qcCheckItem = new QcCheckItem();
while (Objects.nonNull(childNode)) {
String nodeName = childNode.getNodeName();
switch (nodeName) {
case "col_time":
case "acq_time":
case "decay_time":
case "samp_vol":
case "Xe133-MDC":
case "airFlow":
case "Be7-FWHM":
case "Ba140-MDC":
qcCheckItem = new QcCheckItem();
setAttributeSetter(childNode, "green", qcCheckItem::setStandard);
qcItems.put(nodeName, qcCheckItem);
log.info(nodeName + ":" + qcCheckItem.getStandard());
break;
case "Be7":
setAttributeSetter(childNode, CalType.ENERGY_CAL.getType(), value -> Be7Value.add(Double.valueOf(value)));
log.info(nodeName + ":" + Be7Value);
break;
case "Ba140":
setAttributeSetter(childNode, CalType.ENERGY_CAL.getType(), value -> vMdcInfoMap.put("0", Double.valueOf(value)));
setAttributeSetter(childNode, "yield", value -> vMdcInfoMap.put("1", Double.valueOf(value)));
setAttributeSetter(childNode, "halflife", value -> vMdcInfoMap.put("2", Double.valueOf(value)));
log.info(nodeName + ":" + vMdcInfoMap.get("0") + vMdcInfoMap.get("1") + vMdcInfoMap.get("2"));
break;
case "Xe133":
setAttributeSetter(childNode, CalType.ENERGY_CAL.getType(), value -> vMdcInfoMap.put("0", Double.valueOf(value)));
setAttributeSetter(childNode, "yield", value -> vMdcInfoMap.put("1", Double.valueOf(value)));
setAttributeSetter(childNode, "halflife", value -> vMdcInfoMap.put("2", Double.valueOf(value)));
log.info(nodeName + ":" + vMdcInfoMap.get("0") + vMdcInfoMap.get("1") + vMdcInfoMap.get("2"));
break;
}
childNode = childNode.getNextSibling();
}
}
//根据map的value获取map的key
private GardsStations getStationInfo(String value) {
Map<String, String> stationMap = (Map<String, String>) redisUtil.get("stationMap");
Map<String, GardsStations> stations = (Map<String, GardsStations>) redisUtil.get("stationInfoMap");
GardsStations station = new GardsStations();
if (Objects.nonNull(stationMap)) {
for (Map.Entry<String, String> entry : stationMap.entrySet()) {
if (value.equals(entry.getValue())) {
station = stations.get(entry.getKey());
}
}
}
return station;
}
private static void setAttributeSetter(Node node, String attributeName, AttributeSetter setter) {
NamedNodeMap attributes = node.getAttributes();
if (Objects.nonNull(attributes)) {
for (int i = 0; i < attributes.getLength(); i++) {
Node item = attributes.item(i);
if (attributeName.equals(item.getNodeName())) {
setter.setValue(item.getNodeValue());
}
}
}
}
@FunctionalInterface
private interface AttributeSetter {
void setValue(String value);
}
public List<String> DetailedInfo(String sampleId, PHDFile phd) {
try {
// Sample_Id, Station_Code, Detector_Code, System_Type, Data_Type, Spectral_Qualifier,
@ -1551,8 +1682,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|| newSets.getK_beta() != oldSets.getK_beta()
|| newSets.getRiskLevelK() != oldSets.getRiskLevelK()
|| !newSets.getRefTime_act().equals(oldSets.getRefTime_act())
|| !newSets.getRefTime_conc().equals(oldSets.getRefTime_conc()))
{
|| !newSets.getRefTime_conc().equals(oldSets.getRefTime_conc())) {
return 1;
}
@ -1662,8 +1792,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
if (rate > 0.5) {
// 获取用于计算ActivityMDC的主γ峰和最大分支比
double maxFoundYield = vYield.get(iter.getValue().maxYeildIdx);
if(mainPeakIdx < 0)
{
if (mainPeakIdx < 0) {
maxFoundYield = 0;
for (int ii = 0; ii < vFit.size(); ii++) {
if (vFit.get(ii) >= 0 && vYield.get(ii) > maxFoundYield) {
@ -2185,8 +2314,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
if (i < 0 || i >= e_size) break;
double y1, y0, x1, x0;
if(i < e_size - 1)
{
if (i < e_size - 1) {
y1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(i * 2 + 3))));
y0 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(i * 2 + 1))));
x1 = Double.valueOf(NumberFormatUtil.numberFormat(String.valueOf(m_curParam.getP().get(i * 2 + 2))));
@ -2331,6 +2459,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
}
return bRet;
}
public boolean GetInterMiddlData(List<PHDFile> phds, String userName, List<GStoreMiddleProcessData> middleDatas, String flag) {
boolean bRet = true;
try {
@ -3435,50 +3564,116 @@ public class GammaFileUtil extends AbstractLogOrReport {
public String EquationDescription(int funcId) {
String desc = "";
switch (funcId)
{
case 1: desc = "y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x<x(i+1)"; break;
case 2: desc = "y=a0+a1*x+a2*x^2+a3*x^3"; break;
case 3: desc = "y=a0+a1*x^(1/2)+a2*x+a3*x^(3/2)"; break;
case 4: desc = "y=sqrt(a0+a1*x+a2*x^2+a3*x^3)"; break;
case 5: desc = "y=A*exp(-(E1/x)^k)*(1-exp(-(E2/x)^n))"; break;
case 6: desc = "log(y)=a0+a1*log(x)+a2*log(x)^2+a3*log(x)^3"; break;
case 7: desc = "log(y)=a0*x+a1+a2/x+a3/(x^2)"; break;
case 8: desc = "log(y)=a0+a1*log(c/x)+a2*log(c/x)^2+a3*log(c/x)^3+a4*log(c/x)^4"; break;
case 9: desc = "y=1/(a*x^(-k)+b*x^(-n))"; break;
case 93: desc = "y=S*exp(-(E1/x)^k)*(1-exp(-(2*E3/(x-E3))^n"; break;
case 94: desc = "y=S*exp(-(E1/x)^k)*(1-exp(-b*(1/(x-E2))^m))"; break;
case 95: desc = "y=S*exp(-(E1/x)^k)*(1-exp(-b*(1/(x-E2))^m))*(1-exp(-(2*E3/(E-E3))^n))"; break;
case 96: desc = "y=A+E1*x^(-n)"; break;
case 97: desc = "y=a0+a1*exp(-lam1*x)"; break;
case 98: desc = "y=c"; break;
case 99: desc = "y=t_0+k_t*x if x>ECut"; break;
default: desc = ""; break;
switch (funcId) {
case 1:
desc = "y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x<x(i+1)";
break;
case 2:
desc = "y=a0+a1*x+a2*x^2+a3*x^3";
break;
case 3:
desc = "y=a0+a1*x^(1/2)+a2*x+a3*x^(3/2)";
break;
case 4:
desc = "y=sqrt(a0+a1*x+a2*x^2+a3*x^3)";
break;
case 5:
desc = "y=A*exp(-(E1/x)^k)*(1-exp(-(E2/x)^n))";
break;
case 6:
desc = "log(y)=a0+a1*log(x)+a2*log(x)^2+a3*log(x)^3";
break;
case 7:
desc = "log(y)=a0*x+a1+a2/x+a3/(x^2)";
break;
case 8:
desc = "log(y)=a0+a1*log(c/x)+a2*log(c/x)^2+a3*log(c/x)^3+a4*log(c/x)^4";
break;
case 9:
desc = "y=1/(a*x^(-k)+b*x^(-n))";
break;
case 93:
desc = "y=S*exp(-(E1/x)^k)*(1-exp(-(2*E3/(x-E3))^n";
break;
case 94:
desc = "y=S*exp(-(E1/x)^k)*(1-exp(-b*(1/(x-E2))^m))";
break;
case 95:
desc = "y=S*exp(-(E1/x)^k)*(1-exp(-b*(1/(x-E2))^m))*(1-exp(-(2*E3/(E-E3))^n))";
break;
case 96:
desc = "y=A+E1*x^(-n)";
break;
case 97:
desc = "y=a0+a1*exp(-lam1*x)";
break;
case 98:
desc = "y=c";
break;
case 99:
desc = "y=t_0+k_t*x if x>ECut";
break;
default:
desc = "";
break;
}
return desc;
}
public String EquationName(int funcId) {
String name = "";
switch (funcId)
{
case 1: name = "Interpolation"; break;
case 2: name = "Polynomial"; break;
case 3: name = "Square root polynomial"; break;
case 4: name = "Square root of polynomial"; break;
case 5: name = "HT Efficiency"; break;
case 6: name = "Polynomial in log(y) against log(x)"; break;
case 7: name = "Polynomial in log(y)"; break;
case 8: name = "Polynomial in log(y) against log(1/x)"; break;
case 9: name = "Inverse exponential"; break;
case 93: name = "HAE Efficiency (1-3)"; break;
case 94: name = "HAE Efficiency (1-2)"; break;
case 95: name = "HAE Efficiency (1-2-3)"; break;
case 96: name = "Inverse power"; break;
case 97: name = "Exponential sum"; break;
case 98: name = "Constant"; break;
case 99: name = "Linear with cut-off"; break;
default: name = ""; break;
switch (funcId) {
case 1:
name = "Interpolation";
break;
case 2:
name = "Polynomial";
break;
case 3:
name = "Square root polynomial";
break;
case 4:
name = "Square root of polynomial";
break;
case 5:
name = "HT Efficiency";
break;
case 6:
name = "Polynomial in log(y) against log(x)";
break;
case 7:
name = "Polynomial in log(y)";
break;
case 8:
name = "Polynomial in log(y) against log(1/x)";
break;
case 9:
name = "Inverse exponential";
break;
case 93:
name = "HAE Efficiency (1-3)";
break;
case 94:
name = "HAE Efficiency (1-2)";
break;
case 95:
name = "HAE Efficiency (1-2-3)";
break;
case 96:
name = "Inverse power";
break;
case 97:
name = "Exponential sum";
break;
case 98:
name = "Constant";
break;
case 99:
name = "Linear with cut-off";
break;
default:
name = "";
break;
}
return name;
}
@ -3634,8 +3829,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
middleData.calibration_pairs_S_EF_Caltype = CalType.EFFICIENCY_CAL.getType();
middleData.calibration_pairs_S_EF_Input = fileAnlyse.getUsedEffi();
List<String> temp = new LinkedList<>();
for(int pos=0;pos<fileAnlyse.getUsedEffiKD().getG_energy().size();pos++)
{
for (int pos = 0; pos < fileAnlyse.getUsedEffiKD().getG_energy().size(); pos++) {
temp.add(String.valueOf(pos));
}
middleData.calibration_pairs_EF_idCalPoint = temp;
@ -4144,14 +4338,11 @@ public class GammaFileUtil extends AbstractLogOrReport {
{
halflife /= 31556736;
units = 'A';
}
else if(halflife >= 86400) // 1天 = 24 * 60 * 60 = 86400s
} else if (halflife >= 86400) // 1天 = 24 * 60 * 60 = 86400s
{
halflife /= 86400;
units = 'D';
}
else if(halflife >= 3600)
{
} else if (halflife >= 3600) {
halflife /= 3600;
units = 'H';
}