| | |
| | | useTheme, |
| | | Fab, |
| | | } from '@mui/material'; |
| | | import { MAP_MODE, MAP_DEFAULT_ROTATION } from "./constants"; |
| | | import { MAP_MODE, MAP_DEFAULT_ROTATION, setMapPreferences } from "./constants"; |
| | | import Player from './player'; |
| | | import * as Tool from './tool'; |
| | | import { NotificationProvider, useNotification } from './Notification'; |
| | |
| | | Tool.setThemeMode(themeMode); |
| | | Http.setNotify(notify); |
| | | Http.setMapContainer(player.mapContainer); |
| | | await Http.fetchMapPreferences(curZone, setMapPreferences); |
| | | websocket = new WebSocketClient('/ws/map/websocket'); |
| | | |
| | | await Http.fetchMapData(curZone, setRcsStatus, setCurSprite); |
| | |
| | | |
| | | export const MAP_DEFAULT_ROTATION = 180; |
| | | |
| | | export const AGV_ANGLE_OFFSET_VAL = 90; |
| | | |
| | | export const MAP_MIRROR = true; |
| | | export const MAP_DEFAULT_ROTATION = 0; |
| | | |
| | | export const ANIMATE_DURING_TIME = 300; |
| | | |
| | | export let AGV_ANGLE_OFFSET_VAL = 0; |
| | | |
| | | export let MAP_MIRROR = false;; |
| | | |
| | | export const setMapPreferences = (preferences = {}) => { |
| | | if (preferences == null || typeof preferences !== 'object') { |
| | | return; |
| | | } |
| | | const { agvAngleOffsetVal, mapMirror } = preferences; |
| | | if (typeof agvAngleOffsetVal === 'number' && !isNaN(agvAngleOffsetVal)) { |
| | | AGV_ANGLE_OFFSET_VAL = agvAngleOffsetVal; |
| | | } |
| | | if (typeof mapMirror === 'boolean') { |
| | | MAP_MIRROR = mapMirror; |
| | | } |
| | | }; |
| | | |
| | | export const MAP_MODE = Object.freeze({ |
| | | OBSERVER_MODE: "1", |
| | | MOVABLE_MODE: "2", |
| | |
| | | mapContainer = param; |
| | | } |
| | | |
| | | export const fetchMapPreferences = async (zoneId, setMapPreferences) => { |
| | | try { |
| | | const res = await request.post('/map/config/preferences', { |
| | | zoneId: zoneId |
| | | }, { |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' } |
| | | }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | setMapPreferences(data); |
| | | return data || {}; |
| | | } |
| | | notify?.error(msg); |
| | | } catch (error) { |
| | | notify?.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | return {}; |
| | | } |
| | | |
| | | export const fetchMapData = (zoneId, setRcsStatus, setCurSprite) => { |
| | | Tool.clearMapData(); |
| | | return request.post('/map/data/fetch', { |
| | |
| | | } |
| | | } |
| | | |
| | | const agvRotationOffset = rotationParseNum(AGV_ANGLE_OFFSET_VAL); |
| | | |
| | | const showAgvSprite = (curZone, agvVo, setCurSprite) => { |
| | | const { agvNo, agvModel, code, direction, battery, jobType, backpack: backpackCount, slots, error } = agvVo; |
| | | if (!code) { return; } |
| | |
| | | if (!codeSprite) { return; } |
| | | |
| | | const targetRotation = rotationParseNum(direction); |
| | | const agvRotationOffset = rotationParseNum(AGV_ANGLE_OFFSET_VAL); |
| | | // const backpackCount = backpack?.filter(item => item.loaded === true).length || 0; |
| | | |
| | | let agvSprite = querySprite(DEVICE_TYPE.AGV, agvNo); |
| | |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping("/config/preferences") |
| | | public R configPreferences(@RequestParam(required = false) Long zoneId, @RequestParam(required = false) Integer floor) { |
| | | Integer dashboardAgvAngleOffsetVal = configService.getVal("dashboardAgvAngleOffsetVal", Integer.class); |
| | | Boolean dashMapMirror = configService.getVal("dashMapMirror", Boolean.class); |
| | | return R.ok().add(Cools |
| | | .add("agvAngleOffsetVal", Optional.ofNullable(dashboardAgvAngleOffsetVal).orElse(0)) |
| | | .add("mapMirror", Optional.ofNullable(dashMapMirror).orElse(Boolean.FALSE)) |
| | | ); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping("/data/fetch") |
| | | public R fetch(@RequestParam(required = false) Long zoneId, @RequestParam(required = false) Integer floor) { |
| | | // code |