Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张苑
bi
Commits
5b719b02
Commit
5b719b02
authored
Sep 18, 2021
by
莫坚培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 抽离请求数据v1
parent
f4f05fff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
4 deletions
+148
-4
.prettierrc
.prettierrc
+8
-0
dashboard.js
js/dashboard.js
+140
-4
No files found.
.prettierrc
0 → 100644
View file @
5b719b02
{
"singleQuote": true,
"semi": false,
"tabWidth": 4,
"trailingComma": "none",
"arrowParens": "avoid",
"htmlWhitespaceSensitivity": "ignore"
}
js/dashboard.js
View file @
5b719b02
...
@@ -841,7 +841,8 @@ function initCanvas() {
...
@@ -841,7 +841,8 @@ function initCanvas() {
LineChartDataFun
(
'tool'
)
LineChartDataFun
(
'tool'
)
},
20
)
},
20
)
clearInterval
(
timer1
)
clearInterval
(
timer1
)
setTimer
()
// setTimer()
refreshDataLoop
()
// wrap.style.background = Common.BackColor
// wrap.style.background = Common.BackColor
...
@@ -906,9 +907,144 @@ function setTimer() {
...
@@ -906,9 +907,144 @@ function setTimer() {
}
}
})
})
},
time
);
},
time
);
}
// 轮询数据,用新逻辑,合并各组件的请求数据,做合并请求,例如,300个组件,分成6个请求,每个请求包含50个组件的数据
function
refreshDataLoop
()
{
console
.
log
(
'Controls'
,
Controls
);
let
requestDataList
=
handleControlListInArray
()
console
.
log
(
9999
,
requestDataList
);
if
(
requestDataList
.
length
)
{
request
.
post
(
`/bi/
${
appId
}
/variables/real-time/data/mergeReq`
,
requestDataList
).
then
(
res
=>
{
console
.
log
(
'res123'
,
res
);
})
}
// timer1 = setInterval(()=> {
// }, time)
}
// 对组件的请求数据分组
function
handleControlListInArray
(
sliceNum
)
{
let
dataPool
=
[]
Controls
.
ControlList
.
forEach
((
item
,
index
)
=>
{
switch
(
item
.
ControlType
)
{
case
'datatextblock'
:
// 数值显示
case
'rwtextbox'
:
// 读写框
dataPool
.
push
({
urlType
:
'status'
,
assemblyKey
:
`
${
index
}
`
,
statusDataDTO
:
{
deviceId
:
item
.
CheckData
.
equipmentId
?
item
.
CheckData
.
equipmentId
:
item
.
CheckData
.
equipmentid
,
variableId
:
item
.
CheckData
.
id
,
variableCode
:
item
.
CheckData
.
name
}
})
break
case
'commonlamp'
:
// 矩形状态灯
case
'image'
:
// 动态图片
case
'dynamictext'
:
// 动态文本
case
'ellipselamp'
:
// 圆形状态灯
item
.
DataList
.
forEach
((
dlItem
,
dlIndex
)
=>
{
if
(
dlItem
.
variable
!==
'选择'
&&
dlItem
.
CheckData
)
{
dataPool
.
push
({
urlType
:
'status'
,
assemblyKey
:
`
${
index
}
-
${
dlIndex
}
`
,
statusDataDTO
:
{
deviceId
:
dlItem
.
CheckData
.
equipmentId
?
dlItem
.
CheckData
.
equipmentId
:
dlItem
.
CheckData
.
equipmentid
,
variableId
:
dlItem
.
CheckData
.
id
,
variableCode
:
dlItem
.
CheckData
.
name
}
})
}
})
break
case
'piechart'
:
Controls
.
Data
.
PieChartItemList
.
forEach
(
pieItem
=>
{
if
(
pieItem
.
name
===
item
.
Name
)
{
if
(
pieItem
.
defaultDataConfig
.
datatype
===
'实时数据'
)
{
let
list
=
pieItem
.
option
?.
Variables
||
[]
let
pieChartOrPanel
=
list
.
map
(
variableItem
=>
{
let
vc
=
variableItem
.
CheckData
return
{
deviceId
:
vc
.
equipmentId
?
vc
.
equipmentId
:
vc
.
equipmentid
,
variableId
:
vc
.
id
,
variableCode
:
vc
.
name
}
})
dataPool
.
push
({
urlType
:
'pieChartOrPanel'
,
assemblyKey
:
`
${
index
}
`
,
pieChartOrPanel
})
}
}
})
break
case
'dashboardchart'
:
Controls
.
Data
.
DashBoardChartItemList
.
forEach
(
dashItem
=>
{
if
(
dashItem
.
name
===
item
.
Name
)
{
if
(
dashItem
.
defaultDataConfig
.
datatype
===
'实时数据'
)
{
let
VariableCheckDataObj
=
dashItem
.
option
?.
Variable
?.
CheckData
||
{}
dataPool
.
push
({
urlType
:
'pieChartOrPanel'
,
assemblyKey
:
`
${
index
}
`
,
pieChartOrPanel
:
[{
deviceId
:
VariableCheckDataObj
.
equipmentId
?
VariableCheckDataObj
.
equipmentId
:
VariableCheckDataObj
.
equipmentid
,
variableId
:
VariableCheckDataObj
.
id
,
variableCode
:
VariableCheckDataObj
.
name
}]
})
}
}
})
break
case
'linechart'
:
Controls
.
Data
.
LineChartItemList
.
forEach
(
pieItem
=>
{
if
(
pieItem
.
name
===
item
.
Name
)
{
if
(
pieItem
.
defaultDataConfig
.
datatype
===
'实时数据'
)
{
let
list
=
pieItem
.
option
?.
Variables
||
[]
list
.
forEach
((
variableItem
,
variableIndex
)
=>
{
let
vc
=
variableItem
.
CheckData
dataPool
.
push
({
urlType
:
'limit'
,
assemblyKey
:
`
${
index
}
-
${
variableIndex
}
`
,
limitData
:
{
deviceId
:
vc
.
equipmentId
?
vc
.
equipmentId
:
vc
.
equipmentid
,
variableId
:
vc
.
id
,
variableCode
:
vc
.
name
}
})
})
}
}
})
break
case
'barchart'
:
Controls
.
Data
.
BarChartItemList
.
forEach
(
pieItem
=>
{
if
(
pieItem
.
name
===
item
.
Name
)
{
if
(
pieItem
.
defaultDataConfig
.
datatype
===
'实时数据'
)
{
let
list
=
pieItem
.
option
?.
Variables
||
[]
list
.
forEach
((
variableItem
,
variableIndex
)
=>
{
let
vc
=
variableItem
.
CheckData
dataPool
.
push
({
urlType
:
'limit'
,
assemblyKey
:
`
${
index
}
-
${
variableIndex
}
`
,
limitData
:
{
deviceId
:
vc
.
equipmentId
?
vc
.
equipmentId
:
vc
.
equipmentid
,
variableId
:
vc
.
id
,
variableCode
:
vc
.
name
}
})
})
}
}
})
break
}
})
return
dataPool
}
}
// 点击触发刷新功能
// 点击触发刷新功能
...
@@ -1619,11 +1755,11 @@ async function renderDataText(index) {
...
@@ -1619,11 +1755,11 @@ async function renderDataText(index) {
if
(
JSON
.
stringify
(
getHistory
)
==
"{}"
||
(
getHistory
.
hasOwnProperty
(
`
${
url
}
`
)
&&
(
curTime
-
getHistory
[
url
].
time
)
/
1000
>
3
)){
if
(
JSON
.
stringify
(
getHistory
)
==
"{}"
||
(
getHistory
.
hasOwnProperty
(
`
${
url
}
`
)
&&
(
curTime
-
getHistory
[
url
].
time
)
/
1000
>
3
)){
await
request
.
get
(
url
).
then
(
res
=>
{
await
request
.
get
(
url
).
then
(
res
=>
{
getHistory
[
url
]
=
{
data
:
res
.
data
.
data
,
time
:
Date
.
now
()
}
getHistory
[
url
]
=
{
data
:
res
.
data
.
data
,
time
:
Date
.
now
()
}
if
(
res
.
data
.
data
)
{
if
(
res
.
data
.
data
&&
res
.
data
.
data
[
item
.
CheckData
.
name
]
)
{
try
{
try
{
res
.
data
.
data
[
item
.
CheckData
.
name
]
=
res
.
data
.
data
[
item
.
CheckData
.
name
].
toFixed
(
dight
)
res
.
data
.
data
[
item
.
CheckData
.
name
]
=
res
.
data
.
data
[
item
.
CheckData
.
name
].
toFixed
(
dight
)
}
catch
(
e
){
}
catch
(
e
){
console
.
log
(
'error'
)
console
.
log
(
'error'
,
e
)
}
}
let
Data
=
res
.
data
.
data
[
item
.
CheckData
.
name
]
let
Data
=
res
.
data
.
data
[
item
.
CheckData
.
name
]
if
(
JSON
.
stringify
(
res
.
data
.
data
)
!==
"{}"
)
{
if
(
JSON
.
stringify
(
res
.
data
.
data
)
!==
"{}"
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment