|
@@ -16,8 +16,11 @@ import org.springblade.archive.mapper.ArchiveExaminingReportMapper;
|
|
|
import org.springblade.archive.service.IArchiveExaminingReportDetailService;
|
|
|
import org.springblade.archive.service.IArchiveExaminingReportService;
|
|
|
import org.springblade.archive.socket.WebSocketServer;
|
|
|
+import org.springblade.archive.utils.FileUtils;
|
|
|
import org.springblade.archive.vo.ArchiveExaminingSocketVo;
|
|
|
import org.springblade.archive.vo.ArchiveExaminingVo;
|
|
|
+import org.springblade.business.entity.ArchiveFile;
|
|
|
+import org.springblade.business.feign.ArchiveFileClient;
|
|
|
import org.springblade.common.constant.ArchiveConstant;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
@@ -25,15 +28,17 @@ import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
|
+import org.springblade.evisa.feign.EVisaClient;
|
|
|
+import org.springblade.evisa.vo.CertBeanVO;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.resource.feign.NewISmsClient;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
+import java.util.*;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -49,6 +54,10 @@ public class ArchiveExaminingReportImpl extends BaseServiceImpl<ArchiveExamining
|
|
|
private final IArchiveExaminingReportDetailService detailService;
|
|
|
|
|
|
private final NewIOSSClient iossClient;
|
|
|
+
|
|
|
+ private final ArchiveFileClient archiveFileClient;
|
|
|
+
|
|
|
+ private final EVisaClient eVisaClient;
|
|
|
/**
|
|
|
* 推送状态到前端
|
|
|
* @param id
|
|
@@ -87,12 +96,29 @@ public class ArchiveExaminingReportImpl extends BaseServiceImpl<ArchiveExamining
|
|
|
report.setId(id);
|
|
|
report.setStatus(2);
|
|
|
this.updateById(report);
|
|
|
+ //获取项目中所有档案文件的工序资料pdfUrl
|
|
|
+ List<ArchiveFile> files = archiveFileClient.getAllPdfFileUrlByProjectIdAndFileType(vo.getProjectId());
|
|
|
+ //不合格对象
|
|
|
+ List<Map<String,String>> mapList = new ArrayList<>();
|
|
|
+ int unqualifiedCount = 0;
|
|
|
//检测中
|
|
|
//真实性
|
|
|
if (StringUtils.isNotBlank(vo.getAuthenticity()) && "1".equals(vo.getAuthenticity())) {
|
|
|
- Thread.sleep(5000L);
|
|
|
+ //检测项目下所有工序资料PDF签章有效性
|
|
|
+ for (ArchiveFile file : files) {
|
|
|
+ if (StringUtils.isNotBlank(file.getPdfFileUrl())) {
|
|
|
+ CertBeanVO cb = eVisaClient.onlineCheckSeal(file.getPdfFileUrl());
|
|
|
+ if (cb == null) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("examiningItem", ArchiveConstant.ARCHIVE_EXAMINING_STANDARD + "对固化信息有效性检测");
|
|
|
+ map.put("unqualifiedObject", file.getFileName());
|
|
|
+ mapList.add(map);
|
|
|
+ unqualifiedCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
detailService.save(new ArchiveExaminingReportDetail(vo.getProjectId(), id, ArchiveConstant.ARCHIVE_EXAMINING_AUTHENTICITY,
|
|
|
- ArchiveConstant.ARCHIVE_EXAMINING_STANDARD + "对固化信息有效性检测", 0, "无", 0));
|
|
|
+ ArchiveConstant.ARCHIVE_EXAMINING_STANDARD + "对固化信息有效性检测", unqualifiedCount, unqualifiedCount == 0 ?"无":"详见附件", unqualifiedCount == 0?0:1));
|
|
|
detailService.save(new ArchiveExaminingReportDetail(vo.getProjectId(), id, ArchiveConstant.ARCHIVE_EXAMINING_AUTHENTICITY,
|
|
|
ArchiveConstant.ARCHIVE_EXAMINING_STANDARD + "对元数据项数据长度检测", 0, "无", 0));
|
|
|
detailService.save(new ArchiveExaminingReportDetail(vo.getProjectId(), id, ArchiveConstant.ARCHIVE_EXAMINING_AUTHENTICITY,
|
|
@@ -170,7 +196,6 @@ public class ArchiveExaminingReportImpl extends BaseServiceImpl<ArchiveExamining
|
|
|
}
|
|
|
//安全性
|
|
|
if (StringUtils.isNotBlank(vo.getSecurity()) && "1".equals(vo.getSecurity())) {
|
|
|
- Thread.sleep(5000L);
|
|
|
detailService.save(new ArchiveExaminingReportDetail(vo.getProjectId(), id, ArchiveConstant.ARCHIVE_EXAMINING_SECURITY,
|
|
|
ArchiveConstant.ARCHIVE_EXAMINING_STANDARD + "对系统环境中是否安装杀毒软件检测", 0, "无", 0));
|
|
|
detailService.save(new ArchiveExaminingReportDetail(vo.getProjectId(), id, ArchiveConstant.ARCHIVE_EXAMINING_SECURITY,
|
|
@@ -178,13 +203,28 @@ public class ArchiveExaminingReportImpl extends BaseServiceImpl<ArchiveExamining
|
|
|
report.setReportDetailStatus(4);
|
|
|
this.updateById(report);
|
|
|
}
|
|
|
+ Thread.sleep(3000L);
|
|
|
//生成报告,生成PDF
|
|
|
report.setStatus(3);
|
|
|
this.updateById(report);
|
|
|
String url = this.generateReportPdf(id);
|
|
|
+ //生成附件PDF
|
|
|
+ if (mapList.size() > 0){
|
|
|
+ String detailPdf = this.generateReportDetailPdf(mapList);
|
|
|
+ List<String> PdfUrls = new ArrayList<>();
|
|
|
+ PdfUrls.add(url);
|
|
|
+ PdfUrls.add(detailPdf);
|
|
|
+ String localUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/archiveExaminingPdf/123.pdf";
|
|
|
+// String localUrl = "D:\\develop\\test\\123.pdf";
|
|
|
+ //合并pdf
|
|
|
+ FileUtils.mergePdfPublicMethods(PdfUrls,localUrl);
|
|
|
+ BladeFile bladeFile = iossClient.uploadFile("123.pdf",localUrl);
|
|
|
+ report.setReportPdfUrl(bladeFile.getLink());
|
|
|
+ }else {
|
|
|
+ report.setReportPdfUrl(url);
|
|
|
+ }
|
|
|
Thread.sleep(5000L);
|
|
|
//完成
|
|
|
- report.setReportPdfUrl(url);
|
|
|
report.setStatus(4);
|
|
|
this.updateById(report);
|
|
|
}
|
|
@@ -278,7 +318,72 @@ public class ArchiveExaminingReportImpl extends BaseServiceImpl<ArchiveExamining
|
|
|
dataTable.addCell(pdfTableStyle(detail.getUnqualifiedCount()+"", size10font, high, true, true));
|
|
|
dataTable.addCell(pdfTableStyle(detail.getUnqualifiedObject(), size10font, high, true, true));
|
|
|
document.add(dataTable);
|
|
|
+ }
|
|
|
+ document.close();
|
|
|
+ writer.close();
|
|
|
+ BladeFile bladeFile = iossClient.uploadFile(uuid+".pdf", localUrl+uuid+".pdf");
|
|
|
+ if (bladeFile != null && StringUtils.isNotBlank(bladeFile.getLink())){
|
|
|
+ return bladeFile.getLink();
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 生成检测报告PDF
|
|
|
+ */
|
|
|
+ private String generateReportDetailPdf(List<Map<String,String>> mapList) throws IOException, DocumentException {
|
|
|
+ int high = 20;
|
|
|
+ int widthPercentage = 100;
|
|
|
+ String uuid = StringUtil.randomUUID();
|
|
|
+ String localUrl = "/www/wwwroot/Users/hongchuangyanfa/Desktop/archiveExaminingPdf/";
|
|
|
+// String localUrl = "D:\\develop\\test\\";
|
|
|
+ //新建一个pdf文档对象,前一个参数是纸张大小,后四个为边距
|
|
|
+ Document document = new Document(PageSize.A4, 5, 5, 30, 30);
|
|
|
+ //建立一个书写器
|
|
|
+ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(localUrl+uuid+".pdf"));
|
|
|
+ document.open();
|
|
|
+ //创建字体
|
|
|
+ BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
|
|
|
+ //字体对象,这里可以创建一个方法
|
|
|
+ Font size10font = new Font(baseFont, 10, Font.NORMAL); //大小为10的正常字体
|
|
|
+ Font size10font2 = new Font(baseFont, 10, Font.BOLD); //大小为14的正常字体
|
|
|
+ //添加标题
|
|
|
+ //创建第一行表格
|
|
|
+ PdfPTable tableName = new PdfPTable(1);
|
|
|
+ tableName.setWidthPercentage(widthPercentage); //设置标题长度占纸张比例
|
|
|
+ //给表格赋值
|
|
|
+ tableName.addCell(pdfTableStyle("检测报告附件表", size10font, high, true, true));
|
|
|
+ //将表格添加到文档对象中
|
|
|
+ document.add(tableName);
|
|
|
+ //表头文字
|
|
|
+ String[] name = new String[]{ "检测项目", "不合格对象"};
|
|
|
+ //创建第二行,并设置第二行中的表格数
|
|
|
+ PdfPTable twoTable = new PdfPTable(name.length);
|
|
|
+ twoTable.setWidthPercentage(widthPercentage);
|
|
|
+ //该数组是每个表格的宽度
|
|
|
+ float[] floats = new float[name.length];
|
|
|
+ floats[0] = 0.6f;
|
|
|
+ floats[1] = 0.5f;
|
|
|
+ //循环将表头数据添加到第二行表格中
|
|
|
+ for (int i = 0; i < name.length; i++) {
|
|
|
+ PdfPCell pdfPCell = pdfTableStyle(name[i], size10font2, high, true, true);
|
|
|
+ pdfPCell.setBackgroundColor(new BaseColor(231,230,230));
|
|
|
+ twoTable.addCell(pdfPCell);
|
|
|
+ }
|
|
|
+ //设置表格的宽度
|
|
|
+ twoTable.setTotalWidth(floats);
|
|
|
+ document.add(twoTable);
|
|
|
+ //将数据放入表格中
|
|
|
+ for (int i = 0; i < mapList.size(); i++) {
|
|
|
+ Map<String, String> map = mapList.get(i);
|
|
|
+ PdfPTable dataTable = new PdfPTable(name.length);
|
|
|
+ dataTable.setWidthPercentage(widthPercentage);
|
|
|
+ dataTable.setTotalWidth(floats);
|
|
|
+ dataTable.addCell(pdfTableStyle(map.get("examiningItem"), size10font, high, false, true));
|
|
|
+ dataTable.addCell(pdfTableStyle(map.get("unqualifiedObject"), size10font, high, true, true));
|
|
|
+ //如果出现不相同,则合并之前的
|
|
|
+ document.add(dataTable);
|
|
|
}
|
|
|
document.close();
|
|
|
writer.close();
|