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 getDeviceInsertBOList(List deviceList, Long experimentId) { List 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 getStuffInsertBOList(List stuffList, Long experimentId) { List 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 getHazardousWasteInsertBOList(List hazardousWasteList, Long experimentId) { List 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 getExperimentAndEmergencyAppInsertBOList(List ExperimentAndEmergencyList, Long experimentId){ List 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 getExperimentInfoAppVoList(List experimentInfoList) { List experimentInfoAppVos = new ArrayList<>(); if(!ObjectUtils.isEmpty(experimentInfoList)){ experimentInfoAppVos = BeanCopyUtils.copyBeanList(experimentInfoList,ExperimentInfoAppVo.class); } return experimentInfoAppVos; } }