|
|
@@ -1,26 +1,22 @@
|
|
|
package com.yingpaipay.business.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.yingpaipay.business.constant.DictTypeConst;
|
|
|
import com.yingpaipay.business.constant.DocumentAuditorTypeConst;
|
|
|
import com.yingpaipay.business.constant.DocumentStatusConst;
|
|
|
-import com.yingpaipay.business.constant.DocumentTypeConst;
|
|
|
import com.yingpaipay.business.domain.DocumentAuditLog;
|
|
|
import com.yingpaipay.business.domain.Folder;
|
|
|
import com.yingpaipay.business.domain.Project;
|
|
|
import com.yingpaipay.business.domain.bo.*;
|
|
|
import com.yingpaipay.business.domain.vo.*;
|
|
|
import com.yingpaipay.business.mapper.DocumentAuditLogMapper;
|
|
|
-import com.yingpaipay.common.file.util.WatermarkUtils;
|
|
|
+import com.yingpaipay.common.file.util.PdfUtils;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import org.apache.commons.io.FilenameUtils;
|
|
|
import org.dromara.common.core.exception.BusinessException;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.MessageUtils;
|
|
|
-import org.dromara.common.core.utils.SpringUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.core.utils.file.FileUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -35,7 +31,6 @@ import org.dromara.common.oss.factory.OssFactory;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.common.tenant.helper.TenantHelper;
|
|
|
import org.dromara.system.domain.vo.SysOssVo;
|
|
|
-import org.dromara.system.service.ISysDictDataService;
|
|
|
import org.dromara.system.service.ISysDictTypeService;
|
|
|
import org.dromara.system.service.ISysOssService;
|
|
|
import org.dromara.system.service.ISysUserService;
|
|
|
@@ -47,6 +42,9 @@ import com.yingpaipay.business.service.IDocumentService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
@@ -385,7 +383,7 @@ public class DocumentServiceImpl implements IDocumentService {
|
|
|
storage.download(sysOss.getFileName(), fos, null);
|
|
|
}
|
|
|
|
|
|
- File processedFile = WatermarkUtils.processFile(tempFile, buildRemark(ossId));
|
|
|
+ File processedFile = PdfUtils.watermark(tempFile, buildRemark(ossId));
|
|
|
|
|
|
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
|
|
|
@@ -563,6 +561,101 @@ public class DocumentServiceImpl implements IDocumentService {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<AppletDocumentScanSubmitVo> listToSubmit(AppletDocumentScanSubmitBo bo, PageQuery pageQuery) {
|
|
|
+ IPage<Document> page = baseMapper.selectPage(
|
|
|
+ pageQuery.build(),
|
|
|
+ Wrappers.lambdaQuery(Document.class)
|
|
|
+ .eq(Document::getSubmitterId, LoginHelper.getUserId())
|
|
|
+ .eq(Document::getStatus, List.of(DocumentStatusConst.UN_UPLOAD, DocumentStatusConst.AUDIT_REJECT))
|
|
|
+ .like(StringUtils.isNotBlank(bo.getName()), Document::getName, bo.getName())
|
|
|
+ .orderByDesc(Document::getId)
|
|
|
+ );
|
|
|
+ List<Long> projectIds = new ArrayList<>();
|
|
|
+ Map<Long, Folder> folderMap = new HashMap<>();
|
|
|
+ Map<Long, String> projectMap = new HashMap<>();
|
|
|
+
|
|
|
+ page.getRecords().forEach(e -> projectIds.add(e.getProjectId()));
|
|
|
+ projectService.queryByIds(projectIds).forEach(e -> projectMap.put(e.getId(), e.getName()));
|
|
|
+ List<Folder> folderList = folderService.queryByProjectIds(projectIds);
|
|
|
+ folderList.forEach(e -> folderMap.put(e.getId(), e));
|
|
|
+
|
|
|
+ return TableDataInfo.build(page.convert(e -> {
|
|
|
+ AppletDocumentScanSubmitVo vo = new AppletDocumentScanSubmitVo();
|
|
|
+ vo.setId(e.getId());
|
|
|
+ vo.setName(e.getName());
|
|
|
+
|
|
|
+ // 显示全路径
|
|
|
+ Folder currentFolder = folderMap.get(e.getFolderId());
|
|
|
+ String folder = "";
|
|
|
+ while (currentFolder != null) {
|
|
|
+ folder = "/" + currentFolder.getName() + folder;
|
|
|
+ currentFolder = folderMap.get(currentFolder.getParentId());
|
|
|
+ }
|
|
|
+ vo.setFolder(folder);
|
|
|
+
|
|
|
+ vo.setProject(projectMap.get(e.getProjectId()));
|
|
|
+ vo.setCreateBy(e.getCreateBy());
|
|
|
+ vo.setCreateTime(e.getCreateTime());
|
|
|
+ vo.setDeadline(e.getSubmitDeadline());
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean uploadOnSubmit(AppletUploadOnSubmitBo bo) {
|
|
|
+
|
|
|
+ Document document = baseMapper.selectById(bo.getDocumentId());
|
|
|
+
|
|
|
+ List<String> fileBase64List = bo.getFileBase64List();
|
|
|
+
|
|
|
+ if (fileBase64List == null || fileBase64List.isEmpty()) {
|
|
|
+ throw new BusinessException("提交的文件列表为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<File> files = new ArrayList<>();
|
|
|
+
|
|
|
+ File finalFile;
|
|
|
+ try {
|
|
|
+
|
|
|
+ for (int i = 0; i < fileBase64List.size(); i++) {
|
|
|
+ String base64Str = fileBase64List.get(i);
|
|
|
+ if (base64Str == null || base64Str.trim().isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ String cleanBase64 = base64Str;
|
|
|
+ if (base64Str.contains(",")) {
|
|
|
+ cleanBase64 = base64Str.split(",", 2)[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ byte[] pdfBytes = Base64.getDecoder().decode(cleanBase64);
|
|
|
+
|
|
|
+ Path tempPath = Files.createTempFile("document_", "_" + i + ".pdf");
|
|
|
+ Files.write(tempPath, pdfBytes);
|
|
|
+ files.add(tempPath.toFile());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (files.isEmpty()) {
|
|
|
+ throw new BusinessException("未解析到有效的 PDF 文件数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ finalFile = PdfUtils.merge(files, document.getName());
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ SysOssVo ossVo = ossService.upload(finalFile);
|
|
|
+
|
|
|
+ return baseMapper.update(
|
|
|
+ Wrappers.lambdaUpdate(Document.class)
|
|
|
+ .eq(Document::getId, bo.getDocumentId())
|
|
|
+ .set(Document::getOssId, ossVo.getOssId())
|
|
|
+ .set(Document::getStatus, DocumentStatusConst.UN_AUDIT)
|
|
|
+ .set(Document::getSubmitTime, new Date())
|
|
|
+ ) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
private LambdaQueryWrapper<Document> buildFilingListWrapper(TaskCenterFilingListBo bo, List<Long> folderIds) {
|
|
|
return Wrappers.lambdaQuery(Document.class)
|
|
|
.like(StringUtils.isNotBlank(bo.getName()), Document::getName, bo.getName())
|
|
|
@@ -607,7 +700,7 @@ public class DocumentServiceImpl implements IDocumentService {
|
|
|
private DocumentAuditLog buildLog(Document document, String type, DocumentAuditBo bo) {
|
|
|
DocumentAuditLog log = new DocumentAuditLog();
|
|
|
log.setDocumentId(document.getId());
|
|
|
- log.setOssId(bo.getOssId());
|
|
|
+ log.setOssId(bo.getOssId() != null ? bo.getOssId() : document.getOssId());
|
|
|
log.setAuditorType(type);
|
|
|
log.setAuditorId(LoginHelper.getUserId());
|
|
|
log.setResult(bo.getResult());
|