fix(surgical): 修复手术安排冲突检测逻辑
- 添加了对重复手术安排校验的注释说明,确保执行顺序正确 - 修复了手术室占用检测的时间范围判断条件 - 增加了对空值的安全检查避免潜在异常 - 在SQL查询中添加了删除标记过滤条件 - 统一了变量命名提高代码可读性
This commit is contained in:
@@ -95,7 +95,7 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验是否重复手术安排
|
// 校验是否重复手术安排(必须在校验手术间占用之前执行,确保能正确返回重复错误)
|
||||||
// 同一患者 + 同一手术单号 + 同一手术名称 只能有一条有效安排记录
|
// 同一患者 + 同一手术单号 + 同一手术名称 只能有一条有效安排记录
|
||||||
if (opCreateScheduleDto.getPatientId() != null
|
if (opCreateScheduleDto.getPatientId() != null
|
||||||
&& opCreateScheduleDto.getOperCode() != null && !opCreateScheduleDto.getOperCode().isEmpty()
|
&& opCreateScheduleDto.getOperCode() != null && !opCreateScheduleDto.getOperCode().isEmpty()
|
||||||
@@ -105,18 +105,20 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
|||||||
opCreateScheduleDto.getOperCode(),
|
opCreateScheduleDto.getOperCode(),
|
||||||
opCreateScheduleDto.getOperName()
|
opCreateScheduleDto.getOperName()
|
||||||
);
|
);
|
||||||
if (existsDuplicate) {
|
if (existsDuplicate != null && existsDuplicate) {
|
||||||
return R.fail("该患者此手术单号已存在手术安排,请勿重复提交");
|
return R.fail("该患者此手术单号已存在手术安排,请勿重复提交");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//校验该时段内手术间是否被占用
|
// 校验该时段内手术间是否被占用
|
||||||
LocalDateTime scheduleDate = opCreateScheduleDto.getEntryTime();//入室时间
|
LocalDateTime startTime = opCreateScheduleDto.getEntryTime();//入室时间
|
||||||
String roomCode = opCreateScheduleDto.getRoomCode();//手术室编号
|
|
||||||
LocalDateTime endTime = opCreateScheduleDto.getEndTime();//手术结束时间
|
LocalDateTime endTime = opCreateScheduleDto.getEndTime();//手术结束时间
|
||||||
Boolean scheduleConflict = surgicalScheduleAppMapper.isScheduleConflict(scheduleDate, endTime, roomCode);
|
String roomCode = opCreateScheduleDto.getRoomCode();//手术室编号
|
||||||
if (scheduleConflict) {
|
if (startTime != null && endTime != null && roomCode != null && !roomCode.isEmpty()) {
|
||||||
return R.fail("该时段内手术间被占用");
|
Boolean scheduleConflict = surgicalScheduleAppMapper.isScheduleConflict(startTime, endTime, roomCode);
|
||||||
|
if (scheduleConflict != null && scheduleConflict) {
|
||||||
|
return R.fail("该时段内手术间被占用");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginUser loginUser = new LoginUser();
|
LoginUser loginUser = new LoginUser();
|
||||||
|
|||||||
@@ -140,9 +140,11 @@
|
|||||||
</select>
|
</select>
|
||||||
<!-- 查询时间段内该手术室是否被占用-->
|
<!-- 查询时间段内该手术室是否被占用-->
|
||||||
<select id="isScheduleConflict" resultType="java.lang.Boolean">
|
<select id="isScheduleConflict" resultType="java.lang.Boolean">
|
||||||
SELECT COUNT(*) > 0 FROM op_schedule WHERE room_code = #{surgeryRoomId}
|
SELECT COUNT(*) > 0 FROM op_schedule
|
||||||
AND entry_time >= #{startTime}
|
WHERE room_code = #{surgeryRoomId}
|
||||||
AND end_time < #{endTime}
|
AND entry_time <= #{endTime}
|
||||||
|
AND end_time >= #{startTime}
|
||||||
|
AND delete_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 检查是否存在重复的手术安排 -->
|
<!-- 检查是否存在重复的手术安排 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user