Jelajahi Sumber

案例添加显示字段

lyhzzz 1 tahun lalu
induk
melakukan
ad716315ea

+ 1 - 1
src/main/java/com/fdkankan/ucenter/common/OssPath.java

@@ -7,5 +7,5 @@ public class OssPath {
     public final static String v3_scenePath = "data/data%s/scene.json";
     public final static String v3_scenePath = "data/data%s/scene.json";
     public final static String v4_statusPath = "scene_view_data/%s/data/status.json";
     public final static String v4_statusPath = "scene_view_data/%s/data/status.json";
     public final static String v4_scenePath = "scene_view_data/%s/data/scene.json";
     public final static String v4_scenePath = "scene_view_data/%s/data/scene.json";
-    public final static String localStatusPath = System.getProperty("java.io.tmpdir") +"status.json";   //获取临时文件目录
+    public final static String localStatusPath = System.getProperty("java.io.tmpdir") +"%s/status.json";   //获取临时文件目录
 }
 }

+ 0 - 1
src/main/java/com/fdkankan/ucenter/service/ISceneProService.java

@@ -85,7 +85,6 @@ public interface ISceneProService extends IService<ScenePro> {
 
 
     Object getScenes(String username, RequestScene param);
     Object getScenes(String username, RequestScene param);
 
 
-    void updateOssStatus(String path,Integer payStatus) ;
 
 
     Integer getSceneSourceByNum(String sceneNum);
     Integer getSceneSourceByNum(String sceneNum);
 
 

+ 0 - 29
src/main/java/com/fdkankan/ucenter/service/impl/ExceedSpaceSceneServiceImpl.java

@@ -105,33 +105,4 @@ public class ExceedSpaceSceneServiceImpl extends ServiceImpl<IExceedSpaceSceneMa
     }
     }
 
 
 
 
-
-    private void updateOssStatus(String num) {
-        String v3StatusJson = String.format(OssPath.v3_statusPath, num);
-        String v4StatusJson = String.format(OssPath.v4_statusPath, num);
-        String statusJson = null;
-        String path = null;
-        if(fYunFileServiceInterface.fileExist(v3StatusJson)){
-            statusJson = fYunFileServiceInterface.getFileContent(v3StatusJson);
-            path = v3StatusJson;
-        }
-        if(fYunFileServiceInterface.fileExist(v4StatusJson)){
-            statusJson = fYunFileServiceInterface.getFileContent(v4StatusJson);
-            path = v4StatusJson;
-        }
-        try {
-            JSONObject jsonObject = JSONObject.parseObject(statusJson);
-            jsonObject.put("status",0);
-            String json = JSONUtil.toJsonStr(jsonObject);
-            FileUtils.writeFile(OssPath.localStatusPath ,json);
-            log.info("updateOssStatus--localPath:{},ossPath:{},status:{}",OssPath.localStatusPath,path,0);
-            fYunFileServiceInterface.uploadFile(OssPath.localStatusPath,path);
-        }catch (Exception e){
-            log.error("updateOssStatus--localPath:{},ossPath:{},status:{},error:{}",OssPath.localStatusPath,path,0,e);
-        }finally {
-            FileUtil.delFile(OssPath.localStatusPath);
-        }
-
-    }
-
 }
 }

+ 11 - 9
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -376,18 +376,18 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
      */
      */
     private void updateOssStatus(List<String> v3NumList ,List<String> v4NumList , Integer payStatus) {
     private void updateOssStatus(List<String> v3NumList ,List<String> v4NumList , Integer payStatus) {
         if(!v3NumList.isEmpty()){
         if(!v3NumList.isEmpty()){
-            v3NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v3_statusPath,e),payStatus));
+            v3NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v3_statusPath,e),payStatus,e));
         }
         }
         if(!v4NumList.isEmpty()){
         if(!v4NumList.isEmpty()){
-            v4NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v4_statusPath,e),payStatus));
+            v4NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v4_statusPath,e),payStatus,e));
         }
         }
     }
     }
 
 
     /**
     /**
      * 从oss中获取文件,并重写,上传替换
      * 从oss中获取文件,并重写,上传替换
      */
      */
-    @Override
-    public void updateOssStatus(String path,Integer payStatus) {
+    public void updateOssStatus(String path,Integer payStatus,String num) {
+        String localStatusPath = String.format(OssPath.localStatusPath,num);
         try {
         try {
             if(!fYunFileService.fileExist(path)){
             if(!fYunFileService.fileExist(path)){
                 return;
                 return;
@@ -399,13 +399,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             JSONObject jsonObject = JSONObject.parseObject(data);
             JSONObject jsonObject = JSONObject.parseObject(data);
             jsonObject.put("payStatus",payStatus);
             jsonObject.put("payStatus",payStatus);
             String json = JSONUtil.toJsonStr(jsonObject);
             String json = JSONUtil.toJsonStr(jsonObject);
-            FileUtils.writeFile(OssPath.localStatusPath ,json);
-            log.info("updateOssStatus--localPath:{},ossPath:{},payStatus:{}",OssPath.localStatusPath,path,payStatus);
-            fYunFileService.uploadFile(OssPath.localStatusPath,path);
+            FileUtils.writeFile(localStatusPath ,json);
+            log.info("updateOssStatus--localPath:{},ossPath:{},payStatus:{}",localStatusPath,path,payStatus);
+            fYunFileService.uploadFile(localStatusPath,path);
         }catch (Exception e){
         }catch (Exception e){
-            e.printStackTrace();
+            log.info("updateOssStatus--localPath:{},ossPath:{},payStatus:{}",localStatusPath,path,payStatus,e);
         }finally {
         }finally {
-            FileUtil.del(OssPath.localStatusPath);
+            if(new File(localStatusPath).getParentFile().exists()){
+                FileUtil.del( new File(localStatusPath).getParentFile());
+            }
         }
         }
     }
     }