|
|
@@ -1,13 +1,23 @@
|
|
|
package com.yunfeiyun.agmp.iotm.web.service.impl;
|
|
|
|
|
|
+import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
+import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
+import com.yunfeiyun.agmp.iot.common.util.BigDecimalUtil;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListStatReqVo;
|
|
|
+import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListStatResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotHomeDeviceStatResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotHomeTypeStatResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotHomeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.MatchOperation;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.ProjectionOperation;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@@ -16,6 +26,9 @@ public class IotHomeServiceImpl implements IIotHomeService {
|
|
|
@Autowired
|
|
|
private IIotDeviceService iIotDeviceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MongoService mongoService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<IotHomeTypeStatResVo> getDeviceTypeStat() {
|
|
|
IotDevice iotDevice = new IotDevice();
|
|
|
@@ -27,4 +40,42 @@ public class IotHomeServiceImpl implements IIotHomeService {
|
|
|
IotDevice iotDevice = new IotDevice();
|
|
|
return iIotDeviceService.selectHomeDeviceStatusStat(iotDevice);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<IotDeviceListStatResVo> getDeviceListStat(IotDeviceListStatReqVo reqVo) {
|
|
|
+ String tid = SecurityUtils.getTid();
|
|
|
+ BigDecimal devLng = reqVo.getDevLng();
|
|
|
+ BigDecimal devLat = reqVo.getDevLat();
|
|
|
+ double lng = 0;
|
|
|
+ double lat = 0;
|
|
|
+ if(devLng != null && devLat != null) {
|
|
|
+ lng = BigDecimalUtil.format(lng).doubleValue();
|
|
|
+ lat = BigDecimalUtil.format(lat).doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ Criteria criteria = new Criteria()
|
|
|
+ .and("tid").is(tid);
|
|
|
+ MatchOperation matchOperation = Aggregation.match(criteria);
|
|
|
+
|
|
|
+ ProjectionOperation projectionOperationResult = Aggregation.project("_id")
|
|
|
+ .and("_id").as("devtypeBid")
|
|
|
+ .and("count").as("count");
|
|
|
+
|
|
|
+// Aggregation aggregation = Aggregation.newAggregation(
|
|
|
+// matchOperation,
|
|
|
+// groupOperation,
|
|
|
+// projectionOperationResult
|
|
|
+// );
|
|
|
+// List<IotIndexDevicetypeCountResVo> dataList = mongoService.aggregate(IotDeviceGeoLocation.class, aggregation, IotIndexDevicetypeCountResVo.class);
|
|
|
+// for(IotIndexDevicetypeCountResVo item : dataList) {
|
|
|
+// String devtypeBid = item.getDevtypeBid();
|
|
|
+// TosDevicetype devicetype = devicetypeMap.get(devtypeBid);
|
|
|
+// if (devicetype != null) {
|
|
|
+// item.setDevtypeName(devicetype.getDevtypeName());
|
|
|
+// item.setDevtypePreview(devicetype.getDevtypePreview());
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|