332 lines
13 KiB
XML
Raw Normal View History

2022-01-11 10:21:53 +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.xhpc.workorder.mapper.XhpcStationDeviceMapper">
<resultMap id="BaseResultMap" type="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
2022-01-11 18:11:20 +08:00
<id column="device_id" jdbcType="BIGINT" property="deviceId" />
2022-01-11 10:21:53 +08:00
<result column="device_name" jdbcType="VARCHAR" property="deviceName" />
<result column="device_type" jdbcType="VARCHAR" property="deviceType" />
2022-01-11 18:11:20 +08:00
<result column="current_type" jdbcType="VARCHAR" property="currentType" />
2022-01-11 10:21:53 +08:00
<result column="station_id" jdbcType="BIGINT" property="stationId" />
<result column="parent_device_id" jdbcType="BIGINT" property="parentDeviceId" />
2022-01-11 18:11:20 +08:00
<result column="brand_model" jdbcType="VARCHAR" property="brandModel" />
2022-01-11 10:21:53 +08:00
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber" />
<result column="status" jdbcType="SMALLINT" property="status" />
<result column="del_flag" jdbcType="SMALLINT" property="delFlag" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
</resultMap>
<sql id="Base_Column_List">
2022-02-21 09:35:37 +08:00
device_id, device_name, device_type, current_type, station_id, brand_model, parent_device_id, serial_number, sorted,
2022-01-11 10:21:53 +08:00
`status`, del_flag, create_time, create_by, update_time, update_by
</sql>
2022-01-11 18:11:20 +08:00
<select id="selectStationGunDeviceBySerialNumber" resultType="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
select
<include refid="Base_Column_List" />
from xhpc_station_device
2022-01-14 13:56:20 +08:00
where serial_number = #{serialNumber}
2022-01-11 18:11:20 +08:00
</select>
<select id="selectStationGunDeviceListByParams" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'pileId',
d1.device_name as 'pileName',
2022-02-21 09:35:37 +08:00
d1.device_type as 'pileDeviceType',
2022-01-11 18:11:20 +08:00
d1.serial_number as 'pileSerialNumber',
d1.brand_model as 'pileBrandModel',
d1.current_type as 'pileCurrentType',
2022-02-21 09:35:37 +08:00
d1.sorted as 'pileSorted',
2022-01-11 18:11:20 +08:00
d2.device_id as 'gunId',
d2.device_name as 'gunName',
2022-02-21 09:35:37 +08:00
d2.device_type as 'gunDeviceType',
2022-01-11 18:11:20 +08:00
d2.serial_number as 'gunSerialNumber',
d2.brand_model as 'gunBrandModel',
2022-02-21 09:35:37 +08:00
d2.current_type as 'gunCurrentType',
d2.sorted as 'gunSorted',
t.status as 'status',
t.work_status as 'workStatus',
t.charging_pile_id as 'chargingPileId'
2022-01-11 18:11:20 +08:00
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
LEFT JOIN xhpc_station_device d2 on d2.parent_device_id=d1.device_id
LEFT JOIN xhpc_terminal t on t.serial_number = d2.serial_number
2022-01-11 18:11:20 +08:00
WHERE s.del_flag=0 and d1.del_flag=0 and d1.device_type='PILE'
2022-02-21 09:35:37 +08:00
<if test="params.stationName!=null and params.stationName != ''">
2022-01-11 18:11:20 +08:00
and s.name like concat('%', #{params.stationName}, '%')
</if>
2022-02-21 09:35:37 +08:00
<if test="params.stationId!=null and params.stationId != ''">
and s.work_station_id = #{params.stationId}
</if>
2022-01-11 18:11:20 +08:00
<if test="params.terminalName!=null and params.terminalName!=''">
2022-02-21 09:35:37 +08:00
and d2.device_name like concat('%', #{params.terminalName},'%')
2022-01-11 18:11:20 +08:00
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
2022-02-21 09:35:37 +08:00
order by d1.device_type, d1.sorted, d2.device_type, d2.sorted
2022-01-11 18:11:20 +08:00
</select>
2022-01-24 17:23:53 +08:00
<select id="selectByDeviceId" resultType="java.util.Map">
select
d.device_id as 'deviceId',
d.device_name as 'deviceName',
d.device_type as 'deviceType',
d.current_type as 'currentType',
d.station_id as 'stationId',
d.brand_model as 'brandModel',
d.parent_device_id as 'parengDeviceId',
d.serial_number as 'serialNumber',
2022-02-21 09:35:37 +08:00
d.sorted as 'sorted',
2022-01-24 17:23:53 +08:00
d.`status` as 'status',
d.del_flag as 'delFlag',
d.create_time as 'createTime',
d.create_by as 'createBy',
d.update_time as 'updateTime',
d.update_by as 'updateBy',
s.name as 'stationName'
from xhpc_station_device d
left join xhpc_work_station s on d.station_id=s.work_station_id
where device_id = #{deviceId,jdbcType=INTEGER}
</select>
2022-01-11 18:11:20 +08:00
<select id="selectStationGunDeviceTreeByParams" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
2022-02-21 09:35:37 +08:00
d1.device_type as 'deviceType',
2022-01-11 18:11:20 +08:00
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
2022-02-21 09:35:37 +08:00
d1.sorted as 'deviceSorted'
2022-01-11 18:11:20 +08:00
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
WHERE s.del_flag=0 and d1.del_flag=0
2022-02-21 09:35:37 +08:00
<if test="params.deviceName != null and params.deviceName != ''">
and d1.device_name like concat('%', #{params.deviceName}, '%')
</if>
<if test="params.stationName!=null and params.stationName != ''">
2022-01-11 18:11:20 +08:00
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
and d1.device_name like concat('%', #{params.terminalName},'%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
2022-02-21 09:35:37 +08:00
order by d1.station_id, d1.device_type, d1.sorted
</select>
<select id="selectListByParent" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
d1.device_type as 'deviceType',
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
d1.sorted as 'deviceSorted'
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
WHERE s.del_flag=0 and d1.del_flag=0
<if test="params.deviceName != null and params.deviceName != ''">
and d1.device_name like concat('%', #{params.deviceName}, '%')
</if>
<if test="params.stationName!=null and params.stationName != ''">
and s.name like concat('%', #{params.stationName}, '%')
</if>
<if test="params.terminalName!=null and params.terminalName!=''">
and d1.device_name like concat('%', #{params.terminalName},'%')
</if>
<if test="params.tenantId!=null and params.tenantId!=''">
and s.tenant_id=#{params.tenantId}
</if>
<if test="params.stationId != null and params.stationId !=''">
and s.work_station_id = #{params.stationId}
</if>
<if test="params.deviceType != null and params.deviceType !=''">
and d1.device_type = #{params.deviceType}
</if>
<if test="params.parentId != null and params.parentId !=''">
and d1.parent_device_id = #{params.parentId}
</if>
order by d1.device_type, d1.sorted
2022-01-11 18:11:20 +08:00
</select>
<select id="selectStationGunDeviceTreeByParent" resultType="map">
SELECT
s.`name` as 'stationName',
d1.device_id as 'deviceId',
d1.device_name as 'deviceName',
2022-02-21 09:35:37 +08:00
d1.device_type as 'deviceType',
2022-01-11 18:11:20 +08:00
d1.serial_number as 'deviceSerialNumber',
d1.brand_model as 'deviceBrandModel',
d1.current_type as 'deviceCurrentType',
2022-02-21 09:35:37 +08:00
d1.sorted as 'deviceSorted'
2022-01-11 18:11:20 +08:00
from xhpc_station_device d1
LEFT JOIN xhpc_work_station s on s.work_station_id=d1.station_id
WHERE s.del_flag=0 and d1.del_flag=0
and d1.parent_device_id=#{parentDeviceId}
2022-02-21 09:35:37 +08:00
order by d1.device_type, d1.sorted
2022-01-11 18:11:20 +08:00
</select>
2022-01-11 10:21:53 +08:00
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from xhpc_station_device
where device_id = #{deviceId,jdbcType=INTEGER}
</select>
<update id="deleteByPrimaryKey" parameterType="java.lang.Integer">
update xhpc_station_device set del_flag = 2
where device_id = #{deviceId,jdbcType=INTEGER}
</update>
<insert id="insert" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true">
2022-01-11 18:11:20 +08:00
insert into xhpc_station_device (device_name, device_type, current_type, station_id,
2022-02-21 09:35:37 +08:00
parent_device_id, serial_number, brand_model,sorted, `status`,
2022-01-11 10:21:53 +08:00
del_flag, create_time, create_by,
update_time, update_by)
2022-01-11 18:11:20 +08:00
values (#{deviceName,jdbcType=VARCHAR}, #{deviceType,jdbcType=VARCHAR}, #{currentType,jdbcType=VARCHAR}, #{stationId,jdbcType=BIGINT},
2022-02-21 09:35:37 +08:00
#{parentDeviceId,jdbcType=BIGINT}, #{serialNumber,jdbcType=VARCHAR}, #{brandModel,jdbcType=VARCHAR},#{sorted, jdbcType=SMALLINT}, #{status,jdbcType=SMALLINT},
2022-01-11 10:21:53 +08:00
0, SYSDATE(), #{createBy,jdbcType=VARCHAR}, SYSDATE(), #{updateBy,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="device_id" keyProperty="deviceId" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain" useGeneratedKeys="true">
insert into xhpc_station_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceName != null">
device_name,
</if>
<if test="deviceType != null">
device_type,
</if>
2022-01-11 18:11:20 +08:00
<if test="currentType != null">
current_type,
</if>
2022-01-11 10:21:53 +08:00
<if test="stationId != null">
station_id,
</if>
<if test="parentDeviceId != null">
parent_device_id,
</if>
<if test="serialNumber != null">
serial_number,
</if>
2022-01-11 18:11:20 +08:00
<if test="brandModel != null">
brand_model,
</if>
2022-02-21 09:35:37 +08:00
<if test="sorted != null">
`sorted`,
</if>
2022-01-11 10:21:53 +08:00
<if test="status != null">
`status`,
</if>
del_flag,
create_time,
<if test="createBy != null">
create_by,
</if>
update_time,
<if test="updateBy != null">
update_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceName != null">
#{deviceName,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
#{deviceType,jdbcType=VARCHAR},
</if>
2022-01-11 18:11:20 +08:00
<if test="currentType != null">
#{currentType,jdbcType=VARCHAR},
</if>
2022-01-11 10:21:53 +08:00
<if test="stationId != null">
#{stationId,jdbcType=BIGINT},
</if>
<if test="parentDeviceId != null">
#{parentDeviceId,jdbcType=BIGINT},
</if>
<if test="serialNumber != null">
#{serialNumber,jdbcType=VARCHAR},
</if>
2022-01-11 18:11:20 +08:00
<if test="brandModel != null">
#{brandModel,jdbcType=VARCHAR},
</if>
2022-02-21 09:35:37 +08:00
<if test="sorted != null">
#{sorted,jdbcType=SMALLINT},
</if>
2022-01-11 10:21:53 +08:00
<if test="status != null">
#{status,jdbcType=SMALLINT},
</if>
0,
sysdate(),
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
sysdate(),
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
update xhpc_station_device
<set>
<if test="deviceName != null">
device_name = #{deviceName,jdbcType=VARCHAR},
</if>
<if test="deviceType != null">
device_type = #{deviceType,jdbcType=VARCHAR},
</if>
2022-01-11 18:11:20 +08:00
<if test="currentType != null">
current_type = #{currentType,jdbcType=VARCHAR},
</if>
2022-01-11 10:21:53 +08:00
<if test="stationId != null">
station_id = #{stationId,jdbcType=BIGINT},
</if>
<if test="parentDeviceId != null">
parent_device_id = #{parentDeviceId,jdbcType=BIGINT},
</if>
<if test="serialNumber != null">
serial_number = #{serialNumber,jdbcType=VARCHAR},
</if>
2022-01-11 18:11:20 +08:00
<if test="brandModel != null">
brand_model = #{brandModel,jdbcType=VARCHAR},
</if>
2022-02-21 09:35:37 +08:00
<if test="sorted != null">
`sorted` = #{sorted,jdbcType=SMALLINT},
</if>
2022-01-11 10:21:53 +08:00
<if test="status != null">
`status` = #{status,jdbcType=SMALLINT},
</if>
update_time = sysdate(),
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
</set>
where device_id = #{deviceId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.workorder.domain.XhpcStationDeviceDomain">
update xhpc_station_device
set device_name = #{deviceName,jdbcType=VARCHAR},
device_type = #{deviceType,jdbcType=VARCHAR},
2022-01-11 18:11:20 +08:00
current_type = #{currentType,jdbcType=VARCHAR},
2022-01-11 10:21:53 +08:00
station_id = #{stationId,jdbcType=BIGINT},
parent_device_id = #{parentDeviceId,jdbcType=BIGINT},
serial_number = #{serialNumber,jdbcType=VARCHAR},
2022-01-11 18:11:20 +08:00
brand_model = #{brandModel,jdbcType=VARCHAR},
2022-02-21 09:35:37 +08:00
sorted = #{sorted,jdbcType=SMALLINT},
2022-01-11 10:21:53 +08:00
`status` = #{status,jdbcType=SMALLINT},
update_time = sysdate(),
update_by = #{updateBy,jdbcType=VARCHAR}
where device_id = #{deviceId,jdbcType=INTEGER}
</update>
</mapper>