| | |
| | | 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.extension.plugins.pagination.Page; |
| | | import com.dji.sample.common.model.Pagination; |
| | | import com.dji.sample.common.model.PaginationData; |
| | |
| | | import com.dji.sample.patches.model.Param.PatchesParam; |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import com.dji.sample.patches.service.GetPatchesService; |
| | | import com.dji.sample.patches.utils.DistrictCodeUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | |
| | | */ |
| | | @Override |
| | | public PaginationData<LotInfo> limitGet(PatchesParam param) { |
| | | if (param.getIsPlan() != null) { |
| | | Page<LotInfo> page = mapper.selectPage(new Page<LotInfo>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getWorkspaceId, param.getWorkspaceId()) |
| | | .like(LotInfo::getDkbh, param.getDkbh()) |
| | | .like(LotInfo::getXzqdm, param.getXzqdm()) |
| | | .eq(LotInfo::getIsPlan, param.getIsPlan())); |
| | | List<LotInfo> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<LotInfo>(records, new Pagination(page)); |
| | | } else { |
| | | Page<LotInfo> page = mapper.selectPage(new Page<LotInfo>(param.getPage(), param.getPageSize()), |
| | | new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getWorkspaceId, param.getWorkspaceId()) |
| | | .like(LotInfo::getDkbh, param.getDkbh()) |
| | | .like(LotInfo::getXzqdm, param.getXzqdm())); |
| | | List<LotInfo> records = page.getRecords() |
| | | .stream() |
| | | .collect(Collectors.toList()); |
| | | return new PaginationData<LotInfo>(records, new Pagination(page)); |
| | | // 创建分页对象 |
| | | Page<LotInfo> page = new Page<>(param.getPage(), param.getPageSize()); |
| | | |
| | | // 创建查询条件对象 |
| | | LambdaQueryWrapper<LotInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | // 添加查询条件 |
| | | queryWrapper.eq(LotInfo::getWorkspaceId, param.getWorkspaceId()); |
| | | |
| | | if (param.getDkbh() != null && !param.getDkbh().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getDkbh, param.getDkbh()); |
| | | } |
| | | if (param.getInvestigate() != null) { |
| | | queryWrapper.eq(LotInfo::getInvestigate, param.getInvestigate()); |
| | | } |
| | | if (param.getDkbh() != null && !param.getDkbh().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getDkbh, param.getDkbh()); |
| | | } |
| | | if (param.getXzqdm() != null && !param.getXzqdm().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getXzqdm, param.getXzqdm()); |
| | | } |
| | | if (param.getXmc() != null && !param.getXmc().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getXmc, param.getXmc()); |
| | | } |
| | | if (param.getBsm() != null && !param.getBsm().isEmpty()) { |
| | | queryWrapper.like(LotInfo::getXmc, param.getBsm()); |
| | | } |
| | | |
| | | // 执行分页查询 |
| | | Page<LotInfo> resultPage = mapper.selectPage(page, queryWrapper); |
| | | |
| | | // 处理查询结果 |
| | | List<LotInfo> records = resultPage.getRecords() |
| | | .stream() |
| | | .peek(lotInfo -> { |
| | | // 修改 xzqdm 字段的值 |
| | | lotInfo.setXmc(DistrictCodeUtils.codeToName(lotInfo.getXzqdm())); |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 返回分页数据 |
| | | return new PaginationData<>(records, new Pagination(resultPage)); |
| | | } |
| | | @Override |
| | | public int delPatches(String workspaceId) { |
| | | return mapper.delete(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getWorkspaceId,workspaceId)); |
| | | } |
| | | |
| | | @Override |
| | | public void delPatches() { |
| | | mapper.delete(null); |
| | | public int deleteOne(int id) { |
| | | return mapper.deleteById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据条件获取照片的分页数据 |
| | |
| | | public List<LotInfo> listLotinfo() { |
| | | return mapper.selectList(null); |
| | | } |
| | | |
| | | @Override |
| | | public LotInfo getPatchesFromId(String patchesId){ |
| | | return mapper.selectOne(new LambdaQueryWrapper<LotInfo>().eq(LotInfo::getId,patchesId)); |
| | | } |
| | | @Override |
| | | public void insertLotinfo(List<LotInfo> list) { |
| | | for (int i = 0; i < list.size(); i++) { |