|
|
@@ -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 "";
|
|
|
- }
|
|
|
-}
|