|
@@ -8,7 +8,8 @@ import com.bizmatics.common.mvc.base.AbstractCrudService;
|
|
|
import com.bizmatics.service.util.Arith;
|
|
|
import com.bizmatics.service.util.SessionLocal;
|
|
|
import com.bizmatics.service.vo.CommonIcoVO;
|
|
|
-import com.bizmatics.service.vo.CommonTotalVO;
|
|
|
+import com.bizmatics.service.vo.HadCountVO;
|
|
|
+import com.bizmatics.service.vo.TimeShareVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -29,17 +30,14 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
private HtAnalogDataMapper htAnalogDataMapper;
|
|
|
|
|
|
@Override
|
|
|
- public List<CommonTotalVO> selectCount() {
|
|
|
+ public HadCountVO selectCount() {
|
|
|
Integer userId = SessionLocal.getUserId();
|
|
|
Date date = new Date();
|
|
|
- List<CommonTotalVO> list = new ArrayList<>();
|
|
|
- list.add(CommonTotalVO.builder().name("day")
|
|
|
- .objectData(getElectricity(userId,null,DateUtils.getDayStartTime(date),date)).build());
|
|
|
- list.add(CommonTotalVO.builder().name("month")
|
|
|
- .objectData(getElectricity(userId,null,DateUtils.getFirstDayOfMonth(date),date)).build());
|
|
|
- list.add(CommonTotalVO.builder().name("year")
|
|
|
- .objectData(getElectricity(userId,null,DateUtils.getBeginDayOfYear(date),date)).build());
|
|
|
- return list;
|
|
|
+ HadCountVO hadCountVO = new HadCountVO();
|
|
|
+ hadCountVO.setDayCount(getElectricity(userId,null,DateUtils.getDayStartTime(date),date));
|
|
|
+ hadCountVO.setMonthCount(getElectricity(userId,null,DateUtils.getFirstDayOfMonth(date),date));
|
|
|
+ hadCountVO.setYearCount(getElectricity(userId,null,DateUtils.getBeginDayOfYear(date),date));
|
|
|
+ return hadCountVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -52,7 +50,7 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CommonTotalVO> getCountBySite(Integer siteId) {
|
|
|
+ public HadCountVO getCountBySite(Integer siteId) {
|
|
|
Date date = new Date();
|
|
|
Integer userId = SessionLocal.getUserId();
|
|
|
//当日开始时间
|
|
@@ -61,70 +59,35 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
Date firstDayOfMonth = DateUtils.getFirstDayOfMonth(date);
|
|
|
//当年开始时间
|
|
|
Date firstDayOfYear = DateUtils.getBeginDayOfYear(date);
|
|
|
- Double dayCount = getElectricity(userId,siteId,firstDayOfDate,date);
|
|
|
- Double monthCount = getElectricity(userId,siteId,firstDayOfMonth,date);
|
|
|
- Double yearCount = getElectricity(userId,siteId,firstDayOfYear,date);
|
|
|
- Double lastDayCount = getElectricity(userId,siteId,DateUtils.addDays(firstDayOfDate, -1),DateUtils.addDays(date, -1));
|
|
|
- Double lastMonthCount = getElectricity(userId,siteId,DateUtils.addMonths(firstDayOfMonth, -1),DateUtils.addMonths(date, -1));
|
|
|
- Double lastYearCount = getElectricity(userId,siteId,DateUtils.addYears(firstDayOfYear, -1),DateUtils.addYears(date, -1));
|
|
|
-
|
|
|
- List<CommonTotalVO> list = new ArrayList<>();
|
|
|
-
|
|
|
- list.add(CommonTotalVO.builder().name("day")
|
|
|
- .objectData(dayCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("month")
|
|
|
- .objectData(monthCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("year")
|
|
|
- .objectData(yearCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("lastDay")
|
|
|
- .objectData(lastDayCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("lastMonth")
|
|
|
- .objectData(lastMonthCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("lastYear")
|
|
|
- .objectData(lastYearCount)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("dayRadio")
|
|
|
- .objectData(Arith.div(lastDayCount,dayCount))
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("monthRadio")
|
|
|
- .objectData(Arith.div(lastMonthCount,monthCount))
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("yearRadio")
|
|
|
- .objectData(Arith.div(lastYearCount,yearCount))
|
|
|
- .build());
|
|
|
- return list;
|
|
|
+ HadCountVO hadCountVO = new HadCountVO();
|
|
|
+ hadCountVO.setDayCount(getElectricity(userId,siteId,firstDayOfDate,date));
|
|
|
+ hadCountVO.setMonthCount(getElectricity(userId,siteId,firstDayOfMonth,date));
|
|
|
+ hadCountVO.setYearCount(getElectricity(userId,siteId,firstDayOfYear,date));
|
|
|
+ hadCountVO.setLastDayCount(getElectricity(userId,siteId,DateUtils.addDays(firstDayOfDate, -1),DateUtils.addDays(date, -1)));
|
|
|
+ hadCountVO.setLastMonthCount(getElectricity(userId,siteId,DateUtils.addMonths(firstDayOfMonth, -1),DateUtils.addMonths(date, -1)));
|
|
|
+ hadCountVO.setLastYearCount(getElectricity(userId,siteId,DateUtils.addYears(firstDayOfYear, -1),DateUtils.addYears(date, -1)));
|
|
|
+ hadCountVO.setDayRadio(Arith.div(hadCountVO.getLastDayCount(),hadCountVO.getDayCount()));
|
|
|
+ hadCountVO.setMonthRadio(Arith.div(hadCountVO.getLastMonthCount(),hadCountVO.getMonthCount()));
|
|
|
+ hadCountVO.setYearRadio(Arith.div(hadCountVO.getLastYearCount(),hadCountVO.getYearCount()));
|
|
|
+ return hadCountVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<CommonTotalVO> getTimeShare(Integer siteId,Date date) {
|
|
|
+ public TimeShareVO getTimeShare(Integer siteId, Date date) {
|
|
|
Integer userId = SessionLocal.getUserId();
|
|
|
+ TimeShareVO timeShareVO = new TimeShareVO();
|
|
|
+ timeShareVO.setNeed(getElectricity(userId, siteId, DateUtils.setHours(date, 9), DateUtils.setHours(date, 12)));
|
|
|
//高峰
|
|
|
Double peakStart = getElectricity(userId, siteId, DateUtils.setHours(date, 8), DateUtils.setHours(date, 12));
|
|
|
Double peakEnd = getElectricity(userId, siteId, DateUtils.setHours(date, 16), DateUtils.setHours(date, 20));
|
|
|
+ timeShareVO.setPeak(peakStart+peakEnd);
|
|
|
//平
|
|
|
Double flatStart = getElectricity(userId, siteId, DateUtils.setHours(date, 6), DateUtils.setHours(date, 8));
|
|
|
Double flatCentre = getElectricity(userId, siteId, DateUtils.setHours(date, 12), DateUtils.setHours(date, 16));
|
|
|
Double flatEnd = getElectricity(userId, siteId, DateUtils.setHours(date, 20), DateUtils.setHours(date, 22));
|
|
|
- List<CommonTotalVO> list = new ArrayList<>();
|
|
|
-
|
|
|
- list.add(CommonTotalVO.builder().name("need")
|
|
|
- .objectData(getElectricity(userId,siteId,DateUtils.setHours(date,9),DateUtils.setHours(date,12)))
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("peak")
|
|
|
- .objectData(peakStart+peakEnd)
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("grain")
|
|
|
- .objectData(getElectricity(userId, siteId, DateUtils.setHours(date, 22), DateUtils.setHours(DateUtils.addDays(date,1), 6)))
|
|
|
- .build());
|
|
|
- list.add(CommonTotalVO.builder().name("flat")
|
|
|
- .objectData(flatStart+flatCentre+flatEnd)
|
|
|
- .build());
|
|
|
- return list;
|
|
|
+ timeShareVO.setFlat(flatStart+flatCentre+flatEnd);
|
|
|
+ timeShareVO.setGrain(getElectricity(userId, siteId, DateUtils.setHours(date, 22), DateUtils.setHours(DateUtils.addDays(date, 1), 6)));
|
|
|
+ return timeShareVO;
|
|
|
}
|
|
|
|
|
|
@Override
|