|
@@ -123,6 +123,7 @@ const Environment: React.FC = () => {
|
|
|
//根据设备状态返回不同的 颜色
|
|
|
const getColorOpacity = (value: any, type?: string): string => {
|
|
|
let colorStr = '';
|
|
|
+ // console.log('getColorOpacity-selNav', selNav, navigatorList);
|
|
|
if (selNav.id == 'all') {
|
|
|
//全部设备时 colorStr赋值
|
|
|
var filterRes = navigatorList.filter(function (item) {
|
|
@@ -216,7 +217,6 @@ const Environment: React.FC = () => {
|
|
|
};
|
|
|
//获取地图 mapList
|
|
|
useEffect(() => {
|
|
|
- getProjectEquipType();
|
|
|
if (selFloorId) {
|
|
|
changeLastFloorId(selFloorId);
|
|
|
setLoading(true);
|
|
@@ -288,7 +288,7 @@ const Environment: React.FC = () => {
|
|
|
[mapListCopy],
|
|
|
);
|
|
|
|
|
|
- const queryDeviceManage = () => {
|
|
|
+ const queryDeviceManage = (equiptTypeArr: any) => {
|
|
|
//setLoading(true);
|
|
|
return queryEquipStatistics({
|
|
|
floorId: selFloorId,
|
|
@@ -300,13 +300,14 @@ const Environment: React.FC = () => {
|
|
|
var statistics = res.data.statistics || [];
|
|
|
//赋值 运行中的设备数量
|
|
|
|
|
|
- navigatorList.forEach(function (nItem) {
|
|
|
+ equiptTypeArr.forEach(function (nItem) {
|
|
|
var fres = statistics.filter((sItem: statistics) => {
|
|
|
return sItem.equipType == nItem.id;
|
|
|
});
|
|
|
nItem.num = (fres[0] || {}).runCount;
|
|
|
});
|
|
|
- setNavigatorList(navigatorList);
|
|
|
+ //console.log('queryDeviceManage333-arr', equiptTypeArr);
|
|
|
+ setNavigatorList(equiptTypeArr);
|
|
|
//设备空间信息
|
|
|
var spaceList = res.data.spaceList || [];
|
|
|
spaceList.forEach((item: any) => {
|
|
@@ -343,17 +344,19 @@ const Environment: React.FC = () => {
|
|
|
return 'next';
|
|
|
})
|
|
|
.catch(() => {
|
|
|
+ setNavigatorList(equiptTypeArr);
|
|
|
// setLoading(false);
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
let setTimer1 = useRef();
|
|
|
let setTimer2 = useRef();
|
|
|
|
|
|
- async function getDeviceStatus() {
|
|
|
- await queryDeviceManage().then((res) => {
|
|
|
+ function getDeviceStatus(equiptTypeArr: any) {
|
|
|
+ queryDeviceManage(equiptTypeArr).then((res) => {
|
|
|
clearTimeout(setTimer1.current);
|
|
|
setTimer1.current = setTimeout(() => {
|
|
|
- getDeviceStatus();
|
|
|
+ getDeviceStatus(equiptTypeArr);
|
|
|
}, 8000);
|
|
|
});
|
|
|
}
|
|
@@ -378,7 +381,9 @@ const Environment: React.FC = () => {
|
|
|
arr.push(item);
|
|
|
}
|
|
|
});
|
|
|
- setNavigatorList(arr);
|
|
|
+ //console.log('setNavigatorList-arr1111', arr);
|
|
|
+ //setNavigatorList(arr);
|
|
|
+ return arr;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -386,6 +391,7 @@ const Environment: React.FC = () => {
|
|
|
//获取有人无人
|
|
|
querySpaceAdjustList(sfId).then((res) => {
|
|
|
//debugger;
|
|
|
+ clearTimeout(setTimer2.current);
|
|
|
setTimer2.current = setTimeout(() => {
|
|
|
getSpaceHasPerson(sfId);
|
|
|
}, 8000);
|
|
@@ -393,34 +399,23 @@ const Environment: React.FC = () => {
|
|
|
}
|
|
|
//获取设备状态 设备种类
|
|
|
useEffect(() => {
|
|
|
- if (selFloorId) {
|
|
|
- getDeviceStatus();
|
|
|
- getSpaceHasPerson(selFloorId);
|
|
|
-
|
|
|
- // queryDeviceManage(); //第一次执行
|
|
|
- // if (setTimer.current) {
|
|
|
- // clearInterval(setTimer.current);
|
|
|
- // setTimer.current = null;
|
|
|
- // }
|
|
|
- // //循环调接口
|
|
|
- // setTimer.current = setInterval(() => {
|
|
|
- // queryDeviceManage();
|
|
|
- // }, 3000);
|
|
|
- }
|
|
|
+ (async function () {
|
|
|
+ var equiptTypeArr = await getProjectEquipType();
|
|
|
+ //console.log('getProjectEquipType222-equiptTypeArr', equiptTypeArr);
|
|
|
+ if (selFloorId) {
|
|
|
+ getDeviceStatus(equiptTypeArr);
|
|
|
+ getSpaceHasPerson(selFloorId);
|
|
|
+ }
|
|
|
+ })();
|
|
|
|
|
|
return () => {
|
|
|
//clearInterval(setTimer.current);
|
|
|
+ console.log('clearTimeout-clear');
|
|
|
clearTimeout(setTimer1.current);
|
|
|
clearTimeout(setTimer2.current);
|
|
|
};
|
|
|
}, [selFloorId]);
|
|
|
|
|
|
- // useEffect(() => {
|
|
|
- // if (selFloorId) {
|
|
|
- // querySpaceAdjustList(selFloorId);
|
|
|
- // }
|
|
|
- // }, [selFloorId]);
|
|
|
-
|
|
|
//获取时间列表 spaceTimeList
|
|
|
useEffect(() => {
|
|
|
if (selFloorId) {
|
|
@@ -465,7 +460,7 @@ const Environment: React.FC = () => {
|
|
|
let firtTime: number = 0;
|
|
|
let lastTime: number = 0;
|
|
|
return (
|
|
|
- <>
|
|
|
+ <div className={styles.sagawrap}>
|
|
|
<PageHeader title={<FormattedMessage id="menu.equipment" />} action={<SearchInput />} />
|
|
|
<TopNavigator
|
|
|
navigatorList={navigatorList}
|
|
@@ -477,7 +472,6 @@ const Environment: React.FC = () => {
|
|
|
selNavObj={selNav}
|
|
|
navigatorList={navigatorList}
|
|
|
mapList={mapCombineList}
|
|
|
- queryDeviceManage={queryDeviceManage}
|
|
|
></TopNavRight>
|
|
|
)
|
|
|
}
|
|
@@ -753,7 +747,7 @@ const Environment: React.FC = () => {
|
|
|
}}
|
|
|
></DeviceModal>
|
|
|
)}
|
|
|
- </>
|
|
|
+ </div>
|
|
|
);
|
|
|
};
|
|
|
|