2025-11-25 15:44:19 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
< !DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace= "com.klp.mapper.WmsDeliveryWaybillDetailMapper" >
<resultMap type= "com.klp.domain.WmsDeliveryWaybillDetail" id= "WmsDeliveryWaybillDetailResult" >
<result property= "detailId" column= "detail_id" />
<result property= "waybillId" column= "waybill_id" />
<result property= "coilId" column= "coil_id" />
<result property= "productName" column= "product_name" />
<result property= "edgeType" column= "edge_type" />
<result property= "packaging" column= "packaging" />
<result property= "settlementType" column= "settlement_type" />
<result property= "rawMaterialFactory" column= "raw_material_factory" />
<result property= "coilNo" column= "coil_no" />
<result property= "specification" column= "specification" />
<result property= "material" column= "material" />
<result property= "quantity" column= "quantity" />
<result property= "weight" column= "weight" />
<result property= "unitPrice" column= "unit_price" />
<result property= "remark" column= "remark" />
<result property= "delFlag" column= "del_flag" />
<result property= "createTime" column= "create_time" />
<result property= "createBy" column= "create_by" />
<result property= "updateTime" column= "update_time" />
<result property= "updateBy" column= "update_by" />
</resultMap>
2026-01-27 14:47:31 +08:00
<resultMap type= "com.klp.domain.vo.WmsCoilBindInfoVo" id= "WmsCoilBindInfoResult" >
<result property= "coilId" column= "coil_id" />
<result property= "detailId" column= "detail_id" />
2026-01-29 16:51:00 +08:00
<!-- 发货计划 -->
2026-01-27 14:47:31 +08:00
<result property= "planId" column= "plan_id" />
<result property= "planName" column= "plan_name" />
<result property= "planDate" column= "plan_date" />
2026-01-29 16:51:00 +08:00
<!-- 发货单主表 -->
<result property= "waybillId" column= "waybill_id" />
<result property= "waybillNo" column= "waybill_no" />
<result property= "waybillName" column= "waybill_name" />
<result property= "licensePlate" column= "license_plate" />
<result property= "consigneeUnit" column= "consignee_unit" />
<result property= "senderUnit" column= "sender_unit" />
<result property= "deliveryTime" column= "delivery_time" />
<result property= "weighbridge" column= "weighbridge" />
<result property= "salesPerson" column= "sales_person" />
<result property= "principal" column= "principal" />
<result property= "principalPhone" column= "principal_phone" />
<result property= "waybillStatus" column= "status" />
<result property= "waybillRemark" column= "remark" />
<!-- 发货单明细补充字段 -->
<result property= "detailSettlementType" column= "settlement_type" />
<result property= "detailUnitPrice" column= "unit_price" />
2026-01-27 14:47:31 +08:00
</resultMap>
<select id= "selectBindInfoByCoilIds" resultMap= "WmsCoilBindInfoResult" >
SELECT
d.coil_id,
d.detail_id,
2026-01-29 16:51:00 +08:00
-- 发货单主表
2026-01-27 14:47:31 +08:00
w.waybill_id,
w.waybill_no,
w.waybill_name,
2026-01-29 16:51:00 +08:00
w.license_plate,
w.consignee_unit,
w.sender_unit,
w.delivery_time,
w.weighbridge,
w.sales_person,
w.principal,
w.principal_phone,
w.status,
w.remark,
-- 发货计划
2026-01-27 14:47:31 +08:00
p.plan_id,
p.plan_name,
2026-01-29 16:51:00 +08:00
p.plan_date,
-- 发货单明细补充字段
d.settlement_type,
d.unit_price
2026-01-27 14:47:31 +08:00
FROM wms_delivery_waybill_detail d
2026-01-29 17:28:37 +08:00
LEFT JOIN wms_delivery_waybill w ON w.waybill_id = d.waybill_id AND w.del_flag = 0
LEFT JOIN wms_delivery_plan p ON p.plan_id = w.plan_id AND p.del_flag = 0
2026-01-27 14:47:31 +08:00
WHERE d.del_flag = 0
AND d.coil_id IN
<foreach collection= "coilIds" item= "id" open= "(" close= ")" separator= "," >
#{id}
</foreach>
</select>
<select id= "selectBindInfoByCoilId" resultMap= "WmsCoilBindInfoResult" >
SELECT
d.coil_id,
d.detail_id,
2026-01-29 16:51:00 +08:00
-- 发货单主表
2026-01-27 14:47:31 +08:00
w.waybill_id,
w.waybill_no,
w.waybill_name,
2026-01-29 16:51:00 +08:00
w.license_plate,
w.consignee_unit,
w.sender_unit,
w.delivery_time,
w.weighbridge,
w.sales_person,
w.principal,
w.principal_phone,
w.status,
w.remark,
-- 发货计划
2026-01-27 14:47:31 +08:00
p.plan_id,
p.plan_name,
2026-01-29 16:51:00 +08:00
p.plan_date,
-- 发货单明细补充字段
d.settlement_type,
d.unit_price
2026-01-27 14:47:31 +08:00
FROM wms_delivery_waybill_detail d
INNER JOIN wms_delivery_waybill w ON w.waybill_id = d.waybill_id AND w.del_flag = 0
INNER JOIN wms_delivery_plan p ON p.plan_id = w.plan_id AND p.del_flag = 0
WHERE d.del_flag = 0
AND d.coil_id = #{coilId}
LIMIT 1
</select>
2025-11-25 15:44:19 +08:00
2026-03-30 10:15:10 +08:00
<resultMap type= "com.klp.domain.vo.WmsDeliveryWaybillDetailVo" id= "WmsDeliveryWaybillDetailVoResult" >
<result property= "detailId" column= "detail_id" />
<result property= "waybillId" column= "waybill_id" />
<result property= "coilId" column= "coil_id" />
<result property= "productName" column= "product_name" />
<result property= "edgeType" column= "edge_type" />
<result property= "packaging" column= "packaging" />
<result property= "settlementType" column= "settlement_type" />
<result property= "rawMaterialFactory" column= "raw_material_factory" />
<result property= "coilNo" column= "coil_no" />
<result property= "specification" column= "specification" />
<result property= "material" column= "material" />
<result property= "quantity" column= "quantity" />
<result property= "weight" column= "weight" />
<result property= "unitPrice" column= "unit_price" />
<result property= "remark" column= "remark" />
<result property= "createTime" column= "create_time" />
<result property= "createBy" column= "create_by" />
<result property= "updateTime" column= "update_time" />
<result property= "updateBy" column= "update_by" />
<!-- 钢卷信息 -->
<result property= "enterCoilNo" column= "enter_coil_no" />
<result property= "currentCoilNo" column= "current_coil_no" />
<result property= "actualWarehouseName" column= "actual_warehouse_name" />
2026-04-15 15:21:17 +08:00
<result property= "exportTime" column= "export_time" />
2026-03-30 10:15:10 +08:00
<!-- 发货单信息 -->
<result property= "waybillNo" column= "waybill_no" />
<result property= "waybillName" column= "waybill_name" />
<result property= "licensePlate" column= "license_plate" />
<result property= "consigneeUnit" column= "consignee_unit" />
<result property= "senderUnit" column= "sender_unit" />
<result property= "deliveryTime" column= "delivery_time" />
<result property= "weighbridge" column= "weighbridge" />
<result property= "salesPerson" column= "sales_person" />
<result property= "principal" column= "principal" />
<result property= "principalPhone" column= "principal_phone" />
<result property= "waybillStatus" column= "waybill_status" />
<result property= "waybillRemark" column= "waybill_remark" />
<!-- 发货计划信息 -->
<result property= "planId" column= "plan_id" />
<result property= "planName" column= "plan_name" />
<result property= "planDate" column= "plan_date" />
2026-03-30 11:10:44 +08:00
<!-- 原材料/产品信息 -->
<result property= "itemName" column= "item_name" />
<result property= "itemSpecification" column= "item_specification" />
<result property= "itemMaterial" column= "item_material" />
<result property= "manufacturer" column= "item_manufacturer" />
<result property= "itemSurfaceTreatmentDesc" column= "item_surface_treatment_desc" />
<result property= "itemZincLayer" column= "item_zinc_layer" />
2026-03-30 10:15:10 +08:00
</resultMap>
<select id= "selectDetailVoList" resultMap= "WmsDeliveryWaybillDetailVoResult" >
SELECT
d.*,
c.enter_coil_no,
c.current_coil_no,
2026-04-15 15:21:17 +08:00
c.export_time,
2026-03-30 10:15:10 +08:00
aw.actual_warehouse_name,
2026-03-30 11:10:44 +08:00
(CASE c.status WHEN 0 THEN '在库' WHEN 1 THEN '在途' WHEN 2 THEN '已出库' ELSE CAST(c.status AS CHAR) END) AS status_desc,
(CASE WHEN c.item_type = 'raw_material' THEN rm.raw_material_name WHEN c.item_type = 'product' THEN pdt.product_name ELSE NULL END) AS item_name,
(CASE WHEN c.item_type = 'raw_material' THEN rm.specification WHEN c.item_type = 'product' THEN pdt.specification ELSE NULL END) AS item_specification,
(CASE WHEN c.item_type = 'raw_material' THEN rm.material WHEN c.item_type = 'product' THEN pdt.material ELSE NULL END) AS item_material,
(CASE WHEN c.item_type = 'raw_material' THEN rm.manufacturer WHEN c.item_type = 'product' THEN pdt.manufacturer ELSE NULL END) AS item_manufacturer,
(CASE WHEN c.item_type = 'raw_material' THEN rm.surface_treatment_desc WHEN c.item_type = 'product' THEN pdt.surface_treatment_desc ELSE NULL END) AS item_surface_treatment_desc,
(CASE WHEN c.item_type = 'raw_material' THEN rm.zinc_layer WHEN c.item_type = 'product' THEN pdt.zinc_layer ELSE NULL END) AS item_zinc_layer,
2026-03-30 10:15:10 +08:00
w.waybill_no,
w.waybill_name,
w.license_plate,
w.consignee_unit,
w.sender_unit,
w.delivery_time,
w.weighbridge,
w.sales_person,
w.principal,
w.principal_phone,
(CASE w.status WHEN 0 THEN '未发货' WHEN 1 THEN '已发货' WHEN 2 THEN '已打印' WHEN 3 THEN '未打印' ELSE '未知' END) AS waybill_status,
w.remark AS waybill_remark,
p.plan_id,
p.plan_name,
p.plan_date
FROM wms_delivery_waybill_detail d
LEFT JOIN wms_material_coil c ON c.coil_id = d.coil_id AND c.del_flag = 0
LEFT JOIN wms_actual_warehouse aw ON aw.actual_warehouse_id = c.actual_warehouse_id AND aw.del_flag = 0
2026-03-30 11:10:44 +08:00
LEFT JOIN wms_raw_material rm ON c.item_type = 'raw_material' AND c.item_id = rm.raw_material_id AND rm.del_flag = 0
LEFT JOIN wms_product pdt ON c.item_type = 'product' AND c.item_id = pdt.product_id AND pdt.del_flag = 0
2026-03-30 10:15:10 +08:00
LEFT JOIN wms_delivery_waybill w ON w.waybill_id = d.waybill_id AND w.del_flag = 0
LEFT JOIN wms_delivery_plan p ON p.plan_id = w.plan_id AND p.del_flag = 0
WHERE d.del_flag = 0
<if test= "bo.waybillId != null" >
AND d.waybill_id = #{bo.waybillId}
</if>
<if test= "bo.coilId != null" >
AND d.coil_id = #{bo.coilId}
</if>
<if test= "bo.productName != null and bo.productName != ''" >
AND d.product_name LIKE CONCAT('%', #{bo.productName}, '%')
</if>
<if test= "bo.edgeType != null and bo.edgeType != ''" >
AND d.edge_type = #{bo.edgeType}
</if>
<if test= "bo.packaging != null and bo.packaging != ''" >
AND d.packaging = #{bo.packaging}
</if>
<if test= "bo.settlementType != null and bo.settlementType != ''" >
AND d.settlement_type = #{bo.settlementType}
</if>
<if test= "bo.rawMaterialFactory != null and bo.rawMaterialFactory != ''" >
AND d.raw_material_factory = #{bo.rawMaterialFactory}
</if>
<if test= "bo.coilNo != null and bo.coilNo != ''" >
AND d.coil_no = #{bo.coilNo}
</if>
<if test= "bo.specification != null and bo.specification != ''" >
AND d.specification = #{bo.specification}
</if>
<if test= "bo.material != null and bo.material != ''" >
AND d.material = #{bo.material}
</if>
<if test= "bo.quantity != null" >
AND d.quantity = #{bo.quantity}
</if>
<if test= "bo.weight != null" >
AND d.weight = #{bo.weight}
</if>
<if test= "bo.unitPrice != null" >
AND d.unit_price = #{bo.unitPrice}
</if>
2026-04-07 16:46:16 +08:00
<if test= "bo.planId != null" >
AND w.plan_id = #{bo.planId}
</if>
2026-03-30 10:15:10 +08:00
</select>
2026-03-30 11:10:44 +08:00
2025-11-25 15:44:19 +08:00
</mapper>