<?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.PhotovoltaicHeartDataDao">
|
|
<select id="findAllBySort" resultType="api.bean.PhotovoltaicHeartData">
|
|
select
|
ps.streetlight_name ,
|
ps.streetlight_id,
|
pe.photovoltaic_name,
|
pe.photovoltaic_id,
|
phd.*
|
from
|
pole_streetlight ps
|
right join
|
(
|
select
|
*
|
from
|
photovoltaic_heart_data
|
join
|
(
|
select
|
max(photovoltaic_heart_data_id) as id
|
from
|
photovoltaic_heart_data
|
group by
|
streetlight_mac
|
limit #{page},#{size}
|
) a
|
on
|
photovoltaic_heart_data_id = a.id ) phd
|
on
|
phd.streetlight_mac = ps.code_number
|
join
|
photovoltaic_entity pe
|
on
|
pe.bind_pole_streelight_id = streetlight_id
|
<if test="field != null and field != ''">
|
ORDER BY ${field}
|
<if test="sort != null and sort != ''">${sort}</if>
|
</if>
|
|
</select>
|
|
<select id="findByCompanyBySort" resultType="api.bean.PhotovoltaicHeartData">
|
|
|
select
|
*
|
from
|
photovoltaic_heart_data phd
|
join
|
(
|
select
|
*
|
from
|
(
|
select
|
ps.streetlight_id ,
|
ps.streetlight_name,
|
ps.code_number
|
from
|
pole_streetlight ps
|
where
|
ps.streetlight_id in (
|
select
|
pus.streetlight_id
|
from
|
pole_user_streetlight pus
|
where
|
pus.company_id in(
|
select
|
suc.company_id
|
from
|
sys_user_company suc
|
where
|
suc.user_id =
|
#{userId}
|
)
|
)
|
limit #{page},#{size}) streetlight
|
join
|
(
|
select
|
max(photovoltaic_heart_data_id) as maxid,
|
streetlight_mac
|
from
|
photovoltaic_heart_data
|
group by
|
streetlight_mac
|
) a
|
on
|
a.streetlight_mac = streetlight.code_number)
|
b
|
on
|
b.maxid = phd.photovoltaic_heart_data_id
|
join
|
photovoltaic_entity pe
|
on
|
pe.bind_pole_streelight_id = streetlight_id
|
</select>
|
|
|
|
|
|
<select id="findByPhotovoltaicId" resultType="api.bean.PhotovoltaicHeartData">
|
select
|
ps.streetlight_name ,
|
ps.streetlight_id,
|
phd.*,
|
pe.photovoltaic_name,
|
pe.photovoltaic_id
|
from
|
pole_streetlight ps
|
right join
|
(
|
select
|
*
|
from
|
photovoltaic_heart_data
|
) phd
|
on
|
phd.streetlight_mac = ps.code_number
|
join
|
photovoltaic_entity pe
|
on
|
pe.bind_pole_streelight_id = streetlight_id
|
where ps.streetlight_id in (
|
select pe.bind_pole_streelight_id from photovoltaic_entity pe where pe.photovoltaic_id = #{photovoltaicId})
|
order by photovoltaic_heart_data_id desc
|
</select>
|
|
</mapper>
|