humuyu vor 2 Jahren
Ursprung
Commit
32a04dad7e
23 geänderte Dateien mit 619 neuen und 228 gelöschten Zeilen
  1. 22 11
      eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
  2. 1 1
      eladmin-common/src/main/java/me/zhengjie/utils/UUIDGenerator.java
  3. 3 3
      eladmin-system/pom.xml
  4. 2 0
      eladmin-system/src/main/java/me/zhengjie/AppRun.java
  5. 87 25
      eladmin-system/src/main/java/me/zhengjie/archives/controller/ArchivesController.java
  6. 6 3
      eladmin-system/src/main/java/me/zhengjie/archives/controller/FileInfoController.java
  7. 22 0
      eladmin-system/src/main/java/me/zhengjie/archives/dao/IChromeLogDao.java
  8. 1 0
      eladmin-system/src/main/java/me/zhengjie/archives/dto/FilePreviewDto.java
  9. 37 0
      eladmin-system/src/main/java/me/zhengjie/archives/entity/ChromeLogEntity.java
  10. 1 1
      eladmin-system/src/main/java/me/zhengjie/archives/plus/QueryWrapperUtil.java
  11. 120 0
      eladmin-system/src/main/java/me/zhengjie/archives/scheduled/DataBaseBack.java
  12. 9 0
      eladmin-system/src/main/java/me/zhengjie/archives/service/ChromeLogService.java
  13. 1 1
      eladmin-system/src/main/java/me/zhengjie/archives/service/FileInfoService.java
  14. 123 120
      eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ArchivesServiceImpl.java
  15. 11 0
      eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ChromeLogServiceImpl.java
  16. 2 1
      eladmin-system/src/main/java/me/zhengjie/archives/service/impl/FileInfoServiceImpl.java
  17. 36 37
      eladmin-system/src/main/java/me/zhengjie/archives/util/HtmlConvertToPdf.java
  18. 6 6
      eladmin-system/src/main/java/me/zhengjie/archives/util/PdfUtils.java
  19. 117 0
      eladmin-system/src/main/java/me/zhengjie/archives/util/Task.java
  20. 1 1
      eladmin-system/src/main/java/me/zhengjie/archives/vo/FileUploadVO.java
  21. 3 0
      eladmin-system/src/main/java/me/zhengjie/config/MybatisPlusConfig.java
  22. 8 3
      eladmin-system/src/main/resources/config/application-dev.yml
  23. 0 15
      eladmin-system/src/main/resources/config/application.yml

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

@@ -171,16 +171,16 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 		} else if (size / KB >= 1) {
 			long kbSize = size / KB;
 			if (kbSize >= 50 && kbSize < 100) {
-				scaleSize = 0.95f;
+				scaleSize = 0.4f;
 			}
 			if (kbSize >= 100 && kbSize < 300) {
-				scaleSize = 0.4f;
-			} else if (kbSize >= 300 && kbSize < 500) {
 				scaleSize = 0.3f;
+			} else if (kbSize >= 300 && kbSize < 500) {
+				scaleSize = 0.25f;
 			} else if (kbSize >= 500 && kbSize < 700) {
 				scaleSize = 0.2f;
 			} else if (kbSize >= 700 && kbSize <= 1000) {
-				scaleSize = 0.18f;
+				scaleSize = 0.15f;
 			}
 		}
 		return scaleSize;
@@ -261,7 +261,7 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 			ImgUtil.scale(new File(writePath), new File(filePath + smallPath), scale(writePath.length()));
 			Pair<String, String> p = new Pair<>(fileName, smallPath);
 			return p;
-			//return fileName;
+			// return fileName;
 
 		} catch (Exception e) {
 			log.error(e.getMessage(), e);
@@ -284,7 +284,8 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 			os.close();
 			String smallPath = name + SMALL + JPG;
 			// 当前小图生成
-			ImgUtil.scale(new File(writePath), new File(filePath + smallPath), scale(writePath.length()));
+			File f = new File(writePath);
+			ImgUtil.scale(f, new File(filePath + smallPath), scale(f.length()));
 			Pair<String, String> p = new Pair<>(fileName, smallPath);
 			return p;
 		} catch (Exception e) {
@@ -303,7 +304,8 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 
 		String formatDate = format.format(time);
 		try {
-			String fileRelatePath = formatDate + "/";
+			int hour = calendar.get(Calendar.HOUR_OF_DAY);
+			String fileRelatePath = formatDate + "/" + hour + "/";
 			String createFilePath = filePath + fileRelatePath;
 			// getCanonicalFile 可解析正确各种路径
 			File dest = new File(createFilePath).getCanonicalFile();
@@ -472,10 +474,19 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
 		return getMd5(getByte(file));
 	}
 
+	public static void deleteFile(File f) {
+
+		try {
+			if (f.isFile())
+				f.delete();
+		} catch (Exception e) {
+
+		}
+	}
+
 	public static void main(String[] args) {
-		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()));
+		File source = new File("C:\\image");
+		System.out.println(source.isFile());
+ 
 	}
 }

+ 1 - 1
eladmin-common/src/main/java/me/zhengjie/utils/UUIDGenerator.java

@@ -18,7 +18,7 @@ public class UUIDGenerator {
 		return businessNo;
 	}
 	public static String getIdNo() {
-		return "100" + getNo() + getRandom();
+		return  getNo() + getRandom();
 	}
 
 	public static String getRandom() {

+ 3 - 3
eladmin-system/pom.xml

@@ -106,9 +106,9 @@
 			<version>3.5.1</version>
 		</dependency>
 		<dependency>
-			<groupId>com.openhtmltopdf</groupId>
-			<artifactId>openhtmltopdf-pdfbox</artifactId>
-			<version>1.0.10</version>
+			<groupId>org.apache.pdfbox</groupId>
+			<artifactId>pdfbox</artifactId>
+			<version>3.0.0-alpha3</version>
 		</dependency>
 
 	</dependencies>

+ 2 - 0
eladmin-system/src/main/java/me/zhengjie/AppRun.java

@@ -26,6 +26,7 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -41,6 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
 @SpringBootApplication
 @EnableTransactionManagement
 @EnableJpaAuditing(auditorAwareRef = "auditorAware")
+@EnableScheduling
 public class AppRun {
 
     public static void main(String[] args) {

+ 87 - 25
eladmin-system/src/main/java/me/zhengjie/archives/controller/ArchivesController.java

@@ -7,6 +7,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+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;
@@ -17,14 +18,17 @@ 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.JSON;
 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.ChromeLogEntity;
 import me.zhengjie.archives.entity.FileInfoEntity;
 import me.zhengjie.archives.service.ArchivesService;
+import me.zhengjie.archives.service.ChromeLogService;
 import me.zhengjie.archives.service.FileInfoService;
 import me.zhengjie.archives.vo.ArchivesVo;
 import me.zhengjie.archives.vo.CaseNumVo;
@@ -52,6 +56,8 @@ public class ArchivesController {
 	@Autowired
 	FileInfoService fileInfoService;
 	@Autowired
+	ChromeLogService chromeLogService;
+	@Autowired
 	private FileProperties properties;
 
 	/**
@@ -62,9 +68,60 @@ public class ArchivesController {
 	 */
 	@AnonymousPostMapping("/mergeSubmit")
 	public ResponseDTO<Map<String, String>> mergeSubmit(@RequestBody CasePortraitVo archives) throws Exception {
+		vadateImage(archives);
 		archivesService.mergeSubmit(archives);
 		return ResponseDTO.success();
 	}
+
+	public void vadateImage(@RequestBody CasePortraitVo archives) {
+		List<String> images = archives.getImageIds();
+		if (CollectionUtils.isEmpty(archives.getImageIds())) {
+			throw new BadRequestException("当前图片为空!");
+		}
+		// 判断图片是否含有null
+		for (int j = 0; j < images.size(); j++) {
+			if (StringUtils.isEmpty(images.get(j)) || images.get(j).equalsIgnoreCase("null")
+					|| images.get(j).equalsIgnoreCase("undefined")) {
+				throw new BadRequestException("当前第" + j + "页码是空值!");
+			}
+		}
+		if (CollectionUtils.isEmpty(archives.getPages())) {
+			throw new BadRequestException("当页码不能为空!");
+		}
+	}
+
+	/**
+	 * 文件和图片
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	@AnonymousPostMapping("/stage")
+	public ResponseDTO<Map<String, String>> stage(@RequestBody CasePortraitVo archives) throws Exception {
+
+//		List<String> images = archives.getImageIds();
+//		if (CollectionUtils.isEmpty(archives.getImageIds())) {
+//			throw new BadRequestException("当前图片为空!");
+//		}
+//		// 判断图片是否含有null
+//		for (int j = 0; j < images.size(); j++) {
+//			if (StringUtils.isEmpty(images.get(j)) || images.get(j).equalsIgnoreCase("null")||images.get(j).equalsIgnoreCase("undefined")) {
+//				throw new BadRequestException("当前第" + j + "页码是空值!");
+//			}
+//		}
+//		if (CollectionUtils.isEmpty(archives.getPages())) {
+//			throw new BadRequestException("当页码不能为空!");
+//		}
+		vadateImage(archives);
+		ArchivesEntity archiveEntity = new ArchivesEntity();
+		archiveEntity.setId(archives.getId());
+		archiveEntity.setStatus("3");
+
+		archiveEntity.setImageJson(JSON.toJSONString(archives));
+		archivesService.updateById(archiveEntity);
+		return ResponseDTO.success();
+	}
+
 	/**
 	 * 文件和图片
 	 *
@@ -73,6 +130,8 @@ public class ArchivesController {
 	 */
 	@AnonymousPostMapping("/reMergeSubmit")
 	public ResponseDTO<Map<String, String>> reMergeSubmit(@RequestBody CasePortraitVo archives) throws Exception {
+		vadateImage(archives);
+		archives.setIsRedo("1");
 		archivesService.mergeSubmit(archives);
 		return ResponseDTO.success();
 	}
@@ -89,8 +148,13 @@ public class ArchivesController {
 		archives.setUpdateBy("1");
 		archives.setIsDelete("1");
 		archives.setStatus("0");
+		archives.setIsClean("0");
+		archives.setRedoCount(0);
+		archives.setCleanCount(0);
+		archives.setPdfPath("");
 		archives.setCreateTime(LocalDateTime.now());
 		archives.setUpdateTime(LocalDateTime.now());
+		archives.setImageJson("");
 		QueryWrapper<ArchivesEntity> qw = new QueryWrapper<>();
 		qw.eq("archives_num", archives.getArchivesNum());
 		long result = archivesService.count(qw);
@@ -100,28 +164,7 @@ public class ArchivesController {
 			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();
@@ -176,6 +219,7 @@ public class ArchivesController {
 		}
 		// 验证案卷号是否正确
 		// validateCaseNum(archives);
+		archives.setPdfPath(null);
 		archivesService.updateById(archives);
 
 		return ResponseDTO.success();
@@ -197,15 +241,16 @@ public class ArchivesController {
 			CasePortraitVo caseVo = JSONObject.parseObject(imageJson, CasePortraitVo.class);
 			List<String> imageIds = caseVo.getImageIds();
 			List<FileInfoEntity> fileInfo = fileInfoService.listByIds(imageIds);
-			Map<String, String> fileInfoMap = new HashMap<>();
+			Map<String, FileInfoEntity> fileInfoMap = new HashMap<>();
 			for (FileInfoEntity file : fileInfo) {
-				fileInfoMap.put(file.getId(), file.getPath());
+				fileInfoMap.put(file.getId(), file);
 			}
 			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));
+				json.put("fileUrl", previewPath + fileInfoMap.get(imageId).getPath());
+				json.put("smallUrl", previewPath + fileInfoMap.get(imageId).getSmallPath());
 				jsonObjs.add(json);
 			}
 			pages = caseVo.getPages();
@@ -322,10 +367,27 @@ public class ArchivesController {
 	 *
 	 * @return
 	 */
+	@AnonymousPostMapping("/log")
+	public ResponseDTO<?> log(@RequestBody Map<String, Object> log) {
+		ChromeLogEntity chrome = new ChromeLogEntity();
+		chrome.setVueLog(JSONObject.toJSONString(log));
+		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 - 3
eladmin-system/src/main/java/me/zhengjie/archives/controller/FileInfoController.java

@@ -6,6 +6,7 @@ import java.util.List;
 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.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
@@ -38,6 +39,7 @@ public class FileInfoController {
 	 * @return
 	 */
 	@AnonymousPostMapping("/uploadFiles")
+
 	public ResponseDTO<List<FilePreviewDto>> uploadFiles(MultipartFile[] files) {
 
 		return ResponseDTO.success(fileInfoService.getFilePath(files));
@@ -52,7 +54,7 @@ public class FileInfoController {
 	public ResponseDTO<List<FilePreviewDto>> uploadBase64(@RequestBody FileUploadVO fileVo) {
 
 		// ;
-		return ResponseDTO.success(fileInfoService.getFilePath(fileVo.getFiles()));
+		return ResponseDTO.success(fileInfoService.getFilePath(fileVo.getFiles(), fileVo.getIndex()));
 	}
 
 	/**
@@ -75,8 +77,8 @@ public class FileInfoController {
 		ImgUtil.rotate(sourceFile, fileVo.getDegree(), new File(path + targetPath));
 		ImgUtil.rotate(sourceSmall, fileVo.getDegree(), new File(path + smallPath));
 		// 删除文件
-		FileUtils.deleteQuietly(sourceFile);
-		FileUtils.deleteQuietly(sourceSmall);
+		FileUtil.deleteFile(sourceFile);
+		FileUtil.deleteFile(sourceSmall);
 		FilePreviewDto filePreview = new FilePreviewDto();
 		filePreview.setFileId(fileVo.getId());
 		filePreview.setFileUrl(previewPath + targetPath);
@@ -86,6 +88,7 @@ public class FileInfoController {
 		fileInfo.setId(fileVo.getId());
 		fileInfo.setPath(targetPath);
 		fileInfo.setSmallPath(smallPath);
+		fileInfoService.updateById(fileInfo);
 		return ResponseDTO.success(filePreview);
 	}
 

+ 22 - 0
eladmin-system/src/main/java/me/zhengjie/archives/dao/IChromeLogDao.java

@@ -0,0 +1,22 @@
+package me.zhengjie.archives.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import me.zhengjie.archives.entity.ChromeLogEntity;
+import me.zhengjie.archives.entity.FileInfoEntity;
+
+
+/**
+ * <p>
+ * 文件上传记录表 Mapper 接口
+ * </p>
+ *
+ * @author humuyu
+ * @since 2022-03-10
+ */
+@Mapper
+public interface IChromeLogDao extends BaseMapper<ChromeLogEntity> {
+
+}

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

@@ -11,4 +11,5 @@ public class FilePreviewDto {
 	private String fileId;
 	private String fileUrl;
 	private String smallUrl;
+	private String index;
 }

+ 37 - 0
eladmin-system/src/main/java/me/zhengjie/archives/entity/ChromeLogEntity.java

@@ -0,0 +1,37 @@
+package me.zhengjie.archives.entity;
+
+import java.io.Serializable;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author <a href="https://www.fengwenyi.com?code">Erwin Feng</a>
+ * @since 2023-04-18
+ */
+@TableName("chrome_log")
+@Getter
+@Setter
+public class ChromeLogEntity implements Serializable {
+
+	private static final long serialVersionUID = 5067661776514555104L;
+
+	@TableId(value = "id", type = IdType.AUTO)
+	private Long id;
+
+	/**
+	 * 主键
+	 */
+	@TableField(value = "vue_log")
+	private String vueLog;
+
+}

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

@@ -48,7 +48,7 @@ public class QueryWrapperUtil {
 	 */
 	public static <T> QueryWrapper<T> convertQuery(Object obj, QueryMap... jsonObj) {
 		Map<String, Object> param = new HashMap<>();
-		if (jsonObj!=null && jsonObj[0]!=null) {
+		if (jsonObj!=null && jsonObj.length>0 && jsonObj[0]!=null) {
 
 			param = jsonObj[0].getMap();
 		}

+ 120 - 0
eladmin-system/src/main/java/me/zhengjie/archives/scheduled/DataBaseBack.java

@@ -0,0 +1,120 @@
+package me.zhengjie.archives.scheduled;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import cn.hutool.core.util.ZipUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Component
+@Slf4j
+public class DataBaseBack {
+	private final static String ip = "127.0.0.1";
+	private final static int port = 3306;
+	private final static String user = "root";
+	private final static String password = "admin";
+	private final static String DB_NAME = "efs";
+	private final static String MYSQL_PATH = "\"C:\\Program Files\\MySQL\\MySQL Server 5.7\\bin\\mysqldump\"";
+	//mysqldump\"
+	private final static long ONE_DATE_TIME = 1000 * 1 * 60 * 60 * 24 * 7;
+
+	@Scheduled(cron = "0 0 13,17 * * ?")  
+	//@Scheduled(cron = "0 */1 * * * ?")  
+	public void backMysql() throws IOException, InterruptedException {
+		log.info("备份数据库");
+		String backDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+		// 判断是windows系统还是linux系统
+		String os = System.getProperty("os.name");
+		if (os.toLowerCase().startsWith("win")) {
+			System.out.println(os + "执行备份");
+			dataBaseDump(ip, port, user, password, backDate);
+		}
+	}
+
+	public void dataBaseDump(String ip, int port, String user, String passWord, String backDate)
+			throws IOException, InterruptedException {
+		File file = new File("D:\\programfile\\mysqlback");
+		if (!file.exists()) {
+			file.mkdir();
+		}
+		// 删除7天的数据
+		FileFilter fileFilter = f -> f.getName().contains(".zip") || f.getName().contains(".sql");
+		for (File f : file.listFiles(fileFilter)) {
+			Path path = Paths.get(f.getAbsolutePath());
+			BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
+			FileTime fileTime = attr.creationTime();
+			long fileMillis = fileTime.toMillis();
+			long date = new Date().getTime();
+			if (date - fileMillis > ONE_DATE_TIME) {
+				try {
+					f.delete();
+				} catch (Exception e) {
+
+				}
+			}
+		}
+		// 删除以前数据
+
+		String fileName = file + "\\" + backDate + ".sql";
+		Object args[] = { ip, port, user, passWord, DB_NAME, fileName };
+		String command = String.format(MYSQL_PATH + " -h%s -P%s -u%s -p%s %s>%s ", args);
+		// 注意这句命令一定要加上\很容易出错
+
+		System.out.println(command);
+		StringBuilder msg = new StringBuilder();
+		BufferedReader bufferedReader = null;
+		Process proc = null;
+		// 命令之间不能有空格
+		ProcessBuilder pb = new ProcessBuilder("cmd", "/c", command);
+//        pb.directory(new File(dir));
+		try {
+			proc = pb.start();
+//			System.out.println(proc.getOutputStream());
+			bufferedReader = new BufferedReader(new InputStreamReader(proc.getErrorStream(), "utf-8"));
+			String line;
+			while ((line = bufferedReader.readLine()) != null) {
+				msg.append(line);
+			}
+			System.out.println(msg);
+			proc.waitFor();
+			if (proc.waitFor() == 0) {
+				System.out.println("数据备份成功");
+
+			}
+			ZipUtil.zip(new File(fileName));
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		} finally {
+			if (bufferedReader != null) {
+				try {
+					bufferedReader.close();
+				} catch (Exception ex) {
+				}
+			}
+			if (proc != null) {
+				proc.destroy();
+			}
+		}
+
+	}
+
+	public static void main(String[] args) throws IOException, InterruptedException {
+		new DataBaseBack().backMysql();
+	}
+}

+ 9 - 0
eladmin-system/src/main/java/me/zhengjie/archives/service/ChromeLogService.java

@@ -0,0 +1,9 @@
+package me.zhengjie.archives.service;
+
+import me.zhengjie.archives.entity.ArchivesEntity;
+import me.zhengjie.archives.entity.ChromeLogEntity;
+import me.zhengjie.archives.plus.AbstractService;
+
+
+public interface ChromeLogService extends AbstractService<ChromeLogEntity> {
+}

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/archives/service/FileInfoService.java

@@ -33,7 +33,7 @@ public interface FileInfoService extends AbstractService<FileInfoEntity> {
 	 *
 	 * @param idList 主键ID列表
 	 */
-	public List<FilePreviewDto> getFilePath(List<String> files);
+	public List<FilePreviewDto> getFilePath(List<String> files,String index);
 	JSONObject saveFile(FileUploadVO file);
 
 }

+ 123 - 120
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ArchivesServiceImpl.java

@@ -9,6 +9,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import javax.annotation.PostConstruct;
+
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -57,8 +59,14 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 	@Autowired
 	HtmlConvertToPdf htmlConvertToPdf;
 
+//	@PostConstruct
+//	public void init() {
+//		new Thread(()-> {deleteNoUserImage();}).start();
+//		
+//	}
+
 	public Map<String, Object> page(ArchivesVo req) {
-		IPage<ArchivesEntity> page = new Page<>(req.getIndex(), 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();
@@ -81,101 +89,104 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 
 	}
 
-	public void pdf(CasePortraitVo archives) throws Exception {
-
-		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 pageHtml = model.getContent();
-
-		ArchivesEntity archive = this.getById(archives.getId());
-
-		pageHtml.replace("{{notarialNum}}", archive.getNotarialNum());
-		pageHtml.replace("{{notarizedItem}}", archive.getNotarizedItem());
-		pageHtml.replace("{{partyName}}", archive.getPartyName());
-		pageHtml.replace("{{undertaker}}", archive.getUndertaker());
-		pageHtml.replace("{{notary}}", archive.getNotary());
-		pageHtml.replace("{{acceptDate}}", archive.getAcceptDate());
-		pageHtml.replace("{{completeDate}}", archive.getCompleteDate());
-		pageHtml.replace("{{filingDate}}", archive.getFilingDate());
-		pageHtml.replace("{{saveTerm}}", archive.getSaveTerm());
-		pageHtml.replace("{{dossierNum}}", archive.getDossierNum());
-		pageHtml.replace("{{acceptNum}}", archive.getAcceptNum());
-		pageHtml.replace("{{fondsNum}}", archive.getFondsNum());
-		pageHtml.replace("{{catalogNum}}", archive.getCatalogNum());
-		pageHtml.replace("{{caseNum}}", archive.getCaseNum());
-		String pagePdf = filePath + UUIDGenerator.uuid() + ".pdf";
-		htmlConvertToPdf.converPdf(pageHtml, pagePdf);
+//	public void pdf(CasePortraitVo archives) throws Exception {
+//
+//		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 pageHtml = model.getContent();
+//
+//		ArchivesEntity archive = this.getById(archives.getId());
+//
+//		pageHtml.replace("{{notarialNum}}", archive.getNotarialNum());
+//		pageHtml.replace("{{notarizedItem}}", archive.getNotarizedItem());
+//		pageHtml.replace("{{partyName}}", archive.getPartyName());
+//		pageHtml.replace("{{undertaker}}", archive.getUndertaker());
+//		pageHtml.replace("{{notary}}", archive.getNotary());
+//		pageHtml.replace("{{acceptDate}}", archive.getAcceptDate());
+//		pageHtml.replace("{{completeDate}}", archive.getCompleteDate());
+//		pageHtml.replace("{{filingDate}}", archive.getFilingDate());
+//		pageHtml.replace("{{saveTerm}}", archive.getSaveTerm());
+//		pageHtml.replace("{{dossierNum}}", archive.getDossierNum());
+//		pageHtml.replace("{{acceptNum}}", archive.getAcceptNum());
+//		pageHtml.replace("{{fondsNum}}", archive.getFondsNum());
+//		pageHtml.replace("{{catalogNum}}", archive.getCatalogNum());
+//		pageHtml.replace("{{caseNum}}", archive.getCaseNum());
+//		String pagePdf = filePath + UUIDGenerator.uuid() + ".pdf";
+//		htmlConvertToPdf.converPdf(pageHtml, pagePdf);
+////		List<String> pages = archives.getPages();
+////		for (int i = 0; i < pages.size(); i++) {
+////			pageHtml = pageHtml.replace("${num" + j + "}", pages.get(i));
+////		}
+//
+//		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++) {
-//			pageHtml = pageHtml.replace("${num" + j + "}", pages.get(i));
+//			j = i + 1;
+//			catalogHtml = catalogHtml.replace("${num" + j + "}", pages.get(i));
 //		}
-
-		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;
-			catalogHtml = catalogHtml.replace("${num" + j + "}", pages.get(i));
-		}
-
-		// String htmlPath = filePath + UUIDGenerator.uuid() + ".html";
-		// String htmlToImage = filePath + UUIDGenerator.uuid() + ".jpg";
-		// 先写入文本
-		// FileUtil.writeUtf8String(html, htmlPath);
-		// HtmlConvertPdf.createPdfFile(html, htmlToPdf);
-		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);
-		// 合并pdf
-		List<String> sourcesList = new ArrayList<>();
-		// 封面放在第一位
-		// sourcesList.add(new File(htmlToImage));
-		sourcesList.add(pagePdf);
-		// 封面放在页码第二位
-		String catalogPdf = filePath + UUIDGenerator.uuid() + ".pdf";
-		htmlConvertToPdf.converPdf(catalogHtml, catalogPdf);
-		sourcesList.add(catalogPdf);
-		// 第三部分是内容
-		sourcesList.add(toPdfTarget);
-		// ---------------------------
-		fileName = "merge_" + UUIDGenerator.uuid() + ".pdf";
-		String dstPath = filePath + fileName;
-
-		PdfUtils.mergePdf(sourcesList, dstPath);
-		ArchivesEntity archiveEntity = new ArchivesEntity();
-		archiveEntity.setId(archives.getId());
-		archiveEntity.setPdfPath(fileRelatePath + fileName);
-		archiveEntity.setStatus("1");
-		this.updateById(archiveEntity);
-
-	}
+//
+//		// String htmlPath = filePath + UUIDGenerator.uuid() + ".html";
+//		// String htmlToImage = filePath + UUIDGenerator.uuid() + ".jpg";
+//		// 先写入文本
+//		// FileUtil.writeUtf8String(html, htmlPath);
+//		// HtmlConvertPdf.createPdfFile(html, htmlToPdf);
+//		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);
+//		// 合并pdf
+//		List<String> sourcesList = new ArrayList<>();
+//		// 封面放在第一位
+//		// sourcesList.add(new File(htmlToImage));
+//		sourcesList.add(pagePdf);
+//		// 封面放在页码第二位
+//		String catalogPdf = filePath + UUIDGenerator.uuid() + ".pdf";
+//		htmlConvertToPdf.converPdf(catalogHtml, catalogPdf);
+//		sourcesList.add(catalogPdf);
+//		// 第三部分是内容
+//		sourcesList.add(toPdfTarget);
+//		// ---------------------------
+//		fileName = "merge_" + UUIDGenerator.uuid() + ".pdf";
+//		String dstPath = filePath + fileName;
+//
+//		PdfUtils.mergePdf(sourcesList, dstPath);
+//		ArchivesEntity archiveEntity = new ArchivesEntity();
+//		archiveEntity.setId(archives.getId());
+//		archiveEntity.setPdfPath(fileRelatePath + fileName);
+//		archiveEntity.setStatus("1");
+//		this.updateById(archiveEntity);
+//
+//	}
 
 	public void image(CasePortraitVo archives) throws Exception {
+		String path = properties.getPath().getPath();
+
 		// 查询对应的值
 		ArchivesEntity entity = this.getById(archives.getId());
+		// 删除以前的pdf
+		FileUtil.deleteFile(new File(path + entity.getPdfPath()));
 		// 保管期限
 		String saveTerm = dictDetailService.getLabelByValue("saveTerm_type", entity.getSaveTerm());
 		// 案卷类型
@@ -185,7 +196,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		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 headPageHtml = model.getContent();
@@ -211,6 +222,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		// 然后生成jpg
 		String exePath = dictDetailService.getValueByName("file_path").get("exe_path");
 		HtmlToImage.htmlToImg(exePath, headPagePath, headPageToImage);
+		FileUtil.deleteFile(new File(headPagePath));
 		// -------------------页号结束------------------------
 		// --------------------目录号开始---------
 		queryWrapper = new QueryWrapper<ModelEntity>();
@@ -233,6 +245,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		// String exePath =
 		// dictDetailService.getValueByName("file_path").get("exe_path");
 		HtmlToImage.htmlToImg(exePath, catalogPath, catalogToImage);
+		FileUtil.deleteFile(new File(catalogPath));
 		// ------------------------目录号结束
 		// HtmlConvertPdf.createPdfFile(html, htmlToPdf);
 		List<String> imageIds = archives.getImageIds();
@@ -268,6 +281,10 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		if (StringUtils.isNotBlank(archives.getIsRedo()) && archives.getIsRedo().equals("1")) {
 			int redoCount = entity.getRedoCount() == null ? 0 : entity.getRedoCount() + 1;
 			archiveEntity.setRedoCount(redoCount);
+		} else {
+			archiveEntity.setRedoCount(0);
+			archiveEntity.setCleanCount(0);
+			archiveEntity.setIsClean("0");
 		}
 		archiveEntity.setStatus("1");
 		// archiveEntity.set
@@ -314,6 +331,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		ArchivesEntity archiveEntity = new ArchivesEntity();
 		archiveEntity.setId(archives.getId());
 		archiveEntity.setStatus("2");
+		this.updateById(archiveEntity);
 		image(archives);
 	}
 
@@ -326,24 +344,32 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		qw.eq("status", 1);
 		qw.eq("is_clean", 0);
 		qw.apply("redo_count != clean_count");
-		int i = 1;
+		int i = 0;
+		int j=10;
 		while (true) {
-			qw.last("limit" + 10 * i);
+			
+			qw.last("limit " + i + "," + j);
 			List<ArchivesEntity> archives = this.list(qw);
+			if (CollectionUtils.isEmpty(archives)) {
+				break;
+			}
+			 i = j;
+			 j+=10;
 			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));
+					 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<>();
@@ -352,7 +378,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 						map.put(fi.getId(), fi);
 						allFileIds.add(fi.getId());
 					}
-					Collection<String> intersection = CollectionUtils.intersection(allFileIds, imageIds);
+					Collection<String> intersection = CollectionUtils.subtract(allFileIds, imageIds);
 					// 开始删除数据
 					if (CollectionUtils.isNotEmpty(intersection)) {
 						for (String imagePath : intersection) {
@@ -361,6 +387,7 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 							FileUtils.deleteQuietly(new File(path + fileInfoEntity.getSmallPath()));
 
 						}
+						fileInfoService.removeByIds(intersection);
 					}
 					ArchivesEntity deleteImageAfter = new ArchivesEntity();
 					deleteImageAfter.setId(a.getId());
@@ -373,28 +400,4 @@ public class ArchivesServiceImpl extends AbstractServiceImpl<IArchivesDao, Archi
 		}
 	}
 
-	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 "";
-	}
-}

+ 11 - 0
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/ChromeLogServiceImpl.java

@@ -0,0 +1,11 @@
+package me.zhengjie.archives.service.impl;
+
+import org.springframework.stereotype.Service;
+
+import me.zhengjie.archives.dao.IChromeLogDao;
+import me.zhengjie.archives.entity.ChromeLogEntity;
+import me.zhengjie.archives.plus.AbstractServiceImpl;
+import me.zhengjie.archives.service.ChromeLogService;
+
+@Service
+public class ChromeLogServiceImpl extends AbstractServiceImpl<IChromeLogDao, ChromeLogEntity> implements ChromeLogService {}

+ 2 - 1
eladmin-system/src/main/java/me/zhengjie/archives/service/impl/FileInfoServiceImpl.java

@@ -83,7 +83,7 @@ public class FileInfoServiceImpl extends AbstractServiceImpl<IFileInfoDao, FileI
 
 	// rotate
 	@Override
-	public List<FilePreviewDto> getFilePath(List<String> files) {
+	public List<FilePreviewDto> getFilePath(List<String> files, String index) {
 
 		previewPath = dictDetailService.getValueByName("file_path").get("preview_path");
 
@@ -103,6 +103,7 @@ public class FileInfoServiceImpl extends AbstractServiceImpl<IFileInfoDao, FileI
 			entity.setCreateTime(LocalDateTime.now());
 			entity.setUpdateTime(LocalDateTime.now());
 			filePreviewDto.setFileId(entity.getId());
+			filePreviewDto.setIndex(index);
 			filePreviewDto.setFileUrl(previewPath + entity.getPath());
 			filePreviewDto.setSmallUrl(previewPath + entity.getPath());
 			previews.add(filePreviewDto);

+ 36 - 37
eladmin-system/src/main/java/me/zhengjie/archives/util/HtmlConvertToPdf.java

@@ -1,7 +1,6 @@
 package me.zhengjie.archives.util;
 
-import com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder;
-import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
+
 import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.utils.FileUtil;
 import org.apache.commons.io.FileUtils;
@@ -62,7 +61,7 @@ public class HtmlConvertToPdf implements InitializingBean {
 	 */
 	public void converPdf(String html, String destPath) throws Exception {
 
-		convertPdfWithOpenPDF(html, destPath);
+		//convertPdfWithOpenPDF(html, destPath);
 
 	}
 
@@ -73,46 +72,46 @@ public class HtmlConvertToPdf implements InitializingBean {
 	 * @param destPath
 	 * @throws Exception
 	 */
-	private void convertPdfWithOpenPDF(String html, String destPath) throws Exception {
-		// 加载html文件
-		Document document = Jsoup.parse(html);
-		document.outputSettings().syntax(Document.OutputSettings.Syntax.html);
-		// 引入资源目录,可以单独引入css,图片文件等
-		String baseUri = FileSystems.getDefault().getPath("eladmin-system/src/main/resources/css").toUri().toString();
-		//
-		File file = new File(destPath);
-		FileUtils.writeStringToFile(file, "", "UTF-8");
-		OutputStream os = new FileOutputStream(file);
-		PdfRendererBuilder builder = new PdfRendererBuilder();
-		builder.withUri(destPath);
-		builder.toStream(os);
-		builder.withW3cDocument(new W3CDom().fromJsoup(document), baseUri);
-		builder.addDOMMutator(doc -> {
-			Element style = doc.createElement("style");
-			Node node = doc.createTextNode("@page { margin-top: 90px; margin-bottom: 90px; }");
-			style.appendChild(node);
-			doc.getElementsByTagName("head").item(0).appendChild(style);
-		});
-
-		// 引入指定字体,注意字体名需要和css样式中指定的字体名相同
-		String fontPath = HtmlConvertToPdf.class.getClassLoader().getResource("").getPath();
-		System.out.println(fontPath);
-		builder.useFont(new File(fontPath + simsumPath.substring(simsumPath.indexOf("/") + 1)), "SimSun", 400,
-				BaseRendererBuilder.FontStyle.NORMAL, true);
-		builder.useFont(new File(fontPath + simfangPath.substring(simfangPath.indexOf("/") + 1)), "simfang", 400,
-				BaseRendererBuilder.FontStyle.NORMAL, true);
-
-		builder.run();
-	}
+//	private void convertPdfWithOpenPDF(String html, String destPath) throws Exception {
+//		// 加载html文件
+//		Document document = Jsoup.parse(html);
+//		document.outputSettings().syntax(Document.OutputSettings.Syntax.html);
+//		// 引入资源目录,可以单独引入css,图片文件等
+//		String baseUri = FileSystems.getDefault().getPath("eladmin-system/src/main/resources/css").toUri().toString();
+//		//
+//		File file = new File(destPath);
+//		FileUtils.writeStringToFile(file, "", "UTF-8");
+//		OutputStream os = new FileOutputStream(file);
+////		PdfRendererBuilder builder = new PdfRendererBuilder();
+//		builder.withUri(destPath);
+//		builder.toStream(os);
+//		builder.withW3cDocument(new W3CDom().fromJsoup(document), baseUri);
+//		builder.addDOMMutator(doc -> {
+//			Element style = doc.createElement("style");
+//			Node node = doc.createTextNode("@page { margin-top: 90px; margin-bottom: 90px; }");
+//			style.appendChild(node);
+//			doc.getElementsByTagName("head").item(0).appendChild(style);
+//		});
+//
+//		// 引入指定字体,注意字体名需要和css样式中指定的字体名相同
+//		String fontPath = HtmlConvertToPdf.class.getClassLoader().getResource("").getPath();
+//		System.out.println(fontPath);
+//		builder.useFont(new File(fontPath + simsumPath.substring(simsumPath.indexOf("/") + 1)), "SimSun", 400,
+//				BaseRendererBuilder.FontStyle.NORMAL, true);
+//		builder.useFont(new File(fontPath + simfangPath.substring(simfangPath.indexOf("/") + 1)), "simfang", 400,
+//				BaseRendererBuilder.FontStyle.NORMAL, true);
+//
+//		builder.run();
+//	}
 
 	public static void main(String[] args) {
 		try {
 			HtmlConvertToPdf htmlConvertToPdf = new HtmlConvertToPdf();
 			htmlConvertToPdf.setSimsumPath("/font/simsun.ttf");
 			htmlConvertToPdf.setSimfangPath("/font/simfang.ttf");
-			htmlConvertToPdf.convertPdfWithOpenPDF(
-					FileUtil.readUtf8String("/Users/sakuya/Downloads/9e88124747724a17996afeda61dbb758.html"),
-					"/Users/sakuya/Downloads/a44a021e9a0d473092fd051c48b3d36b.pdf");
+//			htmlConvertToPdf.convertPdfWithOpenPDF(
+//					FileUtil.readUtf8String("/Users/sakuya/Downloads/9e88124747724a17996afeda61dbb758.html"),
+//					"/Users/sakuya/Downloads/a44a021e9a0d473092fd051c48b3d36b.pdf");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}

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

@@ -21,6 +21,7 @@ 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.JPEGFactory;
 import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
 import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
 import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
@@ -71,7 +72,6 @@ public class PdfUtils {
 	public static void manyImageToOnePdf(List<File> files, String target) throws Exception {
 		PDDocument doc = new PDDocument();
 		// 创建一个空的pdf文件
-
 		PDPage page;
 		PDImageXObject pdImage;
 		PDPageContentStream contents;
@@ -102,16 +102,16 @@ public class PdfUtils {
 
 			bufferedImage = ImageIO.read(tempFile);
 			// Retrieving the page
-			pdImage = LosslessFactory.createFromImage(doc, bufferedImage);
+			pdImage = JPEGFactory.createFromImage(doc, bufferedImage);
 			w = pdImage.getWidth();
 			h = pdImage.getHeight();
 			page = new PDPage(new PDRectangle(w, h));
 			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);
+//			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);
 		}

+ 117 - 0
eladmin-system/src/main/java/me/zhengjie/archives/util/Task.java

@@ -0,0 +1,117 @@
+package me.zhengjie.archives.util;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import cn.hutool.core.util.ZipUtil;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Component
+@Slf4j
+public class Task {
+	private final static String ip = "127.0.0.1";
+	private final static int port = 3306;
+	private final static String user = "root";
+	private final static String password = "admin";
+	private final static String DB_NAME = "efs";
+	private final static String MYSQL_PATH = "\"D:\\Program Files (x86)\\MySQL\\bin\\mysqldump\"";
+	private final static long ONE_DATE_TIME = 1000 * 1 * 60 * 60 * 24 * 7;
+
+	@Scheduled(cron = "0 55 23 1 * ?") // 每月1号的23点59分执行
+//    @Scheduled(cron = "*/10 * * * * ?")
+	public void backMysql() throws IOException, InterruptedException {
+		log.info("备份数据库");
+		String backDate = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+		// 判断是windows系统还是linux系统
+		String os = System.getProperty("os.name");
+		if (os.toLowerCase().startsWith("win")) {
+			System.out.println(os + "执行备份");
+			dataBaseDump(ip, port, user, password, backDate);
+		}
+	}
+
+	public void dataBaseDump(String ip, int port, String user, String passWord, String backDate)
+			throws IOException, InterruptedException {
+		File file = new File("D:\\data\\log");
+		if (!file.exists()) {
+			file.mkdir();
+		}
+		// 删除7天的数据
+		FileFilter fileFilter = f -> f.getName().contains(".zip") || f.getName().contains(".sql");
+		for (File f : file.listFiles(fileFilter)) {
+			Path path = Paths.get(f.getAbsolutePath());
+			BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
+			FileTime fileTime = attr.creationTime();
+			long fileMillis = fileTime.toMillis();
+			long date = new Date().getTime();
+			if (date - fileMillis > ONE_DATE_TIME) {
+				try {
+					f.delete();
+				} catch (Exception e) {
+
+				}
+			}
+		}
+		// 删除以前数据
+
+		String fileName = file + "\\" + backDate + ".sql";
+		Object args[] = { ip, port, user, passWord, DB_NAME, fileName };
+		String command = String.format(MYSQL_PATH + " -h%s -P%s -u%s -p%s %s>%s ", args);
+		// 注意这句命令一定要加上\很容易出错
+
+		System.out.println(command);
+		StringBuilder msg = new StringBuilder();
+		BufferedReader bufferedReader = null;
+		Process proc = null;
+		// 命令之间不能有空格
+		ProcessBuilder pb = new ProcessBuilder("cmd", "/c", command);
+//        pb.directory(new File(dir));
+		try {
+			proc = pb.start();
+			System.out.println(proc.getOutputStream());
+			bufferedReader = new BufferedReader(new InputStreamReader(proc.getErrorStream(), "utf-8"));
+			String line;
+			while ((line = bufferedReader.readLine()) != null) {
+				msg.append(line);
+			}
+			System.out.println(msg);
+			proc.waitFor();
+			if (proc.waitFor() == 0) {
+				System.out.println("数据备份成功");
+
+			}
+			ZipUtil.zip(new File(fileName));
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		} finally {
+			if (bufferedReader != null) {
+				try {
+					bufferedReader.close();
+				} catch (Exception ex) {
+				}
+			}
+			if (proc != null) {
+				proc.destroy();
+			}
+		}
+
+	}
+
+	public static void main(String[] args) throws IOException, InterruptedException {
+		new Task().backMysql();
+	}
+}

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

@@ -24,7 +24,7 @@ public class FileUploadVO {
 
 	private List<MultipartFile> fileUpload;
 	private List<String> files;
-	
+	private  String  index;
 	private String id;
 	private int degree;
 }

+ 3 - 0
eladmin-system/src/main/java/me/zhengjie/config/MybatisPlusConfig.java

@@ -1,5 +1,6 @@
 package me.zhengjie.config;
 
+import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 import org.springframework.context.annotation.Bean;
@@ -19,6 +20,8 @@ public class MybatisPlusConfig {
     public MybatisPlusInterceptor paginationInterceptor() {
         MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
         PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
+        paginationInnerInterceptor.setOptimizeJoin(true);
+        paginationInnerInterceptor.setDbType(DbType.MYSQL);
         interceptor.addInnerInterceptor(paginationInnerInterceptor);
         return interceptor;
     }

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

@@ -48,7 +48,12 @@ spring:
         wall:
           config:
             multi-statement-allow: true
-
+mybatis-plus:
+  configuration:
+    map-underscore-to-camel-case: true
+    auto-mapping-behavior: full
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  mapper-locations: classpath*:mapper/*Mapper.xml
 # 登录相关配置
 login:
   #  是否限制单用户登录
@@ -113,8 +118,8 @@ file:
     path: /home/eladmin/file/
     avatar: /home/eladmin/avatar/
   windows:
-    path: C:\eladmin\file\
-    avatar: C:\eladmin\avatar\
+    path: E:\eladmin\file\
+    avatar: E:\eladmin\avatar\
   # 文件大小 /M
   maxSize: 100
   avatarMaxSize: 5

+ 0 - 15
eladmin-system/src/main/resources/config/application.yml

@@ -30,21 +30,6 @@ spring:
 #    password: 123qysd!@#
     #连接超时时间
     timeout: 5000
-mybatis-plus:
-  configuration:
-    map-underscore-to-camel-case: true
-    auto-mapping-behavior: full
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-  mapper-locations: classpath*:mapper/*Mapper.xml
-#  type-aliases-package: com.tcpp.FqNotarize.entity
-  global-config:
-    # 逻辑删除配置
-    db-config:
-      # 删除前
-      logic-not-delete-value: 1
-      # 删除后
-      logic-delete-value: 0    
-
 
 task:
   pool: