Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-09-15 10:06:17 +08:00
commit 023ca06a9d
6 changed files with 163 additions and 68 deletions

View File

@ -0,0 +1,27 @@
package org.jeecg.modules.base.enums;
public enum CalibrationType {
Cal_Energy(0),
Cal_Resolution(1),
Cal_Efficiency(2),
Cal_Tot_efficiency(3),
Cal_Tail(4),
Cal_Tail_alpha(5),
Cal_Tail_right(6),
Cal_Tail_right_alpha(7),
Cal_Step_ratio(8),
Cal_HalflifeAnalysis(9),
Cal_Default(10);
public int num;
CalibrationType(int num){
this.num = num;
}
public int getNum(){
return this.num;
}
}

View File

@ -801,63 +801,63 @@ public class PHDFileUtil {
BgDataAnlyseResultIn resultIn = new BgDataAnlyseResultIn();
resultIn.setXe131m_con(bgAnalyseResult.Xe131m_con);
resultIn.setXe131m_uncer(bgAnalyseResult.Xe131m_uncer);
resultIn.setMDC_Xe131m(bgAnalyseResult.MDC_Xe131m);
resultIn.setLC_Xe131m(bgAnalyseResult.LC_Xe131m);
resultIn.setMdc_Xe131m(bgAnalyseResult.MDC_Xe131m);
resultIn.setLc_Xe131m(bgAnalyseResult.LC_Xe131m);
resultIn.setXe131mFlag(bgAnalyseResult.XE_131m_NID_FLAG);
resultIn.setXe133_con(bgAnalyseResult.Xe133_con);
resultIn.setXe133_uncer(bgAnalyseResult.Xe133_uncer);
resultIn.setMDC_Xe133(bgAnalyseResult.MDC_Xe133);
resultIn.setLC_Xe133(bgAnalyseResult.LC_Xe133);
resultIn.setMdc_Xe133(bgAnalyseResult.MDC_Xe133);
resultIn.setLc_Xe133(bgAnalyseResult.LC_Xe133);
resultIn.setXe133Flag(bgAnalyseResult.XE_133_NID_FLAG);
resultIn.setXe133m_con(bgAnalyseResult.Xe133m_con);
resultIn.setXe133m_uncer(bgAnalyseResult.Xe133m_uncer);
resultIn.setMDC_Xe133m(bgAnalyseResult.MDC_Xe133m);
resultIn.setLC_Xe133m(bgAnalyseResult.LC_Xe133m);
resultIn.setMdc_Xe133m(bgAnalyseResult.MDC_Xe133m);
resultIn.setLc_Xe133m(bgAnalyseResult.LC_Xe133m);
resultIn.setXe133mFlag(bgAnalyseResult.XE_133m_NID_FLAG);
resultIn.setXe135_con(bgAnalyseResult.Xe135_con);
resultIn.setXe135_uncer(bgAnalyseResult.Xe135_uncer);
resultIn.setMDC_Xe135(bgAnalyseResult.MDC_Xe135);
resultIn.setLC_Xe135(bgAnalyseResult.LC_Xe135);
resultIn.setMdc_Xe135(bgAnalyseResult.MDC_Xe135);
resultIn.setLc_Xe135(bgAnalyseResult.LC_Xe135);
resultIn.setXe135Flag(bgAnalyseResult.XE_135_NID_FLAG);
List<GardsCalibrationSpectrum> gammaCalibrationSpectrumList = new LinkedList<>();
GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum();
gammaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType());
gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_e_c.get(0));
gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_e_c.get(1));
gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_e_c.get(2));
gammaCalibrationS.setCoeff1(bgAnalyseResult.s_g_fitting_c_e.get(0));
gammaCalibrationS.setCoeff2(bgAnalyseResult.s_g_fitting_c_e.get(1));
gammaCalibrationS.setCoeff3(bgAnalyseResult.s_g_fitting_c_e.get(2));
gammaCalibrationSpectrumList.add(gammaCalibrationS);
GardsCalibrationSpectrum gammaCalibrationG = new GardsCalibrationSpectrum();
gammaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType());
gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_e_c.get(0));
gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_e_c.get(1));
gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_e_c.get(2));
gammaCalibrationG.setCoeff1(bgAnalyseResult.g_g_fitting_c_e.get(0));
gammaCalibrationG.setCoeff2(bgAnalyseResult.g_g_fitting_c_e.get(1));
gammaCalibrationG.setCoeff3(bgAnalyseResult.g_g_fitting_c_e.get(2));
gammaCalibrationSpectrumList.add(gammaCalibrationG);
GardsCalibrationSpectrum gammaCalibrationD = new GardsCalibrationSpectrum();
gammaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType());
gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_e_c.get(0));
gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_e_c.get(1));
gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_e_c.get(2));
gammaCalibrationD.setCoeff1(bgAnalyseResult.d_g_fitting_c_e.get(0));
gammaCalibrationD.setCoeff2(bgAnalyseResult.d_g_fitting_c_e.get(1));
gammaCalibrationD.setCoeff3(bgAnalyseResult.d_g_fitting_c_e.get(2));
gammaCalibrationSpectrumList.add(gammaCalibrationD);
List<GardsCalibrationSpectrum> betaCalibrationSpectrumList = new LinkedList<>();
// GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum();
// betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType());
// betaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0));
// betaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1));
// betaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2));
// betaCalibrationSpectrumList.add(betaCalibrationS);
// GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum();
// betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType());
// betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0));
// betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1));
// betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2));
// betaCalibrationSpectrumList.add(betaCalibrationG);
// GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum();
// betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType());
// betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0));
// betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1));
// betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2));
// betaCalibrationSpectrumList.add(betaCalibrationD);
GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum();
betaCalibrationS.setDataType(DataTypeAbbr.SAMPLEPHD.getType());
gammaCalibrationS.setCoeff1(bgAnalyseResult.s_b_fitting_c_e.get(0));
gammaCalibrationS.setCoeff2(bgAnalyseResult.s_b_fitting_c_e.get(1));
gammaCalibrationS.setCoeff3(bgAnalyseResult.s_b_fitting_c_e.get(2));
betaCalibrationSpectrumList.add(betaCalibrationS);
GardsCalibrationSpectrum betaCalibrationG = new GardsCalibrationSpectrum();
betaCalibrationG.setDataType(DataTypeAbbr.GASBKPHD.getType());
betaCalibrationG.setCoeff1(bgAnalyseResult.g_b_fitting_c_e.get(0));
betaCalibrationG.setCoeff2(bgAnalyseResult.g_b_fitting_c_e.get(1));
betaCalibrationG.setCoeff3(bgAnalyseResult.g_b_fitting_c_e.get(2));
betaCalibrationSpectrumList.add(betaCalibrationG);
GardsCalibrationSpectrum betaCalibrationD = new GardsCalibrationSpectrum();
betaCalibrationD.setDataType(DataTypeAbbr.DETBKPHD.getType());
betaCalibrationD.setCoeff1(bgAnalyseResult.d_b_fitting_c_e.get(0));
betaCalibrationD.setCoeff2(bgAnalyseResult.d_b_fitting_c_e.get(1));
betaCalibrationD.setCoeff3(bgAnalyseResult.d_b_fitting_c_e.get(2));
betaCalibrationSpectrumList.add(betaCalibrationD);
List<GardsROIChannelsSpectrum> roiChannelsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.S_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
@ -868,15 +868,30 @@ public class PHDFileUtil {
roiChannels.setGChanStop(bgAnalyseResult.S_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.G_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.G_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.G_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.G_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.G_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
for (int i=0; i<bgAnalyseResult.D_ROI_B_Boundary_start.size(); i++) {
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
roiChannels.setRoi(i+1);
roiChannels.setBChanStart(bgAnalyseResult.D_ROI_B_Boundary_start.get(i));
roiChannels.setBChanStop(bgAnalyseResult.D_ROI_B_Boundary_stop.get(i));
roiChannels.setGChanStart(bgAnalyseResult.D_ROI_G_Boundary_start.get(i));
roiChannels.setGChanStop(bgAnalyseResult.D_ROI_G_Boundary_stop.get(i));
roiChannelsSpectrumList.add(roiChannels);
}
List<GardsROIResultsSpectrum> roiResultsSpectrumList = new LinkedList<>();
for (int i=0; i<bgAnalyseResult.s_roi_cts.size(); i++) {
GardsROIResultsSpectrum roiResults = new GardsROIResultsSpectrum();
roiResults.setRoi(i+1);
if (i==0) {
roiResults.setLc(0.0);
} else {
roiResults.setLc(bgAnalyseResult.LC.get(i-1));
}
bgAnalyseResult.LC.add(0, 0.0);
roiResults.setLc(bgAnalyseResult.LC.get(i));
roiResults.setSGross(bgAnalyseResult.s_roi_cts.get(i));
roiResults.setGGross(bgAnalyseResult.g_roi_cts.get(i));
roiResults.setBGross(bgAnalyseResult.d_roi_cts.get(i));
@ -886,12 +901,13 @@ public class PHDFileUtil {
roiResults.setNetErr(bgAnalyseResult.ROI_net_coutns_err.get(i));
roiResults.setConc(bgAnalyseResult.ROI_con_uncer.get(i));
roiResults.setConcErr(bgAnalyseResult.ROI_con_uncer_err.get(i));
// roiResults.setMdc(bgAnalyseResult.MDC.get(i));
// if(bgAnalyseResult.ROI_con_uncer.get(i)>bgAnalyseResult.MDC.get(i)) {
// roiResults.setNidFlag(1);
// } else {
// roiResults.setNidFlag(0);
// }
bgAnalyseResult.MDC.add(0, 0.0);
roiResults.setMdc(bgAnalyseResult.MDC.get(i));
if(bgAnalyseResult.ROI_con_uncer.get(i)>bgAnalyseResult.MDC.get(i)) {
roiResults.setNidFlag(1);
} else {
roiResults.setNidFlag(0);
}
roiResultsSpectrumList.add(roiResults);
}
map.put("gammaCalibrationSpectrumList", gammaCalibrationSpectrumList);

View File

@ -0,0 +1,40 @@
package org.jeecg.common.util;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Component
public class SSEUtil {
private static Map<String, SseEmitter> sseCache = new ConcurrentHashMap<>();
public SseEmitter subscribe(String id) {
// 超时时间设置为1小时
SseEmitter sseEmitter = new SseEmitter(3600_000L);
sseCache.put(id, sseEmitter);
sseEmitter.onTimeout(() -> sseCache.remove(id));
sseEmitter.onCompletion(() -> System.out.println("完成!!!"));
return sseEmitter;
}
public String push(String id, String content) throws IOException {
SseEmitter sseEmitter = sseCache.get(id);
if (sseEmitter != null) {
sseEmitter.send(content);
}
return "over";
}
public String over(String id) {
SseEmitter sseEmitter = sseCache.get(id);
if (sseEmitter != null) {
sseEmitter.complete();
sseCache.remove(id);
}
return "over";
}
}

View File

@ -1,18 +1,9 @@
package org.jeecg.modules.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.ClassUtil;
import org.jeecg.common.util.ExportUtil;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.base.enums.ExportTemplate;
import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.service.IGammaService;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,19 +11,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.jeecg.modules.base.enums.ExportTemplate.RLR_B;
import static org.jeecg.modules.base.enums.ExportTemplate.RLR_G;
@RestController
@RequestMapping("gamma")
@ -201,6 +180,11 @@ public class GammaController {
return gammaService.applyDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getCurCalName(), changeData.getSampleId(), changeData.getFileName());
}
@PostMapping("saveDataEnergy")
public void saveDataEnergy(@RequestBody ChangeData changeData, HttpServletResponse response) {
gammaService.saveDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response);
}
@GetMapping("resolutionCalibration")
@ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据")
public Result resolutionCalibration(@RequestParam Integer sampleId, String fileName, String currentText) {

View File

@ -63,6 +63,8 @@ public interface IGammaService{
Result applyDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, HttpServletResponse response);
Result resolutionCalibration(Integer sampleId, String fileName, String currentText);
Result changeDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName);

View File

@ -73,6 +73,8 @@ public class GammaServiceImpl implements IGammaService {
private SpectrumPathProperties spectrumPathProperties;
@Autowired
private FTPUtil ftpUtil;
@Autowired
private SSEUtil sseUtil;
@Value("${ZeroTime}")
private String ZeroTimeStr;
@Autowired
@ -965,7 +967,7 @@ public class GammaServiceImpl implements IGammaService {
}
// date of Zero Time
Date datetime = DateUtils.parseDate(date + StringPool.SPACE + time);
Date datetime = DateUtils.parseDate(date + StringPool.SPACE + time, "yyyy-MM-dd HH:mm:ss");
Date oriDate = DateUtils.parseDate("1970-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss");
double second = (datetime.getTime()/1000 - oriDate.getTime()/1000) - t - 8*60*60;
@ -1213,6 +1215,30 @@ public class GammaServiceImpl implements IGammaService {
return result;
}
@Override
public void saveDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, HttpServletResponse response) {
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("#g_Energy").append("\n");
for (int i=0; i<m_vCurCentroid.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurCentroid.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File("文件名"));
fos.write(strBuffer.toString().getBytes());
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
fos.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@Override
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText) {
Result result = new Result();