Browse Source

批量上传案件证据

18792927508 2 years ago
parent
commit
3f17c3a7ee

+ 25
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java View File

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.web.controller.wisdomarbitrate;
2 2
 
3
+import cn.hutool.core.util.StrUtil;
3 4
 import com.ruoyi.common.core.controller.BaseController;
4 5
 import com.ruoyi.common.core.domain.AjaxResult;
5 6
 import com.ruoyi.common.core.page.TableDataInfo;
@@ -55,6 +56,30 @@ public class CaseEvidenceController extends BaseController {
55 56
         Long userId = this.getUserId();
56 57
         return caseEvidenceService.uploadEvidence(file, annexType, id, username, userId);
57 58
     }
59
+    @PostMapping("/batchUpload")
60
+    public AjaxResult batchUpload(@RequestParam("file") MultipartFile[] file, Integer annexType, Long id) {
61
+        if(file==null){
62
+            return error("请选择要上传的文件");
63
+        }
64
+        String username = this.getUsername();
65
+        Long userId = this.getUserId();
66
+        return caseEvidenceService.batchUpload(file, annexType, id, username, userId);
67
+    }
68
+
69
+    /**
70
+     * 获取附件
71
+     * @param caseAppliId
72
+     * @param annexTypeList
73
+     * @param
74
+     * @return
75
+     */
76
+    @GetMapping("/fileList")
77
+    public AjaxResult fileList(Long caseAppliId, @RequestParam("annexTypeList") List<Integer> annexTypeList){
78
+        if(caseAppliId==null){
79
+            return error("案件id不能为空");
80
+        }
81
+        return caseEvidenceService.fileList(caseAppliId, annexTypeList);
82
+    }
58 83
 
59 84
     /**
60 85
      * 查询当前用户案件列表

+ 13
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseEvidenceService.java View File

@@ -20,4 +20,17 @@ public interface ICaseEvidenceService {
20 20
     AjaxResult evidenceConfirmation(CaseApplication caseApplication);
21 21
 
22 22
     AjaxResult caseCrossexamination(CaseEvidenceDTO caseEvidenceDTO);
23
+
24
+    /**
25
+     * 批量上传文件
26
+     * @param file
27
+     * @param annexType
28
+     * @param id
29
+     * @param username
30
+     * @param userId
31
+     * @return
32
+     */
33
+    AjaxResult batchUpload(MultipartFile[] file, Integer annexType, Long id, String username, Long userId);
34
+
35
+    AjaxResult fileList(Long caseAppliId,  List<Integer> annexTypeList);
23 36
 }

+ 69
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseEvidenceServiceImpl.java View File

@@ -1,5 +1,6 @@
1 1
 package com.ruoyi.wisdomarbitrate.service.impl;
2 2
 
3
+import cn.hutool.core.collection.CollectionUtil;
3 4
 import com.ruoyi.common.config.RuoYiConfig;
4 5
 import com.ruoyi.common.constant.CaseApplicationConstants;
5 6
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -21,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
21 22
 import org.springframework.web.multipart.MultipartFile;
22 23
 
23 24
 import java.io.IOException;
25
+import java.util.ArrayList;
24 26
 import java.util.Arrays;
25 27
 import java.util.List;
26 28
 import java.util.stream.Collectors;
@@ -195,6 +197,73 @@ IdentityAuthenticationMapper identityAuthenticationMapper;
195 197
         }
196 198
         return null;
197 199
     }
200
+    @Transactional
201
+    @Override
202
+    public AjaxResult batchUpload(MultipartFile[] files, Integer annexType, Long id, String userName, Long userId) {
203
+        List<CaseAttach> successList= new ArrayList<>();
204
+        try {
205
+            String filePath = RuoYiConfig.getUploadPath();
206
+            for (MultipartFile file : files) {
207
+                // 上传
208
+                String fileName = FileUploadUtils.upload(filePath, file);
209
+                CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id)
210
+                        .annexName(fileName)
211
+                        .annexPath(filePath)
212
+                        .annexType(annexType)
213
+                        .userId(userId)
214
+                        .userName(userName)
215
+                        .build();
216
+                int count = caseAttachMapper.save(caseAttach);
217
+                if (count > 0 && annexType!=null && annexType!=8) {
218
+                    if(id!=null){
219
+                        //修改案件状态
220
+                        CaseApplication caseApplication = new CaseApplication();
221
+                        caseApplication.setId(id);
222
+                        caseApplication.setCaseStatus(4);
223
+                        caseApplicationMapper.submitCaseApplication(caseApplication);
224
+                    }
225
+                    CaseAttach caseAttachselect = new CaseAttach();
226
+                    caseAttachselect.setAnnexId(caseAttach.getAnnexId());
227
+                    caseAttachselect.setAnnexName(caseAttach.getAnnexName());
228
+                    caseAttachselect.setAnnexType(caseAttach.getAnnexType());
229
+                    successList.add(caseAttachselect);
230
+                }
231
+            }
232
+
233
+
234
+        } catch (IOException e) {
235
+            e.printStackTrace();
236
+            return AjaxResult.error("上传失败");
237
+        }
238
+
239
+        return AjaxResult.success("上传成功",successList);
240
+
241
+    }
242
+
243
+    @Override
244
+    public AjaxResult fileList(Long caseAppliId,  List<Integer> annexTypeList) {
245
+        CaseApplication caseApplication = new CaseApplication();
246
+        caseApplication.setId(caseAppliId);
247
+        caseApplication.setAnnexTypeList(annexTypeList);
248
+        List<CaseAttach> caseAttachList = caseAttachMapper.queryCaseAttachList(caseApplication);
249
+        if(CollectionUtil.isNotEmpty(caseAttachList)){
250
+                for (CaseAttach caseAttach : caseAttachList) {
251
+                    String annexName = caseAttach.getAnnexName();
252
+                    String prefix = "/profile";
253
+                    int startIndex = annexName.indexOf(prefix);
254
+                    startIndex += prefix.length();
255
+                    String annexPath = "/uploadPath" + annexName.substring(startIndex);
256
+                    caseAttach.setAnnexPath(annexPath);
257
+                    int startIndexnew = annexName.lastIndexOf("/");
258
+                    if(startIndexnew!=-1){
259
+                        String annexNamenew  = annexName.substring(startIndexnew+1);
260
+                        caseAttach.setAnnexName(annexNamenew);
261
+                    }
262
+                }
263
+                return AjaxResult.success(caseAttachList);
264
+        }
265
+        return null;
266
+    }
198 267
 
199 268
     private List<CaseEvidenceVO> getCaseEvidenceVOList(String identityNum, List<Integer> caseStatusList, Integer identityType) {
200 269
         List<CaseEvidenceVO> caseListByRespondent = caseEvidenceMapper.getCaseListByRespondent(identityNum, caseStatusList, identityType);