file.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. //import axios from 'axios';
  2. import {FILE_MODULE} from "./_prefix";
  3. import request from '../utils/request';
  4. import {axios} from '../utils/request'
  5. /**
  6. * 添加文件 POST /upload
  7. * @param {*} payload:formData,直接放Body里
  8. * @returns
  9. */
  10. export const UploadFile = payload => {
  11. return axios.post(`${FILE_MODULE}/upload`,
  12. payload
  13. ,{
  14. headers:{
  15. 'Content-Type': "multipart/form-data;"
  16. // 'Content-Type': "false",
  17. // 'Process-Data': 'false',
  18. }
  19. }).then((res) => {
  20. return res
  21. })
  22. }
  23. /**
  24. * ({
  25. url: `${FILE_MODULE}/upload`,
  26. method: 'post',
  27. data: payload,
  28. "Process-Data": false,// 告诉axios不要去处理发送的数据(重要参数)
  29. "Content-Type": false, // 告诉axios不要去设置Content-Type请求头
  30. }).then(res => {
  31. return res.data
  32. });
  33. */
  34. // return axios.post(`${FILE_MODULE}/upload`,
  35. // payload,
  36. // {
  37. // headers:{
  38. // 'Content-Type': "multipart/form-data",
  39. // // 'Content-Type': "false",
  40. // // 'Process-Data': 'false',
  41. // }
  42. // }
  43. // ).then(res => {
  44. // return res.data;
  45. // });
  46. /**
  47. * 获得文件列表 GET /get/all
  48. * @param {*} userId 用户Id
  49. * @returns
  50. */
  51. export const GetAllFile = userId => {
  52. return axios.get(`${FILE_MODULE}/get/all`, {
  53. params:{
  54. userId: userId
  55. }
  56. }).then( res => {
  57. return res;
  58. });
  59. }
  60. // 直接返回数据
  61. // return Promise.resolve({
  62. // "timestamp": 1649397417317,
  63. // "status": 200,
  64. // "data": [
  65. // {
  66. // "fileId": "1",
  67. // "fileName": "event_data"
  68. // }
  69. // ]
  70. // })
  71. /**
  72. * 获得文件具体信息 GET /get/detail
  73. * @param {*} fileId 文件Id
  74. * @returns
  75. */
  76. export const getFileDetail = fileId => {
  77. return axios.get(`${FILE_MODULE}/get/detail`, {
  78. params: {
  79. fileId: fileId
  80. }
  81. }).then( res => {
  82. return res;
  83. })
  84. }
  85. //直接返回数据:
  86. // return Promise.resolve({
  87. // "timestamp": 1649398931190,
  88. // "status": 200,
  89. // "data": {
  90. // "fileName": "event_data",
  91. // "createTime": "2022-03-29T09:25:43.154+00:00",
  92. // "fileStrucInfo": {
  93. // "totalRows": "754"
  94. // },
  95. // "headerInfos": [
  96. // {
  97. // "id": 103,
  98. // "fileInfoId": 1,
  99. // "fieldName": "frame_index",
  100. // "aliasName": "",
  101. // "fieldDes": "",
  102. // "nullsRatio": 0.0,
  103. // "conOrDis": 1,
  104. // "fieldType": "int",
  105. // "valueInfo": "[\"79\",\"89992\"]"
  106. // },
  107. // {
  108. // "id": 104,
  109. // "fileInfoId": 1,
  110. // "fieldName": "time",
  111. // "aliasName": "",
  112. // "fieldDes": "",
  113. // "nullsRatio": 0.0,
  114. // "conOrDis": 1,
  115. // "fieldType": "double",
  116. // "valueInfo": "[\"3.16\",\"3599.68\"]"
  117. // },
  118. // {
  119. // "id": 105,
  120. // "fileInfoId": 1,
  121. // "fieldName": "road",
  122. // "aliasName": "",
  123. // "fieldDes": "",
  124. // "nullsRatio": 0.0,
  125. // "conOrDis": 0,
  126. // "fieldType": "string",
  127. // "valueInfo": "[\"R\",\"L\"]"
  128. // },
  129. // {
  130. // "id": 106,
  131. // "fileInfoId": 1,
  132. // "fieldName": "lane",
  133. // "aliasName": "",
  134. // "fieldDes": "",
  135. // "nullsRatio": 0.0,
  136. // "conOrDis": 0,
  137. // "fieldType": "string",
  138. // "valueInfo": "[\"r\",\"m\",\"l\"]"
  139. // },
  140. // {
  141. // "id": 107,
  142. // "fileInfoId": 1,
  143. // "fieldName": "vehicle_class",
  144. // "aliasName": "",
  145. // "fieldDes": "",
  146. // "nullsRatio": 0.0,
  147. // "conOrDis": 0,
  148. // "fieldType": "string",
  149. // "valueInfo": "[\"car\",\"truck\",\"bus\"]"
  150. // },
  151. // {
  152. // "id": 108,
  153. // "fileInfoId": 1,
  154. // "fieldName": "vehicle_id",
  155. // "aliasName": "",
  156. // "fieldDes": "",
  157. // "nullsRatio": 0.0,
  158. // "conOrDis": 1,
  159. // "fieldType": "int",
  160. // "valueInfo": "[\"20\",\"46862\"]"
  161. // },
  162. // {
  163. // "id": 109,
  164. // "fileInfoId": 1,
  165. // "fieldName": "event_type",
  166. // "aliasName": "",
  167. // "fieldDes": "",
  168. // "nullsRatio": 0.0,
  169. // "conOrDis": 0,
  170. // "fieldType": "string",
  171. // "valueInfo": "[\"cruise\",\"overdrive\"]"
  172. // },
  173. // {
  174. // "id": 110,
  175. // "fileInfoId": 1,
  176. // "fieldName": "duration",
  177. // "aliasName": "",
  178. // "fieldDes": "",
  179. // "nullsRatio": 0.0,
  180. // "conOrDis": 0,
  181. // "fieldType": "string",
  182. // "valueInfo": "[\"48,60\",\"24,36\",\"36,48\",\"12,24\",\"0,12\"]"
  183. // }
  184. // ]
  185. // }
  186. // })
  187. // }
  188. /**
  189. * 删除文件 GET /delete
  190. * @param {*} fileId
  191. * @returns
  192. */
  193. export const deleteFile = fileId => {
  194. return axios.get(`${FILE_MODULE}/delete`, {
  195. params:{
  196. fileId: fileId
  197. }
  198. }).then( res => {
  199. return res;
  200. });
  201. }
  202. /**
  203. * 文件分析 GET /analysis/fields
  204. * @param {*} payload
  205. * @returns
  206. */
  207. export const analysisFile = (fieldIds,funcId) => {
  208. //fieldIds=JSON.stringify(fieldIds)
  209. console.log(fieldIds)
  210. fieldIds=JSON.parse(fieldIds)
  211. console.log(fieldIds)
  212. let url=`${FILE_MODULE}/analysis/fields?funcId=${funcId}`
  213. for(let i=0;i<fieldIds.length;i++){
  214. let fieldId=fieldIds[i]
  215. url+=`&fieldIds=${fieldId}`
  216. }
  217. console.log(url)
  218. return axios.get(url).then(res => {
  219. return res;
  220. });
  221. // if (funcId==1){
  222. // return Promise.resolve({
  223. // "timestamp": 1649561125585,
  224. // "status": 200,
  225. // "data": {
  226. // "105_statistical": {
  227. // "R": 330.0,
  228. // "L": 424.0
  229. // },
  230. // "105_distribution": {
  231. // "R": 0.4376657824933687,
  232. // "L": 0.5623342175066314
  233. // }
  234. // }
  235. // });
  236. // }
  237. // if (funcId==2){
  238. // return Promise.resolve({
  239. // "timestamp": 1649561125585,
  240. // "status": 200,
  241. // "data":{
  242. // "103": [
  243. // 79.0,
  244. // 737.0,
  245. // 753.0],
  246. // "104": [
  247. // 3.16,
  248. // 29.48,
  249. // 30.12],
  250. // "108": [
  251. // 20.0,
  252. // 291.0,
  253. // 318.0]
  254. // }
  255. // });
  256. // }
  257. // if (funcId==3){
  258. // return Promise.resolve({
  259. // "timestamp": 1649561321298,
  260. // "status": 200,
  261. // "data": {
  262. // "frame_index": {
  263. // "max": 89992.0,
  264. // "variance": 6.474726567563616E8,
  265. // "mean": 45439.82360742705,
  266. // "stddev": 25445.484014975264
  267. // }
  268. // }
  269. // })
  270. // }
  271. // if (funcId==4){
  272. // return Promise.resolve({
  273. // "timestamp": 1649561409955,
  274. // "status": 200,
  275. // "data": {
  276. // "103": {
  277. // "skewness": -0.010820149962232854,
  278. // "kurtosis": -1.0998405481091291
  279. // }
  280. // }
  281. // })
  282. // }
  283. // if (funcId==5){
  284. // return Promise.resolve({
  285. // "timestamp": 1649561470265,
  286. // "status": 200,
  287. // "data": {
  288. // "Corr": 0.9999999999999994
  289. // }
  290. // })
  291. // }
  292. // return Promise.resolve({
  293. // "timestamp": 1649561470265,
  294. // "status": 400,
  295. // "data": ""
  296. // })
  297. }