fei
22 小时以前 9b1b0782ecb77d6ee958774da94606478482b063
增加了签名和注解接口
5个文件已修改
322 ■■■■■ 已修改文件
archiveManager/src/main/java/com/ruoyi/mapper/DocumentMaterialsMapper.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/IArchiveAnnotationService.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/ArchiveAnnotationServiceImpl.java 116 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
archiveManager/src/main/java/com/ruoyi/service/impl/BarcodeService.java 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/archive/ArchiveAnnotationController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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" +
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);
    /**
     * 新增【请填写功能名称】
     *
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, "不允许注解名称重复!");
        }
        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);
    }
}
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,ZXing可能仍会保留最小边距
            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();
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;
/**
 * 【请填写功能名称】Controller
 *
@@ -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, "【请填写功能名称】数据");
    }