实现庭审笔录上传 #300

Merged
qtz merged 2 commits from qtz3 into dev 2023-12-12 03:56:05 +00:00
5 changed files with 64 additions and 0 deletions
@@ -58,6 +58,22 @@ public class CaseEvidenceController extends BaseController {
Long userId = this.getUserId();
return caseEvidenceService.uploadEvidence(file, annexType, id, username, userId);
}
/**
* 上传庭审笔录
*
* @param file 附件
* @param annexType 附件类型,庭审笔录(7)
* @param id 案件申请id
* @return
*/
@PostMapping("/uploadRecord")
public AjaxResult uploadRecord(@RequestParam("file") MultipartFile file, Integer annexType, Long id) {
String username = this.getUsername();
Long userId = this.getUserId();
return caseEvidenceService.uploadRecord(file, annexType, id, username, userId);
}
@PostMapping("/batchUpload")
public AjaxResult batchUpload(@RequestParam("file") MultipartFile[] file, Integer annexType, Long id) {
if(file==null){
@@ -33,4 +33,6 @@ public interface CaseAttachMapper {
* @param annexType
*/
void deleteByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType,@Param("isBatchUpload") int isBatchUpload);
void deleteCaseAttachByCasedIdAndType(@Param("caseAppliId")Long caseAppliId,@Param("annexType") int annexType);
}
@@ -65,4 +65,6 @@ public interface ICaseEvidenceService {
* @return 下拉树结构列表
*/
List<CaseEvidenceDirectoryVO> buildCaseEvidenceTreeSelect(List<CaseEvidenceDirectory> caseEvidenceDirectorys);
AjaxResult uploadRecord(MultipartFile file, Integer annexType, Long id, String username, Long userId);
}
@@ -400,6 +400,44 @@ public class CaseEvidenceServiceImpl implements ICaseEvidenceService {
return caseEvidenceDirectories.stream().map(CaseEvidenceDirectoryVO::new).collect(Collectors.toList());
}
@Override
@Transactional
public AjaxResult uploadRecord(MultipartFile file, Integer annexType, Long id, String username, Long userId) {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
}
try {
String filePath = RuoYiConfig.getUploadPath();
// 上传
String fileName = FileUploadUtils.upload(filePath, file);
CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id)
.annexName(fileName)
.annexPath(filePath)
.annexType(annexType)
.userId(userId)
.userName(username)
.build();
CaseApplication caseApplicationsel = new CaseApplication();
caseApplicationsel.setId(id);
caseApplicationsel.setAnnexType(7);
List<CaseAttach> caseAttachs = caseAttachMapper.queryCaseAttachList(caseApplicationsel);
if(caseAttachs!=null&&caseAttachs.size()>0){
caseAttachMapper.deleteCaseAttachByCasedIdAndType(id,7);
int count = caseAttachMapper.save(caseAttach);
}else {
int count = caseAttachMapper.save(caseAttach);
}
return AjaxResult.success("上传成功");
} catch (IOException e) {
e.printStackTrace();
}
return AjaxResult.error("上传失败");
}
/**
* 递归列表
*/
@@ -62,6 +62,12 @@
</where>
</select>
<delete id="deleteCaseAttachByCasedIdAndType">
delete from case_attach
where case_appli_id = #{caseAppliId}
and annex_type = #{annexType}
</delete>
<select id="queryCaseAttachList" resultMap="CaseAttachResult">
select annex_id,case_appli_id,annex_name,annex_path,annex_type,note,use_id,use_account
from case_attach