fix(core): 修复审计字段缺失和组件状态管理问题

- 在Account、ChargeItem、EncounterParticipant和Encounter服务中添加审计字段验证
- 确保tenantId、createBy和createTime字段在插入数据库前正确设置
- 修复EMR模块中删除模板API的导出问题
- 更新患者信息状态管理,统一使用localPatientInfo替换patientInfo
- 在EMR组件中实现防抖机制优化历史记录刷新性能
- 修复病历模板切换时的表单数据重置逻辑
- 在首页统计组件中使用markRaw包装图标组件
- 为住院记录模板添加默认表单数据结构
- 修复SVG患者图标路径错误
This commit is contained in:
2026-01-25 16:41:19 +08:00
parent 6382741b71
commit 5cf2dd165c
17 changed files with 493 additions and 116 deletions

View File

@@ -1419,6 +1419,19 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
}
}
// 确保所有PaymentRecDetail对象的审计字段被设置防止违反NOT NULL约束
for (PaymentRecDetail detail : paymentRecDetails) {
if (detail.getTenantId() == null) {
detail.setTenantId(SecurityUtils.getLoginUser().getTenantId());
}
if (detail.getCreateBy() == null || detail.getCreateBy().isEmpty()) {
detail.setCreateBy(SecurityUtils.getLoginUser().getUsername());
}
if (detail.getCreateTime() == null) {
detail.setCreateTime(new Date());
}
}
paymentRecDetailService.saveBatch(paymentRecDetails);
}
@@ -1754,6 +1767,17 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
BeanUtils.copyProperties(outpatientRegistrationAddParam.getChargeItemFormData(), chargeItem);
chargeItem.setContextEnum(ChargeItemContext.REGISTER.getValue());// 挂号
// 确保必需的审计字段被设置防止违反NOT NULL约束
if (chargeItem.getTenantId() == null) {
chargeItem.setTenantId(SecurityUtils.getLoginUser().getTenantId());
}
if (chargeItem.getCreateBy() == null || chargeItem.getCreateBy().isEmpty()) {
chargeItem.setCreateBy(SecurityUtils.getLoginUser().getUsername());
}
if (chargeItem.getCreateTime() == null) {
chargeItem.setCreateTime(new Date());
}
YbPsnSetlWay finCategory = YbPsnSetlWay.getByValue(outpatientRegistrationAddParam.getYbPsnSetlWay());
if (finCategory == null) {
throw new ServiceException("请选择收费方式");
@@ -1818,11 +1842,23 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
// 保存就诊信息
Encounter encounter = new Encounter();
BeanUtils.copyProperties(encounterFormData, encounter);
// 将挂号医生ID提前塞入 encounter 的 registrarId便于生成科室+医生+当日序号
// 将挂号医生ID提前塞入 encounter 的 registrarId便于生成"科室+医生+当日"序号
if (encounterParticipantFormData.getPractitionerId() != null) {
encounter.setRegistrarId(encounterParticipantFormData.getPractitionerId());
}
encounter.setBusNo(outpatientRegistrationSettleParam.getBusNo());
// 确保必需的审计字段被设置防止违反NOT NULL约束
if (encounter.getTenantId() == null) {
encounter.setTenantId(SecurityUtils.getLoginUser().getTenantId());
}
if (encounter.getCreateBy() == null || encounter.getCreateBy().isEmpty()) {
encounter.setCreateBy(SecurityUtils.getLoginUser().getUsername());
}
if (encounter.getCreateTime() == null) {
encounter.setCreateTime(new Date());
}
// 就诊ID
Long encounterId = iEncounterService.saveEncounterByRegister(encounter);
// 保存就诊位置信息
@@ -1920,6 +1956,18 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
.setChargeItemIds(chargeItemIdList.stream().map(String::valueOf).collect(Collectors.joining(",")))
.setTenderedAmount(chargeItem.getTotalPrice()).setDisplayAmount(paymentResult.getPsnPartAmt())
.setReturnedAmount(new BigDecimal("0.0")).setEncounterId(encounter.getId());
// 确保必需的审计字段被设置防止违反NOT NULL约束
if (payment.getTenantId() == null) {
payment.setTenantId(SecurityUtils.getLoginUser().getTenantId());
}
if (payment.getCreateBy() == null || payment.getCreateBy().isEmpty()) {
payment.setCreateBy(SecurityUtils.getLoginUser().getUsername());
}
if (payment.getCreateTime() == null) {
payment.setCreateTime(new Date());
}
// 保存付款信息
paymentReconciliationService.save(payment);
// 保存付款详情
@@ -1938,6 +1986,18 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
invoice.setPatientId(encounter.getPatientId()).setStatusEnum(InvoiceStatus.DRAFT)
.setReconciliationId(payment.getId()).setTypeCode(InvoiceType.ISSUING_INVOICES.getValue())
.setChargeItemIds(payment.getChargeItemIds().toString());
// 确保必需的审计字段被设置防止违反NOT NULL约束
if (invoice.getTenantId() == null) {
invoice.setTenantId(SecurityUtils.getLoginUser().getTenantId());
}
if (invoice.getCreateBy() == null || invoice.getCreateBy().isEmpty()) {
invoice.setCreateBy(SecurityUtils.getLoginUser().getUsername());
}
if (invoice.getCreateTime() == null) {
invoice.setCreateTime(new Date());
}
iInvoiceService.save(invoice);
return R.ok(payment, "收费成功");
}