|  |  |  | 
|---|
|  |  |  | import * as Http from './http'; | 
|---|
|  |  |  | import WebSocketClient from './websocket' | 
|---|
|  |  |  | import ConfirmButton from "../page/components/ConfirmButton"; | 
|---|
|  |  |  | import { FitScreen, AltRoute, RotateRight } from '@mui/icons-material'; | 
|---|
|  |  |  | import { FitScreen, RotateRight } from '@mui/icons-material'; | 
|---|
|  |  |  | import MapSearch from "./header/MapSearch"; | 
|---|
|  |  |  | import { startupOrShutdown } from "./http"; | 
|---|
|  |  |  | import PulseSignal from "../page/components/PulseSignal"; | 
|---|
|  |  |  | import FakeFab from "./header/FakeFab"; | 
|---|
|  |  |  | import RouteFab from "./header/RouteFab"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let player; | 
|---|
|  |  |  | let websocket; | 
|---|
|  |  |  | 
|---|
|  |  |  | > | 
|---|
|  |  |  | {mode !== MAP_MODE.MOVABLE_MODE && ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Fab | 
|---|
|  |  |  | variant="extended" | 
|---|
|  |  |  | color={showRoutes ? 'primary' : 'default'} | 
|---|
|  |  |  | size="small" | 
|---|
|  |  |  | onClick={() => { | 
|---|
|  |  |  | showRoutes ? Tool.hideRoutes(curZone, setShowRoutes) : Tool.showRoutes(curZone, setShowRoutes) | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <AltRoute /> | 
|---|
|  |  |  |  {translate('page.map.action.route')}  | 
|---|
|  |  |  | </Fab> | 
|---|
|  |  |  | <RouteFab | 
|---|
|  |  |  | curZone={curZone} | 
|---|
|  |  |  | showRoutes={showRoutes} | 
|---|
|  |  |  | setShowRoutes={setShowRoutes} | 
|---|
|  |  |  | notify={notify} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <FakeFab /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | )} | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | import React, { useState, useRef, useEffect, useMemo } from "react"; | 
|---|
|  |  |  | import { useTranslate } from "react-admin"; | 
|---|
|  |  |  | import { | 
|---|
|  |  |  | Fab, | 
|---|
|  |  |  | Box, | 
|---|
|  |  |  | Backdrop, | 
|---|
|  |  |  | useTheme, | 
|---|
|  |  |  | } from '@mui/material'; | 
|---|
|  |  |  | import AltRouteIcon from '@mui/icons-material/AltRoute'; | 
|---|
|  |  |  | import CircularProgress from '@mui/material/CircularProgress'; | 
|---|
|  |  |  | import * as Tool from '../tool'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const RouteFab = (props) => { | 
|---|
|  |  |  | const { curZone, showRoutes, setShowRoutes, notify } = props; | 
|---|
|  |  |  | const translate = useTranslate(); | 
|---|
|  |  |  | const theme = useTheme();   // theme.palette.primary.main | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [loading, setLoading] = React.useState(false); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleClick = () => { | 
|---|
|  |  |  | if (showRoutes) { | 
|---|
|  |  |  | Tool.hideRoutes(curZone, setShowRoutes); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | Tool.showRoutes(curZone, setShowRoutes, setLoading); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <Fab | 
|---|
|  |  |  | variant="extended" | 
|---|
|  |  |  | color={showRoutes ? 'primary' : 'default'} | 
|---|
|  |  |  | size="small" | 
|---|
|  |  |  | disabled={loading} | 
|---|
|  |  |  | onClick={handleClick} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <AltRouteIcon /> | 
|---|
|  |  |  |  {translate('page.map.action.route')}  | 
|---|
|  |  |  | {loading && ( | 
|---|
|  |  |  | <> | 
|---|
|  |  |  | <svg width={0} height={0}> | 
|---|
|  |  |  | <defs> | 
|---|
|  |  |  | <linearGradient id="my_gradient" x1="0%" y1="0%" x2="0%" y2="100%"> | 
|---|
|  |  |  | <stop offset="0%" stopColor="#e01cd5" /> | 
|---|
|  |  |  | <stop offset="100%" stopColor="#1CB5E0" /> | 
|---|
|  |  |  | </linearGradient> | 
|---|
|  |  |  | </defs> | 
|---|
|  |  |  | </svg> | 
|---|
|  |  |  | <CircularProgress size={18} thickness={8} sx={{ 'svg circle': { stroke: 'url(#my_gradient)' } }} /> | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | </Fab> | 
|---|
|  |  |  | {/* global */} | 
|---|
|  |  |  | {/* <Backdrop | 
|---|
|  |  |  | sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }} | 
|---|
|  |  |  | open={loading} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <CircularProgress color="inherit" /> | 
|---|
|  |  |  | </Backdrop> */} | 
|---|
|  |  |  | </> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default RouteFab; | 
|---|
|  |  |  | 
|---|
|  |  |  | // support | 
|---|
|  |  |  | switch (item.type) { | 
|---|
|  |  |  | case DEVICE_TYPE.POINT: | 
|---|
|  |  |  | sprite.scale.set(1); | 
|---|
|  |  |  | sprite.scale.set(pointList.length < 2000 ? 1 : 1.6); | 
|---|
|  |  |  | break | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | break | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // }, 50); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mapContainer.addChild(sprite); | 
|---|
|  |  |  | Tool.beInsight(sprite, setCurSprite); | 
|---|
|  |  |  | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const getRouteList = async (zoneId, callback) => { | 
|---|
|  |  |  | export const getRouteList = async (zoneId, callback, errCallBack) => { | 
|---|
|  |  |  | await request.post('/map/route/list', { | 
|---|
|  |  |  | zoneId: zoneId, | 
|---|
|  |  |  | }, { | 
|---|
|  |  |  | 
|---|
|  |  |  | callback(data) | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | notify.error(msg); | 
|---|
|  |  |  | if (errCallBack) { | 
|---|
|  |  |  | errCallBack(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).catch((error) => { | 
|---|
|  |  |  | notify.error(error.message); | 
|---|
|  |  |  | console.error(error.message); | 
|---|
|  |  |  | if (errCallBack) { | 
|---|
|  |  |  | errCallBack(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | effectCircle.position.set(selectedSprite.x, selectedSprite.y); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const showRoutes = (curZone, setShowRoutes) => { | 
|---|
|  |  |  | setShowRoutes(true); | 
|---|
|  |  |  | getRouteList(curZone, (routeList) => { | 
|---|
|  |  |  | export const showRoutes = (curZone, setShowRoutes, setLoading) => { | 
|---|
|  |  |  | setLoading(true); | 
|---|
|  |  |  | getRouteList( | 
|---|
|  |  |  | curZone, | 
|---|
|  |  |  | (routeList) => { | 
|---|
|  |  |  | routeList.forEach(route => { | 
|---|
|  |  |  | const startPoint = querySprite(DEVICE_TYPE.POINT, route.startCodeStr); | 
|---|
|  |  |  | const endPoint = querySprite(DEVICE_TYPE.POINT, route.endCodeStr); | 
|---|
|  |  |  | 
|---|
|  |  |  | pointRoute.alpha = 1; | 
|---|
|  |  |  | mapContainer.addChild(pointRoute); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | setLoading(false); | 
|---|
|  |  |  | setShowRoutes(true); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | () => { | 
|---|
|  |  |  | setLoading(false); | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export const hideRoutes = (curZone, setShowRoutes) => { | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.acs.framework.common.SnowflakeIdWorker; | 
|---|
|  |  |  | import com.zy.acs.manager.core.service.*; | 
|---|
|  |  |  | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; | 
|---|
|  |  |  | import com.zy.acs.manager.core.utils.RouteGenerator; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.AgvDetail; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.enums.TaskTypeType; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | private AvoidWaveCalculator avoidWaveCalculator; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private PatrolService patrolService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RouteGenerator routeGenerator; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/system/info", method = {RequestMethod.GET, RequestMethod.POST}) | 
|---|
|  |  |  | public R systemInfo() { | 
|---|
|  |  |  | return R.ok("RCS-FLOW-1.0.0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @RequestMapping(value = "/system/route/generate", method = {RequestMethod.GET, RequestMethod.POST}) | 
|---|
|  |  |  | //    public R generate() { | 
|---|
|  |  |  | //        String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(null); | 
|---|
|  |  |  | //        List<String> list = routeGenerator.generateRoutes(codeMatrix); | 
|---|
|  |  |  | //        return R.ok(String.valueOf(list.size())).add(list); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/dead/lock") | 
|---|
|  |  |  | public R aaa() { | 
|---|
|  |  |  | AgvDetail agvDetail11 = agvDetailService.selectByAgvNo("11"); | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.acs.manager.core.service.astart.CodeNodeType; | 
|---|
|  |  |  | import com.zy.acs.manager.core.service.astart.MapDataDispatcher; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.Code; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.entity.Route; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.CodeGapService; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.CodeService; | 
|---|
|  |  |  | import com.zy.acs.manager.manager.service.RouteService; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Created by vincent on 12/9/2024 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class RouteGenerator { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CodeGapService codeGapService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<Route> generateRoutes(String[][] codeMatrix) { | 
|---|
|  |  |  | List<Route> routes = new ArrayList<>(); | 
|---|
|  |  |  | public List<String> generateRoutes(String[][] codeMatrix) { | 
|---|
|  |  |  | List<String> list = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int rows = codeMatrix.length; | 
|---|
|  |  |  | int cols = codeMatrix[0].length; | 
|---|
|  |  |  | 
|---|
|  |  |  | String rightCodeData = codeMatrix[i][j + 1]; | 
|---|
|  |  |  | if (!Cools.isEmpty(rightCodeData) && !CodeNodeType.NONE.val.equals(rightCodeData)) { | 
|---|
|  |  |  | Code rightCode = codeService.selectByData(rightCodeData); | 
|---|
|  |  |  | list.add(currCode.getData() + "-" + rightCode.getData()); | 
|---|
|  |  |  | routeService.createRouteByCode(currCode, rightCode, 0, null); | 
|---|
|  |  |  | codeGapService.createCodeGapByCode(currCode, rightCode, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info(currCode.getData() + "-" + rightCode.getData() + " [finished]"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | String bottomCodeData = codeMatrix[i + 1][j]; | 
|---|
|  |  |  | if (!Cools.isEmpty(bottomCodeData) && !CodeNodeType.NONE.val.equals(bottomCodeData)) { | 
|---|
|  |  |  | Code bottomCode = codeService.selectByData(bottomCodeData); | 
|---|
|  |  |  | list.add(currCode.getData() + "-" + bottomCode.getData()); | 
|---|
|  |  |  | routeService.createRouteByCode(currCode, bottomCode, 0, null); | 
|---|
|  |  |  | codeGapService.createCodeGapByCode(currCode, bottomCode, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.info(currCode.getData() + "-" + bottomCode.getData() + " [finished]"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return routes; | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|