- 在 WmsMaterialCoilVo 中新增 nextWarehouseName 字段 - 更新 WmsMaterialCoilMapper.xml 查询语句,关联下一库区表获取库区名称 - 为 nextWarehouseName 字段添加 Excel 导出注解配置 - 完善实体类注释文档
678 lines
30 KiB
XML
678 lines
30 KiB
XML
<?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.WmsMaterialCoilMapper">
|
|
|
|
<resultMap type="com.klp.domain.WmsMaterialCoil" id="WmsMaterialCoilResult">
|
|
<result property="coilId" column="coil_id"/>
|
|
<result property="parentCoilId" column="parent_coil_id"/>
|
|
<result property="enterCoilNo" column="enter_coil_no"/>
|
|
<result property="currentCoilNo" column="current_coil_no"/>
|
|
<result property="supplierCoilNo" column="supplier_coil_no"/>
|
|
<result property="dataType" column="data_type"/>
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
<result property="nextWarehouseId" column="next_warehouse_id"/>
|
|
<result property="qrcodeRecordId" column="qrcode_record_id"/>
|
|
<result property="team" column="team"/>
|
|
<result property="hasMergeSplit" column="has_merge_split"/>
|
|
<result property="parentCoilNos" column="parent_coil_nos"/>
|
|
<result property="itemType" column="item_type"/>
|
|
<result property="itemId" column="item_id"/>
|
|
<result property="grossWeight" column="gross_weight"/>
|
|
<result property="netWeight" column="net_weight"/>
|
|
<result property="length" column="length"/>
|
|
<result property="status" column="status"/>
|
|
<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>
|
|
|
|
<!-- 统计查询专用的ResultMap -->
|
|
<resultMap type="com.klp.domain.vo.WmsMaterialCoilVo" id="WmsMaterialCoilDistributionResult">
|
|
<result property="warehouseId" column="warehouse_id"/>
|
|
<result property="warehouseName" column="warehouse_name"/>
|
|
<result property="itemType" column="item_type"/>
|
|
<result property="coilCount" column="coil_count"/>
|
|
<result property="totalGrossWeight" column="total_gross_weight"/>
|
|
<result property="totalNetWeight" column="total_net_weight"/>
|
|
</resultMap>
|
|
|
|
<!-- 查询各个库区中钢卷的汇总分布情况(按仓库汇总) -->
|
|
<select id="getDistributionByWarehouse" resultType="java.util.Map">
|
|
SELECT
|
|
w.warehouse_id,
|
|
w.warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight
|
|
FROM wms_warehouse w
|
|
LEFT JOIN wms_material_coil mc ON w.warehouse_id = mc.warehouse_id
|
|
AND mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
and (mc.material_type='成品' or mc.material_type='原料')
|
|
and mc.status!=1
|
|
WHERE w.del_flag = '0'
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
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.coating_type,
|
|
mc.temper_grade,
|
|
mc.exclusive_status,
|
|
su.nick_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
|
|
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 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}
|
|
</select>
|
|
<!-- 查询不同类型的钢卷在不同库区的分布情况 -->
|
|
<select id="getDistributionByItemType" resultType="java.util.Map">
|
|
SELECT
|
|
mc.item_type,
|
|
mc.item_id,
|
|
w.warehouse_id,
|
|
w.warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight,
|
|
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,
|
|
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.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.manufacturer
|
|
WHEN mc.item_type = 'product' THEN p.manufacturer
|
|
ELSE NULL
|
|
END as manufacturer
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_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
|
|
WHERE mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
AND (w.del_flag = '0' OR w.del_flag IS NULL)
|
|
and (mc.material_type='成品' or mc.material_type='原料')
|
|
and mc.status!=1
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY mc.item_type, mc.item_id, w.warehouse_id, w.warehouse_name, itemName, itemCode, specification, material,
|
|
surfaceTreatmentDesc, zincLayer, manufacturer
|
|
ORDER BY mc.item_type, mc.item_id, w.warehouse_id
|
|
</select>
|
|
<select id="selectVoListWithDynamicJoin" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
|
SELECT mc.*,
|
|
w.warehouse_name AS warehouseName,
|
|
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
|
|
FROM wms_material_coil mc
|
|
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 wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_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}
|
|
</select>
|
|
<select id="getDistributionByActualWarehouse" resultType="java.util.Map">
|
|
SELECT
|
|
w.actual_warehouse_id,
|
|
w.actual_warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight
|
|
FROM wms_actual_warehouse w
|
|
LEFT JOIN wms_material_coil mc ON w.actual_warehouse_id = mc.actual_warehouse_id
|
|
AND mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
and (mc.material_type='成品' or mc.material_type='原料')
|
|
and mc.status!=1
|
|
WHERE w.del_flag = '0'
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY w.actual_warehouse_id, w.actual_warehouse_name
|
|
ORDER BY w.actual_warehouse_id
|
|
</select>
|
|
<select id="getDistributionByActualItemType" resultType="java.util.Map">
|
|
SELECT
|
|
mc.item_type,
|
|
mc.item_id,
|
|
w.actual_warehouse_id,
|
|
w.actual_warehouse_name,
|
|
COUNT(mc.coil_id) as coil_count,
|
|
COALESCE(SUM(mc.gross_weight), 0) as total_gross_weight,
|
|
COALESCE(SUM(mc.net_weight), 0) as total_net_weight,
|
|
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,
|
|
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.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.manufacturer
|
|
WHEN mc.item_type = 'product' THEN p.manufacturer
|
|
ELSE NULL
|
|
END as manufacturer
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_actual_warehouse w ON mc.actual_warehouse_id = w.actual_warehouse_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
|
|
WHERE mc.data_type = 1
|
|
AND mc.del_flag = '0'
|
|
AND (w.del_flag = '0' OR w.del_flag IS NULL)
|
|
and (mc.material_type='成品' or mc.material_type='原料')
|
|
and mc.status!=1
|
|
<if test="itemType != null and itemType != ''">
|
|
AND mc.item_type = #{itemType}
|
|
</if>
|
|
<if test="itemId != null">
|
|
AND mc.item_id = #{itemId}
|
|
</if>
|
|
GROUP BY mc.item_type, mc.item_id, w.actual_warehouse_id, w.actual_warehouse_name, itemName, itemCode, specification,
|
|
material,surfaceTreatmentDesc, zincLayer, manufacturer
|
|
ORDER BY mc.item_type, mc.item_id, w.actual_warehouse_id
|
|
</select>
|
|
|
|
<!-- 导出查询:包含所有需要的字段 -->
|
|
<select id="selectExportList" resultType="com.klp.domain.vo.WmsMaterialCoilExportVo">
|
|
SELECT
|
|
-- 类型(中文显示)
|
|
CASE
|
|
WHEN mc.item_type = 'product' THEN '成品'
|
|
WHEN mc.item_type = 'raw_material' THEN '原料'
|
|
ELSE mc.item_type
|
|
END AS itemTypeDesc,
|
|
-- 物品ID
|
|
mc.item_id AS itemId,
|
|
-- 数据类型
|
|
mc.data_type AS dataType,
|
|
-- 逻辑库区
|
|
w.warehouse_name AS warehouseName,
|
|
-- 实际库区
|
|
aw.actual_warehouse_name AS actualWarehouseName,
|
|
-- 入场卷号
|
|
mc.enter_coil_no AS enterCoilNo,
|
|
-- 厂家卷号
|
|
mc.supplier_coil_no AS supplierCoilNo,
|
|
-- 成品卷号
|
|
mc.current_coil_no AS currentCoilNo,
|
|
-- 日期
|
|
mc.create_time AS createTime,
|
|
-- 发货时间
|
|
mc.export_time AS exportTime,
|
|
-- 新增:更新时间(用于发货时间为空时兜底)
|
|
mc.update_time AS updateTime,
|
|
-- 重量
|
|
mc.net_weight AS netWeight,
|
|
-- 长度
|
|
mc.length AS length,
|
|
-- 镀层种类
|
|
mc.coating_type AS coatingType,
|
|
-- 调制度
|
|
mc.temper_grade AS temperGrade,
|
|
-- 用途(暂无数据源)
|
|
NULL AS purpose,
|
|
-- 切边要求
|
|
mc.trimming_requirement AS trimmingRequirement,
|
|
-- 包装种类
|
|
mc.packaging_requirement AS packagingRequirement,
|
|
-- 产品状态(直接展示原始值)
|
|
mc.quality_status AS qualityStatus,
|
|
-- 打包状态(直接展示原始值)
|
|
mc.packing_status AS packingStatus,
|
|
-- 库存状态(中文显示)
|
|
CASE
|
|
WHEN mc.status = 0 THEN '在库'
|
|
WHEN mc.status = 1 THEN '已发货'
|
|
ELSE CAST(mc.status AS CHAR)
|
|
END AS statusDesc,
|
|
-- 备注
|
|
mc.remark AS remark,
|
|
-- 名称(根据类型从不同表获取)
|
|
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.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
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_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
|
|
${ew.customSqlSegment}
|
|
</select>
|
|
|
|
<!-- 发货报表导出:按 coilIds 联查钢卷 + 发货单明细 + 发货单主表 + 发货计划 -->
|
|
<select id="selectDeliveryExportListByCoilIds" resultType="com.klp.domain.vo.WmsMaterialCoilDeliveryExportVo">
|
|
SELECT
|
|
-- 钢卷ID
|
|
mc.coil_id AS coilId,
|
|
-- 发货人
|
|
mc.export_by AS exportBy,
|
|
-- 类型(中文显示)
|
|
CASE
|
|
WHEN mc.item_type = 'product' THEN '成品'
|
|
WHEN mc.item_type = 'raw_material' THEN '原料'
|
|
ELSE mc.item_type
|
|
END AS itemTypeDesc,
|
|
mc.item_id AS itemId,
|
|
mc.data_type AS dataType,
|
|
w.warehouse_name AS warehouseName,
|
|
aw.actual_warehouse_name AS actualWarehouseName,
|
|
mc.enter_coil_no AS enterCoilNo,
|
|
mc.supplier_coil_no AS supplierCoilNo,
|
|
mc.current_coil_no AS currentCoilNo,
|
|
mc.create_time AS createTime,
|
|
mc.export_time AS exportTime,
|
|
mc.update_time AS updateTime,
|
|
mc.net_weight AS netWeight,
|
|
mc.length AS length,
|
|
mc.coating_type AS coatingType,
|
|
mc.temper_grade AS temperGrade,
|
|
NULL AS purpose,
|
|
mc.trimming_requirement AS trimmingRequirement,
|
|
mc.packaging_requirement AS packagingRequirement,
|
|
mc.quality_status AS qualityStatus,
|
|
mc.packing_status AS packingStatus,
|
|
CASE
|
|
WHEN mc.status = 0 THEN '在库'
|
|
WHEN mc.status = 1 THEN '已发货'
|
|
ELSE CAST(mc.status AS CHAR)
|
|
END AS statusDesc,
|
|
mc.remark AS remark,
|
|
CASE
|
|
WHEN mc.item_type = 'raw_material' THEN rm.raw_material_name
|
|
WHEN mc.item_type = 'product' THEN pdt.product_name
|
|
ELSE NULL
|
|
END AS itemName,
|
|
CASE
|
|
WHEN mc.item_type = 'raw_material' THEN rm.specification
|
|
WHEN mc.item_type = 'product' THEN pdt.specification
|
|
ELSE NULL
|
|
END AS specification,
|
|
CASE
|
|
WHEN mc.item_type = 'raw_material' THEN rm.material
|
|
WHEN mc.item_type = 'product' THEN pdt.material
|
|
ELSE NULL
|
|
END AS material,
|
|
CASE
|
|
WHEN mc.item_type = 'raw_material' THEN rm.manufacturer
|
|
WHEN mc.item_type = 'product' THEN pdt.manufacturer
|
|
ELSE NULL
|
|
END AS manufacturer,
|
|
CASE
|
|
WHEN mc.item_type = 'raw_material' THEN rm.surface_treatment_desc
|
|
WHEN mc.item_type = 'product' THEN pdt.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 pdt.zinc_layer
|
|
ELSE NULL
|
|
END AS zincLayer,
|
|
|
|
-- 发货计划
|
|
pl.plan_id AS planId,
|
|
pl.plan_name AS planName,
|
|
pl.plan_date AS planDate,
|
|
|
|
-- 发货单主表
|
|
wb.waybill_id AS waybillId,
|
|
wb.waybill_no AS waybillNo,
|
|
wb.waybill_name AS waybillName,
|
|
wb.license_plate AS licensePlate,
|
|
wb.consignee_unit AS consigneeUnit,
|
|
wb.sender_unit AS senderUnit,
|
|
wb.delivery_time AS deliveryTime,
|
|
wb.weighbridge AS weighbridge,
|
|
wb.sales_person AS salesPerson,
|
|
wb.principal AS principal,
|
|
wb.principal_phone AS principalPhone,
|
|
wb.status AS waybillStatus,
|
|
wb.remark AS waybillRemark,
|
|
|
|
-- 发货单明细
|
|
dtl.detail_id AS detailId,
|
|
dtl.product_name AS detailProductName,
|
|
dtl.edge_type AS detailEdgeType,
|
|
dtl.packaging AS detailPackaging,
|
|
dtl.settlement_type AS detailSettlementType,
|
|
dtl.raw_material_factory AS detailRawMaterialFactory,
|
|
dtl.coil_no AS detailCoilNo,
|
|
dtl.specification AS detailSpecification,
|
|
dtl.material AS detailMaterial,
|
|
dtl.quantity AS detailQuantity,
|
|
dtl.weight AS detailWeight,
|
|
dtl.unit_price AS detailUnitPrice,
|
|
dtl.remark AS detailRemark
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_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 pdt ON mc.item_type = 'product' AND mc.item_id = pdt.product_id
|
|
LEFT JOIN wms_delivery_waybill_detail dtl ON dtl.coil_id = mc.coil_id AND dtl.del_flag = 0
|
|
LEFT JOIN wms_delivery_waybill wb ON wb.waybill_id = dtl.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
|
|
WHERE mc.del_flag = 0
|
|
AND mc.coil_id IN
|
|
<foreach collection="coilIds" item="id" open="(" close=")" separator=",">
|
|
#{id}
|
|
</foreach>
|
|
ORDER BY mc.create_time DESC
|
|
</select>
|
|
<!-- 查询重复入场卷号的钢卷信息 -->
|
|
<select id="selectDuplicateEnterCoilNoList" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
|
SELECT mc.*,
|
|
w.warehouse_name AS warehouseName,
|
|
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
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_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
|
|
WHERE mc.data_type = 1
|
|
AND mc.del_flag = 0
|
|
AND mc.enter_coil_no IN (
|
|
SELECT enter_coil_no
|
|
FROM wms_material_coil
|
|
WHERE data_type = 1
|
|
AND del_flag = 0
|
|
AND enter_coil_no IS NOT NULL
|
|
AND enter_coil_no != ''
|
|
GROUP BY enter_coil_no
|
|
HAVING COUNT(*) > 1
|
|
)
|
|
ORDER BY mc.enter_coil_no, mc.create_time
|
|
</select>
|
|
|
|
<!-- 查询重复当前卷号的钢卷信息 -->
|
|
<select id="selectDuplicateCurrentCoilNoList" resultType="com.klp.domain.vo.WmsMaterialCoilVo">
|
|
SELECT mc.*,
|
|
w.warehouse_name AS warehouseName,
|
|
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
|
|
FROM wms_material_coil mc
|
|
LEFT JOIN wms_warehouse w ON mc.warehouse_id = w.warehouse_id
|
|
LEFT JOIN wms_actual_warehouse aw ON mc.actual_warehouse_id = aw.actual_warehouse_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
|
|
WHERE mc.data_type = 1
|
|
AND mc.del_flag = 0
|
|
AND mc.current_coil_no IN (
|
|
SELECT current_coil_no
|
|
FROM wms_material_coil
|
|
WHERE data_type = 1
|
|
AND del_flag = 0
|
|
AND current_coil_no IS NOT NULL
|
|
AND current_coil_no != ''
|
|
GROUP BY current_coil_no
|
|
HAVING COUNT(*) > 1
|
|
)
|
|
ORDER BY mc.current_coil_no, mc.create_time
|
|
</select>
|
|
|
|
<!-- 更新钢卷发货撤回:将发货时间置空,状态改为未发货 -->
|
|
<update id="updateForWithdrawExport">
|
|
UPDATE wms_material_coil
|
|
SET export_time = NULL,
|
|
status = #{status}
|
|
WHERE coil_id = #{coilId}
|
|
</update>
|
|
|
|
</mapper>
|
|
|