diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java index 0343ce2c..6202b7ad 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java @@ -29,11 +29,31 @@ public class NumberFormatUtil { if (number.indexOf("e")>0) { String calNumber = number.substring(0, number.indexOf("e")); String numberCal = numberCal(calNumber); - value = numberCal + number.substring(number.indexOf("e")); + String eValue = number.substring(number.indexOf("e")+1); + if (Double.valueOf(eValue) > 0) { + if (Double.valueOf(eValue) > 10) { + eValue = "e+"+ number.substring(number.indexOf("e")+1); + } else { + eValue = "e+0"+ number.substring(number.indexOf("e")+1); + } + } else { + eValue = number.substring(number.indexOf("e")); + } + value = numberCal + eValue.replace("E", "e"); } else if (number.indexOf("E")>0) { String calNumber = number.substring(0, number.indexOf("E")); String numberCal = numberCal(calNumber); - value = numberCal + number.substring(number.indexOf("E")); + String eValue = number.substring(number.indexOf("E")+1); + if (Double.valueOf(eValue) > 0) { + if (Double.valueOf(eValue) > 10) { + eValue = "e+"+ number.substring(number.indexOf("E")+1); + } else { + eValue = "e+0"+ number.substring(number.indexOf("E")+1); + } + } else { + eValue = number.substring(number.indexOf("E")); + } + value = numberCal + eValue.replace("E", "e"); } return value; } diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 0c9eb2f1..4ad7b331 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -634,11 +634,11 @@ public class GammaFileUtil extends AbstractLogOrReport { return 0.0; } //获取采集开始时间 - Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()); //获取采样结束时间 - Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time()); //获取能谱获取时间 - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()); //计算采样时间 double Ts = ((collectStop.getTime() - collectStart.getTime())/1000); //计算衰变时间 @@ -3740,21 +3740,9 @@ public class GammaFileUtil extends AbstractLogOrReport { String str_mda = (nuc.getMda() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getMda()))); tableNuclideActivity.setMda(str_mda); - if (Objects.nonNull(nuc.getConcentration())) { - if (Double.isFinite(nuc.getConcentration())) { - DecimalFormat decimalFormat = new DecimalFormat("0.###E0"); - nuc.setConcentration(Double.valueOf(decimalFormat.format(nuc.getConcentration()))); - } - } - String str_con = (Objects.nonNull(nuc.getConcentration())?(Double.isFinite(nuc.getConcentration())? nuc.getConcentration() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration())) : "inf"):"null"); + String str_con = (Objects.nonNull(nuc.getConcentration())?(Double.isFinite(nuc.getConcentration())? (nuc.getConcentration() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getConcentration()))) : (Double.isInfinite(nuc.getConcentration())? "inf": "nan")):"null"); tableNuclideActivity.setConc(str_con); - if (Objects.nonNull(nuc.getMdc())) { - if (Double.isFinite(nuc.getMdc())) { - DecimalFormat decimalFormat = new DecimalFormat("0.###E0"); - nuc.setMdc(Double.valueOf(decimalFormat.format(nuc.getMdc()))); - } - } - String str_mdc = (Objects.nonNull(nuc.getMdc())?(Double.isFinite(nuc.getMdc())?nuc.getMdc() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc())) : "inf"):"null"); + String str_mdc = (Objects.nonNull(nuc.getMdc())?(Double.isFinite(nuc.getMdc())? (nuc.getMdc() <= 0 ? "null" : NumberFormatUtil.numberFormat(String.valueOf(nuc.getMdc()))) : (Double.isInfinite(nuc.getMdc())? "inf" : "nan")):"null"); tableNuclideActivity.setMdc(str_mdc); nuclideActivityList.add(tableNuclideActivity); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index 0a776fbd..9b1aa0f4 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -538,16 +538,16 @@ public class GammaController { gammaService.saveToPHD(fileName, request, response); } - @GetMapping("peakComparison") - @ApiOperation(value = "Peak Information页面查看Comparison数据", notes = "Peak Information页面查看Comparison数据") - public Result peakComparison(String fileName, HttpServletRequest request) { - return gammaService.peakComparison(fileName, request); - } - - @GetMapping("nuclComparison") - @ApiOperation(value = "Radionuclide Activity页面查看Comparison数据", notes = "Radionuclide Activity页面查看Comparison数据") - public Result nuclComparison(String fileName, HttpServletRequest request) { - return gammaService.nuclComparison(fileName, request); - } +// @GetMapping("peakComparison") +// @ApiOperation(value = "Peak Information页面查看Comparison数据", notes = "Peak Information页面查看Comparison数据") +// public Result peakComparison(String fileName, HttpServletRequest request) { +// return gammaService.peakComparison(fileName, request); +// } +// +// @GetMapping("nuclComparison") +// @ApiOperation(value = "Radionuclide Activity页面查看Comparison数据", notes = "Radionuclide Activity页面查看Comparison数据") +// public Result nuclComparison(String fileName, HttpServletRequest request) { +// return gammaService.nuclComparison(fileName, request); +// } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index 7edf6462..3b221a5a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -203,8 +203,8 @@ public interface IGammaService{ void readMDCParameter(); - Result peakComparison(String fileName, HttpServletRequest request); - - Result nuclComparison(String fileName, HttpServletRequest request); +// Result peakComparison(String fileName, HttpServletRequest request); +// +// Result nuclComparison(String fileName, HttpServletRequest request); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 7c995165..78c1d69f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -149,8 +149,8 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi private RedisStreamUtil redisStreamUtil; @Autowired private ISysDictSpectrumService sysDictService; - @Autowired - private IDataService dataService; +// @Autowired +// private IDataService dataService; @Override public Result initValue(Integer sampleId, String dbName, String analyst, String samfileName, HttpServletRequest request) { @@ -748,7 +748,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi if (CollectionUtils.isNotEmpty(nuclLinesIdeds)) { for (GardsNuclLinesIdedSpectrum nuclLinesIdedSpectrum : nuclLinesIdeds) { String str_key = nuclLinesIdedSpectrum.getNuclideName(); - phd.getMapNucActMda().put(str_key, new NuclideActMda()); + if (Objects.isNull(phd.getMapNucActMda().get(str_key))) { + phd.getMapNucActMda().put(str_key, new NuclideActMda()); + } if (Objects.nonNull(phd.getMapNucActMda().get(str_key))) { phd.getMapNucActMda().get(str_key).setActivity(Double.valueOf(nuclLinesIdedSpectrum.getActivity())); phd.getMapNucActMda().get(str_key).setAct_err(nuclLinesIdedSpectrum.getUncActivity()); @@ -5887,128 +5889,128 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi } } - @Override - public Result peakComparison(String fileName, HttpServletRequest request) { - Result result = new Result(); - Connection conn = null; - List peakInfoList = new LinkedList<>(); - //获取用户名 - String userName = JwtUtil.getUserNameByToken(request); - //读取缓存内容 - Cache phdCache = localCache.getPHDCache(); - PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName); - if (Objects.isNull(phd)) { - result.error500("Please select the parse file first!"); - return result; - } - Map idcStationMap = (Map) redisUtil.get("idcStationMap"); - try { - String collectStart = ""; - if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { - collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)); - } else { - collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); - } - //获取采集开始时间 - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); - //计算得到采集结束时间对应的毫秒数 - long stopTime = (long) (acqStart.getTime() + (phd.getAcq().getAcquisition_real_time() * 1000)); - //根据毫秒数得到采集结束时间 - Date acquisitionStopDate = new Date(stopTime); - //格式化得到采集结束时间的字符串 - String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); - //从缓存的idc台站信息中获取当前台站对应的台站id - Integer stationId = null; - if (CollectionUtils.isNotEmpty(idcStationMap)) { - stationId = idcStationMap.get(phd.getHeader().getSite_code()); - } - //连接本地同步的idc数据库 - conn = dataService.connectInland(); - //连接对象为空 则连接idc国际库 - if (Objects.isNull(conn)) { - conn = dataService.connectOverSea(); - } - //判断是否连接成功 - if (Objects.nonNull(conn)) { - //查询获取Peaks表的对比数据内容 - peakInfoList = dataService.viewPeaks(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); - } - result.setSuccess(true); - result.setResult(peakInfoList); - } catch (ParseException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(conn)) { - conn.close(); - } - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - return result; - } - - @Override - public Result nuclComparison(String fileName, HttpServletRequest request) { - Result result = new Result(); - Connection conn = null; - List nuclideActivityList = new LinkedList<>(); - //获取用户名 - String userName = JwtUtil.getUserNameByToken(request); - //读取缓存内容 - Cache phdCache = localCache.getPHDCache(); - PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName); - if (Objects.isNull(phd)) { - result.error500("Please select the parse file first!"); - return result; - } - Map idcStationMap = (Map) redisUtil.get("idcStationMap"); - try { - String collectStart = ""; - if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { - collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)); - } else { - collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); - } - //获取采集开始时间 - Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); - //计算得到采集结束时间对应的毫秒数 - long stopTime = (long) (acqStart.getTime() + (phd.getAcq().getAcquisition_real_time() * 1000)); - //根据毫秒数得到采集结束时间 - Date acquisitionStopDate = new Date(stopTime); - //格式化得到采集结束时间的字符串 - String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); - //从缓存的idc台站信息中获取当前台站对应的台站id - Integer stationId = null; - if (CollectionUtils.isNotEmpty(idcStationMap)) { - stationId = idcStationMap.get(phd.getHeader().getSite_code()); - } - //连接本地同步的idc数据库 - conn = dataService.connectInland(); - //连接对象为空 则连接idc国际库 - if (Objects.isNull(conn)) { - conn = dataService.connectOverSea(); - } - //判断是否连接成功 - if (Objects.nonNull(conn)) { - //查询获取Peaks表的对比数据内容 - nuclideActivityList = dataService.viewNucl(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); - } - result.setSuccess(true); - result.setResult(nuclideActivityList); - } catch (ParseException e) { - throw new RuntimeException(e); - } finally { - try { - if (Objects.nonNull(conn)) { - conn.close(); - } - } catch (SQLException e) { - throw new RuntimeException(e); - } - } - return result; - } +// @Override +// public Result peakComparison(String fileName, HttpServletRequest request) { +// Result result = new Result(); +// Connection conn = null; +// List peakInfoList = new LinkedList<>(); +// //获取用户名 +// String userName = JwtUtil.getUserNameByToken(request); +// //读取缓存内容 +// Cache phdCache = localCache.getPHDCache(); +// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName); +// if (Objects.isNull(phd)) { +// result.error500("Please select the parse file first!"); +// return result; +// } +// Map idcStationMap = (Map) redisUtil.get("idcStationMap"); +// try { +// String collectStart = ""; +// if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { +// collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)); +// } else { +// collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); +// } +// //获取采集开始时间 +// Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); +// //计算得到采集结束时间对应的毫秒数 +// long stopTime = (long) (acqStart.getTime() + (phd.getAcq().getAcquisition_real_time() * 1000)); +// //根据毫秒数得到采集结束时间 +// Date acquisitionStopDate = new Date(stopTime); +// //格式化得到采集结束时间的字符串 +// String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); +// //从缓存的idc台站信息中获取当前台站对应的台站id +// Integer stationId = null; +// if (CollectionUtils.isNotEmpty(idcStationMap)) { +// stationId = idcStationMap.get(phd.getHeader().getSite_code()); +// } +// //连接本地同步的idc数据库 +// conn = dataService.connectInland(); +// //连接对象为空 则连接idc国际库 +// if (Objects.isNull(conn)) { +// conn = dataService.connectOverSea(); +// } +// //判断是否连接成功 +// if (Objects.nonNull(conn)) { +// //查询获取Peaks表的对比数据内容 +// peakInfoList = dataService.viewPeaks(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); +// } +// result.setSuccess(true); +// result.setResult(peakInfoList); +// } catch (ParseException e) { +// throw new RuntimeException(e); +// } finally { +// try { +// if (Objects.nonNull(conn)) { +// conn.close(); +// } +// } catch (SQLException e) { +// throw new RuntimeException(e); +// } +// } +// return result; +// } +// +// @Override +// public Result nuclComparison(String fileName, HttpServletRequest request) { +// Result result = new Result(); +// Connection conn = null; +// List nuclideActivityList = new LinkedList<>(); +// //获取用户名 +// String userName = JwtUtil.getUserNameByToken(request); +// //读取缓存内容 +// Cache phdCache = localCache.getPHDCache(); +// PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName); +// if (Objects.isNull(phd)) { +// result.error500("Please select the parse file first!"); +// return result; +// } +// Map idcStationMap = (Map) redisUtil.get("idcStationMap"); +// try { +// String collectStart = ""; +// if (phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT) > 0) { +// collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)); +// } else { +// collectStart = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); +// } +// //获取采集开始时间 +// Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time()); +// //计算得到采集结束时间对应的毫秒数 +// long stopTime = (long) (acqStart.getTime() + (phd.getAcq().getAcquisition_real_time() * 1000)); +// //根据毫秒数得到采集结束时间 +// Date acquisitionStopDate = new Date(stopTime); +// //格式化得到采集结束时间的字符串 +// String acquisitionStop = DateUtils.formatDate(acquisitionStopDate, "yyyy-MM-dd HH:mm:ss"); +// //从缓存的idc台站信息中获取当前台站对应的台站id +// Integer stationId = null; +// if (CollectionUtils.isNotEmpty(idcStationMap)) { +// stationId = idcStationMap.get(phd.getHeader().getSite_code()); +// } +// //连接本地同步的idc数据库 +// conn = dataService.connectInland(); +// //连接对象为空 则连接idc国际库 +// if (Objects.isNull(conn)) { +// conn = dataService.connectOverSea(); +// } +// //判断是否连接成功 +// if (Objects.nonNull(conn)) { +// //查询获取Peaks表的对比数据内容 +// nuclideActivityList = dataService.viewNucl(phd.getHeader().getDetector_code(), phd.getHeader().getSpectrum_quantity(), stationId, collectStart, acquisitionStop, conn); +// } +// result.setSuccess(true); +// result.setResult(nuclideActivityList); +// } catch (ParseException e) { +// throw new RuntimeException(e); +// } finally { +// try { +// if (Objects.nonNull(conn)) { +// conn.close(); +// } +// } catch (SQLException e) { +// throw new RuntimeException(e); +// } +// } +// return result; +// } } diff --git a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/java/org/jeecg/JeecgSpectrumAnalysisApplication.java b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/java/org/jeecg/JeecgSpectrumAnalysisApplication.java index b4add0cf..94c93315 100644 --- a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/java/org/jeecg/JeecgSpectrumAnalysisApplication.java +++ b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/java/org/jeecg/JeecgSpectrumAnalysisApplication.java @@ -33,6 +33,8 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ private IGammaService gammaService; @Autowired private IGardsNuclCoincidenceSumSpectrumService nuclCoincidenceSumSpectrumService; +// @Autowired +// private IDataService dataService; @Override @@ -64,5 +66,6 @@ public class JeecgSpectrumAnalysisApplication extends SpringBootServletInitializ localCache.initCache(); gammaService.readMDCParameter(); nuclCoincidenceSumSpectrumService.getNuclCoincidenceMap(); + //dataService.viewStations(); } } \ No newline at end of file