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
package com.gkhy.labRiskManage.api.controller.experiment.converter;
 
import com.gkhy.labRiskManage.api.controller.experiment.dto.req.ExperimentInfoQueryReqBO;
import com.gkhy.labRiskManage.api.controller.experiment.dto.resp.*;
import com.gkhy.labRiskManage.application.experiment.dto.bo.ExperimentInfoAppQueryBO;
import com.gkhy.labRiskManage.application.experiment.dto.dto.ExperimentInfoAppQueryDTO;
import com.gkhy.labRiskManage.application.experiment.dto.dto.ExperimentInfoAppVo;
import com.gkhy.labRiskManage.commons.model.PageQuery;
import com.gkhy.labRiskManage.commons.utils.BeanCopyUtils;
import com.gkhy.labRiskManage.domain.experiment.entity.ExperimentAndEmergency;
import com.gkhy.labRiskManage.domain.experiment.model.dto.ExperimentAndEmergencyDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * @email 1603559716@qq.com
 * @author: zf
 * @date: 2023/3/22
 * @time: 10:48
 */
@Service
public class ExperimentApiConverter {
    public List<ExperimentInfoRespDTO> getExperimentInfoRespDTO(List<ExperimentInfoAppQueryDTO> experimentInfoAppQueryDTOList){
        List<ExperimentInfoRespDTO> experimentInfoRespDTOS = new ArrayList<>();
        if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTOList)){
            for (ExperimentInfoAppQueryDTO experimentInfoAppQueryDTO:experimentInfoAppQueryDTOList){
                ExperimentInfoRespDTO experimentInfoRespDTO = new ExperimentInfoRespDTO();
                BeanUtils.copyProperties(experimentInfoAppQueryDTO,experimentInfoRespDTO);
                //实验类型
                List<ExperimentAndTypeRespDTO> typeRespDTOs = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getTypes())){
                    typeRespDTOs = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getTypes(),ExperimentAndTypeRespDTO.class);
                }
                experimentInfoRespDTO.setTypeList(typeRespDTOs);
                //实验场所
                List<ExperimentAndSiteRespDTO> siteRespDTOs = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getSites())){
                    siteRespDTOs = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getSites(),ExperimentAndSiteRespDTO.class);
                }
                experimentInfoRespDTO.setSiteList(siteRespDTOs);
                //人员
                List<ExperimentAndPersonRespDTO> personRespDTOList = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getPersons())){
                    personRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getPersons(),ExperimentAndPersonRespDTO.class);
                }
                experimentInfoRespDTO.setPersons(personRespDTOList);
                //设备
                List<ExperimentAndDeviceRespDTO> deviceRespDTOList = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getDevices())){
                    deviceRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getDevices(),ExperimentAndDeviceRespDTO.class);
                }
                experimentInfoRespDTO.setDeviceList(deviceRespDTOList);
                //材料
                List<ExperimentAndStuffRespDTO> stuffRespDTOList = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getStuffs())){
                    stuffRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getStuffs(),ExperimentAndStuffRespDTO.class);
                }
                experimentInfoRespDTO.setStuffList(stuffRespDTOList);
                //危废
                List<ExperimentHazardousWasteRespDTO> wasteRespDTOList = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getWastes())){
                    wasteRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getWastes(),ExperimentHazardousWasteRespDTO.class);
                }
                experimentInfoRespDTO.setHazardousWasteList(wasteRespDTOList);
 
                //应急演练
                List<ExperimentAndEmergencyRespDTO> emergencies = new ArrayList<>();
                if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getEmergencies())){
                    emergencies = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getEmergencies(),ExperimentAndEmergencyRespDTO.class);
                }
                experimentInfoRespDTO.setEmergencyList(emergencies);
                experimentInfoRespDTOS.add(experimentInfoRespDTO);
            }
        }
        return experimentInfoRespDTOS;
    }
 
    public List<ExperimentInfoVoRespDTO> getExperimentInfoVoRespDTO(List<ExperimentInfoAppVo> experimentInfoAppVos) {
        List<ExperimentInfoVoRespDTO> respDTOList = new ArrayList<>();
        if(!ObjectUtils.isEmpty(experimentInfoAppVos)){
            respDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppVos,ExperimentInfoVoRespDTO.class);
        }
        return respDTOList;
    }
 
    public PageQuery<ExperimentInfoAppQueryBO> getAppPageQuery(PageQuery<ExperimentInfoQueryReqBO> pageQueryReqBO) {
        PageQuery<ExperimentInfoAppQueryBO> appPageQuery = new PageQuery<>();
        appPageQuery.setPageIndex(pageQueryReqBO.getPageIndex());
        appPageQuery.setPageSize(pageQueryReqBO.getPageSize());
        ExperimentInfoAppQueryBO experimentInfoAppQueryBO = new ExperimentInfoAppQueryBO();
        if(!ObjectUtils.isEmpty(pageQueryReqBO.getSearchParams())){
            BeanUtils.copyProperties(pageQueryReqBO.getSearchParams(),experimentInfoAppQueryBO);
        }
        appPageQuery.setSearchParams(experimentInfoAppQueryBO);
        return appPageQuery;
    }
}