郑永安
2023-06-19 c8188c0fc9edf6ea3feda5b6f11dcb014af2a89e
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
package com.gkhy.labRiskManage.application.experiment.converter;
 
import cn.hutool.core.util.ObjectUtil;
import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentAndDeviceInsertReqBO;
import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentAndEmergencyInsertReqBO;
import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentAndStuffInsertReqBO;
import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentHazardousWasteInsertReqBO;
import com.gkhy.labRiskManage.application.experiment.dto.bo.ExperimentAndDeviceAppInsertBO;
import com.gkhy.labRiskManage.application.experiment.dto.bo.ExperimentAndEmergencyAppInsertBO;
import com.gkhy.labRiskManage.application.experiment.dto.bo.ExperimentAndStuffAppInsertBO;
import com.gkhy.labRiskManage.application.experiment.dto.bo.ExperimentHazardousWasteAppInsertBO;
import com.gkhy.labRiskManage.application.experiment.dto.dto.ExperimentInfoAppVo;
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAndEmergency;
import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentInfoDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @email 1603559716@qq.com
 * @author: zf
 * @date: 2023/3/20
 * @time: 15:15
 */
@Component
public class ExperimentAppConverter {
    public List<ExperimentAndDeviceAppInsertBO> getDeviceInsertBOList(List<ExperimentAndDeviceInsertReqBO> deviceList, Long experimentId) {
        List<ExperimentAndDeviceAppInsertBO> list = new ArrayList<>();
        if(ObjectUtil.isNotEmpty(deviceList)){
            for(ExperimentAndDeviceInsertReqBO experimentAndDeviceInsertReqBO:deviceList){
                ExperimentAndDeviceAppInsertBO experimentAndDeviceAppInsertBO = new ExperimentAndDeviceAppInsertBO();
                experimentAndDeviceAppInsertBO.setDeviceId(experimentAndDeviceInsertReqBO.getDeviceId());
                experimentAndDeviceAppInsertBO.setDeviceUseCount(experimentAndDeviceInsertReqBO.getDeviceUseCount());
                experimentAndDeviceAppInsertBO.setExperimentId(experimentId);
                list.add(experimentAndDeviceAppInsertBO);
            }
        }
        return list;
    }
    public List<ExperimentAndStuffAppInsertBO> getStuffInsertBOList(List<ExperimentAndStuffInsertReqBO> stuffList, Long experimentId) {
        List<ExperimentAndStuffAppInsertBO> list = new ArrayList<>();
        if(ObjectUtil.isNotEmpty(stuffList)){
            for(ExperimentAndStuffInsertReqBO experimentAndStuffInsertReqBO:stuffList){
                ExperimentAndStuffAppInsertBO experimentAndStuffAppInsertBO = new ExperimentAndStuffAppInsertBO();
                experimentAndStuffAppInsertBO.setStuffId(experimentAndStuffInsertReqBO.getStuffId());
                experimentAndStuffAppInsertBO.setStuffUseCount(experimentAndStuffInsertReqBO.getStuffUseCount());
                experimentAndStuffAppInsertBO.setExperimentId(experimentId);
                list.add(experimentAndStuffAppInsertBO);
            }
        }
        return list;
    }
    public List<ExperimentHazardousWasteAppInsertBO> getHazardousWasteInsertBOList(List<ExperimentHazardousWasteInsertReqBO> hazardousWasteList, Long experimentId) {
 
        List<ExperimentHazardousWasteAppInsertBO> list = new ArrayList<>();
        if(ObjectUtil.isNotEmpty(hazardousWasteList)){
            for(ExperimentHazardousWasteInsertReqBO experimentHazardousWasteInsertReqBO:hazardousWasteList){
                ExperimentHazardousWasteAppInsertBO experimentHazardousWasteAppInsertBO = new ExperimentHazardousWasteAppInsertBO();
                BeanUtils.copyProperties(experimentHazardousWasteInsertReqBO,experimentHazardousWasteAppInsertBO);
                experimentHazardousWasteAppInsertBO.setExperimentId(experimentId);
                list.add(experimentHazardousWasteAppInsertBO);
            }
        }
 
        return list;
    }
    public List<ExperimentAndEmergencyAppInsertBO> getExperimentAndEmergencyAppInsertBOList(List<ExperimentAndEmergencyInsertReqBO> ExperimentAndEmergencyList, Long experimentId){
        List<ExperimentAndEmergencyAppInsertBO> list = new ArrayList<>();
        if (ObjectUtil.isNotEmpty(ExperimentAndEmergencyList)) {
            for(ExperimentAndEmergencyInsertReqBO emergencyInsertReqBO : ExperimentAndEmergencyList){
                ExperimentAndEmergencyAppInsertBO experimentAndEmergencyAppInsertBO = new ExperimentAndEmergencyAppInsertBO();
                BeanUtils.copyProperties(emergencyInsertReqBO,experimentAndEmergencyAppInsertBO);
                experimentAndEmergencyAppInsertBO.setExperimentId(experimentId);
                list.add(experimentAndEmergencyAppInsertBO);
            }
        }
        return list;
    }
 
 
    public List<ExperimentInfoAppVo> getExperimentInfoAppVoList(List<ExperimentInfoDTO> experimentInfoList) {
        List<ExperimentInfoAppVo> experimentInfoAppVos = new ArrayList<>();
        if(!ObjectUtils.isEmpty(experimentInfoList)){
            experimentInfoAppVos = BeanCopyUtils.copyBeanList(experimentInfoList,ExperimentInfoAppVo.class);
        }
        return experimentInfoAppVos;
    }
 
 
}