|
|
|
@ -49,15 +49,15 @@ public class PsdcElectricHtdataServiceImpl implements IPsdcElectricHtdataService |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public Map selTotalElectricityInfo() { |
|
|
|
|
public Map selTotalElectricityInfo(Integer deviceID) { |
|
|
|
|
Date date = new Date(); |
|
|
|
|
Map<String, Double> map = new HashMap<>(); |
|
|
|
|
String tb = df.format(date) + " 00:00:00"; // 今天开始检索时间
|
|
|
|
|
String te = df.format(date) + " 23:59:59"; // 今天结束检索时间
|
|
|
|
|
String mb = benYue()[0] + " 00:00:00"; // 本月开始检索时间
|
|
|
|
|
String me = benYue()[1] + " 23:59:59"; // 本月结束检索时间
|
|
|
|
|
Double todayUseElectric = electricHtdataMapper.selTodayUseEnergy(13, tb, te);// 总电表今日用电量
|
|
|
|
|
Double toMonthUseElectric = electricHtdataMapper.selTodayUseEnergy(13, mb, me);// 总电表本月用电量
|
|
|
|
|
Double todayUseElectric = electricHtdataMapper.selTodayUseEnergy(deviceID, tb, te);// 总电表今日用电量
|
|
|
|
|
Double toMonthUseElectric = electricHtdataMapper.selTodayUseEnergy(deviceID, mb, me);// 总电表本月用电量
|
|
|
|
|
map.put("eday", todayUseElectric); |
|
|
|
|
map.put("emonth", toMonthUseElectric); |
|
|
|
|
return map; |
|
|
|
@ -158,15 +158,15 @@ public class PsdcElectricHtdataServiceImpl implements IPsdcElectricHtdataService |
|
|
|
|
Date yesterday = calendar.getTime(); |
|
|
|
|
List<PsdcElectricHtdata> psdcElectricHtdatas = electricHtdataMapper.statisticalGroupByTime(simpleDateFormat.format(yesterday)); |
|
|
|
|
|
|
|
|
|
//月点位
|
|
|
|
|
// 月点位
|
|
|
|
|
String monthPoint = "day_" + dayDateFormat.format(yesterday); |
|
|
|
|
String yearPoint = "month_" + monthDateFormat.format(yesterday); |
|
|
|
|
for (PsdcElectricHtdata psdcElectricHtdata: psdcElectricHtdatas) { |
|
|
|
|
//先查询是否有该id当月数据
|
|
|
|
|
// 先查询是否有该id当月数据
|
|
|
|
|
Integer deviceId = psdcElectricHtdata.getDeviceId(); |
|
|
|
|
PsdcStatisticsMonth psdcStatisticsMonth = psdcStatisticsMonthMapper.queryByDeviceIdAndDate(deviceId,yearMonthDateFormat.format(yesterday)); |
|
|
|
|
if (psdcStatisticsMonth == null){ |
|
|
|
|
//插入
|
|
|
|
|
// 插入
|
|
|
|
|
PsdcStatisticsMonth newPsdcStatisticsMonth = new PsdcStatisticsMonth(); |
|
|
|
|
newPsdcStatisticsMonth.setMonthDate(simpleDateFormat.format(yesterday)); |
|
|
|
|
newPsdcStatisticsMonth.setDeviceId(deviceId); |
|
|
|
@ -175,17 +175,17 @@ public class PsdcElectricHtdataServiceImpl implements IPsdcElectricHtdataService |
|
|
|
|
Integer monthId = newPsdcStatisticsMonth.getMonthId(); |
|
|
|
|
psdcStatisticsMonthMapper.updatePoint(monthPoint,psdcElectricHtdata.getUseDeiffen(),monthId); |
|
|
|
|
} else { |
|
|
|
|
//更新
|
|
|
|
|
// 更新
|
|
|
|
|
psdcStatisticsMonthMapper.updatePoint(monthPoint,psdcElectricHtdata.getUseDeiffen(),psdcStatisticsMonth.getMonthId() |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//每月数据
|
|
|
|
|
//先查询该id今年每月数据
|
|
|
|
|
// 每月数据
|
|
|
|
|
// 先查询该id今年每月数据
|
|
|
|
|
PsdcStatisticsYear psdcStatisticsYear = psdcStatisticsYearMapper.queryByDeviceIdAndDate(deviceId, yearMonthDateFormat.format(yesterday)); |
|
|
|
|
Double aDouble = psdcStatisticsMonthMapper.queryOneLineSum(deviceId, yearMonthDateFormat.format(yesterday)); |
|
|
|
|
if (psdcStatisticsYear == null){ |
|
|
|
|
//插入
|
|
|
|
|
// 插入
|
|
|
|
|
PsdcStatisticsYear newPsdcStatisticsYear = new PsdcStatisticsYear(); |
|
|
|
|
newPsdcStatisticsYear.setYearDate(simpleDateFormat.format(yesterday)); |
|
|
|
|
newPsdcStatisticsYear.setDeviceId(deviceId); |
|
|
|
@ -194,7 +194,7 @@ public class PsdcElectricHtdataServiceImpl implements IPsdcElectricHtdataService |
|
|
|
|
Integer yearId = newPsdcStatisticsYear.getYearId(); |
|
|
|
|
psdcStatisticsYearMapper.updatePoint(yearPoint,aDouble,yearId); |
|
|
|
|
} else { |
|
|
|
|
//更新
|
|
|
|
|
// 更新
|
|
|
|
|
psdcStatisticsYearMapper.updatePoint(yearPoint,aDouble,psdcStatisticsYear.getYearId()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|