|
@@ -5,31 +5,35 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
import cn.hutool.core.date.TimeInterval;
|
|
import cn.hutool.core.thread.ExecutorBuilder;
|
|
import cn.hutool.core.thread.ExecutorBuilder;
|
|
-import cn.hutool.core.thread.ThreadUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.CommonSuccessStatus;
|
|
import com.fdkankan.common.constant.SceneSource;
|
|
import com.fdkankan.common.constant.SceneSource;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
import com.fdkankan.common.util.DateExtUtil;
|
|
|
|
+import com.fdkankan.external.bean.DownloadProcessBean;
|
|
import com.fdkankan.external.callback.ErrorCallback;
|
|
import com.fdkankan.external.callback.ErrorCallback;
|
|
import com.fdkankan.external.callback.SuccessCallback;
|
|
import com.fdkankan.external.callback.SuccessCallback;
|
|
import com.fdkankan.external.entity.*;
|
|
import com.fdkankan.external.entity.*;
|
|
import com.fdkankan.external.httpclient.HttpClient;
|
|
import com.fdkankan.external.httpclient.HttpClient;
|
|
|
|
+import com.fdkankan.external.mapper.SceneOfflinePackagePushMapper;
|
|
import com.fdkankan.external.service.*;
|
|
import com.fdkankan.external.service.*;
|
|
|
|
+import com.fdkankan.redis.constant.RedisKey;
|
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.web.response.ResultData;
|
|
-import com.mybatisflex.annotation.UseDataSource;
|
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
-import com.fdkankan.external.mapper.SceneOfflinePackagePushMapper;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigInteger;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.concurrent.Callable;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.Objects;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -43,17 +47,9 @@ import java.util.stream.Collectors;
|
|
@Service
|
|
@Service
|
|
public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOfflinePackagePushMapper, SceneOfflinePackagePush> implements ISceneOfflinePackagePushService {
|
|
public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOfflinePackagePushMapper, SceneOfflinePackagePush> implements ISceneOfflinePackagePushService {
|
|
|
|
|
|
- @Value("${host.4dkk.manage}")
|
|
|
|
- private String fdkkManageHost;
|
|
|
|
@Value("${host.4dkk.scene}")
|
|
@Value("${host.4dkk.scene}")
|
|
private String fdkkSceneHost;
|
|
private String fdkkSceneHost;
|
|
|
|
|
|
- @Value("${api.4dkk.manage.checkDownLoad}")
|
|
|
|
- private String checkDownLoadUrl;
|
|
|
|
- @Value("${api.4dkk.manage.downScene}")
|
|
|
|
- private String downSceneUrl;
|
|
|
|
- @Value("${api.4dkk.manage.downloadProcess}")
|
|
|
|
- private String downloadProcessUrl;
|
|
|
|
@Value("${api.4dkk.scene.getInfo}")
|
|
@Value("${api.4dkk.scene.getInfo}")
|
|
private String getInfoUrl;
|
|
private String getInfoUrl;
|
|
|
|
|
|
@@ -66,17 +62,17 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
@Autowired
|
|
@Autowired
|
|
private IScenePlusService scenePlusService;
|
|
private IScenePlusService scenePlusService;
|
|
@Autowired
|
|
@Autowired
|
|
- private ISsoService ssoService;
|
|
|
|
- @Autowired
|
|
|
|
private IScenePlusExtService scenePlusExtService;
|
|
private IScenePlusExtService scenePlusExtService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneOfflinePackagePushService sceneOfflinePackagePushService;
|
|
private ISceneOfflinePackagePushService sceneOfflinePackagePushService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneService sceneService;
|
|
private ISceneService sceneService;
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private HttpClient httpClient;
|
|
private HttpClient httpClient;
|
|
@Autowired
|
|
@Autowired
|
|
private ICameraService cameraService;
|
|
private ICameraService cameraService;
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisUtil redisUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -105,11 +101,6 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- //模拟管理后台登录
|
|
|
|
- String token = ssoService.manageLogin(department.getManageUserName(), department.getManagePassword());
|
|
|
|
- Map<String, Object> headers = new HashMap<>();
|
|
|
|
- headers.put("token", token);
|
|
|
|
-
|
|
|
|
SceneOfflinePackagePush condition =
|
|
SceneOfflinePackagePush condition =
|
|
SceneOfflinePackagePush.builder()
|
|
SceneOfflinePackagePush.builder()
|
|
.departmentId(department.getId())
|
|
.departmentId(department.getId())
|
|
@@ -144,7 +135,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
push.setZipType("laser");
|
|
push.setZipType("laser");
|
|
push.setVersion(scene.getOfflineVerForPush());
|
|
push.setVersion(scene.getOfflineVerForPush());
|
|
try {
|
|
try {
|
|
- sceneOfflinePackagePushService.scenePushHandler(push, headers);
|
|
|
|
|
|
+ sceneOfflinePackagePushService.scenePushHandler(push);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
}
|
|
}
|
|
@@ -174,7 +165,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
push.setZipType("kankan");
|
|
push.setZipType("kankan");
|
|
push.setVersion(version);
|
|
push.setVersion(version);
|
|
try {
|
|
try {
|
|
- sceneOfflinePackagePushService.scenePushHandler(push, headers);
|
|
|
|
|
|
+ sceneOfflinePackagePushService.scenePushHandler(push);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
log.error("场景推送失败,num:{}",scenePlus.getNum(), e);
|
|
}
|
|
}
|
|
@@ -206,49 +197,46 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void scenePushHandler(SceneOfflinePackagePush push, Map<String, Object> headers){
|
|
|
|
|
|
+ public void scenePushHandler(SceneOfflinePackagePush push){
|
|
String num = push.getNum();
|
|
String num = push.getNum();
|
|
String zipType = push.getZipType();
|
|
String zipType = push.getZipType();
|
|
String downloadUrl = null;
|
|
String downloadUrl = null;
|
|
|
|
|
|
|
|
+ String downloadTaskKey = RedisKey.SCENE_DOWNLOADS_TASK_V4;
|
|
|
|
+ String progressKey = String.format(RedisKey.PREFIX_DOWNLOAD_PROGRESS_V4, num);
|
|
|
|
+
|
|
try {
|
|
try {
|
|
- //校验场景下载
|
|
|
|
- String url = fdkkManageHost.concat(String.format(checkDownLoadUrl, num));
|
|
|
|
- ResultData<Map<String, Object>> resultData = httpClient.get(url, headers, new SuccessCallback(), new ErrorCallback());
|
|
|
|
- Map<String, Object> data = resultData.getData();
|
|
|
|
- int downloadStatus = (int) data.get("downloadStatus");
|
|
|
|
- if (downloadStatus == 3) {
|
|
|
|
- downloadUrl = (String) data.get("downloadUrl");
|
|
|
|
- } else {
|
|
|
|
- if (downloadStatus == 0 || downloadStatus == 2) {
|
|
|
|
- url = this.fdkkManageHost.concat(String.format(downSceneUrl, num));
|
|
|
|
- httpClient.get(url, headers, new SuccessCallback(), new ErrorCallback());
|
|
|
|
|
|
+ TimeInterval timer = DateUtil.timer();
|
|
|
|
+ Map<String,String> playod = new HashMap<>(2);
|
|
|
|
+ playod.put("type","local");
|
|
|
|
+ playod.put("sceneNum",num);
|
|
|
|
+ redisUtil.lRightPush(downloadTaskKey, JSONObject.toJSONString(playod));
|
|
|
|
+ boolean exit = false;
|
|
|
|
+ String progress = null;
|
|
|
|
+ DownloadProcessBean downloadProcessBean = null;
|
|
|
|
+ do {
|
|
|
|
+ progress = redisUtil.get(progressKey);
|
|
|
|
+ if(StringUtils.isEmpty(progress)){
|
|
|
|
+ downloadProcessBean = new DownloadProcessBean();
|
|
|
|
+ }else{
|
|
|
|
+ downloadProcessBean = JSONObject.parseObject(progress, DownloadProcessBean.class);
|
|
}
|
|
}
|
|
-
|
|
|
|
- //计时
|
|
|
|
- TimeInterval timer = DateUtil.timer();
|
|
|
|
- url = this.fdkkManageHost.concat(String.format(this.downloadProcessUrl, num));
|
|
|
|
- boolean exit = false;
|
|
|
|
- do {
|
|
|
|
- ResultData<Map<String, Object>> mapResultData = httpClient.get(url, headers, new SuccessCallback(), new ErrorCallback());
|
|
|
|
- data = mapResultData.getData();
|
|
|
|
- int status = (int) data.get("status");
|
|
|
|
- if (status == 1002) {
|
|
|
|
- downloadUrl = (String) data.get("url");
|
|
|
|
- exit = true;
|
|
|
|
- }
|
|
|
|
- if (status == 1003) {
|
|
|
|
- exit = true;
|
|
|
|
- log.error("下载失败,num:{}", num);
|
|
|
|
- throw new RuntimeException("下载失败,num:" + num);
|
|
|
|
- }
|
|
|
|
- if (timer.intervalMinute() > 8 * 60) {
|
|
|
|
- exit = true;
|
|
|
|
- log.error("下载超时,num:{}", num);
|
|
|
|
- throw new RuntimeException("下载超时,num:" + num);
|
|
|
|
- }
|
|
|
|
- } while (!exit);
|
|
|
|
- }
|
|
|
|
|
|
+ Integer status = downloadProcessBean.getStatus();
|
|
|
|
+ if (Objects.nonNull(status) && status == 1002) {
|
|
|
|
+ downloadUrl = downloadProcessBean.getUrl();
|
|
|
|
+ exit = true;
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(status) && status == 1003) {
|
|
|
|
+ exit = true;
|
|
|
|
+ log.error("下载失败,num:{}", num);
|
|
|
|
+ throw new RuntimeException("下载失败,num:" + num);
|
|
|
|
+ }
|
|
|
|
+ if (timer.intervalMinute() > 8 * 60) {
|
|
|
|
+ exit = true;
|
|
|
|
+ log.error("下载超时,num:{}", num);
|
|
|
|
+ throw new RuntimeException("下载超时,num:" + num);
|
|
|
|
+ }
|
|
|
|
+ } while (!exit);
|
|
|
|
|
|
//开始推送到第三方服务
|
|
//开始推送到第三方服务
|
|
if(StrUtil.isNotEmpty(downloadUrl)){
|
|
if(StrUtil.isNotEmpty(downloadUrl)){
|
|
@@ -261,7 +249,7 @@ public class SceneOfflinePackagePushServiceImpl extends ServiceImpl<SceneOffline
|
|
params.put("downloadUrl", downloadUrl);
|
|
params.put("downloadUrl", downloadUrl);
|
|
params.put("version", push.getVersion());
|
|
params.put("version", push.getVersion());
|
|
params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
|
|
params.put("calcTime", DateExtUtil.format(scenePlusExt.getAlgorithmTime(), DateExtUtil.dateStyle8));
|
|
- ResultData pushRes = httpClient.post2(push.getDestUrl(), params, new SuccessCallback(), new ErrorCallback());
|
|
|
|
|
|
+ httpClient.post2(push.getDestUrl(), params, new SuccessCallback(), new ErrorCallback());
|
|
}
|
|
}
|
|
push.setPushStatus(CommonSuccessStatus.SUCCESS.code());
|
|
push.setPushStatus(CommonSuccessStatus.SUCCESS.code());
|
|
push.setZipPath(downloadUrl);
|
|
push.setZipPath(downloadUrl);
|