| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | |
| | | 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.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.Archiverecordstouser; |
| | | import com.ruoyi.mapper.ArchiveRecordsMapper; |
| | | import com.ruoyi.mapper.ArchiverecordstouserMapper; |
| | | import com.ruoyi.service.IArchiveRecordsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | // @Autowired |
| | | // private ArchiveRecordsMapper archiveRecordsMapper; |
| | | |
| | | @Autowired |
| | | private ArchiverecordstouserMapper archiverecordstouserMapper; |
| | | |
| | | |
| | | |
| | | |
| | | private LambdaQueryWrapper<ArchiveRecords> buildCondition(ArchiveRecords archiveRecords){ |
| | | private LambdaQueryWrapper<ArchiveRecords> buildCondition(ArchiveRecords archiveRecords, Long userId){ |
| | | LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); |
| | | |
| | | lqw.like(!StringUtils.isEmpty(archiveRecords.getProjectName()), ArchiveRecords::getProjectName, archiveRecords.getProjectName()) |
| | |
| | | // .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); |
| | | if(userId==1) |
| | | |
| | | lqw.orderByDesc(ArchiveRecords::getCreateTime); |
| | | System.out.println("ssssssssssssddd0000000000000000"); |
| | | return lqw; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Long getMaxId() { |
| | | //return this. |
| | | return baseMapper.findMaxId(); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult selectDataList(ArchiveRecords archiveRecords, Integer pageNum, Integer pageSize) { |
| | | |
| | | LambdaQueryWrapper<ArchiveRecords> lqw = buildCondition(archiveRecords); |
| | | //拿到当前用户的id |
| | | // 获取当前用户ID |
| | | Long userid = SecurityUtils.getUserId(); |
| | | LambdaQueryWrapper<ArchiveRecords> lqw = buildCondition(archiveRecords, userid); |
| | | |
| | | System.out.println("-------------"); |
| | | System.out.println(pageNum); |
| | | |
| | | Page<ArchiveRecords> zfClanPage = new Page<>(pageNum, pageSize); |
| | | Page<ArchiveRecords> pageResult = page(zfClanPage, lqw); |
| | | |
| | | |
| | | |
| | | Page<ArchiveRecords> page = new Page<>(pageNum, pageSize); |
| | | |
| | | // 使用自定义的分页查询方法,先连接再分页 |
| | | Page<ArchiveRecords> pageResult = this.baseMapper.selectJoinUserPage(page, userid, lqw); |
| | | |
| | | |
| | | //selectJoinUserPage(page, lqw); |
| | | |
| | | |
| | | |
| | | List<ArchiveRecords> beanRecords = pageResult.getRecords();//得到查询出来的数据 |
| | | // List<ArchiveRecords> beanRecords = list(lqw); |
| | | // log.info("从数据库中查到的为:{}", beanRecords); |
| | | // return markOwnData(familyId, fatherFaId, motherFaId, beanRecords); |
| | | |
| | | |
| | | beanRecords.forEach(record ->{ |
| | | if(record.isArchiveRecordsId()!=null&&record.getUserId()==userid) |
| | | { |
| | | record.setOwnData(true); |
| | | } |
| | | else |
| | | record.setOwnData(false); |
| | | }); |
| | | //不是管理员进行排序 |
| | | // if(userid != 1) |
| | | // Collections.sort(beanRecords, Comparator.comparing(ArchiveRecords::isOwnData)); |
| | | HashMap<String, Object> data = MapUtils.getResult(pageResult, beanRecords); |
| | | // System.out.println(data.get("data")); |
| | | // System.out.println(data.get("pageNum")); |
| | |
| | | @Override |
| | | public List<ArchiveRecords> selectArchiveRecordsList(ArchiveRecords archiveRecords) |
| | | { |
| | | LambdaQueryWrapper<ArchiveRecords> lambdaQueryWrapper = buildCondition(archiveRecords); |
| | | //拿到当前用户的id |
| | | // 获取当前用户ID |
| | | Long userid = SecurityUtils.getUserId(); |
| | | LambdaQueryWrapper<ArchiveRecords> lambdaQueryWrapper = buildCondition(archiveRecords,userid); |
| | | List<ArchiveRecords> beanRecords = list(lambdaQueryWrapper); |
| | | |
| | | return beanRecords; |
| | |
| | | @Override |
| | | public int insertArchiveRecords(ArchiveRecords archiveRecords) |
| | | { |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | |
| | | Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
| | | archiveRecords.setCreateTime(date); |
| | | boolean res = this.save(archiveRecords); |
| | | if(res) |
| | | return 1; |