From 947f3be7cc756edca18334f71671c2003eff755f Mon Sep 17 00:00:00 2001 From: nieziyan Date: Fri, 29 Dec 2023 19:33:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix=EF=BC=9AsaveQCCheck=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/service/impl/SysDatabaseServiceImpl.java | 9 +++++++-- .../org/jeecg/modules/spectrum/Sample_G_Analysis.java | 9 +++++---- .../src/main/resources/application.yml | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java index 0027344c..2cedb6b6 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java @@ -399,8 +399,13 @@ public class SysDatabaseServiceImpl extends ServiceImpl 0) { + if (!gardsNuclIdedDto.getNucl_ided_Nuclidename().isEmpty()) { String base_NuclideName = "nucl_ided_Nuclidename"; List gardsNuclIdeds = mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap); @@ -868,7 +868,7 @@ public class Sample_G_Analysis { String base_QC = String.valueOf(qcItems.size()); QcCheckDto qcCheckDto = new QcCheckDto(); BeanUtil.copyProperties(middleData,qcCheckDto); - if (qcItems.size() > 0) { + if (!qcItems.isEmpty()) { GardsQcCheck gardsQcCheck = new GardsQcCheck(); List gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap); for (GardsQcCheck qcCheck : gardsQcChecks) { @@ -1131,9 +1131,10 @@ public class Sample_G_Analysis { if (type == String.class) { tartgetField.set(tartget, value); } else if (type == Integer.class || type == int.class) { - tartgetField.set(tartget,Integer.valueOf(value)); + // 避免类似0.000的String值转Integer时NumberFormatException + tartgetField.set(tartget, Double.valueOf(value).intValue()); } else if (type == Double.class || type == double.class) { - tartgetField.set(tartget,Double.valueOf(value)); + tartgetField.set(tartget, Double.valueOf(value)); } else if (type == Boolean.class || type == boolean.class) { tartgetField.set(tartget, Boolean.valueOf(value)); } diff --git a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml index 3deaf293..c5ee5723 100644 --- a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml +++ b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml @@ -16,4 +16,5 @@ spring: import: - optional:nacos:armd.yaml - optional:nacos:armd-@profile.name@.yaml + - optional:nacos:IDC-Data.yaml - optional:nacos:armd-analysis-@profile.name@.yaml From 0b17702d4337e4055f4d320c62dd321e4139ecac Mon Sep 17 00:00:00 2001 From: nieziyan Date: Fri, 29 Dec 2023 20:02:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=EF=BC=9AsaveQCCheck=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/spectrum/Sample_G_Analysis.java | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index 7091a1e6..f4723357 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -1093,7 +1093,7 @@ public class Sample_G_Analysis { return gardsAnalyses; } - public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { + /* public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { try { List result = new ArrayList<>(); Class sourceClass = source.getClass(); @@ -1147,6 +1147,66 @@ public class Sample_G_Analysis { e.printStackTrace(); return new ArrayList<>(); } + }*/ + + public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { + try { + List result = new ArrayList<>(); + Class sourceClass = source.getClass(); + boolean isNumber = NumberUtil.isNumber(baseLine); + int total; + if (isNumber){ + total = Integer.parseInt(baseLine); + }else { + Field declaredField = sourceClass.getDeclaredField(baseLine); + declaredField.setAccessible(true); + List baseList = (List) declaredField.get(source); + if (CollUtil.isEmpty(baseList)) + return result; + total = baseList.size(); + } + Class tartgetClass = (Class) tartget.getClass(); + Field[] sourceFields = sourceClass.getDeclaredFields(); + for (int i = 0; i < total; i++) { + tartget = tartgetClass.newInstance(); + for (Field sourceField : sourceFields) { + try { + sourceField.setAccessible(true); + List sourceList = (List) sourceField.get(source); + if (CollUtil.isEmpty(sourceList)) + continue; + if (sourceList.size() <= i) + continue; + String value = sourceList.get(i); + if (StrUtil.isNotBlank(value)){ + String sourceFieldName = sourceField.getName(); + String targetFieldName = fieldMap.get(sourceFieldName); + targetFieldName = StrUtil.isBlank(targetFieldName) ? sourceFieldName : targetFieldName; + Field tartgetField = tartgetClass.getDeclaredField(targetFieldName); + tartgetField.setAccessible(true); + Class type = tartgetField.getType(); + if (type == String.class) { + tartgetField.set(tartget, value); + } else if (type == Integer.class || type == int.class) { + // 避免类似0.000的String值转Integer时NumberFormatException + tartgetField.set(tartget, Double.valueOf(value).intValue()); + } else if (type == Double.class || type == double.class) { + tartgetField.set(tartget, Double.valueOf(value)); + } else if (type == Boolean.class || type == boolean.class) { + tartgetField.set(tartget, Boolean.valueOf(value)); + } + } + }catch (Exception e){ + log.error("Sample_G_Analysis.mapFields()值映射异常: {}", e.getMessage()); + } + } + result.add(tartget); + } + return result; + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } } private void setPHDFile(PHDFile phdFile, EnergySpectrumStruct spectrumStruct) {