更新
This commit is contained in:
@@ -13,6 +13,7 @@ import org.apache.commons.logging.Log;
|
|||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@@ -45,16 +46,29 @@ public class A4CheckNode extends ACommonSuperNode {
|
|||||||
List<String> paths = fileUtil.fieldFileDownload(Long.parseLong(attachmentId), tempDir + File.separator + "oafile" + File.separator);
|
List<String> paths = fileUtil.fieldFileDownload(Long.parseLong(attachmentId), tempDir + File.separator + "oafile" + File.separator);
|
||||||
for (String path : paths) {
|
for (String path : paths) {
|
||||||
file = new File(path);
|
file = new File(path);
|
||||||
boolean firstPageA4 = DocumentA4Checker.isFirstPageA4(file);
|
try {
|
||||||
if (!firstPageA4) {
|
String fileName = file.getName().toLowerCase();
|
||||||
String errMsg = "上传的附件中" + file.getName() +"非标准A4格式的,请修改后再上传(标准A4为21:29)";
|
// 检测 docx 批注/痕迹:会导致转PDF后页面撑大,不再是A4
|
||||||
|
if (fileName.endsWith(".docx") || fileName.endsWith(".doc")) {
|
||||||
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
|
if (DocumentA4Checker.hasCommentsOrTrackChanges(fis)) {
|
||||||
|
String errMsg = "上传的附件" + file.getName() + "包含批注或修订痕迹,请清除后再上传";
|
||||||
formDataVo.getNewFieldDataMap().put("合同审批附件格式校验结果", errMsg);
|
formDataVo.getNewFieldDataMap().put("合同审批附件格式校验结果", errMsg);
|
||||||
return context.back(errMsg);
|
return context.back(errMsg);
|
||||||
}else {
|
|
||||||
formDataVo.getNewFieldDataMap().put("合同审批附件格式校验结果", "");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean firstPageA4 = DocumentA4Checker.isFirstPageA4(file);
|
||||||
|
if (!firstPageA4) {
|
||||||
|
String errMsg = "上传的附件中" + file.getName() + "非标准A4格式的,请修改后再上传(标准A4为210:297)";
|
||||||
|
formDataVo.getNewFieldDataMap().put("合同审批附件格式校验结果", errMsg);
|
||||||
|
return context.back(errMsg);
|
||||||
|
}
|
||||||
|
formDataVo.getNewFieldDataMap().put("合同审批附件格式校验结果", "");
|
||||||
|
} finally {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return context.success("文件A4格式校验通过");
|
return context.success("文件A4格式校验通过");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ public class EsignOneSignerNode extends ACommonSuperNode {
|
|||||||
param.setPageSize(1);
|
param.setPageSize(1);
|
||||||
param.setOrderField("UPDATE_DATE");
|
param.setOrderField("UPDATE_DATE");
|
||||||
param.setSortType("DESC");
|
param.setSortType("DESC");
|
||||||
Map<String, Object> sqlMap = FormTableExecutor.generateSql(param);
|
Map<String, Object> sqlMap = SqlGenerator.generateSql(param);
|
||||||
JDBCAgent agent = new JDBCAgent();
|
JDBCAgent agent = new JDBCAgent();
|
||||||
try {
|
try {
|
||||||
agent.execute((String)sqlMap.get("sql"), (List)sqlMap.get("params"));
|
agent.execute((String)sqlMap.get("sql"), (List)sqlMap.get("params"));
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.seeyon.apps.esign.po.signer;
|
package com.seeyon.apps.esign.po.signer;
|
||||||
|
|
||||||
import com.seeyon.apps.esign.config.EsignConfigProvider;
|
|
||||||
import com.seeyon.apps.esign.po.signfield.NormalSignFieldConfig;
|
import com.seeyon.apps.esign.po.signfield.NormalSignFieldConfig;
|
||||||
import com.seeyon.apps.esign.po.signfield.SignField;
|
import com.seeyon.apps.esign.po.signfield.SignField;
|
||||||
import com.seeyon.apps.esign.po.signfield.SignFieldPosition;
|
import com.seeyon.apps.esign.po.signfield.SignFieldPosition;
|
||||||
@@ -13,8 +12,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class JsonSignerBuilder implements SignerBuilder{
|
public class JsonSignerBuilder implements SignerBuilder{
|
||||||
|
|
||||||
private EsignConfigProvider esignConfigProvider = EsignConfigProvider.getInstance();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Signer build(List<String> fileIds, List<Object> keywordPos, SignParty party,String appId) {
|
public Signer build(List<String> fileIds, List<Object> keywordPos, SignParty party,String appId) {
|
||||||
if (party.getSignerType() == SignerType.PERSON) {
|
if (party.getSignerType() == SignerType.PERSON) {
|
||||||
|
|||||||
@@ -94,6 +94,71 @@ public class DocumentA4Checker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测 docx 中是否包含批注或修订痕迹
|
||||||
|
* 批注:word/comments.xml
|
||||||
|
* 痕迹:document.xml 中的 w:ins / w:del / w:delText / w:moveFrom / w:moveTo
|
||||||
|
*/
|
||||||
|
public static boolean hasCommentsOrTrackChanges(InputStream in) {
|
||||||
|
try {
|
||||||
|
byte[] docXmlBytes = null;
|
||||||
|
boolean hasComments = false;
|
||||||
|
|
||||||
|
try (ZipInputStream zis = new ZipInputStream(in)) {
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
|
if ("word/comments.xml".equals(entry.getName())) {
|
||||||
|
hasComments = true;
|
||||||
|
}
|
||||||
|
if ("word/document.xml".equals(entry.getName())) {
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
byte[] buf = new byte[4096];
|
||||||
|
int len;
|
||||||
|
while ((len = zis.read(buf)) != -1) {
|
||||||
|
bos.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
docXmlBytes = bos.toByteArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasComments) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析 document.xml 检测修订痕迹
|
||||||
|
if (docXmlBytes != null) {
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
Document doc = factory.newDocumentBuilder()
|
||||||
|
.parse(new ByteArrayInputStream(docXmlBytes));
|
||||||
|
return hasTrackChanges(doc.getDocumentElement());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 读取失败不拦截
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归检测 XML 树中是否包含修订痕迹元素
|
||||||
|
*/
|
||||||
|
private static boolean hasTrackChanges(Node node) {
|
||||||
|
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
String name = node.getNodeName();
|
||||||
|
if ("w:ins".equals(name) || "w:del".equals(name) || "w:delText".equals(name)
|
||||||
|
|| "w:moveFrom".equals(name) || "w:moveTo".equals(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NodeList children = node.getChildNodes();
|
||||||
|
for (int i = 0; i < children.getLength(); i++) {
|
||||||
|
if (hasTrackChanges(children.item(i))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验 docx 第一页是否竖版 A4
|
* 校验 docx 第一页是否竖版 A4
|
||||||
* 直接读取 ZIP 中的 word/document.xml,不依赖 POI ooxml 模块
|
* 直接读取 ZIP 中的 word/document.xml,不依赖 POI ooxml 模块
|
||||||
|
|||||||
Reference in New Issue
Block a user