|
@@ -20,7 +20,6 @@ import com.bosshand.virgo.file.seal.model.Seal;
|
|
|
import com.bosshand.virgo.file.seal.model.SealRegister;
|
|
|
import com.bosshand.virgo.file.seal.model.SealRegisterKey;
|
|
|
import com.bosshand.virgo.file.seal.model.SealRequest;
|
|
|
-import com.bosshand.virgo.file.service.ApiClient;
|
|
|
import com.bosshand.virgo.file.service.FileManagerService;
|
|
|
import com.bosshand.virgo.file.util.AliyunOSSUtil;
|
|
|
import com.bosshand.virgo.file.util.Doc2Pdf;
|
|
@@ -77,192 +76,76 @@ public class DocumentService {
|
|
|
@Autowired
|
|
|
SealDao sealDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- ApiClient apiClient;
|
|
|
-
|
|
|
@Autowired
|
|
|
DocumentFileArchivedDao documentFileArchivedDao;
|
|
|
|
|
|
@Autowired
|
|
|
CollaborativeArchiveDao collaborativeArchiveDao;
|
|
|
|
|
|
- public CollaborativeArchive insertCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
|
|
|
- collaborativeArchiveDao.insert(collaborativeArchive);
|
|
|
- return collaborativeArchive;
|
|
|
- }
|
|
|
-
|
|
|
- public List<CollaborativeArchive> getListByCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
|
|
|
- return collaborativeArchiveDao.getList(collaborativeArchive);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////////////
|
|
|
- // Category management
|
|
|
- //////////////////////////////////////////////////////////////////
|
|
|
- public DocumentCategory createCategory(String name, int parentId) throws ServiceException {
|
|
|
-
|
|
|
- if (parentId != DocumentCategory.ROOT_ID) {
|
|
|
- DocumentCategory category = documentCategoryDao.get(parentId);
|
|
|
- if (category == null) {
|
|
|
- throw new ServiceException("Incorrect parent category");
|
|
|
+ /**
|
|
|
+ * 合同标签
|
|
|
+ */
|
|
|
+ private List<DocumentCategory> getChildren(List<DocumentCategory> list, long parentId) {
|
|
|
+ List<DocumentCategory> tree = new ArrayList<DocumentCategory>();
|
|
|
+ for (DocumentCategory category : list) {
|
|
|
+ if (category.getParentId() == parentId) {
|
|
|
+ tree.add(category);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if (StringUtils.isBlank(name)) {
|
|
|
- throw new ServiceException("Incorrect category name");
|
|
|
- }
|
|
|
-
|
|
|
- DocumentCategory newCategory = new DocumentCategory();
|
|
|
- newCategory.setName(name);
|
|
|
- newCategory.setParentId(parentId);
|
|
|
-
|
|
|
- documentCategoryDao.create(newCategory);
|
|
|
-
|
|
|
- return newCategory;
|
|
|
- }
|
|
|
-
|
|
|
- public DocumentCategory getCategory(int id) throws ServiceException {
|
|
|
-
|
|
|
- DocumentCategory newCategory = documentCategoryDao.get(id);
|
|
|
-
|
|
|
- if (newCategory == null) {
|
|
|
- throw new ServiceException("No such category");
|
|
|
+ for (DocumentCategory node : tree) {
|
|
|
+ node.setChildren(getChildren(list, node.getId()));
|
|
|
}
|
|
|
-
|
|
|
- return newCategory;
|
|
|
-
|
|
|
+ return tree;
|
|
|
}
|
|
|
|
|
|
- public List<DocumentCategory> listCategory(int id) throws ServiceException {
|
|
|
-
|
|
|
- if (id != DocumentCategory.ROOT_ID) {
|
|
|
- DocumentCategory category = documentCategoryDao.get(id);
|
|
|
- if (category == null) {
|
|
|
- throw new ServiceException("Incorrect parent category");
|
|
|
- }
|
|
|
+ public List<DocumentCategory> getDirectory(long organizationId, long projectId){
|
|
|
+ List<DocumentCategory> List = documentCategoryDao.getRoot(organizationId, projectId);
|
|
|
+ List<DocumentCategory> allList = documentCategoryDao.getList(organizationId, projectId);
|
|
|
+ for(DocumentCategory category : List){
|
|
|
+ category.setChildren(this.getChildren(allList, category.getId()));
|
|
|
}
|
|
|
-
|
|
|
- return documentCategoryDao.list(id);
|
|
|
+ return List;
|
|
|
}
|
|
|
|
|
|
- public DocumentCategory updateCategory(int id, String name) throws ServiceException {
|
|
|
-
|
|
|
- if (id == DocumentCategory.ROOT_ID) {
|
|
|
- throw new ServiceException("can not update root category");
|
|
|
- }
|
|
|
-
|
|
|
+ public int deleteCategory(long id) {
|
|
|
DocumentCategory category = documentCategoryDao.get(id);
|
|
|
if (category == null) {
|
|
|
throw new ServiceException("Incorrect category");
|
|
|
}
|
|
|
- category.setName(name);
|
|
|
-
|
|
|
- documentCategoryDao.update(category);
|
|
|
-
|
|
|
- return category;
|
|
|
+ return documentCategoryDao.delete(id);
|
|
|
}
|
|
|
|
|
|
- public void deleteCategory(int id) throws ServiceException {
|
|
|
-
|
|
|
- if (id == DocumentCategory.ROOT_ID) {
|
|
|
- throw new ServiceException("can not update root category");
|
|
|
- }
|
|
|
-
|
|
|
- DocumentCategory category = documentCategoryDao.get(id);
|
|
|
- if (category == null) {
|
|
|
- throw new ServiceException("Incorrect category");
|
|
|
- }
|
|
|
-
|
|
|
- documentCategoryDao.delete(category);
|
|
|
-
|
|
|
+ public int saveCategory(DocumentCategory documentCategory) {
|
|
|
+ return documentCategoryDao.insert(documentCategory);
|
|
|
}
|
|
|
|
|
|
- public void deleteCategoryAndTemplate(int id) throws ServiceException {
|
|
|
-
|
|
|
- if (id == DocumentCategory.ROOT_ID) {
|
|
|
- throw new ServiceException("can not update root category");
|
|
|
- }
|
|
|
+ public int updateCategory(DocumentCategory documentCategory) {
|
|
|
+ return documentCategoryDao.update(documentCategory);
|
|
|
+ }
|
|
|
|
|
|
- DocumentCategory category = documentCategoryDao.get(id);
|
|
|
+ /**
|
|
|
+ * 合同模板
|
|
|
+ */
|
|
|
+ public void deleteCategoryAndTemplate(long categoryId) throws ServiceException {
|
|
|
+ DocumentCategory category = documentCategoryDao.get(categoryId);
|
|
|
if (category == null) {
|
|
|
throw new ServiceException("Incorrect category");
|
|
|
}
|
|
|
-
|
|
|
- documentCategoryDao.delete(category);
|
|
|
-
|
|
|
- documentTemplateDao.deleteByCategoryId(id);
|
|
|
-
|
|
|
- List<DocumentCategory> list = documentCategoryDao.list(id);
|
|
|
-
|
|
|
+ documentCategoryDao.delete(categoryId);
|
|
|
+ documentTemplateDao.deleteByCategoryId(categoryId);
|
|
|
+ List<DocumentCategory> list = documentCategoryDao.getParentId(categoryId);
|
|
|
for (DocumentCategory documentCategory : list) {
|
|
|
- if (documentCategory.getParentId() == id) {
|
|
|
+ if (documentCategory.getParentId() == categoryId) {
|
|
|
deleteCategoryAndTemplate(documentCategory.getId());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public DocumentCategory saveCategory(DocumentCategory documentCategory) {
|
|
|
- documentCategoryDao.create(documentCategory);
|
|
|
- return documentCategory;
|
|
|
- }
|
|
|
-
|
|
|
- public DocumentCategory updateCategory(DocumentCategory documentCategory) {
|
|
|
- documentCategoryDao.update(documentCategory);
|
|
|
- return documentCategory;
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentCategory> listCategory(DocumentCategory documentCategory) {
|
|
|
- return documentCategoryDao.getByList(documentCategory);
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentCategory> listAdjusted() {
|
|
|
- return documentCategoryDao.listAdjusted();
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentCategory> folder(Long[] ids) {
|
|
|
- return documentCategoryDao.folder(ids);
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentCategory> getDirectory(DocumentCategory documentCategory) {
|
|
|
-
|
|
|
- int parentId = documentCategory.getParentId();
|
|
|
- List<DocumentCategory> list = documentCategoryDao.list(parentId);
|
|
|
-
|
|
|
- documentCategory.setParentId(0);
|
|
|
- List<DocumentCategory> byList = documentCategoryDao.getByList(documentCategory);
|
|
|
- for(DocumentCategory dc : list){
|
|
|
- dc.setChildren(getChildren(byList, dc.getId()));
|
|
|
- }
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- private List<DocumentCategory> getChildren(List<DocumentCategory> list, int parentId) {
|
|
|
-
|
|
|
- List<DocumentCategory> tree = new ArrayList<DocumentCategory>();
|
|
|
-
|
|
|
- for (DocumentCategory category : list) {
|
|
|
- if (category.getParentId() == parentId) {
|
|
|
- tree.add(category);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (DocumentCategory node : tree) {
|
|
|
- node.setChildren(getChildren(list, node.getId()));
|
|
|
- }
|
|
|
-
|
|
|
- return tree;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //////////////////////////////////////////////////////////////////
|
|
|
- // Document Template management
|
|
|
- //////////////////////////////////////////////////////////////////
|
|
|
- public void deleteDocumentTemplate(int id) {
|
|
|
+ public void deleteDocumentTemplate(long id) {
|
|
|
documentTemplateDao.delete(id);
|
|
|
}
|
|
|
|
|
|
- public DocumentTemplate getTemplate(int id) {
|
|
|
+ public DocumentTemplate getTemplate(long id) {
|
|
|
return documentTemplateDao.get(id);
|
|
|
}
|
|
|
|
|
@@ -272,79 +155,13 @@ public class DocumentService {
|
|
|
|
|
|
public List<DocumentTemplate> getList(int categoryId, int currPage, int pageSize) {
|
|
|
Map<String, Object> data = new HashMap<String, Object>();
|
|
|
- data.put("id", categoryId);
|
|
|
+ data.put("categoryId", categoryId);
|
|
|
data.put("currIndex", (currPage - 1) * pageSize);
|
|
|
data.put("pageSize", pageSize);
|
|
|
- List<DocumentTemplate> list = documentTemplateDao.getList(data);
|
|
|
- if (list.size() > 0) {
|
|
|
- return sort(list);
|
|
|
- }
|
|
|
- return list;
|
|
|
+ return documentTemplateDao.getList(data);
|
|
|
}
|
|
|
|
|
|
- private List<DocumentTemplate> sort(List<DocumentTemplate> list) {
|
|
|
-
|
|
|
- List<DocumentTemplate> ls = new ArrayList<>();
|
|
|
-
|
|
|
- List<DocumentTemplate> ll = new ArrayList<>();
|
|
|
-
|
|
|
- for (DocumentTemplate t : list) {
|
|
|
- String name = t.getName();
|
|
|
- if (name.length() < 8) {
|
|
|
- ll.add(t);
|
|
|
- continue;
|
|
|
- }
|
|
|
- String num = name.substring(0, 8);
|
|
|
- if (StringUtils.isNumeric(num)) {
|
|
|
- ls.add(t);
|
|
|
- } else {
|
|
|
- ll.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- int listS = ls.size();
|
|
|
- for (int i = 0; i < listS - 1; i++) {
|
|
|
- for (int i1 = 0; i1 < listS - 1 - i; i1++) {
|
|
|
- DocumentTemplate dt1 = ls.get(i1);
|
|
|
- DocumentTemplate dt2 = ls.get(i1 + 1);
|
|
|
- String d1 = dt1.getName().substring(0, 8);
|
|
|
- String d2 = dt2.getName().substring(0, 8);
|
|
|
- d1 = Integer.parseInt(d1.substring(0, 1)) == 0 ? d1.substring(1, 8) : d1.substring(0, 8);
|
|
|
- d2 = Integer.parseInt(d2.substring(0, 1)) == 0 ? d2.substring(1, 8) : d2.substring(0, 8);
|
|
|
- if (Integer.parseInt(d1) > Integer.parseInt(d2)) {
|
|
|
- ls.set(i1, dt2);
|
|
|
- ls.set(i1 + 1, dt1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (ll.size() > 0) {
|
|
|
- ls.addAll(ll);
|
|
|
- }
|
|
|
- return ls;
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentTemplate> getList(String ids) {
|
|
|
- String[] split = ids.split(",");
|
|
|
- List<Integer> documentTemplateIds = new ArrayList<>();
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
- documentTemplateIds.add(Integer.parseInt(split[i]));
|
|
|
- }
|
|
|
- return documentTemplateDao.getIds(documentTemplateIds);
|
|
|
- }
|
|
|
-
|
|
|
- public List<DocumentTemplate> listTemplate(int categoryId) {
|
|
|
- List<DocumentTemplate> list = documentTemplateDao.list(categoryId);
|
|
|
-
|
|
|
- if (list.size() > 0) {
|
|
|
- return sort(list);
|
|
|
- }
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
- public DocumentTemplate importDocument(FileNode fileNode, int categoryId, String documentName, String comment,
|
|
|
- String tag) throws DocumentProcessException {
|
|
|
-
|
|
|
+ public DocumentTemplate importDocument(FileNode fileNode, long categoryId, String documentName, String comment) throws DocumentProcessException {
|
|
|
if (fileNode == null) {
|
|
|
throw new DocumentProcessException("File node was null");
|
|
|
}
|
|
@@ -352,31 +169,24 @@ public class DocumentService {
|
|
|
if (fileNode == null) {
|
|
|
throw new DocumentProcessException("File node not found");
|
|
|
}
|
|
|
-
|
|
|
log.info("Start import document with name " + fileNode.getName());
|
|
|
-
|
|
|
byte[] data = fileManagerService.getByte(fileNode.getId());
|
|
|
if (data == null) {
|
|
|
throw new DocumentProcessException("No data for import");
|
|
|
}
|
|
|
-
|
|
|
DocumentProcessor processor = DocumentProcessFactory.getProcessor(data);
|
|
|
if (processor == null) {
|
|
|
throw new DocumentProcessException("No processor match");
|
|
|
}
|
|
|
-
|
|
|
DocumentTemplate template = processor.importDocument(data, categoryId, documentName, comment);
|
|
|
if (template != null) {
|
|
|
documentTemplateDao.create(template);
|
|
|
}
|
|
|
-
|
|
|
return template;
|
|
|
}
|
|
|
|
|
|
public DocumentTemplate updateDocumentTemplate(DocumentTemplate tp) throws DocumentProcessException {
|
|
|
-
|
|
|
FileNode fileNode = tp.getFileNode();
|
|
|
-
|
|
|
if (fileNode == null) {
|
|
|
throw new DocumentProcessException("File node was null");
|
|
|
}
|
|
@@ -384,21 +194,16 @@ public class DocumentService {
|
|
|
if (fileNode == null) {
|
|
|
throw new DocumentProcessException("File node not found");
|
|
|
}
|
|
|
-
|
|
|
byte[] data = fileManagerService.getByte(fileNode.getId());
|
|
|
if (data == null) {
|
|
|
throw new DocumentProcessException("No data for import");
|
|
|
}
|
|
|
-
|
|
|
DocumentProcessor processor = DocumentProcessFactory.getProcessor(data);
|
|
|
if (processor == null) {
|
|
|
throw new DocumentProcessException("No processor match");
|
|
|
}
|
|
|
-
|
|
|
DocumentTemplate documentTemplate = documentTemplateDao.get(tp.getId());
|
|
|
-
|
|
|
DocumentTemplate template = processor.importDocument(data, documentTemplate.getCategoryId(), tp.getName(), documentTemplate.getComment());
|
|
|
-
|
|
|
if (documentTemplate != null) {
|
|
|
documentTemplate.setName(template.getName());
|
|
|
documentTemplate.setUpdateTime(template.getUpdateTime());
|
|
@@ -413,23 +218,19 @@ public class DocumentService {
|
|
|
return documentTemplate;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public byte[] renderTemplatePdf(int documentTemplateId) throws DocumentProcessException {
|
|
|
-
|
|
|
DocumentTemplate documentTemplate = documentTemplateDao.get(documentTemplateId);
|
|
|
-
|
|
|
if (documentTemplate == null) {
|
|
|
throw new DocumentProcessException("Template not found");
|
|
|
}
|
|
|
return DocumentProcessFactory.getProcessor(documentTemplate.getDocumentType()).renderDocumentTemplateToPDF(documentTemplate);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
// Document management
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
- public Document createDocument(Document document) throws DocumentProcessException {
|
|
|
|
|
|
+ public Document createDocument(Document document) throws DocumentProcessException {
|
|
|
if (document == null) {
|
|
|
throw new DocumentProcessException("Empty document");
|
|
|
}
|
|
@@ -442,11 +243,9 @@ public class DocumentService {
|
|
|
document.setCreateTime(new Date());
|
|
|
documentDao.insert(document);
|
|
|
return document;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public Document updateDocument(Document document) throws DocumentProcessException {
|
|
|
-
|
|
|
if (document == null) {
|
|
|
throw new DocumentProcessException("Empty document");
|
|
|
}
|
|
@@ -459,21 +258,17 @@ public class DocumentService {
|
|
|
document.setCreateTime(new Date());
|
|
|
documentDao.update(document);
|
|
|
return document;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public Document getDocument(int documentId) throws DocumentProcessException {
|
|
|
-
|
|
|
Document document = documentDao.get(documentId);
|
|
|
if (document == null) {
|
|
|
throw new DocumentProcessException("document not found");
|
|
|
}
|
|
|
return document;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public byte[] renderDocument(int documentId) throws DocumentProcessException {
|
|
|
-
|
|
|
Document document = getDocument(documentId);
|
|
|
if (document == null) {
|
|
|
throw new DocumentProcessException("Can not find the document");
|
|
@@ -483,15 +278,15 @@ public class DocumentService {
|
|
|
throw new DocumentProcessException("Can not find the data template");
|
|
|
}
|
|
|
return DocumentProcessFactory.getProcessor(document.getDocumentType()).renderDocument(document, template);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public byte[] archivedFile(int documentId) {
|
|
|
-// DocumentFileArchived archived = documentFileArchivedDao.getDocumentId(documentId);
|
|
|
-// if (archived != null) {
|
|
|
-// return AliyunOSSUtil.getByte(archived.getNode());
|
|
|
-// }
|
|
|
-// return null;
|
|
|
+ /*DocumentFileArchived archived = documentFileArchivedDao.getDocumentId(documentId);
|
|
|
+ if (archived != null) {
|
|
|
+ return AliyunOSSUtil.getByte(archived.getNode());
|
|
|
+ }
|
|
|
+ return null;*/
|
|
|
+
|
|
|
byte[] pdf = null;
|
|
|
try {
|
|
|
pdf = RenderDocumentToPdf(documentId, "");
|
|
@@ -560,25 +355,22 @@ public class DocumentService {
|
|
|
}
|
|
|
|
|
|
public byte[] RenderDocumentToPdf(int documentId, String projectName) throws DocumentProcessException {
|
|
|
- //return PdfWatermark.watermark(RenderDocumentToPdf(documentId), projectName + "档案文件");
|
|
|
+ /*return PdfWatermark.watermark(RenderDocumentToPdf(documentId), projectName + "档案文件");*/
|
|
|
return RenderDocumentToPdf(documentId);
|
|
|
}
|
|
|
|
|
|
public byte[] RenderDocumentToPdf(int documentId) throws DocumentProcessException {
|
|
|
-
|
|
|
Document document = getDocument(documentId);
|
|
|
if (document == null) {
|
|
|
throw new DocumentProcessException("Can not find the document");
|
|
|
}
|
|
|
-
|
|
|
DocumentTemplate template = getTemplate(document.getDocumentTemplateId());
|
|
|
if (template == null) {
|
|
|
throw new DocumentProcessException("Can not find the data template");
|
|
|
}
|
|
|
-
|
|
|
byte[] pdfdata = DocumentProcessFactory.getProcessor(document.getDocumentType()).renderToPDF(document, template);
|
|
|
|
|
|
- // add seal
|
|
|
+ // 加入印章
|
|
|
byte[] sealToPdf = null;
|
|
|
List<Map<String, Object>> list = getSealKayWord(documentId);
|
|
|
if (list.size() > 0) {
|
|
@@ -587,12 +379,13 @@ public class DocumentService {
|
|
|
sealToPdf = pdfdata;
|
|
|
}
|
|
|
|
|
|
- // add behavior track
|
|
|
- //List<String> behaviorTrack = getBehaviorTrack(documentId);
|
|
|
+ // 加入操作轨迹
|
|
|
+ /*List<String> behaviorTrack = getBehaviorTrack(documentId);
|
|
|
+ return PdfKeywordFinder.additionalPage(sealToPdf, null, chainQRCode(documentId));*/
|
|
|
|
|
|
- //return PdfKeywordFinder.additionalPage(sealToPdf, null, chainQRCode(documentId));
|
|
|
return sealToPdf;
|
|
|
}
|
|
|
+
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
// ElementData management
|
|
|
//////////////////////////////////////////////////////////////////
|
|
@@ -602,9 +395,7 @@ public class DocumentService {
|
|
|
}
|
|
|
|
|
|
public ElementData saveOrUpdateElementData(ElementData elementData) throws DocumentProcessException {
|
|
|
-
|
|
|
getDocument(elementData.getDocumentId());
|
|
|
-
|
|
|
if (elementData.getId() != -1 && elementData.getId() != 0) {
|
|
|
elementData = getElementData(elementData.getId());
|
|
|
if (elementData == null) {
|
|
@@ -618,14 +409,18 @@ public class DocumentService {
|
|
|
return elementData;
|
|
|
}
|
|
|
|
|
|
- // Fuzzy Query
|
|
|
+ /**
|
|
|
+ * 模糊查询
|
|
|
+ */
|
|
|
public List<DocumentTemplate> getFuzzy(String name) {
|
|
|
DocumentTemplate documentTemplate = new DocumentTemplate();
|
|
|
documentTemplate.setName(name);
|
|
|
return documentTemplateDao.getFuzzy(documentTemplate);
|
|
|
}
|
|
|
|
|
|
- // Get PDF file
|
|
|
+ /**
|
|
|
+ * 获取pdf文件
|
|
|
+ */
|
|
|
public List<FileNode> getDocumentIds(String documentIds) {
|
|
|
List<DocumentFile> dfs = documentFileDao.getListByDocumentIds(documentIds.split(","));
|
|
|
List<Integer> fileNodeIds = new ArrayList<>();
|
|
@@ -633,7 +428,9 @@ public class DocumentService {
|
|
|
return fileNodeDao.getIds(fileNodeIds);
|
|
|
}
|
|
|
|
|
|
- // Conversion to PDF file
|
|
|
+ /**
|
|
|
+ * 判断转换成pdf文件
|
|
|
+ */
|
|
|
public boolean conversionToPdf(String documentIds) throws DocumentProcessException {
|
|
|
String[] ids = documentIds.split(",");
|
|
|
List<DocumentFile> list = documentFileDao.getListByDocumentIds(ids);
|
|
@@ -644,7 +441,6 @@ public class DocumentService {
|
|
|
}
|
|
|
return isS;
|
|
|
}
|
|
|
-
|
|
|
List<String> dList = new ArrayList<>();
|
|
|
for (int i = 0; i < ids.length; i++) {
|
|
|
boolean find = false;
|
|
@@ -669,20 +465,16 @@ public class DocumentService {
|
|
|
}
|
|
|
|
|
|
public boolean renderDocumentToPdf(int documentId) throws DocumentProcessException {
|
|
|
-
|
|
|
Document document = getDocument(documentId);
|
|
|
DocumentTemplate template = getTemplate(document.getDocumentTemplateId());
|
|
|
if (template == null) {
|
|
|
throw new DocumentProcessException("Can not find the data template");
|
|
|
}
|
|
|
-
|
|
|
byte[] dm = DocumentProcessFactory.getProcessor(document.getDocumentType()).renderDocument(document, template);
|
|
|
byte[] pdfdata = Doc2Pdf.doc2pdf(dm, getBehaviorTrack(document.getId()), chainQRCode(document.getId()));
|
|
|
-
|
|
|
if (pdfdata == null) {
|
|
|
throw new DocumentProcessException("License have failed");
|
|
|
}
|
|
|
-
|
|
|
byte[] sealToPdf = null;
|
|
|
List<Map<String, Object>> list = getSealKayWord(documentId);
|
|
|
if (list.size() > 0) {
|
|
@@ -690,21 +482,20 @@ public class DocumentService {
|
|
|
} else {
|
|
|
sealToPdf = pdfdata;
|
|
|
}
|
|
|
-
|
|
|
InputStream is = null;
|
|
|
if (sealToPdf != null) {
|
|
|
is = new ByteArrayInputStream(sealToPdf);
|
|
|
}
|
|
|
-
|
|
|
FileNode fileNode = fileManagerService.create(is, document.getName() + ".pdf", 201);
|
|
|
DocumentFile documentFile = new DocumentFile();
|
|
|
documentFile.setDocumentId(documentId);
|
|
|
documentFile.setFileNodeId(fileNode.getId());
|
|
|
return documentFileDao.insert(documentFile) == 1;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- // seal part
|
|
|
+ /**
|
|
|
+ * 印章区域
|
|
|
+ */
|
|
|
private List<Map<String, Object>> getSealKayWord(int documentId) {
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
List<SealRequest> sealRequestList = sealRequestDao.getByDocumentId(documentId);
|
|
@@ -730,7 +521,9 @@ public class DocumentService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- // behavior track
|
|
|
+ /**
|
|
|
+ * 操作轨迹
|
|
|
+ */
|
|
|
private List<String> getBehaviorTrack(int documentId) {
|
|
|
List<String> string = new ArrayList<>();
|
|
|
List<BehaviorTrack> list = behaviorTrackDao.getDocumentId(documentId);
|
|
@@ -750,12 +543,13 @@ public class DocumentService {
|
|
|
return string;
|
|
|
}
|
|
|
|
|
|
- // chain QRCode
|
|
|
+ /**
|
|
|
+ * 生成区块链二维码
|
|
|
+ */
|
|
|
private byte[] chainQRCode(int documentId) {
|
|
|
- String url = JSONObject.parseObject(apiClient.get()).getString("coordinationUrl");
|
|
|
byte[] qr = null;
|
|
|
try {
|
|
|
- qr = QRCodeUtil.getQRCodeBytes(url + "/manager/chain/" + documentId);
|
|
|
+ qr = QRCodeUtil.getQRCodeBytes("https://www.waywish.com/manager/chain/" + documentId);
|
|
|
} catch (Exception e) {
|
|
|
throw new ServiceException("qr is fail");
|
|
|
}
|
|
@@ -769,35 +563,6 @@ public class DocumentService {
|
|
|
public List<BehaviorTrack> getBehaviorTrackListByUserId(String userId) {
|
|
|
return behaviorTrackDao.getByUserId(userId);
|
|
|
}
|
|
|
-//
|
|
|
-// public FileNode previewTemplatePdf(int documentTemplateId) throws DocumentProcessException {
|
|
|
-//
|
|
|
-// DocumentTemplate documentTemplate = documentTemplateDao.get(documentTemplateId);
|
|
|
-//
|
|
|
-// byte[] dm = DocumentProcessFactory.getProcessor(documentTemplate.getDocumentType()).renderDocumentTemplateToPDF(documentTemplate);
|
|
|
-// if(dm == null){
|
|
|
-// throw new DocumentProcessException("License have failed");
|
|
|
-// }
|
|
|
-//
|
|
|
-// InputStream is = null;
|
|
|
-// try {
|
|
|
-// is = new ByteArrayInputStream(dm);
|
|
|
-// FileNode fileNode = null;
|
|
|
-// if (is != null) {
|
|
|
-// fileNode = fileManagerService.create(is, documentTemplate.getName() + ".pdf", 201);
|
|
|
-// }
|
|
|
-// return fileNode;
|
|
|
-// }
|
|
|
-// finally {
|
|
|
-// if(is != null) {
|
|
|
-// try {
|
|
|
-// is.close();
|
|
|
-// } catch (IOException e) {
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
|
|
|
public Map<String, String> getContextData(String dataRetriever) {
|
|
|
Map<String, String> ret = new HashMap<String, String>();
|
|
@@ -813,5 +578,14 @@ public class DocumentService {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ public CollaborativeArchive insertCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
|
|
|
+ collaborativeArchiveDao.insert(collaborativeArchive);
|
|
|
+ return collaborativeArchive;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CollaborativeArchive> getListByCollaborativeArchive(CollaborativeArchive collaborativeArchive) {
|
|
|
+ return collaborativeArchiveDao.getList(collaborativeArchive);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|