ソースを参照

删除不用的文件

Administrator 1 年間 前
コミット
1603aa4193

+ 10 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InvestigateDispositionServiceImpl.java

@@ -24,6 +24,8 @@ import com.ruoyi.common.core.domain.entity.InvestigateDisposition;
 import com.ruoyi.system.service.IInvestigateDispositionService;
 import org.springframework.web.multipart.MultipartFile;
 
+import static com.ruoyi.common.config.RuoYiConfig.getProfile;
+
 /**
  * 考察配置Service业务层处理
  *
@@ -110,7 +112,14 @@ public class InvestigateDispositionServiceImpl implements IInvestigateDispositio
      */
     @Override
     public int updateInvestigateDisposition(InvestigateDisposition investigateDisposition) {
-        //todo 删除原先的文件
+        String url = investigateDisposition.getUrl();
+        String  path=  url.replace("/profile",getProfile());
+        // 删除原先的文件
+        try {
+            Runtime.getRuntime().exec("rm -f "+path);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
         String fileName = getFileName(investigateDisposition);
         investigateDisposition.setUrl(fileName);
         InvestigateDisposition newParentInfo = investigateDispositionMapper.selectInvestigateDispositionById(investigateDisposition.getParentId());

+ 13 - 1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/InvestigateTableServiceImpl.java

@@ -29,6 +29,8 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 
+import static com.ruoyi.common.config.RuoYiConfig.getProfile;
+
 /**
  * 考察主Service业务层处理
  *
@@ -221,7 +223,7 @@ public class InvestigateTableServiceImpl implements IInvestigateTableService {
             investigateUserMapper.batchDispositionUser(investigateUserList);
         }
 
-        //todo 删除服务器文件
+
 
         //删除原先的考察配置与考察主表关联表信息
         investigateDispositionTableMapper.deleteInvestigateDispositionTableByInvestigateTableId(investigateTable.getInvestigateTableId());
@@ -230,6 +232,16 @@ public class InvestigateTableServiceImpl implements IInvestigateTableService {
         List<InvestigateDispositionTable> investigateDispositionTableList = investigateTable.getInvestigateDispositionTableList();
 
         if (investigateDispositionTableList != null && investigateDispositionTableList.size() > 0) {
+            for (InvestigateDispositionTable investigateDispositionTable : investigateDispositionTableList) {
+                String url = investigateDispositionTable.getUrl();
+                String  path=  url.replace("/profile",getProfile());
+                //todo 删除服务器文件
+                try {
+                    Runtime.getRuntime().exec("rm -f "+path);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
             insertInvestigateDispositionTable(investigateDispositionTableList);
         }