Просмотр исходного кода

新增 获取测报灯识别害虫折线图信息接口

zhaiyifei 8 месяцев назад
Родитель
Сommit
9e464329b9

+ 10 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotScreenController.java

@@ -155,4 +155,14 @@ public class IotScreenController extends BaseController {
         return success(iIotScreenService.cbdRecogStat(reqVo));
     }
 
+    /**
+     * 获取测报灯识别害虫统计信息接口
+     * @param
+     * @return
+     */
+    @GetMapping("/device/cbd/recog/chart/stat")
+    public AjaxResult cbdRecogChartStat(IotScreenStatReqVo reqVo) {
+        return success(iIotScreenService.cbdRecogChartStat(reqVo));
+    }
+
 }

+ 3 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/reqvo/IotScreenStatReqVo.java

@@ -6,4 +6,7 @@ import lombok.Data;
 public class IotScreenStatReqVo {
     private String tid;
     private String devBid;
+
+    private String startDate;
+    private String endDate;
 }

+ 21 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/IotCbdRecogChartResVo.java

@@ -0,0 +1,21 @@
+package com.yunfeiyun.agmp.iotm.web.domain.resvo;
+
+import lombok.Data;
+
+@Data
+public class IotCbdRecogChartResVo {
+    /**
+     * 累计消灭害虫数量
+     */
+    int cbdimgTotalnum;
+    /**
+     * 今日识别害虫数量
+     */
+    int cbdrecogPestnum;
+
+    /**
+     * 日期
+     */
+    String cbdimgCreatedDate;
+
+}

+ 58 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/domain/resvo/IotScreenDeviceListResVo.java

@@ -0,0 +1,58 @@
+package com.yunfeiyun.agmp.iotm.web.domain.resvo;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class IotScreenDeviceListResVo {
+
+    /**
+     * 设备标识
+     */
+    private String devBid;
+
+    /** 设备名称 */
+    private String devName;
+
+    private String devCode;
+
+    /**
+     * 设备状态
+     */
+    private String devStatus;
+
+    /**
+     * 设备型号业务标识
+     */
+    private String devtypeBid;
+
+    /**
+     * 经度
+     */
+    private String lng;
+
+    /**
+     * 纬度
+     */
+    private String lat;
+
+    /**
+     * 经度 手动校准
+     */
+    @Excel(name = "经度 手动校准")
+    private String devLngalign;
+
+    /**
+     * 纬度(校准)
+     */
+    @Excel(name = "纬度", readConverterExp = "校=准")
+    private String devLatalign;
+
+
+    private String devtypeName;
+
+    /** 型号图示 */
+    private String devtypePreview;
+
+    private String devtypeMapicon;
+}

+ 3 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotScreenService.java

@@ -17,7 +17,7 @@ public interface IIotScreenService {
      */
     public IotScreenDevStatResVo deviceStat(IotScreenStatReqVo reqVo);
 
-    public List<IotHomeDeviceListResVo> deviceList(IotHomeDeviceListReqVo reqVo);
+    public List<IotScreenDeviceListResVo> deviceList(IotHomeDeviceListReqVo reqVo);
 
     public List<IotDeviceListResVo> monitorList(IotDeviceListReqVo reqVo);
 
@@ -34,4 +34,6 @@ public interface IIotScreenService {
     public List<IotDeviceListResVo> cbdList(IotDeviceListReqVo reqVo);
 
     public IotCbdRecogStatResVo cbdRecogStat(IotScreenStatReqVo reqVo);
+
+    public List<IotCbdRecogChartResVo> cbdRecogChartStat(IotScreenStatReqVo reqVo);
 }

+ 80 - 6
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotScreenServiceImpl.java

@@ -30,10 +30,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.stereotype.Service;
 
 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
 public class IotScreenServiceImpl implements IIotScreenService {
@@ -81,8 +78,26 @@ public class IotScreenServiceImpl implements IIotScreenService {
     }
 
     @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
@@ -232,4 +247,63 @@ public class IotScreenServiceImpl implements IIotScreenService {
         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;
+    }
+
 }