| | |
| | | } |
| | | const success = await removeArea(id); |
| | | if (success) { |
| | | if (sprite) { |
| | | Tool.removeAreaSprite(sprite); |
| | | } |
| | | onCancel?.(); |
| | | } |
| | | }; |
| | |
| | | return null; |
| | | }; |
| | | |
| | | export const removeArea = async (areaId) => { |
| | | export const removeArea = async (id) => { |
| | | try { |
| | | const res = await request.post('/map/area/remove', { areaId }); |
| | | const res = await request.post('/map/area/remove', { id }); |
| | | const { code, msg } = res.data; |
| | | if (code === 200) { |
| | | notify.success(msg); |
| | |
| | | } |
| | | }; |
| | | |
| | | export const removeAreaSprite = (sprite) => { |
| | | if (!sprite || sprite?.data?.type !== DEVICE_TYPE.AREA) { |
| | | return; |
| | | } |
| | | const parent = sprite.parent || mapContainer; |
| | | if (parent) { |
| | | parent.removeChild(sprite); |
| | | } |
| | | sprite.destroy({ children: true, texture: false, baseTexture: false }); |
| | | }; |
| | | |
| | | export const loadAreas = (curZone, setCurSprite) => { |
| | | if (!mapContainer) return; |
| | | clearAreas(); |
| | |
| | | return codeList; |
| | | } |
| | | |
| | | // reset and set new area |
| | | public Boolean removeArea(Long areaId) { |
| | | if (null == areaId) { return false; } |
| | | List<String> codeList = AREA_CODE.get(areaId); |
| | | AREA_CODE.get(areaId).clear(); |
| | | AREA_CODE.remove(areaId); |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | public List<String> findCodesInArea(MapPointDto start, MapPointDto end) { |
| | | double minX = Math.min(start.getX(), end.getX()); |
| | | double maxX = Math.max(start.getX(), end.getX()); |
| | |
| | | @GetMapping("/area/get") |
| | | public R areaGet(@RequestParam Long areaId) { |
| | | Area area = areaService.getById(areaId); |
| | | MapAreaResult areaResult = new MapAreaResult(); |
| | | return R.ok().add(areaResult.sync(area)); |
| | | return R.ok().add(new MapAreaResult().sync(area)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:loc:update')") |
| | |
| | | @PreAuthorize("hasAuthority('manager:loc:remove')") |
| | | @PostMapping("/area/remove") |
| | | public R areaRemove(@RequestBody MapAreaParam param) { |
| | | areaService.removeMapArea(param.getId(), getLoginUserId()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | MapAreaResult modifyMapArea(MapAreaParam param, Long loginUserId); |
| | | |
| | | void removeMapArea(Long id, Long loginUserId); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | if (needModify) { |
| | | area.setUpdateTime(new Date()); |
| | | area.setUpdateBy(loginUserId); |
| | | if (!this.updateById(area)) { |
| | | throw new RuntimeException("failed to update Area"); |
| | | } |
| | |
| | | return new MapAreaResult().sync(area); |
| | | } |
| | | |
| | | @Override |
| | | public void removeMapArea(Long areaId, Long loginUserId) { |
| | | // area - agv |
| | | areaAgvService.remove(new LambdaQueryWrapper<AreaAgv>().eq(AreaAgv::getAreaId, areaId)); |
| | | // cache |
| | | areaGovernService.removeArea(areaId); |
| | | // db |
| | | this.removeById(areaId); |
| | | } |
| | | |
| | | } |