| | |
| | | public AjaxResult selectDataList(DocumentMaterials documentMaterials, Integer pageNum, Integer pageSize) { |
| | | LambdaQueryWrapper<DocumentMaterials> lqw = buildCondition(documentMaterials); |
| | | |
| | | |
| | | lqw.eq(true, DocumentMaterials::getVisible, 1); |
| | | Page<DocumentMaterials> zfClanPage = new Page<>(pageNum, pageSize); |
| | | Page<DocumentMaterials> pageResult = page(zfClanPage, lqw); |
| | | |
| | |
| | | public List<DocumentMaterials> selectDocumentMaterialsList(DocumentMaterials documentMaterials) { |
| | | LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = buildCondition(documentMaterials); |
| | | List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper); |
| | | int size = beanRecords.size(); |
| | | // 获取该案卷的最大页号(总页数) |
| | | Long totalPages = this.baseMapper.getMaxPageNumber(documentMaterials.getRecordId().intValue()); |
| | | |
| | | // 遍历所有条目,设置pageNumberFormatted |
| | | for (int i = 0; i < size; i++) { |
| | | DocumentMaterials item = beanRecords.get(i); |
| | | Long pageNumber = item.getPageNumber(); |
| | | |
| | | if (i == size - 1) { |
| | | // 最后一行:格式化页号为"最后一页页号-总页数"的形式 |
| | | item.setPageNumberFormatted(pageNumber + "-" + totalPages); |
| | | } else { |
| | | // 其他行:直接使用pageNumber的值 |
| | | item.setPageNumberFormatted(pageNumber != null ? pageNumber.toString() : ""); |
| | | } |
| | | if(item.getSecurityLevel().equals("该页另存")) |
| | | item.setSecurityLevel("普通"); |
| | | } |
| | | return beanRecords; |
| | | } |
| | | |
| | | @Override |
| | | public List<DocumentMaterialsVoLarge> selectDocumentMaterialsAllByRecordId(Long id) { |
| | | |
| | | return this.baseMapper.getDocumentMaterialsvoLarge(Math.toIntExact(id)); |
| | | List<DocumentMaterialsVoLarge> lists = this.baseMapper.getDocumentMaterialsvoLarge(Math.toIntExact(id)); |
| | | // 遍历所有条目,设置pageNumberFormatted |
| | | for (int i = 0; i < lists.size(); i++) { |
| | | DocumentMaterialsVoLarge item = lists.get(i); |
| | | Long pageNumber = item.getPageNumber(); |
| | | |
| | | |
| | | if(item.getSecurityLevel().equals("该页另存")) |
| | | item.setSecurityLevel("普通"); |
| | | } |
| | | return lists; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @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()); |
| | |
| | | boolean res = false; |
| | | try { |
| | | res = this.save(documentMaterials); |
| | | |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!"); |
| | |
| | | } |
| | | |
| | | List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper); |
| | | // 遍历所有条目,设置pageNumberFormatted |
| | | for (int i = 0; i < beanRecords.size(); i++) { |
| | | DocumentMaterials item = beanRecords.get(i); |
| | | Long pageNumber = item.getPageNumber(); |
| | | |
| | | |
| | | if(item.getSecurityLevel().equals("该页另存")) |
| | | item.setSecurityLevel("普通"); |
| | | } |
| | | return beanRecords; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DocumentMaterialsVo> findArchMInfo(String recordId) { |
| | | return this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId)); |
| | | public List<DocumentMaterialsVo> findArchMInfo(String recordId, long pageCount) { |
| | | // 获取原始数据列表 |
| | | List<DocumentMaterialsVo> dataList = this.baseMapper.getArchiveMatInfo(Integer.parseInt(recordId)); |
| | | |
| | | // 获取该案卷的最大页号(总页数) |
| | | Long totalPages = (long) pageCount; |
| | | //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 |
| | |
| | | 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, "是否注销不能为空"); |
| | | } |
| | | // 手动转换密级字段 |
| | | // if ("秘密".equals(documentMaterials.getSecurityLevel())) { |
| | | // documentMaterials.setSecurityLevel("该页另存"); |
| | | // } |
| | | // if ("内部用图".equals(documentMaterials.getSecurityLevel())) { |
| | | // documentMaterials.setSecurityLevel("该页另存"); |
| | | // } |
| | | // if ("内部用途".equals(documentMaterials.getSecurityLevel())) { |
| | | // documentMaterials.setSecurityLevel("该页另存"); |
| | | // } |
| | | this.insertDocumentMaterials(documentMaterials); |
| | | } |
| | | |
| | |
| | | public int getFileCount(Integer recordId) { |
| | | return this.baseMapper.getCount(recordId); |
| | | } |
| | | |
| | | |
| | | public List<DocumentMaterials> SelectAllRecordsByPageNumbersToList(Long recordId, Long maxPageNumber) { |
| | | // 获取指定recordId下的所有记录,按页号升序排列 |
| | | LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(DocumentMaterials::getRecordId, recordId); |
| | | lqw.ne(DocumentMaterials::getFileStyle, "其他材料"); |
| | | lqw.orderByAsc(DocumentMaterials::getPageNumber); |
| | | List<DocumentMaterials> records = this.list(lqw); |
| | | |
| | | if (records == null || records.isEmpty()) { |
| | | // return AjaxResult.success("没有找到指定记录"); |
| | | return null; |
| | | } |
| | | |
| | | List<DocumentMaterials> middleRecords = new ArrayList<>(); |
| | | int startFileNumber = 1; |
| | | // 遍历记录,找出需要添加中间页号的位置 |
| | | for (int i = 0; i < records.size() - 1; i++) { |
| | | // startFileNumber = 1; |
| | | int pageOrderNumber = 1; |
| | | DocumentMaterials currentRecord = records.get(i); |
| | | DocumentMaterials nextRecord = records.get(i + 1); |
| | | currentRecord.setFileNumber((long) startFileNumber); |
| | | currentRecord.setPageOrder((long) pageOrderNumber++); |
| | | middleRecords.add(currentRecord); |
| | | long currentPage = currentRecord.getPageNumber(); |
| | | long nextPage = nextRecord.getPageNumber(); |
| | | |
| | | // 如果当前页号和下一页号之间有间隔 |
| | | if (nextPage - currentPage > 1) { |
| | | // 添加中间页号的记录,信息与当前记录保持一致 |
| | | for (long page = currentPage + 1; page < nextPage; page++) { |
| | | DocumentMaterials newRecord = new DocumentMaterials(); |
| | | // 复制当前记录的所有属性 |
| | | BeanUtils.copyBeanProp(newRecord, currentRecord); |
| | | // 设置新的页号 |
| | | newRecord.setPageNumber(page); |
| | | // 清除ID,确保是新记录 |
| | | newRecord.setMaterialId(null); |
| | | // 设置创建时间 |
| | | newRecord.setCreatedAt(new Date()); |
| | | // 重置文件材料序号为null,让系统自动生成 |
| | | newRecord.setFileNumber((long) startFileNumber); |
| | | // 重置页次为null,让系统自动生成 |
| | | newRecord.setPageOrder((long) pageOrderNumber++); |
| | | // 重置图像相关字段,以便上传文件时更新 |
| | | newRecord.setSizeType(null); |
| | | newRecord.setWidth(null); |
| | | newRecord.setHeight(null); |
| | | newRecord.setHorizontalResolution(null); |
| | | newRecord.setVerticalResolution(null); |
| | | newRecord.setFileSize(null); |
| | | newRecord.setFormat(null); |
| | | newRecord.setUrl(null); |
| | | //不在前端显示 |
| | | newRecord.setVisible(0); |
| | | // 添加到中间记录列表 |
| | | middleRecords.add(newRecord); |
| | | } |
| | | } |
| | | //下一次加1 |
| | | startFileNumber++; |
| | | } |
| | | |
| | | // 处理最后一条记录到maxPageNumber之间的间隔 |
| | | // int startLastFileNumber = 1; |
| | | DocumentMaterials lastRecord = records.get(records.size() - 1); |
| | | lastRecord.setFileNumber((long) startFileNumber); |
| | | int lastpageordernumber = 1; |
| | | lastRecord.setPageOrder((long) lastpageordernumber); |
| | | long lastPage = lastRecord.getPageNumber(); |
| | | middleRecords.add(lastRecord); |
| | | if (maxPageNumber > lastPage) { |
| | | // 添加从lastPage+1到maxPageNumber之间的中间记录 |
| | | for (long page = lastPage + 1; page <= maxPageNumber; page++) { |
| | | DocumentMaterials newRecord = new DocumentMaterials(); |
| | | // 复制最后一条记录的所有属性 |
| | | BeanUtils.copyBeanProp(newRecord, lastRecord); |
| | | // 设置新的页号 |
| | | newRecord.setPageNumber(page); |
| | | // 清除ID,确保是新记录 |
| | | newRecord.setMaterialId(null); |
| | | // 设置创建时间 |
| | | newRecord.setCreatedAt(new Date()); |
| | | // 重置文件材料序号为null,让系统自动生成 |
| | | newRecord.setFileNumber((long) startFileNumber); |
| | | // 重置页次为null,让系统自动生成 |
| | | newRecord.setPageOrder((long) lastpageordernumber++); |
| | | // 重置图像相关字段,以便上传文件时更新 |
| | | newRecord.setSizeType(null); |
| | | newRecord.setWidth(null); |
| | | newRecord.setHeight(null); |
| | | newRecord.setHorizontalResolution(null); |
| | | newRecord.setVerticalResolution(null); |
| | | newRecord.setFileSize(null); |
| | | newRecord.setFormat(null); |
| | | newRecord.setUrl(null); |
| | | newRecord.setVisible(0); |
| | | |
| | | // 添加到中间记录列表 |
| | | middleRecords.add(newRecord); |
| | | } |
| | | } |
| | | |
| | | return middleRecords; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addMiddleRecordsByPageNumbers(Long recordId, Long maxPageNumber) { |
| | | try { |
| | |
| | | newRecord.setFileSize(null); |
| | | newRecord.setFormat(null); |
| | | newRecord.setUrl(null); |
| | | newRecord.setVisible(0); |
| | | |
| | | // 添加到中间记录列表 |
| | | middleRecords.add(newRecord); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |