sinake
10 小时以前 9b977a5dcaae63d5f4997592dae8df0ee0b6d85f
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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<ServiceDonateorganBaseMapper, ServiceDonateorganBase> implements IServiceDonateorganBaseService {
 
    @Autowired
    private ServiceDonateorganBaseMapper serviceDonateorganBaseMapper;
 
    @Autowired
    private ServiceDonateorganMapper serviceDonateorganMapper;
 
    /**
     * 查询捐献器官分配基础列表
     *
     * @param serviceDonateorganBase 捐献器官分配基础
     * @return 捐献器官分配基础
     */
    @Override
    public Page<ServiceDonateorganBase> queryList(ServiceDonateorganBase serviceDonateorganBase) {
        LambdaQueryWrapper<ServiceDonateorganBase> 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<ServiceDonateorganBase> page = new Page<>(currentPage, size);
        List<ServiceDonateorganBase> serviceDonateorganBaseList = serviceDonateorganBaseMapper.selectPage(page, wrappers).getRecords();
 
        return page.setRecords(serviceDonateorganBaseList);
    }
 
    @Override
    public List<DonateorganBaseInfoDTO> getDonateorganBaseInfoList(DonateorganBaseInfoVO donateorganBaseInfoVO) {
        List<DonateorganBaseInfoDTO> 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<ServiceDonateorgan> serviceDonateorgans = serviceDonateorganMapper.selectServiceDonateorganList(serviceDonateorgan);
                donateorganBaseInfoDTO.setServiceDonateorganList(serviceDonateorgans);
            }
        }
        return donateorganBaseInfoList;
    }
 
 
    /**
     * 查询捐献器官分配基础列表
     *
     * @param serviceDonateorganBase 捐献器官分配基础
     * @return 捐献器官分配基础
     */
    @Override
    public List<ServiceDonateorganBase> exportQueryList(ServiceDonateorganBase serviceDonateorganBase) {
        LambdaQueryWrapper<ServiceDonateorganBase> 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 long 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 serviceDonateorganBase.getId();
    }
 
    @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()) {
                    if(ObjectUtils.isNotEmpty(serviceDonateorgan.getId()) ) {
                        if(ObjectUtils.isNotEmpty(serviceDonateorgan.getDelFlag())&&serviceDonateorgan.getDelFlag()==1 ) {
                            serviceDonateorganMapper.deleteById(serviceDonateorgan.getId());
                        }else {
                            serviceDonateorganMapper.updateById(serviceDonateorgan);
                        }
                    }else {
                        serviceDonateorgan.setBaseId(serviceDonateorganBase.getId());
                        serviceDonateorganMapper.insert(serviceDonateorgan);
                    }
                }
            }
        }
        return b;
    }
 
}