package com.ywt.outpatient.service.batch;

import com.ywt.gapi.Result;
import com.ywt.gapi.doctor.DoctorHisCode;
import com.ywt.gapi.doctor.DoctorService;
import com.ywt.gapi.doctor.SaveDoctorHisCodeListRequest;
import com.ywt.gapi.doctor.SaveDoctorHisCodeListResponse;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author daiyihua
 * @create 2023-07-06 15:36
 * @program dispatcher
 * @description 调用taihe.proto的公共类
 **/
@Service
public class DoctorServiceSrv {

    private final Logger logger = LoggerFactory.getLogger(DoctorServiceSrv.class);

    @DubboReference
    private DoctorService doctorServiceBlockingStub;

    /**
     * 获取医生排班记录
     */
    public Result saveDoctorHisCodeList(List<DoctorHisCode> doctorHisCodeList) {
        try {
            SaveDoctorHisCodeListRequest request = SaveDoctorHisCodeListRequest.newBuilder()
                    .addAllDoctorHisCode(doctorHisCodeList)
                    .build();
            SaveDoctorHisCodeListResponse res = doctorServiceBlockingStub.saveDoctorHisCodeList(request);
            return res.getResult();
        } catch (Exception e) {
            logger.error("DoctorServiceSrv>>saveDoctorHisCodeList():保存docotrHisCode信息:{}", e.getMessage(), e);
        }
        return null;
    }
}
