|
@@ -33,6 +33,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
import static com.bizmatics.service.impl.RtAnalogDataServiceImpl.getLastDayOfMonth;
|
|
|
|
|
@@ -194,25 +195,29 @@ public class HtAnalogDataServiceImpl extends AbstractCrudService<HtAnalogDataMap
|
|
|
|
|
|
@Override
|
|
|
public TimeShareVO getTimeShare(Integer siteId, Integer type) {
|
|
|
- TimeShareVO timeShareVO = new TimeShareVO();
|
|
|
+ AtomicReference<TimeShareVO> timeShareVO = new AtomicReference<>(new TimeShareVO());
|
|
|
Date date = new Date();
|
|
|
if (0 == type) {
|
|
|
- HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, date, date);
|
|
|
- Optional.ofNullable(hadSiteStatic).ifPresent(hads -> JsonUtils.fromJson(hads.getTimeShare(), timeShareVO.getClass()));
|
|
|
+ Date yeDay = DateUtils.addDays(date, -1);
|
|
|
+ Date yeStartDay = DateUtils.getDayStartTime(yeDay);
|
|
|
+ HadSiteStatic hadSiteStatic = hadSiteStaticService.oneBySite(siteId, yeStartDay, yeDay);
|
|
|
+ Optional.ofNullable(hadSiteStatic).ifPresent(hads -> {
|
|
|
+ timeShareVO.set(JsonUtils.fromJson(hads.getTimeShare(), TimeShareVO.class));
|
|
|
+ });
|
|
|
} else {
|
|
|
List<HadSiteStatic> list = hadSiteStaticService.list(siteId, DateUtils.getFirstDayOfMonth(date), date);
|
|
|
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.get().setFlat(Arith.add(timeShareVO.get().getFlat(), ts.getFlat()));
|
|
|
+ timeShareVO.get().setPeak(Arith.add(timeShareVO.get().getPeak(), ts.getPeak()));
|
|
|
+ timeShareVO.get().setNeed(Arith.add(timeShareVO.get().getNeed(), ts.getNeed()));
|
|
|
+ timeShareVO.get().setGrain(Arith.add(timeShareVO.get().getGrain(), ts.getGrain()));
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- return timeShareVO;
|
|
|
+ return timeShareVO.get();
|
|
|
}
|
|
|
|
|
|
@Override
|