package com.mosty.rwzx.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyQwzxFeignService;
import com.mosty.base.model.dto.qwzx.TbQwJlDto;
import com.mosty.base.model.dto.qwzx.TbQwXfbbVo;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 勤务中心远程调用
 */
@Slf4j
@Service
@AllArgsConstructor
public class TbQwzxAdaptRemoteService {

    private final MostyQwzxFeignService mostyQwzxFeignService;

    /**
     * 获取报备详情
     *
     * @param
     * @return
     */
    public TbQwXfbbVo getBbInfo(String id) {
        ResponseResult<TbQwXfbbVo> responseResult = mostyQwzxFeignService.getBbInfo(id);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取报备详情失败 responseResult = {}", JSON.toJSONString(responseResult));
            return null;
        }
        return responseResult.getData();
    }

    /**
     * 根据报备ID查询巡组下的人员列表
     *
     * @param
     * @return
     */
    public List<TbQwJlDto> getJlxxByBbid(String id) {
        ResponseResult<List<TbQwJlDto>> responseResult = mostyQwzxFeignService.getJlxxByBbid(id);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取报备警力失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("获取报备警力列表异常！");
        }
        return responseResult.getData();
    }
}
