|
@@ -0,0 +1,85 @@
|
|
|
+package cn.cslg.report.service.business;
|
|
|
+
|
|
|
+import cn.cslg.report.common.utils.Response;
|
|
|
+import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
+import cn.cslg.report.entity.InvalidRecord;
|
|
|
+import cn.cslg.report.entity.LitigationHistory;
|
|
|
+import cn.cslg.report.entity.ReportFiles;
|
|
|
+import cn.cslg.report.entity.ReportReferences;
|
|
|
+import cn.cslg.report.entity.asso.AssoReportFile;
|
|
|
+import cn.cslg.report.mapper.ReportFileMapper;
|
|
|
+import cn.cslg.report.mapper.ReportReferencesMapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
+public class ReportReferencesService extends ServiceImpl<ReportReferencesMapper, ReportReferences> {
|
|
|
+ private final ReportFileService reportFileService;
|
|
|
+ private final LoginUtils loginUtils;
|
|
|
+ private final AssoReportFileService assoReportFileService;
|
|
|
+ public String add(ReportReferences reportReferences, List<MultipartFile> files)throws IOException{
|
|
|
+ ReportReferences i = new ReportReferences();
|
|
|
+ i.setReportID(reportReferences.getReportID());
|
|
|
+ i.setCreationTime(new Date());
|
|
|
+ i.setType(reportReferences.getType());
|
|
|
+ i.setFileName(reportReferences.getFileName());
|
|
|
+ i.setFileUrl(reportReferences.getFileUrl());
|
|
|
+ i.setRemark(reportReferences.getRemark());
|
|
|
+ i.setCreationManId(loginUtils.getId());
|
|
|
+ i.setType(reportReferences.getType());
|
|
|
+ i.setReferName(reportReferences.getReferName());
|
|
|
+ i.insert();
|
|
|
+ if (files == null && files.size() != 0) {
|
|
|
+ //将文档上传并返回文件入库的Id
|
|
|
+ List<Integer> fileIds = reportFileService.uploadFiles(files);
|
|
|
+ assoReportFileService.add(reportReferences.getReportID(),fileIds);
|
|
|
+ return Response.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ return Response.error();
|
|
|
+ }
|
|
|
+ public String queryReportReferences(ReportReferences reportReferences)throws IOException{
|
|
|
+ LambdaQueryWrapper<ReportReferences> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(ReportReferences::getReportID,reportReferences.getReportID())
|
|
|
+ .eq(ReportReferences::getRemark,reportReferences.getRemark());
|
|
|
+
|
|
|
+ if(reportReferences.getSize()!=null&&reportReferences.getCurrent()!=null){
|
|
|
+ IPage<ReportReferences> pages = this.page(new Page<>(reportReferences.getCurrent(), reportReferences.getSize()), wrapper);
|
|
|
+ return Response.success(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return Response.success(this.list(wrapper));
|
|
|
+
|
|
|
+ }
|
|
|
+ public String delete(int id)throws IOException{
|
|
|
+
|
|
|
+ this.removeById(id);
|
|
|
+ LambdaQueryWrapper<AssoReportFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(AssoReportFile::getFileId,id);
|
|
|
+
|
|
|
+ assoReportFileService.remove(wrapper);
|
|
|
+ return Response.success();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|