|
@@ -0,0 +1,60 @@
|
|
|
|
+package com.fdkankan.openApi.service.fuison;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.fdkankan.common.constant.ErrorCode;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.openApi.constant.JmgaConstant;
|
|
|
|
+import com.fdkankan.openApi.dto.www.DownSceneDto;
|
|
|
|
+import com.fdkankan.openApi.httpclient.client.JmgaClient;
|
|
|
|
+import com.fdkankan.openApi.vo.www.CaseParam;
|
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class CaseService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ JmgaClient jmgaClient;
|
|
|
|
+ public ResultData caseList(CaseParam param) {
|
|
|
|
+ return jmgaClient.post(JmgaConstant.API_GET_LIST_CASE ,param);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public DownSceneDto getCaseOfflinePage(Integer caseId) {
|
|
|
|
+ if(caseId == null){
|
|
|
|
+ throw new BusinessException(ErrorCode.PARAM_ERROR);
|
|
|
|
+ }
|
|
|
|
+ ResultData checkResult = jmgaClient.get(JmgaConstant.API_GET_CHECK_DOWNLOAD_CASE + "?caseId=" + caseId );
|
|
|
|
+ if(checkResult.getCode() != 0 || checkResult.getData() == null){
|
|
|
|
+ throw new BusinessException(checkResult.getCode(),checkResult.getMessage());
|
|
|
|
+ }
|
|
|
|
+ JSONObject checkObject = JSONObject.parseObject(JSONObject.toJSONString(checkResult.getData()));
|
|
|
|
+ Integer checkStatus = checkObject.getInteger("downloadStatus");
|
|
|
|
+ String checkUrl = checkObject.getString("downloadUrl");
|
|
|
|
+ if(StringUtils.isNotBlank(checkUrl)){
|
|
|
|
+ return new DownSceneDto(checkUrl);
|
|
|
|
+ }
|
|
|
|
+ if(checkStatus !=1){
|
|
|
|
+ ResultData downResult = jmgaClient.get(JmgaConstant.API_GET_DOWN_SCENE_CASE + "?caseId=" + caseId );
|
|
|
|
+ if(downResult.getCode() != 0 || downResult.getData() == null){
|
|
|
|
+ throw new BusinessException(downResult.getCode(),downResult.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ResultData processResult = jmgaClient.get(JmgaConstant.API_GET_DOWNLOAD_PROCESS_CASE + "?caseId=" + caseId );
|
|
|
|
+ if(processResult.getCode() != 0 || processResult.getData() == null){
|
|
|
|
+ throw new BusinessException(processResult.getCode(),processResult.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject processObj = JSONObject.parseObject(JSONObject.toJSONString(processResult.getData()));
|
|
|
|
+ String processUrl = processObj.getString("url");
|
|
|
|
+ Integer percent = processObj.getInteger("percent");
|
|
|
|
+ Integer processStatus = processObj.getInteger("status");
|
|
|
|
+ if(processStatus == 1003){
|
|
|
|
+ return new DownSceneDto(processUrl,percent,-1);
|
|
|
|
+ }
|
|
|
|
+ return new DownSceneDto(processUrl,percent);
|
|
|
|
+ }
|
|
|
|
+}
|