lyhzzz 4 viikkoa sitten
vanhempi
commit
72aec78521

+ 10 - 0
src/main/java/com/fdkankan/fusion/common/util/UploadToOssUtil.java

@@ -126,6 +126,16 @@ public class UploadToOssUtil {
 		}
 	}
 	public void delete(String objectName){
+		if(StringUtils.isBlank(objectName)){
+			return;
+		}
+		if(objectName.contains(queryPath)){
+			objectName = objectName.replace(queryPath,"");
+		}
+		if(!this.fileExist(objectName)){
+			return;
+		}
+
 		if("local".equals(type)){
 			localToOssUtil.delete(objectName);
 			return ;

+ 17 - 1
src/main/java/com/fdkankan/fusion/controller/CaseFilesController.java

@@ -9,7 +9,9 @@ import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.ResultData;
 import com.fdkankan.fusion.entity.CaseFiles;
 import com.fdkankan.fusion.service.ICaseFilesService;
+import com.fdkankan.fusion.service.ICaseOverviewService;
 import com.fdkankan.fusion.service.ICaseService;
+import com.fdkankan.fusion.service.ICaseTabulationService;
 import com.fdkankan.fusion.service.impl.UploadService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -41,6 +44,10 @@ public class CaseFilesController extends BaseController{
     UploadService uploadService;
     @Value("${spring.profiles.active}")
     private String environment;
+    @Autowired
+    ICaseOverviewService caseOverviewService;
+    @Autowired
+    ICaseTabulationService caseTabulationService;
 
     @GetMapping("/allList")
     public ResultData allList(@RequestParam(required = false) Integer caseId,
@@ -108,15 +115,24 @@ public class CaseFilesController extends BaseController{
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
         CaseFiles caseFiles1 = caseFilesService.getById(caseFiles.getFilesId());
+        if(caseFiles1 == null){
+            return ResultData.ok();
+        }
         caseFilesService.removeById(caseFiles.getFilesId());
 
         //删除认定书,案件修改为未认定
-        if(caseFiles1 != null && caseFiles1.getFilesTypeId() == 4){
+        if(caseFiles1.getFilesTypeId() == 4){
             List<CaseFiles> caseFilesList = caseFilesService.allList(caseFiles1.getCaseId(),caseFiles1.getFilesTypeId());
             if(caseFilesList == null || caseFilesList.size() <=0){
                 caseService.updateIdenTityStatus(caseFiles1.getCaseId(),0);
             }
         }
+        if(caseFiles1.getOverviewId() != null){
+            caseOverviewService.del(caseFiles1.getOverviewId());
+        }
+        if(caseFiles1.getTabulationId() != null){
+            caseTabulationService.delByIds(Arrays.asList(caseFiles1.getTabulationId()));
+        }
         return ResultData.ok();
     }
 

+ 1 - 1
src/main/java/com/fdkankan/fusion/controller/CaseOverviewController.java

@@ -59,7 +59,7 @@ public class CaseOverviewController {
 
     @PostMapping("/del")
     public ResultData del (@RequestBody CaseOverview caseOverview){
-        caseOverviewService.removeById(caseOverview.getId());
+        caseOverviewService.del(caseOverview.getId());
         return ResultData.ok();
     }
 }

+ 3 - 1
src/main/java/com/fdkankan/fusion/controller/CaseTabulationController.java

@@ -7,6 +7,8 @@ import com.fdkankan.fusion.service.ICaseTabulationService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
+
 /**
  * <p>
  *  前端控制器
@@ -50,7 +52,7 @@ public class CaseTabulationController {
 
     @PostMapping("/del")
     public ResultData del (@RequestBody CaseTabulation caseTabulation){
-        caseTabulationService.removeById(caseTabulation.getId());
+        caseTabulationService.delByIds(Arrays.asList(caseTabulation.getId()));
         return ResultData.ok();
     }
 }

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/ICaseOverviewService.java

@@ -16,4 +16,6 @@ import java.util.List;
 public interface ICaseOverviewService extends IService<CaseOverview> {
 
     List<CaseOverview> getByCaseId(String caseId);
+
+    void del(Integer id);
 }

+ 4 - 0
src/main/java/com/fdkankan/fusion/service/ICaseTabulationService.java

@@ -20,4 +20,8 @@ public interface ICaseTabulationService extends IService<CaseTabulation> {
     List<CaseTabulation> getByOverviewId(String overviewId);
 
     void addOrUpdate(CaseTabulation caseTabulation);
+
+    List<CaseTabulation> getByOverId(Integer overviewId);
+
+    void delByIds(List<Integer> collect);
 }

+ 49 - 0
src/main/java/com/fdkankan/fusion/service/impl/CaseOverviewServiceImpl.java

@@ -1,13 +1,21 @@
 package com.fdkankan.fusion.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
 import com.fdkankan.fusion.entity.CaseOverview;
+import com.fdkankan.fusion.entity.CaseTabulation;
+import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.ICaseOverviewMapper;
 import com.fdkankan.fusion.service.ICaseOverviewService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.fusion.service.ICaseTabulationService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -20,6 +28,10 @@ import java.util.List;
 @Service
 public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, CaseOverview> implements ICaseOverviewService {
 
+    @Autowired
+    ICaseTabulationService caseTabulationService;
+    @Autowired
+    UploadToOssUtil uploadToOssUtil;
 
     @Override
     public List<CaseOverview> getByCaseId(String caseId) {
@@ -28,4 +40,41 @@ public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, Ca
         wrapper.orderByDesc(CaseOverview::getId);
         return this.list(wrapper);
     }
+
+    @Override
+    public void del(Integer overviewId) {
+        if(overviewId == null ){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        CaseOverview caseOverview = this.getById(overviewId);
+        if(caseOverview == null){
+            return;
+        }
+        this.removeById(overviewId);
+        this.delFile(caseOverview);
+
+        List<CaseTabulation> caseTabulations = caseTabulationService.getByOverId(overviewId);
+        if(!caseTabulations.isEmpty()){
+            caseTabulationService.delByIds(caseTabulations.stream().map(CaseTabulation::getId).collect(Collectors.toList()));
+        }
+    }
+
+
+    private void delFile(CaseOverview caseOverview) {
+        List<CaseOverview> list = this.getByCover(caseOverview.getListCover());
+        if(list.isEmpty()){
+            uploadToOssUtil.delete(caseOverview.getListCover());
+        }
+
+        List<CaseOverview> list2 = this.getByCover(caseOverview.getKankanCover());
+        if(list2.isEmpty()){
+            uploadToOssUtil.delete(caseOverview.getKankanCover());
+        }
+    }
+
+    private List<CaseOverview> getByCover(String listCover) {
+        LambdaQueryWrapper<CaseOverview> wrapper = new LambdaQueryWrapper<>();
+        wrapper.and(e -> e.eq(CaseOverview::getListCover,listCover).or().eq(CaseOverview::getKankanCover,listCover));
+        return this.list(wrapper);
+    }
 }

+ 45 - 0
src/main/java/com/fdkankan/fusion/service/impl/CaseTabulationServiceImpl.java

@@ -2,6 +2,7 @@ package com.fdkankan.fusion.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
 import com.fdkankan.fusion.entity.CaseFiles;
 import com.fdkankan.fusion.entity.CaseOverview;
 import com.fdkankan.fusion.entity.CaseTabulation;
@@ -15,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -32,6 +34,8 @@ public class CaseTabulationServiceImpl extends ServiceImpl<ICaseTabulationMapper
     ICaseFilesService caseFilesService;
     @Autowired
     ICaseOverviewService caseOverviewService;
+    @Autowired
+    UploadToOssUtil uploadToOssUtil;
 
     @Override
     public List<CaseTabulation> getByCaseId(String caseId) {
@@ -51,6 +55,45 @@ public class CaseTabulationServiceImpl extends ServiceImpl<ICaseTabulationMapper
     }
 
     @Override
+    public List<CaseTabulation> getByOverId(Integer overId) {
+        LambdaQueryWrapper<CaseTabulation> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CaseTabulation::getOverviewId,overId);
+        return this.list(wrapper);
+    }
+
+    @Override
+    public void delByIds(List<Integer> ids) {
+        if(!ids.isEmpty()){
+            List<CaseTabulation> caseTabulations = this.listByIds(ids);
+            this.removeByIds(ids);
+            for (CaseTabulation caseTabulation : caseTabulations) {
+                delFile(caseTabulation);
+            }
+        }
+    }
+
+    private void delFile(CaseTabulation caseTabulation) {
+        List<CaseTabulation> list = this.getByCover(caseTabulation.getListCover());
+        if(list.isEmpty()){
+            uploadToOssUtil.delete(caseTabulation.getListCover());
+        }
+        List<CaseTabulation> list2 = this.getByCover(caseTabulation.getMapUrl());
+        if(list2.isEmpty()){
+            uploadToOssUtil.delete(caseTabulation.getMapUrl());
+        }
+        List<CaseTabulation> list3 = this.getByCover(caseTabulation.getCover());
+        if(list3.isEmpty()){
+            uploadToOssUtil.delete(caseTabulation.getCover());
+        }
+    }
+
+    private List<CaseTabulation> getByCover(String listCover) {
+        LambdaQueryWrapper<CaseTabulation> wrapper = new LambdaQueryWrapper<>();
+        wrapper.and(e -> e.eq(CaseTabulation::getListCover,listCover).or().eq(CaseTabulation::getMapUrl,listCover).or().like(CaseTabulation::getCover,listCover));
+        return this.list(wrapper);
+    }
+
+    @Override
     public void addOrUpdate(CaseTabulation caseTabulation) {
         if(caseTabulation.getId() != null){
             CaseTabulation caseTabulation1 = this.getById(caseTabulation.getId());
@@ -102,5 +145,7 @@ public class CaseTabulationServiceImpl extends ServiceImpl<ICaseTabulationMapper
 
 
 
+
+
     }
 }