Commit a3c983bc authored by 赵啸非's avatar 赵啸非

修改统计逻辑

parent d1ca66ce
......@@ -80,17 +80,6 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device
int alarmTotalCount = deviceAlarmInfoService.count(deviceAlarmInfoQuery, null);
deviceStatEntity.setAlarmTotalCount(alarmTotalCount);
/* //上行下行数量
DeviceLogQuery deviceLogQuery = new DeviceLogQuery();
deviceLogQuery.setCreateTimeStart(DateUtils.getCurrStrDate());
deviceLogQuery.setCreateTimeEnd(DateUtils.getCurrStrDate());
deviceLogQuery.setLogType(LogTypeEnum.上报事件.getValue());
int uploadMessageTotalCount = deviceLogService.count(deviceLogQuery, null);
deviceLogQuery.setLogType(LogTypeEnum.下发服务.getValue());
int downloadMessageTotalCount = deviceLogService.count(deviceLogQuery, null);
deviceStatEntity.setUploadMessageTotalCount(uploadMessageTotalCount);
deviceStatEntity.setDownloadMessageTotalCount(downloadMessageTotalCount);*/
if (deviceStatEntity.newEntity()) {
deviceStatEntity.setCreateTime(new Date());
this.save(deviceStatEntity);
......@@ -117,4 +106,8 @@ public class DeviceMessageStatServiceImpl extends AbstractCRUDServiceImpl<Device
return deviceStatEntityResult;
}
}
\ No newline at end of file
package com.mortals.xhx.module.device.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.device.model.DeviceMessageStatEntity;
import com.mortals.xhx.module.device.service.DeviceMessageStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 设备消息统计
......@@ -35,4 +39,15 @@ public class DeviceMessageStatController extends BaseCRUDJsonBodyMappingControll
}
@Override
protected int doListAfter(DeviceMessageStatEntity query, Map<String, Object> model, Context context) throws AppException {
List<DeviceMessageStatEntity> statEntities = (List<DeviceMessageStatEntity>) model.get(KEY_RESULT_DATA);
//重新分组返回 [{date:2024-8}]
if(!ObjectUtils.isEmpty(statEntities)){
//按月分组
Map<Integer, Map<String, List<DeviceMessageStatEntity>>> collect = statEntities.stream().collect(Collectors.groupingBy(DeviceMessageStatEntity::getMonth, Collectors.groupingBy(DeviceMessageStatEntity::getProductCode)));
model.put("stat", collect);
}
return super.doListAfter(query, model, context);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment