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

This commit is contained in:
qiaoqinzheng 2023-12-29 20:05:16 +08:00
commit a8215234e3
3 changed files with 74 additions and 7 deletions

View File

@ -399,8 +399,13 @@ public class SysDatabaseServiceImpl extends ServiceImpl<SysDatabaseMapper, SysDa
private String bias(String url){ private String bias(String url){
if (StrUtil.isBlank(url)) if (StrUtil.isBlank(url))
return null; return null;
String regex = "/([^/?]+)\\?"; String regex1 = "/([^/?]+)\\?";
return ReUtil.getGroup1(regex, url); String regex2 = ".*/(.*)";
String dbName = ReUtil.getGroup1(regex1, url);
if (StrUtil.isNotBlank(dbName))
return dbName;
dbName = ReUtil.getGroup1(regex2, url);
return dbName;
} }
/* /*

View File

@ -848,7 +848,7 @@ public class Sample_G_Analysis {
GardsNuclIdedDto gardsNuclIdedDto = new GardsNuclIdedDto(); GardsNuclIdedDto gardsNuclIdedDto = new GardsNuclIdedDto();
GardsNuclIded gardsNuclIded = new GardsNuclIded(); GardsNuclIded gardsNuclIded = new GardsNuclIded();
BeanUtil.copyProperties(middleData,gardsNuclIdedDto); BeanUtil.copyProperties(middleData,gardsNuclIdedDto);
if (gardsNuclIdedDto.getNucl_ided_Nuclidename().size() > 0) { if (!gardsNuclIdedDto.getNucl_ided_Nuclidename().isEmpty()) {
String base_NuclideName = "nucl_ided_Nuclidename"; String base_NuclideName = "nucl_ided_Nuclidename";
List<GardsNuclIded> gardsNuclIdeds = List<GardsNuclIded> gardsNuclIdeds =
mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap); mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap);
@ -868,7 +868,7 @@ public class Sample_G_Analysis {
String base_QC = String.valueOf(qcItems.size()); String base_QC = String.valueOf(qcItems.size());
QcCheckDto qcCheckDto = new QcCheckDto(); QcCheckDto qcCheckDto = new QcCheckDto();
BeanUtil.copyProperties(middleData,qcCheckDto); BeanUtil.copyProperties(middleData,qcCheckDto);
if (qcItems.size() > 0) { if (!qcItems.isEmpty()) {
GardsQcCheck gardsQcCheck = new GardsQcCheck(); GardsQcCheck gardsQcCheck = new GardsQcCheck();
List<GardsQcCheck> gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap); List<GardsQcCheck> gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap);
for (GardsQcCheck qcCheck : gardsQcChecks) { for (GardsQcCheck qcCheck : gardsQcChecks) {
@ -1093,7 +1093,7 @@ public class Sample_G_Analysis {
return gardsAnalyses; return gardsAnalyses;
} }
public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) { /* public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) {
try { try {
List<T2> result = new ArrayList<>(); List<T2> result = new ArrayList<>();
Class<?> sourceClass = source.getClass(); Class<?> sourceClass = source.getClass();
@ -1131,9 +1131,10 @@ public class Sample_G_Analysis {
if (type == String.class) { if (type == String.class) {
tartgetField.set(tartget, value); tartgetField.set(tartget, value);
} else if (type == Integer.class || type == int.class) { } 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) { } 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) { } else if (type == Boolean.class || type == boolean.class) {
tartgetField.set(tartget, Boolean.valueOf(value)); tartgetField.set(tartget, Boolean.valueOf(value));
} }
@ -1146,6 +1147,66 @@ public class Sample_G_Analysis {
e.printStackTrace(); e.printStackTrace();
return new ArrayList<>(); return new ArrayList<>();
} }
}*/
public <T1,T2> List<T2> mapFields(T1 source, T2 tartget, String baseLine, Map<String,String> fieldMap) {
try {
List<T2> 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<String> baseList = (List<String>) declaredField.get(source);
if (CollUtil.isEmpty(baseList))
return result;
total = baseList.size();
}
Class<T2> tartgetClass = (Class<T2>) 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<String> sourceList = (List<String>) 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) { private void setPHDFile(PHDFile phdFile, EnergySpectrumStruct spectrumStruct) {

View File

@ -16,4 +16,5 @@ spring:
import: import:
- optional:nacos:armd.yaml - optional:nacos:armd.yaml
- optional:nacos:armd-@profile.name@.yaml - optional:nacos:armd-@profile.name@.yaml
- optional:nacos:IDC-Data.yaml
- optional:nacos:armd-analysis-@profile.name@.yaml - optional:nacos:armd-analysis-@profile.name@.yaml