From f69de5e78fbdddd33f7b171cb5e61a66cb585be6 Mon Sep 17 00:00:00 2001 From: HuangXinQuan Date: Thu, 5 Feb 2026 16:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E6=8E=92=E7=8F=AD=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E7=9A=84=E6=AD=A3=E7=A1=AE=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appservice/IDoctorScheduleAppService.java | 2 + .../impl/DoctorScheduleAppServiceImpl.java | 113 ++++++++++++++++++ .../controller/DoctorScheduleController.java | 11 ++ .../domain/DoctorSchedule.java | 4 + .../api/appointmentmanage/doctorSchedule.js | 9 ++ .../views/appoinmentmanage/deptManage/api.js | 13 ++ .../deptManage/doctorschedule/index.vue | 10 +- .../appoinmentmanage/deptManage/index.vue | 5 +- 8 files changed, 161 insertions(+), 6 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/IDoctorScheduleAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/IDoctorScheduleAppService.java index 8ab7b393..d2eececd 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/IDoctorScheduleAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/IDoctorScheduleAppService.java @@ -15,6 +15,8 @@ public interface IDoctorScheduleAppService { R addDoctorSchedule(DoctorSchedule doctorSchedule); + R addDoctorScheduleWithDate(DoctorSchedule doctorSchedule, String scheduledDate); + R updateDoctorSchedule(DoctorSchedule doctorSchedule); R removeDoctorSchedule(Integer doctorScheduleId); diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/impl/DoctorScheduleAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/impl/DoctorScheduleAppServiceImpl.java index 52d9d1d8..df765713 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/impl/DoctorScheduleAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/appservice/impl/DoctorScheduleAppServiceImpl.java @@ -177,6 +177,66 @@ public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService { } } + @Override + public R addDoctorScheduleWithDate(DoctorSchedule doctorSchedule, String scheduledDate) { + if (ObjectUtil.isEmpty(doctorSchedule)) { + return R.fail("医生排班不能为空"); + } + + if (doctorSchedule.getLimitNumber() == null || doctorSchedule.getLimitNumber() <= 0) { + return R.fail("限号数量必须大于0"); + } + + // 创建新对象,排除id字段(数据库id列是GENERATED ALWAYS,由数据库自动生成) + DoctorSchedule newSchedule = new DoctorSchedule(); + newSchedule.setWeekday(doctorSchedule.getWeekday()); + newSchedule.setTimePeriod(doctorSchedule.getTimePeriod()); + newSchedule.setDoctor(doctorSchedule.getDoctor()); + newSchedule.setClinic(doctorSchedule.getClinic()); + newSchedule.setStartTime(doctorSchedule.getStartTime()); + newSchedule.setEndTime(doctorSchedule.getEndTime()); + newSchedule.setLimitNumber(doctorSchedule.getLimitNumber()); + // call_sign_record 字段不能为null,设置默认值为空字符串 + newSchedule.setCallSignRecord(doctorSchedule.getCallSignRecord() != null ? doctorSchedule.getCallSignRecord() : ""); + newSchedule.setRegisterItem(doctorSchedule.getRegisterItem() != null ? doctorSchedule.getRegisterItem() : ""); + newSchedule.setRegisterFee(doctorSchedule.getRegisterFee() != null ? doctorSchedule.getRegisterFee() : 0); + newSchedule.setDiagnosisItem(doctorSchedule.getDiagnosisItem() != null ? doctorSchedule.getDiagnosisItem() : ""); + newSchedule.setDiagnosisFee(doctorSchedule.getDiagnosisFee() != null ? doctorSchedule.getDiagnosisFee() : 0); + newSchedule.setIsOnline(doctorSchedule.getIsOnline() != null ? doctorSchedule.getIsOnline() : true); + newSchedule.setIsStopped(doctorSchedule.getIsStopped() != null ? doctorSchedule.getIsStopped() : false); + newSchedule.setStopReason(doctorSchedule.getStopReason() != null ? doctorSchedule.getStopReason() : ""); + newSchedule.setDeptId(doctorSchedule.getDeptId()); + newSchedule.setDoctorId(doctorSchedule.getDoctorId()); + + // 不设置id字段,让数据库自动生成 + // 使用自定义的insertWithoutId方法,确保INSERT语句不包含id字段 + int result = doctorScheduleMapper.insertWithoutId(newSchedule); + + if (result > 0) { + // 创建号源池,并传入正确的医生ID和具体日期 + SchedulePool pool = createSchedulePoolWithDate(newSchedule, doctorSchedule.getDoctorId(), scheduledDate); + boolean poolSaved = schedulePoolService.save(pool); + + if (poolSaved) { + // 创建号源槽 + List slots = createScheduleSlots(pool.getId().intValue(), newSchedule.getLimitNumber(), + newSchedule.getStartTime(), newSchedule.getEndTime()); + boolean slotsSaved = scheduleSlotService.saveBatch(slots); + + if (slotsSaved) { + return R.ok(newSchedule); + } else { + throw new RuntimeException("创建号源槽失败"); + } + } + else { + throw new RuntimeException("创建号源池失败"); + } + } else { + return R.fail("保存排班信息失败"); + } + } + @Override public R updateDoctorSchedule(DoctorSchedule doctorSchedule) { if (ObjectUtil.isEmpty(doctorSchedule) || ObjectUtil.isEmpty(doctorSchedule.getId())) { @@ -227,6 +287,59 @@ public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService { return pool; } + /** + * 创建号源池(使用具体日期) + */ + private SchedulePool createSchedulePoolWithDate(DoctorSchedule schedule, Long doctorId, String scheduledDateStr) { + SchedulePool pool = new SchedulePool(); + // 生成唯一池编码 + pool.setPoolCode("POOL_" + System.currentTimeMillis()); + pool.setHospitalId(1L); // 默认医院ID,实际项目中应从上下文获取 + pool.setDoctorId(doctorId); // 使用正确的医生ID + pool.setDoctorName(schedule.getDoctor()); + pool.setDeptId(schedule.getDeptId()); + pool.setClinicRoom(schedule.getClinic()); + + // 使用传入的具体日期 + if (scheduledDateStr != null && !scheduledDateStr.isEmpty()) { + try { + LocalDate scheduledDate = LocalDate.parse(scheduledDateStr); + pool.setScheduleDate(scheduledDate); + } catch (Exception e) { + // 如果解析失败,回退到原来的计算方式 + pool.setScheduleDate(calculateScheduleDate(schedule.getWeekday())); + } + } else { + // 如果没有提供具体日期,使用原来的计算方式 + pool.setScheduleDate(calculateScheduleDate(schedule.getWeekday())); + } + + pool.setShift(schedule.getTimePeriod()); + pool.setStartTime(schedule.getStartTime()); + pool.setEndTime(schedule.getEndTime()); + pool.setTotalQuota(schedule.getLimitNumber()); + pool.setBookedNum(0); + pool.setLockedNum(0); + // 不设置available_num,因为它是数据库生成列 + // pool.setAvailableNum(0); // 初始为0,稍后更新 + pool.setRegType(schedule.getRegisterItem() != null ? schedule.getRegisterItem() : "普通"); + pool.setFee(schedule.getRegisterFee() != null ? schedule.getRegisterFee() / 100.0 : 0.0); // 假设数据库中以分为单位存储 + pool.setInsurancePrice(pool.getFee()); // 医保价格暂时与原价相同 + // 暂时设置support_channel为空字符串,避免JSON类型问题 + pool.setSupportChannel(""); + pool.setStatus(1); // 1表示可用 + + // 设置时间字段 + java.util.Date now = new java.util.Date(); + java.util.Date tomorrow = new java.util.Date(System.currentTimeMillis() + 24 * 60 * 60 * 1000); // 明天的时间 + + pool.setReleaseTime(now); + pool.setDeadlineTime(tomorrow); // 截止时间为明天 + pool.setScheduleId(schedule.getId()); + + return pool; + } + /** * 创建号源槽 */ diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/controller/DoctorScheduleController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/controller/DoctorScheduleController.java index c5db53e2..77ab066a 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/controller/DoctorScheduleController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointmentmanage/controller/DoctorScheduleController.java @@ -51,6 +51,17 @@ public class DoctorScheduleController { return doctorScheduleAppService.addDoctorSchedule(doctorSchedule); } + /* + * 新增医生排班(带具体日期) + * + * */ + @PostMapping("/add-with-date") + public R addDoctorScheduleWithDate(@RequestBody DoctorSchedule doctorSchedule) { + // 从DoctorSchedule对象中获取scheduledDate字段 + String scheduledDate = doctorSchedule.getScheduledDate(); + return doctorScheduleAppService.addDoctorScheduleWithDate(doctorSchedule, scheduledDate); + } + /* * 修改医生排班 * diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/domain/DoctorSchedule.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/domain/DoctorSchedule.java index 9bb16b3b..0766f4d5 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/domain/DoctorSchedule.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/appointmentmanage/domain/DoctorSchedule.java @@ -74,4 +74,8 @@ public class DoctorSchedule extends HisBaseEntity { /** 医生ID - 不映射到数据库表字段,仅作传输使用 */ private Long doctorId; + + /** 排班日期 - 不映射到数据库表字段,仅作传输使用 */ + @TableField(exist = false) + private String scheduledDate; } diff --git a/openhis-ui-vue3/src/api/appointmentmanage/doctorSchedule.js b/openhis-ui-vue3/src/api/appointmentmanage/doctorSchedule.js index 6ff52358..31634aec 100644 --- a/openhis-ui-vue3/src/api/appointmentmanage/doctorSchedule.js +++ b/openhis-ui-vue3/src/api/appointmentmanage/doctorSchedule.js @@ -25,6 +25,15 @@ export function addDoctorSchedule(data) { }) } +// 添加医生排班(带具体日期) +export function addDoctorScheduleWithDate(data) { + return request({ + url: '/appointment/doctor-schedule/add-with-date', + method: 'post', + data: data + }) +} + // 更新医生排班 export function updateDoctorSchedule(data) { return request({ diff --git a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/api.js b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/api.js index 0c2defae..4fed6eeb 100644 --- a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/api.js +++ b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/api.js @@ -13,6 +13,19 @@ export function addDoctorSchedule(data) { }) } +/** + * 添加医生排班(带具体日期) + * @param {Object} data - 排班数据 + * @returns {Promise} + */ +export function addDoctorScheduleWithDate(data) { + return request({ + url: '/doctor-schedule/add-with-date', + method: 'post', + data: data + }) +} + /** * 更新医生排班 * @param {Object} data - 排班数据 (必须包含ID) diff --git a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/doctorschedule/index.vue b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/doctorschedule/index.vue index 9be77b1e..242be4ef 100644 --- a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/doctorschedule/index.vue +++ b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/doctorschedule/index.vue @@ -239,7 +239,7 @@ import {computed, onMounted, ref, watch} from 'vue' import {useRoute, useRouter} from 'vue-router' import {ElDialog, ElMessage, ElMessageBox} from 'element-plus' import {View} from '@element-plus/icons-vue' -import {addDoctorSchedule, deleteDoctorSchedule} from '../api' +import {addDoctorSchedule, addDoctorScheduleWithDate, deleteDoctorSchedule} from '../api' // 路由和导航 const route = useRoute() @@ -587,6 +587,7 @@ const handleSave = async () => { isStopped: item.stopClinic || false, stopReason: item.stopClinic ? (item.stopReason || '') : '', deptId: currentDept.value?.id || route.query.deptId || null, + scheduledDate: item.date // 添加具体日期字段 } } }) @@ -608,13 +609,14 @@ const handleSave = async () => { let successCount = 0 let failCount = 0 const errors = [] - + for (const { localIndex, localId, scheduleData } of newSchedulesToSave) { try { // 确保新记录的id为null scheduleData.id = null - - const res = await addDoctorSchedule(scheduleData) + + // 使用带日期的API,日期信息已包含在scheduleData中 + const res = await addDoctorScheduleWithDate(scheduleData) if (res.code === 200 && res.data) { successCount++ // 更新本地记录的backendId diff --git a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue index 507a6938..5a374a4a 100644 --- a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue +++ b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue @@ -377,7 +377,7 @@ import {ElDialog, ElForm, ElFormItem, ElInput, ElMessage, ElMessageBox, ElOption import {DocumentRemove, EditPen, View, Delete} from '@element-plus/icons-vue' import {listDept, searchDept} from '@/api/appoinmentmanage/dept' import {getLocationTree, getPractitionerMetadata, getHealthcareMetadata} from '@/views/charge/outpatientregistration/components/outpatientregistration' -import {addDoctorSchedule, updateDoctorSchedule, deleteDoctorSchedule, getRegisterOrganizations, getDoctorScheduleListByDeptId} from './api' +import {addDoctorSchedule, addDoctorScheduleWithDate, updateDoctorSchedule, deleteDoctorSchedule, getRegisterOrganizations, getDoctorScheduleListByDeptId} from './api' import {getClinicRoomList} from '@/api/appoinmentmanage/clinicRoom' import {getInitOption, getRegistrationItems, getClinicItems} from '@/views/basicservices/registrationfee/components/registrationfee' import { deptTreeSelect } from '@/api/system/user' @@ -1534,6 +1534,7 @@ const handleSave = async () => { isStopped: item.stopClinic, stopReason: item.stopClinic ? (item.stopReason || '') : '', deptId: currentDept.value?.id || null, + scheduledDate: item.date // 添加具体日期字段 }; if (item.backendId) { scheduleData.id = item.backendId; @@ -1557,7 +1558,7 @@ const handleSave = async () => { // 处理新增 for (const { scheduleData } of recordsToAdd) { try { - const res = await addDoctorSchedule(scheduleData); + const res = await addDoctorScheduleWithDate(scheduleData); if (res.code === 200) { addSuccess++; } else {