|
@@ -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());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|