From 5678535d887341ee9a9094b8db90302fcb074fe7 Mon Sep 17 00:00:00 2001 From: wangjian963 <15215920+aprilry@user.noreply.gitee.com> Date: Tue, 31 Mar 2026 15:47:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=A3=80=E9=AA=8C=E7=94=B3=E8=AF=B7):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A3=80=E9=AA=8C=E7=94=B3=E8=AF=B7=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E7=94=9F=E6=88=90=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=89=A7=E8=A1=8C=E7=A7=91=E5=AE=A4=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(检验申请): 重构申请单详情加载逻辑,使用后端接口获取完整数据 fix(检验申请): 修复执行科室默认值设置问题 fix(会诊): 修复就诊卡号取值错误和表格选中状态问题 perf(检验申请): 使用Redis实现并发安全的申请单号生成 docs(检验申请): 补充相关接口和方法注释 --- .../impl/DiagTreatMAppServiceImpl.java | 8 + ...octorStationInspectionLabApplyService.java | 7 + .../DoctorStationLabApplyServiceImpl.java | 83 ++++- ...orStationInspectionLabApplyController.java | 16 + .../dto/DoctorStationLabApplyDto.java | 4 + .../mapper/DoctorStationLabApplyMapper.java | 5 + .../DoctorStationLabApplyMapper.xml | 31 +- .../src/views/doctorstation/components/api.js | 27 +- .../doctorstation/components/consultation.vue | 17 +- .../inspection/inspectionApplication.vue | 308 ++++++++---------- 10 files changed, 331 insertions(+), 175 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/datadictionary/appservice/impl/DiagTreatMAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/datadictionary/appservice/impl/DiagTreatMAppServiceImpl.java index ad523bb4..94988bfc 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/datadictionary/appservice/impl/DiagTreatMAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/datadictionary/appservice/impl/DiagTreatMAppServiceImpl.java @@ -186,6 +186,14 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService { public R getDiseaseTreatmentPage(DiagnosisTreatmentSelParam DiagnosisTreatmentSelParam, String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request) { + // 如果没有指定状态,默认只查询启用状态(status_enum=2),避免显示未启用的项目导致保存失败 + if (DiagnosisTreatmentSelParam == null) { + DiagnosisTreatmentSelParam = new DiagnosisTreatmentSelParam(); + } + if (DiagnosisTreatmentSelParam.getStatusEnum() == null) { + DiagnosisTreatmentSelParam.setStatusEnum(PublicationStatus.ACTIVE.getValue()); + } + // 临时保存ybType值并从参数对象中移除,避免HisQueryUtils构建yb_type条件 String ybTypeValue = null; if (DiagnosisTreatmentSelParam != null && StringUtils.isNotEmpty(DiagnosisTreatmentSelParam.getYbType())) { diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationInspectionLabApplyService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationInspectionLabApplyService.java index 7e04abfa..6790f25c 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationInspectionLabApplyService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/IDoctorStationInspectionLabApplyService.java @@ -19,4 +19,11 @@ public interface IDoctorStationInspectionLabApplyService { * @return 删除结果 */ R deleteInspectionLabApply(String applyNo); + + /** + * 生成检验申请单号 + * 规则:LS + YYYYMMDD + 5位流水号(每日从1开始递增) + * @return 申请单号 + */ + String generateApplyNo(); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationLabApplyServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationLabApplyServiceImpl.java index be054fb7..756832ad 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationLabApplyServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationLabApplyServiceImpl.java @@ -1,6 +1,7 @@ package com.openhis.web.doctorstation.appservice.impl; import com.core.common.core.domain.R; +import com.core.common.core.redis.RedisCache; import com.core.common.enums.DelFlag; import com.core.common.utils.SecurityUtils; import com.openhis.common.enums.DbOpType; @@ -35,6 +36,8 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -76,6 +79,9 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio @Autowired private IServiceRequestService serviceRequestService; + @Autowired + private RedisCache redisCache; + /** * 保存检验申请单信息 * @param doctorStationLabApplyDto @@ -116,8 +122,8 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio //设置从表申请单明细的申请单号 inspectionLabApplyItem.setApplyNo(doctorStationLabApplyDto.getApplyNo()); - //检验科代码,取值于检验申请单 - inspectionLabApplyItem.setPerformDeptCode(doctorStationLabApplyDto.getApplyDeptCode()); + //执行科室代码,取值于检验申请单明细(前端传递的字典值) + inspectionLabApplyItem.setPerformDeptCode(doctorStationLabApplyItemDto.getPerformDeptCode()); //同主表状态,可单独回写 inspectionLabApplyItem.setItemStatus(doctorStationLabApplyDto.getApplyStatus()); // 设置项目序号 (打印顺序),按照遍历序号进行排序 @@ -194,6 +200,12 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio } } + // 如果没有指定执行科室,使用当前医生所在的科室作为默认执行科室 + if (positionId == null) { + positionId = SecurityUtils.getDeptId(); + log.debug("检验项目未指定执行科室,使用当前科室:{}", positionId); + } + // 4. 创建医嘱保存对象 AdviceSaveDto adviceSaveDto = new AdviceSaveDto(); // 设置医嘱操作类型 @@ -279,14 +291,41 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio } /** - * 根据申请单号查询检验申请单 + * 根据申请单号查询检验申请单(包含检验项目明细) * * @param applyNo * @return */ @Override public Object getInspectionApplyByApplyNo(String applyNo) { - return doctorStationLabApplyMapper.getInspectionApplyByApplyNo(applyNo); + // 查询主表数据 + DoctorStationLabApplyDto applyDto = (DoctorStationLabApplyDto) doctorStationLabApplyMapper.getInspectionApplyByApplyNo(applyNo); + if (applyDto == null) { + return null; + } + + // 查询检验项目明细 + List itemList = inspectionLabApplyItemService.list( + new QueryWrapper() + .eq("apply_no", applyNo) + .eq("delete_flag", "0") + .orderByAsc("item_seq") + ); + + // 转换为 DTO 列表 + List itemDtoList = new ArrayList<>(); + if (itemList != null && !itemList.isEmpty()) { + for (InspectionLabApplyItem item : itemList) { + DoctorStationLabApplyItemDto itemDto = new DoctorStationLabApplyItemDto(); + BeanUtils.copyProperties(item, itemDto); + itemDtoList.add(itemDto); + } + // 从第一个明细项获取执行科室代码 + applyDto.setExecuteDepartment(itemList.get(0).getPerformDeptCode()); + } + applyDto.setLabApplyItemList(itemDtoList); + + return applyDto; } /** @@ -502,7 +541,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio ); if (deleteResult) { - log.debug("成功删除申请单号 [{}] 的条码数据,更新人:{},更新时间:{}", + log.debug("成功删除申请单号 [{}] 的条码数据,更新人:{},更新时间:{}", applyNo, currentUsername, currentTime); } else { log.warn("删除申请单号 [{}] 的条码数据失败", applyNo); @@ -514,4 +553,38 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio } } + /** + * 生成检验申请单号 + * 规则:LS + YYYYMMDD + 5位流水号(每日从1开始递增) + * 支持并发安全:使用 Redis 原子递增保证唯一性 + * @return 申请单号 + */ + @Override + public String generateApplyNo() { + // 获取当前日期 + LocalDate today = LocalDate.now(); + String dateStr = today.format(DateTimeFormatter.ofPattern("yyyyMMdd")); + + // 生成前缀:LS + 日期 + String prefix = "LS" + dateStr; + + // Redis key 用于存储当天的流水号 + String redisKey = "lab_apply_no:" + dateStr; + + // 使用 Redis 原子递增获取流水号(并发安全) + long sequence = redisCache.incr(redisKey, 1); + + // 设置 Redis key 过期时间为 2 天,避免数据积累 + redisCache.expire(redisKey, 2 * 24 * 60 * 60); + + // 格式化流水号为5位,不足前补0 + String sequenceStr = String.format("%05d", sequence); + + // 生成完整的申请单号 + String applyNo = prefix + sequenceStr; + + log.debug("生成检验申请单号:{}", applyNo); + return applyNo; + } + } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/controller/DoctorStationInspectionLabApplyController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/controller/DoctorStationInspectionLabApplyController.java index 0f46eebe..a18b91ee 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/controller/DoctorStationInspectionLabApplyController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/controller/DoctorStationInspectionLabApplyController.java @@ -9,6 +9,8 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import org.springframework.validation.annotation.Validated; +import java.util.HashMap; +import java.util.Map; /** * 门诊医生站-检验控制器 @@ -62,4 +64,18 @@ public class DoctorStationInspectionLabApplyController { log.debug("删除检验申请单:{}", applyNo); return R.ok(iDoctorStationInspectionLabApplyService.deleteInspectionLabApply(applyNo)); } + + /** + * 生成检验申请单号 + * 规则:LS + YYYYMMDD + 5位流水号(每日从1开始递增) + * @return 申请单号 + */ + @GetMapping(value = "/generate-apply-no") + public R generateApplyNo(){ + log.debug("生成检验申请单号"); + String applyNo = iDoctorStationInspectionLabApplyService.generateApplyNo(); + Map result = new HashMap<>(); + result.put("applyNo", applyNo); + return R.ok(result); + } } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/dto/DoctorStationLabApplyDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/dto/DoctorStationLabApplyDto.java index c2f491da..fdcd81fb 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/dto/DoctorStationLabApplyDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/dto/DoctorStationLabApplyDto.java @@ -135,6 +135,10 @@ public class DoctorStationLabApplyDto { * 就诊id */ private Long encounterId; + /** + * 执行科室代码(从明细项获取) + */ + private String executeDepartment; /** * 检验项目数据列表 */ diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationLabApplyMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationLabApplyMapper.java index fd7aca61..55020e48 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationLabApplyMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/mapper/DoctorStationLabApplyMapper.java @@ -11,6 +11,11 @@ import java.util.List; */ @Repository public interface DoctorStationLabApplyMapper { + /** + * 根据申请单号查询检验申请单 + * @param applyNo 申请单号 + * @return 检验申请单DTO + */ Object getInspectionApplyByApplyNo(String applyNo); /** diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationLabApplyMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationLabApplyMapper.xml index 486e3c24..f9464c2c 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationLabApplyMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/doctorstation/DoctorStationLabApplyMapper.xml @@ -4,9 +4,36 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - +