From ce7184b9b054e4cd98af2d747545d04ae85c2728 Mon Sep 17 00:00:00 2001
From: value <z1292839451@163.com>
Date: 星期一, 29 四月 2024 01:45:52 +0800
Subject: [PATCH] 修改产品绑定和标准库关系

---
 inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java |   40 ++++++++++++++++++++++++++++++++++------
 1 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
index ee1ad15..2392e16 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
@@ -1,6 +1,5 @@
 package com.yuanchu.mom.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,29 +10,28 @@
 import com.spire.doc.FileFormat;
 import com.yuanchu.mom.common.GetLook;
 import com.yuanchu.mom.common.PrintChina;
-import com.yuanchu.mom.dto.InsOrderPlanDTO;
 import com.yuanchu.mom.dto.ReportPageDto;
-import com.yuanchu.mom.dto.SampleOrderDto;
 import com.yuanchu.mom.exception.ErrorException;
+import com.yuanchu.mom.mapper.InsOrderMapper;
 import com.yuanchu.mom.mapper.UserMapper;
+import com.yuanchu.mom.pojo.InsOrder;
 import com.yuanchu.mom.pojo.InsReport;
 import com.yuanchu.mom.service.InsReportService;
 import com.yuanchu.mom.mapper.InsReportMapper;
 import com.yuanchu.mom.utils.QueryWrappers;
-import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.CompletableFuture;
 
 /**
 * @author Administrator
@@ -58,6 +56,9 @@
 
     @Value("${file.path}")
     private String imgUrl;
+
+    @Resource
+    private InsOrderMapper insOrderMapper;
 
     @Override
     public Map<String, Object> pageInsReport(Page page, ReportPageDto reportPageDto) {
@@ -127,6 +128,7 @@
         if (isExamine==0){
             //濡傛灉瀹℃牳涓嶉�氳繃
             insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦
+            return insReportMapper.updateById(insReport);
         }
         //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃
         String signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl();
@@ -142,6 +144,7 @@
 
     //鎵瑰噯
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) {
         InsReport insReport = insReportMapper.selectById(id);
         insReport.setIsRatify(isRatify);
@@ -153,6 +156,7 @@
         if (isRatify==0){
             //濡傛灉鎵瑰噯涓嶉�氳繃
             insReport.setState(0);//鎻愪氦鐘舵�佹敼涓哄緟鎻愪氦
+            return insReportMapper.updateById(insReport);
         }
         //鑾峰彇瀹℃牳浜虹殑绛惧悕鍦板潃
         String signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl();
@@ -163,6 +167,11 @@
         wordInsertUrl(new HashMap<String, Object>(){{
             put("ratifyUrl", Pictures.ofLocal(imgUrl+"/"+signatureUrl).create());
         }}, (urlS==null?url:urlS).replace("/word", wordUrl));
+        wordToPdf((urlS == null ? url : urlS).replace("/word", wordUrl));
+        InsOrder insOrder = new InsOrder();
+        insOrder.setId(insReportMapper.selectById(id).getInsOrderId());
+        insOrder.setState(4);
+        insOrderMapper.updateById(insOrder);
         return insReportMapper.updateById(insReport);
     }
 
@@ -176,6 +185,25 @@
         }
         return 1;
     }
+
+    @Override
+    public void wordToPdf(String path) {
+        CompletableFuture.supplyAsync(() -> {
+            try(ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+                Document document = new Document();
+                document.loadFromFile(path);
+                document.saveToFile(path.replace(".docx", ".pdf"), FileFormat.PDF);
+                System.out.println(path.replace(".docx", ".pdf"));
+                return null;
+            } catch (Exception e) {
+                throw new ErrorException("杞崲澶辫触");
+            }
+        }).thenAccept(res -> {
+        }).exceptionally(e -> {
+            e.printStackTrace();
+            return null;
+        });
+    }
 }
 
 

--
Gitblit v1.9.3