XH-Power-Cloud/xhpc-modules/xhpc-card/src/main/resources/mapper/XhpcChargingStationMapper.xml

572 lines
25 KiB
XML
Raw Normal View History

<?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">
<!--suppress ALL -->
<mapper namespace="com.xhpc.card.mapper.XhpcChargingStationMapper">
<resultMap id="BaseResultMap" type="com.xhpc.card.pojo.XhpcChargingStation">
<id column="charging_station_id" jdbcType="BIGINT" property="chargingStationId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="operator_id" jdbcType="BIGINT" property="operatorId"/>
<result column="type" jdbcType="INTEGER" property="type"/>
<result column="construction_site" jdbcType="SMALLINT" property="constructionSite"/>
<result column="service_facilities" jdbcType="VARCHAR" property="serviceFacilities"/>
<result column="periphery_facilities" jdbcType="VARCHAR" property="peripheryFacilities"/>
<result column="area_code" jdbcType="INTEGER" property="areaCode"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="detailed_address" jdbcType="VARCHAR" property="detailedAddress"/>
<result column="longitude" jdbcType="VARCHAR" property="longitude"/>
<result column="latitude" jdbcType="VARCHAR" property="latitude"/>
<result column="parking_instructions" jdbcType="VARCHAR" property="parkingInstructions"/>
<result column="serial_number" jdbcType="VARCHAR" property="serialNumber"/>
<result column="client_visible" jdbcType="VARCHAR" property="clientVisible"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="del_flag" jdbcType="INTEGER" 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"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="rate_model_id" jdbcType="BIGINT" property="rateModelId"/>
<result column="business_instructions" jdbcType="VARCHAR" property="businessInstructions"/>
<result column="reminder_instructions" jdbcType="VARCHAR" property="reminderInstructions"/>
<result column="img_id" jdbcType="VARCHAR" property="imgId"/>
<result column="station_type" jdbcType="SMALLINT" property="stationType"/>
<result column="operator_id_evcs" jdbcType="VARCHAR" property="operatorIdEvcs"/>
<result column="service_tel" jdbcType="VARCHAR" property="serviceTel"/>
<result column="search_value" jdbcType="VARCHAR" property="searchValue"/>
<result column="park_nums" jdbcType="INTEGER" property="parkNums"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
</resultMap>
<sql id="Base_Column_List">
charging_station_id
, `name`, operator_id, `type`, construction_site, service_facilities,
periphery_facilities, area_code, address, detailed_address, longitude, latitude,
parking_instructions, serial_number, client_visible, `status`, del_flag, create_time,
create_by, update_time, update_by, remark, rate_model_id, business_instructions,
reminder_instructions, img_id, station_type, operator_id_evcs, service_tel, search_value,
park_nums, tenant_id
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from xhpc_charging_station
where charging_station_id = #{chargingStationId,jdbcType=BIGINT}
</select>
2022-03-03 15:52:39 +08:00
<select id="selectByTenantIdAndChargingStationId" resultType="Map">
SELECT
xhpc_charging_station.tenant_id tenantId,
2022-03-03 15:52:39 +08:00
xhpc_charging_station.charging_station_id chargingStationId,
xhpc_charging_station.`name`,
2022-03-03 15:52:39 +08:00
xhpc_charging_station.area_code areaCode,
xhpc_charging_station.longitude,
xhpc_charging_station.latitude
FROM
xhpc_charging_station
WHERE
xhpc_charging_station.del_flag = 0
AND xhpc_charging_station.`status` = 0
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
</if>
2022-03-03 15:52:39 +08:00
<if test="chargingStationId!=null">
AND xhpc_charging_station.charging_station_id = #{chargingStationId}
</if>
</select>
2022-05-12 16:12:31 +08:00
<select id="returnCoreChargingStation" resultType="map">
SELECT
name,
(SELECT count(charging_station_id) FROM xhpc_charging_station
WHERE del_flag = 0
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
</if>
<if test="areaCode== null">
<if test="number ==1">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =xa.code))
2022-05-12 16:12:31 +08:00
</if>
<if test="number ==2">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode =xa.code)
</if>
<if test="number ==3">
AND area_code =xa.code
</if>
</if>
<if test="areaCode != null">
2022-05-12 16:12:31 +08:00
<if test="number ==1">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =xa.code))
2022-05-12 16:12:31 +08:00
</if>
<if test="number ==2">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode =xa.code)
2022-05-12 16:12:31 +08:00
</if>
<if test="number ==3">
AND area_code =xa.code
</if>
</if>) value
FROM
2022-05-18 10:50:21 +08:00
xhpc_area_pc as xa
2022-05-12 16:12:31 +08:00
WHERE 1=1
<if test="areaCode != null">
2022-05-12 16:12:31 +08:00
and xa.level =#{number}
<if test="number ==1">
and (SELECT count(charging_station_id) FROM xhpc_charging_station
WHERE del_flag = 0
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =xa.code)))>0
2022-05-12 16:12:31 +08:00
</if>
<if test="number ==2">
2022-05-12 16:12:31 +08:00
and (SELECT count(charging_station_id) FROM xhpc_charging_station
WHERE del_flag = 0
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode =xa.code))>0
AND (xa.code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =#{areaCode}))
or xa.code in (select code from xhpc_area_pc where pcode =#{areaCode})
)
2022-05-12 16:12:31 +08:00
</if>
<if test="number ==3">
and (SELECT count(charging_station_id) FROM xhpc_charging_station
WHERE del_flag = 0
AND area_code =xa.code )>0
2022-05-18 10:50:21 +08:00
and xa.code in (select code from xhpc_area_pc where pcode =#{areaCode})
2022-05-12 16:12:31 +08:00
</if>
</if>
<if test="areaCode==null">
2022-05-12 16:12:31 +08:00
and xa.level =1
and (SELECT count(charging_station_id) FROM xhpc_charging_station
WHERE del_flag = 0
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =xa.code)))>0
2022-05-12 16:12:31 +08:00
</if>
</select>
2022-03-03 15:52:39 +08:00
<select id="selectByTenantIdAndAreaCode" resultType="map">
SELECT
xhpc_charging_station.tenant_id tenantId,
xhpc_charging_station.charging_station_id chargingStationId,
xhpc_charging_station.`name`,
xhpc_charging_station.area_code areaCode,
xhpc_charging_station.longitude,
xhpc_charging_station.latitude
FROM
xhpc_charging_station
WHERE
del_flag = 0
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
2022-03-03 15:52:39 +08:00
</if>
<if test="areaCode != null and areaCode != '' ">
<if test="number !=0 and number ==1">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode in(select code from xhpc_area_pc where pcode =#{areaCode}))
</if>
<if test="number !=0 and number ==2">
2022-05-18 10:50:21 +08:00
AND area_code in (select code from xhpc_area_pc where pcode =#{areaCode})
</if>
<if test="number !=0 and number ==3">
AND area_code =#{areaCode}
</if>
2022-03-03 15:52:39 +08:00
</if>
</select>
<select id="getXhpcAreaLevel" resultType="int">
2022-05-18 10:50:21 +08:00
select level from xhpc_area_pc where code =#{areaCode}
</select>
2022-03-09 10:41:59 +08:00
<select id="selectChargingStationIds" resultType="java.lang.Long">
SELECT
charging_station_id
FROM
xhpc_charging_station
<where>
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
2022-03-09 10:41:59 +08:00
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from xhpc_charging_station
where charging_station_id = #{chargingStationId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="charging_station_id" keyProperty="chargingStationId"
parameterType="com.xhpc.card.pojo.XhpcChargingStation" useGeneratedKeys="true">
insert into xhpc_charging_station (`name`, operator_id, `type`,
construction_site, service_facilities, periphery_facilities,
area_code, address, detailed_address,
longitude, latitude, parking_instructions,
serial_number, client_visible, `status`,
del_flag, create_time, create_by,
update_time, update_by, remark,
rate_model_id, business_instructions, reminder_instructions,
img_id, station_type, operator_id_evcs,
service_tel, search_value, park_nums,
tenant_id)
values (#{name,jdbcType=VARCHAR}, #{operatorId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER},
#{constructionSite,jdbcType=SMALLINT}, #{serviceFacilities,jdbcType=VARCHAR},
#{peripheryFacilities,jdbcType=VARCHAR},
#{areaCode,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, #{detailedAddress,jdbcType=VARCHAR},
#{longitude,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR}, #{parkingInstructions,jdbcType=VARCHAR},
#{serialNumber,jdbcType=VARCHAR}, #{clientVisible,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
#{delFlag,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{rateModelId,jdbcType=BIGINT}, #{businessInstructions,jdbcType=VARCHAR},
#{reminderInstructions,jdbcType=VARCHAR},
#{imgId,jdbcType=VARCHAR}, #{stationType,jdbcType=SMALLINT}, #{operatorIdEvcs,jdbcType=VARCHAR},
#{serviceTel,jdbcType=VARCHAR}, #{searchValue,jdbcType=VARCHAR}, #{parkNums,jdbcType=INTEGER},
#{tenantId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="charging_station_id" keyProperty="chargingStationId"
parameterType="com.xhpc.card.pojo.XhpcChargingStation" useGeneratedKeys="true">
insert into xhpc_charging_station
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">
`name`,
</if>
<if test="operatorId != null">
operator_id,
</if>
<if test="type != null">
`type`,
</if>
<if test="constructionSite != null">
construction_site,
</if>
<if test="serviceFacilities != null">
service_facilities,
</if>
<if test="peripheryFacilities != null">
periphery_facilities,
</if>
<if test="areaCode != null">
area_code,
</if>
<if test="address != null">
address,
</if>
<if test="detailedAddress != null">
detailed_address,
</if>
<if test="longitude != null">
longitude,
</if>
<if test="latitude != null">
latitude,
</if>
<if test="parkingInstructions != null">
parking_instructions,
</if>
<if test="serialNumber != null">
serial_number,
</if>
<if test="clientVisible != null">
client_visible,
</if>
<if test="status != null">
`status`,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="remark != null">
remark,
</if>
<if test="rateModelId != null">
rate_model_id,
</if>
<if test="businessInstructions != null">
business_instructions,
</if>
<if test="reminderInstructions != null">
reminder_instructions,
</if>
<if test="imgId != null">
img_id,
</if>
<if test="stationType != null">
station_type,
</if>
<if test="operatorIdEvcs != null">
operator_id_evcs,
</if>
<if test="serviceTel != null">
service_tel,
</if>
<if test="searchValue != null">
search_value,
</if>
<if test="parkNums != null">
park_nums,
</if>
<if test="tenantId != null">
tenant_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="operatorId != null">
#{operatorId,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
<if test="constructionSite != null">
#{constructionSite,jdbcType=SMALLINT},
</if>
<if test="serviceFacilities != null">
#{serviceFacilities,jdbcType=VARCHAR},
</if>
<if test="peripheryFacilities != null">
#{peripheryFacilities,jdbcType=VARCHAR},
</if>
<if test="areaCode != null">
#{areaCode,jdbcType=INTEGER},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="detailedAddress != null">
#{detailedAddress,jdbcType=VARCHAR},
</if>
<if test="longitude != null">
#{longitude,jdbcType=VARCHAR},
</if>
<if test="latitude != null">
#{latitude,jdbcType=VARCHAR},
</if>
<if test="parkingInstructions != null">
#{parkingInstructions,jdbcType=VARCHAR},
</if>
<if test="serialNumber != null">
#{serialNumber,jdbcType=VARCHAR},
</if>
<if test="clientVisible != null">
#{clientVisible,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
<if test="rateModelId != null">
#{rateModelId,jdbcType=BIGINT},
</if>
<if test="businessInstructions != null">
#{businessInstructions,jdbcType=VARCHAR},
</if>
<if test="reminderInstructions != null">
#{reminderInstructions,jdbcType=VARCHAR},
</if>
<if test="imgId != null">
#{imgId,jdbcType=VARCHAR},
</if>
<if test="stationType != null">
#{stationType,jdbcType=SMALLINT},
</if>
<if test="operatorIdEvcs != null">
#{operatorIdEvcs,jdbcType=VARCHAR},
</if>
<if test="serviceTel != null">
#{serviceTel,jdbcType=VARCHAR},
</if>
<if test="searchValue != null">
#{searchValue,jdbcType=VARCHAR},
</if>
<if test="parkNums != null">
#{parkNums,jdbcType=INTEGER},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.xhpc.card.pojo.XhpcChargingStation">
update xhpc_charging_station
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="operatorId != null">
operator_id = #{operatorId,jdbcType=BIGINT},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
<if test="constructionSite != null">
construction_site = #{constructionSite,jdbcType=SMALLINT},
</if>
<if test="serviceFacilities != null">
service_facilities = #{serviceFacilities,jdbcType=VARCHAR},
</if>
<if test="peripheryFacilities != null">
periphery_facilities = #{peripheryFacilities,jdbcType=VARCHAR},
</if>
<if test="areaCode != null">
area_code = #{areaCode,jdbcType=INTEGER},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="detailedAddress != null">
detailed_address = #{detailedAddress,jdbcType=VARCHAR},
</if>
<if test="longitude != null">
longitude = #{longitude,jdbcType=VARCHAR},
</if>
<if test="latitude != null">
latitude = #{latitude,jdbcType=VARCHAR},
</if>
<if test="parkingInstructions != null">
parking_instructions = #{parkingInstructions,jdbcType=VARCHAR},
</if>
<if test="serialNumber != null">
serial_number = #{serialNumber,jdbcType=VARCHAR},
</if>
<if test="clientVisible != null">
client_visible = #{clientVisible,jdbcType=VARCHAR},
</if>
<if test="status != null">
`status` = #{status,jdbcType=INTEGER},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="rateModelId != null">
rate_model_id = #{rateModelId,jdbcType=BIGINT},
</if>
<if test="businessInstructions != null">
business_instructions = #{businessInstructions,jdbcType=VARCHAR},
</if>
<if test="reminderInstructions != null">
reminder_instructions = #{reminderInstructions,jdbcType=VARCHAR},
</if>
<if test="imgId != null">
img_id = #{imgId,jdbcType=VARCHAR},
</if>
<if test="stationType != null">
station_type = #{stationType,jdbcType=SMALLINT},
</if>
<if test="operatorIdEvcs != null">
operator_id_evcs = #{operatorIdEvcs,jdbcType=VARCHAR},
</if>
<if test="serviceTel != null">
service_tel = #{serviceTel,jdbcType=VARCHAR},
</if>
<if test="searchValue != null">
search_value = #{searchValue,jdbcType=VARCHAR},
</if>
<if test="parkNums != null">
park_nums = #{parkNums,jdbcType=INTEGER},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=VARCHAR},
</if>
</set>
where charging_station_id = #{chargingStationId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.xhpc.card.pojo.XhpcChargingStation">
update xhpc_charging_station
set `name` = #{name,jdbcType=VARCHAR},
operator_id = #{operatorId,jdbcType=BIGINT},
`type` = #{type,jdbcType=INTEGER},
construction_site = #{constructionSite,jdbcType=SMALLINT},
service_facilities = #{serviceFacilities,jdbcType=VARCHAR},
periphery_facilities = #{peripheryFacilities,jdbcType=VARCHAR},
area_code = #{areaCode,jdbcType=INTEGER},
address = #{address,jdbcType=VARCHAR},
detailed_address = #{detailedAddress,jdbcType=VARCHAR},
longitude = #{longitude,jdbcType=VARCHAR},
latitude = #{latitude,jdbcType=VARCHAR},
parking_instructions = #{parkingInstructions,jdbcType=VARCHAR},
serial_number = #{serialNumber,jdbcType=VARCHAR},
client_visible = #{clientVisible,jdbcType=VARCHAR},
`status` = #{status,jdbcType=INTEGER},
del_flag = #{delFlag,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
create_by = #{createBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
remark = #{remark,jdbcType=VARCHAR},
rate_model_id = #{rateModelId,jdbcType=BIGINT},
business_instructions = #{businessInstructions,jdbcType=VARCHAR},
reminder_instructions = #{reminderInstructions,jdbcType=VARCHAR},
img_id = #{imgId,jdbcType=VARCHAR},
station_type = #{stationType,jdbcType=SMALLINT},
operator_id_evcs = #{operatorIdEvcs,jdbcType=VARCHAR},
service_tel = #{serviceTel,jdbcType=VARCHAR},
search_value = #{searchValue,jdbcType=VARCHAR},
park_nums = #{parkNums,jdbcType=INTEGER},
tenant_id = #{tenantId,jdbcType=VARCHAR}
where charging_station_id = #{chargingStationId,jdbcType=BIGINT}
</update>
<select id="getTerminal" resultType="string">
select serial_number as serialNumber
from xhpc_terminal
where del_flag = 0 and charging_station_id not in(6,7)
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
</if>
<if test="chargingStationIds !=null and chargingStationIds.size()>0">
and charging_station_id in
<foreach collection="chargingStationIds" open="(" item="chargingStationId" separator="," close=")" >
#{chargingStationId}
</foreach>
</if>
</select>
<select id="getWorkOrderTerminal" resultType="map">
select
title,
DATE_FORMAT(create_time,'%Y-%m-%d') as createTime,
status
from xhpc_work_order
where 1=1
<if test="tenantIdsStr!=null and tenantIdsStr!='' ">
and find_in_set(tenant_id, #{tenantIdsStr})
</if>
order by create_time desc
LIMIT 50
</select>
</mapper>