Fix Bug #570: AI修复
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package com.openhis.web.appointment.service;
|
||||
|
||||
import com.openhis.web.appointment.entity.Appointment;
|
||||
import com.openhis.web.appointment.mapper.AppointmentMapper;
|
||||
import com.openhis.web.appointment.dto.AppointmentParam;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 门诊预约挂号服务实现
|
||||
*/
|
||||
@Service
|
||||
public class AppointmentServiceImpl implements AppointmentService {
|
||||
|
||||
private final AppointmentMapper appointmentMapper;
|
||||
|
||||
public AppointmentServiceImpl(AppointmentMapper appointmentMapper) {
|
||||
this.appointmentMapper = appointmentMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createAppointment(AppointmentParam param) {
|
||||
Appointment appointment = new Appointment();
|
||||
appointment.setPatientId(param.getPatientId());
|
||||
appointment.setScheduleId(param.getScheduleId());
|
||||
appointment.setDoctorId(param.getDoctorId());
|
||||
appointment.setDeptId(param.getDeptId());
|
||||
appointment.setVisitDate(param.getVisitDate());
|
||||
appointment.setCreateTime(LocalDateTime.now());
|
||||
appointment.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
// Bug #570 Fix: 预约成功后状态应设置为“已预约”(1),原代码错误设置为“已锁定”(2)导致查询过滤异常
|
||||
// 状态字典: 1-已预约, 2-已就诊, 3-已取消, 4-已爽约
|
||||
appointment.setStatus(1);
|
||||
|
||||
int rows = appointmentMapper.insert(appointment);
|
||||
if (rows > 0) {
|
||||
// 同步扣减号源库存
|
||||
appointmentMapper.decrementScheduleStock(param.getScheduleId());
|
||||
}
|
||||
return rows > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Appointment getAppointmentById(Long id) {
|
||||
return appointmentMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Appointment> listAppointmentsByStatus(Integer status) {
|
||||
return appointmentMapper.selectByStatus(status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user