From 8ac9ac3dab7c44bd9d5377dc69eec93ca1f333f6 Mon Sep 17 00:00:00 2001 From: syruan <15555146157@163.com> Date: Mon, 13 Oct 2025 19:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/service/impl/DevInfoServiceImpl.java | 13 ++----------- .../mapper/material/bookcar/BookCarMapper.xml | 1 - .../material/devchange/MaDevInfoMapper.xml | 4 ---- .../mapper/material/device/DevInfoMapper.xml | 12 ++++++++++-- .../mapper/material/home/MaTypeInfoMapper.xml | 1 - .../mapper/material/ma/MaMachineTypeMapper.xml | 16 +--------------- 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index 791ae5d..c7761ee 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -890,17 +890,8 @@ public class DevInfoServiceImpl implements DevInfoService { @Override public List getDevList(DevInfoVo devInfo) { - Integer rentNum = devInfo.getRentNum(); - List devList = devInfoMapper.getDevList(devInfo); - for (DevInfoVo devInfoVo : devList) { - DevInfo devInfo1 = devInfoMapper.getDevStatus(devInfoVo); - devInfoVo.setRentNum(devInfo1.getRentNum()); - devInfoVo.setMaStatus(devInfo1.getMaStatus()); - } - if (rentNum != null) { - devList = devList.stream().filter(devInfoVo -> devInfoVo.getRentNum().equals(rentNum)).collect(Collectors.toList()); - } - return devList; + // 直接由SQL一次性返回 rentNum 与 maStatus,无需循环二次查询 + return devInfoMapper.getDevList(devInfo); } /** diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/bookcar/BookCarMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/bookcar/BookCarMapper.xml index f87bacc..13731fd 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/bookcar/BookCarMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/bookcar/BookCarMapper.xml @@ -34,7 +34,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.manage_type as manageType, d.production_date as productionDate, d.working_hours as workingHours, - d.serial_number as serialNumber, d.person as person, d.person_phone as personPhone, c.company_name as companyName, diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml index afb1146..ac4815b 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/devchange/MaDevInfoMapper.xml @@ -14,7 +14,6 @@ - @@ -223,9 +222,6 @@ working_hours = #{workingHours}, - - serial_number = #{serialNumber}, - diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index 654ca9d..8088db2 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -311,7 +311,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{modelName}, #{productionDate}, #{workingHours}, - #{serialNumber}, #{picUrl}, #{jsMonthPrice}, #{jsDayPrice}, @@ -652,7 +651,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{modelName}, #{productionDate}, #{workingHours}, - #{serialNumber}, #{picUrl}, #{jsMonthPrice}, #{jsDayPrice}, @@ -800,6 +798,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt4.type_name AS typeName, mt4.unit_name AS unitName, d.ma_status AS maStatus, + IFNULL(r.rent_num, 0) AS rentNum, d.brand AS brand, d.production_date AS productionDate, d.working_hours AS workingHours, @@ -820,6 +819,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ma_dev_info d LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id + LEFT JOIN ( + SELECT md.ma_id, COUNT(moi.order_id) AS rent_num + FROM ma_order_details md + LEFT JOIN ma_order_info moi ON moi.order_id = md.order_id + GROUP BY md.ma_id + ) r ON r.ma_id = d.ma_id LEFT JOIN ma_type mt4 ON mt4.type_id = d.type_id AND mt4.del_flag = '0' LEFT JOIN ma_type mt3 ON mt3.type_id = mt4.parent_id @@ -842,6 +847,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND d.ma_status = #{maStatus} + + AND IFNULL(r.rent_num, 0) = #{rentNum} + AND d.update_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59') diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml index 9b24ac3..84551c6 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml @@ -29,7 +29,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" d.brand as brand, d.production_date as productionDate, d.working_hours as workingHours, - d.serial_number as serialNumber, d.person as person, d.person_phone as personPhone, c.company_name as companyName, diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml index 00ec04f..4b31a02 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/ma/MaMachineTypeMapper.xml @@ -11,7 +11,6 @@ - @@ -44,11 +43,8 @@ code, unit_name, manage_type, - lease_price, eff_time, rent_price, - buy_price, - pay_price, level, rated_load, test_load, @@ -319,11 +315,8 @@ m.storage_num, m.unit_name, m.manage_type, - m.lease_price, m.eff_time, m.rent_price, - m.buy_price, - m.pay_price, m.level, m.rated_load, m.test_load, @@ -392,12 +385,8 @@ m.storage_num, m.unit_name, m.manage_type, - m.lease_price, m.is_state_grid, m.eff_time, - m.rent_price, - m.buy_price, - m.pay_price, m.level, m.rated_load, m.test_load, @@ -445,7 +434,7 @@