From c3c2f35d8fb91ecdf368a4b62dc8bb48ab5f39a1 Mon Sep 17 00:00:00 2001
From: lxp <1928192722@qq.com>
Date: 星期四, 13 三月 2025 09:45:48 +0800
Subject: [PATCH] 报告编制修改2.0
---
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java | 22 --
/dev/null | 218 ------------------------
cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsOrderPlanServiceImpl.java | 1
inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java | 6
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java | 233 +++++++++++++------------
ruoyi-system/src/main/resources/mapper/system/UserMapper.xml | 5
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java | 2
inspect-server/pom.xml | 1
8 files changed, 130 insertions(+), 358 deletions(-)
diff --git a/cnas-require/src/main/java/com/ruoyi/requier/service/InsReportService.java b/cnas-require/src/main/java/com/ruoyi/requier/service/InsReportService.java
deleted file mode 100644
index b7d5701..0000000
--- a/cnas-require/src/main/java/com/ruoyi/requier/service/InsReportService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.ruoyi.requier.service;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.ruoyi.inspect.dto.ReportPageDto;
-import com.ruoyi.inspect.pojo.InsReport;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-/**
-* @author Administrator
-* @description 閽堝琛ㄣ�恑ns_report(妫�楠屾姤鍛�)銆戠殑鏁版嵁搴撴搷浣淪ervice
-* @createDate 2024-03-17 22:10:02
-*/
-public interface InsReportService extends IService<InsReport> {
-
- IPage<ReportPageDto> pageInsReport(Page page, ReportPageDto reportPageDto);
-
-// void wordToPdf(String path,String sealUrl);
-
- int inReport(String url, Integer id);
-
- int upReportUrl(Integer id);
- // 涓嬭浇
- void downReport(Integer id, Integer type ,HttpServletResponse response);
-
- //鎻愪氦
- int writeReport(Integer id);
-
- //瀹℃牳
- int examineReport(Integer id, Integer isExamine, String examineTell);
-
- //鎵瑰噯
- int ratifyReport(Integer id, Integer isRatify, String ratifyTell);
-
- int wordInsertUrl(Map<String, Object> map, String url);
-
- String downAll(String ids);
-
- int upAll(MultipartFile file) throws IOException;
-
- void withdraw(Map<String,Object> map);
-
- List<Map<String,Object>> getLaboratoryByReportId(Integer id);
-
- Map<String,Object> getReportCountInfo(ReportPageDto reportPageDto);
-
- void batchApprovalReport(List<Integer> ids);
-
- Map<String,Object> getBatchApprovalProgress();
-}
diff --git a/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsOrderPlanServiceImpl.java b/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsOrderPlanServiceImpl.java
index 5430bc1..693b928 100644
--- a/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsOrderPlanServiceImpl.java
+++ b/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsOrderPlanServiceImpl.java
@@ -57,6 +57,7 @@
import com.ruoyi.inspect.service.InsUnPassService;
import com.ruoyi.inspect.service.impl.InsOrderServiceImpl;
import com.ruoyi.framework.util.SheetWriteHandlerUtil;
+import com.ruoyi.inspect.service.impl.InsReportServiceImpl;
import com.ruoyi.inspect.vo.*;
import com.ruoyi.performance.mapper.AuxiliaryOutputWorkingHoursMapper;
import com.ruoyi.performance.mapper.PerformanceShiftMapper;
diff --git a/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsReportServiceImpl.java b/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsReportServiceImpl.java
deleted file mode 100644
index fd71352..0000000
--- a/cnas-require/src/main/java/com/ruoyi/requier/service/impl/InsReportServiceImpl.java
+++ /dev/null
@@ -1,942 +0,0 @@
-package com.ruoyi.requier.service.impl;
-
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONArray;
-import com.aspose.words.Document;
-import com.aspose.words.License;
-import com.aspose.words.SaveFormat;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.deepoove.poi.XWPFTemplate;
-import com.deepoove.poi.data.FilePictureRenderData;
-import com.itextpdf.text.BadElementException;
-import com.itextpdf.text.DocumentException;
-import com.itextpdf.text.pdf.PdfContentByte;
-import com.itextpdf.text.pdf.PdfReader;
-import com.itextpdf.text.pdf.PdfStamper;
-import com.ruoyi.common.core.domain.entity.User;
-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.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.mapper.ProcessReportMapper;
-import com.ruoyi.process.pojo.ProcessReport;
-import com.ruoyi.requier.service.InsReportService;
-import com.ruoyi.system.mapper.UserMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.util.Strings;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.annotation.Resource;
-import javax.imageio.ImageIO;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import java.awt.image.BufferedImage;
-import java.io.*;
-import java.math.BigDecimal;
-import java.net.URLEncoder;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipOutputStream;
-
-/**
- * @author Administrator
- * @description 閽堝琛ㄣ�恑ns_report(妫�楠屾姤鍛�)銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇
- * @createDate 2024-03-17 22:10:02
- */
-@Service
-@Slf4j
-public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport>
- implements InsReportService {
-
- @Resource
- private UserMapper userMapper;
-
- @Resource
- private InsReportMapper insReportMapper;
-
- @Resource
- ProcessReportMapper processReportMapper;
-
- @Value("${wordUrl}")
- private String wordUrl;
-
- @Value("${file.licenseUrl}")
- private String licenseUrl;
-
- @Value("${file.path}")
- private String imgUrl;
-
- @Resource
- private InsOrderMapper insOrderMapper;
-
- @Resource
- private RedisTemplate<String, Object> redisTemplate;
-
- @Resource
- private ThreadPoolTaskExecutor threadPoolTaskExecutor;
-
- @Resource
- private InsOrderStateMapper insOrderStateMapper;
-
- private static final String SYNC_REPORT_KEY_PREFIX = "syncApprovalReport_lock_";
-
- @Resource
- private InsReportApproveConfigMapper insReportApproveConfigMapper;
-
- @Override
- public IPage<ReportPageDto> pageInsReport(Page page, ReportPageDto reportPageDto) {
- Map<String, Object> map = new HashMap<>();
- User user = userMapper.selectById(SecurityUtils.getUserId());//褰撳墠鐧诲綍鐨勪汉
- //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
- String departLimsId = user.getDepartLimsId();
- String laboratory = null;
- if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.isEmpty()) {
- String[] split = departLimsId.split(",");
- //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
- String departLims = insOrderMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
- if (departLims.contains("瀹為獙瀹�")) {
- laboratory = departLims;
- }
- }
- QueryWrapper<ReportPageDto> wrapper = QueryWrappers.queryWrappers(reportPageDto);
- 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));
- }
- return insReportMapper.pageInsReport(page, wrapper ,laboratory);
- }
-
- @Override
- public int inReport(String url, Integer id) {
- InsReport insReport = new InsReport();
- insReport.setId(id);
- insReport.setUrlS(url);
- return insReportMapper.updateById(insReport);
- }
-
- // 杩樺師
- @Override
- 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
- public void downReport(Integer id,Integer type, HttpServletResponse response) {
- InsReport insReport = insReportMapper.selectById(id);
- String url = "";
- // 0 涓嬭浇docx 1 涓嬭浇pdf
- if(type == 0) {
- url = Strings.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl();
- }else {
- url = insReport.getTempUrlPdf();
- }
- if(Strings.isEmpty(url)){
- throw new ErrorException("鎶ュ憡鍦板潃涓虹┖");
- }
- File file = new File(wordUrl + File.separator + url.replace("/word/", ""));
- try {
- String fileName = file.getName();
- if(fileName.indexOf("_") != -1) {
- fileName = fileName.split("_")[1];
- }
- fileName = URLEncoder.encode(fileName, "UTF-8");
- response.setContentType("application/octet-stream");
- response.setHeader("Content-disposition","attachment;filename=" + fileName);
- ServletOutputStream stream = response.getOutputStream();
- FileInputStream fileInputStream = new FileInputStream(file);
- byte[] bytes = new byte[1024];
- int byteRead;
- while((byteRead = fileInputStream.read(bytes)) != -1){
- stream.write(bytes, 0, byteRead);
- stream.flush();
- }
- fileInputStream.close();
- stream.close();
- }catch (Exception e){
- throw new ErrorException("涓嬭浇澶辫触");
- }
- }
-
-
-
-
-
- //鎻愪氦
- @Override
- public int writeReport(Integer id) {
- InsReport insReport = insReportMapper.selectById(id);
- insReport.setId(id);
- insReport.setState(1);
- insReport.setWriteTime(LocalDateTime.now());//鎻愪氦鏃堕棿
- insReport.setWriteUserId(SecurityUtils.getUserId().intValue());//鎻愪氦浜�
- //鑾峰彇鎻愪氦浜虹殑绛惧悕鍦板潃
- String signatureUrl;
- try {
- signatureUrl = userMapper.selectById(SecurityUtils.getUserId().intValue()).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);
- }
-
- //瀹℃牳
- @Override
- public int examineReport(Integer id, Integer isExamine, String examineTell) {
- InsReport insReport = insReportMapper.selectById(id);
- insReport.setIsExamine(isExamine);
- if (ObjectUtils.isNotEmpty(examineTell)) {
- insReport.setExamineTell(examineTell);
- }
- insReport.setExamineUserId(SecurityUtils.getUserId().intValue());//瀹℃牳浜�
- insReport.setExamineTime(LocalDateTime.now());//瀹℃牳鏃堕棿
- if (isExamine == 0) {
- //濡傛灉瀹℃牳涓嶉�氳繃
- insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦
- return insReportMapper.updateById(insReport);
- }
- //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃
- String signatureUrl;
- try {
- signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl();
- } catch (Exception e) {
- throw new ErrorException("鎵句笉鍒板鏍镐汉鐨勭鍚�");
- }
- //绯荤粺鐢熸垚鎶ュ憡鍦板潃
- String url = insReport.getUrl();
- //鎵嬪姩涓婁紶鎶ュ憡鍦板潃
- String urlS = insReport.getUrlS();
- wordInsertUrl(new HashMap<String, Object>() {{
- put("examineUrl", 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);
- }
-
- //鎵瑰噯
- @Override
- @Transactional(rollbackFor = Exception.class)
- public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) {
- InsReport insReport = insReportMapper.selectById(id);
- insReport.setIsRatify(isRatify);
- if (ObjectUtils.isNotEmpty(ratifyTell)) {
- insReport.setRatifyTell(ratifyTell);
- }
- insReport.setRatifyUserId(SecurityUtils.getUserId().intValue());//鎵瑰噯浜�
- insReport.setRatifyTime(LocalDateTime.now());//鎵瑰噯鏃堕棿
- if (isRatify == 0) {
- //濡傛灉鎵瑰噯涓嶉�氳繃
- insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦
- return insReportMapper.updateById(insReport);
- }
- //鑾峰彇鎵瑰噯浜虹殑绛惧悕鍦板潃
- String signatureUrl;
- try {
- signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl();
- } catch (Exception e) {
- throw new ErrorException("鎵句笉鍒版壒鍑嗕汉鐨勭鍚�");
- }
- //鑾峰彇鍦烘墍鐨勬姤鍛婁笓鐢ㄧ珷
- String sealUrl;
- try {
- String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory();
- sealUrl = insReportMapper.getLaboratoryByName(laboratory);
- } catch (Exception e) {
- throw new ErrorException("鎵句笉鍒版姤鍛婁笓鐢ㄧ珷");
- }
- if (sealUrl == null) throw new ErrorException("鎵句笉鍒版姤鍛婁笓鐢ㄧ珷");
- //绯荤粺鐢熸垚鎶ュ憡鍦板潃
- String url = insReport.getUrl();
- //鎵嬪姩涓婁紶鎶ュ憡鍦板潃
- String urlS = insReport.getUrlS();
- String finalUrl = (urlS == null ? url : urlS).replace("/word", wordUrl);
- wordInsertUrl(new HashMap<String, Object>() {{
- put("ratifyUrl", new FilePictureRenderData(100,50,imgUrl + "/" + signatureUrl));
- put("seal1", new FilePictureRenderData(600,600,imgUrl + "/" + sealUrl));
- put("seal2", new FilePictureRenderData(600,600,imgUrl + "/" + sealUrl));
- }}, finalUrl);
- wordToPdf(finalUrl, sealUrl);
-
- InsOrder insOrder = new InsOrder();
- insOrder.setId(insReportMapper.selectById(id).getInsOrderId());
- insOrder.setState(4);
- insOrderMapper.updateById(insOrder);
- // 淇敼涓存椂pdf
- String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl));
- insReport.setTempUrlPdf("/word/" + tempUrlPdf);
- /*鏂板cnas7.8鎶ュ憡缁撴灉*/
- ProcessReport processReport = new ProcessReport();
- processReport.setInsReportCode(insReport.getCode());
- processReportMapper.insert(processReport);
- return insReportMapper.updateById(insReport);
- }
-
- @Override
- public int wordInsertUrl(Map<String, Object> map, String url) {
- XWPFTemplate template = XWPFTemplate.compile(url).render(map);
- try {
- template.writeAndClose(Files.newOutputStream(Paths.get(url)));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- return 1;
- }
-
- //鎶ュ憡鎵归噺涓嬭浇
- @Override
- @Transactional(rollbackFor = Exception.class)
- public String downAll(String ids) {
- List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).collect(Collectors.toList());
- List<InsReport> insReports = insReportMapper.selectBatchIds(list);
- String zipFilePath = null;
- // 涓存椂鏂囦欢澶硅矾寰�
- try {
- String tempFolderPath = wordUrl + "/tempFolder";
- File tempFolder = new File(tempFolderPath);
- if (tempFolder.exists()) {
- deleteDirectory(tempFolder); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶�
- }
- tempFolder.mkdirs(); // 鍒涘缓鏂扮殑涓存椂鏂囦欢澶�
- for (InsReport insReport : insReports) {
- File sourceFile = new File((ObjectUtils.isNotEmpty(insReport.getUrlS()) ? insReport.getUrlS() : insReport.getUrl()).replace("/word", wordUrl));
- // 涓嬭浇鏂囦欢鍚嶇О鍘婚櫎鏃堕棿
- String destinationFileName = sourceFile.getName();
- if(destinationFileName.indexOf("_") != -1) {
- destinationFileName = destinationFileName.split("_")[1];
- }
- File destinationFile = new File(tempFolder, destinationFileName);
- Files.copy(sourceFile.toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
- // 鍘嬬缉涓存椂鏂囦欢澶�
- zipFilePath = wordUrl + "/zip/output.zip";
- zipDirectory(tempFolderPath, zipFilePath);
-
- // 娓呯悊涓存椂鏂囦欢澶�
- deleteDirectory(tempFolder);
-
- System.out.println("ZIP鏂囦欢鍒涘缓瀹屾垚锛�");
- } catch (IOException e) {
- e.printStackTrace();
- }
- return "/word/zip/output.zip";
- }
-
- //鎵归噺涓婁紶
- @Override
- @Transactional(rollbackFor = Exception.class)
- public int upAll(MultipartFile file) {
- if (file != null) {
- // 鏍规嵁鏂囦欢鍚嶆煡璇d
- String fileName = file.getOriginalFilename();
- String code = fileName.replace(".docx", "").replace("JCZX", "JCZX/");
- if(fileName.lastIndexOf("_") != -1) {
- code = code.substring(file.getOriginalFilename().lastIndexOf("_") + 1);
- }
- //鏌ヨ鏈鏍哥殑鎶ュ憡鏁版嵁
- InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getCode, code).eq(InsReport::getIsExamine,-9));
- if (ObjectUtils.isEmpty(insReport)) {
- throw new ErrorException("娌℃湁缂栧彿涓�" + code + "鐨勬姤鍛婃垨璇ユ姤鍛婂凡瀹℃牳閫氳繃");
- }
- // 濡傛灉UrlS鏈夊�� 鍏堝皢璇ユ枃浠跺垹闄�
- if(Strings.isNotEmpty(insReport.getUrlS())) {
- String url = wordUrl + File.separator + insReport.getUrlS().replace("/word/", "");
- File file1 = new File(url);
- if(file1.exists()) {
- file1.delete();
- }
- }
- String urlString;
- String pathName;
- String path = wordUrl;
- File realpath = new File(path);
- if (!realpath.exists()) {
- realpath.mkdirs();
- }
- pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + insReport.getCode().replace("/", "") + ".docx";
- urlString = realpath + "/" + pathName;
- // 澶嶅埗鏂囦欢鍒版寚瀹氳矾寰�
- try {
- Files.copy(file.getInputStream(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- inReport("/word/" + pathName, insReport.getId());
- }
-// File tempFile = null;
-// File unzipDir = null;
-// try {
-// tempFile = File.createTempFile(wordUrl, ".zip");
-// file.transferTo(tempFile);
-//
-// unzipDir = new File("uploaded_files");
-// if (!unzipDir.exists()) {
-// unzipDir.mkdir();
-// }
-// unzip(tempFile, unzipDir);
-// // 澶勭悊瑙e帇鍚庣殑鏂囦欢
-// File[] files = unzipDir.listFiles();
-// if (files != null) {
-// for (File f : files) {
-// // 鏍规嵁鏂囦欢鍚嶆煡璇d
-// String name = f.getName();
-// String code = f.getName().replace(".docx", "").replace("JCZX", "JCZX/");
-// if(f.getName().lastIndexOf("_") != -1) {
-// code = code.substring(f.getName().lastIndexOf("_") + 1);
-// }
-// //InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getCode, f.getName().replace(".docx", "").replace("JCZX", "JCZX/")));
-// InsReport insReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery().eq(InsReport::getCode, code));
-// if (ObjectUtils.isEmpty(insReport)) {
-// throw new ErrorException("娌℃湁鎵惧埌 " + f.getName() + " 杩欎釜鏂囦欢瀵瑰簲鐨勬姤鍛婃暟鎹�");
-// }
-// // 濡傛灉UrlS鏈夊�� 鍏堝皢璇ユ枃浠跺垹闄�
-// if(Strings.isNotEmpty(insReport.getUrlS())) {
-// String url = wordUrl + File.separator + insReport.getUrlS().replace("/word/", "");
-// File file1 = new File(url);
-// if(file1.exists()) {
-// file1.delete();
-// }
-// }
-// String urlString;
-// String pathName;
-// try {
-// String path = wordUrl;
-// File realpath = new File(path);
-// if (!realpath.exists()) {
-// realpath.mkdirs();
-// }
-// pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + insReport.getCode().replace("/", "") + ".docx";
-// urlString = realpath + "/" + pathName;
-// // 澶嶅埗鏂囦欢鍒版寚瀹氳矾寰�
-// Files.copy(f.toPath(), new File(urlString).toPath(), StandardCopyOption.REPLACE_EXISTING);
-// inReport("/word/" + pathName, insReport.getId());
-// }
-// catch (IOException e) {
-// throw new ErrorException("鏂囦欢涓婁紶澶辫触");
-// }
-// }
-// }
-// } catch (IOException e) {
-// throw new ErrorException("鏂囦欢澶勭悊澶辫触");
-// } finally {
-// if (tempFile != null && tempFile.exists()) {
-// tempFile.delete();
-// }
-// // 閫掑綊鍒犻櫎瑙e帇鐩綍鍙婂叾涓殑鏂囦欢
-// if (unzipDir.exists()) {
-// deleteDirectory(unzipDir); // 鍒犻櫎鏃х殑涓存椂鏂囦欢澶�
-// }
-// }
- return 0;
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void withdraw(Map<String,Object> map) {
- Integer id = Integer.parseInt(map.get("id").toString());
- List<String> list = JSONArray.parseArray(map.get("laboratory").toString(), String.class);
- Integer insOrderId = insReportMapper.selectById(id).getInsOrderId();
- List<InsOrderState> insOrderStateS = insOrderStateMapper.selectList(new LambdaQueryWrapper<InsOrderState>()
- .eq(InsOrderState::getInsOrderId, insOrderId)
- .in(CollectionUtils.isNotEmpty(list),InsOrderState::getLaboratory, list));
- if(CollectionUtils.isNotEmpty(insOrderStateS)) {
- List<Integer> collect = insOrderStateS.stream().map(InsOrderState::getId).collect(Collectors.toList());
- // 淇敼璇ュ崟瀛愯瘯楠屽鐨勭姸鎬佷负寰呭鏍革紝鍒犻櫎鎶ュ憡淇℃伅
- insOrderStateMapper.update(null,new LambdaUpdateWrapper<InsOrderState>()
- .set(InsOrderState::getInsState,3) // 寰呭鏍�
- .in(InsOrderState::getId,collect));
- insReportMapper.delete(new LambdaQueryWrapper<InsReport>().eq(InsReport::getId,id));
- }
- }
-
- @Override
- public List<Map<String, Object>> getLaboratoryByReportId(Integer id) {
- List<Map<String, Object>> list = new ArrayList<>();
- Integer insOrderId = insReportMapper.selectById(id).getInsOrderId();
- insOrderStateMapper.selectList(new LambdaQueryWrapper<InsOrderState>()
- .eq(InsOrderState::getInsOrderId,insOrderId))
- .forEach(insOrderState -> {
- Map<String, Object> map = new HashMap<>();
- map.put("label",insOrderState.getLaboratory());
- map.put("value",insOrderState.getLaboratory());
- list.add(map);
- });
- return list;
- }
-
- @Override
- public Map<String, Object> getReportCountInfo(ReportPageDto reportPageDto) {
- HashMap<String, Object> map = new HashMap<>();
- User user = userMapper.selectById(SecurityUtils.getUserId());//褰撳墠鐧诲綍鐨勪汉
- //鑾峰彇褰撳墠浜烘墍灞炲疄楠屽id
- String departLimsId = user.getDepartLimsId();
- String laboratory = null;
- if (ObjectUtils.isNotEmpty(departLimsId) && !departLimsId.isEmpty()) {
- String[] split = departLimsId.split(",");
- //鏌ヨ瀵瑰簲鏋舵瀯鍚嶇О(閫氫俊瀹為獙瀹�,鐢靛姏瀹為獙瀹�,妫�娴嬪姙)
- String departLims = insOrderMapper.seldepLimsId(Integer.parseInt(split[split.length - 1]));
- if (departLims.contains("瀹為獙瀹�")) {
- laboratory = departLims;
- }
- }
- QueryWrapper<ReportPageDto> wrapper = QueryWrappers.queryWrappers(reportPageDto);
- 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));
-
- }
- map.put("unSubmitCount",insReportMapper.findReportCountInfo(wrapper,laboratory,"ir.write_user_id").size());
- map.put("unExamineCount",insReportMapper.findReportCountInfo(wrapper,laboratory,"ir.is_examine").size());
- map.put("unRatifyCount",insReportMapper.findReportCountInfo(wrapper,laboratory,"ir.is_ratify").size());
- return map;
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void batchApprovalReport(List<Integer> ids) {
- redisTemplate.setKeySerializer(new StringRedisSerializer());
- Integer userId = SecurityUtils.getUserId().intValue();
- String key = SYNC_REPORT_KEY_PREFIX+userId;
- //鎵ц鍓嶅垹闄や箣鍓嶇殑keys
- deleteRedisKeys(key);
- synchronized (key) {
- redisTemplate.opsForValue().set(key,1);
- RequestContextHolder.setRequestAttributes(RequestContextHolder.getRequestAttributes(),true);
- //寮傛鎵ц瀹℃壒鎿嶄綔
- CompletableFuture.runAsync(() -> {
- try {
- runBatchApproval(ids,key);
- }catch (Exception e){
- //鍒犻櫎key
- deleteRedisKeys(key);
- redisTemplate.opsForValue().set(key+"_exception",e.getMessage());
- }
- },threadPoolTaskExecutor);
- }
- }
-
- /**
- * 鍒犻櫎redis key
- * @param key
- */
- private void deleteRedisKeys(String key){
- redisTemplate.delete(key);
- redisTemplate.delete(key+"_num");
- redisTemplate.delete(key+"_count");
- redisTemplate.delete(key+"_surplus");
- redisTemplate.delete(key+"_exception");
- }
-
- /**
- * 鎵ц瀹℃壒鎿嶄綔
- * @param ids 鎶ュ憡id鍒楄〃
- */
- private void runBatchApproval(List<Integer> ids,String keyPrefix) {
- if(ids.isEmpty()){
- return;
- }
- long start = System.currentTimeMillis();
- String surplusKey = keyPrefix + "_surplus";//鍓╀綑鏉℃暟
- String numKey = keyPrefix + "_num";//鎬昏繘搴�
- String countKey = keyPrefix + "_count";//鎬绘潯鏁�
- redisTemplate.opsForValue().set(countKey, ids.size());
- redisTemplate.opsForValue().set(surplusKey, ids.size());
- Object countObj = redisTemplate.opsForValue().get(countKey);
- long parsed2 = Long.parseLong(String.valueOf(countObj));
- AtomicLong count = new AtomicLong(parsed2);
- for (Integer id : ids) {
- //涓氬姟浠g爜
- InsReport insReport = insReportMapper.selectById(id);
- String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory();
- //鑾峰彇绛惧悕鍜屽嵃绔�
- String sealUrl;
- String writeUrl;
- String examineUrl;
- String ratifyUrl;
- int writeId;
- int examineId;
- int ratifyId;
- try {
- sealUrl = insReportMapper.getLaboratoryByName(laboratory);//鍗扮珷
- Map<String,Object> urlMap = insReportApproveConfigMapper.selectApprovalConfigByLaboratory(laboratory);//绛惧悕
- writeUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("writeUrl"))?"":urlMap.get("writeUrl").toString());//缂栧埗浜虹鍚島rl
- examineUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("examineUrl"))?"":urlMap.get("examineUrl").toString());//瀹℃牳浜虹鍚島rl
- ratifyUrl = imgUrl + "/" + (Objects.isNull(urlMap.get("ratifyUrl"))?"":urlMap.get("ratifyUrl").toString());//鎵瑰噯浜虹鍚島rl
- writeId = Integer.parseInt(urlMap.get("writeId").toString());//缂栧埗浜�
- examineId = Integer.parseInt(urlMap.get("examineId").toString());//瀹℃牳浜虹
- ratifyId =Integer.parseInt(urlMap.get("ratifyId").toString());//鎵瑰噯浜�
- } catch (Exception e) {
- throw new ErrorException("鎵句笉鍒扮鍚嶅拰鍗扮珷");
- }
- //璁剧疆鎶ュ憡淇℃伅
- insReport.setIsExamine(1);
- insReport.setIsRatify(1);
- insReport.setState(1);
- insReport.setWriteUserId(writeId);
- insReport.setExamineUserId(examineId);
- insReport.setRatifyUserId(ratifyId);
- if(Objects.isNull(insReport.getWriteTime())){
- insReport.setWriteTime(LocalDateTime.now());
- }
- if(Objects.isNull(insReport.getExamineTime())){
- insReport.setExamineTime(LocalDateTime.now());
- }
- if(Objects.isNull(insReport.getRatifyTime())){
- insReport.setRatifyTime(LocalDateTime.now());
- }
- //鏇存柊璁㈠崟鐘舵��
- InsOrder insOrder = new InsOrder();
- insOrder.setId(insReport.getInsOrderId());
- insOrder.setState(4);
- insOrderMapper.updateById(insOrder);
- //绯荤粺鐢熸垚鎶ュ憡鍦板潃
- String url = insReport.getUrl();
- //鎵嬪姩涓婁紶鎶ュ憡鍦板潃
- String urlS = insReport.getUrlS();
- String finalUrl = (StringUtils.isBlank(urlS) ? url : urlS).replace("/word", wordUrl);
- wordInsertUrl(new HashMap<String, Object>() {{
- put("writeUrl", new FilePictureRenderData(100,50,writeUrl));
- put("examineUrl", new FilePictureRenderData(100,50,examineUrl));
- put("ratifyUrl", new FilePictureRenderData(100,50,ratifyUrl));
- put("seal1", new FilePictureRenderData(600,600,imgUrl + "/" +sealUrl));
- put("seal2", new FilePictureRenderData(600,600,imgUrl + "/" +sealUrl));
- }}, finalUrl);
- wordToPdf(finalUrl, sealUrl);
- // 淇敼涓存椂pdf
- String tempUrlPdf = wordToPdfTemp((StrUtil.isBlank(urlS) ? url : urlS).replace("/word", wordUrl));
- insReport.setTempUrlPdf("/word/" + tempUrlPdf);
- //鏇存柊鎶ュ憡鐘舵��
- insReportMapper.updateById(insReport);
- //鏇存柊redis鐨刱ey
- Object o = redisTemplate.opsForValue().get(numKey);
- if (Objects.isNull(o)) {
- redisTemplate.opsForValue().set(numKey, 1);
- } else {
- long parsed = Long.parseLong(String.valueOf(o));
- redisTemplate.opsForValue().set(numKey, parsed + 1);
- }
- redisTemplate.opsForValue().set(surplusKey, count.decrementAndGet());
- }
- long end = System.currentTimeMillis();
- long useTime = (end-start)/1000;
- log.info("绾跨▼{}鎶ュ憡瀹℃壒缁撴潫锛岃�楁椂:{}s",keyPrefix,useTime);
- }
-
- @Override
- public Map<String, Object> getBatchApprovalProgress() {
- Integer userId = SecurityUtils.getUserId().intValue();
- String key = SYNC_REPORT_KEY_PREFIX + userId;
- Map<String, Object> map = new HashMap<>();
- map.put("hasProgress",false);
- map.put("hasNum",0);
- map.put("hasCount",0);
- map.put("surplus",0);
- Object o = redisTemplate.opsForValue().get(key);
- if(Objects.nonNull(o)){
- map.put("hasProgress",true);
- }
- Object o1 = redisTemplate.opsForValue().get(key+"_num");
- Object o2 = redisTemplate.opsForValue().get(key+"_count");
- Object surplus = redisTemplate.opsForValue().get(key+"_surplus");
- Object exception = redisTemplate.opsForValue().get(key+"_exception");
- if(Objects.nonNull(surplus)){
- map.put("surplus",surplus);
- }
- if (Objects.nonNull(o1)&&Objects.nonNull(o2)){
- //寰楀埌杩涘害
- BigDecimal multiply = new BigDecimal(String.valueOf(o1)).divide(new BigDecimal(String.valueOf(o2)), 2,BigDecimal.ROUND_DOWN).multiply(BigDecimal.valueOf(100));
- map.put("hasNum",multiply);
- map.put("hasCount",Long.parseLong(String.valueOf(o2)));
- }
- map.put("hasException",exception);
- return map;
- }
-
- //瑙e帇鏂囦欢澶�
- private void unzip(File zipFile, File destDir) throws IOException {
- try (ZipFile zip = new ZipFile(zipFile)) {
- Enumeration<? extends ZipEntry> entries = zip.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- File file = new File(destDir, entry.getName());
- if (entry.isDirectory()) {
- file.mkdirs();
- } else {
- file.getParentFile().mkdirs();
- try (InputStream in = zip.getInputStream(entry);
- OutputStream out = new FileOutputStream(file)) {
- byte[] buffer = new byte[1024];
- int len;
- while ((len = in.read(buffer)) > 0) {
- out.write(buffer, 0, len);
- }
- }
- }
- }
- }
- }
-
- // 鍘嬬缉鏂囦欢澶�
- public static void zipDirectory(String sourceDirPath, String zipFilePath) throws IOException {
- try (ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
- Path sourceDir = Paths.get(sourceDirPath);
- Files.walk(sourceDir)
- .filter(path -> !Files.isDirectory(path))
- .forEach(path -> {
- ZipEntry zipEntry = new ZipEntry(sourceDir.relativize(path).toString());
- try {
- zipOut.putNextEntry(zipEntry);
- Files.copy(path, zipOut);
- zipOut.closeEntry();
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- }
- }
-
- // 鍒犻櫎鏂囦欢澶瑰強鍏跺唴瀹�
- public static void deleteDirectory(File directory) throws IOException {
- if (directory.isDirectory()) {
- File[] files = directory.listFiles();
- if (files != null) {
- for (File file : files) {
- deleteDirectory(file);
- }
- }
- }
- Files.delete(directory.toPath());
- }
-
- /**
- * word杞崲pdf
- * @param path
- * @return
- */
- public String wordToPdfTemp(String path) {
- try {
- return wordToPdf(path, path.replace(".docx", ".pdf"));
- } catch (Exception e) {
- throw new ErrorException("杞崲澶辫触");
- }
- }
-
- public String wordToPdf(String wordPath, String pdfPath) {
- FileOutputStream os = null;
- try {
- //鍑瘉 涓嶇劧鍒囨崲鍚庢湁姘村嵃
- InputStream is = Files.newInputStream(new File(licenseUrl).toPath());
- License license = new License();
- license.setLicense(is);
- if (!license.getIsLicensed()) {
- System.out.println("License楠岃瘉涓嶉�氳繃...");
- return null;
- }
- //鐢熸垚涓�涓┖鐨凱DF鏂囦欢
- File file;
- //鍒ゆ柇鏄惁鏄繘鍘傛姤鍛�
- file = new File(pdfPath);
- os = new FileOutputStream(file);
- //瑕佽浆鎹㈢殑word鏂囦欢
- Document doc = new Document(wordPath);
- doc.save(os, SaveFormat.PDF);
- String name = file.getName();
- return file.getName();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- 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;
-// }
-
- /**
- * 鍒囧壊鍥剧墖
- *
- * @param Path 鍥剧墖璺緞
- * @param n 鍒囧壊浠芥暟
- */
- public static com.itextpdf.text.Image[] slicingImages(String Path, int n) throws IOException, BadElementException {
- com.itextpdf.text.Image[] nImage = new com.itextpdf.text.Image[n];
- BufferedImage img = ImageIO.read(new File(Path));
-
- int h = img.getHeight();
- int w = img.getWidth();
-
- int sw = w / n;
- for (int i = 0; i < n; i++) {
- BufferedImage subImg;
- if (i == n - 1) {//鏈�鍚庡墿浣欓儴鍒�
- subImg = img.getSubimage(i * sw, 0, w - i * sw, h);
- } else {//鍓峮-1鍧楀潎鍖�鍒�
- subImg = img.getSubimage(i * sw, 0, sw, h);
- }
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ImageIO.write(subImg, Path.substring(Path.lastIndexOf('.') + 1), out);
- nImage[i] = com.itextpdf.text.Image.getInstance(out.toByteArray());
-
- }
- return nImage;
- }
-
- /**
- * 鐩栭獞缂濈珷
- *
- * @param infilePath 鍘烶DF璺緞
- * @param outFilePath 杈撳嚭PDF璺緞
- */
- public static void stamperCheckMarkPDF(String infilePath, String outFilePath, String picPath) throws IOException, DocumentException {
- PdfReader reader = new PdfReader(infilePath);//閫夋嫨闇�瑕佸嵃绔犵殑pdf
- PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//鍔犲畬鍗扮珷鍚庣殑pdf
-
-
- com.itextpdf.text.Rectangle pageSize = reader.getPageSize(1);//鑾峰緱绗竴椤�
- float height = pageSize.getHeight();
- float width = pageSize.getWidth();
-
- int nums = reader.getNumberOfPages();
- com.itextpdf.text.Image[] nImage = slicingImages(picPath, nums);//鐢熸垚楠戠紳绔犲垏鍓插浘鐗�
-
- for (int n = 1; n <= nums; n++) {
- PdfContentByte over = stamp.getOverContent(n);//璁剧疆鍦ㄧ鍑犻〉鎵撳嵃鍗扮珷
- com.itextpdf.text.Image img = nImage[n - 1];//閫夋嫨鍥剧墖
- float newHeight = 100f;
- float newWidth = img.getWidth() / (img.getHeight() / 100);
- img.scaleAbsolute(newWidth, newHeight);//鎺у埗鍥剧墖澶у皬
- img.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2);//鎺у埗鍥剧墖浣嶇疆
- over.addImage(img);
- }
- stamp.close();
- }
-}
-
-
-
-
-
-
diff --git a/inspect-server/pom.xml b/inspect-server/pom.xml
index 30dc02e..1da9deb 100644
--- a/inspect-server/pom.xml
+++ b/inspect-server/pom.xml
@@ -51,6 +51,7 @@
</dependency>
+
<!-- poi-tl鍖呯敓鎴愭姤鍛� -->
<dependency>
<groupId>com.deepoove</groupId>
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
index c1824d4..922213e 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
@@ -48,14 +48,13 @@
@ApiOperation(value = "鏌ョ湅妫�楠屾姤鍛婂垪琛�")
@GetMapping("/pageInsReport")
- public Result pageInsReport(Page page , ReportPageDto reportPageDto) throws Exception {
+ public Result pageInsReport(Page page,ReportPageDto reportPageDto) throws Exception {
return Result.success(insReportService.pageInsReport(page, reportPageDto));
}
@ApiOperation(value = "涓�閿鎵规寜閽�")
@PostMapping("/batchApprovalReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result batchApprovalReport(@RequestBody BatchApprovalReportDTO batchApprovalReportDTO){
try {
insReportService.batchApprovalReport(batchApprovalReportDTO.getIds());
@@ -74,14 +73,12 @@
@ApiOperation(value = "鏌ョ湅妫�楠屾姤鍛婃暟閲忎俊鎭�")
@GetMapping("/getReportCountInfo")
- public Result getReportCountInfo(@RequestParam Map<String, Object> params) throws Exception {
- ReportPageDto reportPageDto = JackSonUtil.unmarshal(JackSonUtil.marshal(params), ReportPageDto.class);
+ public Result getReportCountInfo(ReportPageDto reportPageDto) throws Exception {
return Result.success(insReportService.getReportCountInfo(reportPageDto));
}
@ApiOperation(value = "涓婁紶鎸夐挳")
@PostMapping("/inReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.IMPORT)
public Result inReport(MultipartFile file, Integer id) {
String urlString;
String pathName;
@@ -111,7 +108,6 @@
}
//涓嬭浇
@GetMapping("/downReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.EXPORT)
public void downReport(@RequestParam("id") Integer id,@RequestParam("type") Integer type, HttpServletResponse response) {
insReportService.downReport(id,type, response);
}
@@ -120,22 +116,18 @@
@ApiOperation(value = "杩樺師鎸夐挳")
@PostMapping("/upReportUrl")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
- public Result upReportUrl(Integer id,Integer type) {
- insReportService.upReportUrl(id,type);
- return Result.success();
+ public Result upReportUrl(Integer id) {
+ return Result.success(insReportService.upReportUrl(id));
}
@ApiOperation(value = "缂栧埗鎸夐挳")
@GetMapping("/upReportFile")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result upReportFile() {
return Result.success();
}
@ApiOperation(value = "鎻愪氦鎸夐挳")
@PostMapping("/writeReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result writeReport(Integer id) {
return Result.success(insReportService.writeReport(id));
@@ -143,20 +135,17 @@
@ApiOperation(value = "瀹℃牳鎸夐挳")
@PostMapping("/examineReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result examineReport(Integer id, Integer isExamine, String examineTell) {
return Result.success(insReportService.examineReport(id, isExamine, examineTell));
}
@ApiOperation(value = "鎵瑰噯鎸夐挳")
@PostMapping("/ratifyReport")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result ratifyReport(Integer id, Integer isRatify, String ratifyTell) {
return Result.success(insReportService.ratifyReport(id, isRatify, ratifyTell));
}
@RequestMapping("/onlyOffice/save")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.OTHER)
public void saveFile(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
PrintWriter writer = null;
try {
@@ -187,21 +176,18 @@
@ApiOperation(value = "鎵归噺涓嬭浇鎸夐挳")
@GetMapping("/downAll")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.EXPORT)
public Result downAll(String ids) {
return Result.success(insReportService.downAll(ids));
}
@ApiOperation(value = "鎵归噺涓婁紶鎸夐挳")
@PostMapping("/upAll")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.IMPORT)
public Result upAll(MultipartFile file) throws IOException {
return Result.success(insReportService.upAll(file));
}
@ApiOperation(value = "鎾ゅ洖鎸夐挳")
@PostMapping("/withdraw")
- @Log(title = "妫�楠屾姤鍛�", businessType = BusinessType.UPDATE)
public Result withdraw(@RequestBody Map<String,Object> map) {
insReportService.withdraw(map);
return Result.success();
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/ProcessReport.java b/inspect-server/src/main/java/com/ruoyi/inspect/pojo/ProcessReport.java
deleted file mode 100644
index b88c923..0000000
--- a/inspect-server/src/main/java/com/ruoyi/inspect/pojo/ProcessReport.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package com.ruoyi.inspect.pojo;
-
-import com.baomidou.mybatisplus.annotation.*;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-
-import java.io.Serializable;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-
-/**
- * <p>
- * 妫�楠屾姤鍛婂彂鏀剧櫥璁拌〃
- * </p>
- *
- * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
- * @since 2024-11-05 08:58:39
- */
-@Getter
-@Setter
-@TableName("cnas_process_report")
-@ApiModel(value = "ProcessReport瀵硅薄", description = "妫�楠屾姤鍛婂彂鏀剧櫥璁拌〃")
-public class ProcessReport implements Serializable {
-
-
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- @ApiModelProperty("妫�楠屾姤鍛婄紪鍙�")
- private String insReportCode;
-
- @ApiModelProperty("椤垫暟")
- private String pages;
-
- @ApiModelProperty("鍙戦�佷唤鏁�")
- private String number;
-
- @ApiModelProperty("鍙戝線浣曞")
- private String send;
-
- @ApiModelProperty("鍙戦�佹柟寮�")
- private String method;
-
- @ApiModelProperty("鍙戦�佹棩鏈�")
- @JsonFormat(pattern = "yyyy-MM-dd")
- private LocalDate sendTime;
-
- @ApiModelProperty("鍙戦�佷汉")
- private Integer sendUser;
-
- @ApiModelProperty("鍙戦�佷汉鍚嶇О")
- @TableField(select = false,exist = false)
- private String sendUserName;
-
- @ApiModelProperty("绛炬敹浜�")
- private String signatory;
-
- @TableField(select = false,exist = false)
- private String signatoryUrl;
-
- @ApiModelProperty("绛炬敹浜哄悕绉�")
- @TableField(select = false,exist = false)
- private String signatoryName;
-
- @ApiModelProperty("澶囨敞")
- private String remark;
-
- @TableField(fill = FieldFill.INSERT)
- private Integer createUser;
-
- @TableField(fill = FieldFill.INSERT)
- private LocalDateTime createTime;
-
- @TableField(fill = FieldFill.INSERT_UPDATE)
- private Integer updateUser;
-
- @TableField(fill = FieldFill.INSERT_UPDATE)
- private LocalDateTime updateTime;
-}
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
index 7ac2eba..1b1095c 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/InsReportService.java
@@ -21,11 +21,13 @@
IPage<ReportPageDto> pageInsReport(Page page, ReportPageDto reportPageDto);
+// void wordToPdf(String path,String sealUrl);
+
int inReport(String url, Integer id);
- void upReportUrl(Integer id,Integer type);
+ int upReportUrl(Integer id);
// 涓嬭浇
- void downReport(Integer id, Integer type , HttpServletResponse response);
+ void downReport(Integer id, Integer type ,HttpServletResponse response);
//鎻愪氦
int writeReport(Integer id);
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();
}
}
+
+
+
+
+
+
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/controller/AttachmentTypeController.java b/ruoyi-common/src/main/java/com/ruoyi/common/controller/AttachmentTypeController.java
deleted file mode 100644
index b321181..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/controller/AttachmentTypeController.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package com.ruoyi.common.controller;
-
-import com.ruoyi.common.core.domain.Result;
-import com.ruoyi.common.service.AttachmentTableService;
-import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletResponse;
-
-@RestController
-@RequestMapping("/file/attachmentType")
-@AllArgsConstructor
-public class AttachmentTypeController {
-
- private AttachmentTableService attachmentTableService;
-
- /**
- * 涓婁紶鏂囦欢
- * @param file 鏂囦欢
- * @param type 鏋氫妇绫诲瀷
- * @param id 涓氬姟id
- * @return
- */
- @PostMapping("/upload")
- public Result upload(@RequestParam("file")MultipartFile file,@RequestParam("type")Integer type,@RequestParam("id")Integer id) {
- attachmentTableService.upload(file,type,id);
- return Result.success();
- }
-
- /**
- * 涓嬭浇鏂囦欢
- * @param id 涓氬姟id
- * @param type 鏋氫妇绫诲瀷
- * @param code 鏂囦欢鍚嶇О
- * @param suffix 鏂囦欢鍚庣紑 鍙兘鏄痺ord 鎴栬�� pdf
- * @return
- */
- @GetMapping("/downLoad")
- public void downLoad(Integer id, Integer type , String code,String suffix, HttpServletResponse response) {
- attachmentTableService.downLoad(id, type,code, suffix,response);
- }
-
- /**
- * 鑾峰彇鏂囦欢鐨凪IME
- * @param id
- * @param type
- * @return
- */
- @GetMapping("/getMIME")
- public Result getMIME(Integer id, Integer type,String suffix) {
- return Result.success(attachmentTableService.getAttachmentList(id, type,suffix));
- }
-
-
- /**
- * 鑾峰彇鏂囦欢URL
- * @param id
- * @param type
- * @param suffix 鏂囦欢鍚庣紑 鍙兘鏄痺ord 鍜� pdf
- */
- @GetMapping("/getURL")
- public Result getURL(Integer id, Integer type , String suffix) {
- return Result.success(attachmentTableService.getURL(id, type , suffix));
- }
-
-
-
-
-
-
-
-
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentType.java
deleted file mode 100644
index 0620f96..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/AttachmentType.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package com.ruoyi.common.enums;
-
-
-public enum AttachmentType {
- /*
- * 鎶ュ憡缂栧埗
- */
- INS_REPORT(1, "ins_report"),
- USER(2, "user"),
-
-
- ;
-
-
- private Integer type;
-
- private String value;
-
-
- private AttachmentType(Integer type, String value) {
- this.type = type;
- this.value = value;
- }
-
- public Integer getType() {
- return type;
- }
-
- public void setType(Integer type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
-
- public static String getAttachmentValue(Integer type) {
- for (AttachmentType attachmentType : AttachmentType.values()) {
- if (attachmentType.getType().equals(type)) {
- return attachmentType.getValue();
- }
- }
- return null;
- }
-
-
-
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/mapper/AttachmentTableMapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/mapper/AttachmentTableMapper.java
deleted file mode 100644
index b325705..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/mapper/AttachmentTableMapper.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.ruoyi.common.mapper;
-
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ruoyi.common.pojo.AttachmentTable;
-import org.apache.ibatis.annotations.Mapper;
-
-@Mapper
-public interface AttachmentTableMapper extends BaseMapper<AttachmentTable> {
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/service/AttachmentTableService.java b/ruoyi-common/src/main/java/com/ruoyi/common/service/AttachmentTableService.java
deleted file mode 100644
index 85e0097..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/service/AttachmentTableService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.ruoyi.common.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.ruoyi.common.pojo.AttachmentTable;
-import org.springframework.web.multipart.MultipartFile;
-
-import javax.servlet.http.HttpServletResponse;
-import java.io.InputStream;
-import java.util.Map;
-
-public interface AttachmentTableService extends IService<AttachmentTable> {
-
- void upload(MultipartFile file, Integer type, Integer id);
-
- void downLoad(Integer id, Integer type,String code,String suffix,HttpServletResponse response) ;
-
- Map<String, Object> getAttachmentList(Integer id, Integer type,String suffix);
-
- String getURL(Integer id, Integer type , String suffix);
-
- InputStream getInputStream(Integer id, Integer type , String suffix);
-
-}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/service/impl/AttachmentTableServiceImpl.java b/ruoyi-common/src/main/java/com/ruoyi/common/service/impl/AttachmentTableServiceImpl.java
deleted file mode 100644
index 281cffc..0000000
--- a/ruoyi-common/src/main/java/com/ruoyi/common/service/impl/AttachmentTableServiceImpl.java
+++ /dev/null
@@ -1,218 +0,0 @@
-package com.ruoyi.common.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.common.config.MinioConfig;
-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.StringUtils;
-import com.ruoyi.common.utils.uuid.UUID;
-import io.minio.*;
-import io.minio.http.Method;
-import lombok.AllArgsConstructor;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.multipart.MultipartFile;
-
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-@Service
-@AllArgsConstructor
-public class AttachmentTableServiceImpl extends ServiceImpl<AttachmentTableMapper, AttachmentTable> implements AttachmentTableService {
-
- private MinioConfig minioConfig;
-
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void upload(MultipartFile file, Integer type, Integer id) {
- MinioClient build = MinioClient.builder()
- .endpoint(minioConfig.getEndpoint(), minioConfig.getPort(), minioConfig.getSecure())
- .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey())
- .build();
- String fileName = UUID.randomUUID() + "_" + file.getOriginalFilename();
- try(InputStream inputStream = file.getInputStream()) {
- build.putObject(
- PutObjectArgs.builder()
- .bucket(minioConfig.getBucketName())
- .object(fileName)
- .stream(inputStream, file.getSize(), -1)
- .contentType("application/octet-stream")
- .userMetadata(Collections.singletonMap("Content-Disposition", "attachment; filename=\"" + fileName + "\""))
- .build()
- );
- // 淇濆瓨鍒版暟鎹簱
- AttachmentTable attachmentTable = new AttachmentTable();
- attachmentTable.setSubclassId(id);
- attachmentTable.setFileName(fileName);
- attachmentTable.setOriginalFileName(file.getOriginalFilename());
- attachmentTable.setFileType(file.getContentType());
- attachmentTable.setBucketName(minioConfig.getBucketName());
- attachmentTable.setOtherTableName(AttachmentType.getAttachmentValue(type));
- baseMapper.insert(attachmentTable);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void downLoad(Integer id, Integer type,String code,String suffix, HttpServletResponse response) {
- // 鏌ヨ鏁版嵁搴�
- List<AttachmentTable> list = baseMapper.selectList(new LambdaQueryWrapper<AttachmentTable>()
- .eq(AttachmentTable::getSubclassId, id)
- .eq(AttachmentTable::getOtherTableName, AttachmentType.getAttachmentValue(type))
- .like(AttachmentTable::getFileName, suffix)
- .orderByDesc(AttachmentTable::getId));
- if(CollectionUtils.isNotEmpty(list)) {
- AttachmentTable attachmentTable = list.get(0);
- String fileName = attachmentTable.getFileName(); // 鏂囦欢鍚�
- MinioClient build = MinioClient.builder()
- .endpoint(minioConfig.getEndpoint(), minioConfig.getPort(), minioConfig.getSecure())
- .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey())
- .build();
- try( InputStream inputStream = build.getObject(GetObjectArgs.builder().bucket(minioConfig.getBucketName()).object(fileName).build());
- ServletOutputStream stream = response.getOutputStream()) {
- String finalName = "";
- String fileNameMinIo = attachmentTable.getFileName();
- String suffix1 = fileNameMinIo.substring(fileNameMinIo.lastIndexOf(".")+1);
- String contentType = getContentType(suffix1);
- if(StringUtils.isNotEmpty(code)) {
- finalName = code + "." + suffix1;
- }else {
- finalName = fileNameMinIo;
- }
- // 璁剧疆鍝嶅簲澶�
- response.setContentType(contentType);
- response.setHeader("Content-disposition", "attachment;filename=" + finalName);
- byte[] bytes = new byte[1024];
- int len;
- while ((len = inputStream.read(bytes)) != -1) {
- stream.write(bytes, 0, len);
- stream.flush();
- }
- }catch (Exception e) {
- e.printStackTrace();
- }
-
-
- }
- }
-
- @Override
- public Map<String, Object> getAttachmentList(Integer id, Integer type,String suffix) {
- HashMap<String, Object> map = new HashMap<>();
- // 鏌ヨ鏁版嵁搴�
- List<AttachmentTable> list = baseMapper.selectList(new LambdaQueryWrapper<AttachmentTable>()
- .eq(AttachmentTable::getSubclassId, id)
- .eq(AttachmentTable::getOtherTableName, AttachmentType.getAttachmentValue(type))
- .like(StringUtils.isNotEmpty(suffix),AttachmentTable::getFileName, suffix)
- .orderByDesc(AttachmentTable::getId));
- if(CollectionUtils.isNotEmpty(list)) {
- String contentType = getContentType(suffix.replace(".",""));
- map.put("contentType", contentType);
- map.put("suffix", suffix);
- }
- return map;
- }
-
- @Override
- public String getURL(Integer id, Integer type , String suffix) {
- String url = "";
- // 鏌ヨ鏁版嵁搴� 鑾峰彇鏈�鏂版枃浠跺悕
- List<AttachmentTable> attachmentTables = baseMapper.selectList(new LambdaQueryWrapper<AttachmentTable>()
- .eq(AttachmentTable::getSubclassId, id)
- .eq(AttachmentTable::getOtherTableName, AttachmentType.getAttachmentValue(type))
- .like(AttachmentTable::getFileName, suffix)
- .orderByDesc(AttachmentTable::getId));
- if(CollectionUtils.isNotEmpty(attachmentTables)) {
- AttachmentTable attachmentTable = attachmentTables.get(0);
- MinioClient build = MinioClient.builder()
- .endpoint(minioConfig.getEndpoint(), minioConfig.getPort(), minioConfig.getSecure())
- .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey())
- .build();
- try {
- url = build.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
- .method(Method.GET)
- .bucket(minioConfig.getBucketName())
- .object(attachmentTable.getFileName())
- .expiry(60 * 60 * 24)
- .build());
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
- return url;
- }
-
- public InputStream getInputStream(Integer id, Integer type , String suffix) {
- InputStream inputStream = null;
- // 鏌ヨ鏁版嵁搴� 鑾峰彇鏈�鏂版枃浠跺悕
- List<AttachmentTable> attachmentTables = baseMapper.selectList(new LambdaQueryWrapper<AttachmentTable>()
- .eq(AttachmentTable::getSubclassId, id)
- .eq(AttachmentTable::getOtherTableName, AttachmentType.getAttachmentValue(type))
- .like(StringUtils.isNotEmpty(suffix),AttachmentTable::getFileName, suffix)
- .orderByDesc(AttachmentTable::getId));
- if(CollectionUtils.isNotEmpty(attachmentTables)) {
- AttachmentTable attachmentTable = attachmentTables.get(0);
- MinioClient build = MinioClient.builder()
- .endpoint(minioConfig.getEndpoint(), minioConfig.getPort(), minioConfig.getSecure())
- .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey())
- .build();
- try {
- inputStream = build.getObject(
- GetObjectArgs.builder()
- .bucket(minioConfig.getBucketName())
- .object(attachmentTable.getFileName())
- .build());
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- return inputStream;
- }
-
-
-
-
- // 鏍规嵁鏂囦欢鎵╁睍鍚嶈幏鍙� MIME 绫诲瀷
- private String getContentType(String fileExtension) {
- switch (fileExtension) {
- case "jpg":
- case "jpeg":
- return "image/jpeg";
- case "png":
- return "image/png";
- case "gif":
- return "image/gif";
- case "pdf":
- return "application/pdf";
- case "doc":
- return "application/msword";
- case "docx":
- return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
- case "xls":
- return "application/vnd.ms-excel";
- case "xlsx":
- return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- case "ppt":
- case "pptx":
- return "application/vnd.ms-powerpoint";
- default:
- return "application/octet-stream"; // 榛樿浜岃繘鍒舵祦
- }
- }
-}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
index a463ca3..5f7d242 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserMapper.java
@@ -51,6 +51,8 @@
String seldepLimsId(int depLimsId);
+ List<Map<String,Object>> getPersonList(String laboratory);
+
List<Map<String, Object>> getLaboratoryPersonList(String laboratory);
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
index 750379a..cc58d84 100644
--- a/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/UserMapper.xml
@@ -83,11 +83,6 @@
from user u left join custom c on u.company = c.id
where u.id = #{userId}
</select>
- <select id="seldepLimsId" resultType="java.lang.String">
- select name
- from department_lims
- where id = #{depLimsId}
- </select>
<select id="getLaboratoryPersonList" resultType="java.util.Map">
select
u.id,
--
Gitblit v1.9.3