package com.mosty.lzother.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostyYszxFeignService;
import com.mosty.base.model.dto.yszx.TbYsGajgByJwdDto;
import com.mosty.base.model.dto.yszx.TbYsSxtDto;
import com.mosty.base.model.entity.lzother.ZhjmxfXfqwXfqyGzdw;
import com.mosty.base.model.entity.sjzx.TbJqCjdb;
import com.mosty.base.model.vo.yszx.TbYsGajgVo;
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;

/**
 * @author dw
 * @since 2022/7/23
 * 外部调用公安机关要素接口
 **/
@Service
@Slf4j
public class TbYsZxAdaptRemoteService {

    @Resource
    private MostyYszxFeignService tbYszxFeignService;

    // 返回要素表中不存在的感知源
    public List<String> getInfoBySbbh(List<String> ids) {
        ResponseResult<List<String>> responseResult = tbYszxFeignService.getInfoBySbbh(ids);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("失败 responseResult = {}", JSON.toJSONString(responseResult));
            return new ArrayList<>();
        }
        return responseResult.getData();
    }

    // 添加摄像头信息
    public Integer addSxt(TbYsSxtDto dto) {
        ResponseResult<Integer> responseResult = tbYszxFeignService.addSxt(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加摄像头信息失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加摄像头信息失败");
        }
        return responseResult.getData();
    }

    // 根据经纬度查询所在辖区
    public TbYsGajgVo getGajgByJwd(TbYsGajgByJwdDto dto) {
        ResponseResult<TbYsGajgVo> responseResult = tbYszxFeignService.getGajgByJwd(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询所在辖区失败 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询所在辖区失败");
        }
        return responseResult.getData();
    }

    // 添加泸州感知源信息
    public void addLzGzy(ZhjmxfXfqwXfqyGzdw dto) {
        ResponseResult<Void> responseResult = this.tbYszxFeignService.addLzGzy(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加泸州感知源信息 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加泸州感知源信息异常");
        }
    }
}
