From cccbfadcb6e96c23a33c40c0687a27c2f6efa1db Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 09 十一月 2026 13:16:42 +0800
Subject: [PATCH] feat(seal): 添加印章详情及图片预览功能

---
 yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pd/seal/PdSealServiceTest.java |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pd/seal/PdSealServiceTest.java b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pd/seal/PdSealServiceTest.java
index 02fb810..27d149a 100644
--- a/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pd/seal/PdSealServiceTest.java
+++ b/yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pd/seal/PdSealServiceTest.java
@@ -21,6 +21,22 @@
     @InjectMocks PdSealService service;
     @Mock JdbcTemplate jdbc;
     @Mock BpmTaskService tasks;
+    @Test void imageLookupIsScopedToCurrentTenant() {
+        cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder.setTenantId(42L);
+        try {
+            byte[] image = {1, 2};
+            when(jdbc.queryForList(anyString(), any(Object[].class)))
+                    .thenReturn(List.of(Map.of("image_data", image)));
+            assertArrayEquals(image, service.getImage(7));
+            verify(jdbc).queryForList(contains("tenant_id=? AND deleted=0"), eq(7L), eq(42L));
+        } finally {
+            cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder.clear();
+        }
+    }
+    @Test void refusesImageWhenSealIsNotFound() {
+        when(jdbc.queryForList(anyString(), any(Object[].class))).thenReturn(List.of());
+        assertThrows(ServiceException.class, () -> service.getImage(7));
+    }
     @Test void refusesDownloadWithoutApprovedApplication() {
         when(jdbc.queryForList(anyString(), any(Object[].class))).thenReturn(List.of());
         assertThrows(ServiceException.class, () -> service.download(1, 7));
@@ -34,6 +50,21 @@
         when(tasks.getTaskListByProcessInstanceId("p",true)).thenReturn(List.of(task));
         assertThrows(ServiceException.class, () -> service.download(1,7));
     }
+    @Test void allowsManualApprovalByApplicant() throws Exception {
+        var buffer = new ByteArrayOutputStream();
+        try (var zip = new ZipOutputStream(buffer)) {
+            zip.putNextEntry(new ZipEntry("word/media/seal.png"));
+            zip.write(new byte[]{1});
+            zip.closeEntry();
+        }
+        when(jdbc.queryForList(anyString(), any(Object[].class))).thenReturn(List.of(Map.of(
+                "process_instance_id", "p", "document_snapshot", buffer.toByteArray(), "seal_image", new byte[]{2})));
+        HistoricTaskInstance task = mock(HistoricTaskInstance.class);
+        when(task.getAssignee()).thenReturn("7");
+        when(task.getTaskLocalVariables()).thenReturn(Map.of("TASK_STATUS", 2, "TASK_REASON", ""));
+        when(tasks.getTaskListByProcessInstanceId("p", true)).thenReturn(List.of(task));
+        assertNotNull(service.download(1, 7));
+    }
     @Test void approvedDownloadEmbedsSelectedImage() throws Exception {
         var buffer=new ByteArrayOutputStream();
         try(var zip=new ZipOutputStream(buffer)){zip.putNextEntry(new ZipEntry("word/media/seal.png"));zip.write(new byte[]{1});zip.closeEntry();}

--
Gitblit v1.9.3