package com.mosty.lzother.remote;

import com.alibaba.fastjson.JSON;
import com.mosty.base.feign.service.MostySjzxFeignService;
import com.mosty.base.model.entity.lzother.VLz110Txj;
import com.mosty.base.model.entity.lzother.ZhjmxfXfqwXfqyGzdw;
import com.mosty.base.model.entity.sjzx.TbJq;
import com.mosty.base.model.entity.sjzx.TbJqCjdb;
import com.mosty.base.model.entity.xinzhi.GxCjdb;
import com.mosty.base.model.entity.xinzhi.Jjdb;
import com.mosty.base.model.vo.sjzx.TbJqVo;
import com.mosty.base.model.vo.xinzhi.GxAlarmAllVo;
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.List;

/**
 * @author dw
 * @since 2022/10/31
 * 外部调用事件中心接口
 **/
@Service
@Slf4j
public class TbSjzxAdaptRemoteService {

    @Resource
    private MostySjzxFeignService mostySjzxFeignService;

    // 同步仁寿警情信息
    public void addRsJq(TbJq dto) {
        ResponseResult<Void> responseResult = this.mostySjzxFeignService.addRsJq(dto);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("同步仁寿警情信息异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("同步仁寿警情信息异常");
        }
    }

    // 获取警情的最新的一条信息
    public TbJqVo getLastJq() {
        ResponseResult<TbJqVo> responseResult = this.mostySjzxFeignService.getLastJq();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取警情的最新的一条信息异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("获取警情的最新的一条信息异常");
        }
        return responseResult.getData();
    }

    // 获取最新一条处警单的数据
    public TbJqCjdb getLastJqCjdb() {
        ResponseResult<TbJqCjdb> responseResult = this.mostySjzxFeignService.getLastJqCjdb();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("获取最新一条处警单的数据 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("获取最新一条处警单的数据异常");
        }
        return responseResult.getData();
    }

    // 添加仁寿处警单数据
    public void addRsCjdb(TbJqCjdb cjdb) {
        ResponseResult<TbJqCjdb> responseResult = this.mostySjzxFeignService.addRsCjdb(cjdb);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加仁寿处警单数据 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加仁寿处警单数据异常");
        }
    }

    // 添加泸州110警情数据
    public void addLzJq(VLz110Txj lz110) {
        ResponseResult<Void> responseResult = this.mostySjzxFeignService.addLzJq(lz110);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加泸州110警情数据 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加泸州110警情数据异常");
        }
    }

    // 添加泸州海能达警情数据
    public void addLzHndJq(Jjdb jjdb) {
        ResponseResult<Void> responseResult = this.mostySjzxFeignService.addLzHndJq(jjdb);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加泸州110警情数据 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加泸州110警情数据异常");
        }
    }

    // 查询没得经纬度的接警单编号
    public List<String> selectJjdbh() {
        ResponseResult<List<String>> responseResult = this.mostySjzxFeignService.selectJjdbh();
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("查询没得经纬度的接警单编号 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("查询没得经纬度的接警单编号异常");
        }
        return responseResult.getData();
    }

    //修改经纬度
    public void updateJqJwd(Jjdb jjdb) {
        ResponseResult<Void> responseResult = this.mostySjzxFeignService.updateJqJwd(jjdb);
        if (responseResult == null || !responseResult.isSuccess()) {
            log.error("添加泸州110警情数据 异常 responseResult = {}", JSON.toJSONString(responseResult));
            throw new BusinessException("添加泸州110警情数据异常");
        }
    }
}
