医生排班日期的正确插入
This commit is contained in:
@@ -15,6 +15,8 @@ public interface IDoctorScheduleAppService {
|
|||||||
|
|
||||||
R<?> addDoctorSchedule(DoctorSchedule doctorSchedule);
|
R<?> addDoctorSchedule(DoctorSchedule doctorSchedule);
|
||||||
|
|
||||||
|
R<?> addDoctorScheduleWithDate(DoctorSchedule doctorSchedule, String scheduledDate);
|
||||||
|
|
||||||
R<?> updateDoctorSchedule(DoctorSchedule doctorSchedule);
|
R<?> updateDoctorSchedule(DoctorSchedule doctorSchedule);
|
||||||
|
|
||||||
R<?> removeDoctorSchedule(Integer doctorScheduleId);
|
R<?> removeDoctorSchedule(Integer doctorScheduleId);
|
||||||
|
|||||||
@@ -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<ScheduleSlot> 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
|
@Override
|
||||||
public R<?> updateDoctorSchedule(DoctorSchedule doctorSchedule) {
|
public R<?> updateDoctorSchedule(DoctorSchedule doctorSchedule) {
|
||||||
if (ObjectUtil.isEmpty(doctorSchedule) || ObjectUtil.isEmpty(doctorSchedule.getId())) {
|
if (ObjectUtil.isEmpty(doctorSchedule) || ObjectUtil.isEmpty(doctorSchedule.getId())) {
|
||||||
@@ -227,6 +287,59 @@ public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService {
|
|||||||
return pool;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建号源槽
|
* 创建号源槽
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,17 @@ public class DoctorScheduleController {
|
|||||||
return doctorScheduleAppService.addDoctorSchedule(doctorSchedule);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 修改医生排班
|
* 修改医生排班
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -74,4 +74,8 @@ public class DoctorSchedule extends HisBaseEntity {
|
|||||||
|
|
||||||
/** 医生ID - 不映射到数据库表字段,仅作传输使用 */
|
/** 医生ID - 不映射到数据库表字段,仅作传输使用 */
|
||||||
private Long doctorId;
|
private Long doctorId;
|
||||||
|
|
||||||
|
/** 排班日期 - 不映射到数据库表字段,仅作传输使用 */
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String scheduledDate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
export function updateDoctorSchedule(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@@ -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)
|
* @param {Object} data - 排班数据 (必须包含ID)
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ import {computed, onMounted, ref, watch} from 'vue'
|
|||||||
import {useRoute, useRouter} from 'vue-router'
|
import {useRoute, useRouter} from 'vue-router'
|
||||||
import {ElDialog, ElMessage, ElMessageBox} from 'element-plus'
|
import {ElDialog, ElMessage, ElMessageBox} from 'element-plus'
|
||||||
import {View} from '@element-plus/icons-vue'
|
import {View} from '@element-plus/icons-vue'
|
||||||
import {addDoctorSchedule, deleteDoctorSchedule} from '../api'
|
import {addDoctorSchedule, addDoctorScheduleWithDate, deleteDoctorSchedule} from '../api'
|
||||||
|
|
||||||
// 路由和导航
|
// 路由和导航
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
@@ -587,6 +587,7 @@ const handleSave = async () => {
|
|||||||
isStopped: item.stopClinic || false,
|
isStopped: item.stopClinic || false,
|
||||||
stopReason: item.stopClinic ? (item.stopReason || '') : '',
|
stopReason: item.stopClinic ? (item.stopReason || '') : '',
|
||||||
deptId: currentDept.value?.id || route.query.deptId || null,
|
deptId: currentDept.value?.id || route.query.deptId || null,
|
||||||
|
scheduledDate: item.date // 添加具体日期字段
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -614,7 +615,8 @@ const handleSave = async () => {
|
|||||||
// 确保新记录的id为null
|
// 确保新记录的id为null
|
||||||
scheduleData.id = null
|
scheduleData.id = null
|
||||||
|
|
||||||
const res = await addDoctorSchedule(scheduleData)
|
// 使用带日期的API,日期信息已包含在scheduleData中
|
||||||
|
const res = await addDoctorScheduleWithDate(scheduleData)
|
||||||
if (res.code === 200 && res.data) {
|
if (res.code === 200 && res.data) {
|
||||||
successCount++
|
successCount++
|
||||||
// 更新本地记录的backendId
|
// 更新本地记录的backendId
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ import {ElDialog, ElForm, ElFormItem, ElInput, ElMessage, ElMessageBox, ElOption
|
|||||||
import {DocumentRemove, EditPen, View, Delete} from '@element-plus/icons-vue'
|
import {DocumentRemove, EditPen, View, Delete} from '@element-plus/icons-vue'
|
||||||
import {listDept, searchDept} from '@/api/appoinmentmanage/dept'
|
import {listDept, searchDept} from '@/api/appoinmentmanage/dept'
|
||||||
import {getLocationTree, getPractitionerMetadata, getHealthcareMetadata} from '@/views/charge/outpatientregistration/components/outpatientregistration'
|
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 {getClinicRoomList} from '@/api/appoinmentmanage/clinicRoom'
|
||||||
import {getInitOption, getRegistrationItems, getClinicItems} from '@/views/basicservices/registrationfee/components/registrationfee'
|
import {getInitOption, getRegistrationItems, getClinicItems} from '@/views/basicservices/registrationfee/components/registrationfee'
|
||||||
import { deptTreeSelect } from '@/api/system/user'
|
import { deptTreeSelect } from '@/api/system/user'
|
||||||
@@ -1534,6 +1534,7 @@ const handleSave = async () => {
|
|||||||
isStopped: item.stopClinic,
|
isStopped: item.stopClinic,
|
||||||
stopReason: item.stopClinic ? (item.stopReason || '') : '',
|
stopReason: item.stopClinic ? (item.stopReason || '') : '',
|
||||||
deptId: currentDept.value?.id || null,
|
deptId: currentDept.value?.id || null,
|
||||||
|
scheduledDate: item.date // 添加具体日期字段
|
||||||
};
|
};
|
||||||
if (item.backendId) {
|
if (item.backendId) {
|
||||||
scheduleData.id = item.backendId;
|
scheduleData.id = item.backendId;
|
||||||
@@ -1557,7 +1558,7 @@ const handleSave = async () => {
|
|||||||
// 处理新增
|
// 处理新增
|
||||||
for (const { scheduleData } of recordsToAdd) {
|
for (const { scheduleData } of recordsToAdd) {
|
||||||
try {
|
try {
|
||||||
const res = await addDoctorSchedule(scheduleData);
|
const res = await addDoctorScheduleWithDate(scheduleData);
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
addSuccess++;
|
addSuccess++;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user