import { request } from '@umijs/max';

/**
 *
 * @param url 接口地址
 * @returns 城市风险 city-sjdz-base
 */
const IS_PROD = process.env.NODE_ENV === 'production' ? true : false;
export const reqBaseUrl = IS_PROD
  ? '/cd-comprehensive/apis/city-sjdz-base'
  : '/apis/city-sjdz-base';
const urlProxyApis = (url: string) => {
  return `${reqBaseUrl}${url}`;
};

// 获取城市风险统计
export async function queryStatisticalRiskLevel(): Promise<any> {
  return request(
    urlProxyApis(`/safetyMonitoringObjectInfo/statisticalRiskLevel`),
  );
}

// 获取风险事件分页列表
export async function querySafetyRiskEventPage(
  params: any, // page=1&count=10&parentTypeCode=dlql
): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/eventPage`), {
    params,
  });
}

// 安全一张图预警统计
export async function getstatisticalEvent(
  params: any, // areaCode
): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/statisticalEvent`), {
    params,
  });
}
//安全一张图行业树
export async function getTree(
  params: any, // areaCode
): Promise<any> {
  return request(urlProxyApis(`/safetyDictionary/getTree`), {
    params,
  });
}

//安全一张获取预警等级数量
export async function getStatisticalRiskLevel(
  params: any, // areaCode
): Promise<any> {
  return request(
    urlProxyApis(`/safetyMonitoringObjectInfo/statisticalRiskLevel`),
    {
      params,
    },
  );
}

//安全一张获取地图checkList
export async function getParentType(
  params: any, // areaCode
): Promise<any> {
  return request(urlProxyApis(`/safetyDictionary/getParentType`), {
    params,
  });
}

//安全一张获取事件
export async function getEventPage(
  params: any, // areaCode
): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/eventPage`), {
    params,
  });
}

//安全一张获取地图事件点位
export async function findListForMap(
  params: any, // areaCode--parentTypeCode
): Promise<any> {
  return request(urlProxyApis(`/safetyMonitoringObjectInfo/findListForMap`), {
    params,
    timeout: 100000,
  });
}
//安全一张获取地图预警点位
export async function safetyRiskEventMap(params: any): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/findListForMap`), {
    params,
    timeout: 100000,
  });
}
//tJAO5LxZg==
//安全一张获取地图
export async function getInfo(
  params: any, // riskId
): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/getInfo`), {
    params,
  });
}
//tJAO5LxZg==
//安全一张图风险来源下拉获取
export async function eventSourceTypeSelect(): Promise<any> {
  return request(
    urlProxyApis(`/safetyRiskEventInfo/eventSourceTypeSelect`),
    {},
  );
}

// 获取城市风险统计
export async function safetyMonitoringObjectInfo(params: any): Promise<any> {
  return request(urlProxyApis(`/safetyMonitoringObjectInfo/getInfo`), {
    params,
  });
}

// 获取城市风险统计src/components/CooglMap
export async function statisticalEventPc(): Promise<any> {
  return request(urlProxyApis(`/safetyRiskEventInfo/statisticalEventPc`));
}

// 获取城市风险统计src/components/CooglMap
export async function catalogData(data:any): Promise<any> {
  return request(urlProxyApis(`/sjdzInterfaceInfo/getSjdzInfoData`), {
    data,
    method: 'post',
    timeout: 300000,
  });
}
