// 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 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 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 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,
  });
}