fix: 健康管理系统,吃奶量统计接口新增。

This commit is contained in:
tianyongbao
2025-02-05 16:40:21 +08:00
parent 5d7416445b
commit 2d403c7707
6 changed files with 447 additions and 4 deletions

View File

@@ -61,4 +61,12 @@ public class StatisticAnalysisController extends BaseController {
}
@ApiOperation("吃奶统计分析")
@GetMapping("/milkPowderAnalysis")
public Map<String,Object> getMilkPowderAnalysis(AnalysisDto analysisDto){
Map<String, Object> resultMap = iStatisticAnalysisService.getMilkPowderAnalysis(analysisDto);
return AjaxResult.success(resultMap);
}
}

View File

@@ -0,0 +1,150 @@
package com.intc.health.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 吃奶记录Vo对象 health_milk_powder_record
*
* @author tianyongbao
* @date 2025-02-01
*/
@ApiModel("吃奶记录Vo对象")
@Data
public class HealthMilkPowderStatisticVo
{
/** 人员名称 */
@ApiModelProperty(value="人员姓名)")
private String personName;
/** 人员ID */
@ApiModelProperty(value="人员ID)")
private Long personId;
/** 今日次数 */
@ApiModelProperty(value="今日次数)")
private int todayCount;
/** 今日吃奶量 */
@ApiModelProperty(value="今日吃奶量)")
private double todayConsumption;
/** 今日平均吃奶量 */
@ApiModelProperty(value="今日平均吃奶量)")
private double todayPerConsumption;
/** 近7日次数 */
@ApiModelProperty(value="近7日次数)")
private int sevenDayCount;
/** 近7日吃奶量 */
@ApiModelProperty(value="近7日吃奶量)")
private double sevenDayConsumption;
/** 近7日平均吃奶量 */
@ApiModelProperty(value="近7日平均吃奶量)")
private double sevenDayPerConsumption;
/** 近1月次数 */
@ApiModelProperty(value="近1月次数)")
private int oneMonthCount;
/** 近1月吃奶量 */
@ApiModelProperty(value="近1月吃奶量)")
private double oneMonthConsumption;
/** 近1月平均吃奶量 */
@ApiModelProperty(value="近1月平均吃奶量)")
private double oneMonthPerConsumption;
/** 近3月次数 */
@ApiModelProperty(value="近3月次数)")
private int threeMonthCount;
/** 近3月吃奶量 */
@ApiModelProperty(value="近3月吃奶量)")
private double threeMonthConsumption;
/** 近3月平均吃奶量 */
@ApiModelProperty(value="近3月平均吃奶量)")
private double threeMonthPerConsumption;
/** 近6月次数 */
@ApiModelProperty(value="近6月次数)")
private int sixMonthCount;
/** 近6月吃奶量 */
@ApiModelProperty(value="近6月吃奶量)")
private double sixMonthConsumption;
/** 近6月平均吃奶量 */
@ApiModelProperty(value="近6月平均吃奶量)")
private double sixMonthPerConsumption;
/** 近1年次数 */
@ApiModelProperty(value="近1年次数)")
private int oneYearCount;
/** 近1年吃奶量 */
@ApiModelProperty(value="近1年吃奶量)")
private double oneYearConsumption;
/** 近1年平均吃奶量 */
@ApiModelProperty(value="近1年平均吃奶量)")
private double oneYearPerConsumption;
/** 近2年次数 */
@ApiModelProperty(value="近2年次数)")
private int twoYearCount;
/** 近2年吃奶量 */
@ApiModelProperty(value="近2年吃奶量)")
private double twoYearConsumption;
/** 近2年平均吃奶量 */
@ApiModelProperty(value="近2年平均吃奶量)")
private double twoYearPerConsumption;
/** 近3年次数 */
@ApiModelProperty(value="近3年次数)")
private int threeYearCount;
/** 近3年吃奶量 */
@ApiModelProperty(value="近3年吃奶量)")
private double threeYearConsumption;
/** 近3年平均吃奶量 */
@ApiModelProperty(value="近3年平均吃奶量)")
private double threeYearPerConsumption;
/** 近5年次数 */
@ApiModelProperty(value="近5年次数)")
private int fiveYearCount;
/** 近5年吃奶量 */
@ApiModelProperty(value="近5年吃奶量)")
private double fiveYearConsumption;
/** 近5年平均吃奶量 */
@ApiModelProperty(value="近5年平均吃奶量)")
private double fiveYearPerConsumption;
/** 总次数 */
@ApiModelProperty(value="总次数)")
private int totalCount;
/** 总吃奶量 */
@ApiModelProperty(value="总吃奶量)")
private double totalConsumption;
/** 总平均吃奶量 */
@ApiModelProperty(value="总平均吃奶量)")
private double totalPerConsumption;
}

View File

@@ -3,11 +3,9 @@ package com.intc.health.mapper;
import com.intc.common.datascope.annotation.DataScope;
import com.intc.health.domain.dto.HealthDoctorRecordDto;
import com.intc.health.domain.dto.HealthMarRecordDto;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.domain.dto.HealthRecordDto;
import com.intc.health.domain.vo.HealthDoctorRecordVo;
import com.intc.health.domain.vo.HealthMarRecordVo;
import com.intc.health.domain.vo.HealthRecordVo;
import com.intc.health.domain.vo.HealthStaticPersonVo;
import com.intc.health.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -159,6 +157,22 @@ public interface StatisticAnalysisMapper {
public List<HealthDoctorRecordVo> selectDepartStaticList(HealthDoctorRecordDto dto);
/**
* 查询用药记录
*
* @param healthMilkPowderRecordDto
* @return 收支集合
*/
@DataScope(businessAlias = "hp")
public HealthMilkPowderStatisticVo selectMilkPowderStatistic(HealthMilkPowderRecordDto healthMilkPowderRecordDto);
/**
* 查询用药记录
*
* @param healthMilkPowderRecordDto
* @return 收支集合
*/
@DataScope(businessAlias = "hmpr")
public List<HealthMilkPowderRecordVo> selectMilkPowderDayStatistic(HealthMilkPowderRecordDto healthMilkPowderRecordDto);
}

View File

@@ -23,4 +23,7 @@ public interface IStatisticAnalysisService {
public Map<String, Object> getDoctorAnalysis(AnalysisDto analysisDto);
public Map<String, Object> getMilkPowderAnalysis(AnalysisDto analysisDto);
}

View File

@@ -342,6 +342,7 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
}
ArrayList<Map<String, Object>> temperatureList = new ArrayList<>();
Collections.reverse(temperatureRecordVoList);
for (HealthTemperatureRecordVo vo:temperatureRecordVoList
) {
Map<String, Object> datamap = new HashMap<>();
@@ -738,4 +739,51 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
return map;
}
@Override
public Map<String, Object> getMilkPowderAnalysis(AnalysisDto analysisDto) {
//返回数据
HashMap<String, Object> map = new HashMap<>();
DecimalFormat decimalFormat = new DecimalFormat("#.##");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
HealthMilkPowderRecordDto dto=new HealthMilkPowderRecordDto();
dto.setPersonId(analysisDto.getId());
//获取数据
dto.setEndTime(analysisDto.getEndTime());
dto.setStartTime(analysisDto.getStartTime());
HealthMilkPowderStatisticVo milkPowderStatisticVo= statisticAnalysisMapper.selectMilkPowderStatistic(dto);
if(milkPowderStatisticVo.getTodayCount()!=0) {
milkPowderStatisticVo.setTodayPerConsumption(milkPowderStatisticVo.getTodayConsumption() / milkPowderStatisticVo.getTodayCount());
}
milkPowderStatisticVo.setSevenDayPerConsumption(Double.parseDouble(decimalFormat.format(milkPowderStatisticVo.getSevenDayConsumption()/7)));
//列表
map.put("milkPowderStatistic",milkPowderStatisticVo);
List<HealthMilkPowderRecordVo> list=statisticAnalysisMapper.selectMilkPowderDayStatistic(dto);
ArrayList<Map<String, Object>> milkPowderList = new ArrayList<>();
ArrayList<Map<String, Object>> milkPowderTableList = new ArrayList<>();
for (HealthMilkPowderRecordVo vo:list
) {
Map<String, Object> datamap = new HashMap<>();
datamap.put("time", dateFormat.format(vo.getSucklesTime()));
datamap.put("value", vo.getConsumption());
milkPowderTableList.add(datamap);
}
Collections.reverse(list);
for (HealthMilkPowderRecordVo vo:list
) {
Map<String, Object> datamap = new HashMap<>();
datamap.put("time", dateFormat.format(vo.getSucklesTime()));
datamap.put("value", vo.getConsumption());
milkPowderList.add(datamap);
}
//列表
map.put("milkPowderTableList",milkPowderTableList);
map.put("milkPowderList",milkPowderList);
return map;
}
}

View File

@@ -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>