<?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="api.dao.LampDao">
|
<resultMap id="BaseResultMap" type="api.bean.LampEntity">
|
<id column="singlelamp_data_id" jdbcType="BIGINT" property="singlelampDataId" />
|
<result column="streetlight_id" jdbcType="BIGINT" property="streetlightId" />
|
<result column="curr_error" jdbcType="DOUBLE" property="currError" />
|
<result column="grid_volt" jdbcType="DOUBLE" property="gridVolt" />
|
<result column="grid_curr" jdbcType="DOUBLE" property="gridCurr" />
|
<result column="grid_freq" jdbcType="DOUBLE" property="gridFreq" />
|
<result column="grid_pf" jdbcType="DOUBLE" property="gridPf" />
|
<result column="grid_ap" jdbcType="DOUBLE" property="gridAp" />
|
<result column="grid_rp" jdbcType="DOUBLE" property="gridRp" />
|
<result column="temperature" jdbcType="DOUBLE" property="temperature" />
|
<result column="led_dim" jdbcType="DOUBLE" property="ledDim" />
|
<result column="work_time" jdbcType="DOUBLE" property="workTime" />
|
<result column="work_time_total" jdbcType="DOUBLE" property="workTimeTotal" />
|
<result column="energy_tonight" jdbcType="DOUBLE" property="energyTonight" />
|
<result column="energy_total" jdbcType="DOUBLE" property="energyTotal" />
|
<result column="led_lux" jdbcType="DOUBLE" property="ledLux" />
|
<result column="ppk_today" jdbcType="DOUBLE" property="ppkToday" />
|
<result column="ppk_history" jdbcType="DOUBLE" property="ppkHistory" />
|
<result column="energy_today" jdbcType="DOUBLE" property="energyToday" />
|
<result column="save_money" jdbcType="DOUBLE" property="saveMoney" />
|
<result column="co2" jdbcType="DOUBLE" property="co2" />
|
<result column="energy_month" jdbcType="DOUBLE" property="energyMonth" />
|
<result column="save_money_month" jdbcType="DOUBLE" property="saveMoneyMonth" />
|
<result column="co2_month" jdbcType="DOUBLE" property="co2Month" />
|
<result column="grid_energy_year" jdbcType="DOUBLE" property="gridEnergyYear" />
|
<result column="save_money_year" jdbcType="DOUBLE" property="saveMoneyYear" />
|
<result column="co2_year" jdbcType="DOUBLE" property="co2Year" />
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
singlelamp_data_id, streetlight_id, curr_error, grid_volt, grid_curr, grid_freq,
|
grid_pf, grid_ap, grid_rp, temperature, led_dim, work_time, work_time_total, energy_tonight,
|
energy_total, led_lux, ppk_today, ppk_history, energy_today, save_money, co2, energy_month,
|
save_money_month, co2_month, grid_energy_year, save_money_year, co2_year, update_time
|
</sql>
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from pole_singlelamp_data
|
where singlelamp_data_id = #{singlelampDataId,jdbcType=BIGINT}
|
</select>
|
<select id="selectAll" resultType="api.bean.LampEntity">
|
SELECT
|
pole_streetlight.streetlight_name,pole_singlelamp_data.*
|
FROM
|
pole_singlelamp_data
|
LEFT JOIN
|
pole_streetlight
|
ON
|
pole_singlelamp_data.streetlight_id = pole_streetlight.streetlight_id
|
WHERE
|
singlelamp_data_id IN (
|
SELECT
|
max(singlelamp_data_id)
|
FROM
|
pole_singlelamp_data
|
GROUP BY
|
streetlight_id
|
)
|
ORDER BY
|
singlelamp_data_id DESC
|
</select>
|
|
<select id="selectByCompany" resultType="api.bean.LampEntity">
|
SELECT
|
pole_streetlight.streetlight_name,
|
pole_singlelamp_data.*
|
FROM
|
pole_singlelamp_data
|
LEFT JOIN pole_streetlight ON pole_singlelamp_data.streetlight_id = pole_streetlight.streetlight_id
|
WHERE
|
singlelamp_data_id IN (
|
SELECT
|
max( singlelamp_data_id )
|
FROM
|
pole_singlelamp_data
|
WHERE
|
streetlight_id IN ( SELECT streetlight_id FROM pole_user_streetlight WHERE company_id IN ( SELECT company_id FROM sys_user_company WHERE user_id = #{userId} ) )
|
GROUP BY
|
streetlight_id
|
)
|
ORDER BY
|
singlelamp_data_id DESC
|
</select>
|
|
<select id="selectByUserId" resultType="api.bean.LampEntity">
|
SELECT
|
pole_streetlight.streetlight_name,
|
pole_singlelamp_data.*
|
FROM
|
pole_singlelamp_data
|
LEFT JOIN pole_streetlight ON pole_singlelamp_data.streetlight_id = pole_streetlight.streetlight_id
|
WHERE
|
singlelamp_data_id IN (
|
SELECT
|
max(singlelamp_data_id)
|
FROM
|
pole_singlelamp_data
|
WHERE
|
streetlight_id IN (
|
SELECT
|
streetlight_id
|
FROM
|
pole_user_streetlight
|
WHERE
|
user_id = #{userId}
|
)
|
GROUP BY
|
streetlight_id
|
)
|
ORDER BY
|
singlelamp_data_id DESC
|
</select>
|
|
<select id="selectByStreetlightId" resultType="api.bean.LampEntity">
|
SELECT
|
pole_streetlight.streetlight_name,
|
pole_singlelamp_data.*
|
FROM
|
pole_singlelamp_data
|
LEFT JOIN pole_streetlight ON pole_singlelamp_data.streetlight_id = pole_streetlight.streetlight_id
|
WHERE
|
pole_singlelamp_data.streetlight_id = #{streetlightId}
|
ORDER BY
|
singlelamp_data_id DESC
|
</select>
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
delete from pole_singlelamp_data
|
where singlelamp_data_id = #{singlelampDataId,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" keyColumn="streetlight_id" keyProperty="streetlightId" parameterType="api.bean.LampEntity" useGeneratedKeys="true">
|
insert into pole_singlelamp_data (singlelamp_data_id, curr_error, grid_volt,
|
grid_curr, grid_freq, grid_pf,
|
grid_ap, grid_rp, temperature,
|
led_dim, work_time, work_time_total,
|
energy_tonight, energy_total, led_lux,
|
ppk_today, ppk_history, energy_today,
|
save_money, co2, energy_month,
|
save_money_month, co2_month, grid_energy_year,
|
save_money_year, co2_year, update_time
|
)
|
values (#{singlelampDataId,jdbcType=BIGINT}, #{currError,jdbcType=DOUBLE}, #{gridVolt,jdbcType=DOUBLE},
|
#{gridCurr,jdbcType=DOUBLE}, #{gridFreq,jdbcType=DOUBLE}, #{gridPf,jdbcType=DOUBLE},
|
#{gridAp,jdbcType=DOUBLE}, #{gridRp,jdbcType=DOUBLE}, #{temperature,jdbcType=DOUBLE},
|
#{ledDim,jdbcType=DOUBLE}, #{workTime,jdbcType=DOUBLE}, #{workTimeTotal,jdbcType=DOUBLE},
|
#{energyTonight,jdbcType=DOUBLE}, #{energyTotal,jdbcType=DOUBLE}, #{ledLux,jdbcType=DOUBLE},
|
#{ppkToday,jdbcType=DOUBLE}, #{ppkHistory,jdbcType=DOUBLE}, #{energyToday,jdbcType=DOUBLE},
|
#{saveMoney,jdbcType=DOUBLE}, #{co2,jdbcType=DOUBLE}, #{energyMonth,jdbcType=DOUBLE},
|
#{saveMoneyMonth,jdbcType=DOUBLE}, #{co2Month,jdbcType=DOUBLE}, #{gridEnergyYear,jdbcType=DOUBLE},
|
#{saveMoneyYear,jdbcType=DOUBLE}, #{co2Year,jdbcType=DOUBLE}, #{updateTime,jdbcType=TIMESTAMP}
|
)
|
</insert>
|
<insert id="insertSelective" keyColumn="streetlight_id" keyProperty="streetlightId" parameterType="api.bean.LampEntity" useGeneratedKeys="true">
|
insert into pole_singlelamp_data
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="singlelampDataId != null">
|
singlelamp_data_id,
|
</if>
|
<if test="currError != null">
|
curr_error,
|
</if>
|
<if test="gridVolt != null">
|
grid_volt,
|
</if>
|
<if test="gridCurr != null">
|
grid_curr,
|
</if>
|
<if test="gridFreq != null">
|
grid_freq,
|
</if>
|
<if test="gridPf != null">
|
grid_pf,
|
</if>
|
<if test="gridAp != null">
|
grid_ap,
|
</if>
|
<if test="gridRp != null">
|
grid_rp,
|
</if>
|
<if test="temperature != null">
|
temperature,
|
</if>
|
<if test="ledDim != null">
|
led_dim,
|
</if>
|
<if test="workTime != null">
|
work_time,
|
</if>
|
<if test="workTimeTotal != null">
|
work_time_total,
|
</if>
|
<if test="energyTonight != null">
|
energy_tonight,
|
</if>
|
<if test="energyTotal != null">
|
energy_total,
|
</if>
|
<if test="ledLux != null">
|
led_lux,
|
</if>
|
<if test="ppkToday != null">
|
ppk_today,
|
</if>
|
<if test="ppkHistory != null">
|
ppk_history,
|
</if>
|
<if test="energyToday != null">
|
energy_today,
|
</if>
|
<if test="saveMoney != null">
|
save_money,
|
</if>
|
<if test="co2 != null">
|
co2,
|
</if>
|
<if test="energyMonth != null">
|
energy_month,
|
</if>
|
<if test="saveMoneyMonth != null">
|
save_money_month,
|
</if>
|
<if test="co2Month != null">
|
co2_month,
|
</if>
|
<if test="gridEnergyYear != null">
|
grid_energy_year,
|
</if>
|
<if test="saveMoneyYear != null">
|
save_money_year,
|
</if>
|
<if test="co2Year != null">
|
co2_year,
|
</if>
|
<if test="updateTime != null">
|
update_time,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="singlelampDataId != null">
|
#{singlelampDataId,jdbcType=BIGINT},
|
</if>
|
<if test="currError != null">
|
#{currError,jdbcType=DOUBLE},
|
</if>
|
<if test="gridVolt != null">
|
#{gridVolt,jdbcType=DOUBLE},
|
</if>
|
<if test="gridCurr != null">
|
#{gridCurr,jdbcType=DOUBLE},
|
</if>
|
<if test="gridFreq != null">
|
#{gridFreq,jdbcType=DOUBLE},
|
</if>
|
<if test="gridPf != null">
|
#{gridPf,jdbcType=DOUBLE},
|
</if>
|
<if test="gridAp != null">
|
#{gridAp,jdbcType=DOUBLE},
|
</if>
|
<if test="gridRp != null">
|
#{gridRp,jdbcType=DOUBLE},
|
</if>
|
<if test="temperature != null">
|
#{temperature,jdbcType=DOUBLE},
|
</if>
|
<if test="ledDim != null">
|
#{ledDim,jdbcType=DOUBLE},
|
</if>
|
<if test="workTime != null">
|
#{workTime,jdbcType=DOUBLE},
|
</if>
|
<if test="workTimeTotal != null">
|
#{workTimeTotal,jdbcType=DOUBLE},
|
</if>
|
<if test="energyTonight != null">
|
#{energyTonight,jdbcType=DOUBLE},
|
</if>
|
<if test="energyTotal != null">
|
#{energyTotal,jdbcType=DOUBLE},
|
</if>
|
<if test="ledLux != null">
|
#{ledLux,jdbcType=DOUBLE},
|
</if>
|
<if test="ppkToday != null">
|
#{ppkToday,jdbcType=DOUBLE},
|
</if>
|
<if test="ppkHistory != null">
|
#{ppkHistory,jdbcType=DOUBLE},
|
</if>
|
<if test="energyToday != null">
|
#{energyToday,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoney != null">
|
#{saveMoney,jdbcType=DOUBLE},
|
</if>
|
<if test="co2 != null">
|
#{co2,jdbcType=DOUBLE},
|
</if>
|
<if test="energyMonth != null">
|
#{energyMonth,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoneyMonth != null">
|
#{saveMoneyMonth,jdbcType=DOUBLE},
|
</if>
|
<if test="co2Month != null">
|
#{co2Month,jdbcType=DOUBLE},
|
</if>
|
<if test="gridEnergyYear != null">
|
#{gridEnergyYear,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoneyYear != null">
|
#{saveMoneyYear,jdbcType=DOUBLE},
|
</if>
|
<if test="co2Year != null">
|
#{co2Year,jdbcType=DOUBLE},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="api.bean.LampEntity">
|
update pole_singlelamp_data
|
<set>
|
<if test="streetlightId != null">
|
streetlight_id = #{streetlightId,jdbcType=BIGINT},
|
</if>
|
<if test="currError != null">
|
curr_error = #{currError,jdbcType=DOUBLE},
|
</if>
|
<if test="gridVolt != null">
|
grid_volt = #{gridVolt,jdbcType=DOUBLE},
|
</if>
|
<if test="gridCurr != null">
|
grid_curr = #{gridCurr,jdbcType=DOUBLE},
|
</if>
|
<if test="gridFreq != null">
|
grid_freq = #{gridFreq,jdbcType=DOUBLE},
|
</if>
|
<if test="gridPf != null">
|
grid_pf = #{gridPf,jdbcType=DOUBLE},
|
</if>
|
<if test="gridAp != null">
|
grid_ap = #{gridAp,jdbcType=DOUBLE},
|
</if>
|
<if test="gridRp != null">
|
grid_rp = #{gridRp,jdbcType=DOUBLE},
|
</if>
|
<if test="temperature != null">
|
temperature = #{temperature,jdbcType=DOUBLE},
|
</if>
|
<if test="ledDim != null">
|
led_dim = #{ledDim,jdbcType=DOUBLE},
|
</if>
|
<if test="workTime != null">
|
work_time = #{workTime,jdbcType=DOUBLE},
|
</if>
|
<if test="workTimeTotal != null">
|
work_time_total = #{workTimeTotal,jdbcType=DOUBLE},
|
</if>
|
<if test="energyTonight != null">
|
energy_tonight = #{energyTonight,jdbcType=DOUBLE},
|
</if>
|
<if test="energyTotal != null">
|
energy_total = #{energyTotal,jdbcType=DOUBLE},
|
</if>
|
<if test="ledLux != null">
|
led_lux = #{ledLux,jdbcType=DOUBLE},
|
</if>
|
<if test="ppkToday != null">
|
ppk_today = #{ppkToday,jdbcType=DOUBLE},
|
</if>
|
<if test="ppkHistory != null">
|
ppk_history = #{ppkHistory,jdbcType=DOUBLE},
|
</if>
|
<if test="energyToday != null">
|
energy_today = #{energyToday,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoney != null">
|
save_money = #{saveMoney,jdbcType=DOUBLE},
|
</if>
|
<if test="co2 != null">
|
co2 = #{co2,jdbcType=DOUBLE},
|
</if>
|
<if test="energyMonth != null">
|
energy_month = #{energyMonth,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoneyMonth != null">
|
save_money_month = #{saveMoneyMonth,jdbcType=DOUBLE},
|
</if>
|
<if test="co2Month != null">
|
co2_month = #{co2Month,jdbcType=DOUBLE},
|
</if>
|
<if test="gridEnergyYear != null">
|
grid_energy_year = #{gridEnergyYear,jdbcType=DOUBLE},
|
</if>
|
<if test="saveMoneyYear != null">
|
save_money_year = #{saveMoneyYear,jdbcType=DOUBLE},
|
</if>
|
<if test="co2Year != null">
|
co2_year = #{co2Year,jdbcType=DOUBLE},
|
</if>
|
<if test="updateTime != null">
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where singlelamp_data_id = #{singlelampDataId,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="api.bean.LampEntity">
|
update pole_singlelamp_data
|
set streetlight_id = #{streetlightId,jdbcType=BIGINT},
|
curr_error = #{currError,jdbcType=DOUBLE},
|
grid_volt = #{gridVolt,jdbcType=DOUBLE},
|
grid_curr = #{gridCurr,jdbcType=DOUBLE},
|
grid_freq = #{gridFreq,jdbcType=DOUBLE},
|
grid_pf = #{gridPf,jdbcType=DOUBLE},
|
grid_ap = #{gridAp,jdbcType=DOUBLE},
|
grid_rp = #{gridRp,jdbcType=DOUBLE},
|
temperature = #{temperature,jdbcType=DOUBLE},
|
led_dim = #{ledDim,jdbcType=DOUBLE},
|
work_time = #{workTime,jdbcType=DOUBLE},
|
work_time_total = #{workTimeTotal,jdbcType=DOUBLE},
|
energy_tonight = #{energyTonight,jdbcType=DOUBLE},
|
energy_total = #{energyTotal,jdbcType=DOUBLE},
|
led_lux = #{ledLux,jdbcType=DOUBLE},
|
ppk_today = #{ppkToday,jdbcType=DOUBLE},
|
ppk_history = #{ppkHistory,jdbcType=DOUBLE},
|
energy_today = #{energyToday,jdbcType=DOUBLE},
|
save_money = #{saveMoney,jdbcType=DOUBLE},
|
co2 = #{co2,jdbcType=DOUBLE},
|
energy_month = #{energyMonth,jdbcType=DOUBLE},
|
save_money_month = #{saveMoneyMonth,jdbcType=DOUBLE},
|
co2_month = #{co2Month,jdbcType=DOUBLE},
|
grid_energy_year = #{gridEnergyYear,jdbcType=DOUBLE},
|
save_money_year = #{saveMoneyYear,jdbcType=DOUBLE},
|
co2_year = #{co2Year,jdbcType=DOUBLE},
|
update_time = #{updateTime,jdbcType=TIMESTAMP}
|
where singlelamp_data_id = #{singlelampDataId,jdbcType=BIGINT}
|
</update>
|
</mapper>
|