物资导出bug优化,任务列表搜索优化

pull/1/head
lqh 3 months ago
parent 612e59d4fc
commit 1a3d33ab0a
  1. 31
      lab-service/lab-capital/src/main/java/org/springblade/lims/goods/controller/GoodsController.java
  2. 33
      lab-service/lab-lims/src/main/java/org/springblade/lims/controller/ExamineController.java

@ -303,11 +303,40 @@ public class GoodsController extends BladeController {
}); });
ExcelUtil.export(response, "物品数据", "物品列表", list, GoodsExcel.class); ExcelUtil.export(response, "物品数据", "物品列表", list, GoodsExcel.class);
} }
/*
导出全部数据
*/
@GetMapping("export-allproduct")
@ApiOperationSupport(order = 10)
@ApiOperation(value = "物品全部导出")
public void exportAllProduct(Goods goods, HttpServletResponse response) {
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
// 添加物品查询模糊查询
if (StringUtil.isNoneBlank(goods.getName())) {
String searchKeyword = goods.getName().trim();
List<String> keywordList = Arrays.stream(searchKeyword.split("\\s+"))
.collect(Collectors.toList());
for (String keyword : keywordList) {
queryWrapper.and(w -> w.like(Goods::getName, keyword)
.or().like(Goods::getCompany, keyword)
.or().like(Goods::getBrand, keyword)
.or().like(Goods::getYt, keyword));
}
}
queryWrapper.orderByDesc(Goods::getCreateTime);
queryWrapper.select(Goods::getId);
queryWrapper.eq(Goods::getIsDeleted, 0);
List<Goods> goodsList = goodsService.list(queryWrapper);
String ids = goodsList.stream()
.map(Goods::getId)
.map(String::valueOf) // 转为字符串(如果ID是Long类型)
.collect(Collectors.joining(","));
exportProduct(ids, response);
}
/** /**
* 入库详情 * 入库详情
*/ */
@GetMapping("inDetail")
public R<IPage<ProductStoreDetial>> inDetail(Goods goods, Query query) { public R<IPage<ProductStoreDetial>> inDetail(Goods goods, Query query) {
LambdaQueryWrapper<ProductStoreDetial> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ProductStoreDetial> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProductStoreDetial::getGoodsId, goods.getId()); wrapper.eq(ProductStoreDetial::getGoodsId, goods.getId());

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -13,6 +14,7 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.lims.ao.CommonAo; import org.springblade.lims.ao.CommonAo;
import org.springblade.lims.entry.*; import org.springblade.lims.entry.*;
import org.springblade.lims.service.*; import org.springblade.lims.service.*;
@ -24,6 +26,7 @@ import org.springblade.system.user.feign.IUserClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 检验列表 * 检验列表
@ -305,13 +308,34 @@ public class ExamineController extends BladeController {
if ("-1".equals(examine.getEntrustStatus())) { if ("-1".equals(examine.getEntrustStatus())) {
wrapper.eq(Examine::getStatus, -1); wrapper.eq(Examine::getStatus, -1);
} }
// 模糊查询 // 模糊查询
if (examine.getSimpleName() != null) {
wrapper.like(Examine::getSimpleName, examine.getSimpleName()).or(); if (examine.getSimpleName() != null && !examine.getSimpleName().trim().isEmpty()) {
String[] keywords = examine.getSimpleName().trim().split("\\s+");
// 遍历每个关键词,每个关键词都要满足「匹配simpleName 或 匹配t_examine_item.name」
for (String keyword : keywords) {
if (keyword.isEmpty()) {
continue; // 跳过空的关键词(比如连续空格导致的空字符串)
}
wrapper.and(w -> w.like(Examine::getSimpleName, keyword) // 匹配主表simpleName
.or() // 匹配关联的t_examine_item.name
.exists("SELECT 1 FROM t_examine_item t WHERE t.id = examine_item_id AND t.name LIKE '%" + keyword + "%'"));
}
} }
wrapper.orderByDesc(Examine::getCreateTime);
IPage<Examine> page = examineService.page(Condition.getPage(query), wrapper);
// 1. 手动构建分页对象,关闭自动count
Page<Examine> page = new Page<>(query.getCurrent(), query.getSize());
page.setSearchCount(false);
// 2. 执行分页数据查询
page = (Page<Examine>) examineService.page(page, wrapper);
// 3. 手动统计总数(复用wrapper条件,保证包含双表匹配)
List<Examine> allMatchList = examineService.list(wrapper);
page.setTotal(allMatchList.size());
//IPage<Examine> page = examineService.page(Condition.getPage(query), wrapper);
List<Examine> records = page.getRecords(); List<Examine> records = page.getRecords();
if (records.size() > 0 && records != null) { if (records.size() > 0 && records != null) {
for (Examine record : records) { for (Examine record : records) {
@ -340,6 +364,7 @@ public class ExamineController extends BladeController {
return R.data(page); return R.data(page);
} }
/** /**
* 获取检测单所有状态及其对应的数量 * 获取检测单所有状态及其对应的数量
*/ */

Loading…
Cancel
Save