refactor(文档拆分): 重构文档拆分、列表页、更改权限、删除
This commit is contained in:
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.jero.common.api.vo.Result;
|
||||||
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
|
import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||||
|
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
|
||||||
|
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.ss.formula.functions.T;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: yjz
|
||||||
|
* @Date: 2023/10/12/23:03
|
||||||
|
* @Description: 文档拆分
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Api(tags="文档拆分")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/laws/DocumentTool/documentSplit")
|
||||||
|
@Slf4j
|
||||||
|
public class DocumentSplitController {
|
||||||
|
private final IDocumentSplitService documentSplitService;
|
||||||
|
private final ISarFileSplitInfoService sarFileSplitInfoService;
|
||||||
|
|
||||||
|
public DocumentSplitController(IDocumentSplitService documentSplitService,
|
||||||
|
@Lazy ISarFileSplitInfoService sarFileSplitInfoService){
|
||||||
|
this.documentSplitService = documentSplitService;
|
||||||
|
this.sarFileSplitInfoService = sarFileSplitInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页列表查询
|
||||||
|
*
|
||||||
|
* @return Result<IPage<DocumentSplitInfo>>
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "文档拆分-分页列表查询")
|
||||||
|
@ApiOperation(value="文档拆分-分页列表查询", notes="文档拆分-分页列表查询")
|
||||||
|
@GetMapping(value = "/queryByPage")
|
||||||
|
public Result<IPage<DocumentSplitInfo>> queryByPage(DocumentSplitInfo documentSplitInfo,
|
||||||
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||||
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||||
|
return Result.OK(documentSplitService.queryByPage(documentSplitInfo, pageNo, pageSize));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改权限
|
||||||
|
*
|
||||||
|
* @param documentSplitInfo
|
||||||
|
* @return Result<T>
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "文档拆分-更改权限")
|
||||||
|
@ApiOperation(value="文档拆分-更改权限", notes="文档拆分-更改权限")
|
||||||
|
@PostMapping(value = "/updatePermissions")
|
||||||
|
public Result<T> updatePermissions(@Validated @RequestBody DocumentSplitInfo documentSplitInfo) {
|
||||||
|
documentSplitService.updatePermissions(documentSplitInfo);
|
||||||
|
return Result.OK("操作成功!");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 通过id删除
|
||||||
|
*
|
||||||
|
* @return Result<T>
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "文档拆分-通过id删除Y")
|
||||||
|
@ApiOperation(value="文档拆分-通过id删除", notes="文档拆分-通过id删除")
|
||||||
|
@PostMapping(value = "/delete")
|
||||||
|
public Result<T> delete(@RequestParam(name="id",required=true) String id) {
|
||||||
|
sarFileSplitInfoService.deleteById(id);
|
||||||
|
return Result.OK("删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*
|
||||||
|
* @return Result<T>
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "文档拆分-批量删除Y")
|
||||||
|
@ApiOperation(value="文档拆分-批量删除", notes="文档拆分-批量删除")
|
||||||
|
@PostMapping(value = "/deleteBatch")
|
||||||
|
public Result<T> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||||
|
this.sarFileSplitInfoService.deleteByIds(Arrays.asList(ids.split(",")));
|
||||||
|
return Result.OK("批量删除成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: Entity基类
|
||||||
|
* @Author: yjz
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class BaseEntity implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private java.lang.String id;
|
||||||
|
/** 创建人 */
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
// @Excel(name = "创建人", width = 15)
|
||||||
|
private java.lang.String createBy;
|
||||||
|
/** 创建时间 */
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
// @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private java.util.Date createTime;
|
||||||
|
/** 更新人 */
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
// @Excel(name = "更新人", width = 15)
|
||||||
|
private java.lang.String updateBy;
|
||||||
|
/** 更新时间 */
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
// @Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private java.util.Date updateTime;
|
||||||
|
/** 逻辑删除 */
|
||||||
|
@TableLogic
|
||||||
|
private Integer delFlag;
|
||||||
|
}
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.jero.common.aspect.annotation.Dict;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: yjz
|
||||||
|
* @Date: 2023/10/12/23:03
|
||||||
|
* @Description: 文档拆分
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class DocumentSplitInfo extends BaseEntity{
|
||||||
|
/**标准号*/
|
||||||
|
@Excel(name = "标准号", width = 15)
|
||||||
|
@ApiModelProperty(value = "标准号")
|
||||||
|
private String serialNumber;
|
||||||
|
|
||||||
|
/**标准名称*/
|
||||||
|
@Excel(name = "标准名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "标准名称")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**文件状态*/
|
||||||
|
@Excel(name = "文件状态", width = 15, dicCode = "file_type")
|
||||||
|
@Dict(dicCode = "process_manuscript")
|
||||||
|
private String fileType;
|
||||||
|
|
||||||
|
/**文件名称*/
|
||||||
|
@Excel(name = "文件名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "文件名称")
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
/**拆分状态(1:编辑中 2:已发布)*/
|
||||||
|
@Excel(name = "拆分状态", width = 15)
|
||||||
|
@ApiModelProperty(value = "拆分状态(1:编辑中 2:已发布)")
|
||||||
|
@Dict(dicCode = "split_status")
|
||||||
|
private String splitStatus;
|
||||||
|
|
||||||
|
/**编辑人*/
|
||||||
|
@Excel(name = "编辑人", width = 15)
|
||||||
|
@ApiModelProperty(value = "编辑人")
|
||||||
|
private String author;
|
||||||
|
|
||||||
|
// 拆分时间 父类createTime
|
||||||
|
|
||||||
|
/**拆分结果*/
|
||||||
|
@Excel(name = "拆分结果", width = 15)
|
||||||
|
private String splitResult;
|
||||||
|
|
||||||
|
/**文件id*/
|
||||||
|
@Excel(name = "文件id", width = 15)
|
||||||
|
@ApiModelProperty(value = "文件id")
|
||||||
|
private String fileId;
|
||||||
|
|
||||||
|
/**文档库关联id*/
|
||||||
|
@Excel(name = "文档库关联id", width = 15)
|
||||||
|
@ApiModelProperty(value = "文档库关联id")
|
||||||
|
private String connectId;
|
||||||
|
|
||||||
|
/**标准关联id*/
|
||||||
|
@Excel(name = "标准关联id", width = 15)
|
||||||
|
@ApiModelProperty(value = "标准关联id")
|
||||||
|
private String standardId;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String cut;
|
||||||
|
|
||||||
|
/**ids 搜索用*/
|
||||||
|
@ApiModelProperty(value = "标ids 搜索用")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String ids;
|
||||||
|
|
||||||
|
/**标准编号/标准名称 搜索用*/
|
||||||
|
@ApiModelProperty(value = "标准编号/标准名称 搜索用")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String serialNumberOrName;
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||||
|
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: yjz
|
||||||
|
* @Date: 2023/10/12/23:03
|
||||||
|
* @Description: 文档拆分
|
||||||
|
*/
|
||||||
|
public interface DocumentSplitMapper {
|
||||||
|
/**
|
||||||
|
* 文档拆分-分页列表查询
|
||||||
|
* @param page
|
||||||
|
* @param queryWrapper
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<DocumentSplitInfo> queryByPage(Page<SarFileSplitInfoEO> page, @Param(Constants.WRAPPER) QueryWrapper<SarFileSplitInfoEO> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档拆分-列表查询
|
||||||
|
* @param queryWrapper
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DocumentSplitInfo> queryByPage(@Param(Constants.WRAPPER) QueryWrapper<SarFileSplitInfoEO> queryWrapper);
|
||||||
|
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper">
|
||||||
|
|
||||||
|
<select id="queryByPage" resultType="com.jero.modules.laws.documenttool.entity.DocumentSplitInfo">
|
||||||
|
select *
|
||||||
|
from (select i.id as id,
|
||||||
|
serial_number,
|
||||||
|
(IF(length(s.standard_name) > 0, s.standard_name, d.standard_name)) title,
|
||||||
|
file_type,
|
||||||
|
file_name,
|
||||||
|
split_status,
|
||||||
|
concat(u.realname, '(', u.username, ')') as author,
|
||||||
|
i.create_time,
|
||||||
|
i.split_result,
|
||||||
|
i.create_by,
|
||||||
|
i.standard_id,
|
||||||
|
i.del_flag,
|
||||||
|
file_id,
|
||||||
|
u.username as username
|
||||||
|
from sar_file_split_info i
|
||||||
|
left join laws_domestic_standard s on i.standard_id = s.id and s.del_flag = 0
|
||||||
|
left join laws_enterprise_standard d on i.standard_id = d.id and d.del_flag = 0
|
||||||
|
left join sys_user u on i.author = u.id) t
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: yjz
|
||||||
|
* @Date: 2023/10/12/23:03
|
||||||
|
* @Description: 文档拆分
|
||||||
|
*/
|
||||||
|
public interface IDocumentSplitService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档拆分-分页列表查询
|
||||||
|
* @param documentSplitInfo
|
||||||
|
* @param pageNo
|
||||||
|
* @param pageSize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<DocumentSplitInfo> queryByPage(DocumentSplitInfo documentSplitInfo, Integer pageNo, Integer pageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档拆分-列表查询
|
||||||
|
* @param documentSplitInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DocumentSplitInfo> queryByList(DocumentSplitInfo documentSplitInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改权限
|
||||||
|
* @param documentSplitInfo
|
||||||
|
*/
|
||||||
|
void updatePermissions(DocumentSplitInfo documentSplitInfo);
|
||||||
|
}
|
||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
package com.jero.modules.laws.documenttool.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||||
|
import com.jero.modules.laws.documenttool.mapper.DocumentSplitMapper;
|
||||||
|
import com.jero.modules.laws.documenttool.service.IDocumentSplitService;
|
||||||
|
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||||
|
import com.jero.modules.split.service.ISarFileSplitInfoService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: yjz
|
||||||
|
* @Date: 2023/10/12/23:03
|
||||||
|
* @Description: 文档拆分
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||||
|
private final DocumentSplitMapper documentSplitMapper;
|
||||||
|
private final ISarFileSplitInfoService sarFileSplitInfoService;
|
||||||
|
|
||||||
|
public DocumentSplitServiceImpl(DocumentSplitMapper documentSplitMapper,
|
||||||
|
ISarFileSplitInfoService sarFileSplitInfoService) {
|
||||||
|
this.documentSplitMapper = documentSplitMapper;
|
||||||
|
this.sarFileSplitInfoService = sarFileSplitInfoService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<DocumentSplitInfo> queryByPage(DocumentSplitInfo documentSplitInfo, Integer pageNo, Integer pageSize) {
|
||||||
|
// 构建查询条件
|
||||||
|
QueryWrapper<SarFileSplitInfoEO> queryWrapper = getSarFileSplitInfoEOQueryWrapper(documentSplitInfo);
|
||||||
|
return documentSplitMapper.queryByPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DocumentSplitInfo> queryByList(DocumentSplitInfo documentSplitInfo) {
|
||||||
|
// 构建查询条件
|
||||||
|
QueryWrapper<SarFileSplitInfoEO> queryWrapper = getSarFileSplitInfoEOQueryWrapper(documentSplitInfo);
|
||||||
|
return documentSplitMapper.queryByPage(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updatePermissions(DocumentSplitInfo documentSplitInfo) {
|
||||||
|
LambdaUpdateWrapper<SarFileSplitInfoEO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
List<String> ids;
|
||||||
|
// 获取id集合
|
||||||
|
if (StringUtils.isNotBlank(documentSplitInfo.getIds())){
|
||||||
|
ids = Arrays.asList(documentSplitInfo.getIds().split(","));
|
||||||
|
}else {
|
||||||
|
List<DocumentSplitInfo> documentSplitInfos = queryByList(documentSplitInfo);
|
||||||
|
ids = documentSplitInfos.stream().map(DocumentSplitInfo::getId).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
updateWrapper.in(SarFileSplitInfoEO::getId, ids);
|
||||||
|
updateWrapper.set(SarFileSplitInfoEO::getCreateBy, documentSplitInfo.getCreateBy());
|
||||||
|
sarFileSplitInfoService.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static QueryWrapper<SarFileSplitInfoEO> getSarFileSplitInfoEOQueryWrapper(DocumentSplitInfo documentSplitInfo) {
|
||||||
|
QueryWrapper<SarFileSplitInfoEO> queryWrapper = new QueryWrapper<>();
|
||||||
|
// 标准编号/标准名称
|
||||||
|
if (StringUtils.isNotBlank(documentSplitInfo.getSerialNumberOrName())){
|
||||||
|
queryWrapper.and(qw -> qw
|
||||||
|
.like("serial_number", documentSplitInfo.getSerialNumberOrName())
|
||||||
|
.or()
|
||||||
|
.like("title", documentSplitInfo.getSerialNumberOrName()));
|
||||||
|
}
|
||||||
|
// 拆分状态
|
||||||
|
queryWrapper.eq(StringUtils.isNotBlank(documentSplitInfo.getSplitStatus()), "split_status", documentSplitInfo.getSplitStatus());
|
||||||
|
// 编辑人
|
||||||
|
queryWrapper.eq(StringUtils.isNotBlank(documentSplitInfo.getAuthor()), "username", documentSplitInfo.getAuthor());
|
||||||
|
// 逻辑删除
|
||||||
|
queryWrapper.eq("del_flag", 0);
|
||||||
|
// 排序
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
return queryWrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user