humuyu vor 2 Jahren
Ursprung
Commit
97ad811010
26 geänderte Dateien mit 1040 neuen und 551 gelöschten Zeilen
  1. 14 27
      eladmin-common/src/main/java/me/zhengjie/base/ResponseDTO.java
  2. 1 0
      eladmin-common/src/main/java/me/zhengjie/base/ResultCode.java
  3. 4 2
      eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java
  4. 149 131
      eladmin-common/src/main/java/me/zhengjie/utils/DateUtil.java
  5. 67 11
      eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
  6. 202 21
      eladmin-system/src/main/java/me/zhengjie/archives/controller/ArchivesController.java
  7. 52 4
      eladmin-system/src/main/java/me/zhengjie/archives/controller/FileInfoController.java
  8. 1 0
      eladmin-system/src/main/java/me/zhengjie/archives/dto/FilePreviewDto.java
  9. 214 206
      eladmin-system/src/main/java/me/zhengjie/archives/entity/ArchivesEntity.java
  10. 11 55
      eladmin-system/src/main/java/me/zhengjie/archives/entity/FileInfoEntity.java
  11. 2 2
      eladmin-system/src/main/java/me/zhengjie/archives/plus/AbstractService.java
  12. 4 3
      eladmin-system/src/main/java/me/zhengjie/archives/plus/QueryMapUtil.java
  13. 3 3
      eladmin-system/src/main/java/me/zhengjie/archives/plus/QueryWrapperUtil.java
  14. 195 40
      eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ArchivesServiceImpl.java
  15. 12 6
      eladmin-system/src/main/java/me/zhengjie/archives/service/impl/FileInfoServiceImpl.java
  16. 2 6
      eladmin-system/src/main/java/me/zhengjie/archives/util/HtmlToImage.java
  17. 51 0
      eladmin-system/src/main/java/me/zhengjie/archives/util/PdfUtils.java
  18. 14 0
      eladmin-system/src/main/java/me/zhengjie/archives/vo/ArchivesVo.java
  19. 2 1
      eladmin-system/src/main/java/me/zhengjie/archives/vo/CasePortraitVo.java
  20. 2 0
      eladmin-system/src/main/java/me/zhengjie/archives/vo/FileUploadVO.java
  21. 1 1
      eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java
  22. 1 1
      eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java
  23. 12 2
      eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
  24. 2 2
      eladmin-system/src/main/resources/config/application-dev.yml
  25. 21 26
      eladmin-system/src/main/resources/config/application-prod.yml
  26. 1 1
      eladmin-system/src/main/resources/logback.xml

+ 14 - 27
eladmin-common/src/main/java/me/zhengjie/base/ResponseDTO.java

@@ -28,43 +28,27 @@ public class ResponseDTO<T> {
 
 	}
 
-	public ResponseDTO(ResultCode result, boolean bool) {
+	public ResponseDTO(ResultCode result, Object... args) {
 		this.code = result.code();
-		this.msg = result.message();
+		this.msg = String.format(result.message(), args);
 	}
 
-	public ResponseDTO(ResultCode result, String msg) {
-		this.code = result.code();
-		this.msg = msg;
-	}
-
-	public ResponseDTO(ResultCode result, T data, boolean bool) {
-		this.code = result.code();
-		this.msg = result.message();
+	public ResponseDTO(ResultCode result, T data, Object... args) {
+		this(result, args);
 		this.data = data;
 	}
 
-	public ResponseDTO(ResponseDTO<T> responseDTO) {
-		this.code = responseDTO.getCode();
-		this.msg = responseDTO.getMsg();
-	}
-
 	public static <T> ResponseDTO<T> success() {
-		return new ResponseDTO<>(ResultCode.SUCCESS, true);
+		return new ResponseDTO<>(ResultCode.SUCCESS);
 	}
 
-	public static <T> ResponseDTO<T> success(T data) {
-		return new ResponseDTO<>(ResultCode.SUCCESS, data, true);
+	public static <T> ResponseDTO<T> success(T data, Object... args) {
+		return new ResponseDTO<>(ResultCode.SUCCESS, data, args);
 	}
 
-	public static <T> ResponseDTO<T> error(ResultCode result) {
+	public static <T> ResponseDTO<T> error(ResultCode result, Object... args) {
 
-		return new ResponseDTO<>(result, false);
-	}
-
-	public static <T> ResponseDTO<T> error(ResultCode result, String msg) {
-
-		return new ResponseDTO<>(result, msg);
+		return new ResponseDTO<>(result, args);
 	}
 
 	public String getMsg() {
@@ -96,8 +80,11 @@ public class ResponseDTO<T> {
 
 	@Override
 	public String toString() {
-		return "ResponseDTO{" + "code=" + code + ", msg='" + msg + '\'' + ",  data=" + data
-				+ '}';
+		return "ResponseDTO{" + "code=" + code + ", msg='" + msg + '\'' + ",  data=" + data + '}';
 	}
 
+	public static void main(String[] args) {
+		String aa = String.format("test", "ffff");
+		System.out.println(aa);
+	}
 }

+ 1 - 0
eladmin-common/src/main/java/me/zhengjie/base/ResultCode.java

@@ -110,6 +110,7 @@ public enum ResultCode {
     ORDER_OCR_SERVICE_UNAVAILABLE(30052,"订单扫描录入功能尚未开通,请联系平台开通后使用!"),
     JOB_NO_ALREADY_EXISTS(30053,"此工号已存在,请重新输入!"),
     NOTARY_OFFICE_CODE_ALREADY_EXISTS(30054,"公证处编码已存在!"),
+    ARCHIVES_NUM_ALREADY_EXISTS(30054,"%s档案号已存在!"),
     /* 系统错误:40001-49999 */
     SYSTEM_INNER_ERROR(40001, "系统繁忙,请稍后重试"),
     UPLOAD_ERROR(40002, "系统异常,上传文件失败"),

+ 4 - 2
eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java

@@ -65,7 +65,8 @@ public class GlobalExceptionHandler {
 	@ExceptionHandler(value = BadRequestException.class)
 	public ResponseEntity<ApiError> badRequestException(BadRequestException e) {
         // 打印堆栈信息
-        log.error(ThrowableUtil.getStackTrace(e));
+       // log.error(ThrowableUtil.getStackTrace(e));
+		log.error(e.getLocalizedMessage());
         return buildResponseEntity(ApiError.error(e.getStatus(),e.getMessage()));
 	}
 
@@ -75,7 +76,8 @@ public class GlobalExceptionHandler {
     @ExceptionHandler(value = EntityExistException.class)
     public ResponseEntity<ApiError> entityExistException(EntityExistException e) {
         // 打印堆栈信息
-        log.error(ThrowableUtil.getStackTrace(e));
+        //log.error(ThrowableUtil.getStackTrace(e));
+    	log.error(e.getLocalizedMessage());
         return buildResponseEntity(ApiError.error(e.getMessage()));
     }
 

+ 149 - 131
eladmin-common/src/main/java/me/zhengjie/utils/DateUtil.java

@@ -16,6 +16,8 @@
 
 package me.zhengjie.utils;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.Date;
@@ -23,138 +25,154 @@ import java.util.Date;
 /**
  * @author: liaojinlong
  * @date: 2020/6/11 16:28
- * @apiNote: JDK 8  新日期类 格式化与字符串转换 工具类
+ * @apiNote: JDK 8 新日期类 格式化与字符串转换 工具类
  */
 public class DateUtil {
 
-    public static final DateTimeFormatter DFY_MD_HMS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-    public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-
-    /**
-     * LocalDateTime 转时间戳
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static Long getTimeStamp(LocalDateTime localDateTime) {
-        return localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
-    }
-
-    /**
-     * 时间戳转LocalDateTime
-     *
-     * @param timeStamp /
-     * @return /
-     */
-    public static LocalDateTime fromTimeStamp(Long timeStamp) {
-        return LocalDateTime.ofEpochSecond(timeStamp, 0, OffsetDateTime.now().getOffset());
-    }
-
-    /**
-     * LocalDateTime 转 Date
-     * Jdk8 后 不推荐使用 {@link Date} Date
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static Date toDate(LocalDateTime localDateTime) {
-        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
-    }
-
-    /**
-     * LocalDate 转 Date
-     * Jdk8 后 不推荐使用 {@link Date} Date
-     *
-     * @param localDate /
-     * @return /
-     */
-    public static Date toDate(LocalDate localDate) {
-        return toDate(localDate.atTime(LocalTime.now(ZoneId.systemDefault())));
-    }
-
-
-    /**
-     * Date转 LocalDateTime
-     * Jdk8 后 不推荐使用 {@link Date} Date
-     *
-     * @param date /
-     * @return /
-     */
-    public static LocalDateTime toLocalDateTime(Date date) {
-        return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
-    }
-
-    /**
-     * 日期 格式化
-     *
-     * @param localDateTime /
-     * @param patten /
-     * @return /
-     */
-    public static String localDateTimeFormat(LocalDateTime localDateTime, String patten) {
-        DateTimeFormatter df = DateTimeFormatter.ofPattern(patten);
-        return df.format(localDateTime);
-    }
-
-    /**
-     * 日期 格式化
-     *
-     * @param localDateTime /
-     * @param df /
-     * @return /
-     */
-    public static String localDateTimeFormat(LocalDateTime localDateTime, DateTimeFormatter df) {
-        return df.format(localDateTime);
-    }
-
-    /**
-     * 日期格式化 yyyy-MM-dd HH:mm:ss
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static String localDateTimeFormatyMdHms(LocalDateTime localDateTime) {
-        return DFY_MD_HMS.format(localDateTime);
-    }
-
-    /**
-     * 日期格式化 yyyy-MM-dd
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public String localDateTimeFormatyMd(LocalDateTime localDateTime) {
-        return DFY_MD.format(localDateTime);
-    }
-
-    /**
-     * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, String pattern) {
-        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
-        return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
-    }
-
-    /**
-     * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, DateTimeFormatter dateTimeFormatter) {
-        return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
-    }
-
-    /**
-     * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd HH:mm:ss
-     *
-     * @param localDateTime /
-     * @return /
-     */
-    public static LocalDateTime parseLocalDateTimeFormatyMdHms(String localDateTime) {
-        return LocalDateTime.from(DFY_MD_HMS.parse(localDateTime));
-    }
+	public static final DateTimeFormatter DFY_MD_HMS = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+	public static final DateTimeFormatter DFY_MD = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+	public static final DateTimeFormatter yyyy_mm_dd = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+	/**
+	 * LocalDateTime 转时间戳
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static Long getTimeStamp(LocalDateTime localDateTime) {
+		return localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
+	}
+
+	/**
+	 * 时间戳转LocalDateTime
+	 *
+	 * @param timeStamp /
+	 * @return /
+	 */
+	public static LocalDateTime fromTimeStamp(Long timeStamp) {
+		return LocalDateTime.ofEpochSecond(timeStamp, 0, OffsetDateTime.now().getOffset());
+	}
+
+	/**
+	 * LocalDateTime 转 Date Jdk8 后 不推荐使用 {@link Date} Date
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static Date toDate(LocalDateTime localDateTime) {
+		return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+	}
+
+	/**
+	 * LocalDate 转 Date Jdk8 后 不推荐使用 {@link Date} Date
+	 *
+	 * @param localDate /
+	 * @return /
+	 */
+	public static Date toDate(LocalDate localDate) {
+		return toDate(localDate.atTime(LocalTime.now(ZoneId.systemDefault())));
+	}
+
+	/**
+	 * Date转 LocalDateTime Jdk8 后 不推荐使用 {@link Date} Date
+	 *
+	 * @param date /
+	 * @return /
+	 */
+	public static LocalDateTime toLocalDateTime(Date date) {
+		return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
+	}
+
+	/**
+	 * 日期 格式化
+	 *
+	 * @param localDateTime /
+	 * @param patten        /
+	 * @return /
+	 */
+	public static String localDateTimeFormat(LocalDateTime localDateTime, String patten) {
+		DateTimeFormatter df = DateTimeFormatter.ofPattern(patten);
+		return df.format(localDateTime);
+	}
+
+	/**
+	 * 日期 格式化
+	 *
+	 * @param localDateTime /
+	 * @param df            /
+	 * @return /
+	 */
+	public static String localDateTimeFormat(LocalDateTime localDateTime, DateTimeFormatter df) {
+		return df.format(localDateTime);
+	}
+
+	/**
+	 * 日期格式化 yyyy-MM-dd HH:mm:ss
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static String localDateTimeFormatyMdHms(LocalDateTime localDateTime) {
+		return DFY_MD_HMS.format(localDateTime);
+	}
+
+	/**
+	 * 日期格式化 yyyy-MM-dd
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public String localDateTimeFormatyMd(LocalDateTime localDateTime) {
+		return DFY_MD.format(localDateTime);
+	}
+
+	/**
+	 * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, String pattern) {
+		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
+		return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
+	}
+
+	/**
+	 * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static LocalDateTime parseLocalDateTimeFormat(String localDateTime, DateTimeFormatter dateTimeFormatter) {
+		return LocalDateTime.from(dateTimeFormatter.parse(localDateTime));
+	}
+
+	public static String format(String date) {
+
+		SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyyMMdd");
+		SimpleDateFormat targetFormat = new SimpleDateFormat("yyyy年MM月dd");
+		Date d;
+		try {
+			d = sourceFormat.parse(date);
+			String formatDate = targetFormat.format(d);
+			return formatDate;
+		} catch (ParseException e) {
+			
+			e.printStackTrace();
+		}
+		return date;
+	}
+
+	/**
+	 * 字符串转 LocalDateTime ,字符串格式 yyyy-MM-dd HH:mm:ss
+	 *
+	 * @param localDateTime /
+	 * @return /
+	 */
+	public static LocalDateTime parseLocalDateTimeFormatyMdHms(String localDateTime) {
+		return LocalDateTime.from(DFY_MD_HMS.parse(localDateTime));
+	}
+	public static void main(String[] args) {
+		System.out.println(DateUtil.format("20230601"));;
+	}
 }

+ 67 - 11
eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java

@@ -15,7 +15,9 @@
  */
 package me.zhengjie.utils;
 
+import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.lang.Pair;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.poi.excel.BigExcelWriter;
 import cn.hutool.poi.excel.ExcelUtil;
@@ -63,6 +65,12 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 	 */
 	private static final int GB = 1024 * 1024 * 1024;
 	/**
+	 * 定义GB的计算常量
+	 */
+	public static final String JPG = ".jpg";
+	public static final String SMALL = "_small";
+
+	/**
 	 * 定义MB的计算常量
 	 */
 	private static final int MB = 1024 * 1024;
@@ -142,6 +150,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 		} else if (size / KB >= 1) {
 			// 如果当前Byte的值大于等于1KB
 			resultSize = DF.format(size / (float) KB) + "KB   ";
+			//
 		} else {
 			resultSize = size + "B   ";
 		}
@@ -149,6 +158,35 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 	}
 
 	/**
+	 * 等比例缩放大小,先写死一个,后面优化
+	 */
+	public static float scale(long size) {
+		float scaleSize = 1f;
+		if (size / GB >= 1) {
+			// 如果当前Byte的值大于等于1GB
+			scaleSize = 0.001f;
+		} else if (size / MB >= 1) {
+			// 如果当前Byte的值大于等于1MB
+			scaleSize = 0.1f;
+		} else if (size / KB >= 1) {
+			long kbSize = size / KB;
+			if (kbSize >= 50 && kbSize < 100) {
+				scaleSize = 0.95f;
+			}
+			if (kbSize >= 100 && kbSize < 300) {
+				scaleSize = 0.4f;
+			} else if (kbSize >= 300 && kbSize < 500) {
+				scaleSize = 0.3f;
+			} else if (kbSize >= 500 && kbSize < 700) {
+				scaleSize = 0.2f;
+			} else if (kbSize >= 700 && kbSize <= 1000) {
+				scaleSize = 0.18f;
+			}
+		}
+		return scaleSize;
+	}
+
+	/**
 	 * inputStream 转 File
 	 */
 	static File inputStreamToFile(InputStream ins, String name) {
@@ -206,41 +244,55 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 	/**
 	 * 将文件名解析成文件的上传路径
 	 */
-	public static String uploadFile(MultipartFile file, String filePath) {
+	public static Pair<String, String> uploadFile(MultipartFile file, String filePath) {
 
 		String name = UUIDGenerator.uuid();
 		String suffix = getExtensionName(file.getOriginalFilename());
 		try {
 			String fileName = name + "." + suffix;
 			// getCanonicalFile 可解析正确各种路径
+			String writePath = filePath + fileName;
 			File dest = new File(filePath + fileName).getCanonicalFile();
 			// 文件写入
 			file.transferTo(dest);
-			return fileName;
+
+			String smallPath = name + SMALL + JPG;
+			// 当前小图生成
+			ImgUtil.scale(new File(writePath), new File(filePath + smallPath), scale(writePath.length()));
+			Pair<String, String> p = new Pair<>(fileName, smallPath);
+			return p;
+			//return fileName;
+
 		} catch (Exception e) {
 			log.error(e.getMessage(), e);
 		}
 		return null;
 	}
+
 	/**
 	 * 将文件名解析成文件的上传路径
 	 */
-	public static String uploadFile(byte[] fileBtye, String filePath) {
-
+	public static Pair<String, String> uploadFile(byte[] fileBtye, String filePath) {
 		String name = UUIDGenerator.uuid();
-		String suffix = "jpg";
+//		String suffix = "jpg";
 		try {
-			String fileName = name + "." + suffix;
+			String fileName = name + JPG;
 			// 文件写入
-			OutputStream os = new FileOutputStream(filePath+fileName);
+			String writePath = filePath + fileName;
+			OutputStream os = new FileOutputStream(writePath);
 			os.write(fileBtye);
 			os.close();
-			return fileName;
+			String smallPath = name + SMALL + JPG;
+			// 当前小图生成
+			ImgUtil.scale(new File(writePath), new File(filePath + smallPath), scale(writePath.length()));
+			Pair<String, String> p = new Pair<>(fileName, smallPath);
+			return p;
 		} catch (Exception e) {
 			log.error(e.getMessage(), e);
 		}
 		return null;
 	}
+
 	/**
 	 * 将文件名解析成文件的上传路径
 	 */
@@ -251,7 +303,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 
 		String formatDate = format.format(time);
 		try {
-			String fileRelatePath =  formatDate + "/";
+			String fileRelatePath = formatDate + "/";
 			String createFilePath = filePath + fileRelatePath;
 			// getCanonicalFile 可解析正确各种路径
 			File dest = new File(createFilePath).getCanonicalFile();
@@ -262,7 +314,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 				}
 			}
 			// 文件写入
-			
+
 			return fileRelatePath;
 		} catch (Exception e) {
 			log.error(e.getMessage(), e);
@@ -419,7 +471,11 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 	public static String getMd5(File file) {
 		return getMd5(getByte(file));
 	}
+
 	public static void main(String[] args) {
-		getUploadPath("C:\\eladmin\\file\\");
+		File source = new File("C:\\image\\2daae1b232a442b3975655750d8b1992.jpg");
+//		// getUploadPath("C:\\eladmin\\file\\");
+//		ImgUtil.rotate(new File("C:\\image\\e69ea3343c814e7487cc367b3a3e2cf2.jpg"), -90, new File("C:\\image\\3.jpg"));
+		ImgUtil.scale(source, new File("C:\\image\\2.jpg"), scale(source.length()));
 	}
 }

+ 202 - 21
eladmin-system/src/main/java/me/zhengjie/archives/controller/ArchivesController.java

@@ -1,28 +1,37 @@
 package me.zhengjie.archives.controller;
 
+import java.io.File;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 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.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-
 import org.springframework.web.bind.annotation.RestController;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+
 import me.zhengjie.annotation.rest.AnonymousGetMapping;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.archives.entity.ArchivesEntity;
+import me.zhengjie.archives.entity.FileInfoEntity;
 import me.zhengjie.archives.service.ArchivesService;
+import me.zhengjie.archives.service.FileInfoService;
 import me.zhengjie.archives.vo.ArchivesVo;
+import me.zhengjie.archives.vo.CaseNumVo;
 import me.zhengjie.archives.vo.CasePortraitVo;
-import me.zhengjie.archives.vo.PageResultVo;
 import me.zhengjie.base.ResponseDTO;
+import me.zhengjie.config.FileProperties;
+import me.zhengjie.exception.BadRequestException;
 import me.zhengjie.modules.system.service.DictDetailService;
 
 /**
@@ -40,7 +49,10 @@ public class ArchivesController {
 	DictDetailService dictDetailService;
 	@Autowired
 	ArchivesService archivesService;
-
+	@Autowired
+	FileInfoService fileInfoService;
+	@Autowired
+	private FileProperties properties;
 
 	/**
 	 * 文件和图片
@@ -53,6 +65,17 @@ public class ArchivesController {
 		archivesService.mergeSubmit(archives);
 		return ResponseDTO.success();
 	}
+	/**
+	 * 文件和图片
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	@AnonymousPostMapping("/reMergeSubmit")
+	public ResponseDTO<Map<String, String>> reMergeSubmit(@RequestBody CasePortraitVo archives) throws Exception {
+		archivesService.mergeSubmit(archives);
+		return ResponseDTO.success();
+	}
 
 	/**
 	 * 文件和图片
@@ -61,16 +84,76 @@ public class ArchivesController {
 	 */
 	@AnonymousPostMapping("/save")
 	public ResponseDTO<Map<String, String>> save(@RequestBody ArchivesEntity archives) {
+
 		archives.setCreateBy("1");
 		archives.setUpdateBy("1");
 		archives.setIsDelete("1");
 		archives.setStatus("0");
 		archives.setCreateTime(LocalDateTime.now());
 		archives.setUpdateTime(LocalDateTime.now());
+		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
+		qw.eq("archives_num", archives.getArchivesNum());
+		long result = archivesService.count(qw);
+		if (result >= 1) {
+			// return ResponseDTO.error(ResultCode.ARCHIVES_NUM_ALREADY_EXISTS,
+			// archives.getArchivesNum());
+			throw new BadRequestException(archives.getArchivesNum() + "档案号已存在!");
+		}
+		validateCaseNum(archives);
+//		qw = new QueryWrapper<>();
+//		qw.eq("annual", archives.getAnnual());
+//		qw.eq("catalog_num", archives.getCaseNum());
+//		qw.select("IFNULL(max(case_num),0) caseNum");
+//		Map<String, Object> map = archivesService.getMap(qw);
+//		Object caseNum = map.get("caseNum");
+//		if (caseNum != null) {
+//			if (caseNum.equals("0")) {
+//				String catalogNumYear = "catalog_num_" + archives.getAnnual();
+//				String value = dictDetailService.getLabelValue(catalogNumYear, archives.getCaseNum());
+//				if (value == null) {
+//					throw new BadRequestException("输入年份和目录号在字典不存在默认值。");
+//				}
+//				caseNum = value;
+//			}
+//			int yearMaxCaseNum = Integer.parseInt(caseNum.toString());
+//			int inputCaseNum = Integer.parseInt(archives.getCaseNum());
+//			if (inputCaseNum < yearMaxCaseNum) {
+//				throw new BadRequestException(archives.getAnnual() + "年,输入的值错误,当前最大的案卷号是“" + yearMaxCaseNum + "“");
+//			}
+//
+//		}
+		archives.setId(null);
 		archivesService.save(archives);
 		return ResponseDTO.success();
 	}
 
+	private void validateCaseNum(ArchivesEntity archives) {
+		String year = archives.getAnnual();
+		String catalogNum = archives.getCatalogNum();
+		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
+		qw.eq("annual", year);
+		qw.eq("catalog_num", catalogNum);
+		qw.select("IFNULL(max(case_num),0) caseNum");
+		Map<String, Object> map = archivesService.getMap(qw);
+		Object caseNum = map.get("caseNum");
+		if (caseNum != null) {
+			if (caseNum.equals("0")) {
+				String catalogNumYear = "catalog_num_" + year;
+				String value = dictDetailService.getLabelValue(catalogNumYear, catalogNum);
+				if (value == null) {
+					throw new BadRequestException("输入年份和目录号在字典不存在默认值。");
+				}
+				caseNum = value;
+			}
+			int yearMaxCaseNum = Integer.parseInt(caseNum.toString());
+			int inputCaseNum = Integer.parseInt(archives.getCaseNum());
+			if (inputCaseNum < yearMaxCaseNum) {
+				throw new BadRequestException("当前" + archives.getAnnual() + "年,最大的案卷号是“" + yearMaxCaseNum + "“");
+			}
+
+		}
+	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -78,13 +161,90 @@ public class ArchivesController {
 	 */
 	@AnonymousPostMapping("/edit")
 	public ResponseDTO<ArchivesEntity> edit(@RequestBody ArchivesEntity archives) {
-		ArchivesEntity entity = new ArchivesEntity();
-		//entity = archivesService.getById(archives.getId());
+
+		ArchivesEntity entity = archivesService.getById(archives.getId());
+		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
+		qw.ne("archives_num", entity.getArchivesNum());
+		qw.eq("archives_num", archives.getArchivesNum());
+
+		long result = archivesService.count(qw);
+		// 过来掉自己
+		if (result >= 1) {
+			// return ResponseDTO.error(ResultCode.ARCHIVES_NUM_ALREADY_EXISTS,
+			// archives.getArchivesNum());
+			throw new BadRequestException(archives.getArchivesNum() + "档案号已存在!");
+		}
+		// 验证案卷号是否正确
+		// validateCaseNum(archives);
 		archivesService.updateById(archives);
-		// String	previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
-		// entity.setPdfPath(previewPath + entity.getPdfPath());
-		return ResponseDTO.success(entity);
+
+		return ResponseDTO.success();
 	}
+
+	/**
+	 * 文件和图片
+	 *
+	 * @return
+	 */
+	@AnonymousPostMapping("/redo")
+	public ResponseDTO<Map<String, Object>> redo(@RequestBody ArchivesEntity archives) {
+
+		ArchivesEntity entity = archivesService.getById(archives.getId());
+		String imageJson = entity.getImageJson();
+		List<JSONObject> jsonObjs = new ArrayList<>();
+		List<String> pages = new ArrayList<>();
+		if (StringUtils.isNotBlank(imageJson)) {
+			CasePortraitVo caseVo = JSONObject.parseObject(imageJson, CasePortraitVo.class);
+			List<String> imageIds = caseVo.getImageIds();
+			List<FileInfoEntity> fileInfo = fileInfoService.listByIds(imageIds);
+			Map<String, String> fileInfoMap = new HashMap<>();
+			for (FileInfoEntity file : fileInfo) {
+				fileInfoMap.put(file.getId(), file.getPath());
+			}
+			String previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
+			for (String imageId : imageIds) {
+				JSONObject json = new JSONObject();
+				json.put("imageId", imageId);
+				json.put("filePath", previewPath + fileInfoMap.get(imageId));
+				jsonObjs.add(json);
+			}
+			pages = caseVo.getPages();
+		}
+
+		Map<String, Object> result = new HashMap<>();
+		result.put("imageList", jsonObjs);
+		result.put("pages", pages);
+
+		return ResponseDTO.success(result);
+	}
+
+	/**
+	 * 文件和图片
+	 *
+	 * @return
+	 */
+	@AnonymousPostMapping("/caseNum")
+	public ResponseDTO<Object> caseNum(@RequestBody CaseNumVo caseNumVo) {
+		String year = caseNumVo.getYear();
+		String catalogNum = caseNumVo.getCatalogNum();
+
+		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
+		qw.eq("annual", year);
+		qw.eq("catalog_num", catalogNum);
+		qw.select("IFNULL(max(case_num),0) caseNum");
+		Map<String, Object> map = archivesService.getMap(qw);
+		Object caseNum = map.get("caseNum");
+		if (map == null || caseNum.equals("0")) {
+			String catalogNumYear = "catalog_num_" + year;
+			String value = dictDetailService.getLabelValue(catalogNumYear, catalogNum);
+			if (value == null) {
+				throw new BadRequestException("输入年份和目录号在字典不存在默认值。");
+			}
+			return ResponseDTO.success(Integer.valueOf(value) + 1);
+		}
+		return ResponseDTO.success(Integer.valueOf(caseNum.toString()) + 1);
+	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -94,13 +254,14 @@ public class ArchivesController {
 	public ResponseDTO<ArchivesEntity> detail(@RequestBody ArchivesVo archives) {
 		ArchivesEntity entity = new ArchivesEntity();
 		entity = archivesService.getById(archives.getId());
-		if(entity.getStatus().equalsIgnoreCase("1")) {
-			
+		if (entity.getStatus().equalsIgnoreCase("1")) {
+
 		}
-		 String	previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
-		 entity.setPdfPath(previewPath + entity.getPdfPath());
+		String previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
+		entity.setPdfPath(previewPath + entity.getPdfPath());
 		return ResponseDTO.success(entity);
 	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -109,15 +270,35 @@ public class ArchivesController {
 	@AnonymousPostMapping("/delete")
 	public ResponseDTO<ArchivesEntity> delete(@RequestBody List<String> id) {
 
-		List<ArchivesEntity> list = new ArrayList<ArchivesEntity>();
-		for (int i = 0; i < id.size(); i++) {
-			ArchivesEntity entity = new ArchivesEntity();
-			entity.setId(Long.valueOf(id.get(i)));
-			entity.setIsDelete("0");
-			list.add(entity);
-		}
+//		List<ArchivesEntity> list = new ArrayList<ArchivesEntity>();
+//		for (int i = 0; i < id.size(); i++) {
+//			ArchivesEntity entity = new ArchivesEntity();
+//			entity.setId(Long.valueOf(id.get(i)));
+//			entity.setIsDelete("0");
+//			list.add(entity);
+//		}
+		// 先删除图片,
+		QueryWrapper<FileInfoEntity> qw = new QueryWrapper<>();
+		qw.in("loan_no", id);
+		List<FileInfoEntity> fileInfos = fileInfoService.list(qw);
+		List<String> fileIds = new ArrayList<>();
+		List<String> filePath = new ArrayList<>();
+
+		// FileUtils.forceDelete(arg0);
+		String path = properties.getPath().getPath();
+
+		for (FileInfoEntity f : fileInfos) {
+			fileIds.add(f.getId());
+			filePath.add(path + f.getPath());
+			filePath.add(path + f.getSmallPath());
 
-		archivesService.updateBatchById(list);
+		}
+		for (String imagePath : filePath) {
+			FileUtils.deleteQuietly(new File(imagePath));
+		}
+		fileInfoService.removeBatchByIds(fileIds);
+		archivesService.removeByIds(id);
+		//
 		return ResponseDTO.success();
 	}
 
@@ -128,7 +309,7 @@ public class ArchivesController {
 	 */
 	@AnonymousGetMapping("/list")
 	public ResponseEntity<Object> list(ArchivesVo archives, Pageable pageable) {
-		
+
 		archives.setIndex(pageable.getPageNumber());
 		archives.setSize(pageable.getPageSize());
 		Map<String, Object> map = archivesService.page(archives);

+ 52 - 4
eladmin-system/src/main/java/me/zhengjie/archives/controller/FileInfoController.java

@@ -1,25 +1,37 @@
 package me.zhengjie.archives.controller;
 
+import java.io.File;
 import java.util.List;
-import java.util.Map;
 
+import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import cn.hutool.core.img.ImgUtil;
 import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.archives.dto.FilePreviewDto;
+import me.zhengjie.archives.entity.FileInfoEntity;
 import me.zhengjie.archives.service.FileInfoService;
 import me.zhengjie.archives.vo.FileUploadVO;
 import me.zhengjie.base.ResponseDTO;
+import me.zhengjie.config.FileProperties;
+import me.zhengjie.modules.system.service.DictDetailService;
+import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.UUIDGenerator;
 
 @RestController
 @RequestMapping("/api/fileInfo")
 public class FileInfoController {
 	@Autowired
 	private FileInfoService fileInfoService;
+	@Autowired
+	DictDetailService dictDetailService;
+	@Autowired
+	private FileProperties properties;
+
 	/**
 	 * 文件和图片
 	 *
@@ -27,9 +39,10 @@ public class FileInfoController {
 	 */
 	@AnonymousPostMapping("/uploadFiles")
 	public ResponseDTO<List<FilePreviewDto>> uploadFiles(MultipartFile[] files) {
-		 
+
 		return ResponseDTO.success(fileInfoService.getFilePath(files));
 	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -37,8 +50,43 @@ public class FileInfoController {
 	 */
 	@AnonymousPostMapping("/uploadBase64")
 	public ResponseDTO<List<FilePreviewDto>> uploadBase64(@RequestBody FileUploadVO fileVo) {
-		
-		//;
+
+		// ;
 		return ResponseDTO.success(fileInfoService.getFilePath(fileVo.getFiles()));
 	}
+
+	/**
+	 * 文件和图片
+	 *
+	 * @return
+	 */
+	@AnonymousPostMapping("/rotate")
+	public ResponseDTO<FilePreviewDto> uploadFiles(@RequestBody FileUploadVO fileVo) {
+		String previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
+		FileInfoEntity entity = fileInfoService.getById(fileVo.getId());
+		String path = properties.getPath().getPath();
+		String name = UUIDGenerator.uuid();
+		String filePath = FileUtil.getUploadPath(path);
+		String fileName = filePath + name;
+		String targetPath = fileName + FileUtil.JPG;
+		String smallPath = fileName + FileUtil.SMALL + FileUtil.JPG;
+		File sourceFile = new File(path + entity.getPath());
+		File sourceSmall = new File(path + entity.getSmallPath());
+		ImgUtil.rotate(sourceFile, fileVo.getDegree(), new File(path + targetPath));
+		ImgUtil.rotate(sourceSmall, fileVo.getDegree(), new File(path + smallPath));
+		// 删除文件
+		FileUtils.deleteQuietly(sourceFile);
+		FileUtils.deleteQuietly(sourceSmall);
+		FilePreviewDto filePreview = new FilePreviewDto();
+		filePreview.setFileId(fileVo.getId());
+		filePreview.setFileUrl(previewPath + targetPath);
+		filePreview.setSmallUrl(previewPath + smallPath);
+		// 更新数据
+		FileInfoEntity fileInfo = new FileInfoEntity();
+		fileInfo.setId(fileVo.getId());
+		fileInfo.setPath(targetPath);
+		fileInfo.setSmallPath(smallPath);
+		return ResponseDTO.success(filePreview);
+	}
+
 }

+ 1 - 0
eladmin-system/src/main/java/me/zhengjie/archives/dto/FilePreviewDto.java

@@ -10,4 +10,5 @@ import lombok.ToString;
 public class FilePreviewDto {
 	private String fileId;
 	private String fileUrl;
+	private String smallUrl;
 }

+ 214 - 206
eladmin-system/src/main/java/me/zhengjie/archives/entity/ArchivesEntity.java

@@ -26,210 +26,218 @@ import java.time.LocalDateTime;
 @Setter
 public class ArchivesEntity implements Serializable {
 
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * 主键
-     */
-    @TableId(value = "id", type = IdType.AUTO)
-    private Long id;
-
-    /**
-     * 案卷类型
-     */
-    @TableField("dossier_type")
-    private String dossierType;
-    /**
-     * 档案号
-     */
-    @QueryWapper({QueryKeyword.LIKE})
-    @TableField("archives_num")
-    private String archivesNum;
-    /**
-          * 卷宗号
-     */
-    @QueryWapper({QueryKeyword.LIKE})
-    @TableField("dossier_num")
-    private String dossierNum;
-    /**
-          * 公证类型
-     */
-    @TableField("notarization_type")
-    private String notarizationType;
-
-    /**
-     *  公证事项
-     */
-    @TableField("notarized_item")
-    private String notarizedItem;
-
-    /**
-     * 公证书编号
-     */
-    @TableField("notarial_num")
-    private String notarialNum;
-
-    /**
-     * 公证员
-     */
-    @TableField("notary")
-    private String notary;
-
-    /**
-     * 当事人姓名
-     */
-    @QueryWapper({QueryKeyword.LIKE})
-    @TableField("party_name")
-    private String partyName;
-
-    /**
-     * 受理号
-     */
-    @TableField("accept_num")
-    private String acceptNum;
-
-    /**
-     *  承办人
-     */
-    @TableField("undertaker")
-    private String undertaker;
-
-    /**
-     * 年度
-     */
-    @TableField("annual")
-    private String annual;
-
-    /**
-     * 受理日期
-     */
-    @TableField("accept_date")
-    private String acceptDate;
-
-    /**
-     * 办结日期
-     */
-    @TableField("complete_date")
-    private String completeDate;
-
-    /**
-     * 归档日期
-     */
-    @TableField("filing_date")
-    private String filingDate;
-
-    /**
-     * 保密类型0:非密卷,1:密卷
-     */
-    @TableField("secrecy_type")
-    private String secrecyType;
-
-    /**
-     * 保管期限,1:永久,2:长期 3:短期
-     */
-    @TableField("save_term")
-    private String saveTerm;
-
-    /**
-     * 公证处名称
-     */
-    @TableField("notary_full_name")
-    private String notaryFullName;
-
-    /**
-     * 目录号
-     */
-    @TableField("catalog_num")
-    private String catalogNum;
-
-    /**
-     * 案卷号
-     */
-    @TableField("case_num")
-    private String caseNum;
-
-    /**
-     * 全宗号
-     */
-    @TableField("fonds_num")
-    private String fondsNum;
-
-    /**
-     * 盒号
-     */
-    @TableField("box_num")
-    private String boxNum;
-    /**
-     * 盒号
-     */
-    @TableField("pdf_path")
-    private String pdfPath;
-    /**
-     * 状态,0未扫描,1已提交
-     */
-    @TableField("status")
-    private String status;
-
-    /**
-     * 创建者
-     */
-    @TableField("create_by")
-    private String createBy;
-
-    /**
-     * 更新者
-     */
-    @TableField("update_by")
-    private String updateBy;
-
-    /**
-     * 创建日期
-    
-     */
-    @QueryWapper({QueryKeyword.DESC})
-    @TableField("create_time")
-    private LocalDateTime createTime;
-
-    /**
-     * 更新时间
-     */
-    @TableField("update_time")
-    private LocalDateTime updateTime;
-
-    /**
-     * 更新时间
-     */
-    @TableField("is_delete")
-    private String isDelete;
- 
-    @Override
-    public String toString() {
-        return "ArchivesEntity{" +
-        "id=" + id +
-        ", dossierType=" + dossierType +
-        ", notarizationType=" + notarizationType +
-        ", notarizedItem=" + notarizedItem +
-        ", notarialNum=" + notarialNum +
-        ", notary=" + notary +
-        ", partyName=" + partyName +
-        ", acceptNum=" + acceptNum +
-        ", undertaker=" + undertaker +
-        ", annual=" + annual +
-        ", acceptDate=" + acceptDate +
-        ", completeDate=" + completeDate +
-        ", filingDate=" + filingDate +
-        ", secrecyType=" + secrecyType +
-        ", saveTerm=" + saveTerm +
-        ", notaryFullName=" + notaryFullName +
-        ", catalogNum=" + catalogNum +
-        ", caseNum=" + caseNum +
-        ", fondsNum=" + fondsNum +
-        ", boxNum=" + boxNum +
-        ", status=" + status +
-        ", createBy=" + createBy +
-        ", updateBy=" + updateBy +
-        ", createTime=" + createTime +
-        ", updateTime=" + updateTime +
-        "}";
-    }
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键
+	 */
+	@TableId(value = "id", type = IdType.AUTO)
+	private Long id;
+
+	/**
+	 * 案卷类型
+	 */
+	@TableField("dossier_type")
+	private String dossierType;
+	/**
+	 * 档案号
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("archives_num")
+	private String archivesNum;
+	/**
+	 * 卷宗号
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("dossier_num")
+	private String dossierNum;
+	/**
+	 * 公证类型
+	 */
+	@TableField("notarization_type")
+	private String notarizationType;
+
+	/**
+	 * 公证事项
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("notarized_item")
+	private String notarizedItem;
+
+	/**
+	 * 公证书编号
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("notarial_num")
+	private String notarialNum;
+
+	/**
+	 * 公证员
+	 */
+	@TableField("notary")
+	private String notary;
+
+	/**
+	 * 当事人姓名
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("party_name")
+	private String partyName;
+
+	/**
+	 * 受理号
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("accept_num")
+	private String acceptNum;
+
+	/**
+	 * 承办人
+	 */
+	@QueryWapper({ QueryKeyword.LIKE })
+	@TableField("undertaker")
+	private String undertaker;
+
+	/**
+	 * 年度
+	 */
+	@TableField("annual")
+	private String annual;
+
+	/**
+	 * 受理日期
+	 */
+	@QueryWapper(attribute = { "startTime", "endTime" }, value = { QueryKeyword.RANGE })
+	@TableField("accept_date")
+	private String acceptDate;
+
+	/**
+	 * 办结日期
+	 */
+	@TableField("complete_date")
+	private String completeDate;
+
+	/**
+	 * 归档日期
+	 */
+	@TableField("filing_date")
+	private String filingDate;
+
+	/**
+	 * 保密类型0:非密卷,1:密卷
+	 */
+	@TableField("secrecy_type")
+	private String secrecyType;
+
+	/**
+	 * 保管期限,1:永久,2:长期 3:短期
+	 */
+	@TableField("save_term")
+	private String saveTerm;
+
+	/**
+	 * 公证处名称
+	 */
+	@TableField("notary_full_name")
+	private String notaryFullName;
+
+	/**
+	 * 目录号
+	 */
+	@TableField("catalog_num")
+	private String catalogNum;
+
+	/**
+	 * 案卷号
+	 */
+	@TableField("case_num")
+	private String caseNum;
+
+	/**
+	 * 全宗号
+	 */
+	@TableField("fonds_num")
+	private String fondsNum;
+
+	/**
+	 * 盒号
+	 */
+	@TableField("box_num")
+	private String boxNum;
+	/**
+	 * 盒号
+	 */
+	@TableField("pdf_path")
+	private String pdfPath;
+	/**
+	 * 状态,0未扫描,1已提交
+	 */
+	@TableField("status")
+	private String status;
+
+	/**
+	 * 创建者
+	 */
+	@TableField("create_by")
+	private String createBy;
+
+	/**
+	 * 更新者
+	 */
+	@TableField("update_by")
+	private String updateBy;
+
+	/**
+	 * 创建日期
+	 * 
+	 */
+	@QueryWapper({ QueryKeyword.DESC })
+	@TableField("create_time")
+	private LocalDateTime createTime;
+
+	/**
+	 * 更新时间
+	 */
+	@TableField("update_time")
+	private LocalDateTime updateTime;
+
+	/**
+	 * 更新时间
+	 */
+	@TableField("is_delete")
+	private String isDelete;
+	/**
+	 * 图片清理中
+	 */
+	@TableField("is_clean")
+	private String isClean;
+	/**
+	 * 重做的次数
+	 */
+	@TableField("redo_count")
+	private Integer redoCount;
+	/**
+	 * 清理的值
+	 */
+	@TableField("clean_count")
+	private Integer cleanCount;
+	
+	
+	/**
+	 * 更新时间
+	 */
+	@TableField("image_json")
+	private String imageJson;
+
+	@Override
+	public String toString() {
+		return "ArchivesEntity{" + "id=" + id + ", dossierType=" + dossierType + ", notarizationType="
+				+ notarizationType + ", notarizedItem=" + notarizedItem + ", notarialNum=" + notarialNum + ", notary="
+				+ notary + ", partyName=" + partyName + ", acceptNum=" + acceptNum + ", undertaker=" + undertaker
+				+ ", annual=" + annual + ", acceptDate=" + acceptDate + ", completeDate=" + completeDate
+				+ ", filingDate=" + filingDate + ", secrecyType=" + secrecyType + ", saveTerm=" + saveTerm
+				+ ", notaryFullName=" + notaryFullName + ", catalogNum=" + catalogNum + ", caseNum=" + caseNum
+				+ ", fondsNum=" + fondsNum + ", boxNum=" + boxNum + ", status=" + status + ", createBy=" + createBy
+				+ ", updateBy=" + updateBy + ", createTime=" + createTime + ", updateTime=" + updateTime + "}";
+	}
 }

+ 11 - 55
eladmin-system/src/main/java/me/zhengjie/archives/entity/FileInfoEntity.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 
+import lombok.Getter;
+import lombok.Setter;
 import lombok.ToString;
 
 import java.io.Serializable;
@@ -20,6 +22,8 @@ import java.time.LocalDateTime;
  */
 @TableName("file_info")
 @ToString
+@Getter
+@Setter
 public class FileInfoEntity implements Serializable {
 
 	private static final long serialVersionUID = 1L;
@@ -32,13 +36,18 @@ public class FileInfoEntity implements Serializable {
 
 	@TableField("file_name")
 	private String fileName;
-
+	@TableField("loan_no")
+	private String loanNo;
 	/**
 	 * oss存储路径
 	 */
 	@TableField("path")
 	private String path;
-
+	/**
+	 * oss存储路径
+	 */
+	@TableField("small_path")
+	private String smallPath;
 	/**
 	 * 文件状态 1-可用,0-废弃
 	 */
@@ -51,58 +60,5 @@ public class FileInfoEntity implements Serializable {
 	@TableField("update_time")
 	private LocalDateTime updateTime;
 
-	public String getId() {
-		return id;
-	}
-
-	public FileInfoEntity setId(String id) {
-		this.id = id;
-		return this;
-	}
-
-	public String getFileName() {
-		return fileName;
-	}
-
-	public FileInfoEntity setFileName(String fileName) {
-		this.fileName = fileName;
-		return this;
-	}
-
-	public String getPath() {
-		return path;
-	}
-
-	public FileInfoEntity setPath(String path) {
-		this.path = path;
-		return this;
-	}
-
-	public Integer getStatus() {
-		return status;
-	}
-
-	public FileInfoEntity setStatus(Integer status) {
-		this.status = status;
-		return this;
-	}
-
-	public LocalDateTime getCreateTime() {
-		return createTime;
-	}
-
-	public FileInfoEntity setCreateTime(LocalDateTime createTime) {
-		this.createTime = createTime;
-		return this;
-	}
-
-	public LocalDateTime getUpdateTime() {
-		return updateTime;
-	}
-
-	public FileInfoEntity setUpdateTime(LocalDateTime updateTime) {
-		this.updateTime = updateTime;
-		return this;
-	}
 
 }

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

@@ -205,8 +205,8 @@ public interface AbstractService<T> extends IService<T> {
 	 * @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);
+	default <E extends IPage<T>> E page(E page, T t,QueryMap... jsonObj) {
+		Wrapper<T> queryWrapper = QueryWrapperUtil.convertQuery(t,jsonObj);
 		try {
 			return page(page, queryWrapper);
 		} catch (Exception e) {

+ 4 - 3
eladmin-system/src/main/java/me/zhengjie/archives/plus/QueryMapUtil.java

@@ -1,9 +1,10 @@
 package me.zhengjie.archives.plus;
 
+import java.util.HashMap;
 import java.util.Map;
 
-public class QueryMapUtil {
-	Map<String, Object> map;
+public class QueryMap {
+	Map<String, Object> map=new HashMap<>();
 
 	public Map<String, Object> getMap() {
 		return map;
@@ -13,7 +14,7 @@ public class QueryMapUtil {
 		this.map = map;
 	}
 
-	public QueryMapUtil() {
+	public QueryMap() {
 
 	}
 

+ 3 - 3
eladmin-system/src/main/java/me/zhengjie/archives/plus/QueryWrapperUtil.java

@@ -46,9 +46,9 @@ public class QueryWrapperUtil {
 	 * @return void 返回参数说明
 	 * @exception/throws
 	 */
-	public static <T> QueryWrapper<T> convertQuery(Object obj, QueryMapUtil... jsonObj) {
-		Map<String, Object> param = new JSONObject();
-		if (ArrayUtils.isNotEmpty(jsonObj)) {
+	public static <T> QueryWrapper<T> convertQuery(Object obj, QueryMap... jsonObj) {
+		Map<String, Object> param = new HashMap<>();
+		if (jsonObj!=null && jsonObj[0]!=null) {
 
 			param = jsonObj[0].getMap();
 		}

+ 195 - 40
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ArchivesServiceImpl.java

@@ -3,15 +3,22 @@ package me.zhengjie.archives.service.impl;
 import java.io.File;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
@@ -21,18 +28,18 @@ import me.zhengjie.archives.entity.ArchivesEntity;
 import me.zhengjie.archives.entity.FileInfoEntity;
 import me.zhengjie.archives.entity.ModelEntity;
 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.HtmlConvertPdf;
 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.base.ResponseDTO;
 import me.zhengjie.config.FileProperties;
 import me.zhengjie.modules.system.service.DictDetailService;
 import me.zhengjie.utils.BeanCopyUtils;
+import me.zhengjie.utils.DateUtil;
 import me.zhengjie.utils.FileUtil;
 import me.zhengjie.utils.PageUtil;
 import me.zhengjie.utils.UUIDGenerator;
@@ -54,7 +61,16 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		IPage<ArchivesEntity> page = new Page<>(req.getIndex(), req.getSize());
 		ArchivesEntity entity = BeanCopyUtils.convertObj(req, ArchivesEntity.class);
 		entity.setIsDelete("1");
-		page = page(page, entity);
+		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("-", ""));
+			queryMap.setMap(map);
+		}
+
+		page = page(page, entity, queryMap);
 		String previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
 
 		for (ArchivesEntity archive : page.getRecords()) {
@@ -75,9 +91,9 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		String fileRelatePath = FileUtil.getUploadPath(path);
 		String filePath = path + fileRelatePath;
 		String pageHtml = model.getContent();
-		
-		ArchivesEntity archive=this.getById(archives.getId());
-		
+
+		ArchivesEntity archive = this.getById(archives.getId());
+
 		pageHtml.replace("{{notarialNum}}", archive.getNotarialNum());
 		pageHtml.replace("{{notarizedItem}}", archive.getNotarizedItem());
 		pageHtml.replace("{{partyName}}", archive.getPartyName());
@@ -158,28 +174,66 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 	}
 
 	public void image(CasePortraitVo archives) throws Exception {
-
+		// 查询对应的值
+		ArchivesEntity entity = this.getById(archives.getId());
+		// 保管期限
+		String saveTerm = dictDetailService.getLabelByValue("saveTerm_type", entity.getSaveTerm());
+		// 案卷类型
+		// String dossierType=
+		// dictDetailService.getValueByName("dossier_type").get(entity.getDossierType());
+		// TODO 当事人很多,需要修改字体-------------------页号开始------------------------
 		QueryWrapper<ModelEntity> queryWrapper = new QueryWrapper<ModelEntity>();
 		queryWrapper.eq("code", 1);
 		ModelEntity model = modelDao.selectOne(queryWrapper);
 		String path = properties.getPath().getPath();
 		String fileRelatePath = FileUtil.getUploadPath(path);
 		String filePath = path + fileRelatePath;
-		String html = model.getContent();
+		String headPageHtml = model.getContent();
+		// 替换内容
+		headPageHtml = headPageHtml.replace("${year}", entity.getAnnual())
+				.replace("${notarialNum}", entity.getNotarialNum())
+				.replace("${notarizedItem}", entity.getNotarizedItem()).replace("${partyName}", entity.getPartyName())
+				.replace("${undertaker}", entity.getUndertaker()).replace("${notary}", entity.getNotary())
+				.replace("${undertaker}", entity.getUndertaker())
+				.replace("${acceptDate}", DateUtil.format(entity.getAcceptDate()))
+				.replace("${completeDate}", DateUtil.format(entity.getCompleteDate()))
+				.replace("${filingDate}", DateUtil.format(entity.getFilingDate())).replace("${saveTerm}", saveTerm)
+				.replace("${dossierNum}", entity.getDossierNum()).replace("${acceptNum}", entity.getAcceptNum())
+				.replace("${fondsNum}", entity.getFondsNum()).replace("${catalogNum}", entity.getCatalogNum())
+				.replace("${caseNum}", entity.getCaseNum())
+
+		;
+
+		String headPagePath = filePath + UUIDGenerator.uuid() + ".html";
+		String headPageToImage = filePath + UUIDGenerator.uuid() + ".jpg";
+		// 先写入文本
+		FileUtil.writeUtf8String(headPageHtml, headPagePath);
+		// 然后生成jpg
+		String exePath = dictDetailService.getValueByName("file_path").get("exe_path");
+		HtmlToImage.htmlToImg(exePath, headPagePath, headPageToImage);
+		// -------------------页号结束------------------------
+		// --------------------目录号开始---------
+		queryWrapper = new QueryWrapper<ModelEntity>();
+		queryWrapper.eq("code", 2);
+		model = modelDao.selectOne(queryWrapper);
+
+		String catalogHtml = model.getContent();
 		int j = 0;
 		List<String> pages = archives.getPages();
 		for (int i = 0; i < pages.size(); i++) {
 			j = i + 1;
-			html = html.replace("${num" + j + "}", pages.get(i));
+			catalogHtml = catalogHtml.replace("${num" + j + "}", pages.get(i));
 		}
 
-		String htmlPath = filePath + UUIDGenerator.uuid() + ".html";
-		String htmlToImage = filePath + UUIDGenerator.uuid() + ".jpg";
+		String catalogPath = filePath + UUIDGenerator.uuid() + ".html";
+		String catalogToImage = filePath + UUIDGenerator.uuid() + ".jpg";
 		// 先写入文本
-		FileUtil.writeUtf8String(html, htmlPath);
+		FileUtil.writeUtf8String(catalogHtml, catalogPath);
 		// 然后生成jpg
-		String exePath = dictDetailService.getValueByName("file_path").get("exe_path");
-		HtmlToImage.htmlToImg(exePath, htmlPath, htmlToImage);
+		// String exePath =
+		// dictDetailService.getValueByName("file_path").get("exe_path");
+		HtmlToImage.htmlToImg(exePath, catalogPath, catalogToImage);
+		// ------------------------目录号结束
 		// HtmlConvertPdf.createPdfFile(html, htmlToPdf);
 		List<String> imageIds = archives.getImageIds();
 		List<FileInfoEntity> fileInfos = fileInfoService.listByIds(imageIds);
@@ -188,12 +242,13 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 			map.put(fileInfo.getId(), fileInfo.getPath());
 		}
 		List<File> files = new ArrayList<File>();
-		// 封面放在第一位
-		files.add(new File(htmlToImage));
+		// 页头第一个
+		files.add(new File(headPageToImage));
+		// 目录放在第二个
+		files.add(new File(catalogToImage));
 		for (String str : imageIds) {
 			files.add(new File(path + map.get(str)));
 		}
-
 		String fileName = "merge_pdf" + UUIDGenerator.uuid() + ".pdf";
 		String toPdfTarget = filePath + fileName;
 		// pdf进行合并
@@ -209,37 +264,137 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		ArchivesEntity archiveEntity = new ArchivesEntity();
 		archiveEntity.setId(archives.getId());
 		archiveEntity.setPdfPath(fileRelatePath + fileName);
+		archiveEntity.setImageJson(JSON.toJSONString(archives));
+		if (StringUtils.isNotBlank(archives.getIsRedo()) && archives.getIsRedo().equals("1")) {
+			int redoCount = entity.getRedoCount() == null ? 0 : entity.getRedoCount() + 1;
+			archiveEntity.setRedoCount(redoCount);
+		}
 		archiveEntity.setStatus("1");
+		// archiveEntity.set
 		this.updateById(archiveEntity);
+		// 将图片id和档案绑定
+		// Wrapper<FileInfoEntity> updateWrapper
+
+		UpdateWrapper<FileInfoEntity> updateWrapper = new UpdateWrapper<>();
+		updateWrapper.in("id", imageIds);
+		updateWrapper.set("loan_no", archives.getId());
+
+		this.fileInfoService.update(updateWrapper);
 
 	}
-	public void print(CasePortraitVo archives) throws Exception {
-		String path = properties.getPath().getPath();
-		String fileRelatePath = FileUtil.getUploadPath(path);
-		String filePath = path + fileRelatePath;
 
-		List<String> imageIds = archives.getImageIds();
-		List<FileInfoEntity> fileInfos = fileInfoService.listByIds(imageIds);
-		Map<String, String> map = new HashMap<String, String>();
-		for (FileInfoEntity fileInfo : fileInfos) {
-			map.put(fileInfo.getId(), fileInfo.getPath());
-		}
-		List<File> files = new ArrayList<File>();
-		for (String str : imageIds) {
-			files.add(new File(path + map.get(str)));
-		}
-		String fileName = "merge_pdf" + UUIDGenerator.uuid() + ".pdf";
-		String toPdfTarget = filePath + fileName;
-		// pdf进行合并
-		PdfUtils.manyImageToOnePdf(files, toPdfTarget);
+//	public void print(CasePortraitVo archives) throws Exception {
+//		String path = properties.getPath().getPath();
+//		String fileRelatePath = FileUtil.getUploadPath(path);
+//		String filePath = path + fileRelatePath;
+//
+//		List<String> imageIds = archives.getImageIds();
+//		List<FileInfoEntity> fileInfos = fileInfoService.listByIds(imageIds);
+//		Map<String, String> map = new HashMap<String, String>();
+//		for (FileInfoEntity fileInfo : fileInfos) {
+//			map.put(fileInfo.getId(), fileInfo.getPath());
+//		}
+//		List<File> files = new ArrayList<File>();
+//		for (String str : imageIds) {
+//			files.add(new File(path + map.get(str)));
+//		}
+//		String fileName = "merge_pdf" + UUIDGenerator.uuid() + ".pdf";
+//		String toPdfTarget = filePath + fileName;
+//		// pdf进行合并
+//		PdfUtils.manyImageToOnePdf(files, toPdfTarget);
+//		ArchivesEntity archiveEntity = new ArchivesEntity();
+//		archiveEntity.setId(archives.getId());
+//		archiveEntity.setPdfPath(fileRelatePath + fileName);
+//		archiveEntity.setStatus("1");
+//		this.updateById(archiveEntity);
+//
+//	}
+
+	public void mergeSubmit(CasePortraitVo archives) throws Exception {
 		ArchivesEntity archiveEntity = new ArchivesEntity();
 		archiveEntity.setId(archives.getId());
-		archiveEntity.setPdfPath(fileRelatePath + fileName);
-		archiveEntity.setStatus("1");
-		this.updateById(archiveEntity);
+		archiveEntity.setStatus("2");
+		image(archives);
+	}
+
+	/**
+	 * 删除没有用到的图片,
+	 */
+	public void deleteNoUserImage() {
+		String path = properties.getPath().getPath();
+		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
+		qw.eq("status", 1);
+		qw.eq("is_clean", 0);
+		qw.apply("redo_count != clean_count");
+		int i = 1;
+		while (true) {
+			qw.last("limit" + 10 * i);
+			List<ArchivesEntity> archives = this.list(qw);
+			for (ArchivesEntity a : archives) {
+				ArchivesEntity deleteImagePre = new ArchivesEntity();
+				deleteImagePre.setId(a.getId());
+				deleteImagePre.setIsClean("1");
+				this.updateById(deleteImagePre);
+				if (StringUtils.isNotBlank(a.getImageJson())) {
+					// 处理图片中,
+					CasePortraitVo casePort = JSONObject.parseObject(a.getImageJson(), CasePortraitVo.class);
+					List<String> imageIds = casePort.getImageIds();
+					// 查询id的值
+					FileInfoEntity fileInfo = new FileInfoEntity();
+					// 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);
+					List<String> allFileIds = new ArrayList<>();
+					Map<String, FileInfoEntity> map = new HashMap<>();
 
+					for (FileInfoEntity fi : fileInfos) {
+						map.put(fi.getId(), fi);
+						allFileIds.add(fi.getId());
+					}
+					Collection<String> intersection = CollectionUtils.intersection(allFileIds, imageIds);
+					// 开始删除数据
+					if (CollectionUtils.isNotEmpty(intersection)) {
+						for (String imagePath : intersection) {
+							FileInfoEntity fileInfoEntity = map.get(imagePath);
+							FileUtils.deleteQuietly(new File(path + fileInfoEntity.getPath()));
+							FileUtils.deleteQuietly(new File(path + fileInfoEntity.getSmallPath()));
+
+						}
+					}
+					ArchivesEntity deleteImageAfter = new ArchivesEntity();
+					deleteImageAfter.setId(a.getId());
+					deleteImageAfter.setIsClean("0");
+					deleteImageAfter.setCleanCount(a.getRedoCount());
+					this.updateById(deleteImageAfter);
+				}
+			}
+
+		}
 	}
-	public void mergeSubmit(CasePortraitVo archives) throws Exception {
-		print(archives);
+
+	public static void main(String[] args) {
+		// 声明一个List集合
+		List<Student> list = new ArrayList<>();
+		list.add(new Student());
+		list.add(new Student());
+		list.add(new Student());
+		list.add(new Student());
+
+		// 将list转map 【key为1个属性,value为对象本身】 (map的键去重)
+
+		list.stream().collect(Collectors.toMap(Student::getNo, obj -> obj, (key1, key2) -> key1));
+
 	}
 }
+
+class Student {
+	String no; // 学号
+	String name; // 姓名
+	// 构造方法忽略
+	// set、get 方法忽略
+
+	String getNo() {
+		return "";
+	}
+}

+ 12 - 6
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/FileInfoServiceImpl.java

@@ -15,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import cn.hutool.core.lang.Pair;
 import me.zhengjie.archives.dao.IFileInfoDao;
 import me.zhengjie.archives.dto.FilePreviewDto;
 import me.zhengjie.archives.entity.FileInfoEntity;
@@ -56,14 +57,16 @@ public class FileInfoServiceImpl extends AbstractServiceImpl<IFileInfoDao, FileI
 		for (int i = 0; i < files.length; i++) {
 			FilePreviewDto filePreviewDto = new FilePreviewDto();
 			FileInfoEntity entity = new FileInfoEntity();
-			String fileName = FileUtil.uploadFile(files[i], path + filePath);
+			Pair<String, String> pair = FileUtil.uploadFile(files[i], path + filePath);
 			entity.setId(UUIDGenerator.getIdNo());
-			entity.setPath(filePath + fileName);
-			entity.setFileName(fileName);
+			entity.setFileName(pair.getKey());
+			entity.setPath(filePath + pair.getKey());
+			entity.setSmallPath(filePath+pair.getValue());
 			entity.setCreateTime(LocalDateTime.now());
 			entity.setUpdateTime(LocalDateTime.now());
 			filePreviewDto.setFileId(entity.getId());
 			filePreviewDto.setFileUrl(previewPath + entity.getPath());
+			filePreviewDto.setSmallUrl(previewPath + entity.getSmallPath());
 			previews.add(filePreviewDto);
 			fileInfo.add(entity);
 		}
@@ -78,6 +81,7 @@ public class FileInfoServiceImpl extends AbstractServiceImpl<IFileInfoDao, FileI
 		return null;
 	}
 
+	// rotate
 	@Override
 	public List<FilePreviewDto> getFilePath(List<String> files) {
 
@@ -91,14 +95,16 @@ public class FileInfoServiceImpl extends AbstractServiceImpl<IFileInfoDao, FileI
 			FilePreviewDto filePreviewDto = new FilePreviewDto();
 			FileInfoEntity entity = new FileInfoEntity();
 			byte[] fileBtye = Base64.decodeBase64(files.get(i));
-			String fileName = FileUtil.uploadFile(fileBtye, path + filePath);
+			Pair<String, String> p = FileUtil.uploadFile(fileBtye, path + filePath);
 			entity.setId(UUIDGenerator.getIdNo());
-			entity.setPath(filePath + fileName);
-			entity.setFileName(fileName);
+			entity.setPath(filePath + p.getKey());
+			entity.setFileName(p.getKey());
+			entity.setSmallPath(filePath + p.getValue());
 			entity.setCreateTime(LocalDateTime.now());
 			entity.setUpdateTime(LocalDateTime.now());
 			filePreviewDto.setFileId(entity.getId());
 			filePreviewDto.setFileUrl(previewPath + entity.getPath());
+			filePreviewDto.setSmallUrl(previewPath + entity.getPath());
 			previews.add(filePreviewDto);
 			fileInfo.add(entity);
 		}

+ 2 - 6
eladmin-system/src/main/java/me/zhengjie/archives/util/HtmlToImage.java

@@ -24,7 +24,7 @@ public class HtmlToImage {
 			cmd.append(exePath);
 			cmd.append(" ");
 			// cmd.append("--crop-w 400 --width 1680 --quality 50 ");
-			cmd.append("--width 820  --height 1168  ");
+			cmd.append("--width 1640  --height 2344  ");
 			cmd.append(srcPath);
 			cmd.append(" ");
 			cmd.append(destPath);
@@ -54,22 +54,18 @@ public class HtmlToImage {
 			while (line != null) {
 				System.out.println(line);
 				line = errStreamReader.readLine();
-
 			}
 			process.destroy();
-
 			System.out.println("destroyed process");
 
 		} catch (Exception e) {
-
 			e.printStackTrace();
-
 		}
 
 	}
 
 	public static void main(String[] args) {
-		htmlToImg("", "D:\\data\\index.html", "D:\\data\\cc.jpg");
+		htmlToImg("D:\\programfile\\efs\\wkhtmltoimage.exe", "D:\\360WiFi\\index.html", "D:\\360WiFi\\cc.jpg");
 	}
 
 }

+ 51 - 0
eladmin-system/src/main/java/me/zhengjie/archives/util/PdfUtils.java

@@ -1,8 +1,10 @@
 package me.zhengjie.archives.util;
 
+import java.awt.Color;
 import java.awt.image.BufferedImage;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.List;
@@ -15,12 +17,22 @@ import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.font.PDFont;
+import org.apache.pdfbox.pdmodel.font.PDType0Font;
+import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.apache.pdfbox.pdmodel.graphics.blend.BlendMode;
 import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
+import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
+import org.apache.pdfbox.util.Matrix;
 
 import me.zhengjie.utils.FileUtil;
 
 public class PdfUtils {
+	private static final String WATER_MARK_NAME="宿迁公证处";
+	private static final String SIMSUN= "/font/simsun.ttf";
+	private static int rowSpace = 300;
+	private static int colSpace = 300;
 	public static void mergePdf(List<String> sourcesList, String dstName) throws Exception {
 		PDFMergerUtility mergePdf = new PDFMergerUtility();
 		for (String file : sourcesList) {
@@ -97,6 +109,9 @@ public class PdfUtils {
 			contents = new PDPageContentStream(doc, page);
 			contents.drawImage(pdImage, 0, 0, w, h);
 			System.out.println("Image inserted");
+			PDFont font = PDType0Font.load(doc,
+					PdfUtils.class.getResourceAsStream(SIMSUN), true);
+			addWatermarkText(doc, page, font, WATER_MARK_NAME);
 			contents.close();
 			doc.addPage(page);
 		}
@@ -105,5 +120,41 @@ public class PdfUtils {
 		// 关闭pdf
 		doc.close();
 	}
+	private static void addWatermarkText(PDDocument doc, PDPage page, PDFont font, String text) throws IOException {
+		try (PDPageContentStream cs = new PDPageContentStream(doc, page, PDPageContentStream.AppendMode.APPEND, true,
+				true)) {
+			float fontHeight = 50; // arbitrary for short text
+			float width = page.getMediaBox().getWidth();
+			float height = page.getMediaBox().getHeight();
+			PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
+			// 设置透明度
+			gs.setNonStrokingAlphaConstant(0.8f);
+			gs.setStrokingAlphaConstant(0.8f);
+			gs.setAlphaSourceFlag(true);
+			gs.setLineWidth(1f);
+			gs.setBlendMode(BlendMode.MULTIPLY);
+			cs.setGraphicsStateParameters(gs);
+			cs.setFont(font, fontHeight);
+			Color color = new Color(128, 128, 128);
+			cs.setNonStrokingColor(color);
+			cs.setStrokingColor(color);
+			// PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
+//			gs.setNonStrokingAlphaConstant(0.8f);
+//			gs.setStrokingAlphaConstant(0.8f);
+//			gs.setLineWidth(1f);
+//			cs.setGraphicsStateParameters(gs);
+			cs.beginText();
+			// 根据纸张大小添加水印,30度倾斜
+			for (int h = 10; h < height; h = h + rowSpace) {
+				for (int w = -10; w < width; w = w + colSpace) {
+					cs.setTextMatrix(Matrix.getRotateInstance(0.8, w, h));
+					cs.showText(text);
+				}
+			}
+			cs.endText();
+			cs.restoreGraphicsState();
+			cs.close();
+		}
+	}
 
 }

+ 14 - 0
eladmin-system/src/main/java/me/zhengjie/archives/vo/ArchivesVo.java

@@ -18,6 +18,20 @@ 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; 
+	//接受時間
+	List<String> acceptDate;
 	//主键
 	private Long id;
 }

+ 2 - 1
eladmin-system/src/main/java/me/zhengjie/archives/vo/CasePortraitVo.java

@@ -2,7 +2,6 @@ package me.zhengjie.archives.vo;
 
 import java.util.List;
 
-import org.springframework.web.multipart.MultipartFile;
 
 import lombok.Getter;
 import lombok.Setter;
@@ -19,6 +18,8 @@ import lombok.ToString;
 @ToString
 public class CasePortraitVo {
 	private Long id;
+	private String isRedo;
+
 	private List<String> pages;
 	private List<String> imageIds;
 }

+ 2 - 0
eladmin-system/src/main/java/me/zhengjie/archives/vo/FileUploadVO.java

@@ -25,4 +25,6 @@ public class FileUploadVO {
 	private List<MultipartFile> fileUpload;
 	private List<String> files;
 	
+	private String id;
+	private int degree;
 }

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java

@@ -43,7 +43,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
 
     @Override
     public JwtUserDto loadUserByUsername(String username) {
-        JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
+        JwtUserDto jwtUserDto = null;
         if(jwtUserDto == null){
             UserLoginDto user;
             try {

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java

@@ -63,5 +63,5 @@ public interface DictDetailService {
     
 	public Map<String, String> getValueByName(String name);
 	public String getLabelValue(String name,String key) ;
-    
+	public String getLabelByValue(String name,String value);
 }

+ 12 - 2
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java

@@ -107,6 +107,16 @@ public class DictDetailServiceImpl implements DictDetailService {
 		 
 		return getValueByName(name).get(key);
 	}
-    
-    
+	public Map<String, String> getAllLabelByName(String name) {
+		List<DictDetailDto> dicts = getDictByName(name);
+		Map<String, String> map = new HashMap<>();
+		for (DictDetailDto dict : dicts) {
+			map.put(dict.getValue(), dict.getLabel() );
+		}
+		return map;
+	}
+	public String getLabelByValue(String name,String value) {
+		 
+		return getAllLabelByName(name).get(value);
+	}
 }

+ 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://192.168.0.253:3306/efs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
+      url: jdbc:log4jdbc:mysql://127.0.0.1:3306/efs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
       username: root
-      password: 123456
+      password: admin
       # 初始连接数
       initial-size: 5
       # 最小连接数

+ 21 - 26
eladmin-system/src/main/resources/config/application-prod.yml

@@ -4,17 +4,19 @@ spring:
     druid:
       db-type: com.alibaba.druid.pool.DruidDataSource
       driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
-      url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:eladmin}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
-      username: ${DB_USER:root}
-      password: ${DB_PWD:123456}
+      url: jdbc:log4jdbc:mysql://127.0.0.1:3306/efs?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
+      username: root
+      password: admin
       # 初始连接数
       initial-size: 5
       # 最小连接数
       min-idle: 15
       # 最大连接数
       max-active: 30
+      # 超时时间(以秒数为单位)
+      remove-abandoned-timeout: 180
       # 获取连接超时时间
-      max-wait: 5000
+      max-wait: 3000
       # 连接有效性检测时间
       time-between-eviction-runs-millis: 60000
       # 连接在池中最小生存的时间
@@ -33,13 +35,9 @@ spring:
       webStatFilter:
         enabled: true
       stat-view-servlet:
-        allow:
         enabled: true
-        # 控制台管理用户名和密码
         url-pattern: /druid/*
         reset-enable: false
-        login-username: admin
-        login-password: 123456
       filter:
         stat:
           enabled: true
@@ -71,7 +69,7 @@ login:
     height: 36
     # 内容长度
     length: 2
-    # 字体名称,为空则使用默认字体,如遇到线上乱码,设置其他字体即可
+    # 字体名称,为空则使用默认字体
     font-name:
     # 字体大小
     font-size: 25
@@ -83,35 +81,28 @@ jwt:
   token-start-with: Bearer
   # 必须使用最少88位的Base64对该令牌进行编码
   base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
-  # 令牌过期时间 此处单位/毫秒 ,默认2小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
-  token-validity-in-seconds: 7200000
+  # 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
+  token-validity-in-seconds: 14400000
   # 在线用户key
   online-key: online-token-
   # 验证码
   code-key: code-key-
-  # token 续期检查时间范围(默认30分钟,单位默认毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
+  # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
   detect: 1800000
-  # 续期时间范围,默认 1小时,这里单位毫秒
+  # 续期时间范围,默认1小时,单位毫秒
   renew: 3600000
 
-# IP 本地解析
-ip:
-  local-parsing: true
-
 #是否允许生成代码,生产环境设置为false
 generator:
-  enabled: false
-
-#如果生产环境要开启swagger,需要配置请求地址
-#springfox:
-#  documentation:
-#    swagger:
-#      v2:
-#        host: # 接口域名或外网ip
+  enabled: true
 
 #是否开启 swagger-ui
 swagger:
-  enabled: false
+  enabled: true
+
+# IP 本地解析
+ip:
+  local-parsing: true
 
 # 文件存储路径
 file:
@@ -127,3 +118,7 @@ file:
   # 文件大小 /M
   maxSize: 100
   avatarMaxSize: 5
+html2Pdf:
+  simsumPath: font/simsun.ttf
+  simfangPath: font/simfang.ttf
+  toolName: OpenPDF

+ 1 - 1
eladmin-system/src/main/resources/logback.xml

@@ -8,7 +8,7 @@
     <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
         <encoder>
             <pattern>${log.pattern}</pattern>
-            <charset>${log.charset}</charset>
+           <!--  <charset>${log.charset}</charset> -->
         </encoder>
     </appender>