2021-07-22 14:01:28 +08:00

151 lines
6.1 KiB
XML

<?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.system.mapper.XhpcUserPrivilegeMapper">
<resultMap type="XhpcUserPrivilege" id="XhpcUserPrivilegeResult">
<result column="user_id" property="userId"/>
<result column="charging_station_id" property="chargingStationId"/>
</resultMap>
<insert id="insert" parameterType="XhpcUserPrivilege">
insert into xhpc_user_privilege(
<if test="null != userId and '' != userId">
user_id,
</if>
<if test="null != chargingStationId and '' != chargingStationId">
charging_station_id
</if>
)values(
<if test="null != userId and '' != userId">
#{userId},
</if>
<if test="null != chargingStationId and '' != chargingStationId">
#{chargingStationId}
</if>
)
</insert>
<delete id="delete" parameterType="Long">
delete from xhpc_station_internet_blacklist where user_id = #{userId}
</delete>
<select id="dataCheckedKeys" parameterType="Long" resultType="java.lang.String">
select charging_station_id chargingStationId from xhpc_user_privilege where user_id = #{userId}
</select>
<select id="getOperatorId" parameterType="String" resultType="java.util.Map">
select xo.operator_id operatorId, xo.name, xo.contact_name contactName,
xo.contact_phone contactPhone, xo.phone, xo.attribute,
xdb.dict_value attributenName
from xhpc_operator `xo`
LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute
where xo.del_flag = 0
<if test="null != operatorIds and '' != operatorIds">
operator_id in
<foreach collection="operatorIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
ORDER BY xo.create_time DESC
</select>
<select id="getOperatorIdByUserId" parameterType="String" resultType="java.util.Map">
select xo.operator_id operatorId, xo.name, xo.contact_name contactName,
xo.contact_phone contactPhone, xo.phone, xo.attribute,
xdb.dict_value attributenName
from xhpc_operator `xo`
LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute
where xo.del_flag = 0
<if test="null != operatorIds and '' != operatorIds">
and operator_id in
(select operator_id
from xhpc_charging_station
where charging_station_id in (
select charging_station_id from xhpc_user_privilege where user_id = #{userId})
GROUP BY operator_id)
</if>
ORDER BY xo.create_time DESC
</select>
<select id="groupProvinceByOperatorId" parameterType="String" resultType="java.util.Map">
select `code` ,`name` from xhpc_area where `code` in (
select `pxa`.pcode province
from xhpc_charging_station xcs
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
where xcs.del_flag = 0
<if test="null != userId and '' != userId">
and xcs.charging_station_id in (
select charging_station_id from xhpc_user_privilege where user_id = #{userId})
</if>
<if test="null != operatorId and '' != operatorId">
and xcs.operator_id = #{operatorId}
</if>
GROUP BY `pxa`.pcode
)
</select>
<select id="groupCityByOperatorId" parameterType="String" resultType="java.util.Map">
select `code` ,`name` from xhpc_area where `code` in (
select `pxa`.code city
from xhpc_charging_station xcs
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
where xcs.del_flag = 0
<if test="null != userId and '' != userId">
and xcs.charging_station_id in (
select charging_station_id from xhpc_user_privilege where user_id = #{userId})
</if>
<if test="null != operatorId and '' != operatorId">
and xcs.operator_id = #{operatorId}
</if>
<if test="null != provinceCode and '' != provinceCode">
and pxa.pcode = #{provinceCode}
</if>
GROUP BY `pxa`.code
)
</select>
<select id="groupAreaByOperatorId" parameterType="String" resultType="java.util.Map">
select `code` ,`name` from xhpc_area where `code` in (
select `xa`.code
from xhpc_charging_station xcs
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
where xcs.del_flag = 0
<if test="null != userId and '' != userId">
and xcs.charging_station_id in (
select charging_station_id from xhpc_user_privilege where user_id = #{userId})
</if>
<if test="null != operatorId and '' != operatorId">
and xcs.operator_id = #{operatorId}
</if>
<if test="null != cityCode and '' != cityCode">
and pxa.code = #{cityCode}
</if>
GROUP BY `xa`.code
)
</select>
<select id="dataPowerByOperatorId" parameterType="String" resultType="java.util.Map">
select xcs.charging_station_id chargingStationId,xcs.name
from xhpc_charging_station xcs
LEFT JOIN xhpc_area `xa` on `xa`.`code` = xcs.area_code
LEFT JOIN xhpc_area pxa on `xa`.pcode = pxa.`code`
where xcs.del_flag = 0
<if test="null != userId and '' != userId">
and xcs.charging_station_id in (
select charging_station_id from xhpc_user_privilege where user_id = #{userId})
</if>
<if test="null != operatorId and '' != operatorId">
and xcs.operator_id = #{operatorId}
</if>
<if test="null != code and '' != code">
and `xa`.`code` = #{code}
</if>
</select>
</mapper>