参考值

This commit is contained in:
Flow 2025-07-26 15:39:14 +08:00
parent 4c626969ea
commit 76f441dcab
20 changed files with 731 additions and 2 deletions

View File

@ -26,6 +26,7 @@ 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.pft.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.pft.PftDO;
import cn.iocoder.yudao.module.system.service.pft.PftService;
@ -94,4 +95,27 @@ public class PftController {
BeanUtils.toBean(list, PftRespVO.class));
}
@PostMapping("/insertPftPatientData")
@Operation(summary = "批量插入肺功能患者基础信息")
public CommonResult<Boolean> insertPftPatientData(@RequestBody List<patientinfoRespVO> patientInfoList) {
pftService.insertPftPatientData(patientInfoList);
return success(true);
}
@PutMapping("/updatePftAnalysis")
@Operation(summary = "根据examid更新肺功能分析结果")
@Parameter(name = "examid", description = "检查ID", required = true)
@Parameter(name = "analysisResult", description = "分析结果", required = true)
public CommonResult<Boolean> updatePftAnalysis(@RequestParam("examid") String examid,
@RequestParam("analysisResult") String analysisResult) {
return success(pftService.updatePftAnalysis(examid, analysisResult));
}
@GetMapping("/getPftAnalysis")
@Operation(summary = "根据examid查询肺功能分析结果")
@Parameter(name = "examid", description = "检查ID", required = true)
public CommonResult<String> getPftAnalysis(@RequestParam("examid") String examid) {
return success(pftService.getPftAnalysis(examid));
}
}

View File

@ -94,4 +94,21 @@ public class PftdataController {
BeanUtils.toBean(list, PftdataRespVO.class));
}
@GetMapping("/getByExamidAndRegid")
@Operation(summary = "根据检查ID和患者ID获取肺功能数据")
public CommonResult<PftdataRespVO> getPftdataByExamidAndRegid(@RequestParam("examid") String examid, @RequestParam("regid") String regid) {
PftdataDO pftdata = pftdataService.getPftdataByExamidAndRegid(examid, regid);
return success(BeanUtils.toBean(pftdata, PftdataRespVO.class));
}
@PutMapping("/saveDiagnosisByExamidAndRegid")
@Operation(summary = "根据examid和regid保存诊断结论")
public CommonResult<Boolean> savePftdataDiagnosis(@RequestBody Map<String, String> req) {
String examid = req.get("examid");
String regid = req.get("regid");
String diagnosis = req.get("diagnosis");
pftdataService.savePftdataDiagnosis(examid, regid, diagnosis);
return success(true);
}
}

View File

@ -0,0 +1,105 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds;
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.thresholds.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.thresholds.ThresholdsDO;
import cn.iocoder.yudao.module.system.service.thresholds.ThresholdsService;
@Tag(name = "管理后台 - 指标设置")
@RestController
@RequestMapping("/system/thresholds")
@Validated
public class ThresholdsController {
@Resource
private ThresholdsService thresholdsService;
@PostMapping("/create")
@Operation(summary = "创建指标设置")
public CommonResult<Integer> createThresholds(@Valid @RequestBody ThresholdsSaveReqVO createReqVO) {
return success(thresholdsService.createThresholds(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新指标设置")
public CommonResult<Boolean> updateThresholds(@Valid @RequestBody ThresholdsSaveReqVO updateReqVO) {
thresholdsService.updateThresholds(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除指标设置")
@Parameter(name = "id", description = "编号", required = true)
public CommonResult<Boolean> deleteThresholds(@RequestParam("id") Integer id) {
thresholdsService.deleteThresholds(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除指标设置")
public CommonResult<Boolean> deleteThresholdsList(@RequestParam("ids") List<Integer> ids) {
thresholdsService.deleteThresholdsListByIds(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得指标设置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<ThresholdsRespVO> getThresholds(@RequestParam("id") Integer id) {
ThresholdsDO thresholds = thresholdsService.getThresholds(id);
return success(BeanUtils.toBean(thresholds, ThresholdsRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得指标设置分页")
public CommonResult<PageResult<ThresholdsRespVO>> getThresholdsPage(@Valid ThresholdsPageReqVO pageReqVO) {
PageResult<ThresholdsDO> pageResult = thresholdsService.getThresholdsPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ThresholdsRespVO.class));
}
@GetMapping("/list-by-org")
@Operation(summary = "根据机构ID查询指标设置并按periodType分组")
@Parameter(name = "orgid", description = "机构ID", required = true, example = "1")
public CommonResult<List<ThresholdsGroupRespVO>> getThresholdsByOrgIdGroupByPeriodType(@RequestParam("orgid") Integer orgid) {
List<ThresholdsGroupRespVO> result = thresholdsService.getThresholdsByOrgIdGroupByPeriodType(orgid);
return success(result);
}
@GetMapping("/export-excel")
@Operation(summary = "导出指标设置 Excel")
@ApiAccessLog(operateType = EXPORT)
public void exportThresholdsExcel(@Valid ThresholdsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ThresholdsDO> list = thresholdsService.getThresholdsPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "指标设置.xls", "数据", ThresholdsRespVO.class,
BeanUtils.toBean(list, ThresholdsRespVO.class));
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@Schema(description = "管理后台 - 指标设置分组 Response VO")
@Data
public class ThresholdsGroupRespVO {
@Schema(description = "时段类型", example = "全天")
private String periodType;
@Schema(description = "该时段类型下的指标列表")
private List<ThresholdsItemRespVO> thresholdsList;
public ThresholdsGroupRespVO() {
}
public ThresholdsGroupRespVO(String periodType, List<ThresholdsItemRespVO> thresholdsList) {
this.periodType = periodType;
this.thresholdsList = thresholdsList;
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 指标设置项 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ThresholdsItemRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18680")
@ExcelProperty("主键")
private Integer id;
@Schema(description = "机构ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9106")
@ExcelProperty("机构ID")
private Integer orgid;
@Schema(description = "指标类型", example = "收缩压")
@ExcelProperty("指标类型")
private String metrictype;
@Schema(description = "最小值")
@ExcelProperty("最小值")
private Integer minValue;
@Schema(description = "最大值")
@ExcelProperty("最大值")
private Integer maxValue;
@Schema(description = "单位")
@ExcelProperty("单位")
private String unit;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 指标设置分页 Request VO")
@Data
public class ThresholdsPageReqVO extends PageParam {
@Schema(description = "机构ID", example = "9106")
private Integer orgid;
@Schema(description = "时段类型", example = "2")
private String periodtype;
@Schema(description = "指标类型", example = "1")
private String metrictype;
@Schema(description = "最小值")
private Integer minValue;
@Schema(description = "最大值")
private Integer maxValue;
@Schema(description = "单位")
private String unit;
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 指标设置 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ThresholdsRespVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18680")
@ExcelProperty("主键")
private Integer id;
@Schema(description = "机构ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9106")
@ExcelProperty("机构ID")
private Integer orgid;
@Schema(description = "时段类型", example = "2")
@ExcelProperty("时段类型")
private String periodtype;
@Schema(description = "指标类型", example = "1")
@ExcelProperty("指标类型")
private String metrictype;
@Schema(description = "最小值")
@ExcelProperty("最小值")
private Integer minValue;
@Schema(description = "最大值")
@ExcelProperty("最大值")
private Integer maxValue;
@Schema(description = "单位")
@ExcelProperty("单位")
private String unit;
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.system.controller.admin.thresholds.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 指标设置新增/修改 Request VO")
@Data
public class ThresholdsSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18680")
private Integer id;
@Schema(description = "机构ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9106")
@NotNull(message = "机构ID不能为空")
private Integer orgid;
@Schema(description = "时段类型", example = "2")
private String periodtype;
@Schema(description = "指标类型", example = "1")
private String metrictype;
@Schema(description = "最小值")
private Integer minValue;
@Schema(description = "最大值")
private Integer maxValue;
@Schema(description = "单位")
private String unit;
}

View File

@ -17,12 +17,11 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@TableName("tb_pftdata")
@KeySequence("tb_pftdata_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PftdataDO extends BaseDO {
public class PftdataDO{
/**
* 主键ID

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.system.dal.dataobject.thresholds;
import lombok.*;
import java.util.*;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 指标设置 DO
*
* @author 艾康菲
*/
@TableName("health_thresholds")
@KeySequence("health_thresholds_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ThresholdsDO {
/**
* 主键
*/
@TableId
private Integer id;
/**
* 机构ID
*/
@TableField("orgid")
private Integer orgid;
/**
* 时段类型
*/
@TableField("periodtype")
private String periodtype;
/**
* 指标类型
*/
@TableField("metrictype")
private String metrictype;
/**
* 最小值
*/
@TableField("min_value")
private Integer minValue;
/**
* 最大值
*/
@TableField("max_value")
private Integer maxValue;
/**
* 单位
*/
@TableField("unit")
private String unit;
}

View File

@ -8,6 +8,8 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.dal.dataobject.pft.PftDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.system.controller.admin.pft.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
/**
* 肺功能患者 Mapper
@ -37,4 +39,26 @@ public interface PftMapper extends BaseMapperX<PftDO> {
.orderByDesc(PftDO::getId));
}
/**
* 根据examid更新肺功能分析结果
*
* @param examid 检查ID
* @param analysisResult 分析结果
*/
@Update("UPDATE tb_pft SET analysisresult = #{analysisResult} WHERE examid = #{examid}")
void updateAnalysisByExamid(@Param("examid") String examid, @Param("analysisResult") String analysisResult);
/**
* 根据examid查询肺功能分析结果
*
* @param examid 检查ID
* @return 分析结果
*/
default String selectAnalysisByExamid(String examid) {
PftDO pft = selectOne(new LambdaQueryWrapperX<PftDO>()
.eq(PftDO::getExamid, examid)
.select(PftDO::getAnalysisresult));
return pft != null ? pft.getAnalysisresult() : null;
}
}

View File

@ -0,0 +1,44 @@
package cn.iocoder.yudao.module.system.dal.mysql.thresholds;
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.thresholds.ThresholdsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import cn.iocoder.yudao.module.system.controller.admin.thresholds.vo.*;
/**
* 指标设置 Mapper
*
* @author 艾康菲
*/
@Mapper
public interface ThresholdsMapper extends BaseMapperX<ThresholdsDO> {
default PageResult<ThresholdsDO> selectPage(ThresholdsPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<ThresholdsDO>()
.eqIfPresent(ThresholdsDO::getOrgid, reqVO.getOrgid())
.eqIfPresent(ThresholdsDO::getPeriodtype, reqVO.getPeriodtype())
.eqIfPresent(ThresholdsDO::getMetrictype, reqVO.getMetrictype())
.eqIfPresent(ThresholdsDO::getMinValue, reqVO.getMinValue())
.eqIfPresent(ThresholdsDO::getMaxValue, reqVO.getMaxValue())
.eqIfPresent(ThresholdsDO::getUnit, reqVO.getUnit())
.orderByDesc(ThresholdsDO::getId));
}
/**
* 根据机构ID查询指标设置并按periodType分组
*
* @param orgId 机构ID
* @return 按periodType分组的指标设置列表
*/
default List<ThresholdsDO> selectByOrgIdGroupByPeriodType(@Param("orgId") Integer orgId) {
return selectList(new LambdaQueryWrapperX<ThresholdsDO>()
.eq(ThresholdsDO::getOrgid, orgId)
.orderByAsc(ThresholdsDO::getPeriodtype));
}
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.pft;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.pft.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.pft.PftDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -43,6 +44,29 @@ public interface PftService {
*/
void deletePftListByIds(List<Long> ids);
/**
* 批量插入肺功能患者基础信息
*
* @param patientInfoList 患者信息列表
*/
void insertPftPatientData(List<patientinfoRespVO> patientInfoList);
/**
* 根据examid更新肺功能分析结果
*
* @param examid 检查ID
* @param analysisResult 分析结果
* @return 是否成功
*/
Boolean updatePftAnalysis(String examid, String analysisResult);
/**
* 根据examid查询肺功能分析结果
* @param examid 检查ID
* @return 分析结果
*/
String getPftAnalysis(String examid);
/**
* 获得肺功能患者
*

View File

@ -8,6 +8,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.system.controller.admin.pft.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.patientinfo.vo.patientinfoRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.pft.PftDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -66,6 +67,38 @@ public class PftServiceImpl implements PftService {
pftMapper.deleteByIds(ids);
}
@Override
public void insertPftPatientData(List<patientinfoRespVO> patientInfoList) {
if (CollUtil.isNotEmpty(patientInfoList)) {
List<PftDO> pftDataList = new ArrayList<>();
for (patientinfoRespVO patientInfo : patientInfoList) {
PftDO pft = new PftDO();
pft.setRegid(patientInfo.getRegid());
String examId = UUID.randomUUID().toString().replaceAll("-", ""); // 去除横线保持简洁
pft.setExamid(examId);
pft.setName(patientInfo.getName());
pft.setGender(patientInfo.getGender());
pft.setOrgid(patientInfo.getOrgid());
pft.setOrgname(patientInfo.getOrgname());
pft.setStatus(0); // 默认状态0申请中
pftDataList.add(pft);
}
// 批量插入肺功能数据
pftMapper.insertBatch(pftDataList);
}
}
@Override
public Boolean updatePftAnalysis(String examid, String analysisResult) {
pftMapper.updateAnalysisByExamid(examid, analysisResult);
return true;
}
@Override
public String getPftAnalysis(String examid) {
return pftMapper.selectAnalysisByExamid(examid);
}
private void validatePftExists(List<Long> ids) {
List<PftDO> list = pftMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {

View File

@ -59,4 +59,14 @@ public interface PftdataService {
*/
PageResult<PftdataDO> getPftdataPage(PftdataPageReqVO pageReqVO);
/**
* 根据检查ID和患者ID获取肺功能数据
*/
PftdataDO getPftdataByExamidAndRegid(String examid, String regid);
/**
* 根据examid和regid保存诊断结论
*/
void savePftdataDiagnosis(String examid, String regid, String diagnosis);
}

View File

@ -87,4 +87,27 @@ public class PftdataServiceImpl implements PftdataService {
return pftdataMapper.selectPage(pageReqVO);
}
@Override
public PftdataDO getPftdataByExamidAndRegid(String examid, String regid) {
return pftdataMapper.selectOne(
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<PftdataDO>()
.eq(PftdataDO::getExamid, examid)
.eq(PftdataDO::getRegid, regid)
);
}
@Override
public void savePftdataDiagnosis(String examid, String regid, String diagnosis) {
int updated = pftdataMapper.update(
null,
new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<PftdataDO>()
.eq(PftdataDO::getExamid, examid)
.eq(PftdataDO::getRegid, regid)
.set(PftdataDO::getDiagnosis, diagnosis)
);
if (updated == 0) {
throw new RuntimeException("未找到对应的肺功能数据记录,无法保存诊断结论");
}
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.system.service.thresholds;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.system.controller.admin.thresholds.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.thresholds.ThresholdsDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 指标设置 Service 接口
*
* @author 艾康菲
*/
public interface ThresholdsService {
/**
* 创建指标设置
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createThresholds(@Valid ThresholdsSaveReqVO createReqVO);
/**
* 更新指标设置
*
* @param updateReqVO 更新信息
*/
void updateThresholds(@Valid ThresholdsSaveReqVO updateReqVO);
/**
* 删除指标设置
*
* @param id 编号
*/
void deleteThresholds(Integer id);
/**
* 批量删除指标设置
*
* @param ids 编号
*/
void deleteThresholdsListByIds(List<Integer> ids);
/**
* 获得指标设置
*
* @param id 编号
* @return 指标设置
*/
ThresholdsDO getThresholds(Integer id);
/**
* 获得指标设置分页
*
* @param pageReqVO 分页查询
* @return 指标设置分页
*/
PageResult<ThresholdsDO> getThresholdsPage(ThresholdsPageReqVO pageReqVO);
/**
* 根据机构ID查询指标设置并按periodType分组
*
* @param orgId 机构ID
* @return 按periodType分组的指标设置列表
*/
List<ThresholdsGroupRespVO> getThresholdsByOrgIdGroupByPeriodType(Integer orgId);
}

View File

@ -0,0 +1,119 @@
package cn.iocoder.yudao.module.system.service.thresholds;
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.thresholds.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.thresholds.ThresholdsDO;
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.thresholds.ThresholdsMapper;
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 ThresholdsServiceImpl implements ThresholdsService {
@Resource
private ThresholdsMapper thresholdsMapper;
@Override
public Integer createThresholds(ThresholdsSaveReqVO createReqVO) {
// 插入
ThresholdsDO thresholds = BeanUtils.toBean(createReqVO, ThresholdsDO.class);
thresholdsMapper.insert(thresholds);
// 返回
return thresholds.getId();
}
@Override
public void updateThresholds(ThresholdsSaveReqVO updateReqVO) {
// 校验存在
validateThresholdsExists(updateReqVO.getId());
// 更新
ThresholdsDO updateObj = BeanUtils.toBean(updateReqVO, ThresholdsDO.class);
thresholdsMapper.updateById(updateObj);
}
@Override
public void deleteThresholds(Integer id) {
// 校验存在
validateThresholdsExists(id);
// 删除
thresholdsMapper.deleteById(id);
}
@Override
public void deleteThresholdsListByIds(List<Integer> ids) {
// 校验存在
validateThresholdsExists(ids);
// 删除
thresholdsMapper.deleteByIds(ids);
}
private void validateThresholdsExists(List<Integer> ids) {
List<ThresholdsDO> list = thresholdsMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
}
}
private void validateThresholdsExists(Integer id) {
if (thresholdsMapper.selectById(id) == null) {
}
}
@Override
public ThresholdsDO getThresholds(Integer id) {
return thresholdsMapper.selectById(id);
}
@Override
public PageResult<ThresholdsDO> getThresholdsPage(ThresholdsPageReqVO pageReqVO) {
return thresholdsMapper.selectPage(pageReqVO);
}
@Override
public List<ThresholdsGroupRespVO> getThresholdsByOrgIdGroupByPeriodType(Integer orgId) {
// 查询所有数据
List<ThresholdsDO> allThresholds = thresholdsMapper.selectByOrgIdGroupByPeriodType(orgId);
// 按periodType分组
Map<String, List<ThresholdsDO>> groupedMap = new HashMap<>();
for (ThresholdsDO threshold : allThresholds) {
String periodType = threshold.getPeriodtype();
groupedMap.computeIfAbsent(periodType, k -> new ArrayList<>()).add(threshold);
}
// 转换为响应VO
List<ThresholdsGroupRespVO> result = new ArrayList<>();
for (Map.Entry<String, List<ThresholdsDO>> entry : groupedMap.entrySet()) {
String periodType = entry.getKey();
List<ThresholdsDO> thresholdsList = entry.getValue();
// 转换为ThresholdsItemRespVO列表不包含periodtype字段
List<ThresholdsItemRespVO> respVOList = BeanUtils.toBean(thresholdsList, ThresholdsItemRespVO.class);
// 创建分组响应VO
ThresholdsGroupRespVO groupRespVO = new ThresholdsGroupRespVO(periodType, respVOList);
result.add(groupRespVO);
}
return result;
}
}

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

View File

@ -297,6 +297,7 @@ yudao:
- tb_pftdata #忽略肺功能数据表
- tb_era #忽略电测听表
- tb_era_data #忽略电测听数据表
- health_thresholds #忽略健康阈值表
ignore-caches:
- user_role_ids
- permission_menu_ids