|
@@ -44,6 +44,77 @@
|
|
|
AND lo.material_code LIKE concat(concat("%",#{materialCode}),"%")
|
|
|
</if>
|
|
|
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ -- sap库存物料
|
|
|
+ SELECT
|
|
|
+ sap.factory_id AS factoryId,
|
|
|
+ 0 AS costCenterId,
|
|
|
+ sap.storage_location_id AS storageLocationId,
|
|
|
+ sap.material_code AS materialCode,
|
|
|
+ sap.material_name AS materialName,
|
|
|
+ sap.unit_price AS unitPrice,
|
|
|
+ sap.quantity AS totalInventoryQuantity,
|
|
|
+ sap.unit AS unit,
|
|
|
+ 'sap库存' AS materialSource
|
|
|
+ FROM
|
|
|
+ rq_iot_sap_stock sap
|
|
|
+ WHERE
|
|
|
+ 1=1
|
|
|
+ <if test="materialCodes != null and materialCodes.size > 0">
|
|
|
+ AND sap.material_code IN
|
|
|
+ <foreach collection="materialCodes" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="factoryIds != null and factoryIds.size > 0">
|
|
|
+ AND sap.factory_id IN
|
|
|
+ <foreach collection="factoryIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="stockLocationIds != null and stockLocationIds.size > 0">
|
|
|
+ AND sap.storage_location_id IN
|
|
|
+ <foreach collection="stockLocationIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="materialName!=null and materialName!=''">
|
|
|
+ AND sap.material_name LIKE concat(concat("%",#{materialName}),"%")
|
|
|
+ </if>
|
|
|
+ <if test="materialCode!=null and materialCode!=''">
|
|
|
+ AND sap.material_code LIKE concat(concat("%",#{materialCode}),"%")
|
|
|
+ </if>
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+ -- sap主数据
|
|
|
+ SELECT
|
|
|
+ 0 AS factoryId,
|
|
|
+ 0 AS costCenterId,
|
|
|
+ 0 AS storageLocationId,
|
|
|
+ m.`code` AS materialCode,
|
|
|
+ m.`name` AS materialName,
|
|
|
+ m.unit_price AS unitPrice,
|
|
|
+ 0 AS totalInventoryQuantity,
|
|
|
+ m.unit AS unit,
|
|
|
+ 'sap主数据' AS materialSource
|
|
|
+ FROM
|
|
|
+ rq_iot_material m
|
|
|
+ WHERE
|
|
|
+ 1=1
|
|
|
+ <if test="materialCodes != null and materialCodes.size > 0">
|
|
|
+ AND m.`code` IN
|
|
|
+ <foreach collection="materialCodes" index="index" item="key" open="(" separator="," close=")">
|
|
|
+ #{key}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="materialName!=null and materialName!=''">
|
|
|
+ AND m.`name` LIKE concat(concat("%",#{materialName}),"%")
|
|
|
+ </if>
|
|
|
+ <if test="materialCode!=null and materialCode!=''">
|
|
|
+ AND m.`code` LIKE concat(concat("%",#{materialCode}),"%")
|
|
|
+ </if>
|
|
|
+
|
|
|
UNION ALL
|
|
|
-- 本地库存物料
|
|
|
SELECT
|
|
@@ -86,7 +157,6 @@
|
|
|
</if>
|
|
|
|
|
|
UNION ALL
|
|
|
-
|
|
|
-- sap库存物料
|
|
|
SELECT
|
|
|
sap.factory_id AS factoryId,
|
|
@@ -103,7 +173,7 @@
|
|
|
WHERE
|
|
|
1=1
|
|
|
<if test="materialCodes != null and materialCodes.size > 0">
|
|
|
- AND sap.material_code IN
|
|
|
+ AND sap.material_code NOT IN
|
|
|
<foreach collection="materialCodes" index="index" item="key" open="(" separator="," close=")">
|
|
|
#{key}
|
|
|
</foreach>
|
|
@@ -128,46 +198,33 @@
|
|
|
</if>
|
|
|
|
|
|
UNION ALL
|
|
|
- -- sap库存物料
|
|
|
+ -- sap主数据
|
|
|
SELECT
|
|
|
- sap.factory_id AS factoryId,
|
|
|
+ 0 AS factoryId,
|
|
|
0 AS costCenterId,
|
|
|
- sap.storage_location_id AS storageLocationId,
|
|
|
- sap.material_code AS materialCode,
|
|
|
- sap.material_name AS materialName,
|
|
|
- sap.unit_price AS unitPrice,
|
|
|
- sap.quantity AS totalInventoryQuantity,
|
|
|
- sap.unit AS unit,
|
|
|
- 'sap库存' AS materialSource
|
|
|
+ 0 AS storageLocationId,
|
|
|
+ m.`code` AS materialCode,
|
|
|
+ m.`name` AS materialName,
|
|
|
+ m.unit_price AS unitPrice,
|
|
|
+ 0 AS totalInventoryQuantity,
|
|
|
+ m.unit AS unit,
|
|
|
+ 'sap主数据' AS materialSource
|
|
|
FROM
|
|
|
- rq_iot_sap_stock sap
|
|
|
+ rq_iot_material m
|
|
|
WHERE
|
|
|
1=1
|
|
|
<if test="materialCodes != null and materialCodes.size > 0">
|
|
|
- AND sap.material_code NOT IN
|
|
|
+ AND m.`code` NOT IN
|
|
|
<foreach collection="materialCodes" index="index" item="key" open="(" separator="," close=")">
|
|
|
#{key}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- <if test="factoryIds != null and factoryIds.size > 0">
|
|
|
- AND sap.factory_id IN
|
|
|
- <foreach collection="factoryIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
- #{key}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="stockLocationIds != null and stockLocationIds.size > 0">
|
|
|
- AND sap.storage_location_id IN
|
|
|
- <foreach collection="stockLocationIds" index="index" item="key" open="(" separator="," close=")">
|
|
|
- #{key}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
<if test="materialName!=null and materialName!=''">
|
|
|
- AND sap.material_name LIKE concat(concat("%",#{materialName}),"%")
|
|
|
+ AND m.`name` LIKE concat(concat("%",#{materialName}),"%")
|
|
|
</if>
|
|
|
<if test="materialCode!=null and materialCode!=''">
|
|
|
- AND sap.material_code LIKE concat(concat("%",#{materialCode}),"%")
|
|
|
+ AND m.`code` LIKE concat(concat("%",#{materialCode}),"%")
|
|
|
</if>
|
|
|
|
|
|
-
|
|
|
</select>
|
|
|
</mapper>
|