fix(query): 修复查询时未考虑 del_flag 导致返回已删除数据问题
- 在多个 Mapper 文件中,为 LEFT JOIN 的条件添加 del_flag = 0 判断 - 确保查询结果中不包含已删除的数据
This commit is contained in:
@@ -43,7 +43,7 @@
|
|||||||
oe.remark,
|
oe.remark,
|
||||||
su.nick_name as ownerName
|
su.nick_name as ownerName
|
||||||
from wms_express oe
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
<select id="selectVoByIdPlus" resultType="com.klp.domain.vo.WmsExpressVo">
|
<select id="selectVoByIdPlus" resultType="com.klp.domain.vo.WmsExpressVo">
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
oe.remark,
|
oe.remark,
|
||||||
su.nick_name as ownerName
|
su.nick_name as ownerName
|
||||||
from wms_express oe
|
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}
|
where express_id = #{expressId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
oeq.remark,
|
oeq.remark,
|
||||||
oe.express_code
|
oe.express_code
|
||||||
from wms_express_question oeq
|
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}
|
${ew.getCustomSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
wje.status as je_status,
|
wje.status as je_status,
|
||||||
wje.remark as je_remark
|
wje.remark as je_remark
|
||||||
FROM wms_financial_document wfd
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
p.product_name AS productName,
|
p.product_name AS productName,
|
||||||
p.product_code AS productCode
|
p.product_code AS productCode
|
||||||
FROM wms_order_detail d
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
o.no_tax_amount,
|
o.no_tax_amount,
|
||||||
c.name as customerName
|
c.name as customerName
|
||||||
from wms_order o
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
p.update_time,
|
p.update_time,
|
||||||
p.update_by
|
p.update_by
|
||||||
from wms_payable p
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
r.raw_material_name AS rawMaterialName,
|
r.raw_material_name AS rawMaterialName,
|
||||||
r.raw_material_code AS rawMaterialCode
|
r.raw_material_code AS rawMaterialCode
|
||||||
FROM wms_product_bom b
|
FROM wms_product_bom b
|
||||||
LEFT JOIN wms_product p ON b.product_id = p.product_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
|
LEFT JOIN wms_raw_material r ON b.raw_material_id = r.raw_material_id AND r.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -100,8 +100,8 @@
|
|||||||
psg.remark as psg_remark
|
psg.remark as psg_remark
|
||||||
from
|
from
|
||||||
wms_production_task t
|
wms_production_task t
|
||||||
left join wms_order o on t.order_id = o.order_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
|
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_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
|
left join wms_product_spec_group psg on t.product_spec_group_id = psg.group_id and psg.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
wc.contract_no AS contractNo
|
wc.contract_no AS contractNo
|
||||||
FROM
|
FROM
|
||||||
wms_purchase_plan_detail wpd
|
wms_purchase_plan_detail wpd
|
||||||
LEFT JOIN wms_raw_material wm ON wpd.raw_material_id = wm.raw_material_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
|
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
|
left join wms_contract wc on wpd.contract_id = wc.contract_id and wc.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
r.update_by,
|
r.update_by,
|
||||||
c.name as customerName
|
c.name as customerName
|
||||||
from wms_receivable r
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
ord.del_flag,
|
ord.del_flag,
|
||||||
ord.remark
|
ord.remark
|
||||||
from wms_report_detail ord
|
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}
|
where project_id = #{projectId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
wpt.plan_name AS planName,
|
wpt.plan_name AS planName,
|
||||||
wpt.plan_code AS planCode
|
wpt.plan_code AS planCode
|
||||||
FROM wms_schedule_plan_detail wspd
|
FROM wms_schedule_plan_detail wspd
|
||||||
left join wms_production_line wpl on wspd.line_id = wpl.line_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
|
left join wms_production_task wpt on wspd.task_id = wpt.task_id and wpt.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
wpt.plan_name AS planName,
|
wpt.plan_name AS planName,
|
||||||
wpt.plan_code AS planCode
|
wpt.plan_code AS planCode
|
||||||
FROM wms_schedule_plan_detail wspd
|
FROM wms_schedule_plan_detail wspd
|
||||||
left join wms_production_line wpl on wspd.line_id = wpl.line_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
|
left join wms_production_task wpt on wspd.task_id = wpt.task_id and wpt.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
w1.warehouse_name AS warehouseName,
|
w1.warehouse_name AS warehouseName,
|
||||||
w2.warehouse_name AS fromWarehouseName
|
w2.warehouse_name AS fromWarehouseName
|
||||||
FROM wms_stock_io_detail d
|
FROM wms_stock_io_detail d
|
||||||
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.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
|
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id and w2.del_flag = 0
|
||||||
<where>
|
<where>
|
||||||
<if test="stockIoId != null">d.stock_io_id = #{stockIoId}</if>
|
<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,
|
w1.warehouse_name AS warehouseName,
|
||||||
w2.warehouse_name AS fromWarehouseName
|
w2.warehouse_name AS fromWarehouseName
|
||||||
FROM wms_stock_io_detail d
|
FROM wms_stock_io_detail d
|
||||||
LEFT JOIN wms_warehouse w1 ON d.warehouse_id = w1.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
|
LEFT JOIN wms_warehouse w2 ON d.from_warehouse_id = w2.warehouse_id and w2.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockLogVo">
|
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsStockLogVo">
|
||||||
select sl.*, w.warehouse_name
|
select sl.*, w.warehouse_name
|
||||||
from wms_stock_log sl
|
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}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
ELSE NULL
|
ELSE NULL
|
||||||
END AS itemCode
|
END AS itemCode
|
||||||
FROM wms_stock s
|
FROM wms_stock s
|
||||||
LEFT JOIN wms_product p ON s.item_type = 'product' AND s.item_id = p.product_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
|
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
|
left join wms_warehouse w on s.warehouse_id = w.warehouse_id and w.del_flag = 0
|
||||||
${ew.customSqlSegment}
|
${ew.customSqlSegment}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user