| | |
| | | package com.dji.sample.patches.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dji.sample.common.model.Pagination; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | if (param.getBsm() != null && !param.getBsm().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getXmc, param.getBsm()); |
| | | } |
| | | if (param.getDkmj()!=null){ |
| | | queryWrapper.eq(LotInfo::getDkmj,param.getDkmj()); |
| | | } |
| | | if (param.getIsPlan() != null) { |
| | | queryWrapper.eq(LotInfo::getIsPlan, param.getIsPlan()); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | | Page<LotInfo> resultPage = mapper.selectPage(page, queryWrapper); |
| | |
| | | |
| | | @Override |
| | | public PaginationData getPhoto(PatchesParam param, String dkbh) { |
| | | LotInfo lotInfo=getLotinfoToDb(dkbh); |
| | | int statue=lotInfo.getIsPush(); |
| | | if (statue==1){ |
| | | Page<MediaFileMarkEntity> page = markMapper.selectPage(new Page<MediaFileMarkEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileMarkEntity>().like(MediaFileMarkEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | List<MediaFileMarkEntity> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<MediaFileMarkEntity>(records, new Pagination(page));} |
| | | else { |
| | | Page<MediaFileEntity> page = fileMapper.selectPage(new Page<MediaFileEntity>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | List<MediaFileEntity> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<MediaFileEntity>(records, new Pagination(page));} |
| | | // LotInfo lotInfo = getLotinfoToDb(dkbh); |
| | | // int statue = lotInfo.getIsPush(); |
| | | // |
| | | // if (statue == 1) { |
| | | // List<MediaFileMarkEntity> allResults = markMapper.selectList( |
| | | // new LambdaQueryWrapper<MediaFileMarkEntity>() |
| | | // .like(MediaFileMarkEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | // |
| | | // // 去重处理 |
| | | // Map<String, MediaFileMarkEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | // List<MediaFileMarkEntity> uniqueResults = allResults.stream() |
| | | // .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | // .collect(Collectors.toList()); |
| | | // |
| | | // // 计算分页信息 |
| | | // int total = uniqueResults.size(); |
| | | // int start = (param.getPage() - 1) * param.getPageSize(); |
| | | // int end = Math.min(start + param.getPageSize(), total); |
| | | // |
| | | // // 获取当前页的结果 |
| | | // List<MediaFileMarkEntity> pageResults = uniqueResults.subList(start, end); |
| | | // |
| | | // // 创建临时的 Page 对象 |
| | | // Page<MediaFileMarkEntity> resultPage = new Page<>(param.getPage(), param.getPageSize()); |
| | | // resultPage.setRecords(pageResults); |
| | | // resultPage.setTotal(total); |
| | | // |
| | | // // 返回分页数据 |
| | | // return new PaginationData<>(pageResults, new Pagination(resultPage)); |
| | | // } |
| | | // else { |
| | | List<MediaFileEntity> allResults = fileMapper.selectList( |
| | | new LambdaQueryWrapper<MediaFileEntity>() |
| | | .like(MediaFileEntity::getFileName, "%" + dkbh + "~" + "%")); |
| | | |
| | | } |
| | | // 去重处理 |
| | | Map<String, MediaFileEntity> uniqueFileMap = new LinkedHashMap<>(); |
| | | List<MediaFileEntity> uniqueResults = allResults.stream() |
| | | .filter(mediaFile -> uniqueFileMap.putIfAbsent(mediaFile.getFileName(), mediaFile) == null) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 计算分页信息 |
| | | int total = uniqueResults.size(); |
| | | int start = (param.getPage() - 1) * param.getPageSize(); |
| | | int end = Math.min(start + param.getPageSize(), total); |
| | | |
| | | // 获取当前页的结果 |
| | | List<MediaFileEntity> pageResults = uniqueResults.subList(start, end); |
| | | |
| | | // 创建临时的 Page 对象 |
| | | Page<MediaFileEntity> resultPage = new Page<>(param.getPage(), param.getPageSize()); |
| | | resultPage.setRecords(pageResults); |
| | | resultPage.setTotal(total); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(pageResults, new Pagination(resultPage)); |
| | | } |
| | | // } |
| | | |
| | | |
| | | |
| | | public List<MediaFileEntity> listPohto(String dkbh, String workspaceId) { |
| | | return fileMapper.selectList(new LambdaQueryWrapper<MediaFileEntity>().like(MediaFileEntity::getFileName, "%" + dkbh + "%") |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId)); |
| | | .eq(MediaFileEntity::getWorkspaceId, workspaceId) |
| | | .eq(MediaFileEntity::getExamine,1)); |
| | | } |
| | | public LotInfo getLotinfo(String dkbh, String workspaceId) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh) |
| | |
| | | public LotInfo getLotinfoToDb(String dkbh) { |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getDkbh, dkbh)); |
| | | } |
| | | |
| | | public List<LotInfo> getLotInfosByIds(List<Integer> ids) { |
| | | LambdaQueryWrapper<LotInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(LotInfo::getId, ids); |
| | | return mapper.selectList(queryWrapper); |
| | | } |
| | | public List<LotInfo> listLotinfo() { |
| | | return mapper.selectList(null); |
| | | } |