lyhzzz il y a 1 jour
Parent
commit
1c09aea5c3

+ 36 - 0
src/main/java/com/fdkankan/manage/common/MyFileUtil.java

@@ -0,0 +1,36 @@
+package com.fdkankan.manage.common;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.File;
+import java.nio.file.FileSystemException;
+
+@Slf4j
+public class MyFileUtil {
+
+    public static void del(File file){
+        try {
+            for (int i = 0; i < 3; i++) {
+                try {
+                    if(!file.exists()){
+                        return;
+                    }
+                    file.delete();
+                    return;
+                } catch (Exception e) {
+                    if (i == 2) throw e;
+                    Thread.sleep(2000L * (i + 1));
+                }
+            }
+        }catch (Exception e){
+            log.info("文件删除失败:{}",e);
+        }
+
+    }
+    public static void del(String filePath){
+        if(StringUtils.isNotBlank(filePath)){
+            del(new File(filePath));
+        }
+    }
+}

+ 5 - 0
src/main/java/com/fdkankan/manage/httpClient/service/FdkkService.java

@@ -54,6 +54,8 @@ public class FdkkService {
             if(resultData.getCode() != 0){
                 throw new BusinessException(resultData.getCode(),resultData.getMessage());
             }
+        }catch (BusinessException e){
+            throw e;
         }catch (Exception e){
             log.info("uploadSceneOrig:{}",e);
             throw new BusinessException(ResultCode.UPLOAD_ERROR);
@@ -102,6 +104,9 @@ public class FdkkService {
             }
             JSONObject jsonObject = JSON.parseObject(sceneJsonStr);
             //校验版本
+            if(!jsonObject.containsKey("camType") || !jsonObject.containsKey("offlineVersion")){
+                return new UploadSceneCheckVo(ResultCode.UPLOAD_SCENE_ERROR4);
+            }
             String offlineVersion = jsonObject.getString("offlineVersion");
 
             String platformVersion = manageConfig.getPlatformVersion();//从数据中获取

+ 7 - 7
src/main/java/com/fdkankan/manage/service/impl/AuthPageServiceImpl.java

@@ -124,8 +124,8 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
         }
         List<AuthPage> authPages = this.getByJyUserId(loginUser.getId());
         List<Integer> platformIds = authPages.stream().map(AuthPage::getCreaterPlatformId).collect(Collectors.toList());
+        List<JyPlatform> reList = new ArrayList<>();
         if(!platformIds.isEmpty()){
-            List<JyPlatform> reList = new ArrayList<>();
             List<JyPlatform> jyPlatforms = platformService.listByIds(platformIds);
             for (JyPlatform jyPlatform : jyPlatforms) {
                 jyPlatform.setPageAuth("admin");
@@ -143,8 +143,7 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
             reList.addAll(jyPlatforms);
             return reList;
         }
-
-        return new ArrayList<>();
+        return reList;
     }
 
     @Override
@@ -156,12 +155,13 @@ public class AuthPageServiceImpl extends ServiceImpl<IAuthPageMapper, AuthPage>
             List<GroupByCount> list = dataService.cameraGroupByPlatformId(new ArrayList<>());
             return getCameraGroupList(list);
         }
-
+        List<Integer> platformIds = new ArrayList<>();
         List<JyPlatform> jyPlatforms = this.platformList(sceneType);
-        if(jyPlatforms == null || jyPlatforms.isEmpty()){
-            return new ArrayList<>();
+        if(jyPlatforms !=null && !jyPlatforms.isEmpty()){
+            platformIds.addAll( jyPlatforms.stream().map(JyPlatform::getId).collect(Collectors.toList()));
         }
-        List<Integer> platformIds = jyPlatforms.stream().map(JyPlatform::getId).collect(Collectors.toList());
+        JyUser loginUser = jyUserService.getLoginUser();
+        platformIds.add(loginUser.getPlatformId());
         List<GroupByCount> list = dataService.cameraGroupByPlatformId(platformIds);
         return getCameraGroupList(list);
     }

+ 9 - 8
src/main/java/com/fdkankan/manage/service/impl/CommonServiceImpl.java

@@ -6,6 +6,7 @@ import cn.hutool.core.io.FileUtil;
 import cn.hutool.json.JSONObject;
 import com.alibaba.fastjson.JSONArray;
 import com.fdkankan.common.util.SecurityUtil;
+import com.fdkankan.manage.common.MyFileUtil;
 import com.fdkankan.manage.common.OssPath;
 import com.fdkankan.manage.common.ResultCode;
 import com.fdkankan.manage.common.ResultData;
@@ -80,7 +81,7 @@ public class CommonServiceImpl implements ICommonService {
             throw new BusinessException(ResultCode.UPLOAD_ERROR);
         }finally {
             if(tempFile != null){
-                tempFile.delete();
+                MyFileUtil.del(tempFile);
             }
         }
 
@@ -135,7 +136,7 @@ public class CommonServiceImpl implements ICommonService {
             }
             String format = extName.replace(".", "");
             CommonUpload commonUpload = commonUploadService.add(originalFilename.replace(extName, ""), url, String.valueOf(file.getSize()), uuid, fileTypeEnum, format,format,1,null,dictId);
-            tempFile.delete();
+            MyFileUtil.del(tempFile);
             return ResultData.ok(commonUpload);
         }catch ( BusinessException e){
             log.info("upload-file-error:{}",e);
@@ -203,7 +204,7 @@ public class CommonServiceImpl implements ICommonService {
         Integer status = StringUtils.isNotBlank(url) ?1:-1;
         CommonUpload commonUpload = commonUploadService.add(oldName,url, String.valueOf(tempFile.length()),
                 null, fileTypeEnum, modelFileFormat,resultFormat,status,unzipPath,dictId);
-        tempFile.delete();
+        MyFileUtil.del(tempFile);
         return ResultData.ok(commonUpload);
     }
 
@@ -216,7 +217,7 @@ public class CommonServiceImpl implements ICommonService {
         if(!fYunFileServiceInterface.fileExist(localGlbPath.replace(OssPath.localPath,""))){
             throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
         }
-        FileUtil.del(unzipPath);
+         MyFileUtil.del(unzipPath);
         return  ossUrlPrefix +  localGlbPath.replace(OssPath.localPath,"");
     }
 
@@ -230,7 +231,7 @@ public class CommonServiceImpl implements ICommonService {
         if(!fYunFileServiceInterface.fileExist(ossPath)){
             throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
         }
-        FileUtil.del(unzipPath);
+         MyFileUtil.del(unzipPath);
         return ossUrlPrefix +  ossPath;
     }
 
@@ -249,7 +250,7 @@ public class CommonServiceImpl implements ICommonService {
         if(!fYunFileServiceInterface.fileExist(modelOssPath)){
             throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
         }
-        FileUtil.del(unzipPath);
+         MyFileUtil.del(unzipPath);
         return ossUrlPrefix +  ossPath;
     }
 
@@ -260,7 +261,7 @@ public class CommonServiceImpl implements ICommonService {
         if(!fYunFileServiceInterface.fileExist(modelOssPath)){
             throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
         }
-        FileUtil.del(unzipPath);
+         MyFileUtil.del(unzipPath);
         return ossUrlPrefix +  modelOssPath;
     }
 
@@ -271,7 +272,7 @@ public class CommonServiceImpl implements ICommonService {
         if(!fYunFileServiceInterface.fileExist(ossPath+"/webcloud/cloud.js")){
             throw new BusinessException(-1,"缺少cloud.js文件");
         }
-        FileUtil.del(unzipPath);
+         MyFileUtil.del(unzipPath);
         return ossUrlPrefix +  ossPath + "/webcloud";
     }
 

+ 2 - 2
src/main/java/com/fdkankan/manage/service/impl/DataService.java

@@ -47,10 +47,10 @@ public class DataService implements IDataService {
        Boolean isSuperAdmin  = sysRoleService.isSuperAdmin();
        Boolean isAdmin  = sysRoleService.isAdmin();
 
-       if (param.getPlatformId() != null && !param.getPlatformId().equals(jyUser.getPlatformId()) && !isSuperAdmin) {
+       if (param.getPlatformId() != null  && !isSuperAdmin) {
            List<JyPlatform> jyPlatforms = authPageService.platformList(3);
            List<Integer> collect = jyPlatforms.stream().map(JyPlatform::getId).collect(Collectors.toList());
-           if(!collect.contains(param.getPlatformId())){
+           if(!collect.contains(param.getPlatformId()) && !param.getPlatformId().equals(jyUser.getPlatformId())){
                throw new BusinessException(ResultCode.NOT_PERMISSION);
            }
        }else {