Commit 60159a3d authored by 朱晨阳's avatar 朱晨阳

优化sql

parent 5f692fea
......@@ -72,7 +72,7 @@ public interface JpStationMapper extends BaseMapper<JpStation> {
@UserEmpower(field ={"regional_companies_code"} ,dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
Map<String,Object> getcount( @Param("dto") JpStationDto reviewDto);
@UserEmpower(field ={"hygf_jp_station.regional_companies_code"},dealerField ={"hygf_jp_station.amos_company_code","hygf_jp_station.regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<JpStationDto> queryForDealerReviewPagenew(@Param("dto") JpStationDto reviewDto);
List<DropDown> getDealerNew(@Param("regionalCompaniesSeq") String regionalCompaniesSeq);
......
......@@ -625,102 +625,110 @@
select
`sequence_nbr` sequenceNbr,
`rec_date` recDate,
`rec_user_id` recUserId,
`rec_user_name` recUserName,
hygf_jp_station.sn_code snCode,
CAST( (FLOOR(`capacity` * 1000) / 1000) AS DECIMAL(20, 3)) capacity,
`name` ,
`code` ,
`system_code` systemCode,
`access_time` accessTime,
`create_time` createTime,
`address` ,
`longitude` ,
`latitude` ,
`price` ,
`user_name` userName,
`user_phone` userPhone,
`station_contact` stationContact,
`module_count` moduleCount,
`on_grid_type` onGridType,
`on_grid_time` onGridTime,
hygf_jp_station.third_station_id thirdStationId,
`third_code` thirdCode,
`station_id` stationId,
`day_power_use` dayPowerUse,
`month_power_use` monthPowerUse,
`year_power_use` yearPowerUse,
CAST( (FLOOR(`real_time_power` * 1000) / 1000) AS DECIMAL(20, 3)) realTimePower,
CAST( (FLOOR(`accumulated_power`/1000 * 1000) / 1000) AS DECIMAL(20, 3)) accumulatedPower,
`state` ,
`type`,
`organizational_code` organizationalCode,
`is_delete` isDelete,
CAST( (FLOOR(`day_generate` * 1000) / 1000) AS DECIMAL(20, 3)) dayGenerate,
CAST( (FLOOR(`month_generate` * 1000) / 1000) AS DECIMAL(20, 3)) monthGenerate,
CAST( (FLOOR(`year_generate` * 1000) / 1000) AS DECIMAL(20, 3)) yearGenerate,
`day_income` dayIncome,
`month_income` monthIncome,
`year_income` yearIncome,
`area` ,
`cumulative_income` cumulativeIncome,
`email`,
rated_power ratedPower,
CAST( (FLOOR(`day_generate`/capacity * 1000) / 1000) AS DECIMAL(20, 3)) fullhour,
hjs.sequence_nbr sequenceNbr,
hjs.rec_date recDate,
hjs.rec_user_id recUserId,
hjs.rec_user_name recUserName,
hjs.regional_companies_code,
hjs.amos_company_code,
hjs.sn_code snCode,
CAST( (FLOOR(hjs.capacity * 1000) / 1000) AS DECIMAL(20, 3)) capacity,
hjs.name ,
hjs.code ,
hjs.system_code systemCode,
hjs.access_time accessTime,
hjs.create_time createTime,
hjs.address ,
hjs.longitude ,
hjs.latitude ,
hjs.price ,
hjs.user_name userName,
hjs.user_phone userPhone,
hjs.station_contact stationContact,
hjs.module_count moduleCount,
hjs.on_grid_type onGridType,
hjs.on_grid_time onGridTime,
hjs.third_station_id thirdStationId,
hjs.third_code thirdCode,
hjs.station_id stationId,
hjs.day_power_use dayPowerUse,
hjs.month_power_use monthPowerUse,
hjs.year_power_use yearPowerUse,
CAST( (FLOOR(hjs.real_time_power * 1000) / 1000) AS DECIMAL(20, 3)) realTimePower,
CAST( (FLOOR(hjs.accumulated_power/1000 * 1000) / 1000) AS DECIMAL(20, 3)) accumulatedPower,
hjs.state,
hjs.type,
hjs.organizational_code organizationalCode,
hjs.is_delete isDelete,
CAST( (FLOOR(hjs.day_generate * 1000) / 1000) AS DECIMAL(20, 3)) dayGenerate,
CAST( (FLOOR(hjs.month_generate * 1000) / 1000) AS DECIMAL(20, 3)) monthGenerate,
CAST( (FLOOR(hjs.year_generate * 1000) / 1000) AS DECIMAL(20, 3)) yearGenerate,
hjs.day_income dayIncome,
hjs.month_income monthIncome,
hjs.year_income yearIncome,
hjs.area ,
hjs.cumulative_income cumulativeIncome,
hjs.email,
hjs.rated_power ratedPower,
CAST( (FLOOR(hjs.day_generate/hjs.capacity * 1000) / 1000) AS DECIMAL(20, 3)) fullhour,
(select privilege_company.COMPANY_NAME from privilege_company where
privilege_company.ORG_CODE=hygf_jp_station.regional_companies_code) regionalCompaniesName,
newTable.sn_code nbqSnCode
from hygf_jp_station
left join (select hygf_jp_inverter.sn_code, hygf_jp_inverter.third_station_id from hygf_jp_station left join hygf_jp_inverter on hygf_jp_station.third_station_id = hygf_jp_inverter.third_station_id) newTable on hygf_jp_station.third_station_id = newTable.third_station_id
privilege_company.ORG_CODE=hjs.regional_companies_code) regionalCompaniesName,
lc.nbqSnCode
from hygf_jp_station hjs
INNER join
(
select MAX(hjs.sequence_nbr) AS sequence_nbr,group_concat(hji.sn_code) AS nbqSnCode from hygf_jp_station hjs left join hygf_jp_inverter hji on hjs.third_station_id = hji.third_station_id
group by hjs.third_station_id
) lc
on hjs.sequence_nbr = lc.sequence_nbr
<where>
<if test="dto.name!=null">
and hygf_jp_station.name like concat(concat('%',#{dto.name}),'%')
and hjs.name like concat(concat('%',#{dto.name}),'%')
</if>
<if test="dto.userName!=null">
and hygf_jp_station.user_name like concat(concat('%',#{dto.userName}),'%')
and hjs.user_name like concat(concat('%',#{dto.userName}),'%')
</if>
<if test="dto.address!=null">
and hygf_jp_station.address like concat(concat('%',#{dto.address}),'%')
and hjs.address like concat(concat('%',#{dto.address}),'%')
</if>
<if test="dto.area!=null">
and hygf_jp_station.area like concat(concat('%',#{dto.area}),'%')
and hjs.area like concat(concat('%',#{dto.area}),'%')
</if>
<if test="dto.statioId!=null">
and hygf_jp_station.third_station_id in
and hjs.third_station_id in
<foreach collection="dto.statioId" item="item" index="index" open="(" separator="," close=")">
#{item.stationId}
</foreach>
</if>
<if test="dto.thirdStationId!=null">
and hygf_jp_station.third_station_id =#{dto.thirdStationId}
and hjs.third_station_id =#{dto.thirdStationId}
</if>
<if test="dto.type!=null and dto.type!=''">
and hygf_jp_station.type =#{dto.type}
and hjs.type =#{dto.type}
</if>
<if test="dto.regionalCompaniesCode!=null">
and hygf_jp_station.regional_companies_code =#{dto.regionalCompaniesCode}
and hjs.regional_companies_code =#{dto.regionalCompaniesCode}
</if>
<if test="dto.state!=null">
and hygf_jp_station.state =#{dto.state}
and hjs.state =#{dto.state}
</if>
<if test="dto.amosCompanyCode!=null">
and hygf_jp_station.amos_company_code =#{dto.amosCompanyCode}
and hjs.amos_company_code =#{dto.amosCompanyCode}
</if>
<if test="dto.nbqSnCode!=null">
and newTable.sn_code =#{dto.nbqSnCode}
and lc.nbqSnCode like concat('%',#{dto.nbqSnCode},'%')
</if>
</where>
ORDER BY CASE
WHEN state = '报警' THEN 1
WHEN state = '离线' THEN 2
WHEN state = '在线' THEN 3
WHEN hjs.state = '报警' THEN 1
WHEN hjs.state = '离线' THEN 2
WHEN hjs.state = '在线' THEN 3
ELSE 4
END
</select>
<!-- ========电站监控区域=======-->
<!-- <select id="getRegionPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationStatistics">-->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment