humuyu 2 rokov pred
rodič
commit
c5360a10ab

+ 13 - 16
eladmin-system/src/main/java/me/zhengjie/archives/controller/ArchivesController.java

@@ -1,12 +1,15 @@
 package me.zhengjie.archives.controller;
 
 import java.io.File;
+import java.io.IOException;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -14,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -22,6 +27,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
+import io.swagger.annotations.ApiOperation;
 import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.archives.entity.ArchivesEntity;
@@ -36,6 +42,7 @@ import me.zhengjie.archives.vo.CasePortraitVo;
 import me.zhengjie.base.ResponseDTO;
 import me.zhengjie.config.FileProperties;
 import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.mnt.service.dto.AppQueryCriteria;
 import me.zhengjie.modules.system.service.DictDetailService;
 
 /**
@@ -362,6 +369,11 @@ public class ArchivesController {
 		return new ResponseEntity<>(map, HttpStatus.OK);
 	}
 
+	@AnonymousGetMapping(value = "/download")
+	public void download(ArchivesVo archives, HttpServletResponse response) throws IOException {
+		archivesService.download(archives, response);
+	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -374,20 +386,5 @@ public class ArchivesController {
 		chromeLogService.save(chrome);
 		return ResponseDTO.success();
 	}
-	/**
-	 * 文件和图片
-	 *
-	 * @return
-	 */
-//	@AnonymousPostMapping("/list")
-//	public ResponseDTO<PageResultVo<List<ArchivesEntity>>> list(@RequestBody ArchivesVo archives) {
-//		// PageResultVo<List<ArchivesEntity>> page = archivesService.page(archives);
-//
-//		return ResponseDTO.success(null);
-//	}
-	public static void main(String[] args) {
-		String value="1000";
-		Integer aaa=Integer.valueOf(value) + 1;
-		System.out.println(aaa);
-	}
+
 }

+ 6 - 0
eladmin-system/src/main/java/me/zhengjie/archives/entity/ArchivesEntity.java

@@ -186,6 +186,12 @@ public class ArchivesEntity implements Serializable {
 	 */
 	@TableField("update_by")
 	private String updateBy;
+	/**
+	 * 更新者
+	 */
+	@QueryWapper(attribute = { "submitStartTime", "submitEndTime" }, value = { QueryKeyword.RANGE })
+	@TableField("submit_time")
+	private String submitTime;
 
 	/**
 	 * 创建日期

+ 26 - 1
eladmin-system/src/main/java/me/zhengjie/archives/plus/AbstractService.java

@@ -171,11 +171,20 @@ public interface AbstractService<T> extends IService<T> {
 	 * @param queryWrapper 实体对象封装操作类
 	 *                     {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
 	 */
+	default List<T> list(T t,QueryMap... jsonObj) {
+		Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t,jsonObj);
+		return list(queryWrapper);
+	}
+	/**
+	 * 查询列表
+	 *
+	 * @param queryWrapper 实体对象封装操作类
+	 *                     {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
+	 */
 	default List<T> list(T t) {
 		Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t);
 		return list(queryWrapper);
 	}
-
 	/**
 	 * 查询列表
 	 *
@@ -197,6 +206,22 @@ public interface AbstractService<T> extends IService<T> {
 		Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t);
 		return listObjs(queryWrapper);
 	}
+	/**
+	 * 翻页查询
+	 *
+	 * @param page         翻页对象
+	 * @param queryWrapper 实体对象封装操作类
+	 *                     {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
+	 */
+	default <E extends IPage<T>> E page(E page, T t) {
+		Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t);
+		try {
+			return page(page, queryWrapper);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
 
 	/**
 	 * 翻页查询

+ 5 - 0
eladmin-system/src/main/java/me/zhengjie/archives/service/ArchivesService.java

@@ -1,8 +1,11 @@
 package me.zhengjie.archives.service;
 
+import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletResponse;
+
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -24,4 +27,6 @@ public interface ArchivesService extends AbstractService<ArchivesEntity> {
 	public Map<String, Object> page(ArchivesVo req);
 
 	public void mergeSubmit(CasePortraitVo archives) throws Exception;
+
+	public void download(ArchivesVo req, HttpServletResponse response) throws IOException;
 }

+ 64 - 11
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ArchivesServiceImpl.java

@@ -1,15 +1,18 @@
 package me.zhengjie.archives.service.impl;
 
 import java.io.File;
-
+import java.io.IOException;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
 import javax.annotation.PostConstruct;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
@@ -33,12 +36,14 @@ import me.zhengjie.archives.plus.AbstractServiceImpl;
 import me.zhengjie.archives.plus.QueryMap;
 import me.zhengjie.archives.service.ArchivesService;
 import me.zhengjie.archives.service.FileInfoService;
+import me.zhengjie.archives.util.ExcelUtils;
 import me.zhengjie.archives.util.HtmlConvertToPdf;
 import me.zhengjie.archives.util.HtmlToImage;
 import me.zhengjie.archives.util.PdfUtils;
 import me.zhengjie.archives.vo.ArchivesVo;
 import me.zhengjie.archives.vo.CasePortraitVo;
 import me.zhengjie.config.FileProperties;
+import me.zhengjie.modules.mnt.service.dto.AppDto;
 import me.zhengjie.modules.system.service.DictDetailService;
 import me.zhengjie.utils.BeanCopyUtils;
 import me.zhengjie.utils.DateUtil;
@@ -66,18 +71,25 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 //	}
 
 	public Map<String, Object> page(ArchivesVo req) {
-		IPage<ArchivesEntity> page = new Page<>(req.getIndex()+1, req.getSize());
+		IPage<ArchivesEntity> page = new Page<>(req.getIndex() + 1, req.getSize());
 		ArchivesEntity entity = BeanCopyUtils.convertObj(req, ArchivesEntity.class);
 		entity.setIsDelete("1");
 		QueryMap queryMap = new QueryMap();
 		Map<String, Object> map = new HashMap<>();
 		List<String> accept = req.getAcceptDate();
 		if (CollectionUtils.isNotEmpty(accept)) {
-			map.put("startTime", accept.get(0).replaceAll("-", ""));
-			map.put("endTime", accept.get(1).replaceAll("-", ""));
+			String stringDate = accept.get(0).replaceAll("-", "");
+			map.put("startTime", stringDate.split(" ")[0]);
+			String endDate=accept.get(1).replaceAll("-", "");
+			map.put("endTime",endDate.split(" ")[0]);
+			queryMap.setMap(map);
+		}
+		List<String> submitTime = req.getSubmitTime();
+		if (CollectionUtils.isNotEmpty(submitTime)) {
+			map.put("submitStartTime", submitTime.get(0));
+			map.put("submitEndTime", submitTime.get(1));
 			queryMap.setMap(map);
 		}
-
 		page = page(page, entity, queryMap);
 		String previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
 
@@ -278,6 +290,8 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		archiveEntity.setId(archives.getId());
 		archiveEntity.setPdfPath(fileRelatePath + fileName);
 		archiveEntity.setImageJson(JSON.toJSONString(archives));
+		String submitTime = DateUtil.localDateTimeFormatyMdHms(LocalDateTime.now());
+		archiveEntity.setSubmitTime(submitTime);
 		if (StringUtils.isNotBlank(archives.getIsRedo()) && archives.getIsRedo().equals("1")) {
 			int redoCount = entity.getRedoCount() == null ? 0 : entity.getRedoCount() + 1;
 			archiveEntity.setRedoCount(redoCount);
@@ -335,6 +349,44 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		image(archives);
 	}
 
+	@Override
+	public void download(ArchivesVo req, HttpServletResponse response) throws IOException {
+
+		List<String> accept = req.getAcceptDate();
+		QueryMap queryMap = new QueryMap();
+		Map<String, Object> map = new HashMap<>();
+		if (CollectionUtils.isNotEmpty(accept)) {
+			String stringDate = accept.get(0).replaceAll("-", "");
+			map.put("startTime", stringDate.split(" ")[0]);
+			String endDate=accept.get(1).replaceAll("-", "");
+			map.put("endTime",endDate.split(" ")[0]);
+			queryMap.setMap(map);
+		}
+		List<String> submitTime = req.getSubmitTime();
+		if (CollectionUtils.isNotEmpty(submitTime)) {
+			map.put("submitStartTime", submitTime.get(0));
+			map.put("submitEndTime", submitTime.get(1));
+			queryMap.setMap(map);
+		}
+		ArchivesEntity entity = BeanCopyUtils.convertObj(req, ArchivesEntity.class);
+		List<Map<String, Object>> list = new ArrayList<>();
+		List<ArchivesEntity> queryAll = list(entity, queryMap);
+		if (queryAll != null && queryAll.size() > 0) {
+			// 受理号、当事人姓名、公证书编号、公证员、公证事项
+			for (ArchivesEntity archives : queryAll) {
+				Map<String, Object> export = new LinkedHashMap<>();
+				export.put("受理号", archives.getAcceptNum());
+				export.put("当事人姓名", archives.getPartyName());
+				export.put("公证书编号", archives.getNotarialNum());
+				export.put("公证员", archives.getNotary());
+				export.put("公证事项", archives.getNotarizedItem());
+				list.add(export);
+			}
+		}
+
+		ExcelUtils.downloadExcel(list, response);
+	}
+
 	/**
 	 * 删除没有用到的图片,
 	 */
@@ -345,16 +397,15 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		qw.eq("is_clean", 0);
 		qw.apply("redo_count != clean_count");
 		int i = 0;
-		int j=10;
+		int j = 10;
 		while (true) {
-			
 			qw.last("limit " + i + "," + j);
 			List<ArchivesEntity> archives = this.list(qw);
 			if (CollectionUtils.isEmpty(archives)) {
 				break;
 			}
-			 i = j;
-			 j+=10;
+			i = j;
+			j += 10;
 			for (ArchivesEntity a : archives) {
 				ArchivesEntity deleteImagePre = new ArchivesEntity();
 				deleteImagePre.setId(a.getId());
@@ -367,7 +418,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 					List<String> imageIds = casePort.getImageIds();
 					// 查询id的值
 					FileInfoEntity fileInfo = new FileInfoEntity();
-					 fileInfo.setLoanNo(String.valueOf(a.getId()));
+					fileInfo.setLoanNo(String.valueOf(a.getId()));
 //						Map<String, FileInfoEntity> allFileIds = fileInfoService.list(fileInfo).stream()
 //								.collect(Collectors.toMap(obj -> obj.getId(), obj -> obj));
 					List<FileInfoEntity> fileInfos = fileInfoService.list(fileInfo);
@@ -399,5 +450,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 
 		}
 	}
-
+	public static void main(String[] args) {
+		System.out.println("20200101 00:00:00".split(" ")[0].length());
+	}
 }

+ 55 - 0
eladmin-system/src/main/java/me/zhengjie/archives/util/ExcelUtils.java

@@ -0,0 +1,55 @@
+package me.zhengjie.archives.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+
+import cn.hutool.core.exceptions.DependencyException;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.poi.excel.BigExcelWriter;
+import cn.hutool.poi.excel.ExcelUtil;
+import me.zhengjie.utils.FileUtil;
+
+public class ExcelUtils {
+	public static MyExcelWriter getBigWriter(File destFile) {
+		try {
+			return new MyExcelWriter(destFile);
+		} catch (NoClassDefFoundError var1) {
+			throw new DependencyException((Throwable) ObjectUtil.defaultIfNull(var1.getCause(), var1),
+					"You need to add dependency of 'poi-ooxml' to your project, and version >= 4.1.2", new Object[0]);
+		}
+	}
+	/**
+	 * 导出excel
+	 */
+	public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
+		String tempPath = FileUtil.SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
+		File file = new File(tempPath);
+		BigExcelWriter writer = getBigWriter(file);
+		// 一次性写出内容,使用默认样式,强制输出标题
+		writer.write(list, true);
+		SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
+		// 上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
+		sheet.trackAllColumnsForAutoSizing();
+		// 列宽自适应
+		writer.autoSizeColumnAll();
+		// response为HttpServletResponse对象
+		response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
+		// test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
+		response.setHeader("Content-Disposition", "attachment;filename=file.xlsx");
+		ServletOutputStream out = response.getOutputStream();
+		// 终止后删除临时文件
+		file.deleteOnExit();
+		writer.flush(out, true);
+		// 此处记得关闭输出Servlet流
+		IoUtil.close(out);
+	}
+}

+ 56 - 0
eladmin-system/src/main/java/me/zhengjie/archives/util/MyExcelWriter.java

@@ -0,0 +1,56 @@
+package me.zhengjie.archives.util;
+
+import java.io.File;
+
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.xssf.streaming.SXSSFSheet;
+
+import cn.hutool.poi.excel.BigExcelWriter;
+
+public class MyExcelWriter extends BigExcelWriter {
+	public MyExcelWriter(File destFile) {
+		super(destFile, null);
+
+	}
+
+	@Override
+	public BigExcelWriter autoSizeColumnAll() {
+		final SXSSFSheet sheet = (SXSSFSheet) this.sheet;
+		sheet.trackAllColumnsForAutoSizing();
+		super.autoSizeColumnAll();
+//		for (int i = 0; i < sheet.getRow(sheet.getLastRowNum()).getPhysicalNumberOfCells(); i++) {
+//			// 解决自动设置列宽中文失效的问题
+//			sheet.setColumnWidth(i, sheet.getColumnWidth(i) * 17 / 10);
+//		}
+		// sheet的索引从0开始,获取sheet列数
+		if(sheet.getLastRowNum()==-1) {
+			sheet.untrackAllColumnsForAutoSizing();
+			return this;
+		}
+		int maxColumn = sheet.getRow(sheet.getLastRowNum()).getPhysicalNumberOfCells();
+		for (int columnNum = 0; columnNum <= maxColumn; columnNum++) {
+			int columnWidth = sheet.getColumnWidth(columnNum) / 256;
+			// 遍历列的数据,获取这一列的最长字符串
+			for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) {
+				Row currentRow = sheet.getRow(rowNum);
+				if (currentRow != null && currentRow.getCell(columnNum) != null) {
+					Cell currentCell = currentRow.getCell(columnNum);
+					if (currentCell.getCellType() == CellType.STRING) {
+						int length = currentCell.getStringCellValue().getBytes().length;
+						if (columnWidth < length) {
+							columnWidth = length;
+						}
+					}
+				}
+
+			}
+			// 将最长的length*256设为列宽
+			sheet.setColumnWidth(columnNum, columnWidth * 256);
+		}
+		sheet.untrackAllColumnsForAutoSizing();
+		return this;
+	}
+
+}

+ 13 - 11
eladmin-system/src/main/java/me/zhengjie/archives/vo/ArchivesVo.java

@@ -18,20 +18,22 @@ public class ArchivesVo extends PageVo {
 	private String partyName;
 	// 当事人姓名
 	private String status;
-	//输入目录号
+	// 输入目录号
 	private String catalogNum;
-	//输入公证书编号
+	// 输入公证书编号
 	private String notarialNum;
-	//受理号
+	// 受理号
 	private String acceptNum;
-	//公证事项
-	private String notarizedItem; 
-	//公证事项
-	private String undertaker; 
-	//公证事项
-	private String annual; 
-	//接受時間
+	// 公证事项
+	private String notarizedItem;
+	// 公证事项
+	private String undertaker;
+	// 公证事项
+	private String annual;
+	// 接受時間
 	List<String> acceptDate;
-	//主键
+	// 接受時間
+	List<String> submitTime;
+	// 主键
 	private Long id;
 }

+ 2 - 2
eladmin-system/src/main/resources/config/application-dev.yml

@@ -4,9 +4,9 @@ spring:
     druid:
       db-type: com.alibaba.druid.pool.DruidDataSource
       driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
-      url: jdbc:log4jdbc:mysql://127.0.0.1:3306/efs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
+      url: jdbc:log4jdbc:mysql://114.55.230.80:3306/efs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
       username: root
-      password: admin
+      password: QopraffaQWPRPPR123
       # 初始连接数
       initial-size: 5
       # 最小连接数