gamma模块saveToTXT功能
This commit is contained in:
parent
e3b251ee2d
commit
d9ba592743
|
@ -175,8 +175,9 @@ public class GammaServiceImpl implements IGammaService {
|
|||
@Override
|
||||
public Result testFun(String fileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName);
|
||||
PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName);
|
||||
phd.setUserId("1");
|
||||
phd.setXmlFilePath(parameterProperties.getFilePath());
|
||||
String systemType = fileName.substring(2, 3);
|
||||
|
@ -184,7 +185,6 @@ public class GammaServiceImpl implements IGammaService {
|
|||
result.error500("请先选择解析文件!");
|
||||
return result;
|
||||
}
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
//查询当前用户关联的核素信息
|
||||
List<String> nuclides = new LinkedList<>();
|
||||
//从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的
|
||||
|
@ -1208,12 +1208,12 @@ public class GammaServiceImpl implements IGammaService {
|
|||
}
|
||||
tablePeaks.setNuclide(StringUtils.isBlank(nuclide)?nuclide:nuclide.substring(0,nuclide.length()-1));
|
||||
|
||||
tablePeaks.setEnergy(NumberFormatUtil.numberCal(String.valueOf(peak.energy)));
|
||||
tablePeaks.setNetArea(NumberFormatUtil.numberCal(String.valueOf(peak.area)));
|
||||
tablePeaks.setFwhm(NumberFormatUtil.numberCal(String.valueOf(peak.fwhm)));
|
||||
tablePeaks.setStep(NumberFormatUtil.numberCal(String.valueOf(peak.area * peak.stepRatio)));
|
||||
tablePeaks.setEnergy(NumberFormatUtil.numberFormat(String.valueOf(peak.energy)));
|
||||
tablePeaks.setNetArea(NumberFormatUtil.numberFormat(String.valueOf(peak.area)));
|
||||
tablePeaks.setFwhm(NumberFormatUtil.numberFormat(String.valueOf(peak.fwhm)));
|
||||
tablePeaks.setStep(NumberFormatUtil.numberFormat(String.valueOf(peak.area * peak.stepRatio)));
|
||||
double deriva = CalValuesHandler.calDerivaOut(peak.peakCentroid, phd.getUsedEnerPara().getP());
|
||||
tablePeaks.setBwGamma(NumberFormatUtil.numberCal(String.valueOf(peak.BWWidthChan * deriva)));
|
||||
tablePeaks.setBwGamma(NumberFormatUtil.numberFormat(String.valueOf(peak.BWWidthChan * deriva)));
|
||||
tablePeaks.setNetAreaB(false);
|
||||
tablePeaks.setCentroid(true);
|
||||
tablePeaks.setFwhmB(true);
|
||||
|
@ -3366,7 +3366,7 @@ public class GammaServiceImpl implements IGammaService {
|
|||
}
|
||||
item.setName(name);
|
||||
item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL");
|
||||
item.setValue( Double.parseDouble(NumberFormatUtil.numberCal(String.valueOf(iter.getValue().getValue()))) );
|
||||
item.setValue( Double.parseDouble(NumberFormatUtil.numberFormat(String.valueOf(iter.getValue().getValue()))) );
|
||||
String standard="";
|
||||
List<String> strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA));
|
||||
for (String str : strList) {
|
||||
|
@ -3484,16 +3484,16 @@ public class GammaServiceImpl implements IGammaService {
|
|||
TablePeakFit tablePeak = new TablePeakFit();
|
||||
tablePeak.setIndex(i + 1);
|
||||
PeakInfo peak = phd.getVPeak().get(i);
|
||||
tablePeak.setEnergy( NumberFormatUtil.numberCal(String.valueOf(peak.energy)) );
|
||||
tablePeak.setEnergy( NumberFormatUtil.numberFormat(String.valueOf(peak.energy)) );
|
||||
tablePeak.setEnergyErr(energy_uncert);
|
||||
tablePeak.setNetArea( NumberFormatUtil.numberCal(String.valueOf(peak.area)) );
|
||||
String area_err = peak.area > 0 ? NumberFormatUtil.numberCal(String.valueOf(peak.areaErr/peak.area*100)) : "0";
|
||||
tablePeak.setNetArea( NumberFormatUtil.numberFormat(String.valueOf(peak.area)) );
|
||||
String area_err = peak.area > 0 ? NumberFormatUtil.numberFormat(String.valueOf(peak.areaErr/peak.area*100)) : "0";
|
||||
tablePeak.setAreaErr(area_err);
|
||||
String rate = live_time > 0 ? NumberFormatUtil.numberCal(String.valueOf(peak.area/live_time)) : "0";
|
||||
String rate = live_time > 0 ? NumberFormatUtil.numberFormat(String.valueOf(peak.area/live_time)) : "0";
|
||||
tablePeak.setNetCountRate(rate);
|
||||
tablePeak.setNcRateErr(area_err);
|
||||
tablePeak.setLc( NumberFormatUtil.numberCal(String.valueOf(peak.lc)) );
|
||||
tablePeak.setSignificance( NumberFormatUtil.numberCal(String.valueOf(peak.significance)) );
|
||||
tablePeak.setLc( NumberFormatUtil.numberFormat(String.valueOf(peak.lc)) );
|
||||
tablePeak.setSignificance( NumberFormatUtil.numberFormat(String.valueOf(peak.significance)) );
|
||||
peakFitList.add(tablePeak);
|
||||
}
|
||||
map.put("peakFit", peakFitList);
|
||||
|
@ -3925,9 +3925,77 @@ public class GammaServiceImpl implements IGammaService {
|
|||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName+"-"+userName);
|
||||
StringBuilder strBuild = new StringBuilder();
|
||||
//txt文本内容
|
||||
//文本内容第一块内容匹配格式
|
||||
String title1 = " %s The Results of Peak Searching %s";
|
||||
//文本内容第一块内容匹配
|
||||
strBuild.append(titleFormat(title1, 51, StringPool.ASTERISK));
|
||||
//换行
|
||||
strBuild.append(System.lineSeparator());
|
||||
//文本内容第二块
|
||||
//文本内容第二块匹配格式
|
||||
String title2 = "%-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s %-12s";
|
||||
//文本内容第二块第一部分数据信息
|
||||
String[] titleArgs2 = new String[]{"PeakID", "Energy(keV)", "Centroid", "Multiplet", "FWHM(keV)", "NetArea", "NAErr%", "Signif", "Sensit", "Nuclide"};
|
||||
//文本内容第二块第一部分数据匹配
|
||||
strBuild.append(rowFormat(title2, titleArgs2));
|
||||
//遍历数组进行文本内容第二块第二部分数据匹配
|
||||
for (int i=0; i<phd.getVPeak().size(); i++) {
|
||||
PeakInfo peakInfo = phd.getVPeak().get(i);
|
||||
String peakId = String.valueOf(peakInfo.index);
|
||||
String energy = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.energy));
|
||||
String peakCentroid = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.peakCentroid));
|
||||
String multiIndex = String.valueOf(peakInfo.multiIndex);
|
||||
String fwhm = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.fwhm));
|
||||
String area = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.area));
|
||||
String areaErr = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.areaErr));
|
||||
String signif = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.significance));
|
||||
String sensit = NumberFormatUtil.numberFormat(String.valueOf(peakInfo.sensitivity));
|
||||
String nuclide = StringUtils.join(peakInfo.nuclides, StringPool.SEMICOLON);
|
||||
strBuild.append(rowFormat(title2, peakId, energy, peakCentroid, multiIndex, fwhm, area, areaErr, signif, sensit, nuclide));
|
||||
}
|
||||
//换行
|
||||
strBuild.append(System.lineSeparator());
|
||||
//文本内容第三块
|
||||
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(strBuild.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行日志格式化
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user