dengsixing недель назад: 3
Родитель
Сommit
8579f0959f

+ 0 - 57
src/main/java/com/fdkankan/scene/httpclient/FdkankanMiniClient.java

@@ -1,57 +0,0 @@
-//package com.fdkankan.scene.httpclient;
-//
-//import com.dtflys.forest.annotation.Get;
-//import com.dtflys.forest.annotation.Header;
-//import com.dtflys.forest.annotation.Post;
-//import com.dtflys.forest.annotation.Retry;
-//import com.dtflys.forest.annotation.Success;
-//import com.dtflys.forest.annotation.Var;
-//import com.dtflys.forest.callback.OnError;
-//import com.dtflys.forest.callback.OnSuccess;
-//import com.fdkankan.common.response.Result;
-//import java.util.Map;
-//import com.fdkankan.scene.bean.CameraBean;
-//import com.fdkankan.scene.bean.UserIncrementBean;
-//import com.fdkankan.scene.callback.FdkkMiniReqSuccessCondition;
-//
-///**
-// * <p>
-// * TODO
-// * </p>
-// *
-// * @author dengsixing
-// * @since 2022/4/24
-// **/
-//@Success(condition = FdkkMiniReqSuccessCondition.class)
-//public interface FdkankanMiniClient {
-//
-//    @Get(url="{url}"
-////        ,interceptor = TLogForestInterceptor.class    加这个拦截器,打印的tlog日志会详细一些,包括头信息等等
-//    )
-//    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-//    Result<String> getDataSyncType(@Var("url") String url, OnSuccess<Result> onSuccess, OnError onError);
-//
-//    @Get("{url}")
-//    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-//    Result<UserIncrementBean> getUserIncrementByCameraId(@Var("url") String url, OnSuccess<Result> onSuccess, OnError onError);
-//
-//    @Get("{url}")
-//    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-//    Result<CameraBean> getCameraByCameraId(@Var("url") String url, OnSuccess<Result> onSuccess, OnError onError);
-//
-////    @Get(url="{url}")
-////    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-////    Result<SceneProV3> getSceneProByNum(@Var("url") String url, OnSuccess<Result> onSuccess, OnError onError);
-//
-//    @Post(url="{url}")
-//    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-//    Result<Map<String, Object>> getIsLogin(@Var("url") String url, @Header("token") String token, OnSuccess<Result> onSuccess, OnError onError);
-//
-////    @Post(
-////        url = "${url}",
-////        contentType = "application/json"
-////    )
-////    @Retry(maxRetryCount = "3", maxRetryInterval = "100")
-////    Result upgradeToV4ResultSync(@Var("url") String url, @Body RequestSceneProV4 param, OnSuccess<Result> onSuccess, OnError onError);
-//
-//}

+ 38 - 0
src/main/java/com/fdkankan/scene/httpclient/ShapesHttpClient.java

@@ -0,0 +1,38 @@
+package com.fdkankan.scene.httpclient;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.dtflys.forest.annotation.*;
+import com.dtflys.forest.callback.OnError;
+import com.dtflys.forest.callback.OnSuccess;
+import com.fdkankan.scene.httpclient.callback.CommonErrorCallback;
+import com.fdkankan.scene.httpclient.callback.CommonSuccessCallback;
+import com.fdkankan.scene.httpclient.callback.CommonSuccessCondition;
+import com.fdkankan.scene.vo.BaseSceneParamVO;
+import com.fdkankan.scene.vo.TraceEvidenceInfoListParamVo;
+import com.fdkankan.scene.vo.TraceEvidenceListParamVO;
+import com.fdkankan.web.response.ResultData;
+
+import java.util.List;
+
+@Success(condition = CommonSuccessCondition.class)
+public interface ShapesHttpClient {
+
+    @Post("${host}/service/shapes/seg/list")
+    ResultData<List<JSONObject>> shapesSegList(@Var("host") String host, @JSONBody BaseSceneParamVO param,OnSuccess onSuccess, OnError onError);
+
+//    @Post("${host}/service/manage/inner/traceEvidenceInfoList")
+//    ResultData traceEvidenceInfoList(@Var("host") String host, @Header("token") String token, @JSONBody TraceEvidenceInfoListParamVo param);
+//
+//    @Get("${host}/service/manage/inner/refreshTraceEvidenceInfoList/${kno}")
+//    ResultData refreshTraceEvidenceInfoList(@Var("host") String host, @Header("token") String token, @Var("kno") String kno);
+//
+//    @Post("${host}/service/manage/inner/addMediaLibrary")
+//    ResultData addMediaLibrary(@Var("host") String host, @Header("token") String token, @JSONBody JSONObject param);
+//
+//    @Post("${host}/service/manage/inner/addMediaLibrarys")
+//    ResultData addMediaLibrarys(@Var("host") String host, @Header("token") String token, @JSONBody JSONObject param);
+//
+//    @Get("${host}/service/manage/inner/getCaseByNum?num=${num}")
+//    ResultData getCaseByNum(@Var("host") String host, @Var("num") String num);
+}

+ 7 - 6
src/main/java/com/fdkankan/scene/callback/FdkkMiniReqErrorCallback.java

@@ -1,4 +1,4 @@
-package com.fdkankan.scene.callback;
+package com.fdkankan.scene.httpclient.callback;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -9,6 +9,7 @@ import com.dtflys.forest.http.ForestResponse;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.web.response.Result;
+import com.fdkankan.web.response.ResultData;
 import lombok.extern.slf4j.Slf4j;
 
 /**
@@ -20,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
  * @since 2022/4/25
  **/
 @Slf4j
-public class FdkkMiniReqErrorCallback implements OnError {
+public class CommonErrorCallback implements OnError {
 
     @Override
     public void onError(ForestRuntimeException e, ForestRequest forestRequest,
@@ -28,12 +29,12 @@ public class FdkkMiniReqErrorCallback implements OnError {
         JSONObject jsonObject = JSON.parseObject(forestResponse.getContent());
         Integer status = jsonObject.getInteger("status");
         if(status != null && status == 500){
-            log.error("v3接口报错,status:{},error:{}", status, jsonObject.getString("error"));
+            log.error("接口报错,status:{},error:{}", status, jsonObject.getString("error"));
             throw new BusinessException(ServerCode.SYSTEM_ERROR);
         }
-        Result result = JSON.parseObject(forestResponse.getContent(), Result.class);
-        if(result.getCode() != ServerCode.SUCCESS.code()){
-            throw new BusinessException(result.getCode(), result.getMsg());
+        ResultData resultData = JSON.parseObject(forestResponse.getContent(), ResultData.class);
+        if(resultData.getCode() != ServerCode.SUCCESS.code()){
+            throw new BusinessException(resultData.getCode(), resultData.getMessage());
         }
         log.error("跨服务请求失败!", e);
         throw new BusinessException(ServerCode.FEIGN_REQUEST_FAILD);

+ 5 - 4
src/main/java/com/fdkankan/scene/callback/FdkkMiniReqSuccessCallback.java

@@ -1,9 +1,10 @@
-package com.fdkankan.scene.callback;
+package com.fdkankan.scene.httpclient.callback;
 
 import com.dtflys.forest.callback.OnSuccess;
 import com.dtflys.forest.http.ForestRequest;
 import com.dtflys.forest.http.ForestResponse;
 import com.fdkankan.web.response.Result;
+import com.fdkankan.web.response.ResultData;
 import lombok.extern.slf4j.Slf4j;
 
 /**
@@ -15,11 +16,11 @@ import lombok.extern.slf4j.Slf4j;
  * @since 2022/4/25
  **/
 @Slf4j
-public class FdkkMiniReqSuccessCallback implements OnSuccess<Result> {
+public class CommonSuccessCallback implements OnSuccess<ResultData> {
 
     @Override
-    public void onSuccess(Result result, ForestRequest forestRequest,
+    public void onSuccess(ResultData result, ForestRequest forestRequest,
         ForestResponse forestResponse) {
-        log.info("请求v3成功,url:{},result:{}", forestRequest.getUrl(), forestResponse.getContent());
+        log.info("请求成功,url:{},result:{}", forestRequest.getUrl(), forestResponse.getContent());
     }
 }

+ 7 - 5
src/main/java/com/fdkankan/scene/callback/FdkkMiniReqSuccessCondition.java

@@ -1,12 +1,14 @@
-package com.fdkankan.scene.callback;
+package com.fdkankan.scene.httpclient.callback;
 
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.dtflys.forest.callback.SuccessWhen;
 import com.dtflys.forest.http.ForestRequest;
 import com.dtflys.forest.http.ForestResponse;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.web.response.Result;
+import com.fdkankan.web.response.ResultData;
 
 /**
  * <p>
@@ -18,7 +20,7 @@ import com.fdkankan.web.response.Result;
  * @since 2022/4/25
  **/
 
-public class FdkkMiniReqSuccessCondition implements SuccessWhen {
+public class CommonSuccessCondition implements SuccessWhen {
 
     /**
      * 请求成功条件
@@ -36,12 +38,12 @@ public class FdkkMiniReqSuccessCondition implements SuccessWhen {
         }
 
         String content = res.getContent();
-        if(StrUtil.isEmpty(content)){
+        if(StrUtil.isEmpty(content) || !JSONUtil.isJson(content)){
             reqStatus = false;
             return reqStatus;
         }
-        Result result = JSON.parseObject(content, Result.class);
-        if(result.getCode() != ServerCode.SUCCESS.code()){
+        ResultData resultData = JSON.parseObject(content, ResultData.class);
+        if(resultData.getCode() != ServerCode.SUCCESS.code()){
             reqStatus = false;
             return reqStatus;
         }

+ 30 - 4
src/main/java/com/fdkankan/scene/service/impl/SceneDrawServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.fdkankan.common.constant.CommonStatus;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.constant.FileBizType;
+import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
@@ -23,12 +24,17 @@ import com.fdkankan.scene.bean.TagBean;
 import com.fdkankan.scene.entity.SceneEditInfoExt;
 import com.fdkankan.scene.entity.ScenePlus;
 import com.fdkankan.scene.entity.ScenePlusExt;
+import com.fdkankan.scene.httpclient.ShapesHttpClient;
+import com.fdkankan.scene.httpclient.callback.CommonErrorCallback;
+import com.fdkankan.scene.httpclient.callback.CommonSuccessCallback;
 import com.fdkankan.scene.service.*;
 import com.fdkankan.scene.vo.BaseJsonArrayParamVO;
+import com.fdkankan.scene.vo.BaseSceneParamVO;
 import com.fdkankan.scene.vo.DeleteFileParamVO;
 import com.fdkankan.scene.vo.DeleteSidListParamVO;
 import com.fdkankan.web.response.ResultData;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -41,6 +47,9 @@ public class SceneDrawServiceImpl implements ISceneDrawService {
 
     private final String SCENE_DRAW_JSON_NAME = "sceneDraw.json";
 
+    @Value("${4dkk.fdService.basePath}")
+    private String fdServiceHost;
+
     @Autowired
     private IScenePlusService scenePlusService;
     @Autowired
@@ -55,6 +64,8 @@ public class SceneDrawServiceImpl implements ISceneDrawService {
     private ISceneEditInfoService sceneEditInfoService;
     @Resource
     private FYunFileServiceInterface fYunFileService;
+    @Resource
+    private ShapesHttpClient shapesHttpClient;
 
     @Override
     public void saveSceneDraw(BaseJsonArrayParamVO param) throws Exception {
@@ -181,11 +192,11 @@ public class SceneDrawServiceImpl implements ISceneDrawService {
         List<JSONObject> tags = new ArrayList<>();
         this.syncFileToRedis(num);
 
-        //获取裁剪模型数据
+        List<TagBean> sortList = new ArrayList<>();
         String key = String.format(RedisKey.SCENE_DRAW, num);
         List<String> list = redisUtil.hgetValues(key);
         if(CollUtil.isNotEmpty(list)){
-            List<TagBean> sortList = list.stream().map(str -> {
+            List<TagBean> drawList = list.stream().map(str -> {
                 JSONObject jsonObject = JSON.parseObject(str);
                 TagBean tagBean = new TagBean();
                 tagBean.setCreateTime(jsonObject.getLong("createTime"));
@@ -193,10 +204,25 @@ public class SceneDrawServiceImpl implements ISceneDrawService {
                 tagBean.setTag(jsonObject);
                 return tagBean;
             }).collect(Collectors.toList());
-            sortList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
-            tags = sortList.stream().map(item -> item.getTag()).collect(Collectors.toList());
+            sortList.addAll(drawList);
+        }
+
+        BaseSceneParamVO sceneParamVO = new BaseSceneParamVO();
+        sceneParamVO.setNum(num);
+        List<JSONObject> shapesReps = shapesHttpClient.shapesSegList(fdServiceHost, sceneParamVO, new CommonSuccessCallback(), new CommonErrorCallback()).getData();
+        if(CollUtil.isNotEmpty(shapesReps)){
+            List<TagBean> shapeList = shapesReps.stream().map(v -> {
+                TagBean tagBean = new TagBean();
+                tagBean.setCreateTime(v.getDate("updateTime").getTime());
+                tagBean.setTag(v);
+                return tagBean;
+            }).collect(Collectors.toList());
+            sortList.addAll(shapeList);
         }
 
+        sortList.sort(Comparator.comparingLong(TagBean::getCreateTime).reversed());
+        tags = sortList.stream().map(item -> item.getTag()).collect(Collectors.toList());
+
         return tags;
     }