From 46f3299f078aa3c5447a9a0265716de26716b812 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Mon, 11 Sep 2023 19:20:09 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9ARLR=20Export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/util/ClassUtil.java | 18 +++++ .../org/jeecg/common/util/ExportUtil.java | 25 +++--- .../modules/base/enums/ExportTemplate.java | 3 +- .../main/resources/excelTemplate/Gamma.RLR | 76 ++++++++++++++++++ .../main/resources/excelTemplate/RLR-B.xls | Bin 0 -> 34816 bytes .../modules/controller/GammaController.java | 62 +++----------- .../SpectrumAnalysesController.java | 6 ++ .../jeecg/modules/service/IGammaService.java | 3 +- .../service/ISpectrumAnalysisService.java | 2 + .../service/impl/GammaServiceImpl.java | 70 +++++++++++++++- .../impl/SpectrumAnalysisServiceImpl.java | 15 +++- 11 files changed, 210 insertions(+), 70 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/resources/excelTemplate/Gamma.RLR create mode 100644 jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java index a5569856..eb650c0e 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ClassUtil.java @@ -2,7 +2,12 @@ package org.jeecg.common.util; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import org.jeecgframework.poi.excel.entity.TemplateExportParams; +import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; @@ -47,4 +52,17 @@ public class ClassUtil { } return objsStr; } + + public static String classPath(String path){ + try { + String pathPrefix = "classpath:"; + ResourceLoader loader = new DefaultResourceLoader(); + String templatePath = pathPrefix + path; + Resource resource = loader.getResource(templatePath); + return resource.getFile().getAbsolutePath(); + } catch (IOException e) { + e.printStackTrace(); + return ""; + } + } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java index d901e1b1..c8e72adb 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ExportUtil.java @@ -14,6 +14,7 @@ import org.springframework.core.io.ResourceLoader; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; +import java.io.PrintWriter; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -47,6 +48,13 @@ public class ExportUtil { response.setHeader("Content-disposition", "attachment;filename=" + name); return response.getOutputStream(); } + public static PrintWriter streamWriter(HttpServletResponse response, String fileName) throws IOException { + response.setCharacterEncoding(UTF_8); + response.setContentType("application/octet-stream"); + String name = URLEncoder.encode(fileName, UTF_8); + response.setHeader("Content-disposition", "attachment;filename=" + name); + return response.getWriter(); + } public static void exportXls(HttpServletResponse response, Class target, List data, String fileName){ @@ -77,18 +85,11 @@ public class ExportUtil { exportXls(response, target, data, "file.xls"); } - public static TemplateExportParams excelTemplate(String name){ - try { - String pathPrefix = "classpath:excelTemplate/"; - ResourceLoader loader = new DefaultResourceLoader(); - String templatePath = pathPrefix + name; - Resource resource = loader.getResource(templatePath); - String path = resource.getFile().getAbsolutePath(); - return new TemplateExportParams(path); - } catch (IOException e) { - e.printStackTrace(); - return null; - } + public static TemplateExportParams excelTemplate(String template){ + String pathPrefix = "excelTemplate/"; + String path = pathPrefix + template; + String templatePath = ClassUtil.classPath(path); + return new TemplateExportParams(templatePath); } public static void exportXls(HttpServletResponse response, String template, diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java index 1a2375ea..23b2e163 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/enums/ExportTemplate.java @@ -12,7 +12,8 @@ public enum ExportTemplate { SampleInfo_G("SampleInformation-G.xls"), RadionuclideActivity_G("RadionuclideActivity-G.xls"), SampleInfo_B("SampleInformation-B.xls"), - QcResult_B("QcResult-B.xls"); + QcResult_B("QcResult-B.xls"), + RLR_B("RLR-B.xls"),RLR_G("Gamma.RLR"); ExportTemplate(String name) { this.name = name; diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/Gamma.RLR b/jeecg-boot-base-core/src/main/resources/excelTemplate/Gamma.RLR new file mode 100644 index 00000000..c6c127bf --- /dev/null +++ b/jeecg-boot-base-core/src/main/resources/excelTemplate/Gamma.RLR @@ -0,0 +1,76 @@ +BEGIN IMS2.0 +MSG_TYPE DATA +MSG_ID ${header_msg_id} ${header_station_code} +DATA_TYPE MINIRLR +#Header +${header_priority_level} +${header_station_code} ${header_srid} +${header_lab_code} ${header_lab_detector} +${header_report_type} ${header_report_number} +${header_sample_category} +${header_transmission} +#Objective +~AnalysisPurpose +${Obj_purpose} +~TestsAuthorized +${Obj_authorized} +~SpecialInstructions +${Obj_instruction} +#Collection +${collect_start} ${collect_stop} ${collect_airVolume} +#SampleReceipt +${Receipt_srid} +${Receipt_sealNum} +${Receipt_sample_dateTime} +~PackageCondition +${Receipt_package} +~SealCondition +${Receipt_seal} +~SampleCondition +${Receipt_sample} +#Test +${Test_type} +${Test_completion} +${Test_person} +${Test_purpose} +#PeaksMethod +${PeakMethod_software} +${PeakMethod_location} +#PeakFit +${peakFit} +#g_AnalysisMethods +${AnalyMethod_software} +~NuclidesMethod +${AnalyMethod_nuclide} +~BaselineMethod +${AnalyMethod_baseline} +~LCMethod +${AnalyMethod_lc} +~CalibrationMethod +${AnalyMethod_calib} +#PeakAssociation +${Association} +#References +~SAMPLEPHD +${Reference_samplePHD} +~CALIBPHD +${Reference_CalibPHD} +~PhysicalConstants +${Reference_physical} +#Results +${Result_act_ref} ${Result_conc_ref} +${Result} +#NuclideRatios +#g_CoincidenceCorrection +#MDA +#Conclusions +${conclusion_person} +~IDCSummary +${Conclusion_IDC} +~Labsummary +${Conclusion_Lab} +~ResultComparison +${Conclusion_Res} +#Comment +${Comment} +STOP \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls new file mode 100644 index 0000000000000000000000000000000000000000..747c0bbc44cef78501829982997d4da29e107329 GIT binary patch literal 34816 zcmeHw349b)@_$bfasYt@!W9H2AwYnTgm9lZhHxc7AOXa11ri7v2og?(C35I0$RREQ zBBF>O3JBhE9|{Pr93r5rg2*Kb=;{KB=J)-+H*b2Tr)LQ4{(qnU{&qWgeN@-0s#mY7 z-qqc6_><7nFKh}wqZzi2ny>apNs#961h?RvNo*mS))6PX{-dO%L;^Jpr~lpljWqB( zWKBlp`6Brtl|f>i2OtF^1tFD1Du+}aDHy2&Qbi<~fEJ2W38^wt7*Z9asz}w4sw34v z3P-AmbPrN3q}oVzkgP}%NRdc&k)n|5A=O7}fE10?5UCMTW26|QCP=YJaY*qLOJegX1`D z3N%vsttu==3FCuo)yvEL{#wu*fR z5s5Udct-@=4G@hcnPwf!0+f>qWm zk=nVENHpRxNOjRLx6>qKAR25PTHCJ$Iv3T=(6eF7d0MVE$V0|f=#kWL&ln3{p18?- zwf&Oe6tz8P_0Cxl8HHX*f@T?_S?vNg!kJz&!rN)CcU{YFh7k$vM2cK8Z<08#?bjdO zo`#Z{CpLt8V!(TzNKZi(we?&MSzI$&U72~tlZ+F!M3ZujL^rOfS-Fhl+)HPM;f+-s ze58tI8Hi4$b1gMQEe%A+(iJ`s+OF-_29_Cao<+A2Pnp}nI%^s;E1}J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P5dAosbZZE_jIZW=yP@wKd~rr zNtHe)uShk?aYd@h_A8dvhCZK^6;Es7o=&xyplWmAl4>W%6{)5=u1K}B{fauXp(T@4 zG4~6X@>GIP82f|lQI*Azr@$xH-gA;YB(;})DPD~g?~U=@FR*8;U!zBo8$BIt2OJo=pxM(;Di=yOIGJr>t_P%FJQ0x z;ovCSy#nSs%QCrE2YOZnJ7Cb?NJbI`(Um<5+P zl0^0JLEtMx8aF6$)THr zLpL`L#HQ`rw87ZRD@G5F@hDSw(;V~+8=iEMIWYb1lq1bF2mK~p8*0yi)eEN_>83g8 zRW{7gOCCL3a`bS^!8)eTnd^g|mx9GPSuedn%N0-79(^$t>jDxh!vhw*vj^t9C01`> z@%@P&4vLZ%{WTTq1`?}}39aqWJUy6_V4e<^kcm?Dgw{iF=IfxR?3A9Jisdk=k1XWr zg@q8(uY_37oO+q0<ss zKLA~DcK&?Pu(P4}1-m41Gc*J zH(zu%XuQ5KLN3Snz*z1T#{mdzydD`?4GAdr4b#W`DFk1H$g&Fdf9J?rLft?g-hcm_ zzn5JeIKfC2ka!(}V<=K3q{?;}RrTNP-$w&nu(kMW6_@!O4?q>7bERp&Rh;MZ(l_h2 z_vSB3!$5YH@Xr7KQ81-}VmpllIaXYdM}`);x!zZJj{Bz-zB;OW@>ZtNnXJnQ?6UngW>yGQ?sJOqn?3g$EtLjr}C4x&+(6s zFORJmvgjF_@McbY7 z{}-`!kokA!Pn)J6&~{lR(MZ^e=_|C&)<_{pNl3IQXPf7JZtA!M=cL1pbV!d~Q*6b# z*fD=j(qkl7kx86S;x)Do4!Mz lines = FileUtil.readUtf8Lines(template); - // 正则表达式,匹配${}中的内容 - String regex = "\\$\\{([^}]+)}"; - List newLines = new ArrayList<>(); - List list = ListUtil.toList("peakFit","Association","Result"); - for (String line : lines) { - if (StrUtil.isBlank(line)) continue; - List fieldNames = ReUtil.findAllGroup1(regex, line); - if (CollUtil.isEmpty(fieldNames)){ - newLines.add(line); - continue; - } - Map fieldValue = ClassUtil.fieldValue(gammaRLR, fieldNames); - for (Map.Entry entry : fieldValue.entrySet()) { - String fieldName = entry.getKey(); - Object value = entry.getValue(); - if (list.contains(fieldName)){ - List lineList = new ArrayList<>(); - switch (fieldName){ - case "peakFit": - lineList = ClassUtil.objsStr((List)value); - break; - case "Association": - lineList = ClassUtil.objsStr((List)value); - break; - case "Result": - lineList = ClassUtil.objsStr((List)value); - break; - default: - break; - } - newLines.addAll(lineList); - }else { - String search = "${" + fieldName + "}"; - String newLine = StrUtil.replace(line, search, value.toString()); - newLines.add(newLine); - } - } - } - - String output = "C:\\Users\\a\\Desktop\\"; + public void exportRLR(@RequestBody GammaRLR gammaRLR, HttpServletResponse response) { + gammaService.exportRLR(gammaRLR, response); } @GetMapping("viewAutomaticAnalysisLog") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java index ed097a43..dfe1e77d 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/SpectrumAnalysesController.java @@ -128,6 +128,12 @@ public class SpectrumAnalysesController { return spectrumAnalysisService.viewRLR(sampleId); } + @GetMapping("exportRLR") + @ApiOperation(value = "导出RLR数据", notes = "导出RLR数据") + public void exportRLR(Integer sampleId, HttpServletResponse response) { + spectrumAnalysisService.exportRLR(sampleId, response); + } + @GetMapping("viewGammaDetectorCalibration") @ApiOperation(value = "查询GammaDetectorCalibration数据", notes = "查询GammaDetectorCalibration数据") public Result viewGammaDetectorCalibration(Integer sampleId) { 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 58544e57..0dc4930e 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 @@ -1,6 +1,7 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.entity.vo.*; import javax.servlet.http.HttpServletRequest; @@ -107,7 +108,7 @@ public interface IGammaService{ Result viewRLR(Integer sampleId, String fileName); - void exportRLR(Integer sampleId, String fileName, HttpServletResponse response); + void exportRLR(GammaRLR gammaRLR, HttpServletResponse response); void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java index e13a01a3..e2c56c37 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISpectrumAnalysisService.java @@ -45,6 +45,8 @@ public interface ISpectrumAnalysisService { Result viewRLR(Integer sampleId); + void exportRLR(Integer sampleId, HttpServletResponse response); + Result viewGammaDetectorCalibration(Integer sampleId); Result viewBetaDetectorCalibration(Integer sampleId); 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 89c6b0fa..c751402c 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 @@ -1,10 +1,13 @@ package org.jeecg.modules.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ReUtil; +import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; @@ -19,6 +22,7 @@ import org.jeecg.common.constant.DateConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.util.*; +import org.jeecg.modules.base.bizVo.GammaRLR; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.enums.ExportTemplate; import org.jeecg.modules.base.enums.RoleType; @@ -48,6 +52,7 @@ import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; +import static org.jeecg.modules.base.enums.ExportTemplate.RLR_G; import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_G; @Service(value = "gammaService") @@ -2046,12 +2051,69 @@ public class GammaServiceImpl implements IGammaService { result.setResult(map); return result; } - @Override - public void exportRLR(Integer sampleId, String fileName, HttpServletResponse response) { - + public void exportRLR(GammaRLR gammaRLR, HttpServletResponse response) { + String pathPrefix = "excelTemplate/"; + String path = pathPrefix + RLR_G.getName(); + String template = ClassUtil.classPath(path); + List lines = FileUtil.readUtf8Lines(template); + // 正则表达式,匹配${}中的内容 + String regex = "\\$\\{([^}]+)}"; + List newLines = new ArrayList<>(); + List list = ListUtil.toList("peakFit","Association","Result"); + List skip = ListUtil.toList("${peakFit}","${Association}","${Result}"); + for (String line : lines) { + if (StrUtil.isBlank(line)) continue; + List fieldNames = ReUtil.findAllGroup1(regex, line); + if (CollUtil.isEmpty(fieldNames)){ + newLines.add(line); + continue; + } + Map fieldValue = ClassUtil.fieldValue(gammaRLR, fieldNames); + String newLine = line; + for (Map.Entry entry : fieldValue.entrySet()) { + String fieldName = entry.getKey(); + Object value = entry.getValue(); + if (list.contains(fieldName)){ + List lineList = new ArrayList<>(); + switch (fieldName){ + case "peakFit": + lineList = ClassUtil.objsStr((List)value); + break; + case "Association": + lineList = ClassUtil.objsStr((List)value); + break; + case "Result": + lineList = ClassUtil.objsStr((List)value); + break; + default: + break; + } + newLines.addAll(lineList); + }else { + String search = "${" + fieldName + "}"; + String replacement = StrUtil.toString(value); + replacement = StrUtil.isBlank(replacement) ? "null" : replacement; + newLine = StrUtil.replace(newLine, search, replacement); + } + } + if (!CollUtil.contains(skip, newLine)) + newLines.add(newLine); + } + PrintWriter writer = null; + try { + String export = "Gamma.RLR"; + writer = ExportUtil.streamWriter(response, export); + for (String newLine : newLines) { + writer.println(newLine); + } + } catch (IOException e) { + e.printStackTrace(); + }finally { + if (ObjectUtil.isNotNull(writer)) + writer.close(); + } } - @Override public void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) { if (Objects.isNull(sampleId)){ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index 9b474f44..d335357c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -45,8 +45,7 @@ import java.util.*; import java.util.regex.Pattern; import java.util.stream.Collectors; -import static org.jeecg.modules.base.enums.ExportTemplate.QcResult_B; -import static org.jeecg.modules.base.enums.ExportTemplate.SampleInfo_B; +import static org.jeecg.modules.base.enums.ExportTemplate.*; @Service("spectrumAnalysisService") @DS("ora") @@ -1455,6 +1454,18 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { return result; } + @Override + public void exportRLR(Integer sampleId, HttpServletResponse response) { + Result result = viewRLR(sampleId); + RlrDataValues rlrDataValues = (RlrDataValues)result.getResult(); + Map dataMap = BeanUtil.beanToMap(rlrDataValues); + // 将Null值替换为"",避免空指针异常(或者在模板中进行判断) + dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); + String export = "RLR-Beta.xls"; + String template = RLR_B.getName(); + ExportUtil.exportXls(response, template, dataMap,export); + } + @Override public Result viewGammaDetectorCalibration(Integer sampleId) { Result result = new Result();