package com.mosty.sjzx.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyJcglFeignService;
import com.mosty.base.model.dto.jcgl.TbJcglKfdDto;
import com.mosty.base.model.dto.jcgl.TbJcglPzfzDto;
import com.mosty.base.model.dto.jcgl.TbJcglXfllVo;
import com.mosty.base.model.dto.jcgl.TbJcglXfqyDto;
import com.mosty.base.model.entity.jcgl.TbJcglJwz;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

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

/**
 * @author dw
 * @since 2022/7/23
 * 外部调用基础管理接口
 **/
@Service
@Slf4j
public class TbJcglAdaptRemoteService {

    @Resource
    private MostyJcglFeignService mostyJcglFeignService;

    // 查询配置分值
    public List<TbJcglPzfzDto> getFzList() {
        ResponseResult<List<TbJcglPzfzDto>> responseResult = mostyJcglFeignService.getFzList();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询配置分值失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询配置分值失败");
        }
        return responseResult.getData();
    }

    // 添加计算出来的必巡点的数据
    public void createdBxd(List<Map<String, Object>> rList) {
        ResponseResult<Void> responseResult = mostyJcglFeignService.createdBxd(rList);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加计算出来的必巡点的数据失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加计算出来的必巡点的数据失败");
        }
    }

    // 查询所有快反点数据
    public List<TbJcglKfdDto> getListKfdAll() {
        ResponseResult<List<TbJcglKfdDto>> responseResult = mostyJcglFeignService.getListKfdAll();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询所有快反点数据失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询所有快反点数据失败");
        }
        return responseResult.getData();
    }

    // 查询所有巡防区数据
    public List<TbJcglXfqyDto> getListXfqyAll() {
        ResponseResult<List<TbJcglXfqyDto>> responseResult = mostyJcglFeignService.getListXfqyAll();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询所有巡防区数据失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询所有巡防区数据失败");
        }
        return responseResult.getData();
    }
}
