- 将WmsMaterialCoilMapper.xml中JOIN语句的全角空格替换为半角空格 - 修复因全角空格导致的SQL语法潜在问题 - 确保SQL语句格式统一和可读性
429 lines
19 KiB
XML
429 lines
19 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="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="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.export_time,
|
|
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,
|
|
w.warehouse_name AS warehouseName,
|
|
su.nick_name AS saleName,
|
|
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_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,
|
|
-- 逻辑库区
|
|
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.gross_weight AS grossWeight,
|
|
-- 用途(暂无数据源)
|
|
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>
|
|
|
|
|
|
</mapper>
|
|
|