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