|
|
@@ -18,7 +18,6 @@ import com.yunfeiyun.agmp.iot.common.constant.IotErrorCode;
|
|
|
import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotCbddata;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotCbdimg;
|
|
|
-import com.yunfeiyun.agmp.iot.common.domain.TosDevicetype;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.reqvo.IotCbdConfigEditReqVo;
|
|
|
import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
@@ -27,6 +26,7 @@ import com.yunfeiyun.agmp.iotm.common.controller.BaseController;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.common.service.IotDeviceRefreshService;
|
|
|
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotCbdimgCountResVo;
|
|
|
import com.yunfeiyun.agmp.iotm.device.pest.service.IotCbdService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.reqvo.IotDeviceListReqVo;
|
|
|
import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotDeviceListResVo;
|
|
|
@@ -34,6 +34,11 @@ import com.yunfeiyun.agmp.iotm.web.service.IIotCmdtaskService;
|
|
|
import com.yunfeiyun.agmp.iotm.web.service.IIotDeviceService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
|
|
+import org.springframework.data.mongodb.core.aggregation.GroupOperation;
|
|
|
+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.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
@@ -79,11 +84,13 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
* @param reqVo
|
|
|
* @return
|
|
|
*/
|
|
|
- @GetMapping({"/gk/list", "/sd/list", "/pt/list"})
|
|
|
+ @GetMapping({"/list", "/gk/list", "/sd/list", "/pt/list"})
|
|
|
public TableDataInfo list(HttpServletRequest request, IotDeviceListReqVo reqVo) {
|
|
|
- startPage();
|
|
|
String reqUri = request.getRequestURI();
|
|
|
- String[] devTypeList = null;
|
|
|
+ log.info("【{}】【测报灯】【列表】客户id {}", LogCore.getSeq(), getCustomerId());
|
|
|
+ String[] devTypeList = new String[]{
|
|
|
+ IotDeviceDictConst.TYPE_YF_GKCBD, IotDeviceDictConst.TYPE_YF_SDCBD, IotDeviceDictConst.TYPE_YF_CBD
|
|
|
+ };
|
|
|
if(reqUri.endsWith("/gk/list")){
|
|
|
devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_GKCBD};
|
|
|
}else if(reqUri.endsWith("/sd/list")){
|
|
|
@@ -91,11 +98,48 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
}else if(reqUri.endsWith("/pt/list")){
|
|
|
devTypeList = new String[]{IotDeviceDictConst.TYPE_YF_CBD};
|
|
|
}
|
|
|
- List<IotDeviceListResVo> list = new ArrayList<>();
|
|
|
- if(devTypeList != null){
|
|
|
- reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
|
|
|
- list = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+ reqVo.setDevtypeBidList(Arrays.asList(devTypeList));
|
|
|
+
|
|
|
+ startPage();
|
|
|
+ List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+ List<String> devBidList = new ArrayList<>();
|
|
|
+ if(!list.isEmpty()){
|
|
|
+ for(IotDeviceListResVo resVo : list){
|
|
|
+ devBidList.add(resVo.getDevBid());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ if(!devBidList.isEmpty()) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ for (IotDeviceListResVo resVo : list) {
|
|
|
+ //查询图片数量
|
|
|
+ String devBid = resVo.getDevBid();
|
|
|
+ resVo.setImgCount(imgCountMap.getOrDefault(devBid, 0L));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
@@ -217,23 +261,23 @@ public class IotDeviceCbdController extends BaseController {
|
|
|
* @param reqVo
|
|
|
* @return
|
|
|
*/
|
|
|
- @GetMapping("/list")
|
|
|
- public TableDataInfo list(IotDeviceListReqVo reqVo) {
|
|
|
- startPage();
|
|
|
- TosDevicetype tosDevicetype= typeCacheService.getCacheObjectByDevTypeCode(IotDeviceDictConst.TYPE_YF_CBD);
|
|
|
- reqVo.setDevtypeBid(tosDevicetype.getDevtypeBid());
|
|
|
- List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
- for (IotDeviceListResVo resVo : list) {
|
|
|
- //查询图片数量
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("devBid", resVo.getDevBid());
|
|
|
- map.put("cbdimgDelstatus", "0");
|
|
|
- long count = mongoService.count(IotCbdimg.class, map);
|
|
|
- resVo.setImgCount(count);
|
|
|
-
|
|
|
- }
|
|
|
- return getDataTable(list);
|
|
|
- }
|
|
|
+// @GetMapping("/list")
|
|
|
+// public TableDataInfo list(IotDeviceListReqVo reqVo) {
|
|
|
+// startPage();
|
|
|
+// TosDevicetype tosDevicetype= typeCacheService.getCacheObjectByDevTypeCode(IotDeviceDictConst.TYPE_YF_CBD);
|
|
|
+// reqVo.setDevtypeBid(tosDevicetype.getDevtypeBid());
|
|
|
+// List<IotDeviceListResVo> list = iIotDeviceService.selectIotDeviceListByType(reqVo);
|
|
|
+// for (IotDeviceListResVo resVo : list) {
|
|
|
+// //查询图片数量
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("devBid", resVo.getDevBid());
|
|
|
+// map.put("cbdimgDelstatus", "0");
|
|
|
+// long count = mongoService.count(IotCbdimg.class, map);
|
|
|
+// resVo.setImgCount(count);
|
|
|
+//
|
|
|
+// }
|
|
|
+// return getDataTable(list);
|
|
|
+// }
|
|
|
|
|
|
//
|
|
|
// /**
|