设备绑定及体征检测接口

This commit is contained in:
gaoyu 2023-10-09 11:18:06 +08:00
parent 52ba21ab35
commit 7707af2ab7
37 changed files with 2260 additions and 0 deletions

View File

@ -83,6 +83,13 @@
<groupId>com.xinelu</groupId>
<artifactId>xinelu-familydoctor</artifactId>
</dependency>
<!-- 家医相关模块 -->
<dependency>
<groupId>com.xinelu</groupId>
<artifactId>xinelu-familydoctor</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,63 @@
package com.xinelu.web.controller.familydoctor;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.familydoctor.entity.DeviceBindResident;
import com.xinelu.familydoctor.service.DeviceBindResidentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @author gaoyu
* @description 设备绑定控制器
* @date 2023-9-25 16:54
*/
@Api(tags = {"设备绑定控制器"})
@RestController
@RequestMapping("/fd/device")
public class DeviceBindResidentController extends BaseController {
@Resource
private DeviceBindResidentService deviceBindResidentService;
@ApiOperation("绑定设备")
@PostMapping("binding")
public AjaxResult bind(@RequestBody DeviceBindResident entity) {
if (deviceBindResidentService.repeatBind(entity)) {
return AjaxResult.error("设备【" + entity.getSn() + "】已绑定");
}
AjaxResult ajaxResult;
int row = deviceBindResidentService.bindDevice(entity);
if (row > 0) {
ajaxResult = AjaxResult.success();
} else {
ajaxResult = AjaxResult.error("绑定失败");
}
return ajaxResult;
}
@ApiOperation("已绑定的设备")
@GetMapping("bound/{identity}")
@ApiImplicitParam(name = "identity", value = "身份证号", required = true)
public AjaxResult boundDevice(@PathVariable String identity) {
List<DeviceBindResident> list = deviceBindResidentService.boundDevice(identity);
return AjaxResult.success(list);
}
@ApiOperation("解绑设备")
@PostMapping("unbind")
public AjaxResult unbindDevice(@RequestBody DeviceBindResident entity) {
AjaxResult ajaxResult;
int row = deviceBindResidentService.unbindDevice(entity);
if (row > 0) {
ajaxResult = AjaxResult.success();
} else {
ajaxResult = AjaxResult.error("解绑失败");
}
return ajaxResult;
}
}

View File

@ -0,0 +1,86 @@
package com.xinelu.web.controller.familydoctor;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.familydoctor.entity.*;
import com.xinelu.familydoctor.service.PhysicalSignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
/**
* @author gaoyu
* @description 体征检测控制器
* @date 2023-9-26 11:21
*/
@Api(tags = {"体征检测控制器"})
@RestController
@RequestMapping("/fd/ps")
public class PhysicalSignController extends BaseController {
@Resource
private PhysicalSignService physicalSignService;
@ApiOperation("上传血糖")
@PostMapping("bg/save")
public AjaxResult saveBg(@RequestBody DeviceBgRecord record) {
physicalSignService.saveBg(record);
return AjaxResult.success();
}
@ApiOperation("上传血压")
@PostMapping("bp/save")
public AjaxResult saveBp(@RequestBody DeviceBpRecord record) {
physicalSignService.saveBp(record);
return AjaxResult.success();
}
@ApiOperation("上传血脂")
@PostMapping("bf/save")
public AjaxResult saveBf(@RequestBody DeviceBfRecord record) {
physicalSignService.saveBf(record);
return AjaxResult.success();
}
@ApiOperation("上传BMI")
@PostMapping("bmi/save")
public AjaxResult saveBmi(@RequestBody DeviceBmiRecord record) {
physicalSignService.saveBmi(record);
return AjaxResult.success();
}
@ApiOperation("上传血氧")
@PostMapping("bo/save")
public AjaxResult saveBo(@RequestBody DeviceBoRecord record) {
physicalSignService.saveBo(record);
return AjaxResult.success();
}
@ApiOperation("上传心率")
@PostMapping("hr/save")
public AjaxResult saveHr(@RequestBody DeviceHrRecord record) {
physicalSignService.saveHr(record);
return AjaxResult.success();
}
@ApiOperation("上传体温")
@PostMapping("temp/save")
public AjaxResult saveTemp(@RequestBody DeviceTempRecord record) {
physicalSignService.saveTemp(record);
return AjaxResult.success();
}
@ApiOperation("获取体征记录")
@GetMapping("record")
@ApiImplicitParams({@ApiImplicitParam(name = "identity", value = "身份证号", required = true),
@ApiImplicitParam(name = "type", value = "时间类型0全部1周2月3", required = true),
@ApiImplicitParam(name = "label", value = "查询标识1血糖2血压3血脂4bmi5血氧6心率7体温", required = true)})
public AjaxResult record(String identity, String type, String label) {
Map<String, Object> map = physicalSignService.record(identity, type, label);
return AjaxResult.success(map);
}
}

View File

@ -0,0 +1,50 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 血脂记录表
* @TableName device_bf_record
*/
@Data
public class DeviceBfRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 血清总胆固醇单位mmol/L
*/
private BigDecimal tc;
/**
* 甘油三酯单位mmol/L
*/
private BigDecimal tg;
/**
* 高密度脂蛋白胆固醇单位mmol/L
*/
private BigDecimal hdl;
/**
* 低密度脂蛋白胆固醇单位mmol/L
*/
private BigDecimal ldl;
/**
* 测量时间
*/
private Date measureTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,45 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 血糖记录表
* @TableName device_bg_record
*/
@Data
public class DeviceBgRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 血糖值单位mmol/L
*/
private BigDecimal bg;
/**
* 时间段1凌晨2早餐前3早晨后4午餐前5午餐后6晚餐前7晚餐后8睡前
*/
private String bucket;
/**
* 测量时间
*/
private Date measureTime;
/**
* 上传方式1手动2自动
*/
private String uploadType;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,69 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 居民设备绑定记录表
* @TableName device_bind_resident
*/
@ApiModel("居民设备绑定记录表")
@Data
public class DeviceBindResident implements Serializable {
/**
* 主键
*/
@ApiModelProperty("主键")
private Long id;
/**
* 身份证号
*/
@ApiModelProperty("身份证号")
private String identity;
/**
* 设备SN码
*/
@ApiModelProperty("设备SN码")
private String sn;
/**
* 设备类型(0 其他 1血压计 2血糖仪 3血脂仪 4血氧仪 5体重秤 6体温计)
*/
@ApiModelProperty("设备类型(0 其他 1血压计 2血糖仪 3血脂仪 4血氧仪 5体重秤 6体温计)")
private String deviceType;
/**
* 状态0解绑 1绑定
*/
@ApiModelProperty("状态0解绑 1绑定")
private String state;
/**
* 备注
*/
@ApiModelProperty("备注")
private String remark;
/**
* 绑定时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("绑定时间")
private Date bindTime;
/**
* 解绑时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty("解绑时间")
private Date unbindTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,35 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* BMI记录表
* @TableName device_bmi_record
*/
@Data
public class DeviceBmiRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* BMI单位kg/m^2
*/
private BigDecimal bmi;
/**
* 测量时间
*/
private Date measureTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,39 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 血氧记录表
* @TableName device_bo_record
*/
@Data
public class DeviceBoRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 血氧单位%
*/
private Integer spo2;
/**
* 脉搏单位/
*/
private Integer pulse;
/**
* 测量时间
*/
private Date measureTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,49 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 血压记录表
* @TableName device_bp_record
*/
@Data
public class DeviceBpRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 收缩压单位mmHg
*/
private Integer sbp;
/**
* 舒张压单位mmHg
*/
private Integer dbp;
/**
* 心率单位/
*/
private Integer hr;
/**
* 测量时间
*/
private Date measureTime;
/**
* 上传方式1手动2自动
*/
private String uploadType;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,39 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 心率记录表
* @TableName device_hr_record
*/
@Data
public class DeviceHrRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 心率单位/
*/
private Integer hr;
/**
* 测量时间
*/
private Date measureTime;
/**
* 上传方式1手动2自动
*/
private String uploadType;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,35 @@
package com.xinelu.familydoctor.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 体温记录表
* @TableName device_temp_record
*/
@Data
public class DeviceTempRecord implements Serializable {
/**
* 自增主键
*/
private Long id;
/**
* 居民身份证号
*/
private String identity;
/**
* 体温单位
*/
private BigDecimal temp;
/**
* 测量时间
*/
private Date measureTime;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,30 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBfRecord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bf_record(血脂记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:04:52
* @Entity com.xinelu.familydoctor.entity.DeviceBfRecord
*/
public interface DeviceBfRecordMapper {
/**
* 获取血脂记录
* @param identity 身份证号
* @param type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBfRecord>}
* @author gaoyu
* @date 2023-9-27 16:17
*/
List<DeviceBfRecord> getBfRecord(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceBfRecord record);
int update(DeviceBfRecord record);
}

View File

@ -0,0 +1,41 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBgRecord;
import com.xinelu.familydoctor.vo.BgCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bg_record(血糖记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:00
* @Entity com.xinelu.familydoctor.entity.DeviceBgRecord
*/
public interface DeviceBgRecordMapper {
/**
* 获取血糖记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBgRecord>}
* @author gaoyu
* @date 2023-9-27 16:24
*/
List<DeviceBgRecord> getBgRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取血糖计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.BgCalcVO}
* @author gaoyu
* @date 2023-9-28 9:10
*/
BgCalcVO getBgCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceBgRecord record);
int update(DeviceBgRecord record);
}

View File

@ -0,0 +1,38 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBindResident;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bind_resident(居民设备绑定记录表)的数据库操作Mapper
* @createDate 2023-09-25 16:01:01
* @Entity com.xinelu.familydoctor.entity.DeviceBindResident
*/
public interface DeviceBindResidentMapper {
/**
* 已绑定设备
* @param identity 身份证号
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBindResident>}
* @author gaoyu
* @date 2023-9-26 9:58
*/
List<DeviceBindResident> boundDevice(@Param("identity") String identity);
/**
* 设备是否多次绑定
* @param record 参数
* @return {@link java.lang.Integer}
* @author gaoyu
* @date 2023-9-25 17:16
*/
Integer repeatBind(DeviceBindResident record);
int insert(DeviceBindResident record);
int update(DeviceBindResident record);
}

View File

@ -0,0 +1,41 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBmiRecord;
import com.xinelu.familydoctor.vo.BmiCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bmi_record(BMI记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:05
* @Entity com.xinelu.familydoctor.entity.DeviceBmiRecord
*/
public interface DeviceBmiRecordMapper {
/**
* 获取bmi记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBmiRecord>}
* @author gaoyu
* @date 2023-10-8 9:21
*/
List<DeviceBmiRecord> getBmiRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取bmi计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.BmiCalcVO}
* @author gaoyu
* @date 2023-10-8 9:22
*/
BmiCalcVO getBmiCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceBmiRecord record);
int update(DeviceBmiRecord record);
}

View File

@ -0,0 +1,43 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBmiRecord;
import com.xinelu.familydoctor.entity.DeviceBoRecord;
import com.xinelu.familydoctor.vo.BmiCalcVO;
import com.xinelu.familydoctor.vo.BoCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bo_record(血氧记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:09
* @Entity com.xinelu.familydoctor.entity.DeviceBoRecord
*/
public interface DeviceBoRecordMapper {
/**
* 获取血氧记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBoRecord>}
* @author gaoyu
* @date 2023-10-8 9:21
*/
List<DeviceBoRecord> getBoRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取血氧计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.BoCalcVO}
* @author gaoyu
* @date 2023-10-8 9:22
*/
BoCalcVO getBoCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceBoRecord record);
int update(DeviceBoRecord record);
}

View File

@ -0,0 +1,41 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBpRecord;
import com.xinelu.familydoctor.vo.BpCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bp_record(血压记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:12
* @Entity com.xinelu.familydoctor.entity.DeviceBpRecord
*/
public interface DeviceBpRecordMapper {
/**
* 获取血压记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBpRecord>}
* @author gaoyu
* @date 2023-10-8 14:33
*/
List<DeviceBpRecord> getBpRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取血压计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.BpCalcVO}
* @author gaoyu
* @date 2023-10-8 14:34
*/
BpCalcVO getBpCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceBpRecord record);
int update(DeviceBpRecord record);
}

View File

@ -0,0 +1,41 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceHrRecord;
import com.xinelu.familydoctor.vo.HrCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_hr_record(心率记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:16
* @Entity com.xinelu.familydoctor.entity.DeviceHrRecord
*/
public interface DeviceHrRecordMapper {
/**
* 获取心率记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceHrRecord>}
* @author gaoyu
* @date 2023-10-8 14:48
*/
List<DeviceHrRecord> getHrRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取心率计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.HrCalcVO}
* @author gaoyu
* @date 2023-10-8 14:49
*/
HrCalcVO getHrCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceHrRecord record);
int update(DeviceHrRecord record);
}

View File

@ -0,0 +1,43 @@
package com.xinelu.familydoctor.mapper;
import com.xinelu.familydoctor.entity.DeviceBoRecord;
import com.xinelu.familydoctor.entity.DeviceTempRecord;
import com.xinelu.familydoctor.vo.BoCalcVO;
import com.xinelu.familydoctor.vo.TempCalcVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_temp_record(体温记录表)的数据库操作Mapper
* @createDate 2023-09-26 15:05:19
* @Entity com.xinelu.familydoctor.entity.DeviceTempRecord
*/
public interface DeviceTempRecordMapper {
/**
* 获取体温记录
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceTempRecord>}
* @author gaoyu
* @date 2023-10-8 9:21
*/
List<DeviceTempRecord> getTempRecord(@Param("identity") String identity, @Param("type") String type);
/**
* 获取体温计算值
* @param identity 身份证号
* @param type type 类型0全部1周2月3
* @return {@link com.xinelu.familydoctor.vo.TempCalcVO}
* @author gaoyu
* @date 2023-10-8 9:22
*/
TempCalcVO getTempCalc(@Param("identity") String identity, @Param("type") String type);
int insert(DeviceTempRecord record);
int update(DeviceTempRecord record);
}

View File

@ -0,0 +1,48 @@
package com.xinelu.familydoctor.service;
import com.xinelu.familydoctor.entity.DeviceBindResident;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bind_resident(居民设备绑定记录表)的数据库操作Service
* @createDate 2023-09-25 16:00:00
*/
public interface DeviceBindResidentService {
/**
* 已绑定设备
* @param identity 身份证号
* @return {@link java.util.List<com.xinelu.familydoctor.entity.DeviceBindResident>}
* @author gaoyu
* @date 2023-9-26 9:58
*/
List<DeviceBindResident> boundDevice(@Param("identity") String identity);
/**
* 设备是否重复绑定
* @param record 参数
* @return {@link boolean}
* @author gaoyu
* @date 2023-9-25 17:17
*/
boolean repeatBind(DeviceBindResident record);
/**
* 绑定设备
* @param entity 参数
* @return {@link int}
* @author gaoyu
* @date 2023-9-25 16:49
*/
int bindDevice(DeviceBindResident entity);
/**
* 解绑设备
* @param entity 参数
* @return {@link int}
* @author gaoyu
* @date 2023-9-26 10:14
*/
int unbindDevice(DeviceBindResident entity);
}

View File

@ -0,0 +1,25 @@
package com.xinelu.familydoctor.service;
import com.xinelu.familydoctor.entity.*;
import java.util.Map;
public interface PhysicalSignService {
void saveBg(DeviceBgRecord record);
void saveBp(DeviceBpRecord record);
void saveBf(DeviceBfRecord record);
void saveBmi(DeviceBmiRecord record);
void saveBo(DeviceBoRecord record);
void saveHr(DeviceHrRecord record);
void saveTemp(DeviceTempRecord record);
/**
* 获取体征记录
* @param identity 身份证号
* @param type 时间类型0全部1周2月3
* @param label 查询标识1血糖2血压3血脂4bmi5血氧6心率7体温
* @return {@link java.util.Map<java.lang.String,java.lang.Object>}
* @author gaoyu
* @date 2023-10-9 10:10
*/
Map<String, Object> record(String identity, String type, String label);
}

View File

@ -0,0 +1,45 @@
package com.xinelu.familydoctor.service.impl;
import com.xinelu.familydoctor.entity.DeviceBindResident;
import com.xinelu.familydoctor.service.DeviceBindResidentService;
import com.xinelu.familydoctor.mapper.DeviceBindResidentMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @author gaoyu
* @description 针对表device_bind_resident(居民设备绑定记录表)的数据库操作Service实现
* @createDate 2023-09-25 16:00:00
*/
@Service
public class DeviceBindResidentServiceImpl implements DeviceBindResidentService{
@Resource
private DeviceBindResidentMapper deviceBindResidentMapper;
@Override
public List<DeviceBindResident> boundDevice(String identity) {
return deviceBindResidentMapper.boundDevice(identity);
}
@Override
public boolean repeatBind(DeviceBindResident record) {
return deviceBindResidentMapper.repeatBind(record) != null;
}
@Override
public int bindDevice(DeviceBindResident entity) {
entity.setBindTime(new Date());
entity.setState("1");
return deviceBindResidentMapper.insert(entity);
}
@Override
public int unbindDevice(DeviceBindResident entity) {
entity.setUnbindTime(new Date());
entity.setState("0");
return deviceBindResidentMapper.update(entity);
}
}

View File

@ -0,0 +1,164 @@
package com.xinelu.familydoctor.service.impl;
import com.xinelu.familydoctor.entity.*;
import com.xinelu.familydoctor.mapper.*;
import com.xinelu.familydoctor.service.PhysicalSignService;
import com.xinelu.familydoctor.vo.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author gaoyu
* @description 体征检测业务实现类
* @date 2023-10-8 15:59
*/
@Service
public class PhysicalSignServiceImpl implements PhysicalSignService {
@Resource
private DeviceBfRecordMapper deviceBfRecordMapper;
@Resource
private DeviceBgRecordMapper deviceBgRecordMapper;
@Resource
private DeviceBmiRecordMapper deviceBmiRecordMapper;
@Resource
private DeviceBoRecordMapper deviceBoRecordMapper;
@Resource
private DeviceBpRecordMapper deviceBpRecordMapper;
@Resource
private DeviceHrRecordMapper deviceHrRecordMapper;
@Resource
private DeviceTempRecordMapper deviceTempRecordMapper;
@Override
public void saveBg(DeviceBgRecord record) {
deviceBgRecordMapper.insert(record);
}
@Override
public void saveBp(DeviceBpRecord record) {
deviceBpRecordMapper.insert(record);
}
@Override
public void saveBf(DeviceBfRecord record) {
deviceBfRecordMapper.insert(record);
}
@Override
public void saveBmi(DeviceBmiRecord record) {
deviceBmiRecordMapper.insert(record);
}
@Override
public void saveBo(DeviceBoRecord record) {
deviceBoRecordMapper.insert(record);
}
@Override
public void saveHr(DeviceHrRecord record) {
deviceHrRecordMapper.insert(record);
}
@Override
public void saveTemp(DeviceTempRecord record) {
deviceTempRecordMapper.insert(record);
}
@Override
public Map<String, Object> record(String identity, String type, String label) {
Map<String, Object> map = new HashMap<>();
switch (label) {
case "1":
map = bgRecord(identity, type);
break;
case "2":
map = bpRecord(identity, type);
break;
case "3":
map = bfRecord(identity, type);
break;
case "4":
map = bmiRecord(identity, type);
break;
case "5":
map = boRecord(identity, type);
break;
case "6":
map = hrRecord(identity, type);
break;
case "7":
map = tempRecord(identity, type);
break;
default:
break;
}
return map;
}
private Map<String, Object> bgRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBgRecord> list = deviceBgRecordMapper.getBgRecord(identity, type);
BgCalcVO calc = deviceBgRecordMapper.getBgCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
private Map<String, Object> bpRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBpRecord> list = deviceBpRecordMapper.getBpRecord(identity, type);
BpCalcVO calc = deviceBpRecordMapper.getBpCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
private Map<String, Object> bfRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBfRecord> list = deviceBfRecordMapper.getBfRecord(identity, type);
// BfCalcVO calc = deviceBfRecordMapper.getBfCalc(identity, type);
map.put("list", list);
// map.put("calc", calc);
return map;
}
private Map<String, Object> bmiRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBmiRecord> list = deviceBmiRecordMapper.getBmiRecord(identity, type);
BmiCalcVO calc = deviceBmiRecordMapper.getBmiCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
private Map<String, Object> boRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceBoRecord> list = deviceBoRecordMapper.getBoRecord(identity, type);
BoCalcVO calc = deviceBoRecordMapper.getBoCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
private Map<String, Object> hrRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceHrRecord> list = deviceHrRecordMapper.getHrRecord(identity, type);
HrCalcVO calc = deviceHrRecordMapper.getHrCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
private Map<String, Object> tempRecord(String identity, String type) {
Map<String, Object> map = new HashMap<>();
List<DeviceTempRecord> list = deviceTempRecordMapper.getTempRecord(identity, type);
TempCalcVO calc = deviceTempRecordMapper.getTempCalc(identity, type);
map.put("list", list);
map.put("calc", calc);
return map;
}
}

View File

@ -0,0 +1,27 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author gaoyu
* @description 血糖计算视图
* @date 2023-9-27 16:28
*/
@Data
@ApiModel("血糖计算视图")
public class BgCalcVO {
@ApiModelProperty("最大值")
private BigDecimal maxVal;
@ApiModelProperty("最小值")
private BigDecimal minVal;
@ApiModelProperty("偏低次数")
private Integer lowerNum;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("偏高次数")
private Integer higherNum;
}

View File

@ -0,0 +1,27 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author gaoyu
* @description BMI计算视图
* @date 2023-10-8 9:00
*/
@ApiModel("BMI计算视图")
@Data
public class BmiCalcVO {
@ApiModelProperty("最大值")
private BigDecimal maxVal;
@ApiModelProperty("最小值")
private BigDecimal minVal;
@ApiModelProperty("平均值")
private BigDecimal avgVal;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("超标次数")
private Integer overNum;
}

View File

@ -0,0 +1,27 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author gaoyu
* @description 血氧计算视图
* @date 2023-10-8 9:25
*/
@ApiModel("血氧计算视图")
@Data
public class BoCalcVO {
@ApiModelProperty("最大值")
private BigDecimal maxVal;
@ApiModelProperty("最小值")
private BigDecimal minVal;
@ApiModelProperty("平均值")
private BigDecimal avgVal;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("超标次数")
private Integer overNum;
}

View File

@ -0,0 +1,29 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author gaoyu
* @description 血压计算视图
* @date 2023-10-8 9:42
*/
@ApiModel("血压计算视图")
@Data
public class BpCalcVO {
@ApiModelProperty("收缩压最大值")
private String maxSbpVal;
@ApiModelProperty("舒张压最大值")
private String maxDbpVal;
@ApiModelProperty("收缩压最小值")
private String minSbpVal;
@ApiModelProperty("舒张压最小值")
private String minDbpVal;
@ApiModelProperty("平均值")
private String avgVal;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("超标次数")
private Integer overNum;
}

View File

@ -0,0 +1,25 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author gaoyu
* @description 心率计算视图
* @date 2023-10-8 14:37
*/
@ApiModel("心率计算视图")
@Data
public class HrCalcVO {
@ApiModelProperty("最大值")
private Integer maxVal;
@ApiModelProperty("最小值")
private Integer minVal;
@ApiModelProperty("平均值")
private Integer avgVal;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("超标次数")
private Integer overNum;
}

View File

@ -0,0 +1,27 @@
package com.xinelu.familydoctor.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author gaoyu
* @description 体温计算视图
* @date 2023-10-8 15:05
*/
@ApiModel("体温计算视图")
@Data
public class TempCalcVO {
@ApiModelProperty("最大值")
private BigDecimal maxVal;
@ApiModelProperty("最小值")
private BigDecimal minVal;
@ApiModelProperty("平均值")
private BigDecimal avgVal;
@ApiModelProperty("正常次数")
private Integer normalNum;
@ApiModelProperty("超标次数")
private Integer overNum;
}

View File

@ -0,0 +1,85 @@
<?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.xinelu.familydoctor.mapper.DeviceBfRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBfRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="tc" column="tc" jdbcType="DECIMAL"/>
<result property="tg" column="tg" jdbcType="DECIMAL"/>
<result property="hdl" column="hdl" jdbcType="DECIMAL"/>
<result property="ldl" column="ldl" jdbcType="DECIMAL"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,tc,
tg,hdl,ldl,
measure_time
</sql>
<select id="getBfRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_bf_record
where identity = #{identity,jdbcType=VARCHAR}
<choose>
<!-- 全部 -->
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBfRecord" useGeneratedKeys="true">
insert into device_bf_record
(identity,tc
,tg,hdl,ldl
,measure_time)
values (#{identity,jdbcType=VARCHAR},#{tc,jdbcType=DECIMAL}
,#{tg,jdbcType=DECIMAL},#{hdl,jdbcType=DECIMAL},#{ldl,jdbcType=DECIMAL}
,#{measureTime,jdbcType=TIMESTAMP})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBfRecord">
update device_bf_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="tc != null">
tc = #{tc,jdbcType=DECIMAL},
</if>
<if test="tg != null">
tg = #{tg,jdbcType=DECIMAL},
</if>
<if test="hdl != null">
hdl = #{hdl,jdbcType=DECIMAL},
</if>
<if test="ldl != null">
ldl = #{ldl,jdbcType=DECIMAL},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,108 @@
<?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.xinelu.familydoctor.mapper.DeviceBgRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBgRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="bg" column="bg" jdbcType="DECIMAL"/>
<result property="bucket" column="bucket" jdbcType="VARCHAR"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
<result property="uploadType" column="upload_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,bg,
bucket,measure_time,upload_type
</sql>
<select id="getBgRecord" resultMap="BaseResultMap">
select <include refid="Base_Column_List" />
from device_bg_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<select id="getBgCalc" resultType="com.xinelu.familydoctor.vo.BgCalcVO">
select IFNULL(max(bg),0) "maxVal",
IFNULL(min(bg),0) "minVal",
count(case when bg &lt; 4.4 then 1 else null end) "lowerNum",
count(case when (bucket = '2' and (bg &gt;= 4.4 or bg &lt;= 7.0)) or (bucket != '2' and (bg &gt;= 4.4 or bg &lt;= 10)) then 1 else null end) "normalNum",
count(case when (bucket = '2' and bg &gt; 7.0) or (bucket != '2' and bg &gt; 10) then 1 else null end) "higherNum"
from device_bg_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBgRecord" useGeneratedKeys="true">
insert into device_bg_record
(identity,bg
,bucket,measure_time,upload_type
)
values (#{identity,jdbcType=VARCHAR},#{bg,jdbcType=DECIMAL}
,#{bucket,jdbcType=VARCHAR},#{measureTime,jdbcType=TIMESTAMP},#{uploadType,jdbcType=VARCHAR}
)
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBgRecord">
update device_bg_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="bg != null">
bg = #{bg,jdbcType=DECIMAL},
</if>
<if test="bucket != null">
bucket = #{bucket,jdbcType=VARCHAR},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
<if test="uploadType != null">
upload_type = #{uploadType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,71 @@
<?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.xinelu.familydoctor.mapper.DeviceBindResidentMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBindResident">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/>
<result property="state" column="state" jdbcType="CHAR"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="bindTime" column="bind_time" jdbcType="TIMESTAMP"/>
<result property="unbindTime" column="unbind_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,sn,
device_type,state,remark,
bind_time,unbind_time
</sql>
<select id="boundDevice" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from device_bind_resident
where identity = #{identity} and state = '1'
</select>
<select id="repeatBind" resultType="java.lang.Integer">
select 1 from device_bind_resident where sn = #{sn} and state = '1'
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBindResident" useGeneratedKeys="true">
insert into device_bind_resident
(identity,sn
,device_type,state,remark
,bind_time,unbind_time)
values (#{identity,jdbcType=VARCHAR},#{sn,jdbcType=VARCHAR}
,#{deviceType,jdbcType=VARCHAR},#{state,jdbcType=CHAR},#{remark,jdbcType=VARCHAR}
,#{bindTime,jdbcType=TIMESTAMP},#{unbindTime,jdbcType=TIMESTAMP})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBindResident">
update device_bind_resident
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="sn != null">
sn = #{sn,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=CHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="bindTime != null">
bind_time = #{bindTime,jdbcType=TIMESTAMP},
</if>
<if test="unbindTime != null">
unbind_time = #{unbindTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,99 @@
<?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.xinelu.familydoctor.mapper.DeviceBmiRecordMapper">
<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="bmi" column="bmi" jdbcType="DECIMAL"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,bmi,
measure_time
</sql>
<select id="getBmiRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_bmi_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<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"
from device_bmi_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</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})
</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>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,103 @@
<?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.xinelu.familydoctor.mapper.DeviceBoRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBoRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="spo2" column="spo2" jdbcType="INTEGER"/>
<result property="pulse" column="pulse" jdbcType="INTEGER"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,spo2,
pulse,measure_time
</sql>
<select id="getBoRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_bo_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<select id="getBoCalc" resultType="com.xinelu.familydoctor.vo.BoCalcVO">
select ifnull(max(spo2), 0) "maxVal",
ifnull(min(spo2), 0) "minVal",
ifnull(avg(spo2), 0) "avgVal",
count(case when spo2 &gt;= 95 then 1 else null end) "normalNum",
count(case when spo2 &lt; 95 then 1 else null end) "overNum"
from device_bo_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBoRecord" useGeneratedKeys="true">
insert into device_bo_record
(identity,spo2
,pulse,measure_time)
values (#{identity,jdbcType=VARCHAR},#{spo2,jdbcType=INTEGER}
,#{pulse,jdbcType=INTEGER},#{measureTime,jdbcType=TIMESTAMP})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBoRecord">
update device_bo_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="spo2 != null">
spo2 = #{spo2,jdbcType=INTEGER},
</if>
<if test="pulse != null">
pulse = #{pulse,jdbcType=INTEGER},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,313 @@
<?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.xinelu.familydoctor.mapper.DeviceBpRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceBpRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="sbp" column="sbp" jdbcType="INTEGER"/>
<result property="dbp" column="dbp" jdbcType="INTEGER"/>
<result property="hr" column="hr" jdbcType="INTEGER"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
<result property="uploadType" column="upload_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,sbp,
dbp,hr,measure_time,
upload_type
</sql>
<select id="getBpRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_bp_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<sql id="maxSbpSql">
select concat(sbp, '/', dbp) "maxSbpVal" from device_bp_record
where sbp = (select max(sbp) from device_bp_record
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>)
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by id desc limit 1
</sql>
<sql id="maxDbpSql">
select concat(sbp, '/', dbp) "maxDbpVal" from device_bp_record
where dbp = (select max(dbp) from device_bp_record
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>)
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by id desc limit 1
</sql>
<sql id="minSbpSql">
select concat(sbp, '/', dbp) "minSbpVal" from device_bp_record
where sbp = (select min(sbp) from device_bp_record
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>)
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by id desc limit 1
</sql>
<sql id="minDbpSql">
select concat(sbp, '/', dbp) "minDbpVal" from device_bp_record
where dbp = (select min(dbp) from device_bp_record
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>)
and identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by id desc limit 1
</sql>
<sql id="avgSql">
select concat(cast(avg(sbp) as signed), '/', cast(avg(dbp) as signed)) "avgVal",
count(case when sbp &gt;= 90 and sbp &lt;= 140 and dbp &gt;= 60 and dbp &lt;= 90 then 1 else null end) "normalNum",
count(case when sbp &lt; 90 or sbp &gt; 140 or dbp &lt; 60 or dbp &gt; 90 then 1 else null end) "overNum"
from device_bp_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
</sql>
<select id="getBpCalc" resultType="com.xinelu.familydoctor.vo.BpCalcVO">
select * from
(<include refid="maxSbpSql" />) a,
(<include refid="maxDbpSql" />) b,
(<include refid="minSbpSql" />) c,
(<include refid="minDbpSql" />) d,
(<include refid="avgSql" />) e
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceBpRecord" useGeneratedKeys="true">
insert into device_bp_record
(identity,sbp
,dbp,hr,measure_time
,upload_type)
values (#{identity,jdbcType=VARCHAR},#{sbp,jdbcType=INTEGER}
,#{dbp,jdbcType=INTEGER},#{hr,jdbcType=INTEGER},#{measureTime,jdbcType=TIMESTAMP}
,#{uploadType,jdbcType=VARCHAR})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceBpRecord">
update device_bp_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="sbp != null">
sbp = #{sbp,jdbcType=INTEGER},
</if>
<if test="dbp != null">
dbp = #{dbp,jdbcType=INTEGER},
</if>
<if test="hr != null">
hr = #{hr,jdbcType=INTEGER},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
<if test="uploadType != null">
upload_type = #{uploadType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,103 @@
<?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.xinelu.familydoctor.mapper.DeviceHrRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceHrRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="hr" column="hr" jdbcType="INTEGER"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
<result property="uploadType" column="upload_type" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,hr,
measure_time,upload_type
</sql>
<select id="getHrRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_hr_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<select id="getHrCalc" resultType="com.xinelu.familydoctor.vo.HrCalcVO">
select ifnull(max(hr), 0) "maxVal",
ifnull(min(hr), 0) "minVal",
ifnull(avg(hr), 0) "avgVal",
count(case when hr &gt;= 60 and hr &lt;= 100 then 1 else null end) "normalNum",
count(case when hr &lt; 60 or hr &gt; 100 then 1 else null end) "overNum"
from device_hr_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceHrRecord" useGeneratedKeys="true">
insert into device_hr_record
(identity,hr
,measure_time,upload_type)
values (#{identity,jdbcType=VARCHAR},#{hr,jdbcType=INTEGER}
,#{measureTime,jdbcType=TIMESTAMP},#{uploadType,jdbcType=VARCHAR})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceHrRecord">
update device_hr_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="hr != null">
hr = #{hr,jdbcType=INTEGER},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
<if test="uploadType != null">
upload_type = #{uploadType,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@ -0,0 +1,99 @@
<?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.xinelu.familydoctor.mapper.DeviceTempRecordMapper">
<resultMap id="BaseResultMap" type="com.xinelu.familydoctor.entity.DeviceTempRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="identity" column="identity" jdbcType="VARCHAR"/>
<result property="temp" column="temp" jdbcType="DECIMAL"/>
<result property="measureTime" column="measure_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,identity,temp,
measure_time
</sql>
<select id="getTempRecord" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from device_temp_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
order by measure_time
</select>
<select id="getTempCalc" resultType="com.xinelu.familydoctor.vo.TempCalcVO">
select ifnull(max(temp), 0) "maxVal",
ifnull(min(temp), 0) "minVal",
ifnull(avg(temp), 0) "avgVal",
count(case when temp &gt;= 36 and temp &lt;= 37 then 1 else null end) "normalNum",
count(case when temp &lt; 36 or temp &gt; 37 then 1 else null end) "overNum"
from device_temp_record
where identity = #{identity}
<choose>
<when test="type == '0'">
</when>
<!-- 按周统计 -->
<when test="type == '1'">
and measure_time between date_add(now(), interval -7 day) and now()
</when>
<!-- 按月统计 -->
<when test="type == '2'">
and measure_time between date_add(now(), interval -1 month) and now()
</when>
<!-- 按年统计 -->
<when test="type == '3'">
and measure_time between date_add(now(), interval -1 year) and now()
</when>
<otherwise>
</otherwise>
</choose>
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.xinelu.familydoctor.entity.DeviceTempRecord" useGeneratedKeys="true">
insert into device_temp_record
(identity,temp
,measure_time)
values (#{identity,jdbcType=VARCHAR},#{temp,jdbcType=DECIMAL}
,#{measureTime,jdbcType=TIMESTAMP})
</insert>
<update id="update" parameterType="com.xinelu.familydoctor.entity.DeviceTempRecord">
update device_temp_record
<set>
<if test="identity != null">
identity = #{identity,jdbcType=VARCHAR},
</if>
<if test="temp != null">
temp = #{temp,jdbcType=DECIMAL},
</if>
<if test="measureTime != null">
measure_time = #{measureTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>