heheng
2024-11-07 37b0d2560607d1e0bfd5247a59a154704cac60f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
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;
    }
 
}