概率统计-电量指标默认7天
This commit is contained in:
@ -1,16 +1,21 @@
|
||||
package com.xzzn.ems.service.impl;
|
||||
|
||||
import com.xzzn.common.utils.DateUtils;
|
||||
import com.xzzn.ems.domain.vo.DateSearchRequest;
|
||||
import com.xzzn.ems.domain.vo.ElectricDataInfoVo;
|
||||
import com.xzzn.ems.domain.vo.SiteMonitorDataVo;
|
||||
import com.xzzn.ems.mapper.EmsPcsDataMapper;
|
||||
import com.xzzn.ems.service.IEmsStatsReportService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -23,6 +28,8 @@ import java.util.List;
|
||||
public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
{
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EmsStatsReportServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmsPcsDataMapper emsPcsDataMapper;
|
||||
|
||||
@ -30,6 +37,14 @@ public class EmsStatsReportServiceImpl implements IEmsStatsReportService
|
||||
public ElectricDataInfoVo getElectricDataResult(DateSearchRequest requestVo) {
|
||||
ElectricDataInfoVo electricDataInfoVo = new ElectricDataInfoVo();
|
||||
|
||||
Date startDate = requestVo.getStartDate();
|
||||
Date endDate = requestVo.getEndDate();
|
||||
if (startDate == null && endDate == null) {
|
||||
// 如果没有传时间,默认从今天往前7天
|
||||
LocalDate sevenDaysAgo = LocalDate.now().minusDays(6);
|
||||
startDate = DateUtils.toDate(sevenDaysAgo);
|
||||
requestVo.setStartDate(startDate);
|
||||
}
|
||||
// 根据时间获取每天的充放电量
|
||||
List<SiteMonitorDataVo> dataList = emsPcsDataMapper.getPcsDataByDate(requestVo);
|
||||
if (!CollectionUtils.isEmpty(dataList)){
|
||||
|
@ -379,8 +379,10 @@
|
||||
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}
|
||||
<if test="startDate != null and endDate != null">
|
||||
<if test="startDate != null">
|
||||
and p.data_update_time >= #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
and p.data_update_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
|
||||
</if>
|
||||
GROUP BY p.site_id,p.device_id,p.date_month,p.date_day
|
||||
|
Reference in New Issue
Block a user