Browse Source

build 合并冲突

mamingxu 2 days ago
parent
commit
18a2c6bc2f

+ 7 - 1
easier-report-biz/src/main/java/com/yaoyicloud/controller/CsoReportController.java

@@ -75,8 +75,14 @@ public class CsoReportController {
         }
     }
 
+    /**
+     * cso word转pdf
+     * @param fileBytes
+     * @return
+     * @throws Exception
+     */
     @PostMapping(value = "/report/create-report", consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE)
-    public ResponseEntity<byte[]> handleReport(@RequestBody byte[] fileBytes) throws Exception {
+    public ResponseEntity<byte[]> handleReport(@RequestBody byte[] fileBytes)  {
         // 1. 直接获取PDF字节流
         ByteArrayOutputStream pdfStream = csoReportService.saveToTempFile(fileBytes);
 

+ 3 - 1
easier-report-biz/src/main/java/com/yaoyicloud/service/CsoReportService.java

@@ -3,6 +3,8 @@ package com.yaoyicloud.service;
 import com.yaoyicloud.constant.enums.ModuleType;
 import com.yaoyicloud.entity.ReportGenerationResult;
 
+import java.io.ByteArrayOutputStream;
+
 
 public interface CsoReportService {
 
@@ -24,5 +26,5 @@ public interface CsoReportService {
     ) throws Exception;
 
 
-
+    ByteArrayOutputStream saveToTempFile(byte[] fileBytes);
 }

+ 51 - 51
easier-report-biz/src/main/java/com/yaoyicloud/service/impl/CsoReportServiceImpl.java

@@ -15,6 +15,7 @@ import com.yaoyicloud.easier.common.file.core.FileTemplate;
 import com.yaoyicloud.render.cso.EntAppendixRender;
 import com.yaoyicloud.render.cso.EntProductIntroductionRender;
 import com.yaoyicloud.render.cso.EntPromotionDetailsRender;
+import com.yaoyicloud.tools.CsoOfficeUtil;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
 import org.springframework.stereotype.Service;
 import com.yaoyicloud.config.CommonDataCache;
@@ -153,57 +154,56 @@ public class CsoReportServiceImpl implements CsoReportService {
 
         return new ReportGenerationResult(reportPath, mergedReportPath, mergeflag);
     }
-	@Override
-	public ByteArrayOutputStream saveToTempFile(byte[] fileBytes) throws Exception {
-		// 1. 初始化路径和字体配置
-		String imagePath = filerepoProperties.getReportImagePath();
-		List<String> fontLists = Arrays.asList(filerepoProperties.getSourceHanSansCnFontMediumPath());
-		// 2. 创建临时Word文件(自动清理)
-		File reportTempWordFile = null;
-		try {
-			reportTempWordFile = File.createTempFile("temp_word_", ".docx");
-			Files.write(reportTempWordFile.toPath(), fileBytes);
-
-			String html = OfficeUtil.convert(reportTempWordFile.getAbsolutePath(), imagePath);
-			try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("1.html"))) {
-				writer2.write(html);
-			} catch (IOException e) {
-				System.err.println("写入 1.html 文件时发生错误: " + e.getMessage());
-				e.printStackTrace();
-			}
-			String html1 = OfficeUtil.formatHtmlCso(html);
-			try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("2.html"))) {
-				writer2.write(html1);
-			} catch (IOException e) {
-				System.err.println("写入 2.html 文件时发生错误: " + e.getMessage());
-				e.printStackTrace();
-			}
-			OfficeUtil.convertHtmlToPdfCso(html1, fontLists, imagePath, true);
-			String html2 = OfficeUtil.formatHtml(html);
-
-			try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("3.html"))) {
-				writer2.write(html2);
-			} catch (IOException e) {
-				System.err.println("写入 3.html 文件时发生错误: " + e.getMessage());
-				e.printStackTrace();
-			}
-			return OfficeUtil.convertHtmlToPdfCso(html2, fontLists, imagePath, false);
-		} catch (Exception e) {
-			log.error("文件转换失败", e);
-			throw e;
-		}
-	}
-
-
-	private void quietlyDelete(File file) {
-		if (file != null && file.exists()) {
-			try {
-				Files.delete(file.toPath());
-			} catch (IOException e) {
-				log.warn("无法删除临时文件 {}: {}", file.getAbsolutePath(), e.getMessage());
-			}
-		}
-	}
 
+    @Override
+    public ByteArrayOutputStream saveToTempFile(byte[] fileBytes) {
+        // 1. 初始化路径和字体配置
+        String imagePath = filerepoProperties.getReportImagePath();
+        List<String> fontLists = Arrays.asList(filerepoProperties.getSourceHanSansCnFontMediumPath());
+        // 2. 创建临时Word文件(自动清理)
+        File reportTempWordFile = null;
+        try {
+            reportTempWordFile = File.createTempFile("temp_word_", ".docx");
+            Files.write(reportTempWordFile.toPath(), fileBytes);
+
+            String html = OfficeUtil.convert(reportTempWordFile.getAbsolutePath(), imagePath);
+            try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("1.html"))) {
+                writer2.write(html);
+            } catch (IOException e) {
+                System.err.println("写入 1.html 文件时发生错误: " + e.getMessage());
+                e.printStackTrace();
+            }
+            String html1 = CsoOfficeUtil.formatHtmlCso(html);
+            try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("2.html"))) {
+                writer2.write(html1);
+            } catch (IOException e) {
+                System.err.println("写入 2.html 文件时发生错误: " + e.getMessage());
+                e.printStackTrace();
+            }
+            CsoOfficeUtil.convertHtmlToPdfCso(html1, fontLists, imagePath, true);
+            String html2 = OfficeUtil.formatHtml(html);
+
+            try (BufferedWriter writer2 = new BufferedWriter(new FileWriter("3.html"))) {
+                writer2.write(html2);
+            } catch (IOException e) {
+                System.err.println("写入 3.html 文件时发生错误: " + e.getMessage());
+                e.printStackTrace();
+            }
+            return CsoOfficeUtil.convertHtmlToPdfCso(html2, fontLists, imagePath, false);
+        } catch (Exception e) {
+            log.error("文件转换失败", e);
+            return null;
+        }
+    }
+
+    private void quietlyDelete(File file) {
+        if (file != null && file.exists()) {
+            try {
+                Files.delete(file.toPath());
+            } catch (IOException e) {
+                log.warn("无法删除临时文件 {}: {}", file.getAbsolutePath(), e.getMessage());
+            }
+        }
+    }
 
 }

+ 46 - 0
logs/easier-report-biz/debug.log

@@ -30085,3 +30085,49 @@ java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" bec
 2025-08-21 12:10:19,082 [http-nio-14070-exec-5] INFO  [com.deepoove.poi.render.DefaultRender] DefaultRender.java:73 - Successfully Render template in 8 millis
 2025-08-21 12:10:19,094 [http-nio-14070-exec-5] INFO  [com.yaoyicloud.factory.FXYAbstractRender] FXYAbstractRender.java:36 - 文档导出成功,文档路径为: C:/Users/yyy/dev/yyc3/easier-be/temp/1C57F8A470F2C2627D85B630E63760F2/1957625996474384386_PLATFORM_COMPANY_ATTACHMENTSECTION.docx
 2025-08-21 12:10:19,316 [http-nio-14070-exec-5] INFO  [com.yaoyicloud.tools.DocxUtil] DocxUtil.java:124 - 文档合并成功,文档路径为:C:/Users/yyy/dev/yyc3/easier-be/temp/1957625996474384386_0d7ec090667d482a987f3a6e305c2ab4.docx
+2025-08-27 17:15:00,252 [main] INFO  [com.yaoyicloud.EasierReportApplication] StartupInfoLogger.java:55 - Starting EasierReportApplication using Java 17.0.1 on DESKTOP-UA6VNIT with PID 34036 (C:\Users\yyy\Desktop\demo\render\easier-render\easier-report-biz\target\classes started by yyy in C:\Users\yyy\Desktop\demo\render\easier-render)
+2025-08-27 17:15:00,254 [main] INFO  [com.yaoyicloud.EasierReportApplication] SpringApplication.java:632 - No active profile set, falling back to 1 default profile: "default"
+2025-08-27 17:15:01,421 [main] INFO  [o.s.d.r.config.RepositoryConfigurationDelegate] RepositoryConfigurationDelegate.java:262 - Multiple Spring Data modules found, entering strict repository configuration mode
+2025-08-27 17:15:01,426 [main] INFO  [o.s.d.r.config.RepositoryConfigurationDelegate] RepositoryConfigurationDelegate.java:132 - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
+2025-08-27 17:15:01,520 [main] INFO  [o.s.d.r.config.RepositoryConfigurationDelegate] RepositoryConfigurationDelegate.java:201 - Finished Spring Data repository scanning in 77 ms. Found 0 Redis repository interfaces.
+2025-08-27 17:15:01,707 [main] WARN  [org.mybatis.spring.mapper.ClassPathMapperScanner] Logger.java:44 - No MyBatis mapper was found in '[com.yaoyicloud]' package. Please check your configuration.
+2025-08-27 17:15:01,782 [main] INFO  [o.springframework.cloud.context.scope.GenericScope] GenericScope.java:283 - BeanFactory id=fe35d0bc-46b8-30ab-9db7-8ccd431c5bb5
+2025-08-27 17:15:01,849 [main] INFO  [c.u.j.c.EnableEncryptablePropertiesBeanFactoryPostProcessor] EnableEncryptablePropertiesBeanFactoryPostProcessor.java:44 - Post-processing PropertySource instances
+2025-08-27 17:15:01,850 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:105 - Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
+2025-08-27 17:15:01,851 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:105 - Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
+2025-08-27 17:15:01,852 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:105 - Skipping PropertySource servletContextInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
+2025-08-27 17:15:01,853 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
+2025-08-27 17:15:01,854 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper
+2025-08-27 17:15:01,854 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper
+2025-08-27 17:15:01,854 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource cachedrandom [org.springframework.cloud.util.random.CachedRandomPropertySource] to EncryptablePropertySourceWrapper
+2025-08-27 17:15:01,854 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource Config resource 'class path resource [application.yml]' via location 'optional:classpath:/' [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
+2025-08-27 17:15:02,228 [main] INFO  [c.u.j.filter.DefaultLazyPropertyFilter] DefaultLazyPropertyFilter.java:45 - Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
+2025-08-27 17:15:02,235 [main] INFO  [c.u.j.resolver.DefaultLazyPropertyResolver] DefaultLazyPropertyResolver.java:46 - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
+2025-08-27 17:15:02,238 [main] INFO  [c.u.j.detector.DefaultLazyPropertyDetector] DefaultLazyPropertyDetector.java:44 - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector
+2025-08-27 17:15:02,385 [main] INFO  [o.s.boot.web.embedded.tomcat.TomcatWebServer] TomcatWebServer.java:108 - Tomcat initialized with port(s): 14070 (http)
+2025-08-27 17:15:02,394 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol] DirectJDKLog.java:173 - Initializing ProtocolHandler ["http-nio-14070"]
+2025-08-27 17:15:02,396 [main] INFO  [org.apache.catalina.core.StandardService] DirectJDKLog.java:173 - Starting service [Tomcat]
+2025-08-27 17:15:02,396 [main] INFO  [org.apache.catalina.core.StandardEngine] DirectJDKLog.java:173 - Starting Servlet engine: [Apache Tomcat/9.0.83]
+2025-08-27 17:15:02,608 [main] INFO  [o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]] DirectJDKLog.java:173 - Initializing Spring embedded WebApplicationContext
+2025-08-27 17:15:02,609 [main] INFO  [o.s.b.w.s.c.ServletWebServerApplicationContext] ServletWebServerApplicationContext.java:292 - Root WebApplicationContext: initialization completed in 2308 ms
+2025-08-27 17:15:02,677 [main] INFO  [c.a.d.s.b.a.DruidDataSourceAutoConfigure] DruidDataSourceAutoConfigure.java:55 - Init DruidDataSource
+2025-08-27 17:15:02,828 [main] INFO  [com.alibaba.druid.pool.DruidDataSource] DruidDataSource.java:1009 - {dataSource-1} inited
+2025-08-27 17:15:04,471 [main] INFO  [o.s.b.actuate.endpoint.web.EndpointLinksResolver] EndpointLinksResolver.java:58 - Exposing 17 endpoint(s) beneath base path '/actuator'
+2025-08-27 17:15:04,546 [main] INFO  [org.apache.coyote.http11.Http11NioProtocol] DirectJDKLog.java:173 - Starting ProtocolHandler ["http-nio-14070"]
+2025-08-27 17:15:04,567 [main] INFO  [o.s.boot.web.embedded.tomcat.TomcatWebServer] TomcatWebServer.java:220 - Tomcat started on port(s): 14070 (http) with context path ''
+2025-08-27 17:15:04,568 [main] INFO  [c.u.j.caching.RefreshScopeRefreshedEventListener] RefreshScopeRefreshedEventListener.java:70 - Refreshing cached encryptable property sources on ServletWebServerInitializedEvent
+2025-08-27 17:15:04,569 [main] INFO  [c.u.j.c.CachingDelegateEncryptablePropertySource] CachingDelegateEncryptablePropertySource.java:92 - Property Source systemProperties refreshed
+2025-08-27 17:15:04,569 [main] INFO  [c.u.j.c.CachingDelegateEncryptablePropertySource] CachingDelegateEncryptablePropertySource.java:92 - Property Source systemEnvironment refreshed
+2025-08-27 17:15:04,570 [main] INFO  [c.u.j.c.CachingDelegateEncryptablePropertySource] CachingDelegateEncryptablePropertySource.java:92 - Property Source random refreshed
+2025-08-27 17:15:04,570 [main] INFO  [c.u.j.c.CachingDelegateEncryptablePropertySource] CachingDelegateEncryptablePropertySource.java:92 - Property Source cachedrandom refreshed
+2025-08-27 17:15:04,570 [main] INFO  [c.u.j.c.CachingDelegateEncryptablePropertySource] CachingDelegateEncryptablePropertySource.java:92 - Property Source Config resource 'class path resource [application.yml]' via location 'optional:classpath:/' refreshed
+2025-08-27 17:15:04,570 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:105 - Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
+2025-08-27 17:15:04,571 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:105 - Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
+2025-08-27 17:15:04,571 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource servletContextInitParams [org.springframework.web.context.support.ServletContextPropertySource] to EncryptableEnumerablePropertySourceWrapper
+2025-08-27 17:15:04,571 [main] INFO  [c.u.j.EncryptablePropertySourceConverter] EncryptablePropertySourceConverter.java:110 - Converting PropertySource Management Server [org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration$SameManagementContextConfiguration$1] to EncryptablePropertySourceWrapper
+2025-08-27 17:15:04,588 [main] INFO  [com.yaoyicloud.EasierReportApplication] StartupInfoLogger.java:61 - Started EasierReportApplication in 4.92 seconds (JVM running for 6.078)
+2025-08-27 17:15:04,763 [RMI TCP Connection(5)-192.168.110.198] INFO  [o.a.c.core.ContainerBase.[Tomcat].[localhost].[/]] DirectJDKLog.java:173 - Initializing Spring DispatcherServlet 'dispatcherServlet'
+2025-08-27 17:15:04,763 [RMI TCP Connection(5)-192.168.110.198] INFO  [org.springframework.web.servlet.DispatcherServlet] FrameworkServlet.java:525 - Initializing Servlet 'dispatcherServlet'
+2025-08-27 17:15:04,764 [RMI TCP Connection(5)-192.168.110.198] INFO  [org.springframework.web.servlet.DispatcherServlet] FrameworkServlet.java:547 - Completed initialization in 0 ms
+2025-08-27 17:15:18,188 [SpringApplicationShutdownHook] INFO  [com.alibaba.druid.pool.DruidDataSource] DruidDataSource.java:2174 - {dataSource-1} closing ...
+2025-08-27 17:15:18,194 [SpringApplicationShutdownHook] INFO  [com.alibaba.druid.pool.DruidDataSource] DruidDataSource.java:2247 - {dataSource-1} closed