feat(wms/coil): 新增已绑定钢卷列表按发货计划创建时间倒序排序功能
在钢卷查询业务中,当查询已绑定钢卷列表且未指定计划ID(planId)时,新增按关联的发货计划创建时间倒序排序功能,确保较新的计划优先展示。 主要改动: 1. 在WmsMaterialCoilBo中新增orderByPlanDesc布尔字段,用于控制排序逻辑 2. 在WmsMaterialCoilMapper中新增selectVoPagePlusPlanOrder方法及对应的XML映射,通过关联发货计划表支持按计划创建时间排序 3. 在WmsMaterialCoilServiceImpl中调整查询逻辑:当orderByPlanDesc为true时调用新的查询方法,并在查询条件中补充排序规则 4. 在WmsDeliveryWaybillDetailController中设置orderByPlanDesc条件:当planId为空时启用该排序 5. 重构XML映射文件,提取公共SQL片段以提高可维护性 调整前,已绑定钢卷列表在无planId时仅按状态排序;调整后,新增按发货计划创建时间倒序排序,便于用户快速查看最新计划相关的钢卷。
This commit is contained in:
@@ -82,90 +82,91 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
GROUP BY w.warehouse_id, w.warehouse_name
|
||||
ORDER BY w.warehouse_id
|
||||
</select>
|
||||
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
SELECT
|
||||
mc.coil_id,
|
||||
mc.parent_coil_id,
|
||||
mc.export_time,
|
||||
mc.export_by,
|
||||
mc.enter_coil_no,
|
||||
mc.current_coil_no,
|
||||
mc.supplier_coil_no,
|
||||
mc.data_type,
|
||||
mc.material_type,
|
||||
mc.next_warehouse_id,
|
||||
mc.qrcode_record_id,
|
||||
mc.team,
|
||||
mc.has_merge_split,
|
||||
mc.parent_coil_nos,
|
||||
mc.item_type,
|
||||
mc.item_id,
|
||||
mc.gross_weight,
|
||||
mc.net_weight,
|
||||
mc.status,
|
||||
mc.remark,
|
||||
mc.warehouse_id,
|
||||
mc.actual_warehouse_id,
|
||||
mc.del_flag,
|
||||
mc.create_time,
|
||||
mc.update_time,
|
||||
mc.create_by,
|
||||
mc.update_by,
|
||||
mc.quality_status,
|
||||
mc.trimming_requirement,
|
||||
mc.packaging_requirement,
|
||||
mc.packing_status,
|
||||
mc.sale_id AS saleId,
|
||||
mc.length,
|
||||
mc.actual_length,
|
||||
mc.actual_width,
|
||||
mc.actual_thickness,
|
||||
mc.production_start_time,
|
||||
mc.production_end_time,
|
||||
mc.production_duration,
|
||||
mc.coil_surface_treatment,
|
||||
mc.reserved_width,
|
||||
mc.coating_type,
|
||||
mc.temper_grade,
|
||||
mc.business_purpose,
|
||||
mc.is_related_to_order,
|
||||
mc.exclusive_status,
|
||||
mc.transfer_type,
|
||||
mc.theoretical_thickness,
|
||||
mc.theoretical_length,
|
||||
mc.chrome_plate_coil_no,
|
||||
mc.sale_name AS saleName,
|
||||
w.warehouse_name AS warehouseName,
|
||||
nw.warehouse_name AS nextWarehouseName,
|
||||
aw.actual_warehouse_name AS actualWarehouseName,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.specification
|
||||
WHEN mc.item_type = 'product' THEN p.specification
|
||||
ELSE NULL END AS specification,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.material
|
||||
WHEN mc.item_type = 'product' THEN p.material
|
||||
ELSE NULL END AS material,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
||||
WHEN mc.item_type = 'product' THEN p.manufacturer
|
||||
ELSE NULL END AS manufacturer,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
||||
WHEN mc.item_type = 'product' THEN p.surface_treatment_desc
|
||||
ELSE NULL END AS surfaceTreatmentDesc,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.zinc_layer
|
||||
WHEN mc.item_type = 'product' THEN p.zinc_layer
|
||||
ELSE NULL END AS zincLayer,
|
||||
-- 物品名称和编号(用于兼容)
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
ELSE NULL
|
||||
END as itemName,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode,
|
||||
-- 异常数量统计
|
||||
COALESCE(ca.abnormal_count, 0) AS abnormalCount
|
||||
<!-- ==================== 公共 SQL 片段 ==================== -->
|
||||
<sql id="baseColumns">
|
||||
mc.coil_id,
|
||||
mc.parent_coil_id,
|
||||
mc.export_time,
|
||||
mc.export_by,
|
||||
mc.enter_coil_no,
|
||||
mc.current_coil_no,
|
||||
mc.supplier_coil_no,
|
||||
mc.data_type,
|
||||
mc.material_type,
|
||||
mc.next_warehouse_id,
|
||||
mc.qrcode_record_id,
|
||||
mc.team,
|
||||
mc.has_merge_split,
|
||||
mc.parent_coil_nos,
|
||||
mc.item_type,
|
||||
mc.item_id,
|
||||
mc.gross_weight,
|
||||
mc.net_weight,
|
||||
mc.status,
|
||||
mc.remark,
|
||||
mc.warehouse_id,
|
||||
mc.actual_warehouse_id,
|
||||
mc.del_flag,
|
||||
mc.create_time,
|
||||
mc.update_time,
|
||||
mc.create_by,
|
||||
mc.update_by,
|
||||
mc.quality_status,
|
||||
mc.trimming_requirement,
|
||||
mc.packaging_requirement,
|
||||
mc.packing_status,
|
||||
mc.sale_id AS saleId,
|
||||
mc.length,
|
||||
mc.actual_length,
|
||||
mc.actual_width,
|
||||
mc.actual_thickness,
|
||||
mc.production_start_time,
|
||||
mc.production_end_time,
|
||||
mc.production_duration,
|
||||
mc.coil_surface_treatment,
|
||||
mc.reserved_width,
|
||||
mc.coating_type,
|
||||
mc.temper_grade,
|
||||
mc.business_purpose,
|
||||
mc.is_related_to_order,
|
||||
mc.exclusive_status,
|
||||
mc.transfer_type,
|
||||
mc.theoretical_thickness,
|
||||
mc.theoretical_length,
|
||||
mc.chrome_plate_coil_no,
|
||||
mc.sale_name AS saleName,
|
||||
w.warehouse_name AS warehouseName,
|
||||
nw.warehouse_name AS nextWarehouseName,
|
||||
aw.actual_warehouse_name AS actualWarehouseName,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.specification
|
||||
WHEN mc.item_type = 'product' THEN p.specification
|
||||
ELSE NULL END AS specification,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.material
|
||||
WHEN mc.item_type = 'product' THEN p.material
|
||||
ELSE NULL END AS material,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
||||
WHEN mc.item_type = 'product' THEN p.manufacturer
|
||||
ELSE NULL END AS manufacturer,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
||||
WHEN mc.item_type = 'product' THEN p.surface_treatment_desc
|
||||
ELSE NULL END AS surfaceTreatmentDesc,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.zinc_layer
|
||||
WHEN mc.item_type = 'product' THEN p.zinc_layer
|
||||
ELSE NULL END AS zincLayer,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
ELSE NULL
|
||||
END as itemName,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode,
|
||||
COALESCE(ca.abnormal_count, 0) AS abnormalCount
|
||||
</sql>
|
||||
|
||||
<sql id="baseFrom">
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_warehouse nw ON mc.next_warehouse_id = nw.warehouse_id
|
||||
@@ -178,114 +179,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
WHERE del_flag = 0
|
||||
GROUP BY coil_id
|
||||
) ca ON mc.coil_id = ca.coil_id
|
||||
</sql>
|
||||
|
||||
<!-- ==================== 各场景查询 ==================== -->
|
||||
|
||||
<select id="selectVoPagePlus" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
SELECT <include refid="baseColumns"/>
|
||||
<include refid="baseFrom"/>
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- orderBy=true 专用:包含库位排序辅助字段(aw_sort_key/aw_layer_key/aw_id_key)以及父库位 join -->
|
||||
<select id="selectVoPagePlusOrderBy" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
SELECT
|
||||
mc.coil_id,
|
||||
mc.parent_coil_id,
|
||||
mc.export_time,
|
||||
mc.export_by,
|
||||
mc.enter_coil_no,
|
||||
mc.current_coil_no,
|
||||
mc.supplier_coil_no,
|
||||
mc.data_type,
|
||||
mc.material_type,
|
||||
mc.next_warehouse_id,
|
||||
mc.qrcode_record_id,
|
||||
mc.team,
|
||||
mc.has_merge_split,
|
||||
mc.parent_coil_nos,
|
||||
mc.item_type,
|
||||
mc.item_id,
|
||||
mc.gross_weight,
|
||||
mc.net_weight,
|
||||
mc.status,
|
||||
mc.remark,
|
||||
mc.warehouse_id,
|
||||
mc.actual_warehouse_id,
|
||||
mc.del_flag,
|
||||
mc.create_time,
|
||||
mc.update_time,
|
||||
mc.create_by,
|
||||
mc.update_by,
|
||||
mc.quality_status,
|
||||
mc.trimming_requirement,
|
||||
mc.packaging_requirement,
|
||||
mc.packing_status,
|
||||
mc.sale_id AS saleId,
|
||||
mc.length,
|
||||
mc.actual_length,
|
||||
mc.actual_width,
|
||||
mc.actual_thickness,
|
||||
mc.production_start_time,
|
||||
mc.production_end_time,
|
||||
mc.production_duration,
|
||||
mc.reserved_width,
|
||||
mc.coating_type,
|
||||
mc.temper_grade,
|
||||
mc.business_purpose,
|
||||
mc.is_related_to_order,
|
||||
mc.exclusive_status,
|
||||
mc.transfer_type,
|
||||
mc.theoretical_thickness,
|
||||
mc.theoretical_length,
|
||||
mc.chrome_plate_coil_no,
|
||||
mc.sale_name AS saleName,
|
||||
su.nick_name AS saleNickName,
|
||||
w.warehouse_name AS warehouseName,
|
||||
nw.warehouse_name AS nextWarehouseName,
|
||||
aw.actual_warehouse_name AS actualWarehouseName,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.specification
|
||||
WHEN mc.item_type = 'product' THEN p.specification
|
||||
ELSE NULL END AS specification,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.material
|
||||
WHEN mc.item_type = 'product' THEN p.material
|
||||
ELSE NULL END AS material,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
||||
WHEN mc.item_type = 'product' THEN p.manufacturer
|
||||
ELSE NULL END AS manufacturer,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
||||
WHEN mc.item_type = 'product' THEN p.surface_treatment_desc
|
||||
ELSE NULL END AS surfaceTreatmentDesc,
|
||||
CASE WHEN mc.item_type = 'raw_material' THEN rm.zinc_layer
|
||||
WHEN mc.item_type = 'product' THEN p.zinc_layer
|
||||
ELSE NULL END AS zincLayer,
|
||||
-- 物品名称和编号(用于兼容)
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
||||
WHEN mc.item_type = 'product' THEN p.product_name
|
||||
ELSE NULL
|
||||
END as itemName,
|
||||
CASE
|
||||
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_code
|
||||
WHEN mc.item_type = 'product' THEN p.product_code
|
||||
ELSE NULL
|
||||
END as itemCode,
|
||||
-- 库位排序辅助字段(用于全局交错排序,避免在 ORDER BY 中写复杂表达式触发 MP 注入拦截)
|
||||
<include refid="baseColumns"/>,
|
||||
COALESCE(CASE WHEN aw.actual_warehouse_type = 4 THEN awp.sort_no ELSE aw.sort_no END, 0) AS aw_sort_key,
|
||||
CASE WHEN aw.actual_warehouse_type = 4 THEN CAST(SUBSTRING_INDEX(aw.actual_warehouse_code, '-', -1) AS UNSIGNED) ELSE 0 END AS aw_layer_key,
|
||||
COALESCE(aw.actual_warehouse_id, 0) AS aw_id_key,
|
||||
-- 异常数量统计
|
||||
COALESCE(ca.abnormal_count, 0) AS abnormalCount
|
||||
FROM wms_material_coil mc
|
||||
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
||||
LEFT JOIN wms_warehouse nw ON mc.next_warehouse_id = nw.warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_id
|
||||
LEFT JOIN wms_actual_warehouse awp ON aw.parent_id = awp.actual_warehouse_id
|
||||
LEFT JOIN sys_user su ON mc.sale_id = su.user_id
|
||||
LEFT JOIN wms_raw_material rm ON mc.item_type = 'raw_material' AND mc.item_id = rm.raw_material_id
|
||||
LEFT JOIN wms_product p ON mc.item_type = 'product' AND mc.item_id = p.product_id
|
||||
LEFT JOIN (
|
||||
SELECT coil_id, COUNT(*) AS abnormal_count
|
||||
FROM wms_coil_abnormal
|
||||
WHERE del_flag = 0
|
||||
GROUP BY coil_id
|
||||
) ca ON mc.coil_id = ca.coil_id
|
||||
${ew.customSqlSegment}
|
||||
COALESCE(aw.actual_warehouse_id, 0) AS aw_id_key
|
||||
<include refid="baseFrom"/>
|
||||
LEFT JOIN wms_actual_warehouse awp ON aw.parent_id = awp.actual_warehouse_id
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<!-- orderByPlanDesc=true 专用:包含发货计划 join,支持按计划创建时间倒序排序 -->
|
||||
<select id="selectVoPagePlusPlanOrder" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
||||
SELECT <include refid="baseColumns"/>
|
||||
<include refid="baseFrom"/>
|
||||
LEFT JOIN wms_delivery_waybill_detail d ON d.coil_id = mc.coil_id AND d.del_flag = 0
|
||||
LEFT JOIN wms_delivery_waybill wb ON wb.waybill_id = d.waybill_id AND wb.del_flag = 0
|
||||
LEFT JOIN wms_delivery_plan pl ON pl.plan_id = wb.plan_id AND pl.del_flag = 0
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user