2025-01-15 10:28:03 +08:00
<?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= "com.ruoyi.app.mapper.AppLocationMapper" >
<resultMap type= "AppLocation" id= "AppLocationResult" >
2025-01-17 10:56:58 +08:00
<result property= "locationId" column= "location_id" />
<result property= "locationType" column= "location_type" />
<result property= "locationStatus" column= "location_status" />
<result property= "outerId" column= "outer_id" />
<result property= "areaId" column= "area_id" />
<result property= "tunnelId" column= "tunnel_id" />
<result property= "equipmentId" column= "equipment_id" />
<result property= "wRow" column= "w_row" />
<result property= "wCol" column= "w_col" />
<result property= "wLayer" column= "w_layer" />
<result property= "wDepth" column= "w_depth" />
<result property= "isLock" column= "is_lock" />
<result property= "vehicleId" column= "vehicle_id" />
<result property= "remark" column= "remark" />
<result property= "isWorking" column= "is_working" />
2025-03-05 15:25:21 +08:00
<result property= "isEnable" column= "is_enable" />
2025-01-15 10:28:03 +08:00
</resultMap>
<sql id= "selectAppLocationVo" >
2025-01-17 10:56:58 +08:00
select location_id,
location_type,
location_status,
outer_id,
area_id,
tunnel_id,
equipment_id,
w_row,
w_col,
w_layer,
w_depth,
is_lock,
vehicle_id,
remark,
2025-03-05 15:25:21 +08:00
is_working,
is_enable
2025-01-17 10:56:58 +08:00
from app_location
2025-01-15 10:28:03 +08:00
</sql>
<select id= "selectAppLocationList" parameterType= "AppLocation" resultMap= "AppLocationResult" >
<include refid= "selectAppLocationVo" />
<where >
2025-01-17 10:56:58 +08:00
<if test= "locationType != null " > and location_type = #{locationType}</if>
<if test= "locationStatus != null " > and location_status = #{locationStatus}</if>
<if test= "outerId != null and outerId != ''" > and outer_id = #{outerId}</if>
<if test= "areaId != null " > and area_id = #{areaId}</if>
<if test= "tunnelId != null " > and tunnel_id = #{tunnelId}</if>
<if test= "equipmentId != null " > and equipment_id = #{equipmentId}</if>
<if test= "wRow != null " > and w_row = #{wRow}</if>
<if test= "wCol != null " > and w_col = #{wCol}</if>
<if test= "wLayer != null " > and w_layer = #{wLayer}</if>
<if test= "wDepth != null " > and w_depth = #{wDepth}</if>
<if test= "isLock != null " > and is_lock = #{isLock}</if>
<if test= "vehicleId != null and vehicleId != ''" > and vehicle_id = #{vehicleId}</if>
<if test= "isWorking != null " > and is_working = #{isWorking}</if>
2025-03-05 15:25:21 +08:00
<if test= "isEnable != null " > and is_enable = #{isEnable}</if>
2025-01-15 10:28:03 +08:00
</where>
</select>
<select id= "selectAppLocationByLocationId" parameterType= "String" resultMap= "AppLocationResult" >
<include refid= "selectAppLocationVo" />
where location_id = #{locationId}
</select>
2025-03-06 02:59:02 +08:00
<select id= "selectFreeLoc" resultMap= "AppLocationResult" >
<include refid= "selectAppLocationVo" />
where location_status = 0 and is_working = 0 and is_enable = 0
and location_id NOT IN ( SELECT DISTINCT ( t.location_id ) FROM app_stock t UNION SELECT DISTINCT ( p.location_id ) FROM app_task p where p.location_id is not null)
ORDER BY
w_depth DESC,
w_col asc ,
w_layer ASC
</select>
2025-02-23 20:33:09 +08:00
<select id= "countAvailableStock" resultType= "java.util.Map" >
SELECT
(SELECT COUNT(*) FROM app_location) AS total_count,
(SELECT COUNT(*) FROM app_location WHERE location_status = 0) AS available_count
</select>
2025-01-15 10:28:03 +08:00
<insert id= "insertAppLocation" parameterType= "AppLocation" >
insert into app_location
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "locationId != null" > location_id,</if>
<if test= "locationType != null" > location_type,</if>
<if test= "locationStatus != null" > location_status,</if>
<if test= "outerId != null" > outer_id,</if>
<if test= "areaId != null" > area_id,</if>
<if test= "tunnelId != null" > tunnel_id,</if>
<if test= "equipmentId != null" > equipment_id,</if>
<if test= "wRow != null" > w_row,</if>
<if test= "wCol != null" > w_col,</if>
<if test= "wLayer != null" > w_layer,</if>
<if test= "wDepth != null" > w_depth,</if>
<if test= "isLock != null" > is_lock,</if>
<if test= "vehicleId != null" > vehicle_id,</if>
<if test= "remark != null" > remark,</if>
2025-01-17 10:56:58 +08:00
<if test= "isWorking != null" > is_working,</if>
2025-03-05 15:25:21 +08:00
<if test= "isEnable != null" > is_enable,</if>
2025-01-15 10:28:03 +08:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "locationId != null" > #{locationId},</if>
<if test= "locationType != null" > #{locationType},</if>
<if test= "locationStatus != null" > #{locationStatus},</if>
<if test= "outerId != null" > #{outerId},</if>
<if test= "areaId != null" > #{areaId},</if>
<if test= "tunnelId != null" > #{tunnelId},</if>
<if test= "equipmentId != null" > #{equipmentId},</if>
<if test= "wRow != null" > #{wRow},</if>
<if test= "wCol != null" > #{wCol},</if>
<if test= "wLayer != null" > #{wLayer},</if>
<if test= "wDepth != null" > #{wDepth},</if>
<if test= "isLock != null" > #{isLock},</if>
<if test= "vehicleId != null" > #{vehicleId},</if>
<if test= "remark != null" > #{remark},</if>
2025-01-17 10:56:58 +08:00
<if test= "isWorking != null" > #{isWorking},</if>
2025-03-05 15:25:21 +08:00
<if test= "isEnable != null" > #{isEnable},</if>
2025-01-15 10:28:03 +08:00
</trim>
</insert>
2025-01-17 10:56:58 +08:00
<insert id= "insertAppLocationBatch" parameterType= "java.util.List" >
2025-02-23 08:04:40 +08:00
<foreach collection= "list" item= "location" separator= ";" >
insert into app_location
2025-01-17 10:56:58 +08:00
(
2025-02-23 08:04:40 +08:00
<trim prefixOverrides= "," suffixOverrides= "," >
2025-01-17 10:56:58 +08:00
<if test= "location.locationId != null" > location_id,</if>
<if test= "location.locationType != null" > location_type,</if>
<if test= "location.locationStatus != null" > location_status,</if>
<if test= "location.outerId != null" > outer_id,</if>
<if test= "location.areaId != null" > area_id,</if>
<if test= "location.tunnelId != null" > tunnel_id,</if>
<if test= "location.equipmentId != null" > equipment_id,</if>
<if test= "location.wRow != null" > w_row,</if>
<if test= "location.wCol != null" > w_col,</if>
<if test= "location.wLayer != null" > w_layer,</if>
<if test= "location.wDepth != null" > w_depth,</if>
<if test= "location.isLock != null" > is_lock,</if>
<if test= "location.vehicleId != null" > vehicle_id,</if>
<if test= "location.remark != null" > remark,</if>
<if test= "location.isWorking != null" > is_working,</if>
2025-03-05 15:25:21 +08:00
<if test= "location.isEnable != null" > is_enable,</if>
2025-01-17 10:56:58 +08:00
</trim>
)
values
(
2025-02-23 08:04:40 +08:00
<trim prefixOverrides= "," suffixOverrides= "," >
2025-01-17 10:56:58 +08:00
<if test= "location.locationId != null" > #{location.locationId},</if>
<if test= "location.locationType != null" > #{location.locationType},</if>
<if test= "location.locationStatus != null" > #{location.locationStatus},</if>
<if test= "location.outerId != null" > #{location.outerId},</if>
<if test= "location.areaId != null" > #{location.areaId},</if>
<if test= "location.tunnelId != null" > #{location.tunnelId},</if>
<if test= "location.equipmentId != null" > #{location.equipmentId},</if>
<if test= "location.wRow != null" > #{location.wRow},</if>
<if test= "location.wCol != null" > #{location.wCol},</if>
<if test= "location.wLayer != null" > #{location.wLayer},</if>
<if test= "location.wDepth != null" > #{location.wDepth},</if>
<if test= "location.isLock != null" > #{location.isLock},</if>
<if test= "location.vehicleId != null" > #{location.vehicleId},</if>
<if test= "location.remark != null" > #{location.remark},</if>
<if test= "location.isWorking != null" > #{location.isWorking},</if>
2025-03-05 15:25:21 +08:00
<if test= "location.isEnable != null" > #{location.isEnable},</if>
2025-01-17 10:56:58 +08:00
</trim>
)
</foreach>
</insert>
2025-01-15 10:28:03 +08:00
<update id= "updateAppLocation" parameterType= "AppLocation" >
update app_location
<trim prefix= "SET" suffixOverrides= "," >
<if test= "locationType != null" > location_type = #{locationType},</if>
<if test= "locationStatus != null" > location_status = #{locationStatus},</if>
<if test= "outerId != null" > outer_id = #{outerId},</if>
<if test= "areaId != null" > area_id = #{areaId},</if>
<if test= "tunnelId != null" > tunnel_id = #{tunnelId},</if>
<if test= "equipmentId != null" > equipment_id = #{equipmentId},</if>
<if test= "wRow != null" > w_row = #{wRow},</if>
<if test= "wCol != null" > w_col = #{wCol},</if>
<if test= "wLayer != null" > w_layer = #{wLayer},</if>
<if test= "wDepth != null" > w_depth = #{wDepth},</if>
<if test= "isLock != null" > is_lock = #{isLock},</if>
<if test= "vehicleId != null" > vehicle_id = #{vehicleId},</if>
<if test= "remark != null" > remark = #{remark},</if>
2025-01-17 10:56:58 +08:00
<if test= "isWorking != null" > is_working = #{isWorking},</if>
2025-03-05 15:25:21 +08:00
<if test= "isEnable != null" > is_enable = #{isEnable},</if>
2025-01-15 10:28:03 +08:00
</trim>
where location_id = #{locationId}
</update>
<delete id= "deleteAppLocationByLocationId" parameterType= "String" >
2025-01-17 10:56:58 +08:00
delete
from app_location
where location_id = #{locationId}
2025-01-15 10:28:03 +08:00
</delete>
<delete id= "deleteAppLocationByLocationIds" parameterType= "String" >
delete from app_location where location_id in
<foreach item= "locationId" collection= "array" open= "(" separator= "," close= ")" >
#{locationId}
</foreach>
</delete>
2025-03-05 15:25:21 +08:00
<select id= "selectAppLocationListByLocationIds" parameterType= "String" resultMap= "AppLocationResult" >
<include refid= "selectAppLocationVo" />
where location_id in
<foreach item= "locationId" collection= "array" open= "(" separator= "," close= ")" >
#{locationId}
</foreach>
</select>
2025-03-06 02:59:02 +08:00
</mapper>