package com.gkhy.labRiskManage.commons.utils;
|
|
import com.alibaba.fastjson.*;
|
import com.gkhy.labRiskManage.api.controller.basic.dto.respDto.*;
|
import com.gkhy.labRiskManage.api.controller.riskReport.dto.respDto.*;
|
import com.gkhy.labRiskManage.application.basic.dto.bo.BasicExperimentPersonAppQueryBO;
|
import com.gkhy.labRiskManage.application.basic.dto.dto.BasicExperimentDeviceAppQueryDTO;
|
import com.gkhy.labRiskManage.application.basic.dto.dto.BasicExperimentSiteAppQueryDTO;
|
import com.gkhy.labRiskManage.application.basic.dto.dto.BasicExperimentStuffAppQueryDTO;
|
import com.gkhy.labRiskManage.application.riskReport.dto.dto.RiskAssessPlanAppQueryDTO;
|
import com.gkhy.labRiskManage.domain.basic.model.dto.RiskUnitBasicQueryDTO;
|
import com.gkhy.labRiskManage.domain.riskReport.entity.RiskAssessPlan;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.AssessPlanQueryDTO;
|
import com.gkhy.labRiskManage.domain.riskReport.model.dto.RiskAssessPlanQueryDTO;
|
import org.springframework.beans.BeanUtils;
|
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
public class BeanCopyUtils {
|
|
private BeanCopyUtils() {
|
}
|
|
/**练习
|
public static Object copyBean(Object source, Class clazz) {
|
//创建目标对象
|
Object result = null;
|
try {
|
result = clazz.newInstance();
|
//实现属性copy
|
BeanUtils.copyProperties(source, result);
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
//返回结果
|
return result;
|
}*/
|
|
public static <V> V copyBean(Object source,Class<V> clazz) {
|
//创建目标对象
|
V result = null;
|
try {
|
result = clazz.newInstance();
|
//实现属性copy
|
BeanUtils.copyProperties(source, result);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
//返回结果
|
return result;
|
}
|
|
/**练习
|
* public static <V> List<V> copyBeanList(List<Object> list, Class<V> clazz){
|
return list.stream()
|
.map(o -> copyBean(o, clazz))
|
.collect(Collectors.toList());
|
}*/
|
|
public static <O,V> List<V> copyBeanList(List<O> list, Class<V> clazz){
|
return list.stream()
|
.map(o -> copyBean(o, clazz))
|
.collect(Collectors.toList());
|
}
|
|
|
|
public static <T> List<T> list2OtherList(List originList,Class<T> tClass){
|
List<T> list = new ArrayList<>();
|
for (Object info : originList) {
|
T t = JSON.parseObject(JSON.toJSONString(info),tClass);
|
list.add(t);
|
}
|
return list;
|
}
|
|
|
public static Object copyDeviceAppQueryList(Object data, Class<BasicExperimentDeviceAppQueryDTO> basicExperimentDeviceAppQueryDTOClass) {
|
return data;
|
}
|
|
public static Object copyDeviceQueryRespList(Object data, Class<BasicExperimentDeviceQueryRespDTO> basicExperimentDeviceQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyDeviceListRespList(Object data, Class<BasicExperimentDeviceQueryRespDTO> basicExperimentDeviceQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyPersonAppQueryList(Object data, Class<BasicExperimentPersonAppQueryBO> basicExperimentPersonAppQueryDOClass) {
|
return data;
|
}
|
|
public static Object copyPersonQueryRespList(Object data, Class<BasicExperimentPersonQueryRespDTO> basicExperimentPersonQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyPersonListQueryList(Object data, Class<BasicExperimentPersonListRespDTO> basicExperimentPersonListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copySiteAppQueryList(Object data, Class<BasicExperimentSiteAppQueryDTO> basicExperimentSiteAppQueryDTOClass) {
|
return data;
|
}
|
|
public static Object copySiteQueryRespList(Object data, Class<BasicExperimentSiteQueryRespDTO> basicExperimentSiteQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copySiteListQueryResp(Object data, Class<BasicExperimentSiteListRespDTO> basicExperimentSiteListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyStuffAppQueryList(Object data, Class<BasicExperimentStuffAppQueryDTO> basicExperimentStuffAppQueryDTOClass) {
|
return data;
|
}
|
|
public static Object copyStuffQueryRespList(Object data, Class<BasicExperimentStuffQueryRespDTO> basicExperimentStuffQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyStuffListQueryResp(Object data, Class<BasicExperimentStuffListRespDTO> basicExperimentStuffListRespDTOClass) {
|
return data;
|
}
|
|
|
public static Object copyRiskUnitListQueryResp(Object data, Class<BasicRiskUnitQueryRespDTO> basicRiskUnitQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyRiskUnitRespList(Object data, Class<BasicRiskUnitListRespDTO> basicRiskUnitListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorLecLQueryResp(Object data, Class<FactorLecLListRespDTO> factorLecEListRespDTOClass) {
|
return data;
|
}
|
public static Object copyFactorLecEQueryResp(Object data, Class<FactorLecEListRespDTO> factorLecCListRespDTOClass) {
|
return data;
|
}
|
public static Object copyFactorLecCQueryResp(Object data, Class<FactorLecCListRespDTO> factorLecCListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorLsLQueryResp(Object data, Class<FactorLsLListRespDTO> factorLsLListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorLsSQueryResp(Object data, Class<FactorLsSListRespDTO> factorLsSListRespDTOClass) {
|
return data;
|
}
|
public static Object copyFactorMesMQueryResp(Object data, Class<FactorMesMListRespDTO> factorMesMListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorMesEQueryResp(Object data, Class<FactorMesEListRespDTO> factorMesEListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorMesSQueryResp(Object data, Class<FactorMesSListRespDTO> factorMesSListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorRsRQueryResp(Object data, Class<FactorRsRListRespDTO> factorRsRListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyFactorRsSQueryResp(Object data, Class<FactorRsSListRespDTO> factorRsSListRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyExperimentRiskUnitListQueryResp(Object data, Class<RiskUnitQueryRespDTO> riskUnitQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyExperimentRiskUnitAppQueryList(Object data, Class<RiskUnitBasicQueryDTO> riskUnitBasicQueryDTOClass) {
|
return data;
|
}
|
|
public static Object copyRiskAssessPlanQueryResp(Object data, Class<RiskAssessPlanQueryRespDTO> riskAssessPlanQueryRespDTOClass) {
|
return data;
|
}
|
|
public static Object copyRiskAssessPlanAppQueryList(Object data, Class<RiskAssessPlanAppQueryDTO> riskAssessPlanAppQueryDTOClass) {
|
return data;
|
}
|
|
public static Object copyRiskAssessQueryResp(Object data, Class<RiskAssessQueryRespDTO> riskAssessQueryReqBOClass) {
|
return data;
|
}
|
|
|
public static Object copyReportQueryResp(Object data, Class<ReportQueryRespDTO> reportQueryRespDTOClass) {
|
return data;
|
}
|
|
}
|