|
@@ -24,14 +24,17 @@ import com.fdkankan.manage.entity.*;
|
|
|
import com.fdkankan.manage.mapper.ISceneProMapper;
|
|
|
import com.fdkankan.manage.mq.common.MqQueueUtil;
|
|
|
import com.fdkankan.manage.mq.param.ScenePayStatusVo;
|
|
|
+import com.fdkankan.manage.mq.param.SceneRestStoreVo;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
+import com.fdkankan.manage.thread.ThreadService;
|
|
|
+import com.fdkankan.manage.util.CameraUtils;
|
|
|
import com.fdkankan.manage.util.Dateutils;
|
|
|
+import com.fdkankan.manage.util.ProvinceUtils;
|
|
|
import com.fdkankan.manage.util.SceneStatusUtil;
|
|
|
import com.fdkankan.manage.vo.request.SceneParam;
|
|
|
-import com.fdkankan.manage.vo.response.CameraDataVo;
|
|
|
-import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
-import com.fdkankan.manage.vo.response.SceneVo;
|
|
|
+import com.fdkankan.manage.vo.response.*;
|
|
|
import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -97,6 +100,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
ISceneDelLogService sceneDelLogService;
|
|
|
@Autowired
|
|
|
RabbitMqProducer rabbitMqProducer;
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+ @Autowired
|
|
|
+ ISceneColdStorageService sceneColdStorageService;
|
|
|
+ @Autowired
|
|
|
+ ICommonService commonService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -213,6 +222,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
List<String> numList = records.parallelStream().map(SceneVo::getNum).collect(Collectors.toList());
|
|
|
map = copyLogService.getByNewNumList(numList);
|
|
|
}
|
|
|
+ HashMap<String,SceneColdStorage> coldStorageMap = null;
|
|
|
+ if(records.size() >0){
|
|
|
+ List<String> numList = records.parallelStream().map(SceneVo::getNum).collect(Collectors.toList());
|
|
|
+ coldStorageMap = sceneColdStorageService.getByNumList(numList);
|
|
|
+ }
|
|
|
for (SceneVo record : page.getRecords()) {
|
|
|
record.setStatusString(SceneStatusUtil.getStatusString(record));
|
|
|
if(map !=null ){
|
|
@@ -222,6 +236,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
record.setIsCopy(true);
|
|
|
}
|
|
|
}
|
|
|
+ if(coldStorageMap != null){
|
|
|
+ SceneColdStorage sceneColdStorage = coldStorageMap.get(record.getNum());
|
|
|
+ if(sceneColdStorage != null){
|
|
|
+ record.setIsColdStorage(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
if(record.getStatus() == -1){ //计算失败
|
|
|
SceneBuildProcessLog sceneBuildProcessLog = sceneBuildProcessLogService.getByNum(record.getNum());
|
|
|
if(sceneBuildProcessLog != null){
|
|
@@ -229,6 +249,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
record.setBuildErrorReason(SceneBuildProcessLogEnum.getReason(sceneBuildProcessLog.getProcess()));
|
|
|
}
|
|
|
}
|
|
|
+ //{"latitude":22.3672085,"longitude":113.595673,"altitude":9.275519,"horizontalAccuracy":65.0,"verticalAccuracy":10.0,"timestamp":1564381147.2775609}
|
|
|
+ record.setAddressComponent(commonService.getAddressComponent(record.getGps()));
|
|
|
}
|
|
|
return PageInfo.PageInfo(page);
|
|
|
}
|
|
@@ -284,10 +306,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(!oldCameraDetail.getType().equals(cameraDetail.getType())){
|
|
|
throw new BusinessException(ResultCode.CAMERA_TYPE_NOT_ERROR);
|
|
|
}
|
|
|
- String home = dataSource.replace("/mnt/data", "home")+"/data.fdage";
|
|
|
- if(!fYunFileServiceInterface.fileExist(home)){
|
|
|
- throw new BusinessException(ResultCode.MOVE_ERROR);
|
|
|
- }
|
|
|
+// String home = dataSource.replace("/mnt/data", "home")+"/data.fdage";
|
|
|
+// if(!fYunFileServiceInterface.fileExist(home)){
|
|
|
+// throw new BusinessException(ResultCode.MOVE_ERROR);
|
|
|
+// }
|
|
|
|
|
|
HashMap<String, SceneCopyLog> byNewNumList = copyLogService.getByNewNumList(Arrays.asList(param.getNum()));
|
|
|
if(byNewNumList.size() >0){
|
|
@@ -308,26 +330,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
Long subSpace = oldCameraDetail.getTotalSpace() - oldUseSpace;
|
|
|
|
|
|
- if(oldCameraDetail.getType() != 11 && oldCameraDetail.getType() != 10 && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(oldCameraDetail,oldCameraDetail.getCameraId(),1);
|
|
|
- }
|
|
|
-
|
|
|
- Integer payStatus = scenePro == null ? scenePlus.getPayStatus() : scenePro.getPayStatus();
|
|
|
-
|
|
|
- if(cameraDetail.getType() != 11 && cameraDetail.getType() != 10 && payStatus!=1){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(scenePro,scenePlus,1);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
if(scenePro!=null){
|
|
|
LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(ScenePro::getId,scenePro.getId());
|
|
|
wrapper.set(ScenePro::getCameraId,camera.getId());
|
|
|
wrapper.set(ScenePro::getUserId,cameraDetail.getUserId());
|
|
|
- wrapper.set(ScenePro::getStatus,0);
|
|
|
+ // wrapper.set(ScenePro::getStatus,0);
|
|
|
+ // this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),0,"status");
|
|
|
this.update(wrapper);
|
|
|
//场景迁移到另外的相机清除本身在的文件夹
|
|
|
- this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),0,"status");
|
|
|
folderSceneService.delBySceneId(scenePro.getId());
|
|
|
}
|
|
|
if(scenePlus!=null){
|
|
@@ -335,23 +346,30 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
wrapper.eq(ScenePlus::getId,scenePlus.getId());
|
|
|
wrapper.set(ScenePlus::getCameraId,camera.getId());
|
|
|
wrapper.set(ScenePlus::getUserId,cameraDetail.getUserId());
|
|
|
- wrapper.set(ScenePlus::getSceneStatus,0);
|
|
|
+ //wrapper.set(ScenePlus::getSceneStatus,0);
|
|
|
+ //this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),0,"status");
|
|
|
scenePlusService.update(wrapper);
|
|
|
- this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),0,"status");
|
|
|
folderSceneService.delBySceneId(scenePlus.getId());
|
|
|
}
|
|
|
//协作相机
|
|
|
sceneResourceCameraService.setCooperationUser(cameraDetail,param.getNum());
|
|
|
|
|
|
- String newDataSource = updateFdageNewDataSource(scenePro, scenePlus, oldCamera.getSnCode(), param.getSnCode(), dataSource);
|
|
|
+ //String newDataSource = updateFdageNewDataSource(scenePro, scenePlus, oldCamera.getSnCode(), param.getSnCode(), dataSource);
|
|
|
|
|
|
if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11){ //深时场景
|
|
|
//迁移深时 dataSource
|
|
|
- FileUtil.move(new File(dataSource +"_laserData"),new File(newDataSource+"_laserData"),true);
|
|
|
- laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),newDataSource);
|
|
|
+ //FileUtil.move(new File(dataSource +"_laserData"),new File(newDataSource+"_laserData"),true);
|
|
|
+ laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),dataSource);
|
|
|
}
|
|
|
cameraDetailService.initSpace(oldCameraDetail);
|
|
|
cameraDetailService.initSpace(cameraDetail);
|
|
|
+
|
|
|
+ if(oldCameraDetail.getType() != 11 && oldCameraDetail.getType() != 10 && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(oldCameraDetail.getCameraId());
|
|
|
+ }
|
|
|
+ if(cameraDetail.getType() != 11 && cameraDetail.getType() != 10){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(cameraDetail.getCameraId());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -380,6 +398,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
try {
|
|
|
newSnCode = newSnCode.toLowerCase();
|
|
|
String fdagePaht = dataSource.replace("/mnt/data","home") +"/data.fdage";
|
|
|
+ if(!fYunFileServiceInterface.fileExist(fdagePaht)){
|
|
|
+ return dataSource;
|
|
|
+ }
|
|
|
localPathFdage = String.format(OssPath.localFdagePath,fdagePaht);
|
|
|
String fileContent = fYunFileServiceInterface.getFileContent(fdagePaht);
|
|
|
JSONObject jsonObject = updateFdageJson(JSONObject.parseObject(fileContent), newSnCode);
|
|
@@ -616,6 +637,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
snCodeMap.put(num,cameraMap.get(cameraId));
|
|
|
}
|
|
|
}
|
|
|
+ List<CameraDetail> cameraIds1 = cameraDetailService.getByCameraIds(cameraList.stream().map(Camera::getId).collect(Collectors.toList()));
|
|
|
+ for (CameraDetail cameraDetail : cameraIds1) {
|
|
|
+ snCodeMap.put(cameraMap.get(cameraDetail.getCameraId()), CameraUtils.getCameraTypeStr(CameraUtils.getCameraType(cameraDetail.getType())));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return snCodeMap;
|
|
@@ -637,6 +662,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
@Override
|
|
|
public void rebuildScene(String num) {
|
|
|
+ String redisKey2 = String.format(RedisKeyUtil.numShootKey, num);
|
|
|
+ redisUtil.del(redisKey2);
|
|
|
String dataSource = null;
|
|
|
ScenePro scenePro = this.getByNum(num);
|
|
|
if(scenePro!=null && scenePro.getSceneSource() != 4){
|
|
@@ -662,6 +689,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(countByNewNum >0){
|
|
|
throw new BusinessException(ResultCode.COPY_NUM_NOTREBUILD);
|
|
|
}
|
|
|
+ SceneColdStorage coldStorage = sceneColdStorageService.getByNum(num);
|
|
|
+ if(coldStorage != null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_REBUILD_ERROR2);
|
|
|
+ }
|
|
|
|
|
|
if(!fYunFileServiceInterface.fileExist(dataSource.replace("/mnt/data","home")+"/data.fdage")){
|
|
|
throw new BusinessException(ResultCode.SCENE_REBUILD_ERROR);
|
|
@@ -682,6 +713,81 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void restStore(String num) {
|
|
|
+ if(StringUtils.isBlank(num)){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ String redisKey = String.format(RedisKeyUtil.restStoreKey, num);
|
|
|
+ if(redisUtil.hasKey(redisKey)){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_STORE_ING);
|
|
|
+ }
|
|
|
+ SceneColdStorage sceneColdStorage = sceneColdStorageService.getByNum(num);
|
|
|
+ if(sceneColdStorage == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_STORE);
|
|
|
+ }
|
|
|
+ String dataSource = scenePlusService.getDataSourceByNum(num);
|
|
|
+ if(StringUtils.isBlank(dataSource)){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ String homePath = dataSource.replace("/mnt/data","home");
|
|
|
+ SceneRestStoreVo sceneRestStoreVo = new SceneRestStoreVo(num,sceneColdStorage.getColdBucket(),sceneColdStorage.getBucket(),homePath);
|
|
|
+ Map<String, Object> map = BeanUtil.beanToMap(sceneRestStoreVo);
|
|
|
+ redisUtil.set(redisKey,homePath);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(MqQueueUtil.sceneRestoreQueue,map);
|
|
|
+ //threadService.checkRestore(num,sceneColdStorage.getColdBucket(),sceneColdStorage.getBucket(),homePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void restStoreSuccess(String num) {
|
|
|
+ Integer sceneResource = null;
|
|
|
+ ScenePro scenePro = this.getByNum(num);
|
|
|
+ Date time = Dateutils.dateAddOneMonth(new Date(),-11);
|
|
|
+ String date = Dateutils.getDate(time);
|
|
|
+ if(scenePro!=null ){
|
|
|
+ sceneResource = scenePro.getSceneSource();
|
|
|
+ LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(ScenePro::getId,scenePro.getId());
|
|
|
+ wrapper.set(ScenePro::getCreateTime,date);
|
|
|
+ this.update(wrapper);
|
|
|
+ }
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ if(scenePlus != null ){
|
|
|
+ sceneResource = scenePlus.getSceneSource();
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ if(scenePlusExt != null){
|
|
|
+ LambdaUpdateWrapper<ScenePlusExt> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(ScenePlusExt::getId,scenePlusExt.getId());
|
|
|
+ wrapper.set(ScenePlusExt::getAlgorithmTime,date);
|
|
|
+ scenePlusExtService.update(wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //深时场景通知修改计算完成时间
|
|
|
+ if(sceneResource != null && (sceneResource == 4 || sceneResource == 5)){
|
|
|
+ HashMap<String,String> map = new HashMap<>();
|
|
|
+ map.put("sceneCode",num);
|
|
|
+ map.put("algorithmTime",date);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(MqQueueUtil.laserUnfreezeScene,map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getRestStoreProcess(String num) {
|
|
|
+ if(StringUtils.isBlank(num)){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ SceneColdStorage sceneColdStorage = sceneColdStorageService.getByNum(num);
|
|
|
+ if(sceneColdStorage == null){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_STORE);
|
|
|
+ }
|
|
|
+ String dataSource = scenePlusService.getDataSourceByNum(num);
|
|
|
+ if(StringUtils.isBlank(dataSource)){
|
|
|
+ throw new BusinessException(ResultCode.SCENE_NOT_EXIST);
|
|
|
+ }
|
|
|
+ String homePath = dataSource.replace("/mnt/data","home");
|
|
|
+ return fYunFileServiceInterface.getRestoreFolderProcess(sceneColdStorage.getColdBucket(),homePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Long getSpaceSumByCameraId(Long cameraId) {
|
|
|
return this.getBaseMapper().getSpaceSumByCameraId(cameraId);
|
|
|
}
|