fei
1 天以前 359f1d48b1d859a23cd35a425d2cffb1e9d1c811
archiveManager/src/main/java/com/ruoyi/service/impl/DocumentMaterialsServiceImpl.java
@@ -129,8 +129,9 @@
    @Override
    public int insertDocumentMaterials(DocumentMaterials documentMaterials) {
        LocalDateTime time = LocalDateTime.now();
        Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
        documentMaterials.setCreatedAt(date);
        System.out.println(documentMaterials.getFileStyle());
@@ -142,7 +143,6 @@
        boolean res = false;
        try {
             res = this.save(documentMaterials);
        } catch (Exception e) {
            System.out.println(e);
            throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!");
@@ -265,7 +265,32 @@
    @Override
    public List<DocumentMaterialsVo> findArchMInfo(String recordId) {
        return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId));
        // 获取原始数据列表
        List<DocumentMaterialsVo> dataList = this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId));
        // 获取该案卷的最大页号(总页数)
        Long totalPages = this.baseMapper.getMaxPageNumber(Integer.parseInt(recordId));
        // 如果数据列表不为空
        if (dataList != null && !dataList.isEmpty() && totalPages != null) {
            int size = dataList.size();
            // 遍历所有条目,设置pageNumberFormatted
            for (int i = 0; i < size; i++) {
                DocumentMaterialsVo item = dataList.get(i);
                Long pageNumber = item.getPageNumber();
                if (i == size - 1) {
                    // 最后一行:格式化页号为"最后一页页号-总页数"的形式
                    item.setPageNumberFormatted(pageNumber + "-" + totalPages);
                } else {
                    // 其他行:直接使用pageNumber的值
                    item.setPageNumberFormatted(pageNumber != null ? pageNumber.toString() : "");
                }
            }
        }
        return dataList;
    }
    @Override
@@ -291,6 +316,32 @@
            BeanUtils.copyProperties(archiveCategory, documentMaterials);
            documentMaterials.setRecordId(Long.parseLong(recordId));
            documentMaterials.setVisible(1);
               // 验证必填字段
        if (StringUtils.isEmpty(documentMaterials.getTitle())) {
            throw new ErrorcodeExceptionextends(400, "文件题名不能为空");
        }
        if (StringUtils.isEmpty(documentMaterials.getFileStyle())) {
            throw new ErrorcodeExceptionextends(400, "材料类型不能为空");
        }
        // 材料类型不是"其它材料"时,页号必须输入
        if (!"其他材料".equals(documentMaterials.getFileStyle()) && documentMaterials.getPageNumber() == null) {
            throw new ErrorcodeExceptionextends(400, "当前材料类型非其它材料,页号必须输入");
        }
        if (StringUtils.isEmpty(documentMaterials.getIsAttachment())) {
            throw new ErrorcodeExceptionextends(400, "是否为附件不能为空");
        }
        if (StringUtils.isEmpty(documentMaterials.getStage())) {
            throw new ErrorcodeExceptionextends(400, "所处阶段不能为空");
        }
        if (StringUtils.isEmpty(documentMaterials.getRetentionPeriod())) {
            throw new ErrorcodeExceptionextends(400, "保管期限不能为空");
        }
        if (StringUtils.isEmpty(documentMaterials.getIsSensitive())) {
            throw new ErrorcodeExceptionextends(400, "是否敏感不能为空");
        }
        if (StringUtils.isEmpty(documentMaterials.getIsCanceled())) {
            throw new ErrorcodeExceptionextends(400, "是否注销不能为空");
        }
            this.insertDocumentMaterials(documentMaterials);
        }
@@ -422,6 +473,14 @@
            return AjaxResult.error("添加中间记录失败:" + e.getMessage());
        }
    }
    @Override
    public Boolean judgeInfo(int recordId) {
            return  this.baseMapper.judgeArchiveInfo(recordId);
    }
}