//api公共请求地址
import { request } from '@umijs/max';
import { RespResult } from './Resp';
/**
 *
 * @param url 接口地址
 * @returns 诚管24
 * @description 首页-城市实况-城市问题
 */
const IS_PROD = process.env.NODE_ENV === 'production' ? true : false;
export const reqBaseUrl = IS_PROD
  ? '/cd-comprehensive/apis/city-comprehensive-coordination'
  : '/apis/city-comprehensive-coordination';

const urlProxyApis = (url: string) => {
  return `${reqBaseUrl}${url}`;
};

// 城市问题数量统计
export async function getCityProblemStatistics() {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getLargeScreenData'),
    {
      method: 'get',
    },
  );
}

/**
 * 获取城管24问题总数
 * @returns 城管24问题总数
 */
export async function getCityTotal(params?: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getCityTotal'),
    {
      method: 'post',
      params,
    },
  );
}

/**
 * 获取各来源统计数据
 * @returns 来源统计数据
 */
export async function getSourceTotal(params?: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getSourceTotal'),
    {
      method: 'post',
      params,
    },
  );
}

/**
 *
 * @description 事件汇总顶部筛选
 */
export async function getComprehensiveDiscoveryStatistics(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/homePage/comprehensiveDiscoveryStatistics'),
    {
      method: 'get',
      params,
    },
  );
}

/**
 *
 * @description 事件汇总左侧顶部统计
 */
export async function getContentStatisticsApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getContentStatistics'),
    {
      method: 'post',
      params,
    },
  );
}
/**
 *
 * @description 运行态势下钻统计
 */
export async function getSourceSystemCloseRate(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/sourceSystemDisposalRate'),
    {
      method: 'post',
      params,
    },
  );
}
/**
 *
 * @description 事件汇总左侧顶部统计
 */
export async function getContentStatisticsV3(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getContentStatisticsV31'),
    {
      method: 'post',
      params,
    },
  );
}
/**
 *
 * @description 事件汇总高发类别统计
 */
export async function getCategoryAnalysisApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getCategoryAnalysis'),
    {
      method: 'post',
      params,
    },
  );
}

/**
 *
 * @description 事件汇总高发区域统计
 */
export async function getAreaAnalysisApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getAreaAnalysis'),
    {
      method: 'post',
      params,
    },
  );
}

/**
 *
 * @description 事件汇总高发区域统计
 */
export async function getCaseSourceTypeList() {
  return request<RespResult<any>>(
    urlProxyApis('/config-case-source-type/list'),
    {
      method: 'post',
    },
  );
}
/**来源列表 */
export async function getSourceSystemList() {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/sourceSystemList'),
    {
      method: 'post',
    },
  );
}

/**
 *
 * @description 全部状态
 */
export async function getCaseStatusListApi() {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getCaseStatusList'),
    {
      method: 'get',
    },
  );
}

/**
 *
 * @description 事件类型
 */
export async function getEventTypeListApi() {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/getEventTypeList'),
    {
      method: 'get',
    },
  );
}

/**
 *
 * @description 事件列表
 */
export async function getZzEventListApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/zongzhi/getZzEventList'),
    {
      method: 'post',
      params
    },
  );
}

/**
 *
 * @description 类别分析top
 */
export async function getCategoryTopAnalysisApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getCategoryTopAnalysis'),
    {
      method: 'post',
      params
    },
  );
}

/**
 *
 * @description 类别分析top
 */
export async function getAreaDistribAnalysisApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getAreaDistribAnalysis'),
    {
      method: 'post',
      params
    },
  );
}
/**
 *
 * @description 趋势图
 */
export async function getSourceSystemTrend(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/sourceSystemTrend'),
    {
      method: 'post',
      params
    },
  );
}
/**
 *
 * @description 重要事件统计
 */
export async function getImportEventStatisticsApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/importEventStatistics'),
    {
      method: 'get',
      params
    },
  );
}

/**
 *
 * @description 待处置统计
 */
export async function getSourceStatisticsApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getSourceStatistics'),
    {
      method: 'post',
      params
    },
  );
}

/**
 *
 * @description 统计整体结案率分析
 */
export async function getAllCloseCaseStatisticsApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getAllCloseCaseStatistics'),
    {
      method: 'post',
      params
    },
  );
}

/**
 *
 * @description 时限统计
 */
export async function getTimeLimitsApi(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/cityScreen/getTimeLimits'),   
    {
      method: 'get',
      params
    },
  );
}

//获取最新事件
export async function getUpToDateEvent(
  params: {
    page: number;
    count: number;
    protrudeFlag?: string;//1待确认 2 已确认推送 3 不推送
  },
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/comprehensiveDiscovery/getUpToDateEvent`), {
    method: 'POST',
    params,
  });
}

//获取最新事件
export async function getUpToDateEventOther(
  params: {
    page: number;
    count: number;
    protrudeFlag?: string;//1待确认 2 已确认推送 3 不推送
    subTypeCode?: string;//小类编码
    districtCode?: string;//区县编码
    streetCode?: string;//街道编码
    type?: string;//时间，1.年 2.月 3.日 4.自定义
    date?: string;//查询的日期
    customizeStart?: string;//自定义开始日期
    customizeEnd?: string;//自定义结束日期
  },
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/comprehensiveDiscovery/getUpToDateEventOther`), {
    method: 'POST',
    params,
  });
}

/**
 *
 * @description 获取高发时段
 */
export async function getHighIncidenceTime(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/highIncidenceTime'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

/**
 *
 * @description 获取案件情况
 */
export async function getDisposeStats(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/disposeStats'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

/**
 *
 * @description 获取问题来源
 */
export async function getSourceSystemRank(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/sourceSystemRank'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

/**
 *
 * @description 获取问题趋势
 */
export async function getEventTrends(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/eventTrends'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

/**
 *
 * @description 获取区市县办结率
 */
export async function getDistrictCompletionRate(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/closeRateRank'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

/**
 *
 * @description 获取区市县高发案件
 */
export async function getDistrictHighFrequencyArea(params: any) {
  return request<RespResult<any>>(
    urlProxyApis('/comprehensiveDiscovery/highIncidenceAreaRank'),
    {
      method: 'post',
      params,
      data: {} // 添加空的data确保不会将params作为请求体发送
    },
  );
}

export async function getCaseStatistics(params?: any) {
  return request<RespResult<any>>(urlProxyApis('/comprehensiveDiscovery/getCaseStatistics'), {
    method: 'get',
    params,
  });
}

export default {
  /**
   * 获取城管24问题总数
   */
  getCityTotal(params?: any) {
    return getCityTotal(params);
  },

  /**
   * 获取各来源上报数据总数
   */
  getSourceTotal(params?: any) {
    return getSourceTotal(params);
  },
};