瀏覽代碼

12/6update

chenyi 2 年之前
父節點
當前提交
0f2b9dd2cc

+ 11 - 0
RMS/src/main/java/cn/cslg/report/common/model/vo/FileVO.java

@@ -0,0 +1,11 @@
+package cn.cslg.report.common.model.vo;
+
+import lombok.Data;
+
+@Data
+public class FileVO {
+    public Integer reportID;
+    public String name;
+    public int PageSize;
+    public int PageNO;
+}

+ 29 - 4
RMS/src/main/java/cn/cslg/report/controller/ReportController.java

@@ -1,10 +1,14 @@
 package cn.cslg.report.controller;
 
 import cn.cslg.report.common.core.base.Constants;
+import cn.cslg.report.common.model.vo.FileVO;
 import cn.cslg.report.common.model.vo.ReportVO;
 import cn.cslg.report.common.utils.Response;
 import cn.cslg.report.common.utils.StringUtils;
+import cn.cslg.report.entity.InvalidRecord;
+import cn.cslg.report.entity.LitigationHistory;
 import cn.cslg.report.entity.Report;
+import cn.cslg.report.entity.ReportReferences;
 import cn.cslg.report.service.business.*;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.JsonObject;
@@ -13,10 +17,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -31,6 +32,8 @@ public class ReportController {
     private final AssoTaskPersonelService assoTaskPersonelService;
     private final ReportFileService reportFileService;
     private final AssoReportFileService assoReportFileService;
+    private final ReportReferencesService reportReferencesService;
+
 
     /**
      * @param report 报告类
@@ -90,6 +93,28 @@ public class ReportController {
     public String deleReport(Integer id) throws IOException {
         return reportService.reportDele(id);
     }
+    @RequestMapping(value = "/addFile", method = RequestMethod.POST)
+    @Operation(summary = "文件上传")
+    public  String addFile(String jsons, List<MultipartFile> file) throws IOException{
+        ReportReferences reportReferences = JSONObject.parseObject(jsons, ReportReferences.class);
+
+        return reportReferencesService.add(reportReferences,file);
+    }
+    @PostMapping(value = "selectfile")
+    @Operation(summary = "文件查询")
+
+    public String queryLitigationHistory(@RequestBody ReportReferences reportReferences)throws IOException{
+            return reportReferencesService.queryReportReferences(reportReferences);
+
+    }
+    @GetMapping("/deletefile")
+    @Operation(summary = "删除文件")
+    public String deleFile(int id)throws IOException{
+        return reportReferencesService.delete(id);
+    }
+
+
+
 
 
 }

+ 1 - 1
RMS/src/main/java/cn/cslg/report/entity/ReportFiles.java

@@ -48,7 +48,7 @@ public class ReportFiles extends BaseEntity<ReportFiles> {
     private Integer reportId;
 
     @Schema(description = "备注")
-@TableField("REMARK")
+    @TableField("REMARK")
     private String remark;
 
     /**

+ 78 - 0
RMS/src/main/java/cn/cslg/report/entity/ReportReferences.java

@@ -0,0 +1,78 @@
+package cn.cslg.report.entity;
+
+import cn.cslg.report.common.model.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+@TableName(value = "REPORT_REFERENCES")
+public class ReportReferences extends BaseEntity<ReportReferences> {
+    @Schema(description = "报告ID")
+    @TableField(value = "REPORT_ID")
+    private Integer reportID;
+    @Schema(description = "路径")
+    @TableField(value = "FILE_URL")
+    private String fileUrl;
+
+    @Schema(description = "备注")
+    @TableField(value = "REMARK")
+    private String remark;
+
+    @Schema(description = "创建时间")
+    @TableField(value = "CREATION_TIME")
+    private Date creationTime;
+
+    @Schema(description = "创建人id")
+    @TableField(value = "CREATION_MAN_ID")
+    private Integer creationManId;
+
+    @Schema(description = "类型")
+    @TableField(value = "TEPY")
+    private String type;
+
+    @Schema(description = "参考资料名称")
+    @TableField(value = "REFERENCES_NAME")
+    private String referName;
+
+    @Schema(description = "文件名称")
+    @TableField(value = "FILE_NAME")
+    private String fileName;
+    /**
+     * 每页条数
+     */
+    @Schema(description = "每页条数")
+    @TableField(exist = false)
+    private Integer size;
+
+    /**
+     * 当前页数
+     */
+    @Schema(description = "当前页数")
+    @TableField(exist = false)
+    private Integer current;
+
+    /**
+     * 数据总数
+     */
+    @Schema(description = "数据总数")
+    @TableField(exist = false)
+    private Integer total;
+
+    /**
+     * 文件
+     */
+    @TableField(exist = false)
+    private List<ReportFiles> reportFiles;
+
+
+}

+ 2 - 0
RMS/src/main/java/cn/cslg/report/entity/asso/AssoReportFile.java

@@ -29,4 +29,6 @@ public class AssoReportFile extends BaseEntity<AssoReportFile> {
     @TableField(value = "FILE_ID")
     private Integer fileId;
 
+
+
 }

+ 9 - 0
RMS/src/main/java/cn/cslg/report/mapper/ReportReferencesMapper.java

@@ -0,0 +1,9 @@
+package cn.cslg.report.mapper;
+
+import cn.cslg.report.entity.ReportReferences;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface ReportReferencesMapper extends BaseMapper<ReportReferences> {
+}

+ 1 - 1
RMS/src/main/java/cn/cslg/report/service/OutInterfaceService.java

@@ -154,7 +154,7 @@ public class OutInterfaceService {
      * @title 获取部分部门(有权限控制)
      * @description 接口来源:PCS
      */
-    // TODO: 2022/11/2 未开发
+
     public String getPartDepartmentFromPCS() throws IOException {
         OkHttpClient okHttpClient = new OkHttpClient();
         Request request = new Request.Builder()

+ 42 - 1
RMS/src/main/java/cn/cslg/report/service/business/AssoReportFileService.java

@@ -1,6 +1,8 @@
 package cn.cslg.report.service.business;
 
+import cn.cslg.report.common.model.vo.FileVO;
 import cn.cslg.report.common.utils.Response;
+import cn.cslg.report.entity.ReportFiles;
 import cn.cslg.report.entity.asso.AssoReportFile;
 
 import cn.cslg.report.mapper.AssoReportFileMapper;
@@ -10,7 +12,9 @@ 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.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -20,7 +24,7 @@ import java.util.stream.Collectors;
 @RequiredArgsConstructor(onConstructor_ = {@Lazy})
 public class AssoReportFileService extends ServiceImpl<AssoReportFileMapper, AssoReportFile> {
 
-
+    private final ReportFileService reportFileService;
     //添加
     public String addAsso(Integer reportId, List<Integer> fileIds) {
         List<AssoReportFile> assoReportFiles = new ArrayList<>();
@@ -34,12 +38,49 @@ public class AssoReportFileService extends ServiceImpl<AssoReportFileMapper, Ass
            this.saveBatch(assoReportFiles);
         return Response.success();
     }
+    public String add(Integer reportId, List<Integer> fileIds){
+        List<AssoReportFile> assoReportFiles = new ArrayList<>();
+        fileIds.forEach(item -> {
+            AssoReportFile assoReportFile = new AssoReportFile();
+            assoReportFile.setReportId(reportId);
+            assoReportFile.setFileId(item);
+
+            assoReportFile.setFileType(0);
+            assoReportFiles.add(assoReportFile);
+        });
+        this.saveBatch(assoReportFiles);
+        return Response.success();
+    }
+
 
     //根据报告Id查询文件Id
     public List<AssoReportFile> queryFileByReportId(List<Integer> reportIds){
+        if(reportIds.size()==0){
+            List<AssoReportFile> files=new ArrayList<>();
+            return files;
+        }
         LambdaQueryWrapper<AssoReportFile> wrapper =new LambdaQueryWrapper<>();
         wrapper.in(AssoReportFile::getReportId,reportIds);
         List<AssoReportFile> assoReportFiles =this.list(wrapper);
         return assoReportFiles;
     }
+    public String upload(Integer reportID,List<MultipartFile> files)throws IOException{
+        List<Integer> integers = reportFileService.uploadFiles(files);
+        for(Integer integer :integers){
+
+            AssoReportFile assoReportFile = new AssoReportFile();
+            assoReportFile.setReportId(reportID);
+            assoReportFile.setFileId(integer);
+            assoReportFile.setFileType(1);
+            assoReportFile.insert();
+
+        }
+        return Response.success();
+
+    }
+
+
+
+
+
 }

+ 6 - 0
RMS/src/main/java/cn/cslg/report/service/business/ReportFileService.java

@@ -19,6 +19,7 @@ import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -72,5 +73,10 @@ public class ReportFileService extends ServiceImpl<ReportFileMapper, ReportFiles
    List<ReportFiles> file =  this.list(queryWrapper);
    return file;
     }
+//    public List<ReportFiles> getFile(List<Integer> FileIds ,String name)throws IOException{
+//        LambdaQueryWrapper<ReportFiles> queryWrapper =new LambdaQueryWrapper<>();
+//        queryWrapper.in(ReportFiles::getId,FileIds).eq(ReportFiles::getFileName,name);
+//    }
+
 
 }

+ 85 - 0
RMS/src/main/java/cn/cslg/report/service/business/ReportReferencesService.java

@@ -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();
+
+
+
+    }
+
+
+
+}

+ 1 - 1
RMS/src/main/java/cn/cslg/report/service/business/ReportService.java

@@ -111,7 +111,7 @@ public class ReportService extends ServiceImpl<ReportMapper, Report> {
             queryWrapper.eq(Report::getId, reportVO.getReportId());
         }
         queryWrapper.orderByDesc(Report::getId);
-        if (reportVO.getSize() != null && reportVO.getSize() != null) {
+        if (reportVO.getSize() != null && reportVO.getCurrent() != null) {
             List<Report> reports = this.page(new Page<>(reportVO.getCurrent(), reportVO.getSize()), queryWrapper).getRecords();
             reports = this.reportData(reports);
             long count = this.count(queryWrapper);