修正SQL语法错误

This commit is contained in:
刘名喜 2024-12-18 10:29:01 +08:00
parent f14fd39c5c
commit c7edc4ea37

View File

@ -1,60 +1,85 @@
<?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">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ktg.mes.wm.mapper.WmStorageLocationMapper">
<resultMap type="WmStorageLocation" id="WmStorageLocationResult">
<result property="locationId" column="location_id" />
<result property="locationCode" column="location_code" />
<result property="locationName" column="location_name" />
<result property="warehouseId" column="warehouse_id" />
<result property="area" column="area" />
<result property="areaFlag" column="area_flag" />
<result property="frozenFlag" column="frozen_flag" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="locationId" column="location_id"/>
<result property="locationCode" column="location_code"/>
<result property="locationName" column="location_name"/>
<result property="warehouseId" column="warehouse_id"/>
<result property="area" column="area"/>
<result property="areaFlag" column="area_flag"/>
<result property="frozenFlag" column="frozen_flag"/>
<result property="remark" column="remark"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="attr4" column="attr4"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<resultMap type="WmStorageLocationVo" id="WmStorageLocationVoResult">
<result property="locationId" column="location_id" />
<result property="locationCode" column="location_code" />
<result property="locationName" column="location_name" />
<result property="warehouseId" column="warehouse_id" />
<result property="area" column="area" />
<result property="areaFlag" column="area_flag" />
<result property="frozenFlag" column="frozen_flag" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="warehouseName" column="warehouse_name" />
<result property="locationId" column="location_id"/>
<result property="locationCode" column="location_code"/>
<result property="locationName" column="location_name"/>
<result property="warehouseId" column="warehouse_id"/>
<result property="area" column="area"/>
<result property="areaFlag" column="area_flag"/>
<result property="frozenFlag" column="frozen_flag"/>
<result property="remark" column="remark"/>
<result property="attr1" column="attr1"/>
<result property="attr2" column="attr2"/>
<result property="attr3" column="attr3"/>
<result property="attr4" column="attr4"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="warehouseName" column="warehouse_name"/>
</resultMap>
<sql id="selectWmStorageLocationVo">
select location_id, location_code, location_name, warehouse_id, area, area_flag, frozen_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_storage_location
select location_id,
location_code,
location_name,
warehouse_id,
area,
area_flag,
frozen_flag,
remark,
attr1,
attr2,
attr3,
attr4,
create_by,
create_time,
update_by,
update_time
from wm_storage_location
</sql>
<select id="selectWmStorageLocationList" parameterType="WmStorageLocation" resultMap="WmStorageLocationResult">
<include refid="selectWmStorageLocationVo"/>
<where>
<if test="locationCode != null and locationCode != ''"> and location_code like concat('%',#{locationCode}, '%') </if>
<if test="locationName != null and locationName != ''"> and location_name like concat('%', #{locationName}, '%')</if>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="area != null "> and area = #{area}</if>
<if test="areaFlag != null and areaFlag != ''"> and area_flag = #{areaFlag}</if>
<where>
<if test="locationCode != null and locationCode != ''">
and location_code like concat('%', #{locationCode}, '%')
</if>
<if test="locationName != null and locationName != ''">
and location_name like concat('%', #{locationName}, '%')
</if>
<if test="warehouseId != null">
and warehouse_id = #{warehouseId}
</if>
<if test="area != null">
and area = #{area}
</if>
<if test="areaFlag != null and areaFlag != ''">
and area_flag = #{areaFlag}
</if>
and IS_DELETE = 0
</where>
</select>
@ -62,114 +87,228 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWmStorageLocationListVo" parameterType="WmStorageLocation" resultMap="WmStorageLocationVoResult">
SELECT l.*, w.warehouse_name
FROM wm_storage_location l
JOIN wm_warehouse w ON w.warehouse_id = l.warehouse_id
JOIN wm_warehouse w ON w.warehouse_id = l.warehouse_id
<where>
<if test="locationCode != null and locationCode != ''"> and l.location_code like concat('%',#{locationCode}, '%') </if>
<if test="locationName != null and locationName != ''"> and l.location_name like concat('%', #{locationName}, '%')</if>
<if test="warehouseId != null "> and w.warehouse_id = #{warehouseId}</if>
<if test="area != null "> and l.area = #{area}</if>
<if test="areaFlag != null and areaFlag != ''"> and l.area_flag = #{areaFlag}</if>
<if test="locationCode != null and locationCode != ''">
and l.location_code like concat('%', #{locationCode}, '%')
</if>
<if test="locationName != null and locationName != ''">
and l.location_name like concat('%', #{locationName}, '%')
</if>
<if test="warehouseId != null">
and w.warehouse_id = #{warehouseId}
</if>
<if test="area != null">
and l.area = #{area}
</if>
<if test="areaFlag != null and areaFlag != ''">
and l.area_flag = #{areaFlag}
</if>
and l.IS_DELETE = 0
</where>
</select>
<select id="selectWmStorageLocationByLocationId" parameterType="Long" resultMap="WmStorageLocationResult">
<include refid="selectWmStorageLocationVo"/>
where location_id = #{locationId} and IS_DELETE = 0
where location_id = #{locationId}
and IS_DELETE = 0
</select>
<select id="selectWmStorageLocationByVoLocationId" parameterType="Long" resultMap="WmStorageLocationVoResult">
select l.* ,w.warehouse_name from wm_storage_location l
join wm_warehouse w on w.warehouse_id = l.warehouse_id
where location_id = #{locationId} and l.IS_DELETE = 0
select l.*, w.warehouse_name
from wm_storage_location l
join wm_warehouse w on w.warehouse_id = l.warehouse_id
where location_id = #{locationId}
and l.IS_DELETE = 0
</select>
<select id="selectWmStorageLocationByLocationCode" parameterType="String" resultMap="WmStorageLocationResult">
<include refid="selectWmStorageLocationVo"/>
where location_code = #{locationCode} limit 1 and IS_DELETE = 0
where location_code = #{locationCode}
and IS_DELETE = 0 limit 1
</select>
<select id="checkLocationCodeUnique" parameterType="WmStorageLocation" resultMap="WmStorageLocationResult">
<include refid="selectWmStorageLocationVo"/>
where location_code = #{locationCode} and IS_DELETE = 0 and warehouse_id = #{warehouseId} limit 1
where location_code = #{locationCode}
and IS_DELETE = 0
and warehouse_id = #{warehouseId} limit 1
</select>
<select id="checkLocationNameUnique" parameterType="WmStorageLocation" resultMap="WmStorageLocationResult">
<include refid="selectWmStorageLocationVo"/>
where location_name = #{locationName} and IS_DELETE = 0 and warehouse_id = #{warehouseId} limit 1
where location_name = #{locationName}
and IS_DELETE = 0
and warehouse_id = #{warehouseId} limit 1
</select>
<insert id="insertWmStorageLocation" parameterType="WmStorageLocation" useGeneratedKeys="true" keyProperty="locationId">
<insert id="insertWmStorageLocation" parameterType="WmStorageLocation" useGeneratedKeys="true"
keyProperty="locationId">
insert into wm_storage_location
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="locationCode != null and locationCode != ''">location_code,</if>
<if test="locationName != null and locationName != ''">location_name,</if>
<if test="warehouseId != null">warehouse_id,</if>
<if test="area != null">area,</if>
<if test="areaFlag != null">area_flag,</if>
<if test="frozenFlag != null">frozen_flag,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<if test="locationCode != null and locationCode != ''">
location_code,
</if>
<if test="locationName != null and locationName != ''">
location_name,
</if>
<if test="warehouseId != null">
warehouse_id,
</if>
<if test="area != null">
area,
</if>
<if test="areaFlag != null">
area_flag,
</if>
<if test="frozenFlag != null">
frozen_flag,
</if>
<if test="remark != null">
remark,
</if>
<if test="attr1 != null">
attr1,
</if>
<if test="attr2 != null">
attr2,
</if>
<if test="attr3 != null">
attr3,
</if>
<if test="attr4 != null">
attr4,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="locationCode != null and locationCode != ''">#{locationCode},</if>
<if test="locationName != null and locationName != ''">#{locationName},</if>
<if test="warehouseId != null">#{warehouseId},</if>
<if test="area != null">#{area},</if>
<if test="areaFlag != null">#{areaFlag},</if>
<if test="frozenFlag != null">#{frozenFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
<if test="locationCode != null and locationCode != ''">
#{locationCode},
</if>
<if test="locationName != null and locationName != ''">
#{locationName},
</if>
<if test="warehouseId != null">
#{warehouseId},
</if>
<if test="area != null">
#{area},
</if>
<if test="areaFlag != null">
#{areaFlag},
</if>
<if test="frozenFlag != null">
#{frozenFlag},
</if>
<if test="remark != null">
#{remark},
</if>
<if test="attr1 != null">
#{attr1},
</if>
<if test="attr2 != null">
#{attr2},
</if>
<if test="attr3 != null">
#{attr3},
</if>
<if test="attr4 != null">
#{attr4},
</if>
<if test="createBy != null">
#{createBy},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateBy != null">
#{updateBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert>
<update id="updateWmStorageLocation" parameterType="WmStorageLocation">
update wm_storage_location
<trim prefix="SET" suffixOverrides=",">
<if test="locationCode != null and locationCode != ''">location_code = #{locationCode},</if>
<if test="locationName != null and locationName != ''">location_name = #{locationName},</if>
<if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
<if test="area != null">area = #{area},</if>
<if test="areaFlag != null">area_flag = #{areaFlag},</if>
<if test="frozenFlag != null">frozen_flag = #{frozenFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="locationCode != null and locationCode != ''">
location_code = #{locationCode},
</if>
<if test="locationName != null and locationName != ''">
location_name = #{locationName},
</if>
<if test="warehouseId != null">
warehouse_id = #{warehouseId},
</if>
<if test="area != null">
area = #{area},
</if>
<if test="areaFlag != null">
area_flag = #{areaFlag},
</if>
<if test="frozenFlag != null">
frozen_flag = #{frozenFlag},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="attr1 != null">
attr1 = #{attr1},
</if>
<if test="attr2 != null">
attr2 = #{attr2},
</if>
<if test="attr3 != null">
attr3 = #{attr3},
</if>
<if test="attr4 != null">
attr4 = #{attr4},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</trim>
where location_id = #{locationId}
</update>
<update id="deleteWmStorageLocationByLocationId" parameterType="Long">
update wm_storage_location set IS_DELETE = 1 where location_id = #{locationId}
update wm_storage_location
set IS_DELETE = 1
where location_id = #{locationId}
</update>
<update id="deleteWmStorageLocationByLocationIds" parameterType="String">
update wm_storage_location set IS_DELETE = 1 where location_id in
update wm_storage_location
set IS_DELETE = 1 where location_id in
<foreach item="locationId" collection="array" open="(" separator="," close=")">
#{locationId}
</foreach>
</update>
<update id="deleteByWarehouseId" parameterType="Long">
update wm_storage_location set IS_DELETE = 1 where warehouse_id = #{warehouseId}
update wm_storage_location
set IS_DELETE = 1
where warehouse_id = #{warehouseId}
</update>
</mapper>