fix: 健康管理系统,吃奶量统计接口新增。
This commit is contained in:
@@ -599,5 +599,225 @@
|
||||
group by hmr.departments
|
||||
order by count(hmr.departments) desc
|
||||
</select>
|
||||
<select id="selectMilkPowderStatistic" parameterType="HealthMilkPowderRecordDto" resultType="com.intc.health.domain.vo.HealthMilkPowderStatisticVo">
|
||||
select
|
||||
hp.id as personId ,
|
||||
hp.name as personName,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and to_char(hmpr.suckles_time,
|
||||
'yyyy-MM-dd') = to_char(CURRENT_DATE,
|
||||
'yyyy-MM-dd')
|
||||
) as todayCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and to_char(hmpr.suckles_time,
|
||||
'yyyy-MM-dd') = to_char(CURRENT_DATE,
|
||||
'yyyy-MM-dd')
|
||||
) as todayConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '7 days'
|
||||
) as sevenDayCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '7 days'
|
||||
) as sevenDayConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '1 months'
|
||||
) as oneMonthCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '1 months'
|
||||
) as oneMonthConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '3 months'
|
||||
) as threeMonthCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '3 months'
|
||||
) as threeMonthConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '6 months'
|
||||
) as sixMonthCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '6 months'
|
||||
) as sixMonthConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '1 years'
|
||||
) as oneYearCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '1 years'
|
||||
) as oneYearConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '2 years'
|
||||
) as twoYearCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '2 years'
|
||||
) as twoYearConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '3 years'
|
||||
) as threeYearCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '3 years'
|
||||
) as threeYearConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '5 years'
|
||||
) as fiveYearCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
and hmpr.suckles_time >= CURRENT_DATE - interval '5 years'
|
||||
) as fiveYearConsumption,
|
||||
(
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
) as totalCount,
|
||||
(
|
||||
select
|
||||
sum(hmpr.consumption)
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where
|
||||
hmpr.person_id = hp.id
|
||||
) as totalConsumption
|
||||
from
|
||||
health_person hp
|
||||
<where>
|
||||
hp.del_flag = '0'
|
||||
<if test="personId != null "> and hp.id = #{personId}</if>
|
||||
</where>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectMilkPowderDayStatistic" parameterType="HealthMilkPowderRecordDto" resultType="com.intc.health.domain.vo.HealthMilkPowderRecordVo">
|
||||
select
|
||||
to_char(hmpr.suckles_time,
|
||||
'yyyy-MM-dd') as sucklesTime,
|
||||
sum (hmpr.consumption) as consumption
|
||||
from
|
||||
health_milk_powder_record hmpr
|
||||
where hmpr.del_flag ='0'
|
||||
<if test="personId != null "> and hmpr.person_id = #{personId}</if>
|
||||
<if test="endTime!=null and endTime !=''">
|
||||
and #{endTime}>=to_char(hmpr.suckles_time, 'yyyy-MM-dd')
|
||||
</if>
|
||||
<if test="startTime!=null and startTime !=''">
|
||||
and to_char(hmpr.suckles_time, 'yyyy-MM-dd')>=#{startTime}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
group by
|
||||
to_char(hmpr.suckles_time,
|
||||
'yyyy-MM-dd')
|
||||
order by
|
||||
to_char(hmpr.suckles_time,
|
||||
'yyyy-MM-dd') desc
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user