From 9b1b0782ecb77d6ee958774da94606478482b063 Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期二, 20 一月 2026 22:41:32 +0800
Subject: [PATCH] 增加了签名和注解接口

---
 archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java                  |   21 +-
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java |   16 +
 archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java               |    5 
 archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java       |  116 +++++++++++++++++--
 archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java                     |  164 +++++++++++++++++++++++++++
 5 files changed, 290 insertions(+), 32 deletions(-)

diff --git a/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java b/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
index 2e4fce8..6672983 100644
--- a/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
+++ b/archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java
@@ -33,20 +33,21 @@
 
 
     //鏌ヨ鍗峰唴鐩綍
-    @Select(
-            "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity, file_style, dm.retention_period from document_materials as dm, archive_records as ar \n" +
-            "            WHERE ar.id = dm.record_id and page_number  IN (\n" +
-            "            SELECT MIN(page_number)\n" +
-            "            FROM document_materials where record_id=#{recordId}\n" +
-            "             GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
+//    @Select(
+//            "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity, file_style, dm.retention_period from document_materials as dm, archive_records as ar \n" +
+//            "            WHERE ar.id = dm.record_id and page_number  IN (\n" +
+//            "            SELECT MIN(page_number)\n" +
+//            "            FROM document_materials where record_id=#{recordId}\n" +
+//            "             GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
+
+    @Select("select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number,dm.remarks, ar.record_id, publicity, file_style, dm.retention_period from document_materials as dm, archive_records as ar " +
+            "where ar.id=dm.record_id and dm.record_id=#{recordId} and file_style!='鍏跺畠鏉愭枡' order by page_number"
+            )
     List<DocumentMaterialsVo> getArchiveMatInfo(@Param("recordId") int recordId);
     //鏌ヨ鍗峰唴鐩綍鐨勮缁嗕俊鎭�
     @Select(
             "select ROW_NUMBER() OVER (ORDER BY page_number) AS num, document_number, creator,title, date, page_number, publicity, file_style, stage,is_attachment,is_diagram, dm.retention_period,is_sensitive,is_canceled,dm.remarks from document_materials as dm, archive_records as ar \n" +
-                    "            WHERE ar.id = dm.record_id and page_number  IN (\n" +
-                    "            SELECT MIN(page_number)\n" +
-                    "            FROM document_materials where record_id=#{recordId}\n" +
-                    "             GROUP BY stage, title) and ar.id =#{recordId} order by page_number ;")
+                    "            WHERE ar.id = dm.record_id and dm.record_id =#{recordId} file_style!='鍏跺畠鏉愭枡' order by page_number ;")
     List<DocumentMaterialsVoMid> getArchiveMatInfoAll(@Param("recordId") int recordId);
 
     @Select(  "select ROW_NUMBER() OVER (ORDER BY page_number) AS num,ar.record_id, file_number, \n" +
diff --git a/archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java b/archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java
index 1ad4c54..949cfc4 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java
@@ -1,6 +1,7 @@
 package com.ruoyi.service;
 
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.domain.ArchiveAnnotation;
 
 import java.util.List;
@@ -27,8 +28,10 @@
      * @param archiveAnnotation 銆愯濉啓鍔熻兘鍚嶇О銆�
      * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚�
      */
-    public List<ArchiveAnnotation> selectArchiveAnnotationList(ArchiveAnnotation archiveAnnotation);
+    public AjaxResult selectArchiveAnnotationList(ArchiveAnnotation archiveAnnotation, Integer pageNum, Integer pageSize);
 
+
+    public List<ArchiveAnnotation> selectArchiveAnnoList(ArchiveAnnotation archiveAnnotation);
     /**
      * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
      *
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java
index b8b8794..6c3ea39 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java
@@ -1,45 +1,133 @@
 package com.ruoyi.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.MapUtils;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.domain.ArchiveAnnotation;
-import com.ruoyi.domain.ArchiveCategory;
+import com.ruoyi.domain.ArchiveSignature;
 import com.ruoyi.mapper.ArchiveAnnotationMapper;
-import com.ruoyi.mapper.ArchiveCategoryMapper;
 import com.ruoyi.service.IArchiveAnnotationService;
-import com.ruoyi.service.IArchiveCategoryService;
+import com.ruoyi.util.ErrorcodeExceptionextends;
 import org.springframework.stereotype.Service;
 
-import java.util.Collections;
-import java.util.List;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.*;
+
 @Service
-public class ArchiveAnnotationServiceImpl  extends ServiceImpl<ArchiveAnnotationMapper, ArchiveAnnotation> implements IArchiveAnnotationService {
-    @Override
-    public ArchiveAnnotation selectArchiveAnnotationById(Long id) {
-        return null;
+public class ArchiveAnnotationServiceImpl extends ServiceImpl<ArchiveAnnotationMapper, ArchiveAnnotation> implements IArchiveAnnotationService {
+
+    private LambdaQueryWrapper<ArchiveAnnotation> buildCondition(ArchiveAnnotation archiveAnnotation) {
+        LambdaQueryWrapper<ArchiveAnnotation> lqw = new LambdaQueryWrapper<>();
+        lqw.like(!StringUtils.isEmpty(archiveAnnotation.getName()), ArchiveAnnotation::getName, archiveAnnotation.getName());
+        
+        lqw.orderByDesc(ArchiveAnnotation::getSrt);
+        return lqw;
     }
 
     @Override
-    public List<ArchiveAnnotation> selectArchiveAnnotationList(ArchiveAnnotation archiveAnnotation) {
+    public ArchiveAnnotation selectArchiveAnnotationById(Long id) {
+        LambdaQueryWrapper<ArchiveAnnotation> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(id != null, ArchiveAnnotation::getId, id);
+        List<ArchiveAnnotation> lists = this.list(lqw);
+        if (!lists.isEmpty())
+            return lists.get(0);
+        else
+            return null;
+    }
+
+    @Override
+    public AjaxResult selectArchiveAnnotationList(ArchiveAnnotation archiveAnnotation, Integer pageNum, Integer pageSize) {
+        LambdaQueryWrapper<ArchiveAnnotation> lqw = buildCondition(archiveAnnotation);
+
+
+        Page<ArchiveAnnotation> archiveSignaturePage = new Page<>(pageNum, pageSize);
+        Page<ArchiveAnnotation> pageResult = page(archiveSignaturePage, lqw);
+
+        List<ArchiveAnnotation> beanRecords = pageResult.getRecords();//寰楀埌鏌ヨ鍑烘潵鐨勬暟鎹�
+
+
+
+        //  List<ArchiveRecords> beanRecords = list(lqw);
+        //   log.info("浠庢暟鎹簱涓煡鍒扮殑涓�:{}", beanRecords);
+        //    return markOwnData(familyId, fatherFaId, motherFaId, beanRecords);
+        HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords);
+
+
+        return AjaxResult.success(data);
+    }
+
+    @Override
+    public List<ArchiveAnnotation> selectArchiveAnnoList(ArchiveAnnotation archiveAnnotation) {
         return Collections.emptyList();
     }
 
     @Override
     public int insertArchiveAnnotation(ArchiveAnnotation archiveAnnotation) {
-        return 0;
+        LocalDateTime time = LocalDateTime.now();
+        if (archiveAnnotation.getName() == null || StringUtils.isEmpty(archiveAnnotation.getName()))
+            throw new RuntimeException("娉ㄨВ鍚嶇О涓嶈兘涓虹┖锛�");
+        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
+        archiveAnnotation.setCreateTime(date);
+        
+        // 鏍规嵁娉ㄨВ鍚嶇О鏌ヨ锛屾槸鍚﹀凡缁忓瓨鍦紝瀛樺湪鐨勮瘽涓嶈鎻掑叆
+        LambdaQueryWrapper<ArchiveAnnotation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(!StringUtils.isEmpty(archiveAnnotation.getName()), ArchiveAnnotation::getName, 
+                archiveAnnotation.getName());
+        List<ArchiveAnnotation> lis = list(lambdaQueryWrapper);
+        if (!lis.isEmpty()) {
+            return 0;
+        }
+        
+        boolean res = this.save(archiveAnnotation);
+        
+        // 0琛ㄧず澶辫触锛�1琛ㄧず鎴愬姛
+        if (res)
+            return 1;
+        else
+            return 0;
     }
 
     @Override
     public int updateArchiveAnnotation(ArchiveAnnotation archiveAnnotation) {
-        return 0;
+        boolean result = false;
+        try {
+            // 浣跨敤LambdaUpdateWrapper鏋勯�犳洿鏂版潯浠讹紝纭繚null鍊间篃鑳芥洿鏂板埌鏁版嵁搴�
+            LambdaUpdateWrapper<ArchiveAnnotation> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.eq(ArchiveAnnotation::getId, archiveAnnotation.getId());
+
+            // 鏄庣‘璁剧疆闇�瑕佹洿鏂扮殑瀛楁
+            updateWrapper.set(ArchiveAnnotation::getName, archiveAnnotation.getName());
+            updateWrapper.set(ArchiveAnnotation::getSrt, archiveAnnotation.getSrt());
+            updateWrapper.set(ArchiveAnnotation::getCreateTime, archiveAnnotation.getCreateTime());
+
+            // 鎵ц鏇存柊鎿嶄綔
+            result = update(updateWrapper);
+        } catch (Exception e) {
+            System.out.println(e);
+            throw new ErrorcodeExceptionextends(500, "涓嶅厑璁告敞瑙e悕绉伴噸澶嶏紒");
+        }
+        if (result)
+            return 1;
+        else
+            return 0;
     }
 
     @Override
     public int deleteArchiveAnnotationByIds(Long[] ids) {
-        return 0;
+        if (this.removeByIds(Arrays.asList(ids))) {
+            return 1;
+        } else {
+            return 0;
+        }
     }
 
     @Override
     public int deleteArchiveAnnotationById(Long id) {
-        return 0;
+        return this.baseMapper.deleteById(id);
     }
 }
diff --git a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
index a717baf..9ee3c57 100644
--- a/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
+++ b/archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java
@@ -23,7 +23,167 @@
 @Service
 
 public class BarcodeService {
-    public byte[] generateBarcodeImage(String barcodeText) {
+    /**
+     * 娣诲姞鏂囧瓧鍒版潯鐮侊紙浼樺寲鐗堟湰锛�
+     */
+    private void addTextToBarcode(Graphics2D g2d, String text, int width, int barcodeHeight) {
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+        // 浣跨敤鏇存竻鏅扮殑瀛椾綋
+        Font font = new Font("Tahoma", Font.PLAIN, 45);
+        g2d.setFont(font);
+        g2d.setColor(Color.BLACK);
+
+        // 璁$畻鏂囧瓧浣嶇疆
+        FontMetrics fm = g2d.getFontMetrics();
+        int textWidth = fm.stringWidth(text);
+        int textHeight = fm.getHeight();
+
+        // 灞呬腑瀵归綈
+        int x = (width - textWidth) / 2;
+        int y = barcodeHeight + textHeight - fm.getDescent(); // 绮剧‘鍨傜洿灞呬腑
+
+        // 缁樺埗鏂囧瓧
+        g2d.drawString(text, x, y);
+    }
+    public byte[] generateBarcodeImage(String barcodeText)   {
+        try {
+            BarcodeFormat format = BarcodeFormat.CODE_39;
+            Code39Writer writer = new Code39Writer();
+
+            // 缂栫爜鍙傛暟 - 璁剧疆杈硅窛涓�0
+            Map<EncodeHintType, Object> hints = new HashMap<>();
+            hints.put(EncodeHintType.MARGIN, 0); // 鍏抽敭锛氳缃竟璺濅负0
+
+            // 鐢熸垚 BitMatrix锛堢函鏉$爜锛屾棤鏂囧瓧锛�
+            // 娉ㄦ剰锛氬嵆浣胯缃簡MARGIN=0锛孼Xing鍙兘浠嶄細淇濈暀鏈�灏忚竟璺�
+            BitMatrix matrix = writer.encode(barcodeText, format, 1300, 141, hints);
+
+            // 鏂规1.1锛氱洿鎺ヨ鍓櫧杈�
+            return generateBarcodeWithCroppedMargin(matrix, barcodeText);
+        }
+        catch (IOException e) {
+            throw new RuntimeException("Error generating barcode", e);
+        } catch (WriterException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private byte[] generateBarcodeWithCroppedMargin(BitMatrix matrix, String barcodeText) throws IOException {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+
+        // 鎵惧埌鏉$爜鐨勫疄闄呰竟鐣�
+        int left = findLeftBoundary(matrix);
+        int right = findRightBoundary(matrix);
+        int top = findTopBoundary(matrix);
+        int bottom = findBottomBoundary(matrix);
+
+        // 璁$畻鏉$爜鐨勫疄闄呭搴﹀拰楂樺害
+        int barcodeWidth = right - left + 1;
+        int barcodeHeight = bottom - top + 1;
+
+        // 璁$畻鏂囧瓧鍖哄煙楂樺害
+        int textAreaHeight = 30 + 27;
+
+        // 鍒涘缓鏈�缁堝浘鍍忥紙绮剧‘灏哄锛�
+        BufferedImage finalImage = new BufferedImage(
+                barcodeWidth,
+                barcodeHeight + textAreaHeight,
+                BufferedImage.TYPE_BYTE_BINARY
+        );
+
+        Graphics2D g2d = finalImage.createGraphics();
+
+        // 鐧借壊鑳屾櫙
+        g2d.setColor(Color.WHITE);
+        g2d.fillRect(0, 0, barcodeWidth, barcodeHeight + textAreaHeight);
+
+        // 缁樺埗鏉$爜锛堝彧缁樺埗鏈夋晥閮ㄥ垎锛�
+        g2d.setColor(Color.BLACK);
+        for (int x = left; x <= right; x++) {
+            for (int y = top; y <= bottom; y++) {
+                if (matrix.get(x, y)) {
+                    g2d.fillRect(x - left, y - top, 1, 1);
+                }
+            }
+        }
+
+        // 娣诲姞鑷畾涔夋枃瀛�
+        addTextToBarcode(g2d, barcodeText, barcodeWidth, barcodeHeight);
+
+        g2d.dispose();
+
+        // 淇濆瓨
+        ByteArrayOutputStream resultStream = new ByteArrayOutputStream();
+        ImageIO.write(finalImage, "png", resultStream);
+
+        return resultStream.toByteArray();
+    }
+
+    // 杈呭姪鏂规硶锛氭壘鍒版潯鐮佺殑杈圭晫
+    private int findLeftBoundary(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+
+        for (int x = 0; x < width; x++) {
+            for (int y = 0; y < height; y++) {
+                if (matrix.get(x, y)) {
+                    return x;
+                }
+            }
+        }
+        return 0;
+    }
+
+    private int findRightBoundary(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+
+        for (int x = width - 1; x >= 0; x--) {
+            for (int y = 0; y < height; y++) {
+                if (matrix.get(x, y)) {
+                    return x;
+                }
+            }
+        }
+        return width - 1;
+    }
+
+    private int findTopBoundary(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+
+        for (int y = 0; y < height; y++) {
+            for (int x = 0; x < width; x++) {
+                if (matrix.get(x, y)) {
+                    return y;
+                }
+            }
+        }
+        return 0;
+    }
+
+    private int findBottomBoundary(BitMatrix matrix) {
+        int width = matrix.getWidth();
+        int height = matrix.getHeight();
+
+        for (int y = height - 1; y >= 0; y--) {
+            for (int x = 0; x < width; x++) {
+                if (matrix.get(x, y)) {
+                    return y;
+                }
+            }
+        }
+        return height - 1;
+    }
+
+
+
+
+    public byte[] generateBarcodeImage1(String barcodeText) {
         try {
            // 浣跨敤 BitMatrix 鐢熸垚绾潯鐮侊紝涓嶅寘鍚换浣曟枃瀛�
             BarcodeFormat format = BarcodeFormat.CODE_39; // 鏍规嵁鎮ㄧ殑鏉$爜绫诲瀷
@@ -36,7 +196,7 @@
             hints.put(EncodeHintType.MARGIN, 0); // 鏃犺竟妗�
 
             // 鐢熸垚 BitMatrix锛堢函鏉$爜锛屾棤鏂囧瓧锛�
-            BitMatrix matrix = writer.encode(barcodeText, format, 230, 63, hints);
+            BitMatrix matrix = writer.encode(barcodeText, format, 1128, 199, hints);
 
             int width = matrix.getWidth();
             int height = matrix.getHeight();
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java
index 21fca5f..5c59ae2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java
@@ -4,6 +4,8 @@
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.domain.ArchiveAnnotation;
 import com.ruoyi.service.IArchiveAnnotationService;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -24,6 +26,9 @@
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.common.core.page.TableDataInfo;
 
+import static com.ruoyi.common.core.page.TableSupport.PAGE_NUM;
+import static com.ruoyi.common.core.page.TableSupport.PAGE_SIZE;
+
 /**
  * 銆愯濉啓鍔熻兘鍚嶇О銆慍ontroller
  *
@@ -42,11 +47,12 @@
      */
     @PreAuthorize("@ss.hasPermi('system:annotation:list')")
     @GetMapping("/list")
-    public TableDataInfo list(ArchiveAnnotation archiveAnnotation)
+    public AjaxResult list(ArchiveAnnotation archiveAnnotation)
     {
-        startPage();
-        List<ArchiveAnnotation> list = archiveAnnotationService.selectArchiveAnnotationList(archiveAnnotation);
-        return getDataTable(list);
+        Integer pageNum = Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1);
+        Integer pageSize = Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10);
+        AjaxResult list = archiveAnnotationService.selectArchiveAnnotationList(archiveAnnotation, pageNum, pageSize);
+        return list;
     }
 
     /**
@@ -57,7 +63,7 @@
     @PostMapping("/export")
     public void export(HttpServletResponse response, ArchiveAnnotation archiveAnnotation)
     {
-        List<ArchiveAnnotation> list = archiveAnnotationService.selectArchiveAnnotationList(archiveAnnotation);
+        List<ArchiveAnnotation> list = archiveAnnotationService.selectArchiveAnnoList(archiveAnnotation);
         ExcelUtil<ArchiveAnnotation> util = new ExcelUtil<ArchiveAnnotation>(ArchiveAnnotation.class);
         util.exportExcel(response, list, "銆愯濉啓鍔熻兘鍚嶇О銆戞暟鎹�");
     }

--
Gitblit v1.9.1