sinake
2026-09-15 c427395d096da3df775a2fac9987bbcbd1f654fd
ruoyi-project/src/main/resources/mapper/project/ServiceTotalsMapper.xml
@@ -5,46 +5,46 @@
<mapper namespace="com.ruoyi.project.mapper.ServiceTotalsMapper">
    <select id="caseTrend" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
        SELECT DATE_FORMAT(a.ReportTime, '%Y-%m') donateTime, register_county_name area,  COUNT(*) potentialCount,COUNT(IF(complete_state=3, true, null)) completeCount  FROM service_donatebaseinfo_report a
        LEFT JOIN  service_donatecompletioninfo  b ON b.InfoID=a.id and a.del_flag=0 and b.del_flag=0
            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
        <where>
            <if test="area != null  and area != ''">and register_county_name>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.ReportTime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.ReportTime &lt;= #{endTime}</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>
        GROUP BY register_county_name, DATE_FORMAT(a.ReportTime, '%Y-%m')
        GROUP BY RegisterCountyName, DATE_FORMAT(a.donatetime, '%Y-%m')
    </select>
    <select id="caseTrendMoon" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
        SELECT DATE_FORMAT(a.ReportTime, '%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 and a.del_flag=0 and b.del_flag=0
            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
        <where>
            <if test="area != null  and area != ''">and register_county_name>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.ReportTime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.ReportTime &lt;= #{endTime}</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>
        GROUP BY DATE_FORMAT(a.ReportTime, '%Y-%m')
        GROUP BY DATE_FORMAT(a.donatetime, '%Y-%m')
    </select>
    <select id="caseTrendArea" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
        SELECT register_county_name 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 and a.del_flag=0 and b.del_flag=0
            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
        <where>
            <if test="area != null  and area != ''">and register_county_name>=#{area}</if>
            <if test="startTime != null  and startTime != ''">and a.ReportTime>=#{startTime}</if>
            <if test="endTime != null  and endTime != ''">and a.ReportTime &lt;= #{endTime}</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>
        GROUP BY register_county_name
        GROUP BY RegisterCountyName
    </select>
    <select id="organ" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
            resultType="ServiceTotalsOrgan">
        SELECT DATE_FORMAT(a.OrganGetTime, '%Y-%m') donateTime,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  and a.del_flag=0  and b.del_flag=0
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
@@ -57,10 +57,10 @@
    </select>
    <select id="organMoon" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
            resultType="ServiceTotalsOrgan">
        SELECT DATE_FORMAT(a.OrganGetTime, '%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  and a.del_flag=0  and b.del_flag=0
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
@@ -73,10 +73,10 @@
    </select>
    <select id="organType" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="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  and a.del_flag=0  and b.del_flag=0
        LEFT JOIN  service_donatecomporgan b ON a.InfoID=b.InfoID AND a.OrganName=b.OrganName  where a.del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and a.InfoID in (select id FROM service_donatecompletioninfo where RegisterCountyName>=#{area} )
@@ -89,15 +89,15 @@
    </select>
    <select id="caseSex" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
            resultType="ServiceTotalsSex">
        SELECT COUNT(sex) totalCount, COUNT(IF(sex=1, true, NULL)) manCount ,COUNT(IF(sex=2, true, NULL)) womanCount
        FROM service_donatebaseinfo
        FROM service_donatebaseinfo where del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="bloodType != null  and bloodType != ''">
                and  BloodType>=#{bloodType}
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
@@ -113,13 +113,13 @@
    <select id="caseAvgAge" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
        SELECT AVG(age) avgAge FROM  service_donatebaseinfo
        SELECT AVG(age) avgAge FROM  service_donatebaseinfo where del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="bloodType != null  and bloodType != ''">
                and  BloodType>=#{bloodType}
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
@@ -133,15 +133,15 @@
    </select>
    <select id="caseBloodType" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotals">
            resultType="ServiceTotalsBood">
        SELECT COUNT(BloodType) boodTypeCount,BloodType bloodType
        FROM service_donatebaseinfo
        FROM service_donatebaseinfo where del_flag=0
        <where>
            <if test="area != null  and area != ''">
                and  RegisterCountyName>=#{area}
            </if>
            <if test="bloodType != null  and bloodType != ''">
                and  BloodType>=#{bloodType}
            <if test="boodType != null  and boodType != ''">
                and  BloodType>=#{boodType}
            </if>
            <if test="sex != null  and sex != ''">
                and  sex>=#{sex}
@@ -155,4 +155,25 @@
        GROUP BY  BloodType
    </select>
    <select id="totals" parameterType="com.ruoyi.project.domain.ServiceTotals"
            resultType="ServiceTotalsTotal">
        SELECT ( SELECT COUNT(*) FROM service_donatebaseinfo_report WHERE del_flag=0) totalPotential,
        (SELECT COUNT(*) FROM service_donatecompletioninfo WHERE del_flag=0) 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
        <where>
            <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>