// import { OptionsDto } from '@/components/TabSwitch';
import { request } from '@umijs/max';
import { RespResult } from './core/ReqData';
// privateKey：25105957f6027a4a4842126c71caf550c338c934f5ee407c4be1695bd353b45b
/**
 *
 * @param url 接口地址
 * @returns 首页体征physicalsignindex
 */
const IS_PROD = process.env.NODE_ENV === 'production' ? true : false;
export const reqBaseUrl = IS_PROD
  ? '/cd-comprehensive/apis/physicalsignindex'
  : '/apis/physicalsignindex';
const urlProxyApis = (url: string) => {
  return `${reqBaseUrl}${url}`;
};

//体征首页
export async function queryTzzsPhysicalSign(
  data: PhysicalsignApi.QueryTzzsPhysicalSignIndexInstanceDataParams,
): Promise<
  PhysicalsignApi.Result<PhysicalsignApi.QueryTzzsPhysicalSignIndexInstanceDataList>
> {
  return request(
    urlProxyApis(`/physicalsignindexinstance/queryIndexInstanceHomepageData`),
    {
      params: data,
    },
  );
}
//获取体征体系
export async function getPhysicalSignSystem(): Promise<
  PhysicalsignApi.Result<PhysicalsignApi.SignWeightSystem>
> {
  return request(urlProxyApis(`/physicalSignModel/getPhysicalSignSystem`));
}
//获取体征权重
export async function getWeightSystem(): Promise<
  PhysicalsignApi.Result<PhysicalsignApi.SignWeightSystem>
> {
  return request(urlProxyApis(`/physicalSignModel/getWeightSystem`));
}

//宏观体征首页数据
export async function getMacroscopicPhysicalSign(
  data: PhysicalsignApi.MacroscopicPhysicalSignParams,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.SignIndexTabs>> {
  return request(urlProxyApis(`/macroscopicPhysicalSign/getIndexInstance`), {
    params: data,
  });
}

//中观体征底部指数
export async function getPhysicalSignIndexTabs(): Promise<
  PhysicalsignApi.Result<PhysicalsignApi.SignIndexTabs>
> {
  return request(urlProxyApis(`/middlePhysicalSign/getPhysicalSignIndexTabs`));
}

//影响体征Top5
export async function getlistTopNItems(
  data: any,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.ListTopNItems>> {
  return request(
    urlProxyApis(`/physicalsignindexquestioninstance/listTopNItems`),
    {
      params: data,
    },
  );
}

//中观体征地图边界
export async function getObjectPolygon(
  params: any,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.ListTopNItems>> {
  return request(urlProxyApis(`/middlePhysicalSign/getObjectPolygon`), {
    params: params,
  });
}

//中观体征地图边界
export async function getObjectPolygon2(
  params: any,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.ListTopNItems>> {
  return request(urlProxyApis(`/middlePhysicalSign/getObjectPolygon2`), {
    params: params,
  });
}

//中观体征县区体征数据
export async function getGroupObjectPhysicalSignIndex(
  params: any,
): Promise<PhysicalsignApi.Result<string[][]>> {
  return request(
    urlProxyApis(`/middlePhysicalSign/getGroupObjectPhysicalSignIndex`),
    {
      params,
    },
  );
}

/**
 * @description 获取体征指数对比结果接口
 */
export async function getComparisonIndexInstance(data: any): Promise<any> {
  return request(urlProxyApis(`/main/getComparisonIndexInstance`), {
    params: data,
    // timeout: 30000,
  });
}

/**
 * @description 基于对象与指数查询指标影响top5
 */
export async function getPhysicalsignindexquestioninstanceListTop(
  data: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(
    urlProxyApis(`/physicalsignindexquestioninstance/listTopNItems`),
    {
      params: data,
    },
  );
}

/**
 * @description 影响指标详情
 */
export async function getPhysicalsignindexPageCaseInfoVO(
  data: any,
): Promise<any> {
  return request(
    urlProxyApis(`/physicalsignindexquestioninstance/pageCaseInfoVO`),
    {
      params: data,
    },
  );
}

/**
 * @description 预警区域
 */
export async function getWarningDistrictIndexInstance(
  data: PhysicalsignApi.PhysicalSignParams,
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/main/getWarningDistrictIndexInstance`), {
    params: data,
  });
}

/**
 * @description 重点区域
 */
export async function getImportantDistrictIndexInstance(
  data: PhysicalsignApi.PhysicalSignParams,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.ImportantDistrictDto>> {
  return request(urlProxyApis(`/main/getImportantDistrictIndexInstance`), {
    params: data,
  });
}

/**
 * @description 指标体系查询，附带查询对象的各子级的得分和丢失分数
 */
export async function getIndexSystem(
  params: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/physicalSignIndex/getIndexSystem`), {
    params,
  });
}

/**
 * @description 指标体系查询，
 */
export async function getExpendIndexSystem(
  params: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/physicalSignIndex/getExpendIndexSystem`), {
    params,
  });
}

/**
 * @description 具体问题列表
 */
export async function getIndexSafetyProblemList(
  data: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(
    urlProxyApis(
      `/livePhysicalSignInfluenceFactor/listTzzsLivePhysicalSignInfluenceFactorQuestionVO`,
    ),
    {
      params: data,
    },
  );
}

/**
 * @description 查询体征指数数据
 */
export async function getTzzsPhysicalSignIndexInstanceData(
  data: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(
    urlProxyApis(
      `/physicalsignindexinstance/queryTzzsPhysicalSignIndexInstanceDataVO`,
    ),
    {
      params: data,
    },
  );
}

/**
 * @description 城市安全态势指数
 */
export async function getIndexInstanceData(
  data: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(urlProxyApis(`/main/getIndexInstance`), {
    params: data,
    // timeout: 30000,
  });
}

/**
 * @description 行业体征指数
 */
export async function getDepartIndustryPhysicalSignIndex(
  data: any,
): Promise<PhysicalsignApi.Result<any>> {
  return request(
    urlProxyApis(`/middlePhysicalSign/getDepartIndustryPhysicalSignIndex`),
    {
      params: data,
    },
  );
}
///zhgl/getIndexDetailEventStatic?physicalSignType=2&indexType=1&indexId=1&objectId=510100&startTime=&endTime=
/**
 * @description 城市问题
 */
export async function getIndexDetailEventStatic(data: any): Promise<{
  noHandleEventCount: string;
  safetyWarningEventCount: string;
  lastMonthMinimumIndex: any;
}> {
  return request(urlProxyApis(`/zhgl/getIndexDetailEventStatic`), {
    params: data,
  });
}

//获取区域数据/physicalSignObject/getOptions?count=10&page=1
export const getIndicatorGapAnalysis = (): Promise<
  PhysicalsignApi.Result<{ items: { label: string; value: string }[] }>
> => {
  return request(
    urlProxyApis(`/physicalSignObject/getOptions?count=100&page=1`),
    {
      method: 'GET',
    },
  );
};

//街道列表指数查询
export const getAreaShapeAndIndexInstance = (
  params: PhysicalsignApi.PhysicalSignParams,
): Promise<PhysicalsignApi.Result<PhysicalsignApi.AreaShapeAndIndexDto>> => {
  return request(urlProxyApis(`/main/getAreaShapeAndIndexInstance`), {
    params,
    method: 'GET',
  });
};

//查询道路层级接口
export async function getRoadGroups(): Promise<PhysicalsignApi.Result<string>> {
  return request(urlProxyApis(`/zhgl/getRoadGroups`), {
    method: 'GET',
  });
}

//道路列表指数查询
export async function getAreaShapeAndIndex(
  params: PhysicalsignApi.PhysicalSignParams & {
    roadName?: string; //道路名称
    objGroup?: string; //道路层级
  },
): Promise<PhysicalsignApi.Result<PhysicalsignApi.AreaShapeAndIndexDto>> {
  return request(urlProxyApis(`/main/getAreaShapeAndIndexInstance`), {
    method: 'GET',
    params,
  });
}

// 右侧城市问题饼状图和待处置数等接口
export async function getCityEventGroupBySource(params: {
  physicalSignType: '1';
  indexType: '1';
  indexId: '1';
  objectId: string;
  startTime?: string;
  endTime?: string;
}): Promise<RespResult<PhysicalsignApi.EventGroupBySourceDto>> {
  return request(urlProxyApis(`/zhgl/getCityEventGroupBySource`), {
    method: 'GET',
    params,
  });
}

//获取所有行业情况
export async function getAllIndutryIndexInstance(params: {
  physicalSignType: string;
  objectId: string;
}): Promise<PhysicalsignApi.Result<PhysicalsignApi.IndutryIndexInstanceDto>> {
  return request(urlProxyApis(`/zhgl/getAllIndutryIndexInstance`), {
    method: 'GET',
    params,
  });
}

//城市运行情况的行业体征
export async function getCityRunIndutryIndexInstance(params: {
  physicalSignType: string;
  objectId: string;
}): Promise<PhysicalsignApi.Result<PhysicalsignApi.IndutryIndexInstanceDto>> {
  return request(urlProxyApis(`/zhgl/getCityRunIndutryIndexInstance`), {
    method: 'GET',
    params,
  });
}

//近三十天体征趋势
export async function TrendAnalysis(
  params: any,
): Promise<PhysicalsignApi.Result<{ indexScore: string; date: string }>> {
  return request(urlProxyApis(`/physicalsignindexinstance/trendAnalysis`), {
    method: 'GET',
    params,
  });
}

//重点区域-事件列表
export async function getNormalEventListForKeyAreas(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventListForKeyAreas`), {
    method: 'GET',
    params,
  });
}

// 重点区域-事件详情
export async function getKeyAreaEventDetail(id: string): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventInfo/${id}`), {
    method: 'GET',
  });
}

//重点区域-数据统计
export async function getNormalEventCountForKeyAreas(
  params: any,
): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventCountForKeyAreas`), {
    method: 'GET',
    params,
  });
}

//重点区域-疑难问题
export async function getDifficultEventForKeyAreas(params: any): Promise<any> {
  return request(urlProxyApis(`/difficultEvent/getDifficultEventForKeyAreas`), {
    method: 'GET',
    params,
  });
}

// 重点区域-近7日趋势
export async function getNormalEventTrendForKeyAreas(
  params: any,
): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventTrendForKeyAreas`), {
    method: 'GET',
    params,
  });
}

// 重点区域-高发类型
export async function getHighIncidenceTypeRoadCountForKeyAreas(
  params: any,
): Promise<any> {
  return request(
    urlProxyApis(`/normalEvent/getHighIncidenceTypeRoadCountForKeyAreas`),
    {
      method: 'GET',
      params,
    },
  );
}

// 重点区域-高发时段
export async function getHighIncidenceTimeCountForKeyAreas(
  params: any,
): Promise<any> {
  return request(
    urlProxyApis(`/normalEvent/getHighIncidenceTimeCountForKeyAreas`),
    {
      method: 'GET',
      params,
    },
  );
}

// 重点区域-高发来源
export async function getHighIncidenceSourceCountForKeyAreas(
  params: any,
): Promise<any> {
  return request(
    urlProxyApis(`/normalEvent/getHighIncidenceSourceCountForKeyAreas`),
    {
      method: 'GET',
      params,
    },
  );
}

export async function getTotalCountForKeyAreas(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getTotalCountForKeyAreas`), {
    method: 'GET',
    params,
  });
}

// 统览模式-行业运行情况-事件统计
export async function getNormalEventCountApi(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventCount`), {
    method: 'GET',
    params,
  });
}

// 统览模式-行业运行情况-事件统计趋势
export async function getNormalEventTrendApi(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventTrend`), {
    method: 'GET',
    params,
  });
}
//环境卫生下钻统计
//?objectId=5101&industry=02&dateType=custom&startTime=2024-11-01&endTime=2024-11-30
export async function getDisposeOverallStatistics(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getDisposeOverallStatistics`), {
    method: 'GET',
    params,
  });
}

//环境卫生下钻高发区域top3
///?objectId=510100&industry=02&limit=3&dateType=custom&startTime=2024-11-01&endTime=2024-11-30
export async function getHighIncidenceTypes(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getHighIncidenceTypes`), {
    method: 'GET',
    params,
  });
}
///?industry=02&limit=5&dateType=custom&startTime=2024-11-01&endTime=2024-11-30&highIncidenceType=area&gridGroup=5+2
//环境卫生下钻高发区域top3

export async function getHighIncidenceAreas(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getHighIncidenceAreas`), {
    method: 'GET',
    params,
  });
}
///normalEvent/getHighIncidenceTimeCount?objectId=5101&industry=01&dateType=month
//环境卫生下钻高发时段
export async function getHighIncidenceTimeCount(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getHighIncidenceTimeCount`), {
    method: 'GET',
    params,
  });
}

//?objectId=5101&industry=01&dateType=month
export async function getHighIncidenceSourceCount(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getHighIncidenceSourceCount`), {
    method: 'GET',
    params,
  });
}

//?industry=02&eventStatus=超期&page=1&count=10&objectId=5101&dateType=custom&startTime=2024-11-01&endTime=2024-11-30

export async function getNormalEventList(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getNormalEventList`), {
    method: 'GET',
    params,
  });
}

export async function getHighIncidenceTypeRoadEventList(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getHighIncidenceTypeRoadEventList`), {
    method: 'GET',
    params,
  });
}
//normalEvent/getOverdueStatusCount?objectId=&industry=&dateType=&startTime=&endTime=&eventStatus=
export async function getOverdueStatusCount(params: any): Promise<any> {
  return request(urlProxyApis(`/normalEvent/getOverdueStatusCount`), {
    method: 'GET',
    params,
  });
}

//疑难问题库基础信息
export async function getStatisticsOfDifficultEvent(data: {
  classification?: string;
}) {
  return request(urlProxyApis(`/tzzsEventInfo/statisticsDifficultEvent`), {
    params: data,
  });
}
//疑难问题库详情列表?page=1&count=10&districtCode=&deptCode=&eventStatus=disposed&listType=2&today=&solvedFlag=&lookAllFlag=true
export async function getPageDifficultEventVO(data:any) {
  return request(urlProxyApis(`/tzzsEventInfo/pageDifficultEventVO`), {
    params: data,
  });
}

/** 获取疑难问题列表 */
export async function getDifficultEventsList(param: {
  page: number;
  count: number;
  classification?: string;
  by?: 'dept';
}) {
  return request(
    urlProxyApis(`/tzzsEventInfo/pageDifficultEventStatisticsVO`),
    {
      method: 'GET',
      params: param,
    },
  );
}

/** 获取疑难问题Top10 */
export async function getDifficultEventsTop10(param: {
  page: number;
  count: number;
  classification?: string;
}) {
  return request(urlProxyApis(`/tzzsEventInfo/pageDifficultEventVO`), {
    method: 'GET',
    params: param,
  });
}

/** 获取疑难问题基础信息 */
export async function getDifficultEventsInfo() {
  return request(urlProxyApis(`/tzzsEventInfo/countDifficultEvent`), {
    method: 'GET',
  });
}
