From 1b16ceca8f77ed37b3c119fbdc3f6c086230e331 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Wed, 13 Sep 2023 17:08:37 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9Aformat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/constant/DateConstant.java | 4 +++ .../java/org/jeecg/common/util/NumUtil.java | 21 ++++-------- .../service/impl/GammaServiceImpl.java | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java index 2c66253b..21ad4bae 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java @@ -8,6 +8,10 @@ public interface DateConstant { String DATE_TIME = "yyyy-MM-dd HH:mm:ss"; + String DATE_BIAS = "yyyy/MM/dd"; + + String DATE_BIAS_TIME = "yyyy/MM/dd HH:mm:ss"; + String TIME_START = " 00:00:00"; String TIME_END = " 23:59:59"; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java index 8ffbff22..8d6554a8 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java @@ -24,13 +24,6 @@ public class NumUtil { 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; @@ -39,13 +32,6 @@ public class NumUtil { .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; @@ -63,6 +49,13 @@ public class NumUtil { return result; } + public static Double keep(Double value, int scale){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue(); + } + public static String keepStr(Double value, int scale){ if (ObjectUtil.isNull(value)) return null; 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 613d9e3b..c2679c9c 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 @@ -39,12 +39,10 @@ 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; import java.sql.Statement; -import java.text.DecimalFormat; import java.text.ParseException; import java.time.LocalDateTime; import java.util.*; @@ -1929,7 +1927,8 @@ public class GammaServiceImpl implements IGammaService { return result; } Map map = new HashMap<>(); - Date curTime = new Date(); + String dateTime = DateUtil.format(new Date(), DateConstant.DATE_BIAS_TIME); + String date = DateUtil.format(new Date(), DateConstant.DATE_BIAS); String responsible_person = "wang shilian"; String software = "GammaAnalyser,GammaAnalyALG"; int num = phd.getVPeak().size(); @@ -1954,29 +1953,29 @@ public class GammaServiceImpl implements IGammaService { map.put("header_report_type", "FIN"); // 8: Report Type map.put("header_report_number", "1"); // 9: Report Number map.put("header_sample_category", "Category C"); // 10:Sample Category - map.put("header_transmission", curTime); // 11:Message Transmission Time + map.put("header_transmission", dateTime); // 11:Message Transmission Time // Init #Objective map.put("Obj_purpose", "The purpose of this analysis is proficiency test."); map.put("Obj_authorized", "High-resolution non-destructive gamma spectroscopy."); - map.put("Obj_instruction", "`0"); + map.put("Obj_instruction", "0"); // Init #Collection String col_start = phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time(); 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", NumUtil.keep3(phd.getCollect().getAir_volume())); + map.put("collect_airVolume", NumUtil.keep(phd.getCollect().getAir_volume(), 4)); // Init #SampleReceipt if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){ map.put("Receipt_srid", phd.getHeader().getSample_ref_id()); } map.put("Receipt_sealNum", "0"); - map.put("Receipt_sample_dateTime", curTime); + map.put("Receipt_sample_dateTime", dateTime); map.put("Receipt_package", "Parcel."); map.put("Receipt_seal", "Good."); map.put("Receipt_sample", "Good."); // Init #Test map.put("Test_type", "Analysis of a reference sample."); - map.put("Test_completion", curTime); + map.put("Test_completion", date); map.put("Test_person", responsible_person); map.put("Test_purpose", "The purpose of this analysis is proficiency test exercise."); // Init #PeaksMethod @@ -2036,20 +2035,28 @@ public class GammaServiceImpl implements IGammaService { String coverage_factor = "2.00"; String level_confidence = "95.00"; - map.put("Result_act_ref", phd.getUsedSetting().getRefTime_act()); - map.put("Result_conc_ref", phd.getUsedSetting().getRefTime_conc()); + Date refTimeAct = phd.getUsedSetting().getRefTime_act(); + Date refTimeConc = phd.getUsedSetting().getRefTime_conc(); + String timeAct = ""; + String timeConc = ""; + if (ObjectUtil.isNotNull(refTimeAct)) + timeAct = DateUtil.format(refTimeAct, DateConstant.DATE_BIAS_TIME); + if (ObjectUtil.isNotNull(refTimeConc)) + timeConc = DateUtil.format(refTimeConc, DateConstant.DATE_BIAS_TIME); + map.put("Result_act_ref", timeAct); + map.put("Result_conc_ref", timeConc); List tableResultList = new LinkedList<>(); for(Map.Entry it : phd.getMapNucActMda().entrySet()){ if(it.getValue().isBCalculateMDA()) { TableResult tableResult = new TableResult(); NuclideActMda nuc = it.getValue(); tableResult.setNuclide(it.getKey()); - tableResult.setActivity(NumUtil.keepStr(nuc.getActivity(), 6)); - String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 4) : "0"; + tableResult.setActivity(NumUtil.keep4ScienceStr(nuc.getActivity())); + String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 2) : "0"; tableResult.setActErr(act_err); tableResult.setFactor1(coverage_factor); tableResult.setConfidence1(level_confidence); - tableResult.setConc(NumUtil.keepStr(nuc.getConcentration()/1000, 5)); + tableResult.setConc(NumUtil.keep4ScienceStr(nuc.getConcentration()/1000)); tableResult.setConcErr(act_err); tableResult.setFactor2(coverage_factor); tableResult.setConfidence2(level_confidence);