baseStationQueryApi.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /**
  2. * Copyright (c) 2013-Now https://jeesite.com All rights reserved.
  3. * No deletion without permission, or be held responsible to law.
  4. * @author ThinkGem
  5. */
  6. import { defHttp } from '@jeesite/core/utils/http/axios';
  7. import { useGlobSetting } from '@jeesite/core/hooks/setting';
  8. import { downloadByData } from '@jeesite/core/utils/file/download';
  9. import type { Result, UploadFileParams } from '@jeesite/types/axios';
  10. import type { AxiosProgressEvent, AxiosResponse } from 'axios';
  11. const { adminPath, ctxAdminPath, ctxPath } = useGlobSetting();
  12. export interface BaseStationSearchParams {
  13. mnc: string | number;
  14. lac: string | number;
  15. ci: string | number;
  16. }
  17. export interface BaseStationSearchLocation {
  18. latitude?: string | number | null;
  19. lat?: string | number | null;
  20. y?: string | number | null;
  21. longitude?: string | number | null;
  22. lng?: string | number | null;
  23. lon?: string | number | null;
  24. x?: string | number | null;
  25. range?: string | number | null;
  26. radius?: string | number | null;
  27. address?: string | null;
  28. addr?: string | null;
  29. stationName?: string | null;
  30. stationAddr?: string | null;
  31. lac?: string | number | null;
  32. ci?: string | number | null;
  33. cid?: string | number | null;
  34. mnc?: string | number | null;
  35. operatorName?: string | null;
  36. yys?: string | null;
  37. }
  38. export type BaseStationSearchResponse =
  39. | Array<string | number | null>
  40. | BaseStationSearchLocation
  41. | BaseStationSearchLocation[]
  42. | {
  43. data?: Array<string | number | null> | BaseStationSearchLocation | BaseStationSearchLocation[] | null;
  44. rows?: BaseStationSearchLocation[] | null;
  45. list?: BaseStationSearchLocation[] | null;
  46. records?: BaseStationSearchLocation[] | null;
  47. result?: Array<string | number | null> | BaseStationSearchLocation | BaseStationSearchLocation[] | null;
  48. };
  49. export interface BaseStationImportRow {
  50. field1?: string;
  51. lac?: string;
  52. cid?: string;
  53. yys?: string;
  54. field4?: string;
  55. field5?: string;
  56. field6?: string;
  57. field7?: string;
  58. field8?: string;
  59. }
  60. export interface BaseStationImportPayload {
  61. data?: BaseStationImportRow[];
  62. file?: string;
  63. path?: string;
  64. filePath?: string;
  65. result?: string | Recordable | null;
  66. }
  67. export interface BaseStationImportResponse {
  68. code?: number;
  69. message?: string;
  70. msg?: string;
  71. data?: BaseStationImportPayload | string | Recordable | null;
  72. path?: string;
  73. result?: string | Recordable | null;
  74. }
  75. export type BaseStationTemplateResponse =
  76. | string
  77. | {
  78. code?: number;
  79. message?: string;
  80. msg?: string;
  81. data?: string | { path?: string; filePath?: string; file?: string } | null;
  82. path?: string;
  83. filePath?: string;
  84. file?: string;
  85. };
  86. export interface BaseStationConvertResponse {
  87. code?: number;
  88. message?: string;
  89. msg?: string;
  90. data?: string | Recordable | null;
  91. path?: string;
  92. result?: string | Recordable | null;
  93. }
  94. export const searchBaseStation = (params: BaseStationSearchParams) =>
  95. defHttp.get<BaseStationSearchResponse>({ url: adminPath + '/tower/qry', params });
  96. export const importBaseStationFile = (
  97. params: UploadFileParams,
  98. onUploadProgress: (progressEvent: AxiosProgressEvent) => void,
  99. caseId?: string | number,
  100. ) =>
  101. defHttp.uploadFile<BaseStationImportResponse>(
  102. {
  103. url:
  104. ctxPath +
  105. adminPath +
  106. '/tower/covFile' +
  107. (caseId !== undefined && caseId !== null && String(caseId).trim()
  108. ? `?caseId=${encodeURIComponent(String(caseId).trim())}`
  109. : ''),
  110. onUploadProgress,
  111. },
  112. params,
  113. );
  114. export const fetchBaseStationTemplatePath = () =>
  115. defHttp.get<BaseStationTemplateResponse>(
  116. { url: adminPath + '/tower/tmpFile' },
  117. { isTransformResponse: false, errorMessageMode: 'message' },
  118. );
  119. export const convertBaseStationData = (file: string) =>
  120. defHttp.get<string>(
  121. { url: adminPath + '/tower/covFile', params: { file } },
  122. { errorMessageMode: 'none', skipSuccessMessage: true },
  123. );