feat(文档拆分): 模版下载
This commit is contained in:
+27
-13
@@ -17,6 +17,8 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -45,7 +47,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @return Result<IPage<DocumentSplitInfo>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分-分页列表查询")
|
||||
@ApiOperation(value="文档拆分-分页列表查询", notes="文档拆分-分页列表查询")
|
||||
@@ -60,7 +62,7 @@ public class DocumentSplitController {
|
||||
* 更改权限
|
||||
*
|
||||
* @param documentSplitInfo
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分-更改权限")
|
||||
@ApiOperation(value="文档拆分-更改权限", notes="文档拆分-更改权限")
|
||||
@@ -74,7 +76,7 @@ public class DocumentSplitController {
|
||||
* 拆分
|
||||
*
|
||||
* @param sarFileSplitInfoEO
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分-拆分")
|
||||
@ApiOperation(value="文档拆分-拆分", notes="文档拆分-拆分")
|
||||
@@ -87,7 +89,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分-通过id删除")
|
||||
@ApiOperation(value="文档拆分-通过id删除", notes="文档拆分-通过id删除")
|
||||
@@ -100,7 +102,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分-批量删除")
|
||||
@ApiOperation(value="文档拆分-批量删除", notes="文档拆分-批量删除")
|
||||
@@ -113,7 +115,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-分页列表查询
|
||||
* @param parameter
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-分页列表查询")
|
||||
@ApiOperation(value = "文档拆分详情-分页列表查询")
|
||||
@@ -125,7 +127,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-根据id查询
|
||||
* @param id
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-根据id查询")
|
||||
@ApiOperation(value = "文档拆分详情-根据id查询")
|
||||
@@ -137,7 +139,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-条目信息列表
|
||||
* @param id
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-条目信息列表")
|
||||
@ApiOperation(value = "文档拆分详情-条目信息列表")
|
||||
@@ -150,7 +152,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-编辑
|
||||
* @param parameter
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-编辑")
|
||||
@ApiOperation(value = "文档拆分详情-编辑")
|
||||
@@ -163,7 +165,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-批量编辑
|
||||
* @param parameter
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-批量编辑")
|
||||
@ApiOperation(value = "文档拆分详情-批量编辑")
|
||||
@@ -176,7 +178,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-删除
|
||||
*
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-删除")
|
||||
@ApiOperation(value="文档拆分详情-删除", notes="文档拆分详情-删除")
|
||||
@@ -189,7 +191,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-批量删除
|
||||
*
|
||||
* @return Result<T>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-批量删除")
|
||||
@ApiOperation(value="文档拆分详情-批量删除", notes="文档拆分详情-批量删除")
|
||||
@@ -202,7 +204,7 @@ public class DocumentSplitController {
|
||||
/**
|
||||
* 文档拆分详情-合并条款
|
||||
* @param parameter
|
||||
* @return Result<IPage<Map<String,Object>>>
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-合并条款")
|
||||
@ApiOperation(value = "文档拆分详情-合并条款")
|
||||
@@ -238,4 +240,16 @@ public class DocumentSplitController {
|
||||
return Result.OK("批量复制成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档拆分详情-模板下载
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@AutoLog(value = "文档拆分详情-模板下载")
|
||||
@ApiOperation(value = "文档拆分详情-模板下载")
|
||||
@GetMapping("/downloadImportTemplate")
|
||||
public void downloadImportTemplate(HttpServletRequest request, HttpServletResponse response) {
|
||||
documentSplitService.downloadImportTemplate(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
@@ -5,6 +5,8 @@ import com.jero.modules.laws.documenttool.entity.DocumentSplitInfo;
|
||||
import com.jero.modules.split.entity.SarFileSplitInfoEO;
|
||||
import com.jero.modules.split.entity.SarFileSplitItemsValEO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -105,4 +107,11 @@ public interface IDocumentSplitService {
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> queryDocumentSplitDetailById(String id);
|
||||
|
||||
/**
|
||||
* 文档拆分详情-模板下载
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
void downloadImportTemplate(HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
||||
+70
@@ -33,16 +33,27 @@ import com.jero.modules.tag.entity.LawsTag;
|
||||
import com.jero.modules.tag.enums.LawsFieldTypeEnum;
|
||||
import com.jero.modules.tag.enums.TableNameEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
|
||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.net.URLEncoder.encode;
|
||||
|
||||
/**
|
||||
* @Author: yjz
|
||||
* @Date: 2023/10/12/23:03
|
||||
@@ -409,6 +420,65 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService {
|
||||
return documentSplitMapper.queryLawsDocumentSplitById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadImportTemplate(HttpServletRequest request, HttpServletResponse response) {
|
||||
try (Workbook workbook = new XSSFWorkbook()){
|
||||
// sheet页
|
||||
XSSFSheet sheet = (XSSFSheet) workbook.createSheet("拆分导入模版");
|
||||
// 列宽
|
||||
sheet.setDefaultColumnWidth(16);
|
||||
// 创建第一行
|
||||
Row headerRow = sheet.createRow(0);
|
||||
// 创建表头信息
|
||||
String[] titleArr = {"条文号", "条文标题", "条文内容"};
|
||||
|
||||
//样式
|
||||
CellStyle cellStyle = workbook.createCellStyle();
|
||||
// 水平、垂直居中
|
||||
cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
// 问本格式
|
||||
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("@"));
|
||||
|
||||
for (int i = 0; i < titleArr.length; i++) {
|
||||
// 创建列
|
||||
Cell cell = headerRow.createCell(i);
|
||||
cell.setCellValue(titleArr[i]);
|
||||
cell.setCellStyle(cellStyle);
|
||||
}
|
||||
|
||||
// 创建第二行
|
||||
Row headerRowTwo = sheet.createRow(1);
|
||||
// 填充说明
|
||||
Cell cell = headerRowTwo.createCell(0);
|
||||
String explain = "模版说明:\n" +
|
||||
"1. 条款号/条款标题/条文内容不能为空\n" +
|
||||
"2. 仅支持zip格式文件夹";
|
||||
|
||||
CellStyle cellStyleTwo = workbook.createCellStyle();
|
||||
cellStyleTwo.setWrapText(true);
|
||||
cell.setCellStyle(cellStyleTwo);
|
||||
// 行高
|
||||
headerRowTwo.setHeight((short) 800);
|
||||
cell.setCellValue(new XSSFRichTextString(explain));
|
||||
// 合并单元格(参数说明:起始行,结束行,起始列,结束列)
|
||||
CellRangeAddress region = new CellRangeAddress(1, 1, 0, 2);
|
||||
sheet.addMergedRegion(region);
|
||||
|
||||
// 返回流
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName=" +
|
||||
encode("拆分导入模版下载.xlsx", "UTF-8"));
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
workbook.write(outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}catch (Exception e){
|
||||
throw new JeroBootException("下载文件失败!");
|
||||
}
|
||||
}
|
||||
|
||||
private void manageData(Map<String, Object> resultMap, StringBuilder fieldsBuilder, StringBuilder valuesBuilder) {
|
||||
// 所有key(字段名)
|
||||
resultMap.forEach((k, v) -> {
|
||||
|
||||
Reference in New Issue
Block a user