文档库--字段枚举修改
This commit is contained in:
+2
-54
@@ -409,60 +409,8 @@ public class BussDocumentLibraryEOController extends JeroController<BussDocument
|
||||
|
||||
@ApiOperation(value = "模板下载")
|
||||
@GetMapping(value = "/exportTemplate")
|
||||
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
bussDocumentLibraryEOService.exportTemplate(response,request);
|
||||
OutputStream os = null;
|
||||
OutputStream excelOS = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
String fileOriName = "导入模板";
|
||||
String filePath = "";
|
||||
try{
|
||||
//创建临时文件夹
|
||||
File nowFile = new File(filePath);
|
||||
if (nowFile.exists()){
|
||||
nowFile.delete();
|
||||
}
|
||||
nowFile.mkdirs();
|
||||
String fileName = "导入模板.xls";
|
||||
HSSFSheet sheetItems = workbook.createSheet("模板");
|
||||
sheetItems.setDefaultColumnWidth(16);
|
||||
HSSFCellStyle cellStyle =workbook.createCellStyle();
|
||||
cellStyle.setWrapText(true);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
Row rowHeader = sheetItems.createRow(0);//开始创建标题行
|
||||
String exportFieldName = "标准编号,标题,发布时间";
|
||||
|
||||
if (StringUtils.isNotBlank(exportFieldName)) {
|
||||
String[] headerArr = exportFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||
}
|
||||
}
|
||||
String repFileName = fileName.replaceAll("/","_");
|
||||
excelOS = new FileOutputStream(filePath + "/" + repFileName);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\""+ fileOriName+".zip");
|
||||
response.setContentType("application/force-download");
|
||||
response.flushBuffer();
|
||||
os = response.getOutputStream();
|
||||
workbook.write(excelOS);
|
||||
excelOS.flush();
|
||||
excelOS.close();
|
||||
ZipUtil.zip(filePath,filePath+".zip");
|
||||
FileInputStream fis = new FileInputStream(filePath+".zip");
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
os.write(len);
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
} catch (Exception e) {
|
||||
throw new JeroBootException("下载文件失败,请重试");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
IOUtils.closeQuietly(excelOS);
|
||||
}
|
||||
public void exportTemplate(@RequestParam Map<String,Object> map, HttpServletResponse response, HttpServletRequest request) throws Exception {
|
||||
bussDocumentLibraryEOService.exportTemplate(map,response,request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-5
@@ -6,11 +6,23 @@ package com.jero.modules.document.enums;
|
||||
* @auth zhn
|
||||
*/
|
||||
public enum FieldTypeEnum {
|
||||
TEXT("输入框","text"),
|
||||
LIST("下拉单选","list"),
|
||||
LIST_MULTI("下拉多选","list_multi"),
|
||||
FILE("文件","file"),
|
||||
DATE("日期","date");
|
||||
// TEXT("输入框","text"),
|
||||
// LIST("下拉单选","list"),
|
||||
// LIST_MULTI("下拉多选","list_multi"),
|
||||
// FILE("文件","file"),
|
||||
// DATE("日期","date");
|
||||
//属性类型 1输入框(字符串),2输入框(数字),3单选下拉框,4多选下拉框,5单日期选择,6多日期选择,7文件,8文本框,9人员选择,10标准选择
|
||||
TEXT_STRING("输入框(字符串)","1"),
|
||||
TEXT_NUMBER("输入框(数字)","2"),
|
||||
PULL_SINGLE("单选下拉框","3"),
|
||||
PULL_MORE("多选下拉框","4"),
|
||||
DATE_SINGLE("单日期选择","5"),
|
||||
DATE_MORE("多日期选择","6"),
|
||||
FILE("文件","7"),
|
||||
TEXT("文本框","8"),
|
||||
PERSON("人员选择","9"),
|
||||
STANDARD("标准选择","10");
|
||||
|
||||
|
||||
|
||||
String name;
|
||||
|
||||
+6
-1
@@ -140,7 +140,12 @@ public interface IBussDocumentLibraryEOService extends IService<BussDocumentLibr
|
||||
HttpServletResponse response,
|
||||
HttpServletRequest request);
|
||||
|
||||
void exportTemplate(HttpServletResponse response, HttpServletRequest request);
|
||||
/**
|
||||
* 模板下载
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
void exportTemplate(Map<String,Object> map,HttpServletResponse response, HttpServletRequest request);
|
||||
|
||||
|
||||
}
|
||||
|
||||
+132
-11
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.document.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.aliyuncs.utils.IOUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -30,10 +31,16 @@ import com.jero.modules.tag.entity.OnlCgformArea;
|
||||
import com.jero.modules.tag.service.impl.OnlCgformAreaServiceImpl;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -50,6 +57,7 @@ import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -83,6 +91,9 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
@Autowired
|
||||
private IBussLogEOService iBussLogEOService;
|
||||
|
||||
@Value(value = "${jero.path.upload}")
|
||||
private String uploadpath;
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
@@ -278,8 +289,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
|
||||
//过滤出下拉选
|
||||
List<OnlCgformField> onlCgformFieldList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.LIST.getValue().equals(e.getFieldShowType())
|
||||
|| FieldTypeEnum.LIST_MULTI.getValue().equals(e.getFieldShowType()))
|
||||
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType()))
|
||||
.collect(Collectors.toList());
|
||||
//下拉选字段
|
||||
List<String> fieldPullList = onlCgformFieldList.stream().map(OnlCgformField::getDbFieldName).collect(Collectors.toList());
|
||||
@@ -310,7 +321,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//字段类型
|
||||
String fieldShowType = onlCgformField.getFieldShowType();
|
||||
String value = "";
|
||||
if (FieldTypeEnum.DATE.getValue().equals(fieldShowType)) {
|
||||
if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldShowType)) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
if (ObjectUtils.isNotEmpty(dataList.get(0).get(dbFieldName))) {
|
||||
value = sdf.format(dataList.get(0).get(dbFieldName));
|
||||
@@ -389,7 +400,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//字段属性
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
|
||||
//时间类型字段
|
||||
List<OnlCgformField> fieldDateList = fieldList.stream().filter(e -> FieldTypeEnum.DATE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
List<OnlCgformField> fieldDateList = fieldList.stream().filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
//文件类型字段
|
||||
List<OnlCgformField> fieldFileList = fieldList.stream().filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
String mustFields = "id,create_by,create_time,update_by,update_time,sys_org_code";
|
||||
@@ -457,14 +468,14 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
List<OnlCgformField> fieldList = onlCgformFieldService.getFieldList(ModuleEnum.DOCUMENT_LIBRARY.getValue());
|
||||
//时间类型字段
|
||||
List<OnlCgformField> fieldDateList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.DATE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
.filter(e -> FieldTypeEnum.DATE_SINGLE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
//文件类型字段
|
||||
List<OnlCgformField> fieldFileList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.FILE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
//下拉单选或下拉多选
|
||||
List<OnlCgformField> fieldPullList = fieldList.stream()
|
||||
.filter(e -> FieldTypeEnum.LIST.getValue().equals(e.getFieldShowType())
|
||||
|| FieldTypeEnum.LIST_MULTI.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
.filter(e -> FieldTypeEnum.PULL_SINGLE.getValue().equals(e.getFieldShowType())
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(e.getFieldShowType())).collect(Collectors.toList());
|
||||
|
||||
String id = (String) map.get("id");
|
||||
//通过id查询数据
|
||||
@@ -822,8 +833,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
if (FieldTypeEnum.TEXT.getValue().equals(fieldType)) {
|
||||
//输入框
|
||||
conditionSb.append(" and " + key + " like concat(concat('%','" + value + "'),'%')");
|
||||
} else if (FieldTypeEnum.LIST.getValue().equals(fieldType)
|
||||
|| FieldTypeEnum.LIST_MULTI.getValue().equals(fieldType)) {
|
||||
} else if (FieldTypeEnum.PULL_SINGLE.getValue().equals(fieldType)
|
||||
|| FieldTypeEnum.PULL_MORE.getValue().equals(fieldType)) {
|
||||
StringBuilder valueSb = new StringBuilder();
|
||||
for (String valueTemp : value.split(",")) {
|
||||
valueSb.append("'" + valueTemp + "',");
|
||||
@@ -832,7 +843,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
//下拉单选或下拉多选
|
||||
conditionSb.append(" and " + key + " in(" + substring + ")");
|
||||
|
||||
} else if (FieldTypeEnum.DATE.getValue().equals(fieldType)) {
|
||||
} else if (FieldTypeEnum.DATE_SINGLE.getValue().equals(fieldType)) {
|
||||
//日期(区分单日期还时间范围)
|
||||
if (value.contains(",")) {
|
||||
conditionSb.append(" and " + "date_format(" + key + ",'%Y-%m-%d') >= '" + value.split(",")[0] + "'"
|
||||
@@ -1106,8 +1117,118 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
* @param response
|
||||
* @param request
|
||||
*/
|
||||
@Override
|
||||
public void exportTemplate(HttpServletResponse response, HttpServletRequest request) {
|
||||
public void exportTemplate(Map<String,Object> map,HttpServletResponse response, HttpServletRequest request) {
|
||||
OutputStream os = null;
|
||||
OutputStream excelOS = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
String fileOriName = "导入模板";
|
||||
String filePath = uploadpath + "/" + fileOriName;
|
||||
try{
|
||||
//创建临时文件夹
|
||||
File nowFile = new File(filePath);
|
||||
if (nowFile.exists()){
|
||||
nowFile.delete();
|
||||
}
|
||||
nowFile.mkdirs();
|
||||
String fileName = "导入模板.xls";
|
||||
HSSFSheet sheetItems = workbook.createSheet("模板");
|
||||
sheetItems.setDefaultColumnWidth(16);
|
||||
HSSFCellStyle cellStyle =workbook.createCellStyle();
|
||||
cellStyle.setWrapText(true);
|
||||
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
Row rowHeader = sheetItems.createRow(0);//开始创建标题行
|
||||
|
||||
getWorkbookTitle((String)map.get("cut"));
|
||||
String exportFieldName = "标准编号,标题,发布时间";
|
||||
|
||||
if (StringUtils.isNotBlank(exportFieldName)) {
|
||||
String[] headerArr = exportFieldName.split(",");
|
||||
for (int i=0;i < headerArr.length; i++) {
|
||||
rowHeader.createCell(i).setCellValue(headerArr[i]);
|
||||
}
|
||||
}
|
||||
String repFileName = fileName.replaceAll("/","_");
|
||||
excelOS = new FileOutputStream(filePath + "/" + repFileName);
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=\""+ fileOriName+".zip");
|
||||
response.setContentType("application/force-download");
|
||||
response.flushBuffer();
|
||||
os = response.getOutputStream();
|
||||
workbook.write(excelOS);
|
||||
excelOS.flush();
|
||||
excelOS.close();
|
||||
ZipUtil.zip(filePath,filePath+".zip");
|
||||
FileInputStream fis = new FileInputStream(filePath+".zip");
|
||||
int len = 0;
|
||||
while ((len = fis.read()) != -1) {
|
||||
os.write(len);
|
||||
}
|
||||
os.flush();
|
||||
os.close(); // 后开先关
|
||||
fis.close(); // 先开后关
|
||||
} catch (Exception e) {
|
||||
throw new JeroBootException("下载文件失败,请重试");
|
||||
} finally {
|
||||
IOUtils.closeQuietly(os);
|
||||
IOUtils.closeQuietly(excelOS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板下载的表头
|
||||
* @return
|
||||
*/
|
||||
private String getWorkbookTitle(String cut){
|
||||
|
||||
List<Map<String, Object>> addForm = getAddForm(ModuleEnum.DOCUMENT_LIBRARY.getValue(), cut);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<String> multipleList = new LinkedList<>();
|
||||
List<String> singleList = new LinkedList<>();
|
||||
List<String> fileList = new LinkedList<>();
|
||||
for (Map<String, Object> map : addForm) {
|
||||
if("0".equals(map.get("field_must_input"))){
|
||||
sb.append("*" + map.get("db_field_txt")+",");
|
||||
}else{
|
||||
sb.append(map.get("db_field_txt")+",");
|
||||
}
|
||||
//多选字段
|
||||
// if(FieldTypeEnum.PULL_MORE.getValue().equals(map.get("field_show_type"))){
|
||||
// multipleList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.PULL_SINGLE.getValue().equals(map.get("field_show_type"))){
|
||||
// //单选字段
|
||||
// singleList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.FILE.getValue().equals(map.get("field_show_type"))){
|
||||
// //文件字段
|
||||
// fileList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.0000.getValue().equals(map.get("field_show_type"))){
|
||||
// //数字输入框字段
|
||||
// fileList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.0000.getValue().equals(map.get("field_show_type"))){
|
||||
// //汉字输入框字段
|
||||
// fileList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.0000.getValue().equals(map.get("field_show_type"))){
|
||||
// //单选日期字段
|
||||
// fileList.add((String) map.get("db_field_txt"));
|
||||
// }else if(FieldTypeEnum.000.getValue().equals(map.get("field_show_type"))){
|
||||
// //多选日期字段
|
||||
// fileList.add((String) map.get("db_field_txt"));
|
||||
// }
|
||||
}
|
||||
String title = sb.substring(0, sb.length() - 1);
|
||||
|
||||
//第二行
|
||||
StringBuilder sbTwo = new StringBuilder();
|
||||
sbTwo.append("填写说明\n"+"1.所有带*号的字段必须填写");
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user