Commit 384e9a5c authored by ninglx's avatar ninglx

路口详情tab数据处理逻辑修正 axios放行protobuf修改解析方式

parent e5b71184
......@@ -37,9 +37,15 @@ export const crowdTracksList = (data) => {
}
// 历史灯态
export const getLightByTimeAndCrossId = (params) => {
return fetch('/utc/signalStatus/lightStatusHist', {}, 'POST', params)
}
// export const getLightByTimeAndCrossId = (params) => {
// return fetch('/utc/signalStatus/lightStatusHist', {}, 'POST', params)
// }
export const getLightByTimeAndCrossId = (data) =>
request({
url: '/utc/signalStatus/lightStatusHist',
method: 'get',
params: data,
})
// 获取多车轨迹详情
// export const multiVehicleTrackDetail = (data) => fetch('/holo/carTrack/multi', data, 'GET')
......
import axios from 'axios'
import axios from "axios";
import { tansParams, blobValidate } from "./tools";
import cache from './cache'
import { saveAs } from 'file-saver'
import cache from "./cache";
import { saveAs } from "file-saver";
let downloadLoadingInstance;
// 是否显示重新登录
export let isRelogin = { show: false };
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
// 创建axios实例
const service = axios.create({
// 超时
timeout: 1000000
})
// 超时
timeout: 1000000,
});
// request拦截器
service.interceptors.request.use(config => {
service.interceptors.request.use(
(config) => {
// console.log('axios request...', config);
// 是否需要防止数据重复提交
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
const isRepeatSubmit = (config.headers || {}).repeatSubmit === false;
// get请求映射params参数
if (config.method === 'get' && config.params) {
let url = config.url + '?' + tansParams(config.params);
url = url.slice(0, -1);
config.params = {};
config.url = url;
if (config.method === "get" && config.params) {
let url = config.url + "?" + tansParams(config.params);
url = url.slice(0, -1);
config.params = {};
config.url = url;
}
if (!isRepeatSubmit && (config.method === 'post' || config.method === 'put')) {
const requestObj = {
url: config.url,
data: typeof config.data === 'object' ? JSON.stringify(config.data) : config.data,
time: new Date().getTime(),
}
const sessionObj = cache.session.getJSON('sessionObj')
if (sessionObj === undefined || sessionObj === null || sessionObj === '') {
cache.session.setJSON('sessionObj', requestObj)
if (
!isRepeatSubmit &&
(config.method === "post" || config.method === "put")
) {
const requestObj = {
url: config.url,
data:
typeof config.data === "object"
? JSON.stringify(config.data)
: config.data,
time: new Date().getTime(),
};
const sessionObj = cache.session.getJSON("sessionObj");
if (
sessionObj === undefined ||
sessionObj === null ||
sessionObj === ""
) {
cache.session.setJSON("sessionObj", requestObj);
} else {
const s_url = sessionObj.url; // 请求地址
const s_data = sessionObj.data; // 请求数据
const s_time = sessionObj.time; // 请求时间
const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
if (
s_data === requestObj.data &&
requestObj.time - s_time < interval &&
s_url === requestObj.url
) {
const message = "数据正在处理,请勿重复提交";
console.warn(`[${s_url}]: ` + message);
return Promise.reject(new Error(message));
} else {
const s_url = sessionObj.url; // 请求地址
const s_data = sessionObj.data; // 请求数据
const s_time = sessionObj.time; // 请求时间
const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
const message = '数据正在处理,请勿重复提交';
console.warn(`[${s_url}]: ` + message)
return Promise.reject(new Error(message))
} else {
cache.session.setJSON('sessionObj', requestObj)
}
cache.session.setJSON("sessionObj", requestObj);
}
}
}
return config
}, error => {
console.log(error)
Promise.reject(error)
})
return config;
},
(error) => {
console.log(error);
Promise.reject(error);
}
);
// 响应拦截器
service.interceptors.response.use(res => {
console.log('axios response...', res);
service.interceptors.response.use(
(res) => {
console.log("axios response...", res);
// 未设置状态码则默认成功状态
const code = res.data.code || 200;
// 二进制数据则直接返回
if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
// 给二进制数据添加对应的请求参数信息,避免接收到不需要的数据
// return { data: res.data, params: JSON.parse(res.config.data) }
return res.data
if (
res.request.responseType === "blob" ||
res.request.responseType === "arraybuffer"
) {
let enc = new TextDecoder("utf-8");
let json = null
try {
json = JSON.parse(enc.decode(new Uint8Array(res.data)));
} catch (e) {
json = res.data
}
return json
}
if (code === 401) {
if (!ELEMENT.$_overTime) {
ELEMENT.$_overTime = ELEMENT.Notification.error({
title: "失败",
message: "code 401, 3秒后退出登录",
});
setTimeout(() => {
window.location.href = "/";
}, 3000);
}
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
if (!ELEMENT.$_overTime) {
ELEMENT.$_overTime = ELEMENT.Notification.error({
title: "失败",
message: "code 401, 3秒后退出登录",
});
setTimeout(() => {
window.location.href = "/";
}, 3000);
}
return Promise.reject("无效的会话,或者会话已过期,请重新登录。");
}
if (code !== 200 && res.config.showMsg !== false) {
ELEMENT.Message.error(res.data.message || res.data.status)
if (code == 200) {
if (res.config.showMsg) {
ELEMENT.Message.success(res.data.message || res.data.status);
}
return res.data;
} else {
if (res.config.showMsg) {
ELEMENT.Message.success(res.data.message || res.data.status)
}
if (res.config.showMsg) {
ELEMENT.Message.error(res.data.message || res.data.status);
}
return null
}
return res.data
})
// 通用下载方法
export function download(url, params, filename) {
downloadLoadingInstance = ELEMENT.Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return service.get(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob'
}).then(async (data) => {
const isLogin = await blobValidate(data);
if (isLogin) {
const blob = new Blob([data])
const link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = filename;
link.click();
// saveAs(blob, filename)
} else {
console.log('isNotBlob');
}
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
downloadLoadingInstance.close();
})
}
},
(error) => {
ELEMENT.Message.error(error.message);
return Promise.reject(error);
}
);
export function getBlob(url) {
return service.get(url, {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob',
}).then(async (data) => {
const blob = new Blob([data])
return blob
return service
.get(url, {
headers: { "Content-Type": "application/x-www-form-urlencoded" },
responseType: "blob",
})
.then(async (data) => {
const blob = new Blob([data]);
return blob;
});
}
export default service
export default service;
......@@ -112,7 +112,7 @@
</template>
<script>
import { download, getBlob } from "../../../utils/request";
// import { download, getBlob } from "../../../utils/request";
// import fetch from "@/utils/fetch";
import { getReports, getReportsByPage } from "../../../dao/analysis";
import JSZip from "jszip";
......
......@@ -158,8 +158,8 @@ export default {
mounted() {},
watch: {},
methods: {
tableRowStyle(){
return { height: 'calc((100/5)% - )'}
tableRowStyle() {
return { height: "calc((100/5)% - )" };
},
convertDiff(scope) {
if (
......@@ -180,11 +180,9 @@ export default {
);
}
if (scope.row.indexName.includes("流量")) {
return (
Math.abs(
Number(scope.row.current) - Number(scope.row.compare)
).toFixed(0)
);
return Math.abs(
Number(scope.row.current) - Number(scope.row.compare)
).toFixed(0);
}
if (scope.row.indexName.includes("时间")) {
return (
......@@ -208,7 +206,7 @@ export default {
if (typeof scope.row[which] === "boolean") {
return "暂无数据";
}
return scope.row[which].toFixed(0)
return scope.row[which].toFixed(0);
}
if (scope.row.indexName.includes("时间")) {
if (typeof scope.row[which] === "boolean") {
......@@ -253,7 +251,6 @@ export default {
this.passingRateOptionData[key][k] = [];
}
}
// debugger;
let currentT = this.getTimeStr(this.currentTimeStamp);
let compareT = this.getTimeStr(this.compareTimeStamp);
Promise.all([
......@@ -269,7 +266,6 @@ export default {
}),
]).then(([current, compare]) => {
this.chartLoading = false;
this.$emit("finish");
console.log("right current compare", current, compare);
for (let indexValue of current.content) {
this.passingRateOptionData.current.xAxis.push(
......@@ -283,11 +279,12 @@ export default {
this.passingRateOptionData.current["一次停车通过率"].push(
indexValue.onceStopRate
);
this.passingRateOptionData.current["其他"].push(
let other = (
100 -
Number(indexValue.noStopRate) -
Number(indexValue.onceStopRate)
);
Number(indexValue.noStopRate) -
Number(indexValue.onceStopRate)
).toFixed(2);
this.passingRateOptionData.current["其他"].push(other);
}
for (let indexValue of compare.content) {
if (
......@@ -310,11 +307,12 @@ export default {
this.passingRateOptionData.compare["一次停车通过率"].push(
indexValue.onceStopRate
);
this.passingRateOptionData.compare["其他"].push(
let other = (
100 -
Number(indexValue.noStopRate) -
Number(indexValue.onceStopRate)
);
Number(indexValue.noStopRate) -
Number(indexValue.onceStopRate)
).toFixed(2);
this.passingRateOptionData.compare["其他"].push(other);
}
this.$nextTick(() => {
this.passingRateChart?.clear();
......@@ -342,8 +340,7 @@ export default {
tooltip: {
trigger: "axis",
axisPointer: {
// Use axis to trigger tooltip
type: "shadow", // 'shadow' as default; can also be 'line' or 'shadow'
type: "shadow",
},
textStyle: {
fontSize: getFontSize(12),
......@@ -380,7 +377,6 @@ export default {
xAxis: [
{
type: "category",
// data: this.passingRateOptionData.current.xAxis.length,
data: this.passingRateOptionData[
this.passingRateOptionData.current.xAxis.length >
this.passingRateOptionData.compare.xAxis.length
......@@ -418,7 +414,6 @@ export default {
color: "rgba(217, 231, 255, 1)",
fontSize: getFontSize(16),
align: "left",
// padding: [0, 0, 0, getFontSize(15)]
},
axisLabel: {
fontSize: getFontSize(12),
......@@ -431,14 +426,12 @@ export default {
for (let key in this.passingRateOptionData.current) {
if (key !== "xAxis") {
series.push({
// barWidth: getFontSize(22),
name: key,
type: "bar",
barGap: '40%',
barGap: "40%",
emphasis: {
focus: "series",
},
// barWidth: 8,
stack: 1,
label: {
show: key === "一次停车通过率",
......@@ -454,10 +447,8 @@ export default {
for (let key in this.passingRateOptionData.compare) {
if (key !== "xAxis") {
series.push({
// barWidth: getFontSize(22),
name: key,
type: "bar",
// barGap: 1,
emphasis: {
focus: "series",
},
......@@ -467,7 +458,7 @@ export default {
position: "bottom",
formatter: "对比值",
color: "rgba(217, 231, 255, 1)",
fontSize:getFontSize(10),
fontSize: getFontSize(10),
},
data: this.passingRateOptionData.compare[key],
});
......@@ -492,13 +483,12 @@ export default {
};
</script>
<style lang='less' scoped>
::v-deep .row-deep{
height: 36px
<style lang="less" scoped>
::v-deep .row-deep {
height: 36px;
}
::v-deep .row-not{
height: 36px
::v-deep .row-not {
height: 36px;
}
@import url("../../assets/less/elementTable.less");
......@@ -602,7 +592,7 @@ export default {
/*滚动条的上下两端的按钮*/
::-webkit-scrollbar-button {
width: 0;
width: 0;
height: 0;
}
</style>
\ No newline at end of file
</style>
......@@ -870,7 +870,7 @@ export default {
this.refreshLightWs("zoom");
if (!this.radarShow) {
this.radarShow = true;
// this.loadRadars();
this.loadRadars();
} else {
this.clearRadarWave();
setTimeout(() => {
......
......@@ -33,7 +33,7 @@
@change="selectCrossChange"
>
<el-option
v-for="(item,index) of this.$store.state.dicts.CrossInfo"
v-for="(item, index) of this.$store.state.dicts.CrossInfo"
:key="index"
:label="item.name"
:value="item.id"
......@@ -89,7 +89,7 @@
:h="200"
:x="500"
:y="300"
v-for="(item,index) of videos"
v-for="(item, index) of videos"
:key="index"
class="videoItem"
>
......@@ -152,7 +152,7 @@
>
<el-select v-model="speed" class="ctrl-select">
<el-option
v-for="(item,index) of speeds"
v-for="(item, index) of speeds"
:key="index"
:label="item.label"
:value="item.value"
......@@ -518,15 +518,20 @@ export default {
let realData = FrameList.decode(data); // protobuf根据定义类型转json
console.log("realData", realData);
fullTrack = realData.frameInfo;
// 计算返回数据的总时长
let fullTime =
new Date(fullTrack[fullTrack.length - 1].frameTime).getTime() -
new Date(fullTrack[0].frameTime).getTime();
this.duration = fullTime;
console.log("duration...", this.duration);
this.$nextTick(() => {
this.render();
});
if (fullTrack.length) {
// 计算返回数据的总时长
let fullTime =
new Date(fullTrack[fullTrack.length - 1].frameTime).getTime() -
new Date(fullTrack[0].frameTime).getTime();
this.duration = fullTime;
console.log("duration...", this.duration);
this.$nextTick(() => {
this.render();
});
}
else{
this.$message("暂无轨迹数据");
}
} else {
this.$message("暂无轨迹数据");
}
......@@ -654,9 +659,9 @@ export default {
let timeBetween =
new Date(dillPath[0].frameTime).getTime() -
new Date(lastFrame.frameTime).getTime();
console.log('-frame',timeBetween);
timeDiff = timeBetween < 0 ? 10 : timeBetween > 1000 ? 10 : timeBetween-10;
console.log("-frame", timeBetween);
timeDiff =
timeBetween < 0 ? 10 : timeBetween > 1000 ? 10 : timeBetween - 10;
}
timeDiff = timeDiff / this.speed;
lastFrame = Object.assign({}, dillPath[0], {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment