| | |
| | | msg: { |
| | | confirm: { |
| | | tip: 'Tip', |
| | | desc: 'Are you sure you wanna do this?', |
| | | desc: 'Are you sure you want to proceed?', |
| | | }, |
| | | }, |
| | | }, |
| | |
| | | station: 'STATION', |
| | | direction: 'DIRECTION', |
| | | }, |
| | | action: { |
| | | save: 'Save Map', |
| | | }, |
| | | settings: { |
| | | title: 'Settings', |
| | | map: { |
| | |
| | | msg: { |
| | | confirm: { |
| | | tip: '提示', |
| | | desc: '你确定要操作此项吗?', |
| | | desc: '您确定要执行此操作吗?', |
| | | }, |
| | | }, |
| | | }, |
| | |
| | | station: '输送线', |
| | | direction: '方向', |
| | | }, |
| | | action: { |
| | | save: '保存地图', |
| | | }, |
| | | settings: { |
| | | title: '设置', |
| | | map: { |
| | |
| | | import Settings from "./settings"; |
| | | import * as Http from './http'; |
| | | import WebSocketClient from './websocket' |
| | | import ConfirmButton from "../page/components/ConfirmButton"; |
| | | |
| | | let player; |
| | | let websocket; |
| | |
| | | const [settingsVisible, setSettingsVisible] = useState(false); |
| | | |
| | | const [spriteSettings, setSpriteSettings] = useState(null); |
| | | const prevSpriteSettingsRef = React.useRef(); |
| | | const prevSpriteSettingsRef = useRef(); |
| | | |
| | | const [curZone, setCurZone] = useState(() => { |
| | | const storedValue = localStorage.getItem('curZone'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : null; |
| | | }); |
| | | |
| | | useEffect(() => { |
| | | Tool.patchRaLayout('0px'); |
| | |
| | | |
| | | {mode === MapMode.SETTINGS_MODE && ( |
| | | <> |
| | | <ConfirmButton |
| | | label="page.map.action.save" |
| | | variant="contained" |
| | | onConfirm={() => { |
| | | Http.saveMapData(curZone, mapContainer); |
| | | }} |
| | | /> |
| | | </> |
| | | )} |
| | | |
| | |
| | | import request from '@/utils/request'; |
| | | import * as Tool from './tool'; |
| | | import { DEVICE_TYPE } from './constants'; |
| | | |
| | | let notify; |
| | | |
| | |
| | | |
| | | export const fetchMapData = async (zoneId) => { |
| | | Tool.clearMapData(); |
| | | await request.post('/map/data', { |
| | | await request.post('/map/data/fetch', { |
| | | zoneId: zoneId |
| | | }, { |
| | | headers: { |
| | |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | const mapItemList = eval(data); |
| | | } else { |
| | | notify(msg, "error") |
| | | } |
| | | |
| | | // mapItemList.forEach(item => { |
| | |
| | | // }) |
| | | |
| | | }).catch((error) => { |
| | | notify(error.message, "error") |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | }) |
| | | } |
| | | |
| | | export const saveMapData = async (zone, mapContainer) => { |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | |
| | | const sprites = []; |
| | | mapContainer.children.forEach(child => { |
| | | if (child.data?.uuid) { |
| | | const { type, uuid, no, ...property } = child.data; |
| | | if (type !== DEVICE_TYPE.AGV) { |
| | | sprites.push({ |
| | | // graph |
| | | positionX: child.position.x, |
| | | positionY: child.position.y, |
| | | scaleX: child.scale.x, |
| | | scaleY: child.scale.y, |
| | | rotation: Tool.rotationToNum(child.rotation), |
| | | // data |
| | | type: type, |
| | | uuid: uuid, |
| | | no: no, |
| | | property: property, |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | |
| | | await request.post('/map/data/save', { |
| | | zoneId: zone, |
| | | itemList: sprites |
| | | }).then(res => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | }).catch((error) => { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | }) |
| | | } |
| | |
| | | effectHalfCircle.position.set(sprite.x, sprite.y); |
| | | } |
| | | |
| | | export const rotationToNum = (rotation) => { |
| | | let res = rotation * 180 / Math.PI; |
| | | if (res < 0) { |
| | | res += 360; |
| | | } else if (res > 360) { |
| | | res -= 360; |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | export const rotationParseNum = (num) => { |
| | | return num * Math.PI / 180; |
| | | } |
| | | |
| | | export const incrementSpriteNo = (str, incrementValue) => { |
| | | const match = str.match(/(\D*)(\d+)/); |
| | | if (match) { |
| | |
| | | const ConfirmButton = (props) => { |
| | | const { label, onConfirm, data, ...rest } = props; |
| | | const translate = useTranslate(); |
| | | const buttonRef = useRef(null); |
| | | const [open, setOpen] = useState(false); |
| | | |
| | | const handleClickOpen = (event) => { |
| | |
| | | return ( |
| | | <> |
| | | <Button |
| | | ref={buttonRef} |
| | | onClick={handleClickOpen} |
| | | aria-label={translate(label)} |
| | | {...rest} |
| | | > |
| | | {translate(label)} |
| | | </Button> |
| | | <Dialog open={open} onClose={handleClose}> |
| | | <Dialog |
| | | aria-labelledby="dialog-title" |
| | | aria-describedby="dialog-description" |
| | | open={open} |
| | | onClose={handleClose} |
| | | > |
| | | <DialogTitle>{translate('common.msg.confirm.tip')}</DialogTitle> |
| | | <DialogContent> |
| | | <DialogContentText> |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.domain.MapAgvDto; |
| | | import com.zy.acs.manager.common.domain.MapCodeDto; |
| | | import com.zy.acs.manager.common.domain.MapDto; |
| | |
| | | import com.zy.acs.manager.common.exception.BusinessException; |
| | | import com.zy.acs.manager.core.service.MapService; |
| | | import com.zy.acs.manager.core.service.floyd.FloydNavigateService; |
| | | import com.zy.acs.manager.manager.controller.param.MapDataParam; |
| | | import com.zy.acs.manager.manager.controller.param.MapParam; |
| | | import com.zy.acs.manager.manager.entity.*; |
| | | import com.zy.acs.manager.manager.enums.AgvStsType; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping("/data") |
| | | public R mapData(@RequestParam(required = false) Long zoneId) { |
| | | @PostMapping("/data/fetch") |
| | | public R fetch(@RequestParam(required = false) Long zoneId) { |
| | | String mapData = configService.getVal("mapData", String.class); |
| | | return R.ok().add(mapData); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:update')") |
| | | @PostMapping("/data/save") |
| | | public R save(@RequestBody MapDataParam param) { |
| | | return R.ok("Save Success"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
New file |
| | |
| | | package com.zy.acs.manager.manager.controller.param; |
| | | |
| | | import com.zy.acs.manager.manager.entity.MapItem; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * Created by vincent on 3/15/2024 |
| | | */ |
| | | @Data |
| | | public class MapDataParam { |
| | | |
| | | private Long zoneId; |
| | | |
| | | private List<MapItem> itemList; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.acs.manager.manager.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Created by vincent on 3/15/2024 |
| | | */ |
| | | @Data |
| | | public class MapItem { |
| | | |
| | | // data ------------------------------------------ |
| | | |
| | | private String type; |
| | | |
| | | private String uuid; |
| | | |
| | | private String no; |
| | | |
| | | // dynamical data |
| | | private Map<String, Object> property; |
| | | |
| | | // graph ----------------------------------------- |
| | | |
| | | private Double positionX; |
| | | |
| | | private Double positionY; |
| | | |
| | | private Double scaleX; |
| | | |
| | | private Double scaleY; |
| | | |
| | | private Double rotation; |
| | | |
| | | } |