From e0d15a440c609e6cb764897231efb06323ee8094 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Fri, 6 Mar 2026 10:35:44 +0800 Subject: [PATCH] =?UTF-8?q?2026-03-06=20=E4=BC=98=E5=8C=96=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E7=9B=98=E7=82=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CountingReportController.java | 26 +++++++++++-- .../warehouse/dao/CountingReportMapper.java | 16 ++++++++ .../service/CountingReportService.java | 16 ++++++++ .../impl/CountingReportServiceImpl.java | 38 +++++++++++++++++-- .../mapper/warehouse/CountingReportMapper.xml | 36 +++++++++++++++++- 5 files changed, 125 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java b/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java index 3dd554e..93d5cf0 100644 --- a/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java +++ b/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java @@ -304,7 +304,7 @@ public class CountingReportController extends AbstractController { } /** - * 查询盘点单明细列表 + * 查询盘点单明细列表(带分页) */ @PostMapping("detailList") public R detailList(@RequestBody Map params) { @@ -323,13 +323,33 @@ public class CountingReportController extends AbstractController { return R.error("盘点任务单号不能为空"); } - // 查询明细列表(支持查询条件) + // 分页参数 + int page = params.get("page") != null ? Integer.parseInt(params.get("page").toString()) : 1; + int limit = params.get("limit") != null ? Integer.parseInt(params.get("limit").toString()) : 50; + int offset = (page - 1) * limit; + params.put("offset", offset); + params.put("limit", limit); + + // 分页查询明细列表 List detailList = countingReportService.queryDetailListWithCondition(params); + // 查询当前筛选条件下的总数 + int total = countingReportService.queryDetailTotal(params); + + // 查询全量统计信息(不受查询条件影响,只按 site/buNo/reportId) + Map statisticsParams = new java.util.HashMap<>(); + statisticsParams.put("site", site); + statisticsParams.put("buNo", buNo); + statisticsParams.put("reportId", reportId); + Map statistics = countingReportService.queryDetailStatistics(statisticsParams); + + PageUtils pageUtils = new PageUtils(detailList, total, limit, page); + return R.ok() .put("code", 0) .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000)) - .put("detailList", detailList); + .put("page", pageUtils) + .put("statistics", statistics); } catch (Exception e) { logger.error("查询盘点单明细列表失败", e); return R.error("查询盘点单明细列表失败: " + e.getMessage()); diff --git a/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java b/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java index 5e9c4d6..0a1ee6c 100644 --- a/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java +++ b/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java @@ -118,6 +118,22 @@ public interface CountingReportMapper { @Param("buNo") String buNo, @Param("reportId") String reportId); + /** + * 根据条件查询盘点单明细总数 + * + * @param params 查询参数 + * @return 总数 + */ + int queryDetailTotal(Map params); + + /** + * 查询盘点单明细统计信息(标签总数、物料总数、已盘点数) + * + * @param params 查询参数(site、buNo、reportId) + * @return 统计信息 + */ + Map queryDetailStatistics(Map params); + /** * 根据条件查询盘点单明细列表(带查询条件) * diff --git a/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java b/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java index b7ecbe1..cefd33b 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java @@ -111,6 +111,22 @@ public interface CountingReportService { */ List queryDetailListWithCondition(Map params); + /** + * 根据条件查询盘点单明细总数 + * + * @param params 查询参数 + * @return 总数 + */ + int queryDetailTotal(Map params); + + /** + * 查询盘点单明细统计信息(标签总数、物料总数、已盘点数) + * + * @param params 查询参数(site、buNo、reportId) + * @return 统计信息 + */ + Map queryDetailStatistics(Map params); + /** * 生成盘点任务单号 * diff --git a/src/main/java/com/gaotao/modules/warehouse/service/impl/CountingReportServiceImpl.java b/src/main/java/com/gaotao/modules/warehouse/service/impl/CountingReportServiceImpl.java index 5aeef84..d7749a0 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/impl/CountingReportServiceImpl.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/impl/CountingReportServiceImpl.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -99,9 +100,14 @@ public class CountingReportServiceImpl implements CountingReportService { detail.setCreateBy(countingReport.getCreateBy()); detail.setUpdateBy(countingReport.getUpdateBy()); } - // 批量保存明细 - countingReportMapper.batchSaveDetail(detailList); - logger.info("批量新增盘点单明细成功,明细数: {}", detailList.size()); + // 分批保存明细,每批100条,避免 SQL Server 2100 参数上限(每条13个参数,100条=1300个参数) + final int BATCH_SIZE = 100; + int total = detailList.size(); + for (int i = 0; i < total; i += BATCH_SIZE) { + List batch = new ArrayList<>(detailList.subList(i, Math.min(i + BATCH_SIZE, total))); + countingReportMapper.batchSaveDetail(batch); + } + logger.info("批量新增盘点单明细成功,明细数: {}", total); } return result; @@ -242,6 +248,32 @@ public class CountingReportServiceImpl implements CountingReportService { } } + @Override + public int queryDetailTotal(Map params) { + logger.info("查询盘点单明细总数,参数: {}", params); + try { + int total = countingReportMapper.queryDetailTotal(params); + logger.info("查询盘点单明细总数成功,总数: {}", total); + return total; + } catch (Exception e) { + logger.error("查询盘点单明细总数失败,错误信息: {}", e.getMessage(), e); + throw new RuntimeException("查询盘点单明细总数失败: " + e.getMessage(), e); + } + } + + @Override + public Map queryDetailStatistics(Map params) { + logger.info("查询盘点单明细统计信息,参数: {}", params); + try { + Map statistics = countingReportMapper.queryDetailStatistics(params); + logger.info("查询盘点单明细统计信息成功"); + return statistics; + } catch (Exception e) { + logger.error("查询盘点单明细统计信息失败,错误信息: {}", e.getMessage(), e); + throw new RuntimeException("查询盘点单明细统计信息失败: " + e.getMessage(), e); + } + } + @Override public String generateReportId(String site, String buNo, String type) { logger.info("生成盘点任务单号,站点: {}, BU: {}, 类型: {}", site, buNo, type); diff --git a/src/main/resources/mapper/warehouse/CountingReportMapper.xml b/src/main/resources/mapper/warehouse/CountingReportMapper.xml index ff054e7..fcd81a6 100644 --- a/src/main/resources/mapper/warehouse/CountingReportMapper.xml +++ b/src/main/resources/mapper/warehouse/CountingReportMapper.xml @@ -286,7 +286,7 @@ ORDER BY create_date DESC - + + + + + + + @@ -385,6 +418,7 @@ LEFT JOIN part AS p ON a.site = p.site AND a.part_no = p.partNo WHERE a.site = #{site} AND a.bu_no = #{buNo} + and a.status_tb = 'C'