From f0afb2b17f2f6e13925ffe1b6fd8c8ae724aec0e Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期四, 13 三月 2025 10:46:24 +0800 Subject: [PATCH] 分支合并冲突解决 --- inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java | 233 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 118 insertions(+), 115 deletions(-) diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java index 735cbaa..e7a5ed2 100644 --- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java +++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java @@ -2,8 +2,7 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONArray; -import com.aspose.words.License; -import com.aspose.words.SaveFormat; +import com.aspose.words.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -20,26 +19,22 @@ import com.itextpdf.text.pdf.PdfContentByte; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.PdfStamper; -import com.ruoyi.common.config.MinioConfig; import com.ruoyi.common.core.domain.entity.User; -import com.ruoyi.common.enums.AttachmentType; -import com.ruoyi.common.mapper.AttachmentTableMapper; -import com.ruoyi.common.pojo.AttachmentTable; -import com.ruoyi.common.service.AttachmentTableService; import com.ruoyi.common.utils.QueryWrappers; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.exception.ErrorException; import com.ruoyi.inspect.dto.ReportPageDto; -import com.ruoyi.inspect.mapper.*; +import com.ruoyi.inspect.mapper.InsOrderMapper; +import com.ruoyi.inspect.mapper.InsOrderStateMapper; +import com.ruoyi.inspect.mapper.InsReportApproveConfigMapper; +import com.ruoyi.inspect.mapper.InsReportMapper; import com.ruoyi.inspect.pojo.InsOrder; import com.ruoyi.inspect.pojo.InsOrderState; import com.ruoyi.inspect.pojo.InsReport; -import com.ruoyi.process.pojo.ProcessReport; import com.ruoyi.inspect.service.InsReportService; import com.ruoyi.process.mapper.ProcessReportMapper; +import com.ruoyi.process.pojo.ProcessReport; import com.ruoyi.system.mapper.UserMapper; -import io.minio.MinioClient; -import io.minio.PutObjectArgs; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; @@ -67,6 +62,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; @@ -83,16 +79,6 @@ @Slf4j public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport> implements InsReportService { - - @Resource - private AttachmentTableMapper attachmentTableMapper; - - @Resource - private AttachmentTableService attachmentTableService; - - @Resource - private MinioConfig minioConfig; - @Resource @@ -145,13 +131,14 @@ } } QueryWrapper<ReportPageDto> wrapper = QueryWrappers.queryWrappers(reportPageDto); - if(Objects.nonNull(reportPageDto) && Objects.nonNull(reportPageDto.getCreateTimeRange())){ + if(Objects.nonNull(reportPageDto.getCreateTimeRange())){ wrapper.gt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(0)) .lt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(1)); } IPage<ReportPageDto> iPage = insReportMapper.pageInsReport(page, wrapper, laboratory); return iPage; } + @Override public int inReport(String url, Integer id) { @@ -163,20 +150,17 @@ // 杩樺師 @Override - public void upReportUrl(Integer id,Integer type) { - List<AttachmentTable> attachmentTables = attachmentTableMapper.selectList(new LambdaQueryWrapper<AttachmentTable>() - .eq(AttachmentTable::getSubclassId, id) - .eq(AttachmentTable::getOtherTableName, AttachmentType.getAttachmentValue(type)) - .orderByAsc(AttachmentTable::getId)); - if(CollectionUtils.isNotEmpty(attachmentTables)) { - // 鑾峰彇鎵�鏈夌殑id - List<Integer> collect = attachmentTables.stream().map(AttachmentTable::getId).collect(Collectors.toList()); - // 闄や簡绗竴涓叏閮ㄥ垹闄� 鍒犻櫎鎵�鏈夌殑闄勪欢 - collect.remove(0); - if(collect.size() > 0) { - attachmentTableMapper.deleteBatchIds(collect); + public int upReportUrl(Integer id) { + InsReport insReport = insReportMapper.selectById(id); + String fileName = insReport.getUrlS().replace("/word/", ""); + if(Strings.isNotEmpty(fileName)) { + String path = wordUrl + File.separator + fileName; + File file = new File(path); + if (file.exists()) { + file.delete(); } } + return insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate().eq(InsReport::getId, id).set(InsReport::getUrlS, null)); } @Override @@ -223,91 +207,40 @@ //鎻愪氦 @Override public int writeReport(Integer id) { - int userId = Integer.parseInt(SecurityUtils.getUserId() + ""); InsReport insReport = insReportMapper.selectById(id); insReport.setId(id); insReport.setState(1); insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿 - insReport.setWriteUserId(userId);//鎻愪氦浜� + insReport.setWriteUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//鎻愪氦浜� + //鑾峰彇鎻愪氦浜虹殑绛惧悕鍦板潃 + String signatureUrl; + try { + signatureUrl = userMapper.selectById(Integer.getInteger(SecurityUtils.getUserId().toString())).getSignatureUrl(); + } catch (Exception e) { + throw new ErrorException("鎵句笉鍒扮紪鍒朵汉鐨勭鍚�"); + } + //绯荤粺鐢熸垚鎶ュ憡鍦板潃 + String url = insReport.getUrl(); + //鎵嬪姩涓婁紶鎶ュ憡鍦板潃 + String urlS = insReport.getUrlS(); + wordInsertUrl(new HashMap<String, Object>() {{ + put("writeUrl", new FilePictureRenderData(100,50,imgUrl + "/" + signatureUrl)); + }}, (urlS == null ? url : urlS).replace("/word", wordUrl)); + // 淇敼涓存椂pdf + String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl)); + insReport.setTempUrlPdf("/word/" + tempUrlPdf); return insReportMapper.updateById(insReport); } - - /** - * 鍒涘缓涓存椂鏂囦欢 - * @param inputStream 杈撳叆娴� - * @param suffix 鍚庣紑 - * @return - */ - public String temporaryFile(InputStream inputStream,String suffix) { - String tempFilePath = ""; - try { - File tempFile = File.createTempFile(UUID.randomUUID().toString(), suffix); - tempFile.deleteOnExit(); - // 灏嗚緭鍏ユ祦鍐呭璧嬪�肩殑涓存椂鏂囦欢 - try(FileOutputStream fileInputStream = new FileOutputStream(tempFile)) { - byte[] bytes = new byte[1024]; - int len; - while((len = inputStream.read(bytes)) != -1) { - fileInputStream.write(bytes,0,len); - } - // 鑾峰彇涓存椂鏂囦欢鐨勮矾寰� - tempFilePath = tempFile.getAbsolutePath(); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - return tempFilePath; - } - - - /** - * 灏嗘枃浠朵笂浼犲埌Minio - * @return - */ - public void uploadMinio(String url,Integer id) { - String suffix = url.substring(url.lastIndexOf(".")); - // 閲嶆柊涓婁紶鍒癕inIo - File file = new File(url); - String fileName = UUID.randomUUID().toString() + suffix; - FileInputStream stream = null; - try { - MinioClient build = MinioClient.builder().endpoint(minioConfig.getEndpoint(), minioConfig.getPort(), minioConfig.getSecure()) - .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey()) - .build(); - stream = new FileInputStream(file); - build.putObject( - PutObjectArgs.builder() - .bucket(minioConfig.getBucketName()) - .object(fileName) - .stream(stream, file.length(), -1) - .contentType("application/octet-stream") - .userMetadata(Collections.singletonMap("Content-Disposition", "attachment; filename=\"" + fileName + "\"")) - .build() - ); - // 淇濆瓨鍒版暟鎹簱 - AttachmentTable attachmentTable = new AttachmentTable(); - attachmentTable.setBucketName(minioConfig.getBucketName()); - attachmentTable.setFileName(fileName); - attachmentTable.setSubclassId(id); - attachmentTable.setOtherTableName(AttachmentType.getAttachmentValue(1)); - attachmentTableMapper.insert(attachmentTable); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - //瀹℃牳 @Override public int examineReport(Integer id, Integer isExamine, String examineTell) { - int userId = Integer.parseInt(SecurityUtils.getUserId() + ""); InsReport insReport = insReportMapper.selectById(id); insReport.setIsExamine(isExamine); if (ObjectUtils.isNotEmpty(examineTell)) { insReport.setExamineTell(examineTell); } - insReport.setExamineUserId(userId);//瀹℃牳浜� + insReport.setExamineUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//瀹℃牳浜� insReport.setExamineTime(LocalDateTime.now());//瀹℃牳鏃堕棿 if (isExamine == 0) { //濡傛灉瀹℃牳涓嶉�氳繃 @@ -338,13 +271,12 @@ @Override @Transactional(rollbackFor = Exception.class) public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) { - int userId = Integer.parseInt(SecurityUtils.getUserId() + ""); InsReport insReport = insReportMapper.selectById(id); insReport.setIsRatify(isRatify); if (ObjectUtils.isNotEmpty(ratifyTell)) { insReport.setRatifyTell(ratifyTell); } - insReport.setRatifyUserId(userId);//鎵瑰噯浜� + insReport.setRatifyUserId(Integer.getInteger(SecurityUtils.getUserId().toString()));//鎵瑰噯浜� insReport.setRatifyTime(LocalDateTime.now());//鎵瑰噯鏃堕棿 if (isRatify == 0) { //濡傛灉鎵瑰噯涓嶉�氳繃 @@ -523,9 +455,8 @@ @Override public Map<String, Object> getReportCountInfo(ReportPageDto reportPageDto) { - int userId = Integer.parseInt(SecurityUtils.getUserId() + ""); HashMap<String, Object> map = new HashMap<>(); - User user = userMapper.selectById(userId);//褰撳墠鐧诲綍鐨勪汉 + User user = userMapper.selectById(SecurityUtils.getUserId());//褰撳墠鐧诲綍鐨勪汉 //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id String departLimsId = user.getDepartLimsId(); String laboratory = null; @@ -538,7 +469,7 @@ } } QueryWrapper<ReportPageDto> wrapper = QueryWrappers.queryWrappers(reportPageDto); - if(Objects.nonNull(reportPageDto) && Objects.nonNull(reportPageDto.getCreateTimeRange())){ + if(Objects.nonNull(reportPageDto.getCreateTimeRange())){ wrapper.gt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(0)) .lt(reportPageDto.getCreateTimeRange().size()>1,"create_time",reportPageDto.getCreateTimeRange().get(1)); @@ -553,7 +484,7 @@ @Transactional(rollbackFor = Exception.class) public void batchApprovalReport(List<Integer> ids) { redisTemplate.setKeySerializer(new StringRedisSerializer()); - Integer userId = Integer.parseInt(SecurityUtils.getUserId() + ""); + Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString()); String key = SYNC_REPORT_KEY_PREFIX+userId; //鎵ц鍓嶅垹闄や箣鍓嶇殑keys deleteRedisKeys(key); @@ -682,7 +613,7 @@ @Override public Map<String, Object> getBatchApprovalProgress() { - Integer userId = Integer.parseInt(SecurityUtils.getUserId() + ""); + Integer userId = Integer.parseInt(SecurityUtils.getUserId().toString()); String key = SYNC_REPORT_KEY_PREFIX + userId; Map<String, Object> map = new HashMap<>(); map.put("hasProgress",false); @@ -773,7 +704,7 @@ */ public String wordToPdfTemp(String path) { try { - return wordToPdf(path, path.replace(".docx", "")); + return wordToPdf(path, path.replace(".docx", ".pdf")); } catch (Exception e) { throw new ErrorException("杞崲澶辫触"); } @@ -793,14 +724,13 @@ //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 File file; //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛� - file = File.createTempFile(pdfPath, ".pdf"); - file.deleteOnExit(); + file = new File(pdfPath); os = new FileOutputStream(file); //瑕佽浆鎹㈢殑word鏂囦欢 com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); doc.save(os, SaveFormat.PDF); String name = file.getName(); - return file.getAbsolutePath(); + return file.getName(); } catch (Exception e) { e.printStackTrace(); } finally { @@ -814,6 +744,73 @@ } return null; } + +// @Override +// public void wordToPdf(String path, String sealUrl) { +// CompletableFuture.supplyAsync(() -> { +// try { +// wordToPdf(path, path.replace(".docx", ".pdf"), sealUrl); +// return null; +// } catch (Exception e) { +// throw new ErrorException("杞崲澶辫触"); +// } +// }).thenAccept(res -> { +// }).exceptionally(e -> { +// e.printStackTrace(); +// return null; +// }); +// } + + + +// public String wordToPdf(String wordPath, String pdfPath, String sealUrl) { +// FileOutputStream os = null; +// try { +// //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃 +//// InputStream inputStream = this.getClass().getResourceAsStream("/lib/license.xml"); +// /*String url; +// try { +// InputStream inputStream = this.getClass().getResourceAsStream("/lib/license.xml"); +// File file = File.createTempFile("temp", ".tmp"); +// OutputStream outputStream = new FileOutputStream(file); +// IOUtils.copy(inputStream, outputStream); +// url = file.getAbsolutePath(); +// } catch (FileNotFoundException e) { +// throw new ErrorException("鎵句笉鍒版ā鏉挎枃浠�"); +// } catch (IOException e) { +// throw new RuntimeException(e); +// }*/ +// InputStream is = new ClassPathResource("/lib/license.xml").getInputStream(); +// License license = new License(); +// license.setLicense(is); +// if (!license.getIsLicensed()) { +// System.out.println("License楠岃瘉涓嶉�氳繃..."); +// return null; +// } +// //鐢熸垚涓�涓┖鐨凱DF鏂囦欢 +// File file = new File(pdfPath.replace(".pdf", "-1.pdf")); +// os = new FileOutputStream(file); +// //瑕佽浆鎹㈢殑word鏂囦欢 +// com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); +// doc.save(os, SaveFormat.PDF); +// +// //娣诲姞楠戠紳绔� +// stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); +// +// +// } catch (Exception e) { +// e.printStackTrace(); +// } finally { +// if (os != null) { +// try { +// os.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// return null; +// } /** * 鍒囧壊鍥剧墖 @@ -874,3 +871,9 @@ stamp.close(); } } + + + + + + -- Gitblit v1.9.3