From 89a391ba9f39242cc395947cc9bf8979d357bf3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B6=9B?= Date: Tue, 27 May 2025 10:36:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=80=BB=E8=BE=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/controller/ApplyController.java | 72 ++++++------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/lab-service/lab-capital/src/main/java/org/springblade/lims/goods/controller/ApplyController.java b/lab-service/lab-capital/src/main/java/org/springblade/lims/goods/controller/ApplyController.java index e9c3adc..85696df 100644 --- a/lab-service/lab-capital/src/main/java/org/springblade/lims/goods/controller/ApplyController.java +++ b/lab-service/lab-capital/src/main/java/org/springblade/lims/goods/controller/ApplyController.java @@ -4,6 +4,7 @@ import com.alibaba.nacos.common.utils.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import io.swagger.annotations.Api; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; @@ -105,55 +106,26 @@ public class ApplyController extends BladeController { @GetMapping("/getEveryStatusAndCount") public Map getEveryStatusAndCount(String isGetAll, Integer getType) { Map map = new HashMap<>(6); - QueryWrapper queryWrapper = new QueryWrapper<>(); - // 驳回 - queryWrapper.eq("status", -1); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("bh", applyService.count(queryWrapper)); - queryWrapper.clear(); - // 待审核 - queryWrapper.eq("status", 0); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("dsh", applyService.count(queryWrapper)); - queryWrapper.clear(); - // 待出库 - queryWrapper.eq("status", 1); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("dck", applyService.count(queryWrapper)); - queryWrapper.clear(); - // 待确定 - queryWrapper.eq("status", 2); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("dqd", applyService.count(queryWrapper)); - queryWrapper.clear(); - // 待归还 - queryWrapper.eq("status", 3); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("dgh", applyService.count(queryWrapper)); - queryWrapper.clear(); - // 申领完成 - queryWrapper.eq("status", 4); - if (!"1".equals(isGetAll)) { - queryWrapper.eq("create_dept", AuthUtil.getDeptId()); - queryWrapper.eq("get_type", getType); - } - map.put("slwc", applyService.count(queryWrapper)); - queryWrapper.clear(); + + // 定义状态映射 + Map statusMap = new LinkedHashMap<>(); + statusMap.put("bh", -1); // 驳回 + statusMap.put("dsh", 0); // 待审核 + statusMap.put("dck", 1); // 待出库 + statusMap.put("dqd", 2); // 待确定 + statusMap.put("dgh", 3); // 待归还 + statusMap.put("slwc", 4); // 申领完成 + + // 遍历状态映射并执行查询 + statusMap.forEach((key, status) -> { + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery() + .eq(Apply::getStatus, status) + .eq(Apply::getGetType, getType) + .eq(!"1".equals(isGetAll), Apply::getCreateDept, AuthUtil.getDeptId()); + + map.put(key, applyService.count(wrapper)); + }); + return map; } @@ -483,4 +455,4 @@ public class ApplyController extends BladeController { public R applyCheck() { return R.data(applyService.applyCheck()); } -} +} \ No newline at end of file