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 getExperimentInfoRespDTO(List experimentInfoAppQueryDTOList){ List experimentInfoRespDTOS = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTOList)){ for (ExperimentInfoAppQueryDTO experimentInfoAppQueryDTO:experimentInfoAppQueryDTOList){ ExperimentInfoRespDTO experimentInfoRespDTO = new ExperimentInfoRespDTO(); BeanUtils.copyProperties(experimentInfoAppQueryDTO,experimentInfoRespDTO); //实验场所 List siteRespDTOs = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getSites())){ siteRespDTOs = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getSites(),ExperimentAndSiteRespDTO.class); } experimentInfoRespDTO.setSiteList(siteRespDTOs); //人员 List personRespDTOList = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getPersons())){ personRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getPersons(),ExperimentAndPersonRespDTO.class); } experimentInfoRespDTO.setPersons(personRespDTOList); //设备 List deviceRespDTOList = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getDevices())){ deviceRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getDevices(),ExperimentAndDeviceRespDTO.class); } experimentInfoRespDTO.setDeviceList(deviceRespDTOList); //材料 List stuffRespDTOList = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getStuffs())){ stuffRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getStuffs(),ExperimentAndStuffRespDTO.class); } experimentInfoRespDTO.setStuffList(stuffRespDTOList); //危废 List wasteRespDTOList = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppQueryDTO.getWastes())){ wasteRespDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppQueryDTO.getWastes(),ExperimentHazardousWasteRespDTO.class); } experimentInfoRespDTO.setHazardousWasteList(wasteRespDTOList); //应急演练 List 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 getExperimentInfoVoRespDTO(List experimentInfoAppVos) { List respDTOList = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoAppVos)){ respDTOList = BeanCopyUtils.copyBeanList(experimentInfoAppVos,ExperimentInfoVoRespDTO.class); } return respDTOList; } public PageQuery getAppPageQuery(PageQuery pageQueryReqBO) { PageQuery 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; } }