package com.ruoyi.project.service.impl; import java.util.List; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.utils.bean.DtoConversionUtils; import com.ruoyi.project.domain.ServiceDonateorgan; import com.ruoyi.project.domain.vo.ServiceDonateorganBaseVO; import com.ruoyi.project.domain.dto.DonateorganBaseInfoDTO; import com.ruoyi.project.domain.vo.DonateorganBaseInfoVO; import com.ruoyi.project.mapper.ServiceDonateorganMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.project.mapper.ServiceDonateorganBaseMapper; import com.ruoyi.project.domain.ServiceDonateorganBase; import com.ruoyi.project.service.IServiceDonateorganBaseService; /** * 捐献器官分配基础Service业务层处理 * * @author ls * @date 2026-01-17 */ @Service public class ServiceDonateorganBaseServiceImpl extends ServiceImpl implements IServiceDonateorganBaseService { @Autowired private ServiceDonateorganBaseMapper serviceDonateorganBaseMapper; @Autowired private ServiceDonateorganMapper serviceDonateorganMapper; /** * 查询捐献器官分配基础列表 * * @param serviceDonateorganBase 捐献器官分配基础 * @return 捐献器官分配基础 */ @Override public Page queryList(ServiceDonateorganBase serviceDonateorganBase) { LambdaQueryWrapper wrappers = Wrappers.lambdaQuery(); if (serviceDonateorganBase.getInfoid() != null) { wrappers.eq(ServiceDonateorganBase::getInfoid, serviceDonateorganBase.getInfoid()); } if (serviceDonateorganBase.getAllocationStatus() != null) { wrappers.eq(ServiceDonateorganBase::getAllocationStatus, serviceDonateorganBase.getAllocationStatus()); } if (serviceDonateorganBase.getAllocationTime() != null) { wrappers.eq(ServiceDonateorganBase::getAllocationTime, serviceDonateorganBase.getAllocationTime()); } if (StringUtils.isNotBlank(serviceDonateorganBase.getRegistrationCode())) { wrappers.eq(ServiceDonateorganBase::getRegistrationCode, serviceDonateorganBase.getRegistrationCode()); } if (StringUtils.isNotBlank(serviceDonateorganBase.getRegistrationName())) { wrappers.like(ServiceDonateorganBase::getRegistrationName, serviceDonateorganBase.getRegistrationName()); } if (serviceDonateorganBase.getRegistrationTime() != null) { wrappers.eq(ServiceDonateorganBase::getRegistrationTime, serviceDonateorganBase.getRegistrationTime()); } if (serviceDonateorganBase.getEstimatedtime() != null) { wrappers.eq(ServiceDonateorganBase::getEstimatedtime, serviceDonateorganBase.getEstimatedtime()); } int currentPage = (serviceDonateorganBase.getPageNum() == null || serviceDonateorganBase.getPageNum() < 1) ? 1 : serviceDonateorganBase.getPageNum(); int size = (serviceDonateorganBase.getPageSize() == null || serviceDonateorganBase.getPageSize() < 1) ? 10 : serviceDonateorganBase.getPageSize(); Page page = new Page<>(currentPage, size); List serviceDonateorganBaseList = serviceDonateorganBaseMapper.selectPage(page, wrappers).getRecords(); return page.setRecords(serviceDonateorganBaseList); } @Override public List getDonateorganBaseInfoList(DonateorganBaseInfoVO donateorganBaseInfoVO) { List donateorganBaseInfoList = serviceDonateorganBaseMapper.getDonateorganBaseInfoList(donateorganBaseInfoVO); if (!donateorganBaseInfoList.isEmpty() && donateorganBaseInfoVO.getPageNum() != null) { for (DonateorganBaseInfoDTO donateorganBaseInfoDTO : donateorganBaseInfoList) { ServiceDonateorgan serviceDonateorgan = new ServiceDonateorgan(); serviceDonateorgan.setInfoid(donateorganBaseInfoDTO.getInfoid()); serviceDonateorgan.setBaseId(donateorganBaseInfoDTO.getId()); //获取捐献多个器官详情管理列表 List serviceDonateorgans = serviceDonateorganMapper.selectServiceDonateorganList(serviceDonateorgan); donateorganBaseInfoDTO.setServiceDonateorganList(serviceDonateorgans); } } return donateorganBaseInfoList; } /** * 查询捐献器官分配基础列表 * * @param serviceDonateorganBase 捐献器官分配基础 * @return 捐献器官分配基础 */ @Override public List exportQueryList(ServiceDonateorganBase serviceDonateorganBase) { LambdaQueryWrapper wrappers = Wrappers.lambdaQuery(); if (serviceDonateorganBase.getInfoid() != null) { wrappers.eq(ServiceDonateorganBase::getInfoid, serviceDonateorganBase.getInfoid()); } if (serviceDonateorganBase.getAllocationStatus() != null) { wrappers.eq(ServiceDonateorganBase::getAllocationStatus, serviceDonateorganBase.getAllocationStatus()); } if (serviceDonateorganBase.getAllocationTime() != null) { wrappers.eq(ServiceDonateorganBase::getAllocationTime, serviceDonateorganBase.getAllocationTime()); } if (StringUtils.isNotBlank(serviceDonateorganBase.getRegistrationCode())) { wrappers.eq(ServiceDonateorganBase::getRegistrationCode, serviceDonateorganBase.getRegistrationCode()); } if (StringUtils.isNotBlank(serviceDonateorganBase.getRegistrationName())) { wrappers.like(ServiceDonateorganBase::getRegistrationName, serviceDonateorganBase.getRegistrationName()); } if (serviceDonateorganBase.getRegistrationTime() != null) { wrappers.eq(ServiceDonateorganBase::getRegistrationTime, serviceDonateorganBase.getRegistrationTime()); } if (serviceDonateorganBase.getEstimatedtime() != null) { wrappers.eq(ServiceDonateorganBase::getEstimatedtime, serviceDonateorganBase.getEstimatedtime()); } return this.list(wrappers); } @Override public Boolean add(ServiceDonateorganBaseVO serviceDonateorganBaseVO) { ServiceDonateorganBase serviceDonateorganBase = DtoConversionUtils.sourceToTarget(serviceDonateorganBaseVO, ServiceDonateorganBase.class); boolean save = false; if (ObjectUtils.isNotEmpty(serviceDonateorganBase)) { save = save(serviceDonateorganBase); if (save == true && CollectionUtils.isNotEmpty(serviceDonateorganBaseVO.getServiceDonateorganList())) { for (ServiceDonateorgan serviceDonateorgan : serviceDonateorganBaseVO.getServiceDonateorganList()) { serviceDonateorgan.setBaseId(serviceDonateorganBase.getId()); serviceDonateorganMapper.insert(serviceDonateorgan); } } } return save; } @Override public Boolean updateByParam(ServiceDonateorganBaseVO serviceDonateorganBaseVO) { ServiceDonateorganBase serviceDonateorganBase = DtoConversionUtils.sourceToTarget(serviceDonateorganBaseVO, ServiceDonateorganBase.class); boolean b = false; if (ObjectUtils.isNotEmpty(serviceDonateorganBase)) { b = updateById(serviceDonateorganBase); if (b == true && CollectionUtils.isNotEmpty(serviceDonateorganBaseVO.getServiceDonateorganList())) { for (ServiceDonateorgan serviceDonateorgan : serviceDonateorganBaseVO.getServiceDonateorganList()) { serviceDonateorganMapper.updateById(serviceDonateorgan); } } } return b; } }