| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?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="cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorderbommaterial.IotMainWorkOrderBomMaterialMapper">
- <select id="selectMaterialsBySapOrg"
- resultType="cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbommaterial.vo.IotMainWorkOrderBomMaterialRespVO">
- -- 本地库存中与bom节点关联的物料
- SELECT
- lo.factory_id AS factoryId,
- lo.cost_center_id AS costCenterId,
- lo.storage_location_id AS storageLocationId,
- lo.material_code AS materialCode,
- lo.material_name AS materialName,
- lo.unit_price AS unitPrice,
- lo.quantity AS totalInventoryQuantity,
- lo.unit AS unit,
- '本地库存' AS materialSource
- FROM
- rq_iot_lock_stock lo
- WHERE
- 1=1
- <if test="materialCodes != null and materialCodes.size > 0">
- AND lo.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 lo.factory_id IN
- <foreach collection="factoryIds" index="index" item="key" open="(" separator="," close=")">
- #{key}
- </foreach>
- </if>
- <if test="costCenterIds != null and costCenterIds.size > 0">
- AND lo.cost_center_id IN
- <foreach collection="costCenterIds" index="index" item="key" open="(" separator="," close=")">
- #{key}
- </foreach>
- </if>
- <if test="materialName!=null and materialName!=''">
- AND lo.material_name LIKE concat(concat("%",#{materialName}),"%")
- </if>
- <if test="materialCode!=null and materialCode!=''">
- AND lo.material_code LIKE concat(concat("%",#{materialCode}),"%")
- </if>
- UNION ALL
- -- 本地库存物料
- SELECT
- lo.factory_id AS factoryId,
- lo.cost_center_id AS costCenterId,
- lo.storage_location_id AS storageLocationId,
- lo.material_code AS materialCode,
- lo.material_name AS materialName,
- lo.unit_price AS unitPrice,
- lo.quantity AS totalInventoryQuantity,
- lo.unit AS unit,
- '本地库存' AS materialSource
- FROM
- rq_iot_lock_stock lo
- WHERE
- 1=1
- <if test="materialCodes != null and materialCodes.size > 0">
- AND lo.material_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 lo.factory_id IN
- <foreach collection="factoryIds" index="index" item="key" open="(" separator="," close=")">
- #{key}
- </foreach>
- </if>
- <if test="costCenterIds != null and costCenterIds.size > 0">
- AND lo.cost_center_id IN
- <foreach collection="costCenterIds" index="index" item="key" open="(" separator="," close=")">
- #{key}
- </foreach>
- </if>
- <if test="materialName!=null and materialName!=''">
- AND lo.material_name LIKE concat(concat("%",#{materialName}),"%")
- </if>
- <if test="materialCode!=null and materialCode!=''">
- 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
- 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 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}),"%")
- </if>
- <if test="materialCode!=null and materialCode!=''">
- AND sap.material_code LIKE concat(concat("%",#{materialCode}),"%")
- </if>
- </select>
- </mapper>
|