ocr解析后端逻辑
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled
yudao-ui-admin CI / build (14.x) (push) Has been cancelled
yudao-ui-admin CI / build (16.x) (push) Has been cancelled

This commit is contained in:
yy2205 2025-05-12 08:51:06 +08:00
parent 07bd4ccb79
commit 7c708f0716
11 changed files with 171 additions and 62 deletions

View File

@ -6,10 +6,13 @@ import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqV
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@Mapper @Mapper
@InterceptorIgnore(tenantLine = "true")
public interface DeptMapper extends BaseMapperX<DeptDO> { public interface DeptMapper extends BaseMapperX<DeptDO> {
default List<DeptDO> selectList(DeptListReqVO reqVO) { default List<DeptDO> selectList(DeptListReqVO reqVO) {

View File

@ -47,10 +47,12 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*; import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*;
import cn.iocoder.yudao.module.tblist.controller.admin.patientexamlist.vo.EcgPictureOcr;
import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO; import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO;
import cn.iocoder.yudao.module.tblist.service.ecganalysisparas.EcganalysisparasService; import cn.iocoder.yudao.module.tblist.service.ecganalysisparas.EcganalysisparasService;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -140,7 +142,7 @@ public class EcganalysisparasController {
LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
updateReqVO.setDoctorDiagTime(dateTime); updateReqVO.setDoctorDiagTime(dateTime);
if(!doctorDO.getDepartmentName().isEmpty()) if(doctorDO.getDepartmentName() !=null && !doctorDO.getDepartmentName().isEmpty())
{ {
updateReqVO.setDepartName(doctorDO.getDepartmentName()); updateReqVO.setDepartName(doctorDO.getDepartmentName());
} }
@ -338,30 +340,22 @@ public class EcganalysisparasController {
@PostMapping("/parsePhotoCreateData") @PostMapping("/parsePhotoCreateData")
@Operation(summary = "从JSON文件解析心电数据") @Operation(summary = "从JSON文件解析心电数据")
public CommonResult<Boolean> parsePhotoCreateData(@RequestParam("file") MultipartFile file) { @PermitAll
try { public CommonResult<Boolean> parsePhotoCreateData(@RequestBody String file) {
// 验证文件不为空 // 验证文件不为空
if (file == null || file.isEmpty()) { if (file == null || file.isEmpty()) {
return error(400, "请选择要上传的JSON文件"); return error(400, "请选择要上传的JSON文件");
} }
// 调用service进行文件解析 // 调用service进行文件解析
List<EcganalysisparasSaveReqVO> dataList = ecganalysisparasService.parseEcgDataFromJsonFile(file); List<EcgPictureOcr> dataList = ecganalysisparasService.parseEcgDataFromJsonFile(file);
// 将数据转换为DO对象 // 将数据转换为DO对象
// List<EcganalysisparasDO> resultList = ecganalysisparasService.parsePhotoCreateData(dataList, EcganalysisparasDO.class); // List<EcganalysisparasDO> resultList = ecganalysisparasService.parsePhotoCreateData(dataList, EcganalysisparasDO.class);
ecganalysisparasService.createEcgFromPhotoJson(dataList); ecganalysisparasService.createEcgFromPhotoJson(dataList);
return success(true); return success(true);
} catch (IllegalArgumentException e) {
// 参数错误异常
return error(400, e.getMessage());
} catch (IOException e) {
// 文件读取错误
return error(500, "文件读取失败: " + e.getMessage());
} catch (Exception e) {
// 其他未知错误
return error(500, "处理失败: " + e.getMessage());
}
} }
} }

View File

@ -32,6 +32,9 @@ public class EcganalysisparasSaveReqVO {
@Schema(description = "QRS电轴") @Schema(description = "QRS电轴")
private String qrsAxle; private String qrsAxle;
@Schema(description = "QRS间期")
private String qrs;
@Schema(description = "T电轴") @Schema(description = "T电轴")
private String tAxle; private String tAxle;

View File

@ -378,7 +378,7 @@ public class PatientexamlistController {
LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), LocalDateTime dateTime = LocalDateTime.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
//获取当前登陆用户 //获取当前登陆用户
// AdminUserDO user = userService.getUser(getLoginUserId()); // AdminUserDO user = userService.getUser(getLoginUserId());
PatientexamlistSaveReqVO updateReqVO = new PatientexamlistSaveReqVO(); PatientexamlistSaveReqVO updateReqVO = new PatientexamlistSaveReqVO();
updateReqVO.setId(id); updateReqVO.setId(id);
updateReqVO.setReviewDoctorId(doctorid); updateReqVO.setReviewDoctorId(doctorid);

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.tblist.controller.admin.patientexamlist.vo;
import java.time.LocalDate;
import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.EcganalysisparasSaveReqVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* 心电图图片OCR
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
public class EcgPictureOcr extends EcganalysisparasSaveReqVO{
/** 机构名称(文件夹名称) */
private String orgName;
/** 机构ID */
private String orgId;
/** 心电图数据文件路径 */
private String ecgDataFilePath;
}

View File

@ -64,6 +64,10 @@ public class EcganalysisparasDO {
*/ */
@TableField("QRS_Axle") @TableField("QRS_Axle")
private String qrsAxle; private String qrsAxle;
/**
* QRS间期
*/
private String qrs;
/** /**
* T电轴 * T电轴
*/ */

View File

@ -87,5 +87,7 @@ public interface EcganalysisparasMapper extends BaseMapperX<EcganalysisparasDO>
@Select(" ${sql} ") @Select(" ${sql} ")
List<Map<String, Object>> use_selectList(@Param("sql") String sql); List<Map<String, Object>> use_selectList(@Param("sql") String sql);
@Select("SELECT * FROM tb_ecganalysisparas WHERE examId = #{examId} AND (isDelete = '0' or isDelete is null)")
EcganalysisparasDO selectOneByExamId(@Param("examId") String examId);
} }

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.tblist.dal.orgDo; package cn.iocoder.yudao.module.tblist.dal.orgDo;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.github.xiaoymin.knife4j.annotations.Ignore;
import lombok.*; import lombok.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -22,7 +24,7 @@ public class OrgDO {
/** /**
* 主键 机构ID * 主键 机构ID
*/ */
@TableId(type = IdType.INPUT) @TableId(type = IdType.INPUT,value = "orgID")
private String orgID; private String orgID;
/** /**
* 机构名称 * 机构名称
@ -60,11 +62,5 @@ public class OrgDO {
*/ */
@TableField("orgSN") @TableField("orgSN")
private String orgSN; private String orgSN;
/**
* 创建时间年月日时分秒
*/
@TableField("datetime")
private Date datetime;
} }

View File

@ -17,4 +17,6 @@ public interface OrgMapper extends BaseMapperX<OrgDO>
*/ */
//获取机构表里的上级机构 //获取机构表里的上级机构
String SelectOrgHigID(@Param("orgId") String orgId); String SelectOrgHigID(@Param("orgId") String orgId);
} }

View File

@ -4,6 +4,7 @@ import java.util.*;
import java.io.IOException; import java.io.IOException;
import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*; import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*;
import cn.iocoder.yudao.module.tblist.controller.admin.patientexamlist.vo.EcgPictureOcr;
import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO; import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
@ -104,21 +105,21 @@ public interface EcganalysisparasService extends IService<EcganalysisparasDO> {
* @param <T> 目标类型的泛型参数 * @param <T> 目标类型的泛型参数
* @return 转换后的目标类型列表 * @return 转换后的目标类型列表
*/ */
<T> List<T> parsePhotoCreateData(List<EcganalysisparasSaveReqVO> list, Class<T> clazz); <T> List<T> parsePhotoCreateData(List<EcgPictureOcr> list, Class<T> clazz);
/** /**
* 从JSON文件解析数据 * 从JSON文件解析数据
* *
* @param file 上传的JSON文件 * @param jsonContent 上传的JSON文件数据
* @return 解析后的心电分析数据列表 * @return 解析后的心电分析数据列表
* @throws IOException 如果文件读取失败 * @throws IOException 如果文件读取失败
*/ */
List<EcganalysisparasSaveReqVO> parseEcgDataFromJsonFile(MultipartFile file) throws IOException; List<EcgPictureOcr> parseEcgDataFromJsonFile(String jsonContent);
/** /**
* 将解析后的数据插入数据库 * 将解析后的数据插入数据库
* @param list * @param list
*/ */
void createEcgFromPhotoJson(List<EcganalysisparasSaveReqVO> list); void createEcgFromPhotoJson(List<EcgPictureOcr> list);
} }

View File

@ -4,14 +4,20 @@ import cn.hutool.core.lang.UUID;
import cn.iocoder.yudao.framework.common.exception.ErrorCode; import cn.iocoder.yudao.framework.common.exception.ErrorCode;
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO; import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
import cn.iocoder.yudao.module.infra.service.config.ConfigService; import cn.iocoder.yudao.module.infra.service.config.ConfigService;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO; import cn.iocoder.yudao.module.system.dal.dataobject.doctor.DoctorDO;
import cn.iocoder.yudao.module.system.dal.dataobject.org.OrgUnitDO; import cn.iocoder.yudao.module.system.dal.dataobject.org.OrgUnitDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.doctor.DoctorService; import cn.iocoder.yudao.module.system.service.doctor.DoctorService;
import cn.iocoder.yudao.module.system.service.org.OrgUnitService; import cn.iocoder.yudao.module.system.service.org.OrgUnitService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.module.tblist.dal.dataobject.patientexamlist.PatientexamlistDO; import cn.iocoder.yudao.module.tblist.dal.dataobject.patientexamlist.PatientexamlistDO;
import cn.iocoder.yudao.module.tblist.dal.mysql.patientexamlist.PatientexamlistMapper; import cn.iocoder.yudao.module.tblist.dal.mysql.patientexamlist.PatientexamlistMapper;
import cn.iocoder.yudao.module.tblist.dal.orgDo.OrgDO;
import cn.iocoder.yudao.module.tblist.dal.orgMapper.OrgMapper;
import cn.iocoder.yudao.module.tblist.service.patientexamlist.org.OrgService;
import cn.iocoder.yudao.module.tblist.service.positivestatistics.PositivestatisticsService; import cn.iocoder.yudao.module.tblist.service.positivestatistics.PositivestatisticsService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -36,10 +42,11 @@ import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*; import cn.iocoder.yudao.module.tblist.controller.admin.ecganalysisparas.vo.*;
import cn.iocoder.yudao.module.tblist.controller.admin.patientexamlist.vo.EcgPictureOcr;
import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO; import cn.iocoder.yudao.module.tblist.dal.dataobject.ecganalysisparas.EcganalysisparasDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.tblist.dal.mysql.ecganalysisparas.EcganalysisparasMapper; import cn.iocoder.yudao.module.tblist.dal.mysql.ecganalysisparas.EcganalysisparasMapper;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -79,6 +86,8 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
@Resource @Resource
private RestTemplate httpRestTemplate; private RestTemplate httpRestTemplate;
@Resource
private OrgMapper orgMapper;
@Override @Override
public String createEcganalysisparas(EcganalysisparasSaveReqVO createReqVO) { public String createEcganalysisparas(EcganalysisparasSaveReqVO createReqVO) {
@ -248,37 +257,26 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
return mapResult; return mapResult;
} }
@Override @Override
public <T> List<T> parsePhotoCreateData(List<EcganalysisparasSaveReqVO> list, Class<T> clazz) { public <T> List<T> parsePhotoCreateData(List<EcgPictureOcr> list, Class<T> clazz) {
return BeanUtils.toBean(list, clazz); return BeanUtils.toBean(list, clazz);
} }
@Override @Override
public List<EcganalysisparasSaveReqVO> parseEcgDataFromJsonFile(MultipartFile file) throws IOException { public List<EcgPictureOcr> parseEcgDataFromJsonFile(String jsonContent) {
if (file == null || file.isEmpty()) { if (jsonContent == null || jsonContent.trim().isEmpty()) {
throw new IllegalArgumentException("文件不能为空"); throw exception(new ErrorCode(999, "JSON内容不能为空"));
} }
// 校验文件类型
String contentType = file.getContentType();
String originalFilename = file.getOriginalFilename();
if (contentType == null || !contentType.contains("json") &&
(originalFilename == null || !originalFilename.toLowerCase().endsWith(".json"))) {
throw new IllegalArgumentException("只支持JSON文件格式");
}
// 读取文件内容
String content = new String(file.getBytes(), StandardCharsets.UTF_8);
try { try {
// 解析为List<JSONObject> // 解析为List<JSONObject>
List<JSONObject> jsonList = JSON.parseArray(content, JSONObject.class); List<JSONObject> jsonList = JSON.parseArray(jsonContent, JSONObject.class);
List<EcganalysisparasSaveReqVO> resultList = new ArrayList<>(); List<EcgPictureOcr> resultList = new ArrayList<>();
for (JSONObject json : jsonList) { for (JSONObject json : jsonList) {
// 获取extracted_data字段 // 获取extracted_data字段
JSONObject extractedData = json.getJSONObject("extracted_data"); JSONObject extractedData = json.getJSONObject("extracted_data");
if (extractedData != null) { if (extractedData != null) {
EcganalysisparasSaveReqVO vo = new EcganalysisparasSaveReqVO(); EcgPictureOcr vo = new EcgPictureOcr();
// 处理简单字段映射 // 处理简单字段映射
processSimpleFields(extractedData, vo); processSimpleFields(extractedData, vo);
@ -294,14 +292,14 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
return resultList; return resultList;
} catch (Exception e) { } catch (Exception e) {
throw new IllegalArgumentException("JSON文件格式不正确或不匹配要求的数据结构: " + e.getMessage()); throw exception(new ErrorCode(997, "JSON格式不正确或不匹配要求的数据结构: " + e.getMessage()));
} }
} }
/** /**
* 处理简单字段 * 处理简单字段
*/ */
private void processSimpleFields(JSONObject extractedData, EcganalysisparasSaveReqVO vo) { private void processSimpleFields(JSONObject extractedData, EcgPictureOcr vo) {
// 定义字段映射关系 - <JSON字段名, 处理方式> // 定义字段映射关系 - <JSON字段名, 处理方式>
Map<String, FieldProcessor> fieldMappings = new HashMap<>(); Map<String, FieldProcessor> fieldMappings = new HashMap<>();
@ -314,7 +312,22 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
fieldMappings.put("department", (value) -> vo.setDepartName(cleanValue(value, false))); fieldMappings.put("department", (value) -> vo.setDepartName(cleanValue(value, false)));
fieldMappings.put("rv5Sv1", (value) -> vo.setRv5Sv1(cleanValue(value, true))); fieldMappings.put("rv5Sv1", (value) -> vo.setRv5Sv1(cleanValue(value, true)));
fieldMappings.put("qrsTimeLimit", (value) -> vo.setQrsTimeLimit(cleanValue(value, true))); fieldMappings.put("qrsTimeLimit", (value) -> vo.setQrsTimeLimit(cleanValue(value, true)));
fieldMappings.put("regId", (value) -> vo.setRegId(cleanValue(value, false)));
fieldMappings.put("orgName", (value) -> vo.setOrgName(cleanValue(value, false)));
fieldMappings.put("ecgDataFilePath", (value) -> vo.setEcgDataFilePath(cleanValue(value, false)));
fieldMappings.put("qrs", (value) -> vo.setQrs(cleanValue(value, true)));
fieldMappings.put("collectionTime", (value) -> {
try {
// 解析日期字符串格式2025-04-14
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
// 因为只有日期没有时间所以使用atStartOfDay()添加时间部分
LocalDateTime dateTime = LocalDate.parse(cleanValue(value, false), formatter).atStartOfDay();
vo.setCollectionTime(dateTime);
} catch (Exception e) {
// 解析失败时使用当前时间
vo.setCollectionTime(LocalDateTime.now());
}
});
// 处理所有简单字段 // 处理所有简单字段
for (Map.Entry<String, FieldProcessor> entry : fieldMappings.entrySet()) { for (Map.Entry<String, FieldProcessor> entry : fieldMappings.entrySet()) {
String fieldName = entry.getKey(); String fieldName = entry.getKey();
@ -330,7 +343,7 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
/** /**
* 处理复合字段含有"/"的字段 * 处理复合字段含有"/"的字段
*/ */
private void processCompositeFields(JSONObject extractedData, EcganalysisparasSaveReqVO vo) { private void processCompositeFields(JSONObject extractedData, EcgPictureOcr vo) {
// 处理P/QRS/T或类似格式字段 // 处理P/QRS/T或类似格式字段
processAxisField(extractedData, vo); processAxisField(extractedData, vo);
@ -456,15 +469,18 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
} }
@Override @Override
@Transactional @Transactional
public void createEcgFromPhotoJson(List<EcganalysisparasSaveReqVO> list) { public void createEcgFromPhotoJson(List<EcgPictureOcr> list) {
// 存储格式不正确的记录 // 存储格式不正确的记录
List<EcganalysisparasSaveReqVO> invalidRecords = new ArrayList<>(); List<EcganalysisparasSaveReqVO> invalidRecords = new ArrayList<>();
// 遍历列表检查数字字段的有效性 // 遍历列表检查数字字段的有效性
Iterator<EcganalysisparasSaveReqVO> iterator = list.iterator(); Iterator<EcgPictureOcr> iterator = list.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
EcganalysisparasSaveReqVO item = iterator.next(); EcgPictureOcr item = iterator.next();
if (!isValidNumberFormat(item) && (item.getExamId() == null || item.getExamId().equals(""))) {
isValidNumberFormat(item);
// 如果检查单号为空或者存在相同检查单号的记录则不进行后续处理
if ( (item.getExamId() == null || item.getExamId().equals(""))) {
invalidRecords.add(item); invalidRecords.add(item);
iterator.remove(); // 从原始列表中移除无效记录 iterator.remove(); // 从原始列表中移除无效记录
} }
@ -477,6 +493,13 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
return; return;
} }
list.forEach(e -> { list.forEach(e -> {
String orgName = e.getOrgName().trim();
OrgDO orgDO = orgMapper.selectOne(new LambdaQueryWrapperX<OrgDO>()
.eq(OrgDO::getOrgName, orgName));
if(orgDO != null){
e.setOrgId(orgDO.getOrgID());
e.setEcgJsonDataFilePath("https://zzxmc.gw12320.com/ecgimage/"+e.getOrgName()+"/"+e.getEcgDataFilePath());
}
e.setRegId(UUID.randomUUID().toString()); e.setRegId(UUID.randomUUID().toString());
e.setCreateDate(LocalDateTime.now()); e.setCreateDate(LocalDateTime.now());
}); });
@ -492,10 +515,12 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
patient.setExamId(ecg.getExamId()); patient.setExamId(ecg.getExamId());
patient.setPName(ecg.getName()); patient.setPName(ecg.getName());
patient.setGender(ecg.getGender()); patient.setGender(ecg.getGender());
patient.setOrgId(ecg.getOrgId());
patient.setOrgName(ecg.getOrgName());
// 设置额外属性 // 设置额外属性
patient.setCreateDate(ecg.getCreateDate()); patient.setCreateDate(ecg.getCreateDate());
patient.setExamDate(ecg.getCollectionTime());
patient.setDeviceType("ECG"); // 设置检查类型 patient.setDeviceType("ECG"); // 设置检查类型
return patient; return patient;
@ -503,16 +528,34 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
.collect(Collectors.toList()); .collect(Collectors.toList());
// return; // return;
if (!ecgDO.isEmpty()) { if (ecgDO!=null && !ecgDO.isEmpty()) {
ecgDO.forEach(e -> { Iterator<EcganalysisparasDO> ecgIterator = ecgDO.iterator();
e.setId(UUID.randomUUID().toString()); while (ecgIterator.hasNext()) {
}); EcganalysisparasDO e = ecgIterator.next();
EcganalysisparasDO ecganalysisparasDO = ecganalysisparasMapper.selectOneByExamId(e.getExamId());
if (ecganalysisparasDO != null) {
ecgIterator.remove();
} else {
e.setId(UUID.randomUUID().toString());
e.setSnapshotTime(e.getCollectionTime());
}
}
ecganalysisparasMapper.insertBatch(ecgDO); ecganalysisparasMapper.insertBatch(ecgDO);
} }
if (!patientDOList.isEmpty()) { if (patientDOList!=null && !patientDOList.isEmpty()) {
patientDOList.forEach(e -> { Iterator<PatientexamlistDO> patientIterator = patientDOList.iterator();
e.setId(UUID.randomUUID().toString()); while (patientIterator.hasNext()) {
}); PatientexamlistDO patient = patientIterator.next();
PatientexamlistDO patientexamlistDO = patientexamlistMapper.selectOne(
new LambdaQueryWrapperX<PatientexamlistDO>()
.eq(PatientexamlistDO::getExamId, patient.getExamId())
);
if (patientexamlistDO != null) {
patientIterator.remove(); // 安全地移除元素
} else {
patient.setId(UUID.randomUUID().toString());
}
}
patientexamlistMapper.insertBatch(patientDOList); patientexamlistMapper.insertBatch(patientDOList);
} }
@ -526,6 +569,41 @@ public class EcganalysisparasServiceImpl extends ServiceImpl<EcganalysisparasMap
* @return 如果所有数字字段格式都有效则返回true否则返回false * @return 如果所有数字字段格式都有效则返回true否则返回false
*/ */
private boolean isValidNumberFormat(EcganalysisparasSaveReqVO item) { private boolean isValidNumberFormat(EcganalysisparasSaveReqVO item) {
if (!isValidNumber(item.getHr())) {
item.setHr(null);
}
if (!isValidNumber(item.getPr())) {
item.setPr(null);
}
if (!isValidNumber(item.getQrsTimeLimit())) {
item.setQrsTimeLimit(null);
}
if (!isValidNumber(item.getQt())) {
item.setQt(null);
}
if (!isValidNumber(item.getQtc())) {
item.setQtc(null);
}
if (!isValidNumber(item.getPAxle())) {
item.setPAxle(null);
}
if (!isValidNumber(item.getQrsAxle())) {
item.setQrsAxle(null);
}
if (!isValidNumber(item.getTAxle())) {
item.setTAxle(null);
}
if (!isValidNumber(item.getRv5())) {
item.setRv5(null);
}
if (!isValidNumber(item.getSv1())) {
item.setSv1(null);
}
if (!isValidNumber(item.getRv5Sv1())) {
item.setRv5Sv1(null);
}
// 检查数字格式的字段列表 // 检查数字格式的字段列表
if (!isValidNumber(item.getHr()) || if (!isValidNumber(item.getHr()) ||
!isValidNumber(item.getPr()) || !isValidNumber(item.getPr()) ||