| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.manage.mapper.ManageDocumentControlledMapper; |
| | | import com.ruoyi.manage.mapper.ManageDocumentListMapper; |
| | | import com.ruoyi.manage.mapper.ManageRecordCheckMapper; |
| | |
| | | import com.ruoyi.manage.pojo.ManageDocumentList; |
| | | import com.ruoyi.manage.pojo.ManageRecordCheck; |
| | | import com.ruoyi.manage.service.ManageDocumentControlledService; |
| | | import com.ruoyi.manage.util.DocumentPreviewUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Override |
| | | public void checkManageDocumentControlledPdf(Long id, HttpServletResponse response) throws Exception { |
| | | ManageDocumentControlled manageDocumentControlled = manageDocumentControlledMapper.selectById(id); |
| | | File file = new File(wordUrl + "/" + manageDocumentControlled.getUrl()); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | response.setContentType("application/pdf"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-disposition", "inline;filename=" + file.getName()); |
| | | response.setContentLength((int)file.length()); |
| | | OutputStream os = response.getOutputStream(); |
| | | // 将文件内容写入输出流 |
| | | byte[] buffer = new byte[4096]; |
| | | int bytesRead; |
| | | while ((bytesRead = fileInputStream.read(buffer)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | if (manageDocumentControlled == null || ObjectUtils.isEmpty(manageDocumentControlled.getUrl())) { |
| | | throw new ErrorException("文件未上传"); |
| | | } |
| | | os.flush(); |
| | | os.close(); |
| | | // PDF 直接输出,Word/图片在线转 PDF,供前端预览盖章 |
| | | DocumentPreviewUtils.writeAsPdf(new File(wordUrl + "/" + manageDocumentControlled.getUrl()), response); |
| | | } |
| | | |
| | | } |