fde5ff67 by 荆蔚杰

上传接口优化.卷内目录查询优化

1 parent ee87ffa5
......@@ -63,7 +63,7 @@ public class DgArchivesCatalogController {
}
@PostMapping("search")
@ApiOperation(value = "根据条件进行列表查询")
@ApiOperation(value = "获取档案目录和不动产信息")
public Result<List<DgArchivesCatalogListVO>> searchDgArchivesCatalogList(@ApiParam("档案标识码集合") @RequestParam List<String> bsmArchives) {
return Result.ok(dgarchivescatalogService.searchDgArchivesCatalogList(bsmArchives));
}
......
package com.pashanhoo.catalog.entity.vo;
import com.pashanhoo.file.entity.DgFileDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "档案目录信息列表对应附件列表VO")
public class DgArchivesCatalogWithFileVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 目录标识码
*/
@ApiModelProperty(name = "bsmCatalog", value = "目录标识码")
private String bsmCatalog;
/**
* 档案标识码
*/
@ApiModelProperty(name = "bsmArchives", value = "档案标识码")
private String bsmArchives;
/**
* 序号
*/
@ApiModelProperty(name = "xh", value = "序号")
private Integer xh;
/**
* 材料编码
*/
@ApiModelProperty(name = "wjbm", value = "材料编码")
private String wjbm;
/**
* 材料名称
*/
@ApiModelProperty(name = "wjmc", value = "材料名称")
private String wjmc;
/**
* 材料类型编码
*/
@ApiModelProperty(name = "cllxbm", value = "材料类型编码")
private String cllxbm;
/**
* 材料类型名称
*/
@ApiModelProperty(name = "cllxmc", value = "材料类型名称")
private String cllxmc;
/**
* 页数
*/
@ApiModelProperty(name = "ys", value = "页数")
private String ys;
/**
* 页号
*/
@ApiModelProperty(name = "yh", value = "页号")
private String yh;
/**
* 份数
*/
@ApiModelProperty(name = "fs", value = "份数")
private String fs;
/**
* 文号
*/
@ApiModelProperty(name = "wh", value = "文号")
private String wh;
/**
* 备注
*/
@ApiModelProperty(name = "bz", value = "备注")
private String bz;
/**
* 附件对象集合
*/
@ApiModelProperty(name = "dgFileDOS", value = "附件对象集合")
private List<DgFileDO> dgFileDOS;
}
package com.pashanhoo.common.util.fileupload;
import com.pashanhoo.file.entity.vo.FileAttribute;
import io.minio.MinioClient;
import io.minio.errors.*;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -38,7 +39,7 @@ public class MinioUtil {
* @return minio文件路径
* @throws IOException
*/
public String upload(MultipartFile file) throws IOException {
public FileAttribute upload(MultipartFile file) throws IOException {
Assert.notNull(file, "上传文件为空");
// 上传地址
String savePath = FileAttachmentUtil.getSavePath(UUID.randomUUID().toString());
......@@ -60,8 +61,12 @@ public class MinioUtil {
} catch (Exception e) {
e.printStackTrace();
}
return saveUrl;
FileAttribute fileAttribute = new FileAttribute();
fileAttribute.setFileName(fileName);
fileAttribute.setFileSize(Long.toString(file.getSize()));
fileAttribute.setSaveUrl(saveUrl);
fileAttribute.setPreviewUrl(pUrl);
return fileAttribute;
}
/**
......@@ -71,12 +76,12 @@ public class MinioUtil {
* @return
* @throws IOException
*/
public List<String> batchUpload(MultipartFile[] files) throws IOException {
public List<FileAttribute> batchUpload(MultipartFile[] files) throws IOException {
Assert.notNull(files, "上传文件为空");
List<String> list = new ArrayList<>();
List<FileAttribute> list = new ArrayList<>();
for (MultipartFile file : files) {
String saveUrl = this.upload(file);
list.add(saveUrl);
FileAttribute result = this.upload(file);
list.add(result);
}
return list;
}
......
......@@ -38,7 +38,19 @@ public class SysDictController {
@GetMapping("getSysDictByTypeId")
public Result<List<SysDict>> getSysDictByTypeId(@ApiParam("类型ID") @RequestParam String typeId) {
List<SysDict> dicts = sysDictService.getSysDictByTypeId(typeId);
TreeUtil.setRule((o1, o2) -> 0, SysDict.class,"DictId");
// TreeUtil.setRule((o1, o2) -> 0, SysDict.class,"DictId");
TreeUtil.setRule(new Comparator<SysDict>() {
@Override
public int compare(SysDict o1, SysDict o2) {
if (o1.getSort() == null) {
o1.setSort((short) 0);
}
if (o2.getSort() == null) {
o2.setSort((short) 0);
}
return o1.getSort() - o2.getSort();
}
},SysDict.class,"DictId");
List<SysDict> tree = TreeUtil.listToTree(dicts, typeId);
return Result.ok(tree);
}
......
package com.pashanhoo.file.controller;
import com.pashanhoo.catalog.entity.vo.DgArchivesCatalogWithFileVO;
import com.pashanhoo.common.Result;
import com.pashanhoo.file.entity.vo.AddDgFileRequest;
import com.pashanhoo.file.entity.vo.DgFileListVO;
......@@ -32,7 +33,7 @@ public class DgFileController {
@PostMapping("insertDgFile")
@ApiOperation("新增档案文件信息")
public Result insertDgFile(@RequestBody AddDgFileRequest request){
public Result insertDgFile(@RequestBody List<AddDgFileRequest> request){
if(dgfileService.insertDgFile(request)){
return Result.ok();
}
......@@ -64,8 +65,8 @@ public class DgFileController {
}
@PostMapping("search")
@ApiOperation(value = "根据条件进行列表查询")
public Result<List<DgFileListVO>> searchDgFileList(@RequestBody DgFileSearchRequest request) {
@ApiOperation(value = "查询档案目录和对应的附件")
public Result<List<DgArchivesCatalogWithFileVO>> searchDgFileList(@RequestBody DgFileSearchRequest request) {
return Result.ok(dgfileService.searchDgFileList(request));
}
......
......@@ -23,4 +23,6 @@ public interface DgFileConverter{
DgFileListVO do2ListVO(DgFileDO dgfileDO);
List<DgFileListVO> doList2ListVOList(List<DgFileDO> dgfileDOList);
List<DgFileDO> voList2ListDO(List<AddDgFileRequest> addDgFileRequestList);
}
......
package com.pashanhoo.file.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="文件上传实体")
public class FileAttribute implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 文件名
*/
@ApiModelProperty(name = "fileName", value = "文件名")
private String fileName;
/**
* 文件大小
*/
@ApiModelProperty(name = "fileSize", value = "文件大小")
private String fileSize;
/**
* 文件存储url
*/
@ApiModelProperty(name = "saveUrl", value = "文件url")
private String saveUrl;
/**
* 下载URL
*/
@ApiModelProperty(name = "previewUrl", value = "下载URL")
private String previewUrl;
/**
* 扩展名
*/
@ApiModelProperty(name = "expandName", value = "扩展名")
private String expandName;
}
......@@ -2,6 +2,7 @@ package com.pashanhoo.file.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pashanhoo.catalog.entity.vo.DgArchivesCatalogWithFileVO;
import com.pashanhoo.file.entity.DgFileDO;
import com.pashanhoo.file.entity.vo.DgFileListVO;
import com.pashanhoo.file.entity.vo.DgFileSearchRequest;
......@@ -24,5 +25,5 @@ public interface DgFileMapper extends BaseMapper<DgFileDO> {
* @param request
* @return
*/
List<DgFileListVO> selectFileWithNameAndSort(@Param("request") DgFileSearchRequest request);
List<DgArchivesCatalogWithFileVO> selectCatalogWithFile(@Param("request") DgFileSearchRequest request);
}
......
......@@ -2,6 +2,7 @@ package com.pashanhoo.file.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pashanhoo.catalog.entity.vo.DgArchivesCatalogWithFileVO;
import com.pashanhoo.file.entity.DgFileDO;
import com.pashanhoo.file.entity.vo.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -22,7 +23,7 @@ public interface DgFileService extends IService<DgFileDO> {
* @param request
* @return
*/
boolean insertDgFile(AddDgFileRequest request);
boolean insertDgFile(List<AddDgFileRequest> request);
/**
* 根据主键查询记录详情
......@@ -43,5 +44,5 @@ public interface DgFileService extends IService<DgFileDO> {
* @param request
* @return
*/
List<DgFileListVO> searchDgFileList(DgFileSearchRequest request);
List<DgArchivesCatalogWithFileVO> searchDgFileList(DgFileSearchRequest request);
}
......
package com.pashanhoo.file.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pashanhoo.catalog.entity.vo.DgArchivesCatalogWithFileVO;
import com.pashanhoo.common.util.fileupload.MinioUtil;
import com.pashanhoo.file.entity.DgFileConverter;
import com.pashanhoo.file.entity.DgFileDO;
......@@ -10,7 +11,6 @@ import com.pashanhoo.file.service.DgFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
......@@ -40,9 +40,9 @@ public class DgFileServiceImpl extends ServiceImpl<DgFileMapper, DgFileDO> imple
* @return
*/
@Override
public boolean insertDgFile(AddDgFileRequest request) {
DgFileDO dgfileDO = dgfileConverter.addRequest2DO(request);
return this.save(dgfileDO);
public boolean insertDgFile(List<AddDgFileRequest> request) {
List<DgFileDO> dgFileDOS = dgfileConverter.voList2ListDO(request);
return this.saveBatch(dgFileDOS);
}
/**
......@@ -53,7 +53,10 @@ public class DgFileServiceImpl extends ServiceImpl<DgFileMapper, DgFileDO> imple
@Override
public DgFileDetailVO getDgFileDetailById(String id) {
DgFileDO dgfileDO = this.getById(id);
return dgfileConverter.do2DetailVO(dgfileDO);
DgFileDetailVO dgFileDetailVO = dgfileConverter.do2DetailVO(dgfileDO);
String previewUrl = minioUtil.getPreviewUrl(dgFileDetailVO.getFjurl());
dgFileDetailVO.setFjurl(previewUrl);
return dgFileDetailVO;
}
/**
......@@ -73,14 +76,16 @@ public class DgFileServiceImpl extends ServiceImpl<DgFileMapper, DgFileDO> imple
* @return
*/
@Override
public List<DgFileListVO> searchDgFileList(DgFileSearchRequest request) {
public List<DgArchivesCatalogWithFileVO> searchDgFileList(DgFileSearchRequest request) {
List<DgFileListVO> fileListVOS = dgfileMapper.selectFileWithNameAndSort(request);
List<DgArchivesCatalogWithFileVO> fileListVOS = dgfileMapper.selectCatalogWithFile(request);
for (DgFileListVO fileListVO : fileListVOS) {
if (fileListVO.getFjurl() != null) {
String previewUrl = minioUtil.getPreviewUrl(fileListVO.getFjurl());
fileListVO.setFjurl(previewUrl);
for (DgArchivesCatalogWithFileVO fileListVO : fileListVOS) {
for (DgFileDO dgFileDO : fileListVO.getDgFileDOS()) {
if (dgFileDO.getFjurl() != null) {
String previewUrl = minioUtil.getPreviewUrl(dgFileDO.getFjurl());
dgFileDO.setFjurl(previewUrl);
}
}
}
return fileListVOS;
......
......@@ -23,8 +23,32 @@
FJSIZE
</sql>
<select id="selectFileWithNameAndSort" resultType="com.pashanhoo.file.entity.vo.DgFileListVO">
select DF.*, DAC.WJMC, DAC.XH
<resultMap id="CatalogWithFile" type="com.pashanhoo.catalog.entity.vo.DgArchivesCatalogWithFileVO">
<result column="bsm_catalog" property="bsmCatalog"/>
<result column="bsm_archives" property="bsmArchives"/>
<result column="xh" property="xh"/>
<result column="wjbm" property="wjbm"/>
<result column="wjmc" property="wjmc"/>
<result column="cllxbm" property="cllxbm"/>
<result column="cllxmc" property="cllxmc"/>
<result column="ys" property="ys"/>
<result column="yh" property="yh"/>
<result column="fs" property="fs"/>
<result column="wh" property="wh"/>
<result column="bz" property="bz"/>
<collection property="dgFileDOS" ofType="com.pashanhoo.file.entity.DgFileDO">
<result column="BSM_FILE" property="bsmFile"/>
<result column="DF_BSM_CATALOG" property="bsmCatalog"/>
<result column="KZM" property="kzm"/>
<result column="SCRQ" property="scrq"/>
<result column="SCR" property="scr"/>
<result column="FJURL" property="fjurl"/>
<result column="FJSIZE" property="fjsize"/>
</collection>
</resultMap>
<select id="selectCatalogWithFile" resultMap="CatalogWithFile">
select DAC.*, DF.BSM_FILE as BSM_FILE, DF.BSM_CATALOG as DF_BSM_CATALOG, DF.KZM as KZM,DF.SCRQ as SCRQ,DF.SCR as SCR,DF.FJURL as FJURL,DF.FJSIZE as FJSIZE
from DG_FILE DF
left join DG_ARCHIVES_CATALOG DAC on DAC.BSM_CATALOG =
DF.BSM_CATALOG
......@@ -33,6 +57,6 @@
BSM_ARCHIVES = #{request.bsmArchives,jdbcType=VARCHAR}
</if>
</where>
order by XH;
order by XH
</select>
</mapper>
......