ソースを参照

1.查询当前文件下有多少图片数量,根据原型进行修改 2.多图片上传接口

yuhongqi 1 ヶ月 前
コミット
295f6eba25

+ 4 - 0
fs-service/src/main/java/com/fs/his/domain/FsAttachment.java

@@ -1,5 +1,6 @@
 package com.fs.his.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fs.common.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
@@ -51,5 +52,8 @@ public class FsAttachment extends BaseEntity{
     @ApiModelProperty(value = "文件:oss地址 体检报告:报告id")
     private String url;
 
+    @TableField(exist = false)
+    private Long picCount;
+
 
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/mapper/FsAttachmentMapper.java

@@ -1,9 +1,11 @@
 package com.fs.his.mapper;
 
+import java.util.HashMap;
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.fs.his.domain.FsAttachment;
 import com.fs.his.param.FsAttachmentPageParam;
+import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 
 /**
@@ -66,4 +68,7 @@ public interface FsAttachmentMapper extends BaseMapper<FsAttachment>{
     FsAttachment selectFsAttachmentByFolderName(@Param("folderName") String folderName);
 
     int deleteFsAttachmentByReportId(@Param("reportId")Long reportId);
+
+    @MapKey("attachment_id")
+    HashMap<Long, HashMap<String, Long>> selectPicCount(@Param("filedIds")List<Long> filedIds);
 }

+ 61 - 0
fs-service/src/main/java/com/fs/his/param/FsAttachmentList.java

@@ -0,0 +1,61 @@
+package com.fs.his.param;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 附件管理对象 fs_attachment
+ *
+ * @author fs
+ * @date 2025-08-23
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FsAttachmentList extends BaseEntity{
+
+    @TableId
+    @ApiModelProperty(value = "附件id")
+    private Long attachmentId;
+
+    /** 父id */
+    @Excel(name = "父id")
+    @ApiModelProperty(value = "父id")
+    private Long parentId;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    @ApiModelProperty(value = "用户id")
+    private Long userId;
+
+    /** 文件类型 0:文件夹 1图片 */
+    @Excel(name = "文件类型 0:文件夹 1图片 2体检报告")
+    @ApiModelProperty(value = "文件类型 0:文件夹 1图片 2体检报告")
+    private Integer type;
+
+    /** 文件大小(kb) */
+    @Excel(name = "文件大小(kb)")
+    @ApiModelProperty(value = "文件大小(kb)")
+    private Long size;
+
+    /** 文件名 */
+    @Excel(name = "文件名")
+    @ApiModelProperty(value = "文件名")
+    private String fileName;
+
+    /** oss路径 */
+    @Excel(name = "oss路径")
+    @ApiModelProperty(value = "文件:oss地址 体检报告:报告id")
+    private List<String> urlList;
+
+    @TableField(exist = false)
+    private Long picCount;
+
+
+}

+ 12 - 4
fs-service/src/main/java/com/fs/his/service/impl/FsAttachmentServiceImpl.java

@@ -1,9 +1,7 @@
 package com.fs.his.service.impl;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
 
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
@@ -55,9 +53,19 @@ public class FsAttachmentServiceImpl extends ServiceImpl<FsAttachmentMapper, FsA
     @Override
     public List<FsAttachment> selectFsAttachmentList(FsAttachmentPageParam fsAttachment) {
         List<FsAttachment> list = baseMapper.selectFsAttachmentListPage(fsAttachment);
+        List<Long> filedIds = list.stream().filter(item -> item.getType() == 0).map(FsAttachment::getAttachmentId).collect(Collectors.toList());
+        // 如果当前目录有文件夹 查询当前文件夹里面有多少文件
+        HashMap<Long, HashMap<String, Long>> map = new HashMap<>();
+        if (!filedIds.isEmpty()) {
+            map = baseMapper.selectPicCount(filedIds);
+        }
+
         //查询文件夹大小
         for (FsAttachment attachment : list) {
             long size = 0;
+            if (attachment.getType() == 0 && map.containsKey(attachment.getAttachmentId())) {
+                attachment.setPicCount(map.get(attachment.getAttachmentId()).get("pic_count"));
+            }
             if (attachment.getType() == 0){
                 FsAttachment queryParam = new FsAttachment();
                 queryParam.setParentId(attachment.getAttachmentId());

+ 16 - 0
fs-service/src/main/resources/mapper/his/FsAttachmentMapper.xml

@@ -103,4 +103,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <delete id="deleteFsAttachmentByReportId">
         delete from fs_attachment where url like #{reportId} and type = 2
     </delete>
+
+    <select id="selectPicCount" resultType="java.util.HashMap" parameterType="List">
+        SELECT
+            parent_id as attachment_id,
+            COUNT(*) AS pic_count
+        FROM
+        fs_attachment
+        WHERE
+        parent_id IN
+        <foreach collection="filedIds" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+        AND type = 1
+        GROUP BY
+        parent_id
+    </select>
 </mapper>

+ 25 - 0
fs-user-app/src/main/java/com/fs/app/controller/AttachmentController.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.fs.app.annotation.Login;
 import com.fs.common.core.domain.R;
+import com.fs.his.param.FsAttachmentList;
 import com.fs.his.param.FsAttachmentPageParam;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -74,6 +75,30 @@ public class AttachmentController extends AppBaseController
         return fsAttachmentService.insertFsAttachment(fsAttachment);
     }
 
+    /**
+     * 新增附件管理
+     */
+    @PostMapping("/addList")
+    @Login
+    @ApiOperation("新增附件管理")
+    public R addList(@RequestBody FsAttachmentList fsAttachment)
+    {
+
+        String userId = getUserId();
+        List<String> urlList = fsAttachment.getUrlList();
+        if(urlList == null || urlList.isEmpty()) return R.error("请选择文件");
+        FsAttachment insertEntity;
+        for (String s : urlList) {
+            insertEntity = new FsAttachment();
+            insertEntity.setUserId(Long.parseLong(userId));
+            insertEntity.setUrl(s);
+            insertEntity.setType(fsAttachment.getType());
+            insertEntity.setParentId(fsAttachment.getParentId());
+            fsAttachmentService.insertFsAttachment(insertEntity);
+        }
+        return R.ok();
+    }
+
     /**
      * 修改附件管理
      */