Forráskód Böngészése

增加第三方导入提交查询接口

欧阳劲驰 1 hete
szülő
commit
e9d9b7db64

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/bizservice/GisSurveyThirdImportBizService.java

@@ -184,7 +184,7 @@ public class GisSurveyThirdImportBizService {
      * @param jobId 任务id
      * @return 提交结果
      */
-    private CommAsyncResult<Boolean> getCommitResult(String jobId) {
+    public CommAsyncResult<Boolean> getCommitResult(String jobId) {
         //获取已存在的任务
         ListenableFuture<CommAsyncResult<Boolean>> previousFuture = COMMIT_TASK_CACHE.get(COMMIT_PREFIX + jobId);
         //判断完成

+ 1 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java

@@ -33,6 +33,7 @@ public class ApiURI {
     public static final String URI_XXX_THIRD_IMPORT_CANCEL = "third-import-cancel";
     public static final String URI_XXX_THIRD_IMPORT_PREVIEW = "third-import-preview";
     public static final String URI_XXX_THIRD_IMPORT_COMMIT = "third-import-commit";
+    public static final String URI_XXX_THIRD_IMPORT_COMMIT_GET = "third-import-commit-get";
     public static final String URI_XXX_THIRD_EXPORT = "third-export";
     public static final String URI_XXX_THIRD_EXPORT_GET = "third-export-get";
     public static final String URI_XXX_CAD_CONVERT = "cad-convert";

+ 83 - 1
src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java

@@ -71,6 +71,7 @@ public class ApiGisSurveyController {
     private final AtomicInteger mSeqThirdImportCancelReq;
     private final AtomicInteger mSeqThirdImportPreviewReq;
     private final AtomicInteger mSeqThirdImportCommitReq;
+    private final AtomicInteger mSeqThirdImportCommitGetReq;
     private final AtomicInteger mSeqCadConvertReq;
     private final AtomicInteger mSeqThirdExportReq;
     private final AtomicInteger mSeqThirdExportGetReq;
@@ -101,6 +102,7 @@ public class ApiGisSurveyController {
         mSeqThirdImportCancelReq = new AtomicInteger(0);
         mSeqThirdImportPreviewReq = new AtomicInteger(0);
         mSeqThirdImportCommitReq = new AtomicInteger(0);
+        mSeqThirdImportCommitGetReq = new AtomicInteger(0);
         mSeqThirdExportReq = new AtomicInteger(0);
         mSeqThirdExportGetReq = new AtomicInteger(0);
         mSeqCadConvertReq = new AtomicInteger(0);
@@ -573,7 +575,7 @@ public class ApiGisSurveyController {
 
 
     /**
-     * 提交第三方导入
+     * 第三方导入提交
      *
      * @param request       request
      * @param strClientType 客户端类型
@@ -653,6 +655,86 @@ public class ApiGisSurveyController {
         return resResult;
     }
 
+
+    /**
+     * 第三方导入提交查询
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param jobId         任务id
+     * @return 提交状态
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_THIRD_IMPORT_COMMIT_GET)
+    public ResponseRes<String> commitImport(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam("jobId") String jobId) throws Exception {
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(jobId) || StringUtils.length(jobId) > 64) {
+            throw new SelfException(ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrCode()
+                    , String.format(ApiURI.EXCEPTION_FORMAT
+                    , strPlatform
+                    , URI_PATH
+                    , ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrMsg()));
+        }
+        //begin
+        long llReqBefore = System.currentTimeMillis();
+        String strRunSeq = String.format("%d-%d", llReqBefore, mSeqThirdImportCommitGetReq.incrementAndGet());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} param:%s begin====>"
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , jobId));
+        //构建result
+        ResponseRes<String> resResult = new ResponseRes<>();
+        resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
+
+        //提交导入
+        CommAsyncResult<Boolean> result = thirdImportBizService.getCommitResult(jobId);
+        String resultStr = null;
+        try {
+            if (result != null) resultStr = objectMapper.writeValueAsString(result);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+
+        //执行成功
+        if (resultStr != null && !Objects.equals(result.getStatus(), CommAsyncStatusEnum.FAIL.getCode())) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+            resResult.setResdata(resultStr);
+        }
+        //执行失败
+        if (resultStr != null && Objects.equals(result.getStatus(), CommAsyncStatusEnum.FAIL.getCode())) {
+            resResult.setResdata(resultStr);
+        }
+        //不存在
+        if (resultStr == null) {
+            resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_NOT_FOUND.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_NOT_FOUND.toStrMsg());
+        }
+
+        //end
+        resResult.setTimestamp(System.currentTimeMillis());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , resResult.getRescode()
+                        , resResult.getResmsg()
+                        , resResult.getTimestamp() - llReqBefore));
+        return resResult;
+    }
+
     /**
      * 执行第三方导出
      *

+ 1 - 0
src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTGisSurveyBizFilter.java

@@ -27,6 +27,7 @@ public class ApiJWTGisSurveyBizFilter extends JWTAuthenticationFilter {
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_CANCEL), "GET");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_PREVIEW), "GET");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_COMMIT), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_IMPORT_COMMIT_GET), "GET");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_EXPORT), "POST");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_THIRD_EXPORT_GET), "GET");
         msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_GIS_SURVEY_H, ApiURI.URI_XXX_CAD_CONVERT), "POST");