| | |
| | | import ConfirmButton from "../page/components/ConfirmButton"; |
| | | import { FitScreen } from '@mui/icons-material'; |
| | | import MapSearch from "./header/MapSearch"; |
| | | import { startupOrShutdown } from "./http"; |
| | | |
| | | let player; |
| | | let websocket; |
| | |
| | | const prevCurSpriteRef = useRef(); |
| | | const [batchSprites, setBatchSprites] = useState([]); |
| | | |
| | | const [rcsStatus, setRcsStatus] = useState(null); |
| | | const [curZone, setCurZone] = useState(() => { |
| | | const storedValue = localStorage.getItem('curZone'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : null; |
| | |
| | | Http.setMapContainer(player.mapContainer); |
| | | websocket = new WebSocketClient('/ws/map/websocket'); |
| | | |
| | | await Http.fetchMapData(); |
| | | await Http.fetchMapData(curZone, setRcsStatus); |
| | | websocket.connect(); |
| | | websocket.onMessage = (wsMsg) => { |
| | | Tool.generateDynamicGraphic(curZone, JSON.parse(wsMsg), setCurSprite); |
| | |
| | | <> |
| | | <Button |
| | | variant="contained" |
| | | color="primary" |
| | | color={rcsStatus ? 'inherit' : 'primary'} |
| | | sx={{ mr: 2 }} |
| | | onClick={() => { |
| | | startupOrShutdown(() => { |
| | | setRcsStatus(!rcsStatus); |
| | | }); |
| | | }} |
| | | > |
| | | {translate('page.map.action.startup')} |
| | | {rcsStatus ? translate('page.map.action.shutdown') : translate('page.map.action.startup')} |
| | | </Button> |
| | | <Button variant="contained" color="primary"> |
| | | {translate('page.map.action.monitor')} |
| | |
| | | mapContainer = param; |
| | | } |
| | | |
| | | export const fetchMapData = (zoneId) => { |
| | | export const fetchMapData = (zoneId, setRcsStatus) => { |
| | | Tool.clearMapData(); |
| | | return request.post('/map/data/fetch', { |
| | | zoneId: zoneId |
| | | }, { |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' } |
| | | }).then((res) => { |
| | | const { code, msg, data: { common, point } } = res.data; |
| | | const { code, msg, data: { rcsStatus, common, point } } = res.data; |
| | | if (code === 200) { |
| | | setRcsStatus(rcsStatus); |
| | | const mapItemList = [...eval(common), ...eval(point)]; |
| | | mapItemList.forEach(item => { |
| | | if (item.type !== DEVICE_TYPE.AGV) { |
| | |
| | | }) |
| | | } |
| | | |
| | | export const startupOrShutdown = async (callback) => { |
| | | try { |
| | | const res = await request.post('/map/startupOrShutdown'); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | if (callback) { |
| | | callback(); |
| | | } |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | } catch (error) { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | } |
| | | } |
| | | |
| | | export const getLocGroup = async (row, bay, callback) => { |
| | | await request.post('/map/shelf/group', { |
| | | row: row, |
| | |
| | | }}> |
| | | <Stack direction="row" p={2} pt={3}> |
| | | <Typography variant="h6" flex="1"> |
| | | {title || translate('page.map.insight.title')} |
| | | {title || ''} |
| | | </Typography> |
| | | <IconButton onClick={handleClose} size="small"> |
| | | <CloseIcon /> |
| | |
| | | import com.zy.acs.manager.manager.mapper.MapMapper; |
| | | import com.zy.acs.manager.manager.service.*; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:update')") |
| | | @PostMapping("/startupOrShutdown") |
| | | public synchronized R startupOrShutdown() { |
| | | Boolean taskAssignMode = configService.getVal("TaskAssignMode", Boolean.class); |
| | | return configService.setVal("TaskAssignMode", !taskAssignMode) ? R.ok() : R.error(); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:list')") |
| | | @PostMapping("/data/fetch") |
| | |
| | | // common |
| | | Map activeMap = mapMapper.selectActive(zoneId, floor); |
| | | return R.ok().add(Cools |
| | | .add("rcsStatus", configService.getVal("TaskAssignMode", Boolean.class)) |
| | | .add("point", GsonUtils.toJson(mapCodeItems)) |
| | | .add("common", activeMap.getData()) |
| | | ); |
| | |
| | | |
| | | <T> T getVal(String key, Class<T> clazz); |
| | | |
| | | <T> boolean setVal(String key, T val); |
| | | |
| | | } |
| | |
| | | import com.zy.acs.manager.system.enums.ConfigType; |
| | | import com.zy.acs.manager.system.mapper.ConfigMapper; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public <T> boolean setVal(String key, T val) { |
| | | List<Config> list = this.list(new LambdaQueryWrapper<Config>().eq(Config::getFlag, key)); |
| | | Config config = list.stream().findFirst().orElse(null); |
| | | if (config == null) { |
| | | return false; |
| | | } |
| | | ConfigType configType = ConfigType.query(config.getType()); |
| | | switch (configType) { |
| | | case BOOLEAN: |
| | | if (!(val instanceof Boolean)) { |
| | | throw new IllegalArgumentException("Expected Boolean value for key: " + key); |
| | | } |
| | | config.setVal((Boolean) val ? "TRUE" : "FALSE"); |
| | | break; |
| | | case NUMBER: |
| | | if (val instanceof Integer || val instanceof Short || val instanceof Long || val instanceof Double) { |
| | | config.setVal(String.valueOf(val)); |
| | | } else { |
| | | throw new IllegalArgumentException("Expected a numeric value for key: " + key); |
| | | } |
| | | break; |
| | | case STRING: |
| | | if (!(val instanceof String)) { |
| | | throw new IllegalArgumentException("Expected a String value for key: " + key); |
| | | } |
| | | config.setVal((String) val); |
| | | break; |
| | | case JSON: |
| | | config.setVal(GsonUtils.toJson(val)); |
| | | break; |
| | | case DATE: |
| | | if (!(val instanceof Date)) { |
| | | throw new IllegalArgumentException("Expected a Date value for key: " + key); |
| | | } |
| | | config.setVal(DateUtils.convert((Date) val)); |
| | | break; |
| | | default: |
| | | throw new UnsupportedOperationException("Unsupported ConfigType: " + configType); |
| | | } |
| | | |
| | | return this.updateById(config); |
| | | } |
| | | |
| | | } |