|
@@ -0,0 +1,178 @@
|
|
|
+package com.ecnu.platform.service
|
|
|
+
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgBaseMap
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgBaseMapArea
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgObstacle
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgParkSpace
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgVehicle
|
|
|
+import com.ecnu.alg.pojo.path.inputs.AlgVehicleTask
|
|
|
+import com.three.common.exception.ParamException
|
|
|
+import com.three.data_api.dm.annos.BizApiMethod
|
|
|
+import com.three.data_api.dm.annos.BizRequestPm
|
|
|
+import com.three.data_api.dm.annos.Doc4MethodRes
|
|
|
+import com.three.data_api.dm.constants.ThreeConstant
|
|
|
+import com.three.redis.utils.RedisUtil
|
|
|
+import org.springframework.beans.factory.annotation.Autowired
|
|
|
+
|
|
|
+class PathStrategyDataService {
|
|
|
+
|
|
|
+ public static final String AlgBaseMapKey = "path:AlgBaseMap:"
|
|
|
+ public static final String AlgVehicleKey = "path:AlgVehicle:"
|
|
|
+ public static final String AlgBaseMapAreaKey = "path:AlgBaseMapArea:"
|
|
|
+ public static final String AlgObstacleKey = "path:AlgObstacle:"
|
|
|
+ public static final String AlgParkSpaceKey = "path:AlgParkSpace:"
|
|
|
+ public static final String AlgVehicleTaskKey = "path:AlgVehicleTask:"
|
|
|
+
|
|
|
+ public static final String conn = "-"
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
+// @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "初始化底图信息")
|
|
|
+// @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgBaseMap.class)
|
|
|
+// AlgBaseMap initBaseMap(@BizRequestPm(key = "id", nullable = false, desc = "底图ID") String id,
|
|
|
+// @BizRequestPm(key = "name", nullable = false, desc = "底图名称") String name,
|
|
|
+// @BizRequestPm(key = "pcsBorder", nullable = false, desc = "平面坐标边界") String pcsBorder) throws Exception {
|
|
|
+// AlgBaseMap algBaseMap = new AlgBaseMap()
|
|
|
+// algBaseMap.setId(id)
|
|
|
+// algBaseMap.setName(name)
|
|
|
+// algBaseMap.setPcsBorder(pcsBorder)
|
|
|
+// return algBaseMap
|
|
|
+// }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "初始化底图信息")
|
|
|
+ @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgBaseMap.class)
|
|
|
+ AlgBaseMap initBaseMap(@BizRequestPm(key = "body", nullable = false, desc = "底图信息") AlgBaseMap algBaseMap) throws Exception {
|
|
|
+ redisUtil.set(AlgBaseMapKey + algBaseMap.getId(), algBaseMap)
|
|
|
+ return algBaseMap
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询所有底图信息")
|
|
|
+ @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgBaseMap.class)
|
|
|
+ List<AlgBaseMap> queryAllBaseMap(Map<String, Object> map) throws Exception {
|
|
|
+ redisUtil.getByPrefix(AlgBaseMapKey + "*") as List<AlgBaseMap>
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询所有底图要素")
|
|
|
+ @Doc4MethodRes(key = "result", desc = "底图要素信息", refClasses = [AlgVehicle.class, AlgBaseMapArea.class, AlgObstacle.class, AlgParkSpace.class])
|
|
|
+ Map<String, Object> queryAllElement(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId) throws Exception {
|
|
|
+ Map<String, Object> reMap = new HashMap<>()
|
|
|
+ List<AlgVehicle> algVehicleList = redisUtil.getByPrefix(AlgVehicleKey + mapId + conn + "*") as List<AlgVehicle>
|
|
|
+ List<AlgBaseMapArea> algBaseMapAreaList = redisUtil.getByPrefix(AlgBaseMapAreaKey + mapId + conn + "*") as List<AlgBaseMapArea>
|
|
|
+ List<AlgObstacle> algObstacleList = redisUtil.getByPrefix(AlgObstacleKey + mapId + conn + "*") as List<AlgObstacle>
|
|
|
+ List<AlgParkSpace> algParkSpaceList = redisUtil.getByPrefix(AlgParkSpaceKey + mapId + conn + "*") as List<AlgParkSpace>
|
|
|
+ reMap.put("algVehicleList", algVehicleList)
|
|
|
+ reMap.put("algBaseMapAreaList", algBaseMapAreaList)
|
|
|
+ reMap.put("algObstacleList", algObstacleList)
|
|
|
+ reMap.put("algParkSpaceList", algParkSpaceList)
|
|
|
+ return reMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增选取点")
|
|
|
+ void createPoint(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "position", nullable = false, desc = "坐标点") String position,
|
|
|
+ @BizRequestPm(key = "elementType", nullable = false, desc = "点类型") String elementType,
|
|
|
+ @BizRequestPm(key = "id", nullable = false, desc = "编号") String id) throws Exception {
|
|
|
+ AlgVehicle algVehicle = new AlgVehicle();
|
|
|
+ algVehicle.setMapId(mapId)
|
|
|
+ algVehicle.setVehicleNo(id)
|
|
|
+ algVehicle.setCurPosition(position)
|
|
|
+ redisUtil.set(AlgVehicleKey + mapId + conn + id, algVehicle)
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增绘制矩形")
|
|
|
+ void createRectangle(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "position", nullable = false, desc = "矩形坐标") String position,
|
|
|
+ @BizRequestPm(key = "elementType", nullable = false, desc = "点类型") String elementType,
|
|
|
+ @BizRequestPm(key = "id", nullable = false, desc = "编号") String id,
|
|
|
+ @BizRequestPm(key = "name", desc = "名称") String name) throws Exception {
|
|
|
+ if ("parkSpace".equals(elementType)) {
|
|
|
+ AlgParkSpace algParkSpace = new AlgParkSpace();
|
|
|
+ algParkSpace.setMapId(mapId)
|
|
|
+ algParkSpace.setId(id)
|
|
|
+ algParkSpace.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgParkSpaceKey + mapId + conn + id, algParkSpace)
|
|
|
+ } else if ("obstacle".equals(elementType)) {
|
|
|
+ AlgObstacle algObstacle = new AlgObstacle();
|
|
|
+ algObstacle.setMapId(mapId)
|
|
|
+ algObstacle.setId(id)
|
|
|
+ algObstacle.setName(name)
|
|
|
+ algObstacle.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgObstacleKey + mapId + conn + id, algObstacle)
|
|
|
+ } else if ("baseMapArea".equals(elementType)) {
|
|
|
+ AlgBaseMapArea algBaseMapArea = new AlgBaseMapArea();
|
|
|
+ algBaseMapArea.setMapId(mapId)
|
|
|
+ algBaseMapArea.setId(id)
|
|
|
+ algBaseMapArea.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgBaseMapAreaKey + mapId + conn + id, algBaseMapArea)
|
|
|
+ } else {
|
|
|
+ throw new ParamException("类型(" + elementType + ")暂不支持")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增绘制区域")
|
|
|
+ void createRegion(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "position", nullable = false, desc = "区域坐标") String position,
|
|
|
+ @BizRequestPm(key = "elementType", nullable = false, desc = "点类型") String elementType,
|
|
|
+ @BizRequestPm(key = "id", nullable = false, desc = "编号") String id,
|
|
|
+ @BizRequestPm(key = "name", desc = "名称") String name) throws Exception {
|
|
|
+ if ("parkSpace".equals(elementType)) {
|
|
|
+ AlgParkSpace algParkSpace = new AlgParkSpace();
|
|
|
+ algParkSpace.setMapId(mapId)
|
|
|
+ algParkSpace.setId(id)
|
|
|
+ algParkSpace.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgParkSpaceKey + mapId + conn + id, algParkSpace)
|
|
|
+ } else if ("obstacle".equals(elementType)) {
|
|
|
+ AlgObstacle algObstacle = new AlgObstacle();
|
|
|
+ algObstacle.setMapId(mapId)
|
|
|
+ algObstacle.setId(id)
|
|
|
+ algObstacle.setName(name)
|
|
|
+ algObstacle.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgObstacleKey + mapId + conn + id, algObstacle)
|
|
|
+ } else if ("baseMapArea".equals(elementType)) {
|
|
|
+ AlgBaseMapArea algBaseMapArea = new AlgBaseMapArea();
|
|
|
+ algBaseMapArea.setMapId(mapId)
|
|
|
+ algBaseMapArea.setId(id)
|
|
|
+ algBaseMapArea.setPcsBorder(position)
|
|
|
+ redisUtil.set(AlgBaseMapAreaKey + mapId + conn + id, algBaseMapArea)
|
|
|
+ } else {
|
|
|
+ throw new ParamException("类型(" + elementType + ")暂不支持")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "删除元素")
|
|
|
+ void deleteElement(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "elementType", nullable = false, desc = "底图要素类型") String elementType,
|
|
|
+ @BizRequestPm(key = "id", nullable = false, desc = "编号") String id) throws Exception {
|
|
|
+ if ("parkSpace".equals(elementType)) {
|
|
|
+ redisUtil.del(AlgParkSpaceKey + mapId + conn + id)
|
|
|
+ } else if ("obstacle".equals(elementType)) {
|
|
|
+ redisUtil.del(AlgObstacleKey + mapId + conn + id)
|
|
|
+ } else if ("baseMapArea".equals(elementType)) {
|
|
|
+ redisUtil.del(AlgBaseMapAreaKey + mapId + conn + id)
|
|
|
+ } else {
|
|
|
+ throw new ParamException("类型(" + elementType + ")暂不支持")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "新增车辆任务")
|
|
|
+ void createVehicleTask(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "vehicleNo", nullable = false, desc = "车辆编号") String vehicleNo,
|
|
|
+ @BizRequestPm(key = "startPosition", nullable = false, desc = "起点位置") String startPosition,
|
|
|
+ @BizRequestPm(key = "endPosition", nullable = false, desc = "终点位置") String endPosition) throws Exception {
|
|
|
+ AlgVehicleTask algVehicleTask = new AlgVehicleTask();
|
|
|
+ algVehicleTask.setMapId(mapId)
|
|
|
+ algVehicleTask.setVehicleNo(vehicleNo)
|
|
|
+ algVehicleTask.setStartPosition(startPosition)
|
|
|
+ algVehicleTask.setEndPosition(endPosition)
|
|
|
+ redisUtil.set(AlgVehicleTaskKey + mapId + conn + vehicleNo, algVehicleTask)
|
|
|
+ }
|
|
|
+
|
|
|
+ @BizApiMethod(matchedApis = ThreeConstant.BIZ_API_NAME, desc = "查询车辆任务")
|
|
|
+ @Doc4MethodRes(key = "result", desc = "底图信息", refClasses = AlgVehicleTask.class)
|
|
|
+ AlgVehicleTask queryVehicleTask(@BizRequestPm(key = "mapId", nullable = false, desc = "底图ID") String mapId,
|
|
|
+ @BizRequestPm(key = "vehicleNo", nullable = false, desc = "车辆编号") String vehicleNo) throws Exception {
|
|
|
+ return redisUtil.getByPrefix(AlgVehicleTaskKey + mapId + conn + vehicleNo) as AlgVehicleTask
|
|
|
+ }
|
|
|
+
|
|
|
+}
|