|
@@ -30,10 +30,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
public class IotScreenServiceImpl implements IIotScreenService {
|
|
public class IotScreenServiceImpl implements IIotScreenService {
|
|
@@ -81,8 +78,26 @@ public class IotScreenServiceImpl implements IIotScreenService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public List<IotHomeDeviceListResVo> deviceList(IotHomeDeviceListReqVo reqVo) {
|
|
|
|
|
- return iIotHomeService.getDeviceList(reqVo);
|
|
|
|
|
|
|
+ public List<IotScreenDeviceListResVo> deviceList(IotHomeDeviceListReqVo reqVo) {
|
|
|
|
|
+ List<IotHomeDeviceListResVo> homeDeviceListResList = iIotHomeService.getDeviceList(reqVo);
|
|
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
|
|
+ iotDevice.setTid(SecurityUtils.getTid());
|
|
|
|
|
+ List<IotHomeTypeStatResVo> iotHomeTypeStatResVoList = iIotDeviceService.selectHomeDeviceTypeStat(iotDevice);
|
|
|
|
|
+ Map<String, IotHomeTypeStatResVo> typeMap = new HashMap<>();
|
|
|
|
|
+ for(IotHomeTypeStatResVo item : iotHomeTypeStatResVoList) {
|
|
|
|
|
+ typeMap.put(item.getDevtypeBid(), item);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<IotScreenDeviceListResVo> iotScreenDeviceListResVoList = new ArrayList<>();
|
|
|
|
|
+ for(IotHomeDeviceListResVo item : homeDeviceListResList) {
|
|
|
|
|
+ IotScreenDeviceListResVo iotScreenDeviceListResVo = new IotScreenDeviceListResVo();
|
|
|
|
|
+ BeanUtils.copyProperties(item, iotScreenDeviceListResVo);
|
|
|
|
|
+ if(typeMap.containsKey(item.getDevtypeBid())) {
|
|
|
|
|
+ IotHomeTypeStatResVo iotHomeTypeStatResVo = typeMap.get(item.getDevtypeBid());
|
|
|
|
|
+ BeanUtils.copyProperties(iotHomeTypeStatResVo, iotScreenDeviceListResVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ iotScreenDeviceListResVoList.add(iotScreenDeviceListResVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return iotScreenDeviceListResVoList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -232,4 +247,63 @@ public class IotScreenServiceImpl implements IIotScreenService {
|
|
|
return resVo;
|
|
return resVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<IotCbdRecogChartResVo> cbdRecogChartStat(IotScreenStatReqVo reqVo) {
|
|
|
|
|
+ String devBid = reqVo.getDevBid();
|
|
|
|
|
+ String startDate = reqVo.getStartDate();
|
|
|
|
|
+ String endDate = reqVo.getEndDate();
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isEmpty(devBid)){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备标识不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(StringUtils.isEmpty(startDate) || StringUtils.isEmpty(endDate)){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"时间不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
|
|
+ if(iotDevice == null){
|
|
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"设备不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ String cbdrecogType = iotDevice.getDevCbdrecogtype();
|
|
|
|
|
+ String devRecogtype = iotDevice.getDevRecogtype();
|
|
|
|
|
+ String cbdrecogMarktype = EnumCbdMarkType.AUTO.getCode();
|
|
|
|
|
+
|
|
|
|
|
+ Criteria criteria = new Criteria()
|
|
|
|
|
+ .and("devBid").is(devBid)
|
|
|
|
|
+ .and("cbdimgDelstatus").is("0")
|
|
|
|
|
+ .and("cbdrecog." + cbdrecogType + ".cbdrecogMarktype").is(cbdrecogMarktype)
|
|
|
|
|
+ .andOperator(
|
|
|
|
|
+ Criteria.where("cbdimgCreatedDate").gte(startDate),
|
|
|
|
|
+ Criteria.where("cbdimgCreatedDate").lte(endDate)
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ MatchOperation matchOperation = Aggregation.match(criteria);
|
|
|
|
|
+ SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "cbdimgCreatedDate");
|
|
|
|
|
+
|
|
|
|
|
+ ProjectionOperation projectionOperation = Aggregation.project()
|
|
|
|
|
+ .and("cbdimgTotalnum").as("cbdimgTotalnum")
|
|
|
|
|
+ .and("cbdrecog." + cbdrecogMarktype + ".cbdrecogPestnum").as("cbdrecogPestnum")
|
|
|
|
|
+ .andExpression("{ $substr: {'$cbdimgCreatedDate', 0, 10} }").as("cbdimgCreatedDate");
|
|
|
|
|
+
|
|
|
|
|
+ GroupOperation groupOperation = Aggregation.group("$cbdimgCreatedDate")
|
|
|
|
|
+ .sum("cbdimgTotalnum").as("cbdimgTotalnum")
|
|
|
|
|
+ .sum("cbdrecogPestnum").as("cbdrecogPestnum");
|
|
|
|
|
+
|
|
|
|
|
+ ProjectionOperation projectionOperationResult = Aggregation.project()
|
|
|
|
|
+ .and("_id").as("cbdimgCreatedDate")
|
|
|
|
|
+ .and("cbdimgTotalnum").as("cbdimgTotalnum");
|
|
|
|
|
+
|
|
|
|
|
+ if("1".equals(devRecogtype)){
|
|
|
|
|
+ projectionOperationResult = projectionOperationResult.and("cbdrecogPestnum").as("cbdrecogPestnum");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Aggregation aggregation = Aggregation.newAggregation(
|
|
|
|
|
+ matchOperation, projectionOperation, groupOperation, projectionOperationResult, sortOperation);
|
|
|
|
|
+
|
|
|
|
|
+ List<IotCbdRecogChartResVo> resVoList = mongoService.aggregate(IotCbdimg.class, aggregation, IotCbdRecogChartResVo.class);
|
|
|
|
|
+
|
|
|
|
|
+ return resVoList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|