Переглянути джерело

点位标签信息接口开发

linhuili 3 роки тому
батько
коміт
11153aaad6

+ 182 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmLocationPointController.java

@@ -0,0 +1,182 @@
+package com.persagy.proxy.adm.controller;
+
+import cn.hutool.core.collection.CollUtil;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+
+import com.persagy.proxy.adm.model.AdmPointImage;
+import com.persagy.proxy.adm.request.AdmCreateRequest;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.adm.service.IAdmLocationPointService;
+import com.persagy.proxy.common.entity.DmpResult;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.ws.rs.QueryParam;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName AdmLocationPointController
+ * @Description: 点位标签
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping("/object/location-point")
+@Slf4j
+public class AdmLocationPointController {
+
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    @Autowired
+    private IAdmLocationPointService service;
+
+    /**
+     * 统计点位标签
+     * @param projectId
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/count")
+    public AdmResponse count(@QueryParam("projectId") String projectId,
+                             @RequestBody AdmQueryCriteria request) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        request.setName("point");
+        request.setOnlyCount(true);
+        return service.doQuery(context, request, AdmLocationPoint.class);
+    }
+
+    /**
+     * 查询信息点标签
+     * @param projectId
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/query")
+    public AdmResponse query(@QueryParam("projectId") String projectId,
+                             @RequestBody AdmQueryCriteria request) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        request.setName("point");
+        // 查询信息点标签
+        AdmResponse admResponse = service.doQuery(context, request, AdmLocationPoint.class);
+        // 查询结果处理
+        handleQueryLocationPointResult(admResponse);
+        return  admResponse;
+    }
+
+    /**
+     * 创建点位标签信息
+     * @param createRequest
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/create")
+    public AdmResponse create(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
+        log.info("创建条件"+vos.toString());
+        vos = service.doInsert(context, AdmLocationPoint.class, vos);
+        return AdmResponse.success(vos);
+    }
+
+
+    /**
+     * 更新点位标签信息
+     * @param createRequest
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/update")
+    public AdmResponse update(@RequestBody AdmCreateRequest<AdmLocationPoint> createRequest, @QueryParam("projectId") String projectId) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        List<AdmLocationPoint> vos = CollUtil.newArrayList(createRequest.getContent());
+        vos = service.doUpdate(context, AdmLocationPoint.class, vos);
+        return AdmResponse.success(vos);
+    }
+
+
+    /**
+     * 删除点位标签
+     * @param vos
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/delete")
+    public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmLocationPoint> vos) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        service.doDelete(context, vos);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 删除点位图片
+     * @param vos
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/delete-image")
+    public AdmResponse deleteImage(@QueryParam("projectId") String projectId, @RequestBody List<AdmPointImage> vos) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        // 删除图片参数转换
+        List<AdmLocationPoint> points = deleteImageParamRevert(vos);
+        service.doUpdate(context,AdmLocationPoint.class, points);
+        return AdmResponse.success();
+    }
+
+    /**
+     * 删除图片参数转换
+     * @param vos
+     * @return
+     */
+    private List<AdmLocationPoint> deleteImageParamRevert(List<AdmPointImage> vos){
+        if(CollUtil.isEmpty(vos)){
+            return new ArrayList<>();
+        }
+        ArrayList<AdmLocationPoint> points = new ArrayList<>();
+        for (AdmPointImage vo : vos) {
+            AdmLocationPoint point = new AdmLocationPoint();
+            point.setId(vo.getObjectId());
+            point.setImageList(new ArrayList<>());
+            points.add(point);
+        }
+        return points;
+    }
+
+    /**
+     * 查询标签信息结果处理
+     * @param admResponse
+     */
+    private void handleQueryLocationPointResult(AdmResponse admResponse){
+        if(!DmpResult.SUCCESS.equals(admResponse.getResult())){
+            return;
+        }
+        List<AdmLocationPoint> points = (List<AdmLocationPoint>) admResponse.getContent();
+        for (AdmLocationPoint point : points) {
+            ArrayList<AdmPointImage> imageList = point.getImageList();
+            if(CollUtil.isEmpty(imageList)){
+                continue;
+            }
+            imageList.forEach(item->{
+                item.setObjectId(point.getId());
+            });
+        }
+    }
+}

+ 70 - 0
src/main/java/com/persagy/proxy/adm/model/AdmLocationPoint.java

@@ -0,0 +1,70 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+
+/**
+ * @ClassName AdmLocationPoint
+ * @Description: ADM点位坐标实体类
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@Data
+public class AdmLocationPoint {
+
+    /** 点位标签ID */
+    private String id;
+
+    /** 名称 */
+    private String name;
+
+    /** 本地编码 */
+    private String localId;
+
+    /** 本地名称 */
+    private String localName;
+
+    /** 项目ID */
+    private String projectId;
+
+    /** 建筑ID */
+    private String buildId;
+
+    /** 楼层ID */
+    private String floorId;
+
+    /** 空间id */
+    private String spaceId;
+
+    /** BimId编码 */
+    private String bimId;
+
+    /** beaconID */
+    private String beaconId;
+
+    /** 位置 */
+    private String position;
+
+    /** 信息类型 */
+    private String type;
+
+    /** X坐标 */
+    private String x;
+
+    /** Y坐标 */
+    private String y;
+
+    /** 备注 */
+    private String note;
+
+    /** 图片信息 */
+    private ArrayList<AdmPointImage> imageList;
+
+    /** 类型编码,默认:LocationPoint */
+    private String classCode="LocationPoint";
+
+    /** 对象类型,默认:point */
+    private String objType="point";
+}

+ 29 - 0
src/main/java/com/persagy/proxy/adm/model/AdmPointImage.java

@@ -0,0 +1,29 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+/**
+ * @ClassName AdmLocationPoint
+ * @Description: ADM点位图片
+ * @Author linhuili
+ * @Date 2021/8/31 09:44
+ * @Version V1.0
+ **/
+@Data
+public class AdmPointImage {
+
+    /** 图片 id */
+    private String id;
+
+    /** 图片 key */
+   private String key;
+
+    /** 图片类型 */
+    private String type;
+
+    /** 图片名称 */
+    private String name;
+
+    /** 对象id */
+    private String objectId;
+}

+ 13 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmLocationPointService.java

@@ -0,0 +1,13 @@
+package com.persagy.proxy.adm.service;
+
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+
+/**
+ * @ClassName IAdmLocationPointService
+ * @Description: 点位标签
+ * @Author linhuili
+ * @Date 2021/8/30 16:07
+ * @Version V1.0
+ **/
+public interface IAdmLocationPointService extends IAdmBaseService<AdmLocationPoint>{
+}

+ 16 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AdmLocationPointServiceImpl.java

@@ -0,0 +1,16 @@
+package com.persagy.proxy.adm.service.impl;
+
+import com.persagy.proxy.adm.model.AdmLocationPoint;
+import com.persagy.proxy.adm.service.IAdmLocationPointService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @ClassName AdmLocationPointServiceImpl
+ * @Description: 点位标签实现类
+ * @Author linhuili
+ * @Date 2021/8/31 09:47
+ * @Version V1.0
+ **/
+@Service
+public class AdmLocationPointServiceImpl extends AbstractAdmBaseServiceImpl<AdmLocationPoint> implements IAdmLocationPointService {
+}