eight
2024-11-20 4924f5e98bfbc78693466b667e768092181112eb
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/appointment/AppointmentServiceImpl.java
@@ -5,6 +5,7 @@
import cn.lihu.jh.module.ecg.controller.admin.queue.vo.QueueSaveReqVO;
import cn.lihu.jh.module.ecg.dal.dataobject.checktype.CheckTypeDO;
import cn.lihu.jh.module.ecg.dal.dataobject.patient.PatDetails;
import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO;
import cn.lihu.jh.module.ecg.feign.RemoteDataService;
import cn.lihu.jh.module.ecg.feign.RestApiReqBodyVo;
import cn.lihu.jh.module.ecg.feign.RestApiResult;
@@ -35,6 +36,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.lihu.jh.framework.common.pojo.CommonResult.error;
@@ -124,7 +126,7 @@
     */
    @Override
    public List<AppointmentDO> queryAndCreateAppointmentByPatId(String patCode) {
        // 先从医院平台查询
        // 从医院平台查询
        List<AppointmentDO> appointmentExtermalList = getAppointmentExtermal( patCode );
        for ( int appointmentIndex = 0; appointmentIndex < appointmentExtermalList.size(); appointmentIndex++ ) {
@@ -132,12 +134,22 @@
            if (null == appointmentExtermal )
                continue;
            // 从DB查到预约,是否已经存在
            // 从DB查询预约,是否已经存在
            AppointmentDO appointmentDO = appointmentMapper.getByPatAndCheckTypeAndBookDate(appointmentExtermal.getPatId(), appointmentExtermal.getBookCheckType(), appointmentExtermal.getBookDate());
            if (null == appointmentDO) {
                appointmentMapper.insert(appointmentExtermal);
            } else {
                appointmentExtermal.setId( appointmentDO.getId() ); // 确保 返回值保护 appointment id
                appointmentExtermal.setId( appointmentDO.getId() ); // 确保 返回值包含 appointment id
            }
        }
        // 查询[queue表]补充 book_seq_num 到返回值中
        if (!appointmentExtermalList.isEmpty()) {
            List<Long> appointIdlist = appointmentExtermalList.stream().map(appointmentDO -> appointmentDO.getId()).toList();
            List<QueueDO> simpleQueueDOList = queueService.selectBookSeqNumByAppointIdList(appointIdlist);
            if (!simpleQueueDOList.isEmpty()) {
                Map<Long, Integer> mapAppointIdVsBookSeqNo = simpleQueueDOList.stream().collect(Collectors.toMap(QueueDO::getAppointId, QueueDO::getBookSeqNum));
                appointmentExtermalList.forEach(appointmentExterma -> appointmentExterma.setBookSeqNum(mapAppointIdVsBookSeqNo.get(appointmentExterma.getId())));
            }
        }
@@ -234,6 +246,7 @@
        try {
            QueueSaveReqVO queueSaveReqVO = new QueueSaveReqVO();
            queueSaveReqVO.setAppointId(appointment.getId());
            queueSaveReqVO.setPatId(appointment.getPatId());
            queueSaveReqVO.setPatName(appointment.getPatName());
            queueSaveReqVO.setPatGender(appointment.getPatGender());