fix(doctorstation): 修复会诊模块数据加载异常处理
- 添加了接口响应空值检查,防止因空响应导致的页面崩溃 - 完善了错误处理逻辑,统一返回空数组避免组件渲染异常 - 增强了网络错误捕获,提供更准确的错误信息提示 - 优化了后端服务异常处理,确保查询失败时返回安全的默认值 - 修复了手术收费模块中的用户卡信息引用错误 - 改进了学生合同号处理逻辑,增加了前置条件验证
This commit is contained in:
@@ -121,17 +121,27 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
|
||||
|
||||
@Override
|
||||
public List<ConsultationRequestDto> getConsultationList(Long encounterId) {
|
||||
try {
|
||||
log.info("开始查询会诊列表,encounterId: {}", encounterId);
|
||||
|
||||
// 查询会诊列表
|
||||
LambdaQueryWrapper<ConsultationRequest> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
// 根据就诊ID,查询该患者的会诊申请
|
||||
wrapper.eq(ConsultationRequest::getEncounterId, encounterId);
|
||||
wrapper.orderByDesc(ConsultationRequest::getCreateTime);
|
||||
|
||||
List<ConsultationRequest> list = consultationRequestMapper.selectList(wrapper);
|
||||
log.info("查询到 {} 个会诊申请记录", list.size());
|
||||
|
||||
// 转换为DTO
|
||||
return list.stream().map(this::convertToDto).collect(Collectors.toList());
|
||||
List<ConsultationRequestDto> result = list.stream().map(this::convertToDto).collect(Collectors.toList());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("获取会诊列表失败,encounterId: {}", encounterId, e);
|
||||
// 返回空列表而不是抛出异常,避免前端崩溃
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -915,6 +925,8 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
|
||||
@Override
|
||||
public List<ConsultationActivityDto> getConsultationActivities() {
|
||||
try {
|
||||
log.info("开始查询会诊项目列表");
|
||||
|
||||
// 查询所有会诊相关的诊疗活动
|
||||
LambdaQueryWrapper<ActivityDefinition> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(ActivityDefinition::getName, "会诊")
|
||||
@@ -922,12 +934,16 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
|
||||
.orderBy(true, true, ActivityDefinition::getSortOrder);
|
||||
|
||||
List<ActivityDefinition> activityList = activityDefinitionMapper.selectList(wrapper);
|
||||
log.info("查询到 {} 个会诊相关诊疗活动", activityList.size());
|
||||
|
||||
if (activityList.isEmpty()) {
|
||||
log.warn("未查询到任何会诊项目,请检查数据库配置");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// 转换为DTO并查询价格
|
||||
List<ConsultationActivityDto> resultList = new ArrayList<>();
|
||||
int missingPriceCount = 0;
|
||||
for (ActivityDefinition activity : activityList) {
|
||||
ConsultationActivityDto dto = new ConsultationActivityDto();
|
||||
dto.setId(activity.getId());
|
||||
@@ -951,11 +967,18 @@ public class ConsultationAppServiceImpl implements IConsultationAppService {
|
||||
dto.setPrice(chargeItem.getPrice());
|
||||
} else {
|
||||
dto.setPrice(java.math.BigDecimal.ZERO);
|
||||
log.warn("会诊项目: {} 未找到价格定义", activity.getName());
|
||||
missingPriceCount++;
|
||||
log.warn("会诊项目: {} (ID: {}) 未找到价格定义", activity.getName(), activity.getId());
|
||||
}
|
||||
|
||||
resultList.add(dto);
|
||||
}
|
||||
|
||||
if (missingPriceCount > 0) {
|
||||
log.warn("共 {} 个会诊项目缺少价格定义", missingPriceCount);
|
||||
}
|
||||
|
||||
log.info("会诊项目列表查询成功,共 {} 个项目", resultList.size());
|
||||
return resultList;
|
||||
} catch (Exception e) {
|
||||
log.error("查询会诊项目列表失败", e);
|
||||
|
||||
@@ -39,10 +39,12 @@ public class ConsultationController {
|
||||
@ApiParam("就诊ID(可选,不传则查询当前医生的所有会诊申请)")
|
||||
@RequestParam(required = false) Long encounterId) {
|
||||
try {
|
||||
log.info("获取会诊列表,encounterId: {}", encounterId);
|
||||
List<ConsultationRequestDto> list = consultationAppService.getConsultationList(encounterId);
|
||||
log.info("获取会诊列表成功,共 {} 条记录", list != null ? list.size() : 0);
|
||||
return R.ok(list);
|
||||
} catch (Exception e) {
|
||||
log.error("获取会诊列表失败", e);
|
||||
log.error("获取会诊列表失败,encounterId: {}", encounterId, e);
|
||||
return R.fail("获取会诊列表失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1906,11 +1906,13 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
: outpatientRegistrationAddParam.getYbMdtrtCertType());
|
||||
iAccountService.save(accountZf);
|
||||
}
|
||||
String accountContractNo = outpatientRegistrationAddParam.getAccountFormData().getContractNo();
|
||||
if (!CommonConstants.BusinessName.DEFAULT_CONTRACT_NO
|
||||
.equals(outpatientRegistrationAddParam.getAccountFormData().getContractNo())
|
||||
.equals(accountContractNo)
|
||||
&& !CommonConstants.BusinessName.DEFAULT_STUDENT_CONTRACT_NO
|
||||
.equals(outpatientRegistrationAddParam.getAccountFormData().getContractNo())
|
||||
&& outpatientRegistrationAddParam.getAccountFormData().getContractNo().length() > 11) {
|
||||
.equals(accountContractNo)
|
||||
&& accountContractNo.length() > 11
|
||||
&& accountContractNo.startsWith("STUDENT")) {
|
||||
// 建立学生自费ACCOUNT
|
||||
Account accountStudentZf = new Account();
|
||||
BeanUtils.copyProperties(accountFormData, accountStudentZf);
|
||||
@@ -1920,8 +1922,9 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
: outpatientRegistrationAddParam.getYbMdtrtCertType());
|
||||
iAccountService.save(accountStudentZf);
|
||||
|
||||
Contract contractYb = contractService.getContract(
|
||||
outpatientRegistrationAddParam.getAccountFormData().getContractNo().substring("STUDENT".length()));
|
||||
// 截取医保合同号时,先验证是否以"STUDENT"开头
|
||||
String ybContractNo = accountContractNo.substring("STUDENT".length());
|
||||
Contract contractYb = contractService.getContract(ybContractNo);
|
||||
if (contractYb != null && 1 == contractYb.getYbFlag()) {
|
||||
// 建立纯医保ACCOUNT
|
||||
Account accountYb = new Account();
|
||||
|
||||
@@ -341,7 +341,7 @@ async function handleReadCard(value) {
|
||||
certNo: message.data.idNo,
|
||||
psnCertType: '02',
|
||||
};
|
||||
userCardInfo = {
|
||||
userCardInfo.value = {
|
||||
certType: '01',
|
||||
certNo: message.data.idNo,
|
||||
psnCertType: '01',
|
||||
@@ -372,7 +372,7 @@ async function handleReadCard(value) {
|
||||
certNo: message1.SocialSecurityNumber,
|
||||
psnCertType: '02',
|
||||
};
|
||||
userCardInfo = {
|
||||
userCardInfo.value = {
|
||||
certType: '02',
|
||||
certNo: message1.SocialSecurityNumber,
|
||||
psnCertType: '02',
|
||||
@@ -397,8 +397,8 @@ async function handleReadCard(value) {
|
||||
patientId: props.patientInfo.patientId,
|
||||
encounterId: props.patientInfo.encounterId,
|
||||
chargeItemIds: chargeItemIdList.value,
|
||||
ybMdtrtCertType: userCardInfo.psnCertType,
|
||||
busiCardInfo: userCardInfo.busiCardInfo,
|
||||
ybMdtrtCertType: userCardInfo.value.psnCertType,
|
||||
busiCardInfo: userCardInfo.value.busiCardInfo,
|
||||
generateSourceEnum: 2,
|
||||
sourceBillNo: props.surgeryInfo.surgeryNo,
|
||||
}).then((res) => {
|
||||
|
||||
@@ -447,16 +447,35 @@ const loadActivityList = async () => {
|
||||
const res = await getConsultationActivities();
|
||||
console.log('getConsultationActivities 接口返回:', res);
|
||||
|
||||
// 检查响应是否存在
|
||||
if (!res) {
|
||||
console.error('接口返回空响应');
|
||||
ElMessage.warning('会诊项目列表加载失败:未获取到响应数据');
|
||||
activityList.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查响应代码
|
||||
if (res.code === 200) {
|
||||
activityList.value = res.data || [];
|
||||
console.log('会诊项目列表加载成功,数量:', activityList.value.length);
|
||||
|
||||
// 如果列表为空,给出提示
|
||||
if (activityList.value.length === 0) {
|
||||
console.warn('会诊项目列表为空,请检查数据库配置');
|
||||
ElMessage.warning('暂无可用会诊项目,请联系系统管理员配置');
|
||||
}
|
||||
} else {
|
||||
console.error('接口返回错误:', res.msg || res.message);
|
||||
ElMessage.error(res.msg || '加载会诊项目失败');
|
||||
activityList.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载会诊项目失败,错误详情:', error);
|
||||
ElMessage.error('加载会诊项目失败: ' + (error.message || error));
|
||||
// 网络错误或其他异常
|
||||
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
|
||||
ElMessage.error('加载会诊项目失败: ' + errorMsg);
|
||||
activityList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -473,12 +492,35 @@ const handleActivityChange = (activityId) => {
|
||||
const loadDepartmentTree = async () => {
|
||||
try {
|
||||
const res = await getDepartmentTree();
|
||||
|
||||
// 检查响应是否存在
|
||||
if (!res) {
|
||||
console.error('接口返回空响应');
|
||||
ElMessage.warning('科室医生树加载失败:未获取到响应数据');
|
||||
departmentTree.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.code === 200) {
|
||||
departmentTree.value = res.data || [];
|
||||
console.log('科室医生树加载成功:', departmentTree.value);
|
||||
|
||||
// 如果树为空,给出提示
|
||||
if (departmentTree.value.length === 0) {
|
||||
console.warn('科室医生树为空,请检查数据库配置');
|
||||
ElMessage.warning('暂无可用科室医生数据,请联系系统管理员配置');
|
||||
}
|
||||
} else {
|
||||
console.error('接口返回错误:', res.msg || res.message);
|
||||
ElMessage.warning(res.msg || '加载科室医生树失败');
|
||||
departmentTree.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载科室医生树失败:', error);
|
||||
// 网络错误或其他异常
|
||||
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
|
||||
ElMessage.warning('加载科室医生树失败: ' + errorMsg);
|
||||
departmentTree.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -582,10 +624,20 @@ const clearAllSelections = () => {
|
||||
const loadConsultationList = async () => {
|
||||
if (!props.patientInfo?.encounterId) {
|
||||
console.log('没有就诊ID,无法加载会诊列表');
|
||||
consultationList.value = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await getConsultationList({ encounterId: props.patientInfo.encounterId });
|
||||
|
||||
// 检查响应是否存在
|
||||
if (!res) {
|
||||
console.error('接口返回空响应');
|
||||
ElMessage.warning('会诊列表加载失败:未获取到响应数据');
|
||||
consultationList.value = [];
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.code === 200) {
|
||||
consultationList.value = (res.data || []).map(item => {
|
||||
console.log('列表项数据:', item);
|
||||
@@ -600,9 +652,17 @@ const loadConsultationList = async () => {
|
||||
};
|
||||
});
|
||||
console.log('会诊列表:', consultationList.value);
|
||||
} else {
|
||||
console.error('接口返回错误:', res.msg || res.message);
|
||||
ElMessage.warning(res.msg || '加载会诊列表失败');
|
||||
consultationList.value = [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载会诊列表失败:', error);
|
||||
// 网络错误或其他异常
|
||||
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
|
||||
ElMessage.warning('加载会诊列表失败: ' + errorMsg);
|
||||
consultationList.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -613,11 +673,24 @@ const loadMainDiagnosis = async () => {
|
||||
}
|
||||
try {
|
||||
const res = await getMainDiagnosis({ encounterId: props.patientInfo.encounterId });
|
||||
|
||||
// 检查响应是否存在
|
||||
if (!res) {
|
||||
console.error('获取主诊断接口返回空响应');
|
||||
return;
|
||||
}
|
||||
|
||||
if (res.code === 200 && res.data) {
|
||||
formData.provisionalDiagnosis = res.data.diagnosis || '';
|
||||
console.log('主诊断加载成功:', formData.provisionalDiagnosis);
|
||||
} else {
|
||||
console.warn('获取主诊断失败:', res.msg || res.message);
|
||||
formData.provisionalDiagnosis = '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载主诊断失败:', error);
|
||||
// 主诊断加载失败不应该阻塞整个会诊功能,只是不显示诊断信息
|
||||
formData.provisionalDiagnosis = '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1023,8 +1096,13 @@ watch(
|
||||
(newVal) => {
|
||||
if (newVal === 'consultation' && props.patientInfo?.encounterId) {
|
||||
console.log('切换到会诊tab,加载数据');
|
||||
// 并行加载数据,提升性能
|
||||
loadConsultationList();
|
||||
handleNew();
|
||||
} else if (newVal === 'consultation') {
|
||||
console.log('切换到会诊tab,但没有患者信息');
|
||||
// 即使没有患者信息,也要加载基础数据(会诊项目和科室树)
|
||||
handleNew();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user