feat:Gamma savaToExcel

This commit is contained in:
nieziyan 2023-10-12 11:19:08 +08:00
parent 571502cc36
commit 94665f35a5
2 changed files with 97 additions and 35 deletions

View File

@ -0,0 +1,28 @@
package org.jeecg.modules.base.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class NuclideActMdaDto implements Serializable {
private String nuclide;
private String halflife;
private String yield;
private String energy;
private String efficiency;
private String activity;
private String actErr;
private String mda;
private String conc;
private String mdc;
}

View File

@ -29,6 +29,7 @@ import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.*;
import org.jeecg.modules.base.abstracts.AbstractLogOrReport;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.base.dto.NuclideActMdaDto;
import org.jeecg.modules.base.dto.PeakInfoDto;
import org.jeecg.modules.base.entity.configuration.GardsNuclLib;
import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib;
@ -4115,44 +4116,77 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
}
data.put("peak", peakInfoDtos);
/* The Results of Nuclide Identify */
// 获取所有核素名称 去重
List<String> nuclides = peakInfos.stream()
.flatMap(peakInfo -> peakInfo.nuclides.stream())
.distinct().collect(Collectors.toList());
String nuclideStr = String.join(" ", nuclides);
nuclideStr = ObjectUtil.isNull(nuclideStr) ? "" : nuclideStr;
data.put("nuclides", nuclideStr);
/* Nuclide's Activity and Concentration */
// 时间部分
String actTime = ""; String concTime = "";
Date refTimeAct = phd.getUsedSetting().getRefTime_act();
Date refTimeConc = phd.getUsedSetting().getRefTime_conc();
if (ObjectUtil.isNotNull(refTimeAct))
actTime = DateUtil.format(refTimeAct, DateConstant.DATE_BIAS_TIME);
if (ObjectUtil.isNotNull(refTimeConc))
concTime = DateUtil.format(refTimeConc, DateConstant.DATE_BIAS_TIME);
data.put("actTime", actTime); data.put("concTime", concTime);
// 数据部分
Map<String, NuclideActMda> mapNucActMda = phd.getMapNucActMda();
List<NuclideActMdaDto> nuclideActs = new ArrayList<>();
for (Map.Entry<String, NuclideActMda> entry : mapNucActMda.entrySet()) {
NuclideActMdaDto nuclideActMdaDto = new NuclideActMdaDto();
String nuclide = entry.getKey();
nuclideActMdaDto.setNuclide(nuclide);
NuclideActMda nuclideActMda = entry.getValue();
String halflifeValue = "";
if(nuclideActMda.isBCalculateMDA()) {
String units = "S";
double halflife = nuclideActMda.getHalflife();
if(halflife >= 31556736) { // 1年 = 31556736s
halflife /= 31556736;
units = "A";
} else if(halflife >= 86400) { // 1天 = 86400s
halflife /= 86400;
units = "D";
} else if(halflife >= 3600) { // 1小时 = 3600s
halflife /= 3600;
units = "H";
}
halflifeValue = NumberFormatUtil.numberFormat(String.valueOf(halflife)) + units;
}
nuclideActMdaDto.setHalflife(halflifeValue);
String efficiency = NumberFormatUtil.numberFormat(String.valueOf(nuclideActMda.getEfficiency()));
nuclideActMdaDto.setEfficiency(efficiency);
double actErrValue = nuclideActMda.getAct_err();
double activityValue = nuclideActMda.getActivity();
String activity = NumberFormatUtil.numberFormat(String.valueOf(activityValue));
nuclideActMdaDto.setActivity(activity);
String actErr = NumberFormatUtil.numberFormat(String.valueOf(actErrValue / activityValue * 100));
nuclideActMdaDto.setActErr(actErr);
String mda = NumberFormatUtil.numberFormat(String.valueOf(nuclideActMda.getMda()));
nuclideActMdaDto.setMda(mda);
String conc = NumberFormatUtil.numberFormat(String.valueOf(nuclideActMda.getConcentration()));
nuclideActMdaDto.setConc(conc);
String mdc = NumberFormatUtil.numberFormat(String.valueOf(nuclideActMda.getMdc()));
nuclideActMdaDto.setMdc(mdc);
int calculateIdx = nuclideActMda.getCalculateIdx();
List<Double> vEnergy = nuclideActMda.getVEnergy();
List<Double> vYield = nuclideActMda.getVYield();
if(calculateIdx >= 0 && calculateIdx < vEnergy.size()) {
String yield = NumberFormatUtil.numberFormat(String.valueOf(vYield.get(calculateIdx) * 100));
String energy = NumberFormatUtil.numberFormat(String.valueOf(vEnergy.get(calculateIdx)));
nuclideActMdaDto.setYield(yield); nuclideActMdaDto.setEnergy(energy);
} else {
nuclideActMdaDto.setYield("NULL"); nuclideActMdaDto.setEnergy("NULL");
}
nuclideActs.add(nuclideActMdaDto);
}
data.put("nuclideActs", nuclideActs);
String template = SAVETOEXCEL_G.getName();
// 导出时使用默认文件名 file.xls
ExportUtil.exportXls(response, template, data);
}
/**
* 行日志格式化
* @param source 需要格式化的字符串
* @param symbolNum 格式化的符号数量
* @param args 格式化替换参数数组
* @return
*/
private String titleFormat(String source, Integer symbolNum, String... args){
StringBuilder firstParam = new StringBuilder();
for (int i=0;i<symbolNum;i++){
firstParam.append(args[0]);
}
args[0] = firstParam.toString();
StringBuilder lastParam = new StringBuilder();
for (int i=0;i<symbolNum;i++){
lastParam.append(args[args.length-1]);
}
args[args.length-1] = lastParam.toString();
return String.format(source,args);
}
/**
* 行格式化
* @param source
* @param args
* @return
*/
private String rowFormat(String source, String... args){
return String.format(source,args);
}
}