From a3dbbfc9761886b09df9cc292ecd734c3acc2a91 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Mon, 10 Nov 2025 14:11:40 +0800 Subject: [PATCH] =?UTF-8?q?2025-11-10=20=E4=BB=93=E5=BA=93=E7=9B=98?= =?UTF-8?q?=E7=82=B9=E7=AE=A1=E7=90=86=E7=9A=84=E7=9B=98=E7=82=B9=E4=BB=93?= =?UTF-8?q?=E5=BA=93=E3=80=81=E7=9B=98=E7=82=B9=E5=BA=93=E4=BD=8D=E3=80=81?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E7=89=A9=E6=96=99=E6=94=B9=E4=B8=BA=E5=A4=9A?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CountingReportController.java | 23 ++++++ .../warehouse/dao/CountingReportMapper.java | 8 ++ .../warehouse/entity/CountingReport.java | 24 ++++-- .../service/CountingReportService.java | 8 ++ .../impl/CountingReportServiceImpl.java | 13 +++ .../mapper/warehouse/CountingReportMapper.xml | 80 ++++++++++++++----- 6 files changed, 132 insertions(+), 24 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 0284376..3dd554e 100644 --- a/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java +++ b/src/main/java/com/gaotao/modules/warehouse/controller/CountingReportController.java @@ -335,5 +335,28 @@ public class CountingReportController extends AbstractController { return R.error("查询盘点单明细列表失败: " + e.getMessage()); } } + + /** + * 查询下拉选择数据(仓库/货位/物料) + */ + @PostMapping("/querySelectData") + public R querySelectData(@RequestBody Map params) { + try { + String sql = (String) params.get("sql"); + if (sql == null || sql.trim().isEmpty()) { + return R.error("SQL不能为空"); + } + + List> list = countingReportService.querySelectData(sql); + + return R.ok() + .put("code", 0) + .put("msg", getLanguageMsg(SysMsgConstant.OBJECT_ID_200000)) + .put("list", list); + } 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 0cc61f7..5e9c4d6 100644 --- a/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java +++ b/src/main/java/com/gaotao/modules/warehouse/dao/CountingReportMapper.java @@ -191,6 +191,14 @@ public interface CountingReportMapper { * @return 影响行数 */ int saveDetail(CountingReportDetail detail); + + /** + * 查询下拉选择数据(执行SQL) + * + * @param sql SQL语句 + * @return 查询结果列表 + */ + List> querySelectData(@Param("sql") String sql); } diff --git a/src/main/java/com/gaotao/modules/warehouse/entity/CountingReport.java b/src/main/java/com/gaotao/modules/warehouse/entity/CountingReport.java index a28404a..a6fb37d 100644 --- a/src/main/java/com/gaotao/modules/warehouse/entity/CountingReport.java +++ b/src/main/java/com/gaotao/modules/warehouse/entity/CountingReport.java @@ -34,20 +34,35 @@ public class CountingReport implements Serializable { private String checkDimension; /** - * 盘点仓库ID(当维度为"按仓库"或"按货位"时需填写) + * 盘点仓库ID(当维度为"按仓库"或"按货位"时需填写,多个用逗号分隔) */ private String warehouseId; /** - * 盘点货位ID(当维度为"按货位"或"按仓库"时需填写) + * 盘点仓库名称(多个用逗号分隔) + */ + private String warehouseName; + + /** + * 盘点货位ID(当维度为"按货位"或"按仓库"时需填写,多个用逗号分隔) */ private String locationId; /** - * 盘点物料ID(当维度为"按物料"或"按仓库"时需填写) + * 盘点货位名称(多个用逗号分隔) + */ + private String locationName; + + /** + * 盘点物料ID(当维度为"按物料"或"按仓库"时需填写,多个用逗号分隔) */ private String partNo; + /** + * 盘点物料名称(多个用逗号分隔) + */ + private String partDesc; + /** * 计划盘点时间 */ @@ -89,9 +104,6 @@ public class CountingReport implements Serializable { // 用于前端显示的字段 private String bu; // BU组合字段(site_buNo) private String statusDesc; // 状态描述 - private String warehouseDesc; // 仓库描述 - private String locationDesc; // 货位描述 - private String partDesc; // 物料描述 } 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 ef417e8..b7ecbe1 100644 --- a/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java +++ b/src/main/java/com/gaotao/modules/warehouse/service/CountingReportService.java @@ -120,6 +120,14 @@ public interface CountingReportService { * @return 盘点任务单号 */ String generateReportId(String site, String buNo, String type); + + /** + * 查询下拉选择数据(执行SQL) + * + * @param sql SQL语句 + * @return 查询结果列表 + */ + List> querySelectData(String sql); } 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 ea825a2..5aeef84 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 @@ -254,5 +254,18 @@ public class CountingReportServiceImpl implements CountingReportService { throw new RuntimeException("生成盘点任务单号失败: " + e.getMessage(), e); } } + + @Override + public List> querySelectData(String sql) { + logger.info("查询下拉选择数据,SQL: {}", sql); + try { + List> list = countingReportMapper.querySelectData(sql); + logger.info("查询下拉选择数据成功,记录数: {}", list != null ? list.size() : 0); + return list; + } catch (Exception e) { + logger.error("查询下拉选择数据失败,错误信息: {}", e.getMessage(), e); + throw new RuntimeException("查询下拉选择数据失败: " + e.getMessage(), e); + } + } } diff --git a/src/main/resources/mapper/warehouse/CountingReportMapper.xml b/src/main/resources/mapper/warehouse/CountingReportMapper.xml index d41badc..ff054e7 100644 --- a/src/main/resources/mapper/warehouse/CountingReportMapper.xml +++ b/src/main/resources/mapper/warehouse/CountingReportMapper.xml @@ -47,11 +47,11 @@ cr.report_id AS reportId, cr.check_dimension AS checkDimension, cr.warehouse_id AS warehouseId, - w.warehouseName AS warehouseName, + cr.warehouse_name AS warehouseName, cr.location_id AS locationId, - l.locationName AS locationName, + cr.location_name AS locationName, cr.part_no AS partNo, - p.PartDescription AS partDesc, + cr.part_desc AS partDesc, cr.plan_date AS planDate, cr.create_by AS createBy, cr.update_by AS updateBy, @@ -66,10 +66,7 @@ ELSE '未知' END AS statusDesc, cr.remark - FROM counting_report cr - LEFT JOIN warehouse w ON cr.site = w.site AND cr.warehouse_id = w.warehouseID and cr.bu_no = w.bu_no - LEFT JOIN location l ON cr.site = l.site AND cr.location_id = l.locationID and cr.bu_no = l.bu_no - LEFT JOIN part p ON cr.site = p.site AND cr.part_no = p.partNo + FROM counting_report cr WITH(NOLOCK) WHERE cr.site IN (SELECT site FROM AccessSite WHERE UPPER(userID) = #{userName}) AND cr.bu_no IN (SELECT bu_no FROM AccessBu WHERE username = #{userName}) @@ -82,13 +79,13 @@ AND cr.check_dimension = #{checkDimension} - AND cr.warehouse_id = #{warehouseId} + AND (cr.warehouse_id LIKE '%' + #{warehouseId} + '%' OR cr.warehouse_name LIKE '%' + #{warehouseId} + '%') - AND cr.location_id = #{locationId} + AND (cr.location_id LIKE '%' + #{locationId} + '%' OR cr.location_name LIKE '%' + #{locationId} + '%') - AND cr.part_no = #{partNo} + AND (cr.part_no LIKE '%' + #{partNo} + '%' OR cr.part_desc LIKE '%' + #{partNo} + '%') AND cr.status = #{status} @@ -105,7 +102,7 @@ + + +