Merge branch 'dev_gy_0920' of http://182.92.166.109:3000/jihan/xinelu-api into dev_gy_0920

This commit is contained in:
mengkuiliang 2023-10-23 09:23:39 +08:00
commit 1e237d11fc
15 changed files with 129 additions and 31 deletions

View File

@ -4,6 +4,7 @@ import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.R;
import com.xinelu.familydoctor.entity.*;
import com.xinelu.familydoctor.service.PhysicalSignService;
import com.xinelu.familydoctor.vo.PhysicalLastRecordVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -11,6 +12,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
@ -83,4 +85,11 @@ public class PhysicalSignController extends BaseController {
Map<String, Object> map = physicalSignService.record(identity, type, label);
return R.ok(map);
}
@ApiOperation("获取最后一次体征记录")
@GetMapping("record/last/{identity}")
@ApiImplicitParam(name = "identity", value = "身份证号", required = true)
public R<List<PhysicalLastRecordVO>> lastRecord(@PathVariable String identity) {
return R.ok(physicalSignService.getLastRecord(identity));
}
}

View File

@ -55,7 +55,7 @@ public class DeviceBfRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -43,7 +43,7 @@ public class DeviceBgRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -28,6 +28,18 @@ public class DeviceBmiRecord implements Serializable {
@ApiModelProperty("居民身份证号")
private String identity;
/**
* 身高cm
*/
@ApiModelProperty("身高cm")
private BigDecimal height;
/**
* 体重kg
*/
@ApiModelProperty("体重kg")
private BigDecimal weight;
/**
* BMI单位kg/m^2
*/
@ -37,7 +49,7 @@ public class DeviceBmiRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -42,7 +42,7 @@ public class DeviceBoRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -48,7 +48,7 @@ public class DeviceBpRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -36,7 +36,7 @@ public class DeviceHrRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -37,7 +37,7 @@ public class DeviceTempRecord implements Serializable {
/**
* 测量时间
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty("测量时间")
private Date measureTime;

View File

@ -2,6 +2,7 @@ package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBgRecord;
import com.xinelu.familydoctor.vo.BgCalcVO;
import com.xinelu.familydoctor.vo.PhysicalLastRecordVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -38,4 +39,5 @@ public interface DeviceBgRecordMapper {
int update(DeviceBgRecord record);
List<PhysicalLastRecordVO> getLastRecord(String identity);
}

View File

@ -1,7 +1,9 @@
package com.xinelu.familydoctor.service;
import com.xinelu.familydoctor.entity.*;
import com.xinelu.familydoctor.vo.PhysicalLastRecordVO;
import java.util.List;
import java.util.Map;
public interface PhysicalSignService {
@ -22,4 +24,13 @@ public interface PhysicalSignService {
* @date 2023-10-9 10:10
*/
Map<String, Object> record(String identity, String type, String label);
/**
* 获取最后一次记录
* @param identity 身份证号
* @return {@link java.util.List<com.xinelu.familydoctor.vo.PhysicalLastRecordVO>}
* @author gaoyu
* @date 2023-10-20 14:56
*/
List<PhysicalLastRecordVO> getLastRecord(String identity);
}

View File

@ -99,6 +99,11 @@ public class PhysicalSignServiceImpl implements PhysicalSignService {
return map;
}
@Override
public List<PhysicalLastRecordVO> getLastRecord(String identity) {
return deviceBgRecordMapper.getLastRecord(identity);
}
private Map<String, Object> bgRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBgRecord> list = deviceBgRecordMapper.getBgRecord(identity, type);

View File

@ -0,0 +1,27 @@
package com.xinelu.familydoctor.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author gaoyu
* @description 体征检测最后一次记录
* @date 2023-10-20 14:28
*/
@ApiModel("体征检测最后一次记录")
@Data
public class PhysicalLastRecordVO {
@ApiModelProperty("类型1血糖2血压3血脂4bmi5血氧6心率7体温")
private String type;
@ApiModelProperty("日期")
@JsonFormat(pattern = "yyyy/MM/dd", timezone = "GMT+8")
private Date date;
@ApiModelProperty("时间段1凌晨2早餐前3早晨后4午餐前5午餐后6晚餐前7晚餐后8睡前")
private String bucket;
@ApiModelProperty("")
private String val;
}

View File

@ -105,4 +105,27 @@
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<select id="getLastRecord" resultType="com.xinelu.familydoctor.vo.PhysicalLastRecordVO">
(select '1' AS "type", measure_time "date", bucket, bg "val" from device_bg_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '2' AS "type", measure_time "date", null "bucket", concat(sbp, '/', dbp) "val" from device_bp_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '3' AS "type", measure_time "date", null "bucket", concat(tc, '/', tg, '/', hdl, '/', ldl) "val" from device_bf_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '4' AS "type", measure_time "date", null "bucket", bmi "val" from device_bmi_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '5' AS "type", measure_time "date", null "bucket", spo2 "val" from device_bo_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '6' AS "type", measure_time "date", null "bucket", hr "val" from device_hr_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
union all
(select '7' AS "type", measure_time "date", null "bucket", temp "val" from device_temp_record
where identity = #{identity} and measure_time &gt;= date_add(now(), interval -30 day) order by id desc limit 1)
</select>
</mapper>

View File

@ -7,13 +7,15 @@
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBmiRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="height" column="height" jdbcType="DECIMAL"/>
<result property="weight" column="weight" jdbcType="DECIMAL"/>
<result property="bmi" column="bmi" jdbcType="DECIMAL"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,bmi,
measure_time
id,identity,height,
weight,bmi,measure_time
</sql>
<select id="getBmiRecord" resultMap="BaseResultMap">
@ -46,10 +48,10 @@
<select id="getBmiCalc" resultType="com.xinelu.familydoctor.vo.BmiCalcVO">
select ifnull(max(bmi), 0) "maxVal",
ifnull(min(bmi), 0) "minVal",
ifnull(avg(bmi), 0) "avgVal",
count(case when bmi &gt;= 18.5 and bmi &lt;= 23.9 then 1 else null end) "normalNum",
count(case when bmi &lt; 18.5 or bmi >= 24 then 1 else null end) "overNum"
ifnull(min(bmi), 0) "minVal",
ifnull(avg(bmi), 0) "avgVal",
count(case when bmi &gt;= 18.5 and bmi &lt;= 23.9 then 1 else null end) "normalNum",
count(case when bmi &lt; 18.5 or bmi >= 24 then 1 else null end) "overNum"
from device_bmi_record
where identity = #{identity}
<choose>
@ -73,26 +75,33 @@
</otherwise>
</choose>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBmiRecord" useGeneratedKeys="true">
insert into device_bmi_record
(identity,bmi
,measure_time)
values (#{identity,jdbcType=VARCHAR},#{bmi,jdbcType=DECIMAL}
,#{measureTime,jdbcType=TIMESTAMP})
(identity,height
,weight,bmi,measure_time
)
values (#{identity,jdbcType=VARCHAR},#{height,jdbcType=DECIMAL}
,#{weight,jdbcType=DECIMAL},#{bmi,jdbcType=DECIMAL},#{measureTime,jdbcType=TIMESTAMP}
)
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBmiRecord">
update device_bmi_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="bmi != null">
bmi = #{bmi,jdbcType=DECIMAL},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="height != null">
height = #{height,jdbcType=DECIMAL},
</if>
<if test="weight != null">
weight = #{weight,jdbcType=DECIMAL},
</if>
<if test="bmi != null">
bmi = #{bmi,jdbcType=DECIMAL},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>

View File

@ -51,7 +51,7 @@
<sql id="maxSbpSql">
select concat(sbp, '/', dbp) "maxSbpVal" from device_bp_record
where sbp = (select max(sbp) from device_bp_record
and identity = #{identity}
where identity = #{identity}
<choose>
<when test="type == '0'">
@ -99,7 +99,7 @@
<sql id="maxDbpSql">
select concat(sbp, '/', dbp) "maxDbpVal" from device_bp_record
where dbp = (select max(dbp) from device_bp_record
and identity = #{identity}
where identity = #{identity}
<choose>
<when test="type == '0'">
@ -147,7 +147,7 @@
<sql id="minSbpSql">
select concat(sbp, '/', dbp) "minSbpVal" from device_bp_record
where sbp = (select min(sbp) from device_bp_record
and identity = #{identity}
where identity = #{identity}
<choose>
<when test="type == '0'">
@ -195,7 +195,7 @@
<sql id="minDbpSql">
select concat(sbp, '/', dbp) "minDbpVal" from device_bp_record
where dbp = (select min(dbp) from device_bp_record
and identity = #{identity}
where identity = #{identity}
<choose>
<when test="type == '0'">