liusheng
2024-03-19 ded03f0315e02c13f17b8bf7777c89a5cc73130e
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
package com.ruoyi.project.service.impl;
 
import java.util.List;
 
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.project.domain.ServiceDonatebaseinfo;
import com.ruoyi.project.domain.ServiceDonateorgan;
import com.ruoyi.project.domain.vo.DonationWitnessVO;
import com.ruoyi.project.domain.vo.TimeVO;
import com.ruoyi.project.domain.vo.WitnessStatsVO;
import com.ruoyi.project.mapper.ServiceDonatebaseinfoMapper;
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 java.util.ArrayList;
import java.util.Map;
 
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.project.mapper.ServiceDonationwitnessMapper;
import com.ruoyi.project.domain.ServiceDonationwitness;
import com.ruoyi.project.service.IServiceDonationwitnessService;
 
/**
 * 捐献见证Service业务层处理
 *
 * @author ruoyi
 * @date 2021-11-17
 */
@Service
public class ServiceDonationwitnessServiceImpl extends ServiceImpl<ServiceDonationwitnessMapper, ServiceDonationwitness> implements IServiceDonationwitnessService {
 
 
    @Autowired
    ServiceDonationwitnessMapper serviceDonationwitnessMapper;
 
    @Autowired
    ServiceDonatebaseinfoMapper serviceDonatebaseinfoMapper;
 
    @Autowired
    ServiceDonateorganServiceImpl serviceDonateorganService;
 
    /**
     * 查询捐献见证列表
     *
     * @param serviceDonationwitness 捐献见证
     * @return 捐献见证
     */
    @Override
    public List<ServiceDonationwitness> queryList(ServiceDonationwitness serviceDonationwitness) {
        LambdaQueryWrapper<ServiceDonationwitness> wrappers = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(serviceDonationwitness.getDonorno())) {
            wrappers.eq(ServiceDonationwitness::getDonorno, serviceDonationwitness.getDonorno());
        }
        if (StringUtils.isNotBlank(serviceDonationwitness.getGainhospitalname())) {
            wrappers.like(ServiceDonationwitness::getGainhospitalname, serviceDonationwitness.getGainhospitalname());
        }
        if (StringUtils.isNotBlank(serviceDonationwitness.getOperationdoctor())) {
            wrappers.eq(ServiceDonationwitness::getOperationdoctor, serviceDonationwitness.getOperationdoctor());
        }
        return this.list(wrappers);
    }
 
    @Override
    public List<DonationWitnessVO> selectVOList(DonationWitnessVO donationWitnessVO) {
 
        SysUser user = SecurityUtils.getLoginUser().getUser();
        List<SysRole> l = user.getRoles();
        Boolean b = false;
        for (SysRole r : l) {
            if (r.getRoleId().longValue() == 3) {
                b = true;
            }
        }
        if (b) {
            donationWitnessVO.setBasecreateby(user.getUserName());
        }
        List<DonationWitnessVO> donationWitnessVOS = serviceDonationwitnessMapper.selectVOList(donationWitnessVO);
        return donationWitnessVOS;
    }
 
    @Override
    public ServiceDonationwitness getByInfoId(Long infoid) {
 
 
        return serviceDonationwitnessMapper.selectByInfoId(infoid);
    }
 
    @Override
    public WitnessStatsVO getStats(TimeVO timeVO) {
        WitnessStatsVO w = new WitnessStatsVO();
        ServiceDonationwitness serviceDonationwitness = new ServiceDonationwitness();
        //List<ServiceDonationwitness> list = serviceDonationwitnessMapper.selectServiceDonationwitnessList(serviceDonationwitness);
        List<ServiceDonationwitness> list = serviceDonationwitnessMapper.selectByTime(timeVO);
        int total = list.size();
        int manNumber = 0;
        int womanNumber = 0;
        int D0Number = 0;
        int D1Number = 0;
        int D2Number = 0;
        int D3Number = 0;
        int D4Number = 0;
        int DBDNumber = 0;
        int DCDNumber = 0;
        int DBCDNumber = 0;
        int A1Number = 0;
        int A2Number = 0;
        int A3Number = 0;
        int XANumber = 0;
        int XBNumber = 0;
        int XONumber = 0;
        int XABNumber = 0;
        int DothersNumber = 0;
        for (ServiceDonationwitness l : list) {
            ServiceDonatebaseinfo serviceDonatebaseinfo = serviceDonatebaseinfoMapper.getById(l.getInfoid());
            if (serviceDonatebaseinfo.getSex() != null && serviceDonatebaseinfo.getSex().equals("1")) {
                manNumber++;
            }
            if (serviceDonatebaseinfo.getSex() != null && serviceDonatebaseinfo.getSex().equals("2")) {
                womanNumber++;
            }
            if (serviceDonatebaseinfo.getDiseasetype() != null && serviceDonatebaseinfo.getDiseasetype().equals("0")) {
                D0Number++;
            }
            if (serviceDonatebaseinfo.getDiseasetype() != null && serviceDonatebaseinfo.getDiseasetype().equals("1")) {
                D1Number++;
            }
            if (serviceDonatebaseinfo.getDiseasetype() != null && serviceDonatebaseinfo.getDiseasetype().equals("2")) {
                D2Number++;
            }
            if (serviceDonatebaseinfo.getDiseasetype() != null && serviceDonatebaseinfo.getDiseasetype().equals("3")) {
                D3Number++;
            }
            if (serviceDonatebaseinfo.getDiseasetype() != null && serviceDonatebaseinfo.getDiseasetype().equals("4")) {
                D4Number++;
            }
            if (l.getDonationcategory() != null && l.getDonationcategory().equals("DBD")) {
                DBDNumber++;
            }
            if (l.getDonationcategory() != null && l.getDonationcategory().equals("DCD")) {
                DCDNumber++;
            }
            if (l.getDonationcategory() != null && l.getDonationcategory().equals("DBCD")) {
                DBCDNumber++;
            }
            if (serviceDonatebaseinfo.getAge() != null && serviceDonatebaseinfo.getAge() >= 0 && serviceDonatebaseinfo.getAge() <= 17) {
                A1Number++;
            }
            if (serviceDonatebaseinfo.getAge() != null && serviceDonatebaseinfo.getAge() >= 18 && serviceDonatebaseinfo.getAge() <= 48) {
                A2Number++;
            }
            if (serviceDonatebaseinfo.getAge() != null && serviceDonatebaseinfo.getAge() >= 49 && serviceDonatebaseinfo.getAge() <= 69) {
                A3Number++;
            }
            if (serviceDonatebaseinfo.getBloodtype() != null && serviceDonatebaseinfo.getBloodtype().equals("1")) {
                XANumber++;
            }
            if (serviceDonatebaseinfo.getBloodtype() != null && serviceDonatebaseinfo.getBloodtype().equals("2")) {
                XBNumber++;
            }
            if (serviceDonatebaseinfo.getBloodtype() != null && serviceDonatebaseinfo.getBloodtype().equals("3")) {
                XONumber++;
            }
            if (serviceDonatebaseinfo.getBloodtype() != null && serviceDonatebaseinfo.getBloodtype().equals("4")) {
                XABNumber++;
            }
        }
        DothersNumber = total - D0Number - D1Number - D2Number - D3Number - D4Number;
 
        if (total == 0) {
            w.setManRate(0);
            w.setWomanRate(0);
            w.setD0Rate(0);
            w.setD1Rate(0);
            w.setD2Rate(0);
            w.setD3Rate(0);
            w.setD4Rate(0);
            w.setDOthersRate(0);
            w.setDBDRate(0);
            w.setDCDRate(0);
            w.setDBCDRate(0);
            w.setA1Rate(0);
            w.setA2Rate(0);
            w.setA3Rate(0);
            w.setXARate(0);
            w.setXBRate(0);
            w.setXORate(0);
            w.setXABRate(0);
 
        } else {
            w.setManRate((double) manNumber / (double) total);
            w.setWomanRate((double) womanNumber / (double) total);
            w.setD0Rate((double) D0Number / (double) total);
            w.setD1Rate((double) D1Number / (double) total);
            w.setD2Rate((double) D2Number / (double) total);
            w.setD3Rate((double) D3Number / (double) total);
            w.setD4Rate((double) D4Number / (double) total);
            w.setDOthersRate((double) DothersNumber / (double) total);
            w.setDBDRate((double) DBDNumber / (double) total);
            w.setDCDRate((double) DCDNumber / (double) total);
            w.setDBCDRate((double) DBCDNumber / (double) total);
            w.setA1Rate((double) A1Number / (double) total);
            w.setA2Rate((double) A2Number / (double) total);
            w.setA3Rate((double) A3Number / (double) total);
            w.setXARate((double) XANumber / (double) total);
            w.setXBRate((double) XBNumber / (double) total);
            w.setXORate((double) XONumber / (double) total);
            w.setXABRate((double) XABNumber / (double) total);
        }
 
        return w;
    }
 
}