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

优化sql

parent 5f692fea
...@@ -72,7 +72,7 @@ public interface JpStationMapper extends BaseMapper<JpStation> { ...@@ -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") @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); 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<JpStationDto> queryForDealerReviewPagenew(@Param("dto") JpStationDto reviewDto);
List<DropDown> getDealerNew(@Param("regionalCompaniesSeq") String regionalCompaniesSeq); List<DropDown> getDealerNew(@Param("regionalCompaniesSeq") String regionalCompaniesSeq);
......
...@@ -625,102 +625,110 @@ ...@@ -625,102 +625,110 @@
select select
`sequence_nbr` sequenceNbr, hjs.sequence_nbr sequenceNbr,
`rec_date` recDate, hjs.rec_date recDate,
`rec_user_id` recUserId, hjs.rec_user_id recUserId,
`rec_user_name` recUserName, hjs.rec_user_name recUserName,
hygf_jp_station.sn_code snCode, hjs.regional_companies_code,
CAST( (FLOOR(`capacity` * 1000) / 1000) AS DECIMAL(20, 3)) capacity, hjs.amos_company_code,
`name` , hjs.sn_code snCode,
`code` , CAST( (FLOOR(hjs.capacity * 1000) / 1000) AS DECIMAL(20, 3)) capacity,
`system_code` systemCode, hjs.name ,
`access_time` accessTime, hjs.code ,
`create_time` createTime, hjs.system_code systemCode,
`address` , hjs.access_time accessTime,
`longitude` , hjs.create_time createTime,
`latitude` , hjs.address ,
`price` , hjs.longitude ,
`user_name` userName, hjs.latitude ,
`user_phone` userPhone, hjs.price ,
`station_contact` stationContact, hjs.user_name userName,
`module_count` moduleCount, hjs.user_phone userPhone,
`on_grid_type` onGridType, hjs.station_contact stationContact,
`on_grid_time` onGridTime, hjs.module_count moduleCount,
hygf_jp_station.third_station_id thirdStationId, hjs.on_grid_type onGridType,
`third_code` thirdCode, hjs.on_grid_time onGridTime,
`station_id` stationId, hjs.third_station_id thirdStationId,
`day_power_use` dayPowerUse, hjs.third_code thirdCode,
`month_power_use` monthPowerUse, hjs.station_id stationId,
`year_power_use` yearPowerUse, hjs.day_power_use dayPowerUse,
CAST( (FLOOR(`real_time_power` * 1000) / 1000) AS DECIMAL(20, 3)) realTimePower, hjs.month_power_use monthPowerUse,
CAST( (FLOOR(`accumulated_power`/1000 * 1000) / 1000) AS DECIMAL(20, 3)) accumulatedPower, hjs.year_power_use yearPowerUse,
`state` , CAST( (FLOOR(hjs.real_time_power * 1000) / 1000) AS DECIMAL(20, 3)) realTimePower,
`type`, CAST( (FLOOR(hjs.accumulated_power/1000 * 1000) / 1000) AS DECIMAL(20, 3)) accumulatedPower,
`organizational_code` organizationalCode, hjs.state,
`is_delete` isDelete, hjs.type,
CAST( (FLOOR(`day_generate` * 1000) / 1000) AS DECIMAL(20, 3)) dayGenerate, hjs.organizational_code organizationalCode,
CAST( (FLOOR(`month_generate` * 1000) / 1000) AS DECIMAL(20, 3)) monthGenerate, hjs.is_delete isDelete,
CAST( (FLOOR(`year_generate` * 1000) / 1000) AS DECIMAL(20, 3)) yearGenerate, CAST( (FLOOR(hjs.day_generate * 1000) / 1000) AS DECIMAL(20, 3)) dayGenerate,
`day_income` dayIncome, CAST( (FLOOR(hjs.month_generate * 1000) / 1000) AS DECIMAL(20, 3)) monthGenerate,
`month_income` monthIncome, CAST( (FLOOR(hjs.year_generate * 1000) / 1000) AS DECIMAL(20, 3)) yearGenerate,
`year_income` yearIncome, hjs.day_income dayIncome,
`area` , hjs.month_income monthIncome,
`cumulative_income` cumulativeIncome, hjs.year_income yearIncome,
`email`, hjs.area ,
rated_power ratedPower, hjs.cumulative_income cumulativeIncome,
CAST( (FLOOR(`day_generate`/capacity * 1000) / 1000) AS DECIMAL(20, 3)) fullhour, 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 (select privilege_company.COMPANY_NAME from privilege_company where
privilege_company.ORG_CODE=hygf_jp_station.regional_companies_code) regionalCompaniesName, privilege_company.ORG_CODE=hjs.regional_companies_code) regionalCompaniesName,
newTable.sn_code nbqSnCode lc.nbqSnCode
from hygf_jp_station from hygf_jp_station hjs
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 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> <where>
<if test="dto.name!=null"> <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>
<if test="dto.userName!=null"> <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>
<if test="dto.address!=null"> <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>
<if test="dto.area!=null"> <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>
<if test="dto.statioId!=null"> <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=")"> <foreach collection="dto.statioId" item="item" index="index" open="(" separator="," close=")">
#{item.stationId} #{item.stationId}
</foreach> </foreach>
</if> </if>
<if test="dto.thirdStationId!=null"> <if test="dto.thirdStationId!=null">
and hygf_jp_station.third_station_id =#{dto.thirdStationId} and hjs.third_station_id =#{dto.thirdStationId}
</if> </if>
<if test="dto.type!=null and dto.type!=''"> <if test="dto.type!=null and dto.type!=''">
and hygf_jp_station.type =#{dto.type} and hjs.type =#{dto.type}
</if> </if>
<if test="dto.regionalCompaniesCode!=null"> <if test="dto.regionalCompaniesCode!=null">
and hygf_jp_station.regional_companies_code =#{dto.regionalCompaniesCode} and hjs.regional_companies_code =#{dto.regionalCompaniesCode}
</if> </if>
<if test="dto.state!=null"> <if test="dto.state!=null">
and hygf_jp_station.state =#{dto.state} and hjs.state =#{dto.state}
</if> </if>
<if test="dto.amosCompanyCode!=null"> <if test="dto.amosCompanyCode!=null">
and hygf_jp_station.amos_company_code =#{dto.amosCompanyCode} and hjs.amos_company_code =#{dto.amosCompanyCode}
</if> </if>
<if test="dto.nbqSnCode!=null"> <if test="dto.nbqSnCode!=null">
and newTable.sn_code =#{dto.nbqSnCode} and lc.nbqSnCode like concat('%',#{dto.nbqSnCode},'%')
</if> </if>
</where> </where>
ORDER BY CASE ORDER BY CASE
WHEN state = '报警' THEN 1 WHEN hjs.state = '报警' THEN 1
WHEN state = '离线' THEN 2 WHEN hjs.state = '离线' THEN 2
WHEN state = '在线' THEN 3 WHEN hjs.state = '在线' THEN 3
ELSE 4 ELSE 4
END END
</select> </select>
<!-- ========电站监控区域=======--> <!-- ========电站监控区域=======-->
<!-- <select id="getRegionPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationStatistics">--> <!-- <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