sql报错修改;

This commit is contained in:
王奎兴
2026-04-22 15:16:59 +08:00
parent 88d8666d3b
commit f11c7aad9a
@@ -66,6 +66,70 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="lotNumber" column="lot_number" />
</resultMap>
<sql id="JoinMaterialBaseInfoPo">
<!-- 注意:物料基础信息表中的货主字段统一使用别名,避免与主表中的 shipper_id/shipper_code/shipper_name 冲突 -->
,b.shipper_id AS base_shipper_id,
b.shipper_code AS base_shipper_code,
b.shipper_name AS base_shipper_name,
b.material_code,
b.material_name,
b.bar_code,
b.material_classify_code,
b.material_classify_name,
b.material_type,
b.material_type_name,
b.common,
b.pack_id,
b.pack_code,
b.pack_name
</sql>
<sql id="JoinMaterialBaseInfoPoWhere">
<!-- 该片段总是在物料基础信息表使用别名 b 时被 include,例如:
FROM ... LEFT JOIN material_base_info b ON ...
因此这里所有列名都加上 b. 前缀以避免和主表列名歧义 -->
<if test="shipperId != null ">
and b.shipper_id = #{shipperId}
</if>
<if test="shipperCode != null and shipperCode != ''">
and b.shipper_code like concat('%', #{shipperCode}, '%')
</if>
<if test="shipperName != null and shipperName != ''">
and b.shipper_name like concat('%', #{shipperName}, '%')
</if>
<if test="materialCode != null and materialCode != ''">
and b.material_code = #{materialCode}
</if>
<if test="materialName != null and materialName != ''">
and b.material_name like concat('%', #{materialName}, '%')
</if>
<if test="barCode != null and barCode != ''">
and b.bar_code = #{barCode}
</if>
<if test="materialClassifyCode != null and materialClassifyCode.size() > 0">
<foreach collection="materialClassifyCode" item="code" open="and (" separator="or" close=")">
FIND_IN_SET(#{code}, b.material_classify_code) > 0
</foreach>
</if>
<if test="materialClassifyName != null and materialClassifyName.size() > 0">
<foreach collection="materialClassifyName" item="name" open="and (" separator="or" close=")">
b.material_classify_name like concat('%', #{name}, '%')
</foreach>
</if>
<if test="materialType != null and materialType != ''">
and b.material_type = #{materialType}
</if>
<if test="materialTypeName != null and materialTypeName != ''">
and b.material_type_name like concat('%', #{materialTypeName}, '%')
</if>
<if test="shipperInfo != null and shipperInfo != ''">
and (b.shipper_code like concat('%', #{shipperInfo}, '%') or b.shipper_name like concat('%', #{shipperInfo}, '%'))
</if>
<if test="materialInfo != null and materialInfo != ''">
and (b.material_code = #{materialInfo} or b.material_name like concat('%', #{materialInfo}, '%') or b.bar_code = #{materialInfo})
</if>
</sql>
<sql id="selectMaterialInventoryPo">
a.material_inventory_id, a.organization_id, a.organization_name, a.top_organization_id,
@@ -208,12 +272,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryList" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
<include refid="JoinMaterialBaseInfoPo"/>
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
group by a.MATERIAL_INVENTORY_ID order by a.update_time desc
</select>
@@ -221,12 +285,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryListByWlKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
<include refid="JoinMaterialBaseInfoPo"/>
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID,a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
</select>
@@ -234,12 +298,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryListByKw" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
<include refid="JoinMaterialBaseInfoPo"/>
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.WAREHOUSE_ID,a.STORAGE_SECTION_ID,a.STORAGE_LOCATION_ID
</select>
@@ -247,12 +311,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryListByWl" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
<include refid="JoinMaterialBaseInfoPo"/>
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.MATERIAL_BASE_INFO_ID
</select>
@@ -260,12 +324,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="queryListByHz" parameterType="com.mhd.oms.domain.reservationMaterialInventory.repository.todo.ReservationMaterialInventoryDO" resultMap="MaterialInventoryResult">
select
<include refid="selectMaterialInventoryPo"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPo"/>
<include refid="JoinMaterialBaseInfoPo"/>
from reservation_material_inventory a
left join NGWL_TEST_WMS.material_base_info b on a.material_base_info_id = b.material_base_info_id
<where>
<include refid="selectMaterialInventoryPo1"/>
<include refid="com.mhd.wms.domain.materialBaseInfo.repository.mapper.MaterialBaseInfoMapper.JoinMaterialBaseInfoPoWhere"/>
<include refid="JoinMaterialBaseInfoPoWhere"/>
</where>
GROUP BY a.SHIPPER_ID
</select>