package com.mosty.base.feign.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyQwzxFeignService;
import com.mosty.base.model.dto.qwzx.TbQwXfbbVo;
import com.mosty.base.model.entity.qwzx.TbQwJl;
import com.mosty.base.model.entity.qwzx.TbQwXfbb;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.SpringUtils;
import com.mosty.common.base.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author
 * @description qwgl服务FeignService路由工具
 * @modifier
 * @modifiedTime 2025/05/26 19:30
 * @since 2025/25/26 19:30
 */
@Slf4j
public class MostyQwzxFeignServiceRemote {

    /**
     * 基础服务FeignService
     */
    private static MostyQwzxFeignService mostyQwzxFeignService;

    /**
     * 获取基础服务FeignService
     * @return MostyQwglFeignService
     */
    private static MostyQwzxFeignService getService(){
        if(mostyQwzxFeignService == null){
            mostyQwzxFeignService = SpringUtils.getBean(MostyQwzxFeignService.class);
        }
        return mostyQwzxFeignService;
    }

    /**
     * 根据报备ID获取报备详情
     * @param id 主键ID
     * @return 报备详情
     */
    public static TbQwXfbbVo getXfbbInfo(String id) {
        ResponseResult<TbQwXfbbVo> responseResult = MostyQwzxFeignServiceRemote.getService().getBbInfo(id);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("根据报备ID获取报备详情异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("根据报备ID获取报备详情异常");
        }
        return responseResult.getData();
    }

    /**
     * 查询我今天的报备new
     * @param bblx 报备类型
     * @return 报备详情
     */
    public static TbQwXfbb getMyXfbbTodayNew(String bblx) {
        ResponseResult<TbQwXfbb> responseResult = MostyQwzxFeignServiceRemote.getService().getMyXfbbTodayNew(bblx);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询我今天的报备异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询我今天的报备异常");
        }
        return responseResult.getData();
    }

    /**
     * 查询勤务警力信息（根据报备ID和巡防警力ID）
     * @param id 报备ID
     * @param xfllId 巡防警力ID
     * @return 勤务警力信息
     */
    public static TbQwJl selectQwJlByBbInfo(String id, String xfllId) {
        ResponseResult<TbQwJl> responseResult = MostyQwzxFeignServiceRemote.getService().selectQwJlByBbInfo(id, xfllId);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询勤务警力信息（根据报备ID和巡防警力ID）异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询勤务警力信息（根据报备ID和巡防警力ID）异常");
        }
        return responseResult.getData();
    }

}
