|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.usky.common.core.util.Arith;
|
|
|
import com.usky.common.core.util.DateUtils;
|
|
|
import com.usky.iot.domain.DmpDataOverview;
|
|
|
import com.usky.iot.mapper.DmpDeviceStatusMapper;
|
|
@@ -47,6 +48,8 @@ public class DmpDataOverviewJob {
|
|
|
//产品日
|
|
|
List<DmpDataOverview> dmpDataOverviews = new ArrayList<>();
|
|
|
List<DmpDataOverviewVO> list = getListMap(null, dayStartTime, dayEndTime);
|
|
|
+ //计算产品活跃占比
|
|
|
+ checkRadio(list);
|
|
|
for (DmpDataOverviewVO dvo : list) {
|
|
|
DmpDataOverview dmpDataOverview = new DmpDataOverview();
|
|
|
dmpDataOverview.setCreatedTime(date3);
|
|
@@ -64,9 +67,14 @@ public class DmpDataOverviewJob {
|
|
|
.findFirst()
|
|
|
.ifPresent(hy -> dmpDataOverviewVO.setHyCount(hy.getHyCount()));
|
|
|
}
|
|
|
+ //统计全部时间数据
|
|
|
+ List<DmpDataOverviewVO> allList = getListMap(null, null, null);
|
|
|
+ //计算占比
|
|
|
+ checkRadio(monthList);
|
|
|
+ //查看对应月份数据是否存在
|
|
|
List<DmpDataOverview> listByTimeAndIds = getListByTimeAndIds(monthList, firstDayOfMonth,lastDayOfMonth);
|
|
|
for (DmpDataOverviewVO dmpDataOverviewVO : monthList) {
|
|
|
- listByTimeAndIds.stream()
|
|
|
+ DmpDataOverview dd = listByTimeAndIds.stream()
|
|
|
.filter(dm -> dmpDataOverviewVO.getProductId().equals(dm.getProductId()) && DateUtils.isSameDay(dm.getCreatedTime(),date4))
|
|
|
.findAny()
|
|
|
.map(dm -> {
|
|
@@ -82,20 +90,14 @@ public class DmpDataOverviewJob {
|
|
|
listByTimeAndIds.add(dmpDataOverview);
|
|
|
return dmpDataOverview;
|
|
|
});
|
|
|
+ allList.stream()
|
|
|
+ .filter(dvo -> dvo.getProductId().equals(dd.getProductId()))
|
|
|
+ .findAny()
|
|
|
+ .ifPresent(dvo -> dd.setMiddleStatistic(JSON.toJSONString(dvo)));
|
|
|
}
|
|
|
dmpDataOverviewService.saveOrUpdateBatch(listByTimeAndIds);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- Date date = new Date();
|
|
|
- Date date1 = DateUtils.setHours(date, 0);
|
|
|
- Date date2 = DateUtils.setMinutes(date1, 0);
|
|
|
- Date date3 = DateUtils.setSeconds(date2, 0);
|
|
|
- Date date4 = DateUtils.setDays(date3, 1);
|
|
|
- System.out.println(DateUtils.isSameDay(date4, date4));
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 统计月信息
|
|
|
* @param productIds
|
|
@@ -139,4 +141,12 @@ public class DmpDataOverviewJob {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void checkRadio(List<DmpDataOverviewVO> list){
|
|
|
+ list.forEach(dmpDataOverviewVO -> {
|
|
|
+ dmpDataOverviewVO.setJhRadioCount((null == dmpDataOverviewVO.getDeviceCount() || 0 == dmpDataOverviewVO.getDeviceCount())?0.00: Arith.div(dmpDataOverviewVO.getJhCount(),dmpDataOverviewVO.getDeviceCount()));
|
|
|
+ dmpDataOverviewVO.setHyRadioCount((null == dmpDataOverviewVO.getDeviceCount() || 0 == dmpDataOverviewVO.getDeviceCount())?0.00:Arith.div(dmpDataOverviewVO.getHyCount(),dmpDataOverviewVO.getDeviceCount()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|