| | |
| | | |
| | | |
| | | 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.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ArchiveCategory; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.DocumentMaterials; |
| | | import com.ruoyi.domain.vo.DocumentMaterialFileSmallVo; |
| | | import com.ruoyi.domain.vo.DocumentMaterialFileStyle; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsVo; |
| | | import com.ruoyi.domain.vo.DocumentMaterialsVoLarge; |
| | | import com.ruoyi.domain.vo.*; |
| | | import com.ruoyi.mapper.DocumentMaterialsMapper; |
| | | import com.ruoyi.service.IDocumentMaterialsService; |
| | | import com.ruoyi.util.ErrorcodeExceptionextends; |
| | |
| | | .like(!StringUtils.isEmpty(documentMaterials.getPublicity()), DocumentMaterials::getPublicity, documentMaterials.getPublicity()) |
| | | .like(!StringUtils.isEmpty(documentMaterials.getRetentionPeriod()), DocumentMaterials::getRetentionPeriod, documentMaterials.getRetentionPeriod()) |
| | | .like(!StringUtils.isEmpty(documentMaterials.getSecurityLevel()), DocumentMaterials::getSecurityLevel, documentMaterials.getSecurityLevel()) |
| | | .like(!StringUtils.isEmpty(documentMaterials.getTitle()), DocumentMaterials::getTitle, documentMaterials.getTitle()) |
| | | |
| | | |
| | | .eq(documentMaterials.getDate()!=null, DocumentMaterials::getDate, documentMaterials.getDate()) |
| | | .eq(documentMaterials.getRecordId()!=null, DocumentMaterials::getRecordId, documentMaterials.getRecordId()) |
| | | .eq(documentMaterials.getPageNumber()!=null, DocumentMaterials::getPageNumber, documentMaterials.getPageNumber()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<DocumentMaterialsFileList> selectDocumentMaterialsFileList(Long id) { |
| | | return this.baseMapper.getDocumentMaterialsFileList(Math.toIntExact(id)); |
| | | } |
| | | |
| | | @Override |
| | | public int insertDocumentMaterials(DocumentMaterials documentMaterials) { |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public int updateDocumentMaterials(DocumentMaterials documentMaterials) { |
| | | public List<DocumentMaterials> selectDocumentMaterialsByIds(Long[] ids) { |
| | | // 获取当前用户ID |
| | | Long userid = SecurityUtils.getUserId(); |
| | | |
| | | boolean result = updateById(documentMaterials); |
| | | // 创建查询条件 |
| | | LambdaQueryWrapper<DocumentMaterials> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 根据ids查询 |
| | | lambdaQueryWrapper.in(DocumentMaterials::getMaterialId, Arrays.asList(ids)); |
| | | lambdaQueryWrapper.orderByAsc(DocumentMaterials::getPageNumber); |
| | | // 如果不是管理员,需要考虑权限过滤(可根据实际权限需求调整) |
| | | if (userid != 1) { |
| | | // 这里可以添加权限相关的过滤条件 |
| | | } |
| | | |
| | | List<DocumentMaterials> beanRecords = list(lambdaQueryWrapper); |
| | | return beanRecords; |
| | | } |
| | | |
| | | @Override |
| | | public int updateDocumentMaterials(DocumentMaterials documentMaterials) { |
| | | boolean result = false; |
| | | try { |
| | | // 使用LambdaUpdateWrapper构造更新条件,确保null值也能更新到数据库 |
| | | LambdaUpdateWrapper<DocumentMaterials> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.eq(DocumentMaterials::getMaterialId, documentMaterials.getMaterialId()); |
| | | |
| | | // 明确设置需要更新的字段 |
| | | updateWrapper.set(DocumentMaterials::getFileNumber, documentMaterials.getFileNumber()); |
| | | updateWrapper.set(DocumentMaterials::getDocumentNumber, documentMaterials.getDocumentNumber()); |
| | | updateWrapper.set(DocumentMaterials::getCreator, documentMaterials.getCreator()); |
| | | updateWrapper.set(DocumentMaterials::getTitle, documentMaterials.getTitle()); |
| | | updateWrapper.set(DocumentMaterials::getDate, documentMaterials.getDate()); |
| | | updateWrapper.set(DocumentMaterials::getPageNumber, documentMaterials.getPageNumber()); // 允许更新为null |
| | | updateWrapper.set(DocumentMaterials::getPageOrder, documentMaterials.getPageOrder()); |
| | | updateWrapper.set(DocumentMaterials::getStage, documentMaterials.getStage()); |
| | | updateWrapper.set(DocumentMaterials::getPublicity, documentMaterials.getPublicity()); |
| | | updateWrapper.set(DocumentMaterials::getIsAttachment, documentMaterials.getIsAttachment()); |
| | | updateWrapper.set(DocumentMaterials::getIsDiagram, documentMaterials.getIsDiagram()); |
| | | updateWrapper.set(DocumentMaterials::getRetentionPeriod, documentMaterials.getRetentionPeriod()); |
| | | updateWrapper.set(DocumentMaterials::getSecurityLevel, documentMaterials.getSecurityLevel()); |
| | | updateWrapper.set(DocumentMaterials::getIsSensitive, documentMaterials.getIsSensitive()); |
| | | updateWrapper.set(DocumentMaterials::getIsCanceled, documentMaterials.getIsCanceled()); |
| | | updateWrapper.set(DocumentMaterials::getFormat, documentMaterials.getFormat()); |
| | | updateWrapper.set(DocumentMaterials::getSizeType, documentMaterials.getSizeType()); |
| | | updateWrapper.set(DocumentMaterials::getHorizontalResolution, documentMaterials.getHorizontalResolution()); |
| | | updateWrapper.set(DocumentMaterials::getVerticalResolution, documentMaterials.getVerticalResolution()); |
| | | updateWrapper.set(DocumentMaterials::getWidth, documentMaterials.getWidth()); |
| | | updateWrapper.set(DocumentMaterials::getHeight, documentMaterials.getHeight()); |
| | | updateWrapper.set(DocumentMaterials::getFileSize, documentMaterials.getFileSize()); |
| | | updateWrapper.set(DocumentMaterials::getAttachmentHistoryNumbers, documentMaterials.getAttachmentHistoryNumbers()); |
| | | updateWrapper.set(DocumentMaterials::getRemarks, documentMaterials.getRemarks()); |
| | | updateWrapper.set(DocumentMaterials::getVisible, documentMaterials.getVisible()); |
| | | updateWrapper.set(DocumentMaterials::getFileStyle, documentMaterials.getFileStyle()); |
| | | // 执行更新操作 |
| | | result = update(updateWrapper); |
| | | } catch (Exception e) { |
| | | System.out.println(e); |
| | | throw new ErrorcodeExceptionextends(500, "同一个案卷内,不允许页码重复!"); |
| | | } |
| | | if(result) |
| | | return 1; |
| | | else |
| | |
| | | |
| | | @Override |
| | | public Long getFiNum(Long pageNumber, Long recordId) { |
| | | return this.baseMapper.getFileNumber(pageNumber, recordId); |
| | | return this.baseMapper.getFileNumber(pageNumber, recordId)+1; |
| | | } |
| | | |
| | | @Override |
| | | public int updateByPageNumber(Long pageNumber, String sizeType, Long fileNumber, int width, int height, int horizontalResolution, int verticalResolution, double fileSize, String url, String format, Long recordId) { |
| | | //根据pageNumber拿到title,然后计算pageOrder |
| | | LambdaQueryWrapper<DocumentMaterials> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(recordId!=null, DocumentMaterials::getRecordId, recordId); |
| | | lqw.eq(pageNumber!=null, DocumentMaterials::getPageNumber, pageNumber); |
| | | List<DocumentMaterials> records = list(lqw); |
| | | |
| | | |
| | | //计算pageOrder |
| | | Long pageOrder = 1L; |
| | | if(pageNumber.equals(1)) |
| | | pageOrder = 1L; |
| | |
| | | DocumentMaterials documentMaterials = new DocumentMaterials(); |
| | | BeanUtils.copyProperties(archiveCategory, documentMaterials); |
| | | documentMaterials.setRecordId(Long.parseLong(recordId)); |
| | | documentMaterials.setVisible(1); |
| | | this.insertDocumentMaterials(documentMaterials); |
| | | } |
| | | |
| | |
| | | else |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isPageNumberIslegal(Integer recordId) { |
| | | return this.baseMapper.isPageNumberLegal(recordId); |
| | | } |
| | | |
| | | @Override |
| | | public int getFileCount(Integer recordId) { |
| | | return this.baseMapper.getCount(recordId); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult addMiddleRecordsByPageNumbers(Long recordId, Long maxPageNumber) { |
| | | try { |
| | | // 获取指定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("没有找到指定记录"); |
| | | } |
| | | |
| | | List<DocumentMaterials> middleRecords = new ArrayList<>(); |
| | | |
| | | // 遍历记录,找出需要添加中间页号的位置 |
| | | for (int i = 0; i < records.size() - 1; i++) { |
| | | DocumentMaterials currentRecord = records.get(i); |
| | | DocumentMaterials nextRecord = records.get(i + 1); |
| | | |
| | | 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(null); |
| | | // 重置页次为null,让系统自动生成 |
| | | newRecord.setPageOrder(null); |
| | | // 重置图像相关字段,以便上传文件时更新 |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 处理最后一条记录到maxPageNumber之间的间隔 |
| | | DocumentMaterials lastRecord = records.get(records.size() - 1); |
| | | long lastPage = lastRecord.getPageNumber(); |
| | | |
| | | 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(null); |
| | | // 重置页次为null,让系统自动生成 |
| | | newRecord.setPageOrder(null); |
| | | // 重置图像相关字段,以便上传文件时更新 |
| | | newRecord.setSizeType(null); |
| | | newRecord.setWidth(null); |
| | | newRecord.setHeight(null); |
| | | newRecord.setHorizontalResolution(null); |
| | | newRecord.setVerticalResolution(null); |
| | | newRecord.setFileSize(null); |
| | | newRecord.setFormat(null); |
| | | newRecord.setUrl(null); |
| | | // 添加到中间记录列表 |
| | | middleRecords.add(newRecord); |
| | | } |
| | | } |
| | | |
| | | // 批量保存中间记录 |
| | | if (!middleRecords.isEmpty()) { |
| | | this.saveBatch(middleRecords); |
| | | return AjaxResult.success("成功添加中间记录", "添加数量:" + middleRecords.size()); |
| | | } else { |
| | | return AjaxResult.success("没有需要添加的中间记录"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return AjaxResult.error("添加中间记录失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Boolean judgeInfo(int recordId) { |
| | | |
| | | return this.baseMapper.judgeArchiveInfo(recordId); |
| | | } |
| | | } |
| | | |
| | | |