fix(query): 修复查询时未考虑 del_flag 导致返回已删除数据问题

- 在多个 Mapper 文件中,为 LEFT JOIN 的条件添加 del_flag = 0 判断
- 确保查询结果中不包含已删除的数据
This commit is contained in:
2025-08-26 16:42:29 +08:00
parent 045096b579
commit 666c42a128
15 changed files with 29 additions and 29 deletions

View File

@@ -43,7 +43,7 @@
oe.remark,
su.nick_name as ownerName
from wms_express oe
left join sys_user su on su.user_id = oe.owner_id
left join sys_user su on su.user_id = oe.owner_id and su.del_flag = 0
${ew.customSqlSegment}
</select>
<select id="selectVoByIdPlus" resultType="com.klp.domain.vo.WmsExpressVo">
@@ -66,7 +66,7 @@
oe.remark,
su.nick_name as ownerName
from wms_express oe
left join sys_user su on su.user_id = oe.owner_id
left join sys_user su on su.user_id = oe.owner_id and su.del_flag = 0
where express_id = #{expressId}
</select>

View File

@@ -33,7 +33,7 @@
oeq.remark,
oe.express_code
from wms_express_question oeq
left join wms_express oe on oe.express_id = oeq.express_id
left join wms_express oe on oe.express_id = oeq.express_id and oe.del_flag = 0
${ew.getCustomSqlSegment}
</select>

View File

@@ -68,7 +68,7 @@
wje.status as je_status,
wje.remark as je_remark
FROM wms_financial_document wfd
LEFT JOIN wms_journal_entry wje ON wfd.document_id = wje.document_id
LEFT JOIN wms_journal_entry wje ON wfd.document_id = wje.document_id AND wje.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.product_name AS productName,
p.product_code AS productCode
FROM wms_order_detail d
LEFT JOIN wms_product p ON d.product_id = p.product_id
LEFT JOIN wms_product p ON d.product_id = p.product_id AND p.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -37,7 +37,7 @@
o.no_tax_amount,
c.name as customerName
from wms_order o
left join wms_customer c on o.customer_id = c.customer_id
left join wms_customer c on o.customer_id = c.customer_id and c.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.update_time,
p.update_by
from wms_payable p
left join wms_supplier s on p.supplier_id = s.supplier_id
left join wms_supplier s on p.supplier_id = s.supplier_id and s.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -23,14 +23,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- 分页联查产品和原材料名称编码支持Wrapper动态条件返回Page<WmsProductBomVo> -->
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsProductBomVo">
SELECT
b.*,
b.*,
p.product_name AS productName,
p.product_code AS productCode,
r.raw_material_name AS rawMaterialName,
r.raw_material_code AS rawMaterialCode
FROM wms_product_bom b
LEFT JOIN wms_product p ON b.product_id = p.product_id
LEFT JOIN wms_raw_material r ON b.raw_material_id = r.raw_material_id
LEFT JOIN wms_product p ON b.product_id = p.product_id AND p.del_flag = 0
LEFT JOIN wms_raw_material r ON b.raw_material_id = r.raw_material_id AND r.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -100,8 +100,8 @@
psg.remark as psg_remark
from
wms_production_task t
left join wms_order o on t.order_id = o.order_id
left join wms_order_detail od on t.order_item_id = od.detail_id
left join wms_order o on t.order_id = o.order_id and o.del_flag = 0
left join wms_order_detail od on t.order_item_id = od.detail_id and od.del_flag = 0
left join wms_manufacturing_spec ms on t.manufacturing_spec_id = ms.spec_id and ms.del_flag = 0
left join wms_product_spec_group psg on t.product_spec_group_id = psg.group_id and psg.del_flag = 0
${ew.customSqlSegment}

View File

@@ -33,9 +33,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wc.contract_no AS contractNo
FROM
wms_purchase_plan_detail wpd
LEFT JOIN wms_raw_material wm ON wpd.raw_material_id = wm.raw_material_id
left join wms_supplier ws on wpd.supplier_id = ws.supplier_id
left join wms_contract wc on wpd.contract_id = wc.contract_id
LEFT JOIN wms_raw_material wm ON wpd.raw_material_id = wm.raw_material_id and wm.del_flag = 0
left join wms_supplier ws on wpd.supplier_id = ws.supplier_id and ws.del_flag = 0
left join wms_contract wc on wpd.contract_id = wc.contract_id and wc.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
r.update_by,
c.name as customerName
from wms_receivable r
left join wms_customer c on r.customer_id = c.customer_id
left join wms_customer c on r.customer_id = c.customer_id and c.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -59,7 +59,7 @@
ord.del_flag,
ord.remark
from wms_report_detail ord
left join wms_report_summary ors on ors.summary_id = ord.summary_id
left join wms_report_summary ors on ors.summary_id = ord.summary_id and ors.del_flag = 0
where project_id = #{projectId}
</select>

View File

@@ -42,8 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wpt.plan_name AS planName,
wpt.plan_code AS planCode
FROM wms_schedule_plan_detail wspd
left join wms_production_line wpl on wspd.line_id = wpl.line_id
left join wms_production_task wpt on wspd.task_id = wpt.task_id
left join wms_production_line wpl on wspd.line_id = wpl.line_id and wpl.del_flag = 0
left join wms_production_task wpt on wspd.task_id = wpt.task_id and wpt.del_flag = 0
${ew.customSqlSegment}
</select>
@@ -53,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wpt.plan_name AS planName,
wpt.plan_code AS planCode
FROM wms_schedule_plan_detail wspd
left join wms_production_line wpl on wspd.line_id = wpl.line_id
left join wms_production_task wpt on wspd.task_id = wpt.task_id
left join wms_production_line wpl on wspd.line_id = wpl.line_id and wpl.del_flag = 0
left join wms_production_task wpt on wspd.task_id = wpt.task_id and wpt.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -45,8 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w1.warehouse_name AS warehouseName,
w2.warehouse_name AS fromWarehouseName
FROM wms_stock_io_detail d
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id and w1.del_flag = 0
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id and w2.del_flag = 0
<where>
<if test="stockIoId != null">d.stock_io_id = #{stockIoId}</if>
<!-- 其他条件可补充 -->
@@ -75,8 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
w1.warehouse_name AS warehouseName,
w2.warehouse_name AS fromWarehouseName
FROM wms_stock_io_detail d
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.warehouse_id and w1.del_flag = 0
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id and w2.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockLogVo">
select sl.*, w.warehouse_name
from wms_stock_log sl
left join wms_warehouse w on sl.warehouse_id = w.warehouse_id
left join wms_warehouse w on sl.warehouse_id = w.warehouse_id and w.del_flag = 0
${ew.customSqlSegment}
</select>

View File

@@ -41,9 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ELSE NULL
END AS itemCode
FROM wms_stock s
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_id
LEFT JOIN wms_raw_material r ON s.item_type = 'raw_material' AND s.item_id = r.raw_material_id
left join wms_warehouse w on s.warehouse_id = w.warehouse_id
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_id and p.del_flag = 0
LEFT JOIN wms_raw_material r ON s.item_type = 'raw_material' AND s.item_id = r.raw_material_id and r.del_flag = 0
left join wms_warehouse w on s.warehouse_id = w.warehouse_id and w.del_flag = 0
${ew.customSqlSegment}
</select>