|
@@ -9,7 +9,7 @@ import com.bizmatics.persistence.mapper.HtAnalogDataMapper;
|
|
|
import com.bizmatics.service.HadSiteStaticService;
|
|
|
import com.bizmatics.service.HtAnalogDataService;
|
|
|
import com.bizmatics.service.util.Arith;
|
|
|
-import com.bizmatics.service.util.SessionLocal;
|
|
|
+import com.bizmatics.service.util.SecurityUtils;
|
|
|
import com.bizmatics.service.vo.CommonIcoVO;
|
|
|
import com.bizmatics.service.vo.HadCountVO;
|
|
|
import com.bizmatics.service.vo.TimeShareVO;
|
|
@@ -33,75 +33,74 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
|
|
|
@Autowired
|
|
|
private HadSiteStaticService hadSiteStaticService;
|
|
|
+
|
|
|
@Override
|
|
|
public HadCountVO selectCount() {
|
|
|
HadCountVO hadCountVO = new HadCountVO();
|
|
|
-// Integer userId = UserUtil.getUserId();
|
|
|
- Integer userId = SessionLocal.getUserId();
|
|
|
+ Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
|
|
|
Date date = new Date();
|
|
|
- hadCountVO.setDayCount(hadSiteStaticService.getCount(userId,DateUtils.getDayStartTime(date),date,null));
|
|
|
- hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date,null));
|
|
|
- hadCountVO.setYearCount(hadSiteStaticService.getCount(userId,DateUtils.getBeginDayOfYear(date),date,null));
|
|
|
+ hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, null));
|
|
|
+ hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, null));
|
|
|
+ hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, null));
|
|
|
return hadCountVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<CommonIcoVO> selectTrendByDate(Integer siteId) {
|
|
|
-// Integer userId = UserUtil.getUserId();
|
|
|
- Integer userId = SessionLocal.getUserId();
|
|
|
+ Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
|
|
|
Date date = new Date();
|
|
|
Date sTime = DateUtils.getDayStartTime(date);
|
|
|
Date eTime = DateUtils.getDayEndTime(date);
|
|
|
- Date ysTime = DateUtils.addDays(sTime,-1);
|
|
|
- Date yeTime = DateUtils.addDays(eTime,-1);
|
|
|
+ Date ysTime = DateUtils.addDays(sTime, -1);
|
|
|
+ Date yeTime = DateUtils.addDays(eTime, -1);
|
|
|
List<CommonIcoVO> list = new ArrayList<>();
|
|
|
- if (null != siteId){
|
|
|
+ if (null != siteId) {
|
|
|
list.add(getTreedBySite("昨日", siteId, ysTime, yeTime));
|
|
|
list.add(getTreedBySite("今日", siteId, sTime, eTime));
|
|
|
- }else {
|
|
|
- list.add(getTrendOne("昨日", userId, ysTime,yeTime));
|
|
|
- list.add(getTrendOne("今日", userId, sTime,eTime));
|
|
|
+ } else {
|
|
|
+ list.add(getTrendOne("昨日", userId, ysTime, yeTime));
|
|
|
+ list.add(getTrendOne("今日", userId, sTime, eTime));
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public CommonIcoVO getTrendOne(String name,Integer userId,Date startTime,Date endTime){
|
|
|
+ public CommonIcoVO getTrendOne(String name, Integer userId, Date startTime, Date endTime) {
|
|
|
List<HadSiteStatic> list = hadSiteStaticService.list(null, startTime, endTime, userId);
|
|
|
List<Object> objects = new ArrayList<>();
|
|
|
objects.add(0.0);
|
|
|
List<Object> dates = new ArrayList<>();
|
|
|
dates.add("00:00:00");
|
|
|
- for (int i = 2; i < 24 ; i+=2) {
|
|
|
+ for (int i = 2; i < 24; i += 2) {
|
|
|
//结束时间
|
|
|
Date hours = DateUtils.setHours(startTime, i);
|
|
|
startTime = hours;
|
|
|
dates.add(DateUtils.getTime(hours));
|
|
|
Double hourCount = 0.00;
|
|
|
- for (HadSiteStatic hadSiteStatic:list) {
|
|
|
+ for (HadSiteStatic hadSiteStatic : list) {
|
|
|
CommonIcoVO commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class);
|
|
|
List<Double> dataList = (List<Double>) commonIcoVO.getList();
|
|
|
- hourCount+=dataList.get(i/2);
|
|
|
+ hourCount += dataList.get(i / 2);
|
|
|
}
|
|
|
- objects.add(Arith.div(hourCount,1,2));
|
|
|
+ objects.add(Arith.div(hourCount, 1, 2));
|
|
|
}
|
|
|
return CommonIcoVO.builder().name(name).list(objects).listDate(dates).build();
|
|
|
}
|
|
|
|
|
|
- CommonIcoVO getTreedBySite(String name,Integer siteId,Date startTime,Date endTime){
|
|
|
+ CommonIcoVO getTreedBySite(String name, Integer siteId, Date startTime, Date endTime) {
|
|
|
Date sTime = DateUtils.getDayStartTime(startTime);
|
|
|
Date eTime = DateUtils.getDayEndTime(endTime);
|
|
|
HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, sTime, eTime);
|
|
|
CommonIcoVO commonIcoVO = null;
|
|
|
- if (null != hadSiteStatic){
|
|
|
+ if (null != hadSiteStatic) {
|
|
|
commonIcoVO = JsonUtils.fromJson(hadSiteStatic.getLoadIco(), CommonIcoVO.class);
|
|
|
commonIcoVO.setName(name);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<Object> objects = new ArrayList<>();
|
|
|
objects.add(0.0);
|
|
|
List<Object> dates = new ArrayList<>();
|
|
|
dates.add("00:00:00");
|
|
|
- for (int i = 2; i < 24 ; i+=2) {
|
|
|
+ for (int i = 2; i < 24; i += 2) {
|
|
|
//结束时间
|
|
|
Date hours = DateUtils.setHours(startTime, i);
|
|
|
objects.add(0.0);
|
|
@@ -116,22 +115,21 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
@Override
|
|
|
public List<CommonIcoVO> selectTrendByMonth() {
|
|
|
Date date = new Date();
|
|
|
-// Integer userId = UserUtil.getUserId();
|
|
|
- Integer userId = SessionLocal.getUserId();
|
|
|
+ Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
|
|
|
List<CommonIcoVO> list = new ArrayList<>();
|
|
|
- list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(DateUtils.addMonths(date,-1)),userId,"上月趋势图"));
|
|
|
- list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(date),userId,"当月趋势图"));
|
|
|
+ list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(DateUtils.addMonths(date, -1)), userId, "上月趋势图"));
|
|
|
+ list.add(selectTreedMonthOne(DateUtils.getLastDayOfMonth(date), userId, "当月趋势图"));
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public CommonIcoVO selectTreedMonthOne(Date date,Integer userId,String name){
|
|
|
+ public CommonIcoVO selectTreedMonthOne(Date date, Integer userId, String name) {
|
|
|
List<Object> objects = new ArrayList<>();
|
|
|
List<Object> dateList = new ArrayList<>();
|
|
|
for (int i = 1; i <= Integer.parseInt(DateUtils.getDay(date)); i++) {
|
|
|
Date setDays = DateUtils.setDays(date, i);
|
|
|
Date dayStartTime = DateUtils.getDayStartTime(setDays);
|
|
|
Date dayEndTime = DateUtils.getDayEndTime(setDays);
|
|
|
- objects.add(hadSiteStaticService.getCount(userId,dayStartTime,dayEndTime,null));
|
|
|
+ objects.add(hadSiteStaticService.getCount(userId, dayStartTime, dayEndTime, null));
|
|
|
dateList.add(DateUtils.getDay(setDays));
|
|
|
}
|
|
|
return CommonIcoVO.builder().name(name).list(objects).listDate(dateList).build();
|
|
@@ -139,8 +137,7 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
|
|
|
@Override
|
|
|
public HadCountVO getCountBySite(Integer siteId) {
|
|
|
-// Integer userId = UserUtil.getUserId();
|
|
|
- Integer userId = SessionLocal.getUserId();
|
|
|
+ Integer userId = SecurityUtils.getLoginUser().getUser().getUserId().intValue();
|
|
|
Date date = new Date();
|
|
|
//当日开始时间
|
|
|
Date firstDayOfDate = DateUtils.getDayStartTime(date);
|
|
@@ -149,12 +146,12 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
//当年开始时间
|
|
|
Date firstDayOfYear = DateUtils.getBeginDayOfYear(date);
|
|
|
HadCountVO hadCountVO = new HadCountVO();
|
|
|
- hadCountVO.setDayCount(hadSiteStaticService.getCount(userId,DateUtils.getDayStartTime(date),date,siteId));
|
|
|
- hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date,siteId));
|
|
|
- hadCountVO.setYearCount(hadSiteStaticService.getCount(userId,DateUtils.getBeginDayOfYear(date),date,siteId));
|
|
|
- hadCountVO.setLastDayCount(hadSiteStaticService.getCount(userId, DateUtils.addDays(firstDayOfDate, -1), DateUtils.addDays(date, -1),siteId));
|
|
|
- hadCountVO.setLastMonthCount(hadSiteStaticService.getCount(userId, DateUtils.addMonths(firstDayOfMonth, -1), DateUtils.addMonths(date, -1),siteId));
|
|
|
- hadCountVO.setLastYearCount(hadSiteStaticService.getCount(userId, DateUtils.addYears(firstDayOfYear, -1), DateUtils.addYears(date, -1),siteId));
|
|
|
+ hadCountVO.setDayCount(hadSiteStaticService.getCount(userId, DateUtils.getDayStartTime(date), date, siteId));
|
|
|
+ hadCountVO.setMonthCount(hadSiteStaticService.getCount(userId, DateUtils.getFirstDayOfMonth(date), date, siteId));
|
|
|
+ hadCountVO.setYearCount(hadSiteStaticService.getCount(userId, DateUtils.getBeginDayOfYear(date), date, siteId));
|
|
|
+ hadCountVO.setLastDayCount(hadSiteStaticService.getCount(userId, DateUtils.addDays(firstDayOfDate, -1), DateUtils.addDays(date, -1), siteId));
|
|
|
+ hadCountVO.setLastMonthCount(hadSiteStaticService.getCount(userId, DateUtils.addMonths(firstDayOfMonth, -1), DateUtils.addMonths(date, -1), siteId));
|
|
|
+ hadCountVO.setLastYearCount(hadSiteStaticService.getCount(userId, DateUtils.addYears(firstDayOfYear, -1), DateUtils.addYears(date, -1), siteId));
|
|
|
hadCountVO.setDayRadio(Optional.ofNullable(hadCountVO.getDayCount())
|
|
|
.filter(dayCount -> 0.00 != dayCount)
|
|
|
.map(dayCount -> Arith.div(hadCountVO.getLastDayCount(), dayCount))
|
|
@@ -176,19 +173,19 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
public TimeShareVO getTimeShare(Integer siteId, Integer type) {
|
|
|
TimeShareVO timeShareVO = new TimeShareVO();
|
|
|
Date date = new Date();
|
|
|
- if (0 == type){
|
|
|
+ if (0 == type) {
|
|
|
HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
|
|
|
- Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(),timeShareVO.getClass()));
|
|
|
- }else {
|
|
|
+ Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(), timeShareVO.getClass()));
|
|
|
+ } else {
|
|
|
List<HadSiteStatic> list = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date);
|
|
|
- for (HadSiteStatic hadSiteStatic:list) {
|
|
|
+ for (HadSiteStatic hadSiteStatic : list) {
|
|
|
Optional.ofNullable(hadSiteStatic.getTimeShare())
|
|
|
.ifPresent(has -> {
|
|
|
TimeShareVO ts = JsonUtils.fromJson(has, TimeShareVO.class);
|
|
|
- timeShareVO.setFlat(Arith.add(timeShareVO.getFlat(),ts.getFlat()));
|
|
|
- timeShareVO.setPeak(Arith.add(timeShareVO.getPeak(),ts.getPeak()));
|
|
|
- timeShareVO.setNeed(Arith.add(timeShareVO.getNeed(),ts.getNeed()));
|
|
|
- timeShareVO.setGrain(Arith.add(timeShareVO.getGrain(),ts.getGrain()));
|
|
|
+ timeShareVO.setFlat(Arith.add(timeShareVO.getFlat(), ts.getFlat()));
|
|
|
+ timeShareVO.setPeak(Arith.add(timeShareVO.getPeak(), ts.getPeak()));
|
|
|
+ timeShareVO.setNeed(Arith.add(timeShareVO.getNeed(), ts.getNeed()));
|
|
|
+ timeShareVO.setGrain(Arith.add(timeShareVO.getGrain(), ts.getGrain()));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -208,14 +205,14 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
Date dayStartTime = DateUtils.getDayStartTime(setDays);
|
|
|
Date dayEndTime = DateUtils.getDayEndTime(setDays);
|
|
|
maxList.add(hadSiteStatics.stream()
|
|
|
- .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
|
|
|
+ .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
|
|
|
).findFirst().map(HadSiteStatic::getMaxDemand).orElse(0.00));
|
|
|
|
|
|
minList.add(hadSiteStatics.stream()
|
|
|
- .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
|
|
|
+ .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
|
|
|
).findFirst().map(HadSiteStatic::getMinDemand).orElse(0.00));
|
|
|
avgList.add(hadSiteStatics.stream()
|
|
|
- .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(),dayStartTime,dayEndTime)
|
|
|
+ .filter(hadSiteStatic -> DateUtils.isEffectiveDate(hadSiteStatic.getHadTime(), dayStartTime, dayEndTime)
|
|
|
).findFirst().map(HadSiteStatic::getAvgDemand).orElse(0.00));
|
|
|
dateList.add(DateUtils.getDay(setDays));
|
|
|
}
|
|
@@ -245,9 +242,10 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
|
|
|
List<HtAnalogData> htList = Optional.ofNullable(hadSiteStatic)
|
|
|
.map(HadSiteStatic::getHisIco)
|
|
|
- .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference<List<HtAnalogData>>(){}))
|
|
|
+ .map(his -> JsonUtils.fromJson(hadSiteStatic.getHisIco(), new TypeReference<List<HtAnalogData>>() {
|
|
|
+ }))
|
|
|
.orElse(null);
|
|
|
- for (int i = 2; i < 24 ; i+=2) {
|
|
|
+ for (int i = 2; i < 24; i += 2) {
|
|
|
Date hours = DateUtils.setHours(date, i);
|
|
|
date = hours;
|
|
|
Date finalDate = date;
|