Explorar el Código

实现庭审笔录上传

qitz hace 2 años
padre
commit
5558debc20

+ 16
- 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/CaseEvidenceController.java Ver fichero

@@ -58,6 +58,22 @@ public class CaseEvidenceController extends BaseController {
58 58
         Long userId = this.getUserId();
59 59
         return caseEvidenceService.uploadEvidence(file, annexType, id, username, userId);
60 60
     }
61
+
62
+    /**
63
+     * 上传庭审笔录
64
+     *
65
+     * @param file      附件
66
+     * @param annexType 附件类型,庭审笔录(7)
67
+     * @param id        案件申请id
68
+     * @return
69
+     */
70
+    @PostMapping("/uploadRecord")
71
+    public AjaxResult uploadRecord(@RequestParam("file") MultipartFile file, Integer annexType, Long id) {
72
+        String username = this.getUsername();
73
+        Long userId = this.getUserId();
74
+        return caseEvidenceService.uploadRecord(file, annexType, id, username, userId);
75
+    }
76
+
61 77
     @PostMapping("/batchUpload")
62 78
     public AjaxResult batchUpload(@RequestParam("file") MultipartFile[] file, Integer annexType, Long id) {
63 79
         if(file==null){

+ 2
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/CaseAttachMapper.java Ver fichero

@@ -33,4 +33,6 @@ public interface CaseAttachMapper {
33 33
      * @param annexType
34 34
      */
35 35
     void deleteByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType,@Param("isBatchUpload") int isBatchUpload);
36
+
37
+    void deleteCaseAttachByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType);
36 38
 }

+ 2
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICaseEvidenceService.java Ver fichero

@@ -65,4 +65,6 @@ public interface ICaseEvidenceService {
65 65
      * @return 下拉树结构列表
66 66
      */
67 67
     List<CaseEvidenceDirectoryVO> buildCaseEvidenceTreeSelect(List<CaseEvidenceDirectory> caseEvidenceDirectorys);
68
+
69
+    AjaxResult uploadRecord(MultipartFile file, Integer annexType, Long id, String username, Long userId);
68 70
 }

+ 38
- 0
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseEvidenceServiceImpl.java Ver fichero

@@ -400,6 +400,44 @@ public class CaseEvidenceServiceImpl implements ICaseEvidenceService {
400 400
         return caseEvidenceDirectories.stream().map(CaseEvidenceDirectoryVO::new).collect(Collectors.toList());
401 401
     }
402 402
 
403
+    @Override
404
+    @Transactional
405
+    public AjaxResult uploadRecord(MultipartFile file, Integer annexType, Long id, String username, Long userId) {
406
+        if (file.isEmpty()) {
407
+            return AjaxResult.error("请选择要上传的文件");
408
+        }
409
+        try {
410
+            String filePath = RuoYiConfig.getUploadPath();
411
+            // 上传
412
+            String fileName = FileUploadUtils.upload(filePath, file);
413
+            CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id)
414
+                    .annexName(fileName)
415
+                    .annexPath(filePath)
416
+                    .annexType(annexType)
417
+                    .userId(userId)
418
+                    .userName(username)
419
+                    .build();
420
+
421
+            CaseApplication caseApplicationsel = new CaseApplication();
422
+            caseApplicationsel.setId(id);
423
+            caseApplicationsel.setAnnexType(7);
424
+            List<CaseAttach> caseAttachs = caseAttachMapper.queryCaseAttachList(caseApplicationsel);
425
+            if(caseAttachs!=null&&caseAttachs.size()>0){
426
+                caseAttachMapper.deleteCaseAttachByCasedIdAndType(id,7);
427
+                int count = caseAttachMapper.save(caseAttach);
428
+            }else {
429
+                int count = caseAttachMapper.save(caseAttach);
430
+            }
431
+
432
+            return AjaxResult.success("上传成功");
433
+        } catch (IOException e) {
434
+            e.printStackTrace();
435
+        }
436
+
437
+        return AjaxResult.error("上传失败");
438
+
439
+    }
440
+
403 441
     /**
404 442
      * 递归列表
405 443
      */

+ 6
- 0
ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAttachMapper.xml Ver fichero

@@ -62,6 +62,12 @@
62 62
         </where>
63 63
     </select>
64 64
 
65
+    <delete id="deleteCaseAttachByCasedIdAndType">
66
+        delete from case_attach
67
+        where case_appli_id = #{caseAppliId}
68
+        and annex_type = #{annexType}
69
+    </delete>
70
+
65 71
     <select id="queryCaseAttachList" resultMap="CaseAttachResult">
66 72
         select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
67 73
         from case_attach