|
|
@@ -80,6 +80,33 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
@Resource
|
|
|
private IotDeviceRefreshService iotDeviceRefreshService;
|
|
|
|
|
|
+ private Map<String, Long> getImgCountMap(List<String> devBidList) {
|
|
|
+ Criteria criteria = new Criteria()
|
|
|
+ .and("devBid").in(devBidList)
|
|
|
+ .and("cbdimgDelstatus").is("0");
|
|
|
+ MatchOperation matchOperation = Aggregation.match(criteria);
|
|
|
+ GroupOperation groupOperation = Aggregation.group("devBid").count().as("imgCount");
|
|
|
+
|
|
|
+ ProjectionOperation projectionOperationResult = Aggregation.project()
|
|
|
+ .and("_id").as("devBid")
|
|
|
+ .and("imgCount").as("imgCount");
|
|
|
+ Aggregation aggregation = Aggregation.newAggregation(
|
|
|
+ matchOperation,
|
|
|
+ groupOperation,
|
|
|
+ projectionOperationResult
|
|
|
+ );
|
|
|
+ List<IotCbdimgCountResVo> iotCbdimgCountResVoList = mongoService.aggregate(
|
|
|
+ IotCbdimg.class, aggregation, IotCbdimgCountResVo.class
|
|
|
+ );
|
|
|
+
|
|
|
+ Map<String, Long> imgCountMap = new HashMap<>();
|
|
|
+ for (IotCbdimgCountResVo iotCbdimgCountResVo : iotCbdimgCountResVoList) {
|
|
|
+ String devBid = iotCbdimgCountResVo.getDevBid();
|
|
|
+ imgCountMap.put(devBid, (long) iotCbdimgCountResVo.getImgCount());
|
|
|
+ }
|
|
|
+ return imgCountMap;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取测报灯列表数据
|
|
|
* 普通测报灯 pt
|
|
|
@@ -135,11 +162,7 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
IotCbdimg.class, aggregation, IotCbdimgCountResVo.class
|
|
|
);
|
|
|
|
|
|
- Map<String, Long> imgCountMap = new HashMap<>();
|
|
|
- for (IotCbdimgCountResVo iotCbdimgCountResVo : iotCbdimgCountResVoList) {
|
|
|
- String devBid = iotCbdimgCountResVo.getDevBid();
|
|
|
- imgCountMap.put(devBid, (long) iotCbdimgCountResVo.getImgCount());
|
|
|
- }
|
|
|
+ Map<String, Long> imgCountMap = getImgCountMap(devBidList);
|
|
|
for (IotDeviceListResVo resVo : list) {
|
|
|
//查询图片数量
|
|
|
String devBid = resVo.getDevBid();
|
|
|
@@ -150,6 +173,27 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取设备信息详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/info/{devBid}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("devBid") String devBid)
|
|
|
+ {
|
|
|
+ IotDeviceListReqVo reqVo = new IotDeviceListReqVo();
|
|
|
+ reqVo.setDevBid(devBid);
|
|
|
+
|
|
|
+ List<IotDeviceListResVo> dataList = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+ if(dataList.isEmpty()){
|
|
|
+ throw new IotBizException(IotErrorCode.INVALID_DEVICE_ID.getCode(), "设备不存在");
|
|
|
+ }
|
|
|
+ IotDeviceListResVo devInfo = dataList.get(0);
|
|
|
+ List<String> devBidList = new ArrayList<>();
|
|
|
+ devBidList.add(devInfo.getDevBid());
|
|
|
+ Map<String, Long> imgCountMap = getImgCountMap(devBidList);
|
|
|
+ devInfo.setImgCount(imgCountMap.getOrDefault(devBid, 0L));
|
|
|
+ return success(devInfo);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 下发测报灯配置指令
|