|
@@ -7,6 +7,7 @@ import com.fdkankan.openApi.constant.JmgaConstant;
|
|
import com.fdkankan.openApi.dto.www.DownSceneDto;
|
|
import com.fdkankan.openApi.dto.www.DownSceneDto;
|
|
import com.fdkankan.openApi.httpclient.client.JmgaClient;
|
|
import com.fdkankan.openApi.httpclient.client.JmgaClient;
|
|
import com.fdkankan.openApi.vo.www.CaseParam;
|
|
import com.fdkankan.openApi.vo.www.CaseParam;
|
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,25 +23,32 @@ public class CaseService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static String caseDownKey = "open-api:fusion:case:";
|
|
|
|
+ @Autowired
|
|
|
|
+ RedisUtil redisUtil;
|
|
public DownSceneDto getCaseOfflinePage(Integer caseId) {
|
|
public DownSceneDto getCaseOfflinePage(Integer caseId) {
|
|
if(caseId == null){
|
|
if(caseId == null){
|
|
throw new BusinessException(ErrorCode.PARAM_ERROR);
|
|
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());
|
|
|
|
|
|
+ String redisKey = caseDownKey + caseId;
|
|
|
|
+ if(!redisUtil.hasKey(redisKey)){
|
|
|
|
+ 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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ redisUtil.set(redisKey,"1",60 * 60 * 24);
|
|
}
|
|
}
|
|
|
|
|
|
ResultData processResult = jmgaClient.get(JmgaConstant.API_GET_DOWNLOAD_PROCESS_CASE + "?caseId=" + caseId );
|
|
ResultData processResult = jmgaClient.get(JmgaConstant.API_GET_DOWNLOAD_PROCESS_CASE + "?caseId=" + caseId );
|
|
@@ -53,8 +61,12 @@ public class CaseService {
|
|
Integer percent = processObj.getInteger("percent");
|
|
Integer percent = processObj.getInteger("percent");
|
|
Integer processStatus = processObj.getInteger("status");
|
|
Integer processStatus = processObj.getInteger("status");
|
|
if(processStatus == 1003){
|
|
if(processStatus == 1003){
|
|
|
|
+ redisUtil.del(redisKey);
|
|
return new DownSceneDto(processUrl,percent,-1);
|
|
return new DownSceneDto(processUrl,percent,-1);
|
|
}
|
|
}
|
|
|
|
+ if((percent == 100 || percent == 0) && processStatus == 1000 ){
|
|
|
|
+ redisUtil.del(redisKey);
|
|
|
|
+ }
|
|
return new DownSceneDto(processUrl,percent);
|
|
return new DownSceneDto(processUrl,percent);
|
|
}
|
|
}
|
|
|
|
|