sinake
10 天以前 63b95a545b17b5efdfcfc902f129d354600c44ab
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.mapper.ServiceTotalsMapper">
 
    <select id="caseTrend" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsTrend">
        SELECT DATE_FORMAT(a.donatetime, '%Y-%m') donateTime, RegisterCountyName area,  COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
        GROUP BY RegisterCountyName, DATE_FORMAT(a.donatetime, '%Y-%m')
    </select>
 
    <select id="caseTrendMoon" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsTrend">
        SELECT DATE_FORMAT(a.donatetime, '%Y-%m') donateTime, COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
        GROUP BY DATE_FORMAT(a.donatetime, '%Y-%m')
    </select>
 
    <select id="caseTrendArea" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsTrend">
        SELECT RegisterCountyName area, COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo a
        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
        GROUP BY RegisterCountyName
    </select>
 
    <select id="organ" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsOrgan">
        SELECT DATE_FORMAT(a.organ_start_time, '%Y-%m') donateTime,a.OrganName organName, COUNT(*) getCount,c.RegisterCountyName area,
        COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
        LEFT JOIN  service_donatebaseinfo c ON a.InfoID=c.ID
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
            </if>
            <if test="area != null  and area != ''">and c.RegisterCountyName>=#{area}</if>
            <if test="organName != null  and organName != ''">and a.OrganName>=#{organName}</if>
            <if test="startTime != null  and startTime != ''">and a.organ_start_time>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.organ_start_time &lt;= #{endTime}</if>
        </where>
        GROUP BY DATE_FORMAT(a.organ_start_time, '%Y-%m'),a.OrganName,c.RegisterCountyName
    </select>
 
    <select id="organMoon" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsOrgan">
        SELECT DATE_FORMAT(a.organ_start_time, '%Y-%m') donateTime, COUNT(*) getCount,
        COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
            </if>
            <if test="organName != null  and organName != ''">and a.OrganName>=#{organName}</if>
            <if test="startTime != null  and startTime != ''">and a.organ_start_time>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.organ_start_time &lt;= #{endTime}</if>
        </where>
        GROUP BY DATE_FORMAT(a.organ_start_time, '%Y-%m')
    </select>
 
    <select id="organType" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsOrgan">
        SELECT a.OrganName organName, COUNT(*) getCount,
        COUNT(IF(transplantstate=3, true, NULL)) useCount   FROM  service_donationwitnessorgan a
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
            </if>
            <if test="organName != null  and organName != ''">and a.OrganName>=#{organName}</if>
            <if test="startTime != null  and startTime != ''">and a.organ_start_time>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.organ_start_time &lt;= #{endTime}</if>
        </where>
        GROUP BY a.OrganName
    </select>
 
    <select id="caseSex" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsSex">
        SELECT COUNT(sex) totalCount, COUNT(IF(sex=1, true, NULL)) manCount ,COUNT(IF(sex=2, true, NULL)) womanCount
        FROM service_donatebaseinfo
        <where>
            del_flag=0
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
            </if>
            <if test="ageGroup != null  and ageGroup != ''">
                and  ${ageGroup}
            </if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
        GROUP BY  sex
    </select>
 
    <select id="caseAvgAge" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
        SELECT AVG(age) avgAge FROM  service_donatebaseinfo
        <where>
            del_flag=0
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
            </if>
            <if test="ageGroup != null  and ageGroup != ''">
                and  ${ageGroup}
            </if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
    </select>
 
    <select id="caseBloodType" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsBood">
        SELECT COUNT(BloodType) boodTypeCount,BloodType bloodType
        FROM service_donatebaseinfo
        <where>
            del_flag=0
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
            </if>
            <if test="ageGroup != null  and ageGroup != ''">
                and  ${ageGroup}
            </if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
        GROUP BY  BloodType
    </select>
 
    <select id="totals" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsTotal">
        SELECT ( SELECT COUNT(*) FROM service_donatebaseinfo WHERE del_flag=0) totalPotential,
               (SELECT COUNT(*) FROM service_donatecompletioninfo WHERE del_flag=0 and complete_state=3) totalCompletion
    </select>
 
    <select id="trendList" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="trendList">
        SELECT a.id,a.case_no,a.NAME ,a.InpatientNo,a.TreatmentHospitalName,a.workflow,a.donatetime,d.DeathReason,
        (SELECT  GROUP_CONCAT(c.OrganName) FROM service_donateorgan c WHERE c.InfoId=a.id AND c.del_flag=0) OrganName
        FROM service_donatebaseinfo a
        LEFT JOIN service_deathinfo d ON d.InfoID=a.id
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
 
    </select>
 
    <select id="trendCount" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="Long">
        SELECT count(*)
        FROM service_donatebaseinfo a
        LEFT JOIN service_deathinfo d ON d.InfoID=a.id
        <where>
            a.del_flag=0
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
 
    </select>
 
    <select id="organTotals" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsOrganTotals">
        SELECT ( SELECT COUNT(*) FROM service_donatecomporgan WHERE del_flag=0 AND transplantstate=1) totalTransplant,
               ( SELECT COUNT(*) FROM service_donatecomporgan WHERE del_flag=0 AND transplantstate=4) totalDiscard,
               (SELECT COUNT(*) FROM service_donationwitnessorgan WHERE del_flag=0 AND OrganState=3) totalGet,
               (SELECT COUNT(*) FROM service_donationwitnessorgan WHERE del_flag=0 AND OrganState=4) totalRecycle
    </select>
 
    <select id="organList" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="organList">
        SELECT a.id,a.case_no,a.NAME,a.RegisterCountyName,YEAR(a.donatetime) donateYear,b.OrganName,b.transplantstate,
        b.TransplantTime,b.Name,b.TransplantDoct,b.HospitalName,c.OrganGetTime,c.notgetreason
        FROM service_donatebaseinfo a LEFT JOIN service_donatecomporgan b ON a.ID=b.InfoID
        LEFT JOIN service_donationwitnessorgan c ON a.ID=c.InfoID
        <where>
            a.del_flag=0 AND b.del_flag=0 AND c.del_flag=0
            <if test="organName != null  and organName != ''">and b.OrganName>=#{organName}</if>
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
 
    </select>
 
    <select id="organCount" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="Long">
        SELECT count(*)
        FROM service_donatebaseinfo a LEFT JOIN service_donatecomporgan b ON a.ID=b.InfoID
        LEFT JOIN service_donationwitnessorgan c ON a.ID=c.InfoID
        <where>
            a.del_flag=0 AND b.del_flag=0 AND c.del_flag=0
            <if test="organName != null  and organName != ''">and b.OrganName>=#{organName}</if>
            <if test="area != null  and area != ''">and a.RegisterCountyName>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.donatetime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.donatetime &lt;= #{endTime}</if>
        </where>
 
    </select>
 
</mapper>