package com.ruoyi.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.domain.entity.SysUser; import com.ruoyi.common.utils.MapUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.domain.ArchiveRecords; import com.ruoyi.domain.Archiverecordstouser; import com.ruoyi.domain.DocumentMaterials; import com.ruoyi.mapper.DocumentMaterialsMapper; import com.ruoyi.service.IArchiveCategoryService; import com.ruoyi.service.IDocumentMaterialsService; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; @Service public class DocumentMaterialsServiceImpl extends ServiceImpl implements IDocumentMaterialsService { private LambdaQueryWrapper buildCondition(DocumentMaterials documentMaterials){ LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.like(!StringUtils.isEmpty(documentMaterials.getCreator()), DocumentMaterials::getCreator, documentMaterials.getCreator()) .like(!StringUtils.isEmpty(documentMaterials.getStage()), DocumentMaterials::getStage, documentMaterials.getStage()) .like(!StringUtils.isEmpty(documentMaterials.getIsCanceled()), DocumentMaterials::getIsCanceled, documentMaterials.getIsCanceled()) .like(!StringUtils.isEmpty(documentMaterials.getIsAttachment()), DocumentMaterials::getIsAttachment, documentMaterials.getIsAttachment()) .like(!StringUtils.isEmpty(documentMaterials.getIsSensitive()), DocumentMaterials::getIsSensitive, documentMaterials.getIsSensitive()) .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()) .eq(documentMaterials.getDate()!=null, DocumentMaterials::getDate, documentMaterials.getDate()) .eq(documentMaterials.getRecordId()!=null, DocumentMaterials::getRecordId, documentMaterials.getRecordId()); // .like(!StringUtils.isEmpty(archiveRecords.getFilingNumber()), ArchiveRecords::getFilingNumber, archiveRecords.getFilingNumber()) // .like(!StringUtils.isEmpty(archiveRecords.getArchiveRoomNumber()), ArchiveRecords::getArchiveRoomNumber, archiveRecords.getArchiveRoomNumber()) // .like(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId, archiveRecords.getRecordId()); // // .like(!StringUtils.isEmpty(zfProperty.getLocation()), ZfProperty::getLocation, zfProperty.getLocation()) // .like(!StringUtils.isEmpty(zfProperty.getHolder()), ZfProperty::getHolder, zfProperty.getHolder()) // .like(!StringUtils.isEmpty(zfProperty.getAddress()), ZfProperty::getAddress, zfProperty.getAddress()) // .like(!StringUtils.isEmpty(zfProperty.getRemark()), ZfProperty::getRemark, zfProperty.getRemark()) // .eq(zfProperty.getFamilyId()!=null,ZfProperty::getFamilyId,zfProperty.getFamilyId()) // .in(ZfProperty::getFamilyId,familyIdList) // .eq(zfProperty.getHappenTime()!=null,ZfProperty::getHappenTime,zfProperty.getHappenTime()) // .between(zfProperty.getHappenStartTime() != null && zfProperty.getHappenEndTime() != null, ZfProperty::getHappenTime, zfProperty.getHappenStartTime(), zfProperty.getHappenEndTime()); // lqw.orderByDesc(ZfProperty::getCreateTime); // lqw.orderByDesc(ArchiveRecords::isOwnData) lqw.orderByDesc(DocumentMaterials::getCreatedAt); System.out.println("ssssssssssssddd0000000000000000"); return lqw; } @Override public AjaxResult selectDataList(DocumentMaterials documentMaterials, Integer pageNum, Integer pageSize) { LambdaQueryWrapper lqw = buildCondition(documentMaterials); Page zfClanPage = new Page<>(pageNum, pageSize); Page pageResult = page(zfClanPage, lqw); List beanRecords = pageResult.getRecords();//得到查询出来的数据 // beanRecords.forEach(record -> { // if (record.getUserId() != null) { // SysUser user = userMapper.selectUserById(record.getUserId()); // record.setSysUser(user); // 假设Archiverecordstouser中有setUser方法 // } // }); // List beanRecords = list(lqw); // log.info("从数据库中查到的为:{}", beanRecords); // return markOwnData(familyId, fatherFaId, motherFaId, beanRecords); HashMap data = MapUtils.getResult(pageResult, beanRecords); return AjaxResult.success(data); } @Override public DocumentMaterials selectDocumentMaterialsByMaterialId(String materialId) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(materialId!=null, DocumentMaterials::getMaterialId, materialId); List records = list(lqw); if(!records.isEmpty()) return records.get(0); else return null; } @Override public List selectDocumentMaterialsList(DocumentMaterials documentMaterials) { LambdaQueryWrapper lambdaQueryWrapper = buildCondition(documentMaterials); List beanRecords = list(lambdaQueryWrapper); return beanRecords; } @Override public int insertDocumentMaterials(DocumentMaterials documentMaterials) { LocalDateTime time = LocalDateTime.now(); Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); documentMaterials.setCreatedAt(date); boolean res = this.save(documentMaterials); if(res) return 1; else return 0; } @Override public int updateDocumentMaterials(DocumentMaterials documentMaterials) { boolean result = updateById(documentMaterials); if(result) return 1; else return 0; } @Override public int deleteDocumentMaterialsByMaterialIds(String[] materialIds) { if (this.removeByIds(Arrays.asList(materialIds))) { return 1; } else return 0; } @Override public int deleteDocumentMaterialsByMaterialId(String materialId) { return 0; } }