单体电池添加入参site_id

This commit is contained in:
2025-06-30 22:22:47 +08:00
parent 93bd88b94c
commit 8663ab8325
7 changed files with 48 additions and 21 deletions

View File

@ -110,10 +110,10 @@ public class EmsSiteMonitorController extends BaseController{
* 获取电池簇下面的单体电池数据 * 获取电池簇下面的单体电池数据
*/ */
@GetMapping("/getClusterDataInfoList") @GetMapping("/getClusterDataInfoList")
public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId) public TableDataInfo getClusterDataInfoList(@RequestParam String clusterDeviceId,@RequestParam String siteId)
{ {
startPage(); startPage();
List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId); List<BatteryDataStatsListVo> list = iSingleSiteService.getClusterDataInfoList(clusterDeviceId,siteId);
return getDataTable(list); return getDataTable(list);
} }

View File

@ -91,7 +91,7 @@ public interface EmsBatteryDataMapper
* @param clusterDeviceId * @param clusterDeviceId
* @return * @return
*/ */
public List<BatteryDataStatsListVo> getAllBatteryDataByClusterId(String clusterDeviceId); public List<BatteryDataStatsListVo> getAllBatteryDataByClusterId(@Param("clusterDeviceId") String clusterDeviceId,@Param("siteId") String siteId);
int insertEmsBatteryDataList(List<EmsBatteryData> emsBatteryDataList); int insertEmsBatteryDataList(List<EmsBatteryData> emsBatteryDataList);

View File

@ -1,6 +1,7 @@
package com.xzzn.ems.mapper; package com.xzzn.ems.mapper;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -99,4 +100,12 @@ public interface EmsPcsDataMapper
* @return * @return
*/ */
public Map<String, BigDecimal> getPcsTotalChargeData(String siteId); public Map<String, BigDecimal> getPcsTotalChargeData(String siteId);
/**
* 根据时间按天获取充放电量
* @param startDate
* @param endDate
* @return
*/
public List<SiteMonitorDataVo> getPcsDataByDate(Date startDate, Date endDate);
} }

View File

@ -27,7 +27,7 @@ public interface ISingleSiteService
public List<EmsCoolingData> getCoolingDataList(String siteId); public List<EmsCoolingData> getCoolingDataList(String siteId);
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId); public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId);
public List<AmmeterDataVo> getAmmeterDataList(String siteId); public List<AmmeterDataVo> getAmmeterDataList(String siteId);
} }

View File

@ -242,9 +242,9 @@ public class SingleSiteServiceImpl implements ISingleSiteService {
* @return * @return
*/ */
@Override @Override
public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId) { public List<BatteryDataStatsListVo> getClusterDataInfoList(String clusterDeviceId,String siteId) {
List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>(); List<BatteryDataStatsListVo> batteryDataStatsListVo = new ArrayList<>();
batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId); batteryDataStatsListVo = emsBatteryDataMapper.getAllBatteryDataByClusterId(clusterDeviceId,siteId);
return batteryDataStatsListVo; return batteryDataStatsListVo;
} }

View File

@ -177,21 +177,22 @@
SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0 SELECT NULL AS type, NULL AS device_id FROM DUAL WHERE 1=0
</select> </select>
<select id="getAllBatteryDataByClusterId" parameterType="String" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo"> <select id="getAllBatteryDataByClusterId" resultType="com.xzzn.ems.domain.vo.BatteryDataStatsListVo">
SELECT SELECT t.update_time as updateTime, t.voltage, t.temperature,
update_time as updateTime, t.soc, t.soh, t.device_id as deviceId
voltage, temperature, soc, soh, FROM ems_battery_data t
device_id as deviceId JOIN ( SELECT device_id, MAX(update_time) AS max_update_time
FROM ( FROM ems_battery_data
SELECT WHERE site_id = #{siteId}
t.update_time, t.voltage, t.temperature, t.soc, t.soh, t.device_id, <if test="clusterDeviceId != null and clusterDeviceId != ''">
ROW_NUMBER() OVER ( and cluster_device_id = #{clusterDeviceId}
PARTITION BY t.device_id ORDER BY t.update_time DESC </if>
) AS rn GROUP BY device_id
FROM ems_battery_data t ) latest ON t.device_id = latest.device_id AND t.update_time = latest.max_update_time
WHERE t.cluster_device_id = #{clusterDeviceId} WHERE t.site_id = #{siteId}
) ranked <if test="clusterDeviceId != null and clusterDeviceId != ''">
WHERE rn = 1 and t.cluster_device_id = #{clusterDeviceId}
</if>
</select> </select>

View File

@ -371,4 +371,21 @@
WHERE tmp.site_id = #{siteId} WHERE tmp.site_id = #{siteId}
order by tmp.device_id order by tmp.device_id
</select> </select>
<select id="getPcsDataByDate" resultType="com.xzzn.ems.domain.vo.SiteMonitorDataVo">
select CONCAT(t.date_month,'/',t.date_day) as ammeterDate,
sum(t.daily_ac_charge_energy) as chargedCap,
sum(t.daily_ac_discharge_energy) as disChargedCap
from ( SELECT p.site_id, p.device_id,p.date_month,p.date_day, MAX(p.data_update_time) AS max_update_time
FROM ems_pcs_data p
where p.site_id = #{siteId}
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
) latest inner join ems_pcs_data t ON latest.site_id = t.site_id
AND latest.device_id = t.device_id
AND latest.max_update_time = t.data_update_time
and latest.date_month = t.date_month
and latest.date_day = t.date_day
group by ammeterDate
order by ammeterDate desc
</select>
</mapper> </mapper>