门诊医生预约科室管理功能的完善

This commit is contained in:
2025-12-25 13:49:30 +08:00
parent 55b3dfc077
commit 999a0992e7
5 changed files with 663 additions and 38 deletions

View File

@@ -3,6 +3,7 @@ package com.openhis.web.appointmentmanage.appservice.impl;
import cn.hutool.core.util.ObjectUtil;
import com.core.common.core.domain.R;
import com.openhis.appointmentmanage.domain.DoctorSchedule;
import com.openhis.appointmentmanage.mapper.DoctorScheduleMapper;
import com.openhis.appointmentmanage.service.IDoctorScheduleService;
import com.openhis.web.appointmentmanage.appservice.IDoctorScheduleAppService;
import org.springframework.stereotype.Service;
@@ -14,6 +15,9 @@ import java.util.List;
public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService {
@Resource
private IDoctorScheduleService doctorScheduleService;
@Resource
private DoctorScheduleMapper doctorScheduleMapper;
@Override
@@ -27,8 +31,35 @@ public class DoctorScheduleAppServiceImpl implements IDoctorScheduleAppService {
if (ObjectUtil.isEmpty(doctorSchedule)) {
return R.fail("医生排班不能为空");
}
boolean save = doctorScheduleService.save(doctorSchedule);
return R.ok(save);
// 创建新对象排除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() : false);
newSchedule.setIsStopped(doctorSchedule.getIsStopped() != null ? doctorSchedule.getIsStopped() : false);
newSchedule.setStopReason(doctorSchedule.getStopReason() != null ? doctorSchedule.getStopReason() : "");
newSchedule.setDeptId(doctorSchedule.getDeptId());
// 不设置id字段让数据库自动生成
// 使用自定义的insertWithoutId方法确保INSERT语句不包含id字段
int result = doctorScheduleMapper.insertWithoutId(newSchedule);
boolean save = result > 0;
if (save) {
// 返回保存后的实体对象包含数据库生成的ID
return R.ok(newSchedule);
} else {
return R.fail("保存失败");
}
}
@Override

View File

@@ -1,5 +1,7 @@
package com.openhis.appointmentmanage.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -15,7 +17,8 @@ import java.time.LocalTime;
@TableName(value = "adm_doctor_schedule")
@Accessors(chain = true)
public class DoctorSchedule {
/** id */
/** id - 数据库GENERATED ALWAYS由数据库自动生成插入时不应包含此字段 */
@TableId(type = IdType.NONE)
private Integer id;
/** 星期 */

View File

@@ -2,8 +2,12 @@ package com.openhis.appointmentmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openhis.appointmentmanage.domain.DoctorSchedule;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Mapper;
@Repository
@Mapper
public interface DoctorScheduleMapper extends BaseMapper<DoctorSchedule> {
/**
* 自定义插入方法排除id字段数据库GENERATED ALWAYS
*/
int insertWithoutId(DoctorSchedule doctorSchedule);
}