fix:Gamma RLR
This commit is contained in:
parent
ae2dfc2697
commit
492795c445
|
@ -1,11 +1,17 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
public class NumUtil {
|
||||
|
||||
/*
|
||||
* 整数位+小数位的和 保留指定位数
|
||||
* */
|
||||
public static Double fixedMax(int bit, Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return value;
|
||||
|
@ -17,4 +23,51 @@ public class NumUtil {
|
|||
BigDecimal decimal = new BigDecimal(value);
|
||||
return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
public static Double keep2(Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(value));
|
||||
return decimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
public static String keep2Str(Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(value));
|
||||
return String.valueOf(decimal.setScale(2, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
}
|
||||
|
||||
public static Double keep3(Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(value));
|
||||
return decimal.setScale(3, RoundingMode.HALF_UP).doubleValue();
|
||||
}
|
||||
|
||||
public static String keep3Str(Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(value));
|
||||
return String.valueOf(decimal.setScale(3, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
}
|
||||
|
||||
public static String keep4ScienceStr(Double value){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
String result = NumberUtil.decimalFormat("0.####E00", value);
|
||||
if (!StrUtil.contains(result, "E-"))
|
||||
return StrUtil.replace(result, "E", "E+");
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String keepStr(Double value, int scale){
|
||||
if (ObjectUtil.isNull(value))
|
||||
return null;
|
||||
BigDecimal decimal = new BigDecimal(String.valueOf(value));
|
||||
return String.valueOf(decimal.setScale(scale, RoundingMode.HALF_UP)
|
||||
.doubleValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package org.jeecg.modules.base.bizVo;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.entity.vo.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
|
|
@ -21,4 +21,15 @@ public class Nuclides implements Serializable {
|
|||
private String mdc;
|
||||
|
||||
private String lc;
|
||||
|
||||
public Nuclides() {
|
||||
this.name = "";
|
||||
this.activity = "";
|
||||
this.uncertActivity = "";
|
||||
this.mda = "";
|
||||
this.concentration = "";
|
||||
this.uncertConcentration = "";
|
||||
this.mdc = "";
|
||||
this.lc = "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,11 @@ public class Ratios implements Serializable {
|
|||
private String isotopeRatio;
|
||||
|
||||
private String uncertRatio;
|
||||
|
||||
public Ratios() {
|
||||
this.nuclide1 = "";
|
||||
this.nuclide2 = "";
|
||||
this.isotopeRatio = "";
|
||||
this.uncertRatio = "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.io.Serializable;
|
|||
@Data
|
||||
public class TableAssociation implements Serializable {
|
||||
|
||||
private Integer index;
|
||||
|
||||
private String exLevel;
|
||||
|
||||
private String identified;
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.io.Serializable;
|
|||
@Data
|
||||
public class TablePeakFit implements Serializable {
|
||||
|
||||
private Integer index;
|
||||
|
||||
private String energy;
|
||||
|
||||
private String energyErr;
|
||||
|
|
Binary file not shown.
|
@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -1957,7 +1958,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
String col_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time();
|
||||
map.put("collect_start", col_start);
|
||||
map.put("collect_stop", col_stop);
|
||||
map.put("collect_airVolume", phd.getCollect().getAir_volume());
|
||||
map.put("collect_airVolume", NumUtil.keep3(phd.getCollect().getAir_volume()));
|
||||
// Init #SampleReceipt
|
||||
if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){
|
||||
map.put("Receipt_srid", phd.getHeader().getSample_ref_id());
|
||||
|
@ -1981,17 +1982,18 @@ public class GammaServiceImpl implements IGammaService {
|
|||
double live_time = phd.getAcq().getAcquisition_live_time();
|
||||
for(int i=0; i<num; ++i) {
|
||||
TablePeakFit tablePeak = new TablePeakFit();
|
||||
tablePeak.setIndex(i + 1);
|
||||
PeakInfo peak = phd.getVPeak().get(i);
|
||||
tablePeak.setEnergy(String.valueOf(peak.energy));
|
||||
tablePeak.setEnergy(NumUtil.keep3Str(peak.energy));
|
||||
tablePeak.setEnergyErr(energy_uncert);
|
||||
tablePeak.setNetArea(String.valueOf(peak.area));
|
||||
String area_err = peak.area > 0 ? String.valueOf(peak.areaErr/peak.area*100) : "0";
|
||||
tablePeak.setNetArea(NumUtil.keep4ScienceStr(peak.area));
|
||||
String area_err = peak.area > 0 ? NumUtil.keep2Str(peak.areaErr/peak.area*100) : "0";
|
||||
tablePeak.setAreaErr(area_err);
|
||||
String rate = live_time > 0 ? String.valueOf(peak.area/live_time) : "0";
|
||||
String rate = live_time > 0 ? NumUtil.keep4ScienceStr(peak.area/live_time) : "0";
|
||||
tablePeak.setNetCountRate(rate);
|
||||
tablePeak.setNcRateErr(area_err);
|
||||
tablePeak.setLc(String.valueOf(peak.lc));
|
||||
tablePeak.setSignificance(String.valueOf(peak.significance));
|
||||
tablePeak.setLc(NumUtil.keep4ScienceStr(peak.lc));
|
||||
tablePeak.setSignificance(NumUtil.keep2Str(peak.significance));
|
||||
peakFitList.add(tablePeak);
|
||||
}
|
||||
map.put("peakFit", peakFitList);
|
||||
|
@ -2006,6 +2008,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
List<TableAssociation> associationList = new LinkedList<>();
|
||||
for(int i=0; i<num; ++i) {
|
||||
TableAssociation tableAssociation = new TableAssociation();
|
||||
tableAssociation.setIndex(i + 1);
|
||||
tableAssociation.setExLevel(Explanation_Level);
|
||||
List<String> nuclides = phd.getVPeak().get(i).nuclides;
|
||||
String iden = "";
|
||||
|
@ -2035,12 +2038,12 @@ public class GammaServiceImpl implements IGammaService {
|
|||
TableResult tableResult = new TableResult();
|
||||
NuclideActMda nuc = it.getValue();
|
||||
tableResult.setNuclide(it.getKey());
|
||||
tableResult.setActivity(String.valueOf(nuc.getActivity()));
|
||||
String act_err = nuc.getActivity() > 0 ? String.valueOf(nuc.getAct_err()/nuc.getActivity()*100) : "0";
|
||||
tableResult.setActivity(NumUtil.keepStr(nuc.getActivity(), 6));
|
||||
String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 4) : "0";
|
||||
tableResult.setActErr(act_err);
|
||||
tableResult.setFactor1(coverage_factor);
|
||||
tableResult.setConfidence1(level_confidence);
|
||||
tableResult.setConc(String.valueOf(nuc.getConcentration()/1000));
|
||||
tableResult.setConc(NumUtil.keepStr(nuc.getConcentration()/1000, 5));
|
||||
tableResult.setConcErr(act_err);
|
||||
tableResult.setFactor2(coverage_factor);
|
||||
tableResult.setConfidence2(level_confidence);
|
||||
|
@ -2069,8 +2072,10 @@ public class GammaServiceImpl implements IGammaService {
|
|||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportRLR(GammaRLR gammaRLR, HttpServletResponse response) {
|
||||
if (ObjectUtil.isNull(gammaRLR)) return;
|
||||
String pathPrefix = "excelTemplate/";
|
||||
String path = pathPrefix + RLR_G.getName();
|
||||
String template = ClassUtil.classPath(path);
|
||||
|
@ -2143,6 +2148,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) {
|
||||
if (Objects.isNull(sampleId)){
|
||||
|
|
|
@ -1319,14 +1319,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
|
||||
String export = "RLR-Beta.xls";
|
||||
String template = RLR_B.getName();
|
||||
ExportUtil.exportXls(response, template, dataMap,export);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
BetaRLR betaRLR = new BetaRLR();
|
||||
Map<String,Object> dataMap = BeanUtil.beanToMap(betaRLR);
|
||||
dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
|
||||
dataMap.forEach((key, value) -> System.out.println(key + "---" + value));
|
||||
ExportUtil.exportXls(response, template, dataMap, export);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user