Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
eae304a2f7
|
@ -64,6 +64,11 @@ public class SpectrumPathProperties implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String filesourcePath;
|
private String filesourcePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误文件存储路径
|
||||||
|
*/
|
||||||
|
private String errorFilePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value
|
* 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.jeecg.modules.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断日期是否是正确格式
|
||||||
|
*/
|
||||||
|
public class DateFormatErrorException extends RuntimeException {
|
||||||
|
|
||||||
|
public DateFormatErrorException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,21 +1,20 @@
|
||||||
package org.jeecg.modules.spectrum;
|
package org.jeecg.modules.spectrum;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.jeecg.common.constant.StringConstant;
|
import org.jeecg.common.constant.StringConstant;
|
||||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||||
|
import org.jeecg.common.util.DateUtils;
|
||||||
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
import org.jeecg.modules.base.entity.original.GardsSampleData;
|
||||||
import org.jeecg.modules.base.enums.SampleStatus;
|
import org.jeecg.modules.base.enums.SampleStatus;
|
||||||
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
import org.jeecg.modules.config.datasource.DataSourceSwitcher;
|
||||||
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
import org.jeecg.modules.eneity.event.FormatErrorEvent;
|
||||||
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
import org.jeecg.modules.eneity.event.RepeatErrorEvent;
|
||||||
import org.jeecg.modules.exception.AcquisitionBlockException;
|
import org.jeecg.modules.exception.*;
|
||||||
import org.jeecg.modules.exception.FileRepeatException;
|
|
||||||
import org.jeecg.modules.exception.HeaderBlockException;
|
|
||||||
import org.jeecg.modules.exception.PHD_ReadException;
|
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
import org.jeecg.modules.service.ISpectrumBlockService;
|
import org.jeecg.modules.service.ISpectrumBlockService;
|
||||||
|
@ -25,9 +24,11 @@ import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 样品谱(Samplephd)、探测器本地谱(Detbkphd)、QC谱(Qcphd)、气体谱(Gasbkphd)
|
* 样品谱(Samplephd)、探测器本地谱(Detbkphd)、QC谱(Qcphd)、气体谱(Gasbkphd)
|
||||||
|
@ -99,7 +100,39 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+super.spectrumFile.getAbsolutePath());
|
throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+super.spectrumFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
this.sourceData = sourceData;
|
try {
|
||||||
|
//如果是其中单一一个为空 抛出异常
|
||||||
|
//如果两个都为空 就不抛出异常
|
||||||
|
//如果两个都不为空 进行日期格式化 格式化失败
|
||||||
|
if ((StringUtils.isBlank(sourceData.collection_start_date) && StringUtils.isNotBlank(sourceData.collection_start_time)) ||
|
||||||
|
(StringUtils.isBlank(sourceData.collection_start_time) && StringUtils.isNotBlank(sourceData.collection_start_date))) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
} else if (StringUtils.isNotBlank(sourceData.collection_start_time) && StringUtils.isNotBlank(sourceData.collection_start_date)) {
|
||||||
|
DateUtils.parseDate(sourceData.collection_start_date + StringPool.SPACE + sourceData.collection_start_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((StringUtils.isBlank(sourceData.collection_stop_date) && StringUtils.isNotBlank(sourceData.collection_stop_time)) ||
|
||||||
|
(StringUtils.isBlank(sourceData.collection_stop_time) && StringUtils.isNotBlank(sourceData.collection_stop_date))) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
} else if (StringUtils.isNotBlank(sourceData.collection_stop_time) && StringUtils.isNotBlank(sourceData.collection_stop_date)) {
|
||||||
|
DateUtils.parseDate(sourceData.collection_stop_date + StringPool.SPACE + sourceData.collection_stop_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((StringUtils.isBlank(sourceData.acquisition_start_date) && StringUtils.isNotBlank(sourceData.acquisition_start_time)) ||
|
||||||
|
(StringUtils.isBlank(sourceData.acquisition_start_time) && StringUtils.isNotBlank(sourceData.acquisition_start_date))) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
} else if (StringUtils.isNotBlank(sourceData.acquisition_start_time) && StringUtils.isNotBlank(sourceData.acquisition_start_date)) {
|
||||||
|
DateUtils.parseDate(sourceData.acquisition_start_date + StringPool.SPACE + sourceData.acquisition_start_time);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
//将文件移动到错误文件目录
|
||||||
|
super.isDateFormatErr = true;
|
||||||
|
//发送格式化错误事件,后续统计报告使用
|
||||||
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
throw new DateFormatErrorException("This PHDFile contains the wrong date format content:"+super.spectrumFile.getAbsolutePath());
|
||||||
|
} finally {
|
||||||
|
this.sourceData = sourceData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -144,6 +177,36 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对错误的本地能谱临时文件进行改名
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void updateErrorSpectrumFileName() throws FileNotFoundException {
|
||||||
|
StringBuilder newFileName = new StringBuilder();
|
||||||
|
newFileName.append(this.sourceData.detector_code);
|
||||||
|
newFileName.append(StringConstant.DASH);
|
||||||
|
if (StringUtils.isNotBlank(this.sourceData.acquisition_start_date) && StringUtils.isNotBlank(this.sourceData.acquisition_start_time)) {
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_date,StringConstant.SLASH,""));
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_time.substring(0,this.sourceData.acquisition_start_time.lastIndexOf(":")),":",""));
|
||||||
|
} else {
|
||||||
|
newFileName.append("");
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(this.sourceData.spectrum_quantity) && Double.isFinite(this.sourceData.acquisition_live_time)) {
|
||||||
|
newFileName.append(super.spectrumServiceQuotes.getNameStandUtil().GetSuffix(super.currDataType.getType(),this.sourceData.spectrum_quantity,String.valueOf(this.sourceData.acquisition_live_time)));
|
||||||
|
} else {
|
||||||
|
Random ran = new Random();
|
||||||
|
double live_time = ran.nextDouble() * 10000;
|
||||||
|
newFileName.append(super.spectrumServiceQuotes.getNameStandUtil().GetSuffix(super.currDataType.getType(),this.sourceData.spectrum_quantity,String.valueOf(live_time)));
|
||||||
|
}
|
||||||
|
if(!super.spectrumFile.exists()){
|
||||||
|
//发送格式化错误事件,后续统计报告使用
|
||||||
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
|
}
|
||||||
|
super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取邮件内容#开头的标签
|
* 读取邮件内容#开头的标签
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
|
|
@ -60,6 +60,8 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
* 返回调用方(filesource,undel,SpectrumParsingActuator)的文件名称
|
* 返回调用方(filesource,undel,SpectrumParsingActuator)的文件名称
|
||||||
*/
|
*/
|
||||||
protected StringBuilder returnFileName;
|
protected StringBuilder returnFileName;
|
||||||
|
|
||||||
|
protected boolean isDateFormatErr = false;
|
||||||
/**
|
/**
|
||||||
* 保存当前能谱文件有哪些#开头的标签
|
* 保存当前能谱文件有哪些#开头的标签
|
||||||
*/
|
*/
|
||||||
|
@ -148,6 +150,11 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
*/
|
*/
|
||||||
protected abstract void updateSpectrumFileName() throws FileNotFoundException;
|
protected abstract void updateSpectrumFileName() throws FileNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对错误的本地能谱临时文件进行改名
|
||||||
|
*/
|
||||||
|
protected abstract void updateErrorSpectrumFileName() throws FileNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理原始数据
|
* 处理原始数据
|
||||||
*/
|
*/
|
||||||
|
@ -222,11 +229,21 @@ public abstract class AbstractSpectrumHandler extends AbstractChain {
|
||||||
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
protected void handleParseingFailFile(Exception e) throws FileNotFoundException {
|
||||||
if(!SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)){
|
if(!SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)){
|
||||||
try {
|
try {
|
||||||
//解析失败会把文件移动到undeal目录
|
if (isDateFormatErr) {
|
||||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
//修改能谱文件名称
|
||||||
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
this.updateErrorSpectrumFileName();
|
||||||
final String finalPath = rootPath+File.separator+undealPath;
|
//解析失败会把文件移动到undeal目录
|
||||||
FileOperation.copyFile(spectrumFile,finalPath,true);
|
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||||
|
final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath();
|
||||||
|
final String finalPath = rootPath+File.separator+errorFilePath;
|
||||||
|
FileOperation.moveFile(spectrumFile,finalPath,true);
|
||||||
|
} else {
|
||||||
|
//解析失败会把文件移动到undeal目录
|
||||||
|
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||||
|
final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath();
|
||||||
|
final String finalPath = rootPath+File.separator+undealPath;
|
||||||
|
FileOperation.copyFile(spectrumFile,finalPath,true);
|
||||||
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,25 @@ public class AlertSpectrum extends AbstractSpectrumHandler{
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateErrorSpectrumFileName() throws FileNotFoundException {
|
||||||
|
StringBuilder newFileName = new StringBuilder();
|
||||||
|
newFileName.append(this.sourceData.station_code);
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(super.currDataType.getType());
|
||||||
|
newFileName.append(StringConstant.DASH);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.date,StringConstant.SLASH,""));
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.time,":",""));
|
||||||
|
newFileName.append(super.currDataType.getSuffix());
|
||||||
|
if(!super.spectrumFile.exists()){
|
||||||
|
//发送格式化错误事件,后续统计报告使用
|
||||||
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
|
}
|
||||||
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理原始数据
|
* 处理原始数据
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -136,6 +136,25 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateErrorSpectrumFileName() throws FileNotFoundException {
|
||||||
|
StringBuilder newFileName = new StringBuilder();
|
||||||
|
newFileName.append(this.sourceData.station_code);
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(super.currDataType.getType());
|
||||||
|
newFileName.append(StringConstant.DASH);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.start_date,StringConstant.SLASH,""));
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.start_time,":",""));
|
||||||
|
newFileName.append(super.currDataType.getSuffix());
|
||||||
|
if(!super.spectrumFile.exists()){
|
||||||
|
//发送格式化错误事件,后续统计报告使用
|
||||||
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
|
}
|
||||||
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理原始数据
|
* 处理原始数据
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -132,6 +132,25 @@ public class MetSpectrum extends AbstractSpectrumHandler{
|
||||||
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateErrorSpectrumFileName() throws FileNotFoundException {
|
||||||
|
StringBuilder newFileName = new StringBuilder();
|
||||||
|
newFileName.append(this.sourceData.station_code);
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(super.currDataType.getType());
|
||||||
|
newFileName.append(StringConstant.DASH);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.met_start_date.get(0),StringConstant.SLASH,""));
|
||||||
|
newFileName.append(StringConstant.UNDER_LINE);
|
||||||
|
newFileName.append(StringUtils.replace(this.sourceData.met_start_time.get(0),":",""));
|
||||||
|
newFileName.append(super.currDataType.getSuffix());
|
||||||
|
if(!super.spectrumFile.exists()){
|
||||||
|
//发送格式化错误事件,后续统计报告使用
|
||||||
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent());
|
||||||
|
throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist");
|
||||||
|
}
|
||||||
|
super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理原始数据
|
* 处理原始数据
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user