1:枚举替换,2:新增格式化函数来优化金额显示,3:新增格式化函数,4:表格状态标识优化

This commit is contained in:
wangjian963
2026-02-28 17:48:28 +08:00
parent a05b3a8d3c
commit 6add091a7b
2 changed files with 38 additions and 47 deletions

View File

@@ -1,7 +1,9 @@
package com.openhis.web.doctorstation.appservice.impl;
import com.core.common.core.domain.R;
import com.core.common.enums.DelFlag;
import com.core.common.utils.SecurityUtils;
import com.openhis.common.enums.DbOpType;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.domain.Account;
import com.openhis.lab.domain.InspectionLabApply;
@@ -23,7 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.openhis.web.doctorstation.dto.DoctorStationLabApplyItemDto;
import com.openhis.workflow.service.IActivityDefinitionService;
@@ -100,7 +101,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
inspectionLabApply.setCreateBy(SecurityUtils.getLoginUser().getUsername());
inspectionLabApply.setOperatorId(userId);
inspectionLabApply.setCreateTime(new Date());
inspectionLabApply.setDeleteFlag("0");
inspectionLabApply.setDeleteFlag(DelFlag.NO.getCode());
log.debug("保存检验申请单信息:{}", inspectionLabApply);
inspectionLabApplyService.saveOrUpdate(inspectionLabApply);
@@ -123,7 +124,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
inspectionLabApplyItem.setItemSeq((long) (index + 1));
index++;
inspectionLabApplyItem.setDeleteFlag("0");
inspectionLabApplyItem.setDeleteFlag(DelFlag.NO.getCode());
log.debug("保存申请单明细信息:{}", inspectionLabApplyItem);
inspectionLabApplyItemService.saveOrUpdate(inspectionLabApplyItem);
@@ -138,7 +139,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
barCode.setTenantId(SecurityUtils.getLoginUser().getTenantId());
barCode.setCreateBy(SecurityUtils.getLoginUser().getUsername());
barCode.setCreateTime(new Date());
barCode.setDeleteFlag("0");
barCode.setDeleteFlag(DelFlag.NO.getCode());
log.debug("插入条码数据前barCode:{}",barCode);
@@ -165,17 +166,14 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
// 1. 根据检验项目名称查询诊疗定义(检验项目)
String itemName = labApplyItemDto.getItemName();
Long activityDefinitionId = activityDefinitionService.getAppointActivityDefinitionId(itemName);
// log.debug("检验项目:{} 对应的诊疗定义 ID: {}", itemName, activityDefinitionId);
if (activityDefinitionId == null) {
// log.error("未找到检验项目对应的诊疗定义:{}", itemName);
throw new RuntimeException("未找到检验项目 '" + itemName + "' 对应的诊疗定义");
}
// 2. 获取诊疗定义详情
ActivityDefinition activityDefinition = activityDefinitionService.getById(activityDefinitionId);
if (activityDefinition == null) {
// log.error("诊疗定义不存在ID: {}", activityDefinitionId);
throw new RuntimeException("诊疗定义不存在");
}
@@ -199,7 +197,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
// 4. 创建医嘱保存对象
AdviceSaveDto adviceSaveDto = new AdviceSaveDto();
// 设置医嘱操作类型
adviceSaveDto.setDbOpType("1"); // 1:新增
adviceSaveDto.setDbOpType(DbOpType.INSERT.getCode());
// 设置医嘱类型
adviceSaveDto.setAdviceType(3); // 3:项目(检验项目)
@@ -229,22 +227,17 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
// 开方科室 ID - AdviceSaveDto 构造函数已设置,这里可覆盖
adviceSaveDto.setFounderOrgId(SecurityUtils.getDeptId());
// 账户 ID - 获取就诊的账户(多级回退策略)
// log.debug("获取就诊 id 的参数:{}", doctorStationLabApplyDto.getEncounterId());
Long accountId = accountService.getSelfPayAccount(doctorStationLabApplyDto.getEncounterId());
if (accountId == null) {
// log.warn("未找到就诊 ID {} 对应的自费账户,尝试获取医保账户", doctorStationLabApplyDto.getEncounterId());
accountId = accountService.getMedicalInsuranceAccount(doctorStationLabApplyDto.getEncounterId());
}
if (accountId == null) {
// log.warn("未找到就诊 ID {} 对应的医保账户,尝试获取任何账户", doctorStationLabApplyDto.getEncounterId());
List<Account> accountList = accountService.getAccountListByEncounter(doctorStationLabApplyDto.getEncounterId());
if (accountList != null && !accountList.isEmpty()) {
accountId = accountList.get(0).getId();
// log.info("使用就诊 ID {} 的第一个账户ID: {}", doctorStationLabApplyDto.getEncounterId(), accountId);
}
}
if (accountId == null) {
// log.error("就诊 ID {} 没有任何关联的账户", doctorStationLabApplyDto.getEncounterId());
throw new RuntimeException("未找到就诊对应的账户,请确认患者已完成挂号并拥有有效的账户");
}
adviceSaveDto.setAccountId(accountId);
@@ -279,9 +272,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
// 调用门诊医嘱保存接口,创建关联的医嘱记录
try {
iDoctorStationAdviceAppService.saveAdvice(adviceSaveParam, "1"); // "1"表示保存操作
// log.info("成功创建与检验申请单 [{}] 关联的门诊医嘱记录", doctorStationLabApplyDto.getApplyNo());
} catch (Exception e) {
// log.error("创建与检验申请单 [{}] 关联的门诊医嘱记录失败:{}", doctorStationLabApplyDto.getApplyNo(), e.getMessage(), e);
throw new RuntimeException("创建关联医嘱记录失败", e);
}
return R.ok();
@@ -335,51 +326,51 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
@Transactional(rollbackFor = Exception.class)
public R<?> deleteInspectionLabApply(String applyNo) {
log.debug("删除检验申请单 [{}]", applyNo);
try {
// 1. 根据申请单号查询检验申请单信息
InspectionLabApply inspectionLabApply = inspectionLabApplyService.getOne(
new QueryWrapper<InspectionLabApply>().eq("apply_no", applyNo)
);
if (inspectionLabApply == null) {
log.warn("未找到申请单号为 [{}] 的检验申请单", applyNo);
return R.fail("未找到对应的检验申请单");
}
// 2. 删除关联的门诊医嘱
deleteAssociatedAdvice(applyNo);
// 3. 删除检验申请单明细
deleteInspectionLabApplyItems(applyNo);
// 4. 删除条码数据
deleteBarCodeData(applyNo);
// 5. 删除检验申请单主表数据,并设置更新人和更新时间
// 2. 获取当前登录用户和时间
String currentUsername = SecurityUtils.getUsername();
Date currentTime = new Date();
boolean deleteResult = inspectionLabApplyService.update(
// 3. 删除检验申请单主表数据,并设置更新人和更新时间
boolean deleteMainResult = inspectionLabApplyService.update(
new LambdaUpdateWrapper<InspectionLabApply>()
.set(InspectionLabApply::getDeleteFlag, "1")
.set(InspectionLabApply::getDeleteFlag, DelFlag.YES.getCode())
.set(InspectionLabApply::getUpdateBy, currentUsername)
.set(InspectionLabApply::getUpdateTime, currentTime)
.eq(InspectionLabApply::getApplyNo, applyNo)
);
if (deleteResult) {
log.debug("成功删除申请单号为 [{}] 的检验申请单及相关数据,更新人:{},更新时间:{}",
applyNo, currentUsername, currentTime);
return R.ok("删除成功");
} else {
if (!deleteMainResult) {
log.error("删除申请单号为 [{}] 的检验申请单失败", applyNo);
// 手动抛出异常,确保事务回滚
throw new RuntimeException("删除检验申请单失败,申请单号:" + applyNo);
}
// 4. 删除检验申请单明细
deleteInspectionLabApplyItems(applyNo);
// 5. 删除条码数据
deleteBarCodeData(applyNo);
// 6. 删除关联的门诊医嘱
deleteAssociatedAdvice(applyNo);
log.debug("成功删除申请单号为 [{}] 的检验申请单及相关数据,更新人:{},更新时间:{}",
applyNo, currentUsername, currentTime);
return R.ok("删除成功");
} catch (Exception e) {
log.error("删除检验申请单 [{}] 时发生异常,事务将回滚", applyNo, e);
// 重新抛出异常,确保事务回滚
throw new RuntimeException("删除检验申请单过程中发生异常:" + e.getMessage(), e);
}
}
@@ -404,7 +395,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
Date currentTime = new Date();
boolean updateResult = serviceRequestService.update(
new LambdaUpdateWrapper<ServiceRequest>()
.set(ServiceRequest::getDeleteFlag, "1")
.set(ServiceRequest::getDeleteFlag, DelFlag.YES.getCode())
.set(ServiceRequest::getUpdateBy, currentUsername)
.set(ServiceRequest::getUpdateTime, currentTime)
.in(ServiceRequest::getId, requestIds)
@@ -474,7 +465,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
Date currentTime = new Date();
boolean deleteResult = inspectionLabApplyItemService.update(
new LambdaUpdateWrapper<InspectionLabApplyItem>()
.set(InspectionLabApplyItem::getDeleteFlag, "1")
.set(InspectionLabApplyItem::getDeleteFlag, DelFlag.YES.getCode())
.set(InspectionLabApplyItem::getUpdateBy, currentUsername)
.set(InspectionLabApplyItem::getUpdateTime, currentTime)
.eq(InspectionLabApplyItem::getApplyNo, applyNo)
@@ -504,7 +495,7 @@ public class DoctorStationLabApplyServiceImpl implements IDoctorStationInspectio
Date currentTime = new Date();
boolean deleteResult = inspectionLabBarCodeService.update(
new LambdaUpdateWrapper<BarCode>()
.set(BarCode::getDeleteFlag, "1")
.set(BarCode::getDeleteFlag, DelFlag.YES.getCode())
.set(BarCode::getUpdateBy, currentUsername)
.set(BarCode::getUpdateTime, currentTime)
.eq(BarCode::getApplyNo, applyNo)