zn-cloud-wcs/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/positionmap/PositionMapItemMapper.xml
aikai 1be88c8b42 feat(system): 优化库区管理和设备信息展示
- 新增库区删除功能
- 完善设备状态信息统计
- 优化地图点位与库区、通道关联逻辑
- 重构设备信息获取方法
- 优化数据字典查询效率
2025-02-21 10:52:47 +08:00

290 lines
11 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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.system.dal.mysql.positionmap.PositionMapItemMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<resultMap id="BaseResultMap" type="cn.iocoder.yudao.module.system.dal.dataobject.positionmap.PositionMapItemDO">
<!--@Table ware_position_map_item-->
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="positionMapId" column="position_map_id" jdbcType="INTEGER"/>
<result property="areaId" column="area_id" jdbcType="INTEGER"/>
<result property="laneId" column="lane_id" jdbcType="INTEGER"/>
<result property="locationX" column="location_x" jdbcType="VARCHAR"/>
<result property="locationY" column="location_y" jdbcType="VARCHAR"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="dataJson" column="data_json" jdbcType="VARCHAR"/>
<result property="creator" column="creator" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updater" column="updater" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="deleted" column="deleted" jdbcType="INTEGER"/>
</resultMap>
<!--查询单个-->
<sql id="base_sql" >
id,
position_map_id,
area_id,
lane_id,
location_x,
location_y,
type,
data_json,
creator,
create_time,
updater,
update_time,
deleted,
tenant_id
</sql>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="BaseResultMap">
select
id, position_map_id, area_id, lane_id, location_x, location_y, type, data_json, creator, create_time, updater,
update_time, deleted, tenant_id
from ware_position_map_item
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="positionMapId != null">
and position_map_id = #{positionMapId}
</if>
<if test="areaId != null">
and area_id = #{areaId}
</if>
<if test="laneId != null">
and lane_id = #{laneId}
</if>
<if test="locationX != null and locationX != ''">
and location_x = #{locationX}
</if>
<if test="locationY != null and locationY != ''">
and location_y = #{locationY}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="dataJson != null and dataJson != ''">
and data_json = #{dataJson}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="BaseResultMap">
select
id, position_map_id, area_id, lane_id, location_x, location_y, type, data_json, creator, create_time, updater,
update_time, deleted, tenant_id
from zn_wcs.ware_position_map_item
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from ware_position_map_item
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="positionMapId != null">
and position_map_id = #{positionMapId}
</if>
<if test="areaId != null">
and area_id = #{areaId}
</if>
<if test="laneId != null">
and lane_id = #{laneId}
</if>
<if test="locationX != null and locationX != ''">
and location_x = #{locationX}
</if>
<if test="locationY != null and locationY != ''">
and location_y = #{locationY}
</if>
<if test="type != null">
and type = #{type}
</if>
<if test="dataJson != null and dataJson != ''">
and data_json = #{dataJson}
</if>
<if test="creator != null and creator != ''">
and creator = #{creator}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updater != null and updater != ''">
and updater = #{updater}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="deleted != null">
and deleted = #{deleted}
</if>
<if test="tenantId != null">
and tenant_id = #{tenantId}
</if>
</where>
</select>
<select id="selectByLocationId" resultType="cn.iocoder.yudao.module.mqtt.api.task.dto.Pose2ds">
select
t1.location_x as x,
t1.location_y as y,
t2.location_yaw as yaw
from
ware_position_map_item t1 ,ware_house_location t2
where t1.id = t2.map_item_id
and t2.id = #{locationId}
</select>
<select id="getAllByMapId" resultType="cn.iocoder.yudao.module.mqtt.api.path.dto.PositionMapItemSynDTO">
select
id,
location_x as locationX,
location_y as locationY,
type
from
ware_position_map_item
where
position_map_id = #{positionMapId}
</select>
<!--新增所有列-->
<insert id="insertEntity" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values (#{positionMapId}, #{areaId}, #{laneId}, #{locationX}, #{locationY}, #{type}, #{dataJson}, #{creator},
#{createTime}, #{updater}, #{updateTime}, #{deleted}, #{tenantId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.positionMapId}, #{entity.areaId}, #{entity.laneId}, #{entity.locationX}, #{entity.locationY},
#{entity.type}, #{entity.dataJson}, #{entity.creator}, #{entity.createTime}, #{entity.updater},
#{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into ware_position_map_item(position_map_id, area_id, lane_id, location_x, location_y, type, data_json,
creator, create_time, updater, update_time, deleted, tenant_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.positionMapId}, #{entity.areaId}, #{entity.laneId}, #{entity.locationX}, #{entity.locationY},
#{entity.type}, #{entity.dataJson}, #{entity.creator}, #{entity.createTime}, #{entity.updater},
#{entity.updateTime}, #{entity.deleted}, #{entity.tenantId})
</foreach>
on duplicate key update
position_map_id = values(position_map_id),
area_id = values(area_id),
lane_id = values(lane_id),
location_x = values(location_x),
location_y = values(location_y),
type = values(type),
data_json = values(data_json),
creator = values(creator),
create_time = values(create_time),
updater = values(updater),
update_time = values(update_time),
deleted = values(deleted),
tenant_id = values(tenant_id)
</insert>
<!--通过主键修改数据-->
<update id="update">
update ware_position_map_item
<set>
<if test="positionMapId != null">
position_map_id = #{positionMapId},
</if>
<if test="areaId != null">
area_id = #{areaId},
</if>
<if test="laneId != null">
lane_id = #{laneId},
</if>
<if test="locationX != null and locationX != ''">
location_x = #{locationX},
</if>
<if test="locationY != null and locationY != ''">
location_y = #{locationY},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="dataJson != null and dataJson != ''">
data_json = #{dataJson},
</if>
<if test="creator != null and creator != ''">
creator = #{creator},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="deleted != null">
deleted = #{deleted},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId},
</if>
</set>
where id = #{id}
</update>
<update id="emptyAreaId">
update ware_position_map_item
set area_id = null
where position_map_id = #{mapId}
and area_id = #{areaId}
</update>
<update id="emptyLaneId">
update ware_position_map_item
set lane_id = null
where position_map_id = #{mapId}
and lane_id = #{laneId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from ware_position_map_item
where id = #{id}
</delete>
</mapper>