新增动态血氧界面的相关功能

This commit is contained in:
lxd 2025-07-24 14:20:10 +08:00
parent 7a52dad703
commit 9fcdbe06c9
15 changed files with 708 additions and 8 deletions

View File

@ -0,0 +1,104 @@
package cn.iocoder.yudao.module.system.controller.admin.spo2data;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.system.controller.admin.spo2data.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.spo2data.Spo2dataDO;
import cn.iocoder.yudao.module.system.service.spo2data.Spo2dataService;
@Tag(name = "管理后台 - 血氧数据")
@RestController
@RequestMapping("/system/spo2data")
@Validated
public class Spo2dataController {
@Resource
private Spo2dataService spo2dataService;
@PostMapping("/create")
@Operation(summary = "创建血氧数据")
@PreAuthorize("@ss.hasPermission('system:spo2data:create')")
public CommonResult<Integer> createSpo2data(@Valid @RequestBody Spo2dataSaveReqVO createReqVO) {
return success(spo2dataService.createSpo2data(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新血氧数据")
@PreAuthorize("@ss.hasPermission('system:spo2data:update')")
public CommonResult<Boolean> updateSpo2data(@Valid @RequestBody Spo2dataSaveReqVO updateReqVO) {
spo2dataService.updateSpo2data(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除血氧数据")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('system:spo2data:delete')")
public CommonResult<Boolean> deleteSpo2data(@RequestParam("id") Integer id) {
spo2dataService.deleteSpo2data(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除血氧数据")
@PreAuthorize("@ss.hasPermission('system:spo2data:delete')")
public CommonResult<Boolean> deleteSpo2dataList(@RequestParam("ids") List<Integer> ids) {
spo2dataService.deleteSpo2dataListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得血氧数据")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:spo2data:query')")
public CommonResult<Spo2dataRespVO> getSpo2data(@RequestParam("id") Integer id) {
Spo2dataDO spo2data = spo2dataService.getSpo2data(id);
return success(BeanUtils.toBean(spo2data, Spo2dataRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得血氧数据分页")
@PreAuthorize("@ss.hasPermission('system:spo2data:query')")
public CommonResult<PageResult<Spo2dataRespVO>> getSpo2dataPage(@Valid Spo2dataPageReqVO pageReqVO) {
PageResult<Spo2dataDO> pageResult = spo2dataService.getSpo2dataPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, Spo2dataRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出血氧数据 Excel")
@PreAuthorize("@ss.hasPermission('system:spo2data:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportSpo2dataExcel(@Valid Spo2dataPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<Spo2dataDO> list = spo2dataService.getSpo2dataPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "血氧数据.xls", "数据", Spo2dataRespVO.class,
BeanUtils.toBean(list, Spo2dataRespVO.class));
}
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.system.controller.admin.spo2data.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 血氧数据分页 Request VO")
@Data
public class Spo2dataPageReqVO extends PageParam {
@Schema(description = "注册ID", example = "17977")
private String regid;
@Schema(description = "检查ID", example = "10739")
private String examid;
@Schema(description = "血氧饱和度(%)")
private BigDecimal spo2value;
@Schema(description = "佩戴时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] weartime;
@Schema(description = "测量时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] measuretime;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createtime;
@Schema(description = "更新时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] updatetime;
@Schema(description = "脉率(bpm)")
private String pulsevalue;
}

View File

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.system.controller.admin.spo2data.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 血氧数据 Response VO")
@Data
@ExcelIgnoreUnannotated
public class Spo2dataRespVO {
@Schema(description = "主键ID自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "14896")
@ExcelProperty("主键ID自增")
private Integer id;
@Schema(description = "注册ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17977")
@ExcelProperty("注册ID")
private String regid;
@Schema(description = "检查ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10739")
@ExcelProperty("检查ID")
private String examid;
@Schema(description = "血氧饱和度(%)")
@ExcelProperty("血氧饱和度(%)")
private BigDecimal spo2value;
@Schema(description = "佩戴时间")
@ExcelProperty("佩戴时间")
private LocalDateTime weartime;
@Schema(description = "测量时间")
@ExcelProperty("测量时间")
private LocalDateTime measuretime;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createtime;
@Schema(description = "更新时间")
@ExcelProperty("更新时间")
private LocalDateTime updatetime;
@Schema(description = "脉率(bpm)")
@ExcelProperty("脉率(bpm)")
private String pulsevalue;
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.system.controller.admin.spo2data.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 血氧数据新增/修改 Request VO")
@Data
public class Spo2dataSaveReqVO {
@Schema(description = "主键ID自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "14896")
private Integer id;
@Schema(description = "注册ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17977")
@NotEmpty(message = "注册ID不能为空")
private String regid;
@Schema(description = "检查ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10739")
@NotEmpty(message = "检查ID不能为空")
private String examid;
@Schema(description = "血氧饱和度(%)")
private BigDecimal spo2value;
@Schema(description = "佩戴时间")
private LocalDateTime weartime;
@Schema(description = "测量时间")
private LocalDateTime measuretime;
@Schema(description = "创建时间")
private LocalDateTime createtime;
@Schema(description = "更新时间")
private LocalDateTime updatetime;
@Schema(description = "脉率(bpm)")
private String pulsevalue;
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.spo2info;
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.ecgdataSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.ecgdata.vo.upecgdatawearstarttime;
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -14,6 +15,7 @@ import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.time.LocalDateTime;
import java.util.*;
import java.io.IOException;
@ -27,6 +29,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import cn.iocoder.yudao.module.system.controller.admin.spo2info.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.spo2info.Spo2infoDO;
@ -43,14 +46,12 @@ public class Spo2infoController {
@PostMapping("/create")
@Operation(summary = "创建血氧信息")
@PreAuthorize("@ss.hasPermission('system:spo2info:create')")
public CommonResult<Integer> createSpo2info(@Valid @RequestBody Spo2infoSaveReqVO createReqVO) {
return success(spo2infoService.createSpo2info(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新血氧信息")
@PreAuthorize("@ss.hasPermission('system:spo2info:update')")
public CommonResult<Boolean> updateSpo2info(@Valid @RequestBody Spo2infoSaveReqVO updateReqVO) {
spo2infoService.updateSpo2info(updateReqVO);
return success(true);
@ -88,6 +89,15 @@ public class Spo2infoController {
return success(true);
}
@GetMapping("/analysis")
@Operation(summary = "获得血氧分析结果")
public CommonResult<SpO2AnalysisResult> getSpO2Analysis(@RequestParam("regid") String regid,
@RequestParam("examid") String examid,
@RequestParam("weartime") @org.springframework.format.annotation.DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime weartime) {
SpO2AnalysisResult result = spo2infoService.getSpO2Analysis(regid, examid, weartime);
return success(result);
}
@PutMapping("/update-wearstarttime")
@Operation(summary = "更新佩戴时间")
public CommonResult<Boolean> updateecgdatawearstarttime(@Valid @RequestBody upecgdatawearstarttime updateReqVO) {
@ -99,7 +109,6 @@ public class Spo2infoController {
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除血氧信息")
@PreAuthorize("@ss.hasPermission('system:spo2info:delete')")
public CommonResult<Boolean> deleteSpo2infoList(@RequestParam("ids") List<Integer> ids) {
spo2infoService.deleteSpo2infoListByIds(ids);
return success(true);
@ -108,7 +117,6 @@ public class Spo2infoController {
@GetMapping("/get")
@Operation(summary = "获得血氧信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:spo2info:query')")
public CommonResult<Spo2infoRespVO> getSpo2info(@RequestParam("id") Integer id) {
Spo2infoDO spo2info = spo2infoService.getSpo2info(id);
return success(BeanUtils.toBean(spo2info, Spo2infoRespVO.class));
@ -116,7 +124,6 @@ public class Spo2infoController {
@GetMapping("/page")
@Operation(summary = "获得血氧信息分页")
@PreAuthorize("@ss.hasPermission('system:spo2info:query')")
public CommonResult<PageResult<Spo2infoRespVO>> getSpo2infoPage(@Valid Spo2infoPageReqVO pageReqVO) {
PageResult<Spo2infoDO> pageResult = spo2infoService.getSpo2infoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, Spo2infoRespVO.class));
@ -124,7 +131,6 @@ public class Spo2infoController {
@GetMapping("/export-excel")
@Operation(summary = "导出血氧信息 Excel")
@PreAuthorize("@ss.hasPermission('system:spo2info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportSpo2infoExcel(@Valid Spo2infoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {

View File

@ -0,0 +1,84 @@
package cn.iocoder.yudao.module.system.controller.admin.spo2info.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 血氧分析结果 VO
*
* @author 芋道源码
*/
@Schema(description = "管理后台 - 血氧分析结果 VO")
@Data
public class SpO2AnalysisResult {
@Schema(description = "平均血氧饱和度", example = "95.2")
private Double averageSpO2;
@Schema(description = "最低血氧饱和度", example = "88.5")
private Double minSpO2;
@Schema(description = "最高血氧饱和度", example = "98.7")
private Double maxSpO2;
@Schema(description = "低氧时间(分钟)", example = "45")
private Integer lowOxygenTime;
@Schema(description = "总记录数", example = "1440")
private Integer totalRecords;
@Schema(description = "优秀数量 (≥95%)", example = "800")
private Integer excellentCount;
@Schema(description = "良好数量 (90-94%)", example = "400")
private Integer goodCount;
@Schema(description = "偏低数量 (85-89%)", example = "180")
private Integer warningCount;
@Schema(description = "危险数量 (<85%)", example = "60")
private Integer dangerCount;
// 白天分布统计
@Schema(description = "白天优秀数量 (≥95%)", example = "600")
private Integer daytimeExcellentCount;
@Schema(description = "白天良好数量 (90-94%)", example = "300")
private Integer daytimeGoodCount;
@Schema(description = "白天偏低数量 (85-89%)", example = "120")
private Integer daytimeWarningCount;
@Schema(description = "白天危险数量 (<85%)", example = "40")
private Integer daytimeDangerCount;
// 夜间分布统计
@Schema(description = "夜间优秀数量 (≥95%)", example = "200")
private Integer nighttimeExcellentCount;
@Schema(description = "夜间良好数量 (90-94%)", example = "100")
private Integer nighttimeGoodCount;
@Schema(description = "夜间偏低数量 (85-89%)", example = "60")
private Integer nighttimeWarningCount;
@Schema(description = "夜间危险数量 (<85%)", example = "20")
private Integer nighttimeDangerCount;
// 计算百分比的方法
public Double getExcellentPercentage() {
return totalRecords > 0 ? (double) excellentCount / totalRecords * 100 : 0.0;
}
public Double getGoodPercentage() {
return totalRecords > 0 ? (double) goodCount / totalRecords * 100 : 0.0;
}
public Double getWarningPercentage() {
return totalRecords > 0 ? (double) warningCount / totalRecords * 100 : 0.0;
}
public Double getDangerPercentage() {
return totalRecords > 0 ? (double) dangerCount / totalRecords * 100 : 0.0;
}
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.system.dal.dataobject.spo2data;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 血氧数据 DO
*
* @author 艾康菲
*/
@TableName("tb_spo2data")
@KeySequence("tb_spo2data_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Spo2dataDO {
/**
* 主键ID自增
*/
@TableId
private Integer id;
/**
* 注册ID
*/
@TableField("regid")
private String regid;
/**
* 检查ID
*/
@TableField("examid")
private String examid;
/**
* 血氧饱和度(%)
*/
@TableField("spo2value")
private BigDecimal spo2value;
/**
* 佩戴时间
*/
@TableField("weartime")
private LocalDateTime weartime;
/**
* 测量时间
*/
@TableField("measuretime")
private LocalDateTime measuretime;
/**
* 创建时间
*/
@TableField("createtime")
private LocalDateTime createtime;
/**
* 更新时间
*/
@TableField("updatetime")
private LocalDateTime updatetime;
/**
* 脉率(bpm)
*/
@TableField("pulsevalue")
private String pulsevalue;
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.system.dal.mysql.spo2data;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.spo2data.Spo2dataDO;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.spo2data.vo.*;
/**
* 血氧数据 Mapper
*
* @author 艾康菲
*/
@Mapper
@InterceptorIgnore(tenantLine = "true")
public interface Spo2dataMapper extends BaseMapperX<Spo2dataDO> {
default PageResult<Spo2dataDO> selectPage(Spo2dataPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<Spo2dataDO>()
.eqIfPresent(Spo2dataDO::getRegid, reqVO.getRegid())
.eqIfPresent(Spo2dataDO::getExamid, reqVO.getExamid())
.eqIfPresent(Spo2dataDO::getSpo2value, reqVO.getSpo2value())
.betweenIfPresent(Spo2dataDO::getWeartime, reqVO.getWeartime())
.betweenIfPresent(Spo2dataDO::getMeasuretime, reqVO.getMeasuretime())
.betweenIfPresent(Spo2dataDO::getCreatetime, reqVO.getCreatetime())
.betweenIfPresent(Spo2dataDO::getUpdatetime, reqVO.getUpdatetime())
.eqIfPresent(Spo2dataDO::getPulsevalue, reqVO.getPulsevalue())
.orderByDesc(Spo2dataDO::getId));
}
}

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.system.dal.mysql.spo2info;
import java.util.*;
import java.time.LocalDateTime;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.spo2info.Spo2infoDO;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.spo2info.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 血氧信息 Mapper
@ -38,4 +39,31 @@ public interface Spo2infoMapper extends BaseMapperX<Spo2infoDO> {
.orderByDesc(Spo2infoDO::getId));
}
/**
* 获取血氧分析统计结果
*
* @param regid 注册ID
* @param examid 检查ID
* @param weartime 佩戴时间
* @return 分析结果
*/
SpO2AnalysisResult getSpO2Analysis(@Param("regid") String regid,
@Param("examid") String examid,
@Param("weartime") LocalDateTime weartime);
/**
* 获取血氧数据总记录数
*
* @param regid 注册ID
* @param examid 检查ID
* @param weartime 佩戴时间
* @return 总记录数
*/
int getSpO2DataCount(@Param("regid") String regid,
@Param("examid") String examid,
@Param("weartime") LocalDateTime weartime);
}

View File

@ -0,0 +1,62 @@
package cn.iocoder.yudao.module.system.service.spo2data;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.spo2data.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.spo2data.Spo2dataDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 血氧数据 Service 接口
*
* @author 艾康菲
*/
public interface Spo2dataService {
/**
* 创建血氧数据
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createSpo2data(@Valid Spo2dataSaveReqVO createReqVO);
/**
* 更新血氧数据
*
* @param updateReqVO 更新信息
*/
void updateSpo2data(@Valid Spo2dataSaveReqVO updateReqVO);
/**
* 删除血氧数据
*
* @param id 编号
*/
void deleteSpo2data(Integer id);
/**
* 批量删除血氧数据
*
* @param ids 编号
*/
void deleteSpo2dataListByIds(List<Integer> ids);
/**
* 获得血氧数据
*
* @param id 编号
* @return 血氧数据
*/
Spo2dataDO getSpo2data(Integer id);
/**
* 获得血氧数据分页
*
* @param pageReqVO 分页查询
* @return 血氧数据分页
*/
PageResult<Spo2dataDO> getSpo2dataPage(Spo2dataPageReqVO pageReqVO);
}

View File

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.system.service.spo2data;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.spo2data.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.spo2data.Spo2dataDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.dal.mysql.spo2data.Spo2dataMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 血氧数据 Service 实现类
*
* @author 艾康菲
*/
@Service
@Validated
public class Spo2dataServiceImpl implements Spo2dataService {
@Resource
private Spo2dataMapper spo2dataMapper;
@Override
public Integer createSpo2data(Spo2dataSaveReqVO createReqVO) {
// 插入
Spo2dataDO spo2data = BeanUtils.toBean(createReqVO, Spo2dataDO.class);
spo2dataMapper.insert(spo2data);
// 返回
return spo2data.getId();
}
@Override
public void updateSpo2data(Spo2dataSaveReqVO updateReqVO) {
// 校验存在
validateSpo2dataExists(updateReqVO.getId());
// 更新
Spo2dataDO updateObj = BeanUtils.toBean(updateReqVO, Spo2dataDO.class);
spo2dataMapper.updateById(updateObj);
}
@Override
public void deleteSpo2data(Integer id) {
// 校验存在
validateSpo2dataExists(id);
// 删除
spo2dataMapper.deleteById(id);
}
@Override
public void deleteSpo2dataListByIds(List<Integer> ids) {
// 校验存在
validateSpo2dataExists(ids);
// 删除
spo2dataMapper.deleteByIds(ids);
}
private void validateSpo2dataExists(List<Integer> ids) {
List<Spo2dataDO> list = spo2dataMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
}
}
private void validateSpo2dataExists(Integer id) {
if (spo2dataMapper.selectById(id) == null) {
}
}
@Override
public Spo2dataDO getSpo2data(Integer id) {
return spo2dataMapper.selectById(id);
}
@Override
public PageResult<Spo2dataDO> getSpo2dataPage(Spo2dataPageReqVO pageReqVO) {
return spo2dataMapper.selectPage(pageReqVO);
}
}

View File

@ -79,5 +79,8 @@ public interface Spo2infoService {
* @return 血氧信息分页
*/
PageResult<Spo2infoDO> getSpo2infoPage(Spo2infoPageReqVO pageReqVO);
/*
* 查询分析统计信息
* */
SpO2AnalysisResult getSpO2Analysis(String regid, String examid, LocalDateTime weartime);
}

View File

@ -145,4 +145,10 @@ public class Spo2infoServiceImpl implements Spo2infoService {
return spo2infoMapper.selectPage(pageReqVO);
}
@Override
public SpO2AnalysisResult getSpO2Analysis(String regid, String examid, LocalDateTime weartime) {
return spo2infoMapper.getSpO2Analysis(regid, examid, weartime);
}
}

View File

@ -0,0 +1,12 @@
<?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="cn.iocoder.yudao.module.system.dal.mysql.spo2data.Spo2dataMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -8,5 +8,58 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<!-- 血氧分析统计查询 -->
<!-- 血氧分析统计查询 -->
<select id="getSpO2Analysis" resultType="cn.iocoder.yudao.module.system.controller.admin.spo2info.vo.SpO2AnalysisResult">
SELECT
-- 平均血氧饱和度
ROUND(AVG(CAST(spo2value AS DECIMAL(5,2))), 1) AS averageSpO2,
-- 最低血氧饱和度
ROUND(MIN(CAST(spo2value AS DECIMAL(5,2))), 1) AS minSpO2,
-- 最高血氧饱和度
ROUND(MAX(CAST(spo2value AS DECIMAL(5,2))), 1) AS maxSpO2,
-- 低氧时间血氧低于90%的记录数,按分钟计算)
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &lt; 90 THEN 1 END) AS lowOxygenTime,
-- 总记录数
COUNT(*) AS totalRecords,
-- 全天血氧分布统计
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 95 THEN 1 END) AS excellentCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 90 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 95 THEN 1 END) AS goodCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 85 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 90 THEN 1 END) AS warningCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &lt; 85 THEN 1 END) AS dangerCount,
-- 白天血氧分布统计8:00-22:00
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 95 AND HOUR(measuretime) &gt;= 8 AND HOUR(measuretime) &lt; 22 THEN 1 END) AS daytimeExcellentCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 90 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 95 AND HOUR(measuretime) &gt;= 8 AND HOUR(measuretime) &lt; 22 THEN 1 END) AS daytimeGoodCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 85 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 90 AND HOUR(measuretime) &gt;= 8 AND HOUR(measuretime) &lt; 22 THEN 1 END) AS daytimeWarningCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &lt; 85 AND HOUR(measuretime) &gt;= 8 AND HOUR(measuretime) &lt; 22 THEN 1 END) AS daytimeDangerCount,
-- 夜间血氧分布统计22:00-8:00
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 95 AND (HOUR(measuretime) &gt;= 22 OR HOUR(measuretime) &lt; 8) THEN 1 END) AS nighttimeExcellentCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 90 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 95 AND (HOUR(measuretime) &gt;= 22 OR HOUR(measuretime) &lt; 8) THEN 1 END) AS nighttimeGoodCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &gt;= 85 AND CAST(spo2value AS DECIMAL(5,2)) &lt; 90 AND (HOUR(measuretime) &gt;= 22 OR HOUR(measuretime) &lt; 8) THEN 1 END) AS nighttimeWarningCount,
COUNT(CASE WHEN CAST(spo2value AS DECIMAL(5,2)) &lt; 85 AND (HOUR(measuretime) &gt;= 22 OR HOUR(measuretime) &lt; 8) THEN 1 END) AS nighttimeDangerCount
FROM tb_spo2data
WHERE regid = #{regid}
AND examid = #{examid}
AND weartime = #{weartime}
AND spo2value IS NOT NULL
</select>
<!-- 获取血氧数据总记录数 -->
<select id="getSpO2DataCount" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM tb_spo2data
WHERE regid = #{regid}
AND examid = #{examid}
AND weartime = #{weartime}
AND spo2value IS NOT NULL
</select>
</mapper>