Explorar o código

新增 获取识别数据害虫名称列表接口

zhaiyifei hai 1 ano
pai
achega
91e58cff48

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iotm/device/common/domin/IotDeviceDataListReqVo.java

@@ -26,7 +26,7 @@ public class IotDeviceDataListReqVo
     private String endTime;
 
     /** 标记类型 0 手动标记 1  机器自动标记 */
-    private String pestrecogMarktype;
+    private String cbdrecogMarktype;
 
     /**
      * 数据形式  1 普通列表  2 图表用
@@ -46,6 +46,6 @@ public class IotDeviceDataListReqVo
      * 1  A模型
      * 2  B模型
      */
-    private String cbdRecogType;
+    private String cbdrecogType;
 
 }

+ 353 - 394
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/controller/IotPestrecogController.java

@@ -1,39 +1,23 @@
 package com.yunfeiyun.agmp.iotm.device.pest.controller;
 
-import com.alibaba.fastjson2.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.yunfeiyun.agmp.common.annotation.Log;
 import com.yunfeiyun.agmp.common.constant.ErrorCode;
 import com.yunfeiyun.agmp.common.core.controller.BaseController;
 import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
-import com.yunfeiyun.agmp.common.core.page.PageDomain;
-import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
-import com.yunfeiyun.agmp.common.core.page.TableSupport;
-import com.yunfeiyun.agmp.common.enums.BusinessType;
 import com.yunfeiyun.agmp.common.utils.StringUtils;
-import com.yunfeiyun.agmp.common.utils.poi.ExcelUtil;
-import com.yunfeiyun.agmp.iot.common.domain.IotPest;
-import com.yunfeiyun.agmp.iot.common.domain.IotPestrecog;
 import com.yunfeiyun.agmp.iot.common.service.MongoService;
-import com.yunfeiyun.agmp.iot.common.util.tmn.DatePlugUtil;
 import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
-import com.yunfeiyun.agmp.iotm.device.pest.domain.*;
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogGroupByNameResVo;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
 import lombok.extern.slf4j.Slf4j;
-import org.bson.Document;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.aggregation.*;
-import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.util.*;
+import java.util.List;
 
 /**
  * 虫情识别信息表Controller
@@ -55,179 +39,69 @@ public class IotPestrecogController extends BaseController {
     private MongoTemplate mongoTemplate;
 
     /**
-     * 识别数据列表
-     */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:list')")
-    @GetMapping("/list")
-    public TableDataInfo list(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
-        if (reqVo.getPestBids() == null || reqVo.getPestBids().size() == 0) {
-            TableDataInfo rspData = new TableDataInfo();
-            rspData.setCode(ErrorCode.SUCCESS.getCode());
-            rspData.setMsg(ErrorCode.SUCCESS.getMessage());
-            rspData.setData(new ArrayList<>());
-            rspData.setTotal(0);
-            return (rspData);
-        }
-        Map<String, Object> map = getParamMap(reqVo);
-        PageDomain pageDomain = TableSupport.buildPageRequest();
-        IPage<IotPestrecogResVo> listPage = iIotPestrecogService.selectIotPestrecogList(reqVo, pageDomain);
-        return getDataTable(listPage);
-    }
-
-    /**
-     * 导出识别数据列表
-     */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:data:export')")
-    @Log(title = "设备数据", businessType = BusinessType.EXPORT)
-    @PostMapping("/data/export")
-    public void dataExport(HttpServletResponse response, @RequestBody IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
-
-
-        List<IotPestrecogExportResVo> list = iIotPestrecogService.exportIotPestrecogList(reqVo);
-        //List<IotPestrecogResVo> list = getIotPestrecogResVoList2(records);
-        ExcelUtil<IotPestrecogExportResVo> util = new ExcelUtil<>(IotPestrecogExportResVo.class);
-        util.exportExcel(response, list, "识别数据");
-    }
-
-    /**
-     * 根据害虫分组统计数量
-     */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:pest:list')")
-    @GetMapping("/group/pest/list")
-    public AjaxResult groupByPestList(IotPestRecogPeriodReqVo reqVo) {
-        Criteria criteria = new Criteria();
-        criteria.and("devBid").is(reqVo.getDevBid());
-        if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
-            criteria.and("pestrecogMarktype").is(reqVo.getPestrecogMarktype());
-        }
-        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
-            criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime());
-        }
-        if (StringUtils.isEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
-            criteria.and("pestrecogCreatedDate").lte(reqVo.getEndTime());
-        }
-        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
-            criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime()).lte(reqVo.getEndTime());
-        }
-        MatchOperation matchOperation = Aggregation.match(criteria);
-
-        ProjectionOperation projectionOperation = Aggregation.project()
-                .andExclude("_id")
-                .and("$$ROOT").as("c");
-
-        LookupOperation lookupOperationIotCbdpest = Aggregation.lookup(
-                "IotCbdpest", "c.pestrecogBid", "pestrecogBid", "cp"
-        );
-        UnwindOperation unwindOperationCp = Aggregation.unwind("cp", true);
-
-
-        LookupOperation lookupOperationIotCbdrecog = Aggregation.lookup(
-                "IotCbdrecog", "cp.cbdrecogBid", "cbdrecogBid", "ce"
-        );
-        UnwindOperation unwindOperationCe = Aggregation.unwind("ce", true);
-        Criteria criteria2 = new Criteria()
-                .and("ce.cbdrecogType").is(reqVo.getCbdRecogType())
-                .and("ce.cbdrecogMarktype").is(reqVo.getPestrecogMarktype());;
-        MatchOperation matchOperation2 = Aggregation.match(criteria2);
-
-        GroupOperation group = Aggregation.group("c.pestBusid").first("c.pestBusid").as("pestBusid")
-                .sum("c.pestrecogNum").as("pestrecogNum");// fieldName为要分组的字段名称,totalField为需要求和的字段名称
-
-
-        Aggregation aggregation = Aggregation.newAggregation(
-                matchOperation,
-                projectionOperation,
-                lookupOperationIotCbdpest,
-                unwindOperationCp,
-                lookupOperationIotCbdrecog,
-                unwindOperationCe,
-                matchOperation2,
-                group
-                );
-        List<IotPestResVo> results = mongoService.aggregate(IotPestrecog.class, aggregation, IotPestResVo.class);
-
-        //获取害虫数据
-        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
-        for (IotPestResVo result : results) {
-            if (!StringUtils.isEmpty(result.getPestBusid())) {
-                IotPest pest = pestMap.get(result.getPestBusid());
-                if (pest != null) {
-                    result.setPestName(pest.getPestName());
-                }
-            } else {
-                // 手动识别的名字,待完善
-                result.setPestName("-");
-            }
-
-
-        }
-
-        return AjaxResult.success(results);
-    }
-
-    /**
-     * 虫情趋势矩阵
+     * 根据害虫进行区分统计
      */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:date:name')")
-    @GetMapping("/group/date/name")
-    public AjaxResult groupByDateName(IotDeviceDataListReqVo reqVo) {
+    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:name')")
+    @GetMapping("/group/name")
+    public AjaxResult groupByName(IotDeviceDataListReqVo reqVo) {
         if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
             return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
         }
-        List<IotPestrecog> results = iIotPestrecogService.groupByDateName(reqVo);
-
-        //获取存在识别害虫集合
-        List<IotPest> iotPests2 = getIotPestList(results);
-
-        List<Map<String, Object>> list1 = new ArrayList<>();
-        //获取日期集合
-        List<String> dateList = DatePlugUtil.getTwoDaysDayDes(reqVo.getStartTime(), reqVo.getEndTime());
-        for (String s : dateList) {
-            Map<String, Object> dateMap = new HashMap<>();
-            dateMap.put("date", s);
-            List<Map<String, Object>> list2 = new ArrayList<>();
-            dateMap.put("data", list2);
-            for (IotPest iotPest : iotPests2) {
-                String pestBid = iotPest.getPestBid();
-                Map<String, Object> pestMap = new HashMap<>();
-                pestMap.put("pestName", iotPest.getPestName());
-                pestMap.put("pestBid", iotPest.getPestBid());
-                int sum = 0;
-                for (IotPestrecog iotPestrecog : results) {
-                    if (s.equals(iotPestrecog.getPestrecogCreatedDate().substring(0, 10))
-                            && pestBid != null && pestBid.equals(iotPestrecog.getPestBusid())) {
-                        sum += iotPestrecog.getPestrecogNum();
-                    }
-                }
-                pestMap.put("sum", sum);
-                list2.add(pestMap);
-            }
-            list1.add(dateMap);
-        }
-        return AjaxResult.success(list1);
+        List<IotPestrecogGroupByNameResVo> groupByNameResVoList = iIotPestrecogService.groupByName(reqVo);
+        return AjaxResult.success(groupByNameResVoList);
     }
 
 //    /**
-//     * 虫情趋势矩阵
+//     * 识别数据列表
 //     */
-//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:date:name')")
-//    @GetMapping("/group/date/name")
-//    public AjaxResult groupByDateName(IotDeviceDataListReqVo reqVo) {
-//        if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
-//            return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
+//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:list')")
+//    @GetMapping("/list")
+//    public TableDataInfo list(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
+//        if (reqVo.getPestBids() == null || reqVo.getPestBids().size() == 0) {
+//            TableDataInfo rspData = new TableDataInfo();
+//            rspData.setCode(ErrorCode.SUCCESS.getCode());
+//            rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+//            rspData.setData(new ArrayList<>());
+//            rspData.setTotal(0);
+//            return (rspData);
 //        }
+//        Map<String, Object> map = getParamMap(reqVo);
+//        PageDomain pageDomain = TableSupport.buildPageRequest();
+//        IPage<IotPestrecogResVo> listPage = iIotPestrecogService.selectIotPestrecogList(reqVo, pageDomain);
+//        return getDataTable(listPage);
+//    }
+//
+//    /**
+//     * 导出识别数据列表
+//     */
+//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:data:export')")
+//    @Log(title = "设备数据", businessType = BusinessType.EXPORT)
+//    @PostMapping("/data/export")
+//    public void dataExport(HttpServletResponse response, @RequestBody IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
 //
 //
+//        List<IotPestrecogExportResVo> list = iIotPestrecogService.exportIotPestrecogList(reqVo);
+//        //List<IotPestrecogResVo> list = getIotPestrecogResVoList2(records);
+//        ExcelUtil<IotPestrecogExportResVo> util = new ExcelUtil<>(IotPestrecogExportResVo.class);
+//        util.exportExcel(response, list, "识别数据");
+//    }
+//
+//    /**
+//     * 根据害虫分组统计数量
+//     */
+//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:pest:list')")
+//    @GetMapping("/group/pest/list")
+//    public AjaxResult groupByPestList(IotPestRecogPeriodReqVo reqVo) {
 //        Criteria criteria = new Criteria();
 //        criteria.and("devBid").is(reqVo.getDevBid());
 //        if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
 //            criteria.and("pestrecogMarktype").is(reqVo.getPestrecogMarktype());
 //        }
 //        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
-//            criteria.and("pestrecogCreatedDate").is(reqVo.getPestrecogMarktype());
+//            criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime());
 //        }
 //        if (StringUtils.isEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
-//            criteria.and("pestrecogCreatedDate").is(reqVo.getPestrecogMarktype());
+//            criteria.and("pestrecogCreatedDate").lte(reqVo.getEndTime());
 //        }
 //        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
 //            criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime()).lte(reqVo.getEndTime());
@@ -249,12 +123,11 @@ public class IotPestrecogController extends BaseController {
 //        );
 //        UnwindOperation unwindOperationCe = Aggregation.unwind("ce", true);
 //        Criteria criteria2 = new Criteria()
-//                .and("ce.cbdrecogType").is(reqVo.getCbdRecogType());
+//                .and("ce.cbdrecogType").is(reqVo.getCbdRecogType())
+//                .and("ce.cbdrecogMarktype").is(reqVo.getPestrecogMarktype());;
 //        MatchOperation matchOperation2 = Aggregation.match(criteria2);
 //
-//        GroupOperation group = Aggregation.group("c.pestBusid")
-//                .first("c.pestBusid").as("pestBusid")
-//                .first("c.pestrecogCreatedDate").as("pestrecogCreatedDate")
+//        GroupOperation group = Aggregation.group("c.pestBusid").first("c.pestBusid").as("pestBusid")
 //                .sum("c.pestrecogNum").as("pestrecogNum");// fieldName为要分组的字段名称,totalField为需要求和的字段名称
 //
 //
@@ -267,8 +140,38 @@ public class IotPestrecogController extends BaseController {
 //                unwindOperationCe,
 //                matchOperation2,
 //                group
-//        );
-//        List<IotPestrecog> results = mongoService.aggregate(IotPestrecog.class, aggregation, IotPestrecog.class);
+//                );
+//        List<IotPestResVo> results = mongoService.aggregate(IotPestrecog.class, aggregation, IotPestResVo.class);
+//
+//        //获取害虫数据
+//        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
+//        for (IotPestResVo result : results) {
+//            if (!StringUtils.isEmpty(result.getPestBusid())) {
+//                IotPest pest = pestMap.get(result.getPestBusid());
+//                if (pest != null) {
+//                    result.setPestName(pest.getPestName());
+//                }
+//            } else {
+//                // 手动识别的名字,待完善
+//                result.setPestName("-");
+//            }
+//
+//
+//        }
+//
+//        return AjaxResult.success(results);
+//    }
+//
+//    /**
+//     * 虫情趋势矩阵
+//     */
+//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:date:name')")
+//    @GetMapping("/group/date/name")
+//    public AjaxResult groupByDateName(IotDeviceDataListReqVo reqVo) {
+//        if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
+//            return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
+//        }
+//        List<IotPestrecog> results = iIotPestrecogService.groupByDateName(reqVo);
 //
 //        //获取存在识别害虫集合
 //        List<IotPest> iotPests2 = getIotPestList(results);
@@ -300,8 +203,103 @@ public class IotPestrecogController extends BaseController {
 //        }
 //        return AjaxResult.success(list1);
 //    }
-
-
+//
+////    /**
+////     * 虫情趋势矩阵
+////     */
+////    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:date:name')")
+////    @GetMapping("/group/date/name")
+////    public AjaxResult groupByDateName(IotDeviceDataListReqVo reqVo) {
+////        if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
+////            return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
+////        }
+////
+////
+////        Criteria criteria = new Criteria();
+////        criteria.and("devBid").is(reqVo.getDevBid());
+////        if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
+////            criteria.and("pestrecogMarktype").is(reqVo.getPestrecogMarktype());
+////        }
+////        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
+////            criteria.and("pestrecogCreatedDate").is(reqVo.getPestrecogMarktype());
+////        }
+////        if (StringUtils.isEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
+////            criteria.and("pestrecogCreatedDate").is(reqVo.getPestrecogMarktype());
+////        }
+////        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
+////            criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime()).lte(reqVo.getEndTime());
+////        }
+////        MatchOperation matchOperation = Aggregation.match(criteria);
+////
+////        ProjectionOperation projectionOperation = Aggregation.project()
+////                .andExclude("_id")
+////                .and("$$ROOT").as("c");
+////
+////        LookupOperation lookupOperationIotCbdpest = Aggregation.lookup(
+////                "IotCbdpest", "c.pestrecogBid", "pestrecogBid", "cp"
+////        );
+////        UnwindOperation unwindOperationCp = Aggregation.unwind("cp", true);
+////
+////
+////        LookupOperation lookupOperationIotCbdrecog = Aggregation.lookup(
+////                "IotCbdrecog", "cp.cbdrecogBid", "cbdrecogBid", "ce"
+////        );
+////        UnwindOperation unwindOperationCe = Aggregation.unwind("ce", true);
+////        Criteria criteria2 = new Criteria()
+////                .and("ce.cbdrecogType").is(reqVo.getCbdRecogType());
+////        MatchOperation matchOperation2 = Aggregation.match(criteria2);
+////
+////        GroupOperation group = Aggregation.group("c.pestBusid")
+////                .first("c.pestBusid").as("pestBusid")
+////                .first("c.pestrecogCreatedDate").as("pestrecogCreatedDate")
+////                .sum("c.pestrecogNum").as("pestrecogNum");// fieldName为要分组的字段名称,totalField为需要求和的字段名称
+////
+////
+////        Aggregation aggregation = Aggregation.newAggregation(
+////                matchOperation,
+////                projectionOperation,
+////                lookupOperationIotCbdpest,
+////                unwindOperationCp,
+////                lookupOperationIotCbdrecog,
+////                unwindOperationCe,
+////                matchOperation2,
+////                group
+////        );
+////        List<IotPestrecog> results = mongoService.aggregate(IotPestrecog.class, aggregation, IotPestrecog.class);
+////
+////        //获取存在识别害虫集合
+////        List<IotPest> iotPests2 = getIotPestList(results);
+////
+////        List<Map<String, Object>> list1 = new ArrayList<>();
+////        //获取日期集合
+////        List<String> dateList = DatePlugUtil.getTwoDaysDayDes(reqVo.getStartTime(), reqVo.getEndTime());
+////        for (String s : dateList) {
+////            Map<String, Object> dateMap = new HashMap<>();
+////            dateMap.put("date", s);
+////            List<Map<String, Object>> list2 = new ArrayList<>();
+////            dateMap.put("data", list2);
+////            for (IotPest iotPest : iotPests2) {
+////                String pestBid = iotPest.getPestBid();
+////                Map<String, Object> pestMap = new HashMap<>();
+////                pestMap.put("pestName", iotPest.getPestName());
+////                pestMap.put("pestBid", iotPest.getPestBid());
+////                int sum = 0;
+////                for (IotPestrecog iotPestrecog : results) {
+////                    if (s.equals(iotPestrecog.getPestrecogCreatedDate().substring(0, 10))
+////                            && pestBid != null && pestBid.equals(iotPestrecog.getPestBusid())) {
+////                        sum += iotPestrecog.getPestrecogNum();
+////                    }
+////                }
+////                pestMap.put("sum", sum);
+////                list2.add(pestMap);
+////            }
+////            list1.add(dateMap);
+////        }
+////        return AjaxResult.success(list1);
+////    }
+//
+//
+//
 //    /**
 //     * 根据害虫进行区分统计
 //     */
@@ -312,226 +310,187 @@ public class IotPestrecogController extends BaseController {
 //            return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
 //        }
 //
-//        //获取识别数据
+//        List<IotPestrecogGroupByNameResVo> iotPestrecogGroupByNameResVoList = iIotPestrecogService.groupByName(reqVo);
+//        return AjaxResult.success(iotPestrecogGroupByNameResVoList);
+//    }
+//
+//    /**
+//     * 根据害虫业务标识查询始见期高峰期终见期
+//     */
+//    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:name')")
+//    @GetMapping("/period")
+//    public AjaxResult period(IotPestRecogPeriodReqVo reqVo) {
+//        Map<String, Object> resultMap = iIotPestrecogService.period(reqVo);
+//        return AjaxResult.success(resultMap);
+//    }
+//
+//    public List<IotPest> getIotPestList(List<IotPestrecog> list) {
+//        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
+//        List<IotPest> iotPests2 = new ArrayList<>();
+//        Set<String> set = new HashSet<>();
+//        for (IotPestrecog iotPestrecog : list) {
+//            set.add(iotPestrecog.getPestBusid());
+//        }
+//        for (String s : set) {
+//            IotPest iotPest1 = new IotPest();
+//            iotPest1.setPestBid(s);
+//            IotPest pest = pestMap.get(s);
+//            if (pest != null) {
+//                iotPest1.setPestName(pest.getPestName());
+//                iotPest1.setPestId(pest.getPestId());
+//            }
+//            iotPests2.add(iotPest1);
+//        }
+//        return iotPests2;
+//    }
+//
+//    protected TableDataInfo getDataTable(IPage page) {
+//        TableDataInfo rspData = new TableDataInfo();
+//        rspData.setCode(ErrorCode.SUCCESS.getCode());
+//        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
+//        rspData.setData(page.getRecords());
+//        rspData.setTotal(page.getTotal());
+//        return rspData;
+//    }
+//
+//    /**
+//     * 对列表与导出的参数进行封装
+//     *
+//     * @param reqVo
+//     * @return
+//     */
+//    private Map<String, Object> getParamMap(IotPestRecogPeriodReqVo reqVo) {
 //        Map<String, Object> map = new HashMap<>();
 //        map.put("devBid", reqVo.getDevBid());
+//
+//        if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
+//            map.put("pestrecogMarktype", reqVo.getPestrecogMarktype());
+//        }
+//        if (StringUtils.isNotEmpty(reqVo.getPestBids())) {
+//            map.put("newList_pestBusid", reqVo.getPestBids());
+//        }
+//        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
+//            map.put("gte_pestrecogCreatedDate", reqVo.getStartTime());
+//        }
+//        if (StringUtils.isEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
+//            map.put("lte_pestrecogCreatedDate", reqVo.getEndTime());
+//        }
 //        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
 //            map.put("time_pestrecogCreatedDate", reqVo.getStartTime() + "," + reqVo.getEndTime());
 //        }
-//        List<IotPestrecog> list = mongoService.findAll(IotPestrecog.class, map);
+//        return map;
+//    }
 //
-//        //获取存在识别害虫集合
-//        List<IotPest> iotPests2 = getIotPestList(list);
+//    /**
+//     * 对返回数据进行封装
+//     *
+//     * @param records
+//     * @return
+//     */
+//    private List<IotPestrecogResVo> getIotPestrecogResVoList(List<IotPestrecog> records) {
+//        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
+//        List<IotPestrecogResVo> list = new ArrayList<>();
+//        for (IotPestrecog record : records) {
+//            IotPestrecogResVo resVo = new IotPestrecogResVo();
+//            BeanUtils.copyProperties(record, resVo);
+//            AggregationOperation lookupOperation = LookupOperation.newLookup()
+//                    .from("IotCbdrecog")
+//                    .localField("cbdrecogBid")
+//                    .foreignField("cbdrecogBid")
+//                    .as("IotCbdrecog");
+//            Criteria criteria = new Criteria();
+//            criteria.and("pestrecogBid").is(record.getPestrecogBid());
+//            Aggregation aggregation = Aggregation.newAggregation(lookupOperation, Aggregation.match(criteria));
+////            Aggregation aggregation= Aggregation.newAggregation(
+////                    Aggregation.lookup("IotCbdrecog", "cbdrecogBid", "cbdrecogBid", "IotCbdrecog"),
+////                    Aggregation.match(criteria));
+//            AggregationResults<Document> result = mongoTemplate.aggregate(aggregation, "IotCbdpest", Document.class);
+//            List<Document> objs = result.getMappedResults();
+//            if (objs.size() > 0) {
+//                Document document = objs.get(0);
+//                JSONObject from = JSONObject.from(document);
+//                JSONArray array = from.getJSONArray("IotCbdrecog");
+//                if (array.size() > 0) {
+//                    JSONObject jsonObject = array.getJSONObject(0);
+//                    resVo.setCbdrecogAddr(jsonObject.getString("cbdrecogAddr"));
+//                    resVo.setCbdrecogManualaddr(jsonObject.getString("cbdrecogManualaddr"));
+//                    resVo.setCbdrecogMarktype(jsonObject.getString("cbdrecogMarktype"));
+//                    resVo.setCbdrecogManualmark(jsonObject.getString("cbdrecogManualmark"));
+//                    resVo.setCbdrecogMachinemark(jsonObject.getString("cbdrecogMachinemark"));
+//                }
+//            }
+//            if (!StringUtils.isEmpty(record.getPestBusid())) {
+//                IotPest pest = pestMap.get(record.getPestBusid());
+//                if (pest != null) {
+//                    resVo.setPestName(pest.getPestName());
+//                    resVo.setPestId(pest.getPestId());
+//                    list.add(resVo);
+//                } else {
+//                    // 手动识别的名字,待完善
+//                    resVo.setPestName("-");
+//                    list.add(resVo);
+//                }
 //
-//        List<Map<String, Object>> list1 = new ArrayList<>();
-//        for (IotPest iotPest : iotPests2) {
-//            String pestBid = iotPest.getPestBid();
-//            Map<String, Object> pestMap = new HashMap<>();
-//            pestMap.put("pestName", iotPest.getPestName());
-//            pestMap.put("pestBid", iotPest.getPestBid());
-//            int sum = 0;
-//            for (IotPestrecog iotPestrecog : list) {
-//                if (pestBid != null && pestBid.equals(iotPestrecog.getPestBusid())) {
-//                    sum += iotPestrecog.getPestrecogNum();
+//            }
+//
+//        }
+//        return list;
+//    }
+//
+//
+//    /**
+//     * 对返回数据进行封装
+//     *
+//     * @param records
+//     * @return
+//     */
+//    private List<IotPestrecogResVo> getIotPestrecogResVoList2(List<IotPestrecog> records) {
+//        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
+//        List<IotPestrecogResVo> list = new ArrayList<>();
+//        for (IotPestrecog record : records) {
+//            IotPestrecogResVo resVo = new IotPestrecogResVo();
+//            BeanUtils.copyProperties(record, resVo);
+//            AggregationOperation lookupOperation = LookupOperation.newLookup()
+//                    .from("IotCbdrecog")
+//                    .localField("cbdrecogBid")
+//                    .foreignField("cbdrecogBid")
+//                    .as("IotCbdrecog");
+//            Criteria criteria = new Criteria();
+//            criteria.and("pestrecogBid").is(record.getPestrecogBid());
+//            Aggregation aggregation = Aggregation.newAggregation(lookupOperation, Aggregation.match(criteria));
+////            Aggregation aggregation= Aggregation.newAggregation(
+////                    Aggregation.lookup("IotCbdrecog", "cbdrecogBid", "cbdrecogBid", "IotCbdrecog"),
+////                    Aggregation.match(criteria));
+//            AggregationResults<Document> result = mongoTemplate.aggregate(aggregation, "IotCbdpest", Document.class);
+//            List<Document> objs = result.getMappedResults();
+//            if (objs.size() > 0) {
+//                Document document = objs.get(0);
+//                JSONObject from = JSONObject.from(document);
+//                JSONArray array = from.getJSONArray("IotCbdrecog");
+//                if (array.size() > 0) {
+//                    JSONObject jsonObject = array.getJSONObject(0);
+//                    resVo.setCbdrecogAddr(jsonObject.getString("cbdrecogAddr"));
+//                    resVo.setCbdrecogManualaddr(jsonObject.getString("cbdrecogManualaddr"));
+//                    resVo.setCbdrecogMarktype(jsonObject.getString("cbdrecogMarktype"));
+//                    resVo.setCbdrecogManualmark(jsonObject.getString("cbdrecogManualmark"));
+//                    resVo.setCbdrecogMachinemark(jsonObject.getString("cbdrecogMachinemark"));
 //                }
 //            }
-//            pestMap.put("sum", sum);
-//            list1.add(pestMap);
+//            if (!StringUtils.isEmpty(record.getPestBusid())) {
+//                IotPest pest = pestMap.get(record.getPestBusid());
+//                if (pest != null) {
+//                    resVo.setPestName(pest.getPestName());
+//                    resVo.setPestId(pest.getPestId());
+//                    list.add(resVo);
+//                } else {
+//                    // 手动识别的名字,待完善
+//                    resVo.setPestName("-");
+//                    list.add(resVo);
+//                }
+//
+//            }
+//
 //        }
-//        return AjaxResult.success(list1);
+//        return list;
 //    }
-
-    /**
-     * 根据害虫进行区分统计
-     */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:name')")
-    @GetMapping("/group/name")
-    public AjaxResult groupByName(IotDeviceDataListReqVo reqVo) {
-        if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
-            return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
-        }
-
-        List<IotPestrecogGroupByNameResVo> iotPestrecogGroupByNameResVoList = iIotPestrecogService.groupByName(reqVo);
-        return AjaxResult.success(iotPestrecogGroupByNameResVoList);
-    }
-
-    /**
-     * 根据害虫业务标识查询始见期高峰期终见期
-     */
-    @PreAuthorize("@ss.hasPermi('iot:pestrecog:group:name')")
-    @GetMapping("/period")
-    public AjaxResult period(IotPestRecogPeriodReqVo reqVo) {
-        Map<String, Object> resultMap = iIotPestrecogService.period(reqVo);
-        return AjaxResult.success(resultMap);
-    }
-
-    public List<IotPest> getIotPestList(List<IotPestrecog> list) {
-        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
-        List<IotPest> iotPests2 = new ArrayList<>();
-        Set<String> set = new HashSet<>();
-        for (IotPestrecog iotPestrecog : list) {
-            set.add(iotPestrecog.getPestBusid());
-        }
-        for (String s : set) {
-            IotPest iotPest1 = new IotPest();
-            iotPest1.setPestBid(s);
-            IotPest pest = pestMap.get(s);
-            if (pest != null) {
-                iotPest1.setPestName(pest.getPestName());
-                iotPest1.setPestId(pest.getPestId());
-            }
-            iotPests2.add(iotPest1);
-        }
-        return iotPests2;
-    }
-
-    protected TableDataInfo getDataTable(IPage page) {
-        TableDataInfo rspData = new TableDataInfo();
-        rspData.setCode(ErrorCode.SUCCESS.getCode());
-        rspData.setMsg(ErrorCode.SUCCESS.getMessage());
-        rspData.setData(page.getRecords());
-        rspData.setTotal(page.getTotal());
-        return rspData;
-    }
-
-    /**
-     * 对列表与导出的参数进行封装
-     *
-     * @param reqVo
-     * @return
-     */
-    private Map<String, Object> getParamMap(IotPestRecogPeriodReqVo reqVo) {
-        Map<String, Object> map = new HashMap<>();
-        map.put("devBid", reqVo.getDevBid());
-
-        if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
-            map.put("pestrecogMarktype", reqVo.getPestrecogMarktype());
-        }
-        if (StringUtils.isNotEmpty(reqVo.getPestBids())) {
-            map.put("newList_pestBusid", reqVo.getPestBids());
-        }
-        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
-            map.put("gte_pestrecogCreatedDate", reqVo.getStartTime());
-        }
-        if (StringUtils.isEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
-            map.put("lte_pestrecogCreatedDate", reqVo.getEndTime());
-        }
-        if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
-            map.put("time_pestrecogCreatedDate", reqVo.getStartTime() + "," + reqVo.getEndTime());
-        }
-        return map;
-    }
-
-    /**
-     * 对返回数据进行封装
-     *
-     * @param records
-     * @return
-     */
-    private List<IotPestrecogResVo> getIotPestrecogResVoList(List<IotPestrecog> records) {
-        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
-        List<IotPestrecogResVo> list = new ArrayList<>();
-        for (IotPestrecog record : records) {
-            IotPestrecogResVo resVo = new IotPestrecogResVo();
-            BeanUtils.copyProperties(record, resVo);
-            AggregationOperation lookupOperation = LookupOperation.newLookup()
-                    .from("IotCbdrecog")
-                    .localField("cbdrecogBid")
-                    .foreignField("cbdrecogBid")
-                    .as("IotCbdrecog");
-            Criteria criteria = new Criteria();
-            criteria.and("pestrecogBid").is(record.getPestrecogBid());
-            Aggregation aggregation = Aggregation.newAggregation(lookupOperation, Aggregation.match(criteria));
-//            Aggregation aggregation= Aggregation.newAggregation(
-//                    Aggregation.lookup("IotCbdrecog", "cbdrecogBid", "cbdrecogBid", "IotCbdrecog"),
-//                    Aggregation.match(criteria));
-            AggregationResults<Document> result = mongoTemplate.aggregate(aggregation, "IotCbdpest", Document.class);
-            List<Document> objs = result.getMappedResults();
-            if (objs.size() > 0) {
-                Document document = objs.get(0);
-                JSONObject from = JSONObject.from(document);
-                JSONArray array = from.getJSONArray("IotCbdrecog");
-                if (array.size() > 0) {
-                    JSONObject jsonObject = array.getJSONObject(0);
-                    resVo.setCbdrecogAddr(jsonObject.getString("cbdrecogAddr"));
-                    resVo.setCbdrecogManualaddr(jsonObject.getString("cbdrecogManualaddr"));
-                    resVo.setCbdrecogMarktype(jsonObject.getString("cbdrecogMarktype"));
-                    resVo.setCbdrecogManualmark(jsonObject.getString("cbdrecogManualmark"));
-                    resVo.setCbdrecogMachinemark(jsonObject.getString("cbdrecogMachinemark"));
-                }
-            }
-            if (!StringUtils.isEmpty(record.getPestBusid())) {
-                IotPest pest = pestMap.get(record.getPestBusid());
-                if (pest != null) {
-                    resVo.setPestName(pest.getPestName());
-                    resVo.setPestId(pest.getPestId());
-                    list.add(resVo);
-                } else {
-                    // 手动识别的名字,待完善
-                    resVo.setPestName("-");
-                    list.add(resVo);
-                }
-
-            }
-
-        }
-        return list;
-    }
-
-
-    /**
-     * 对返回数据进行封装
-     *
-     * @param records
-     * @return
-     */
-    private List<IotPestrecogResVo> getIotPestrecogResVoList2(List<IotPestrecog> records) {
-        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
-        List<IotPestrecogResVo> list = new ArrayList<>();
-        for (IotPestrecog record : records) {
-            IotPestrecogResVo resVo = new IotPestrecogResVo();
-            BeanUtils.copyProperties(record, resVo);
-            AggregationOperation lookupOperation = LookupOperation.newLookup()
-                    .from("IotCbdrecog")
-                    .localField("cbdrecogBid")
-                    .foreignField("cbdrecogBid")
-                    .as("IotCbdrecog");
-            Criteria criteria = new Criteria();
-            criteria.and("pestrecogBid").is(record.getPestrecogBid());
-            Aggregation aggregation = Aggregation.newAggregation(lookupOperation, Aggregation.match(criteria));
-//            Aggregation aggregation= Aggregation.newAggregation(
-//                    Aggregation.lookup("IotCbdrecog", "cbdrecogBid", "cbdrecogBid", "IotCbdrecog"),
-//                    Aggregation.match(criteria));
-            AggregationResults<Document> result = mongoTemplate.aggregate(aggregation, "IotCbdpest", Document.class);
-            List<Document> objs = result.getMappedResults();
-            if (objs.size() > 0) {
-                Document document = objs.get(0);
-                JSONObject from = JSONObject.from(document);
-                JSONArray array = from.getJSONArray("IotCbdrecog");
-                if (array.size() > 0) {
-                    JSONObject jsonObject = array.getJSONObject(0);
-                    resVo.setCbdrecogAddr(jsonObject.getString("cbdrecogAddr"));
-                    resVo.setCbdrecogManualaddr(jsonObject.getString("cbdrecogManualaddr"));
-                    resVo.setCbdrecogMarktype(jsonObject.getString("cbdrecogMarktype"));
-                    resVo.setCbdrecogManualmark(jsonObject.getString("cbdrecogManualmark"));
-                    resVo.setCbdrecogMachinemark(jsonObject.getString("cbdrecogMachinemark"));
-                }
-            }
-            if (!StringUtils.isEmpty(record.getPestBusid())) {
-                IotPest pest = pestMap.get(record.getPestBusid());
-                if (pest != null) {
-                    resVo.setPestName(pest.getPestName());
-                    resVo.setPestId(pest.getPestId());
-                    list.add(resVo);
-                } else {
-                    // 手动识别的名字,待完善
-                    resVo.setPestName("-");
-                    list.add(resVo);
-                }
-
-            }
-
-        }
-        return list;
-    }
 }

+ 59 - 96
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/service/impl/IotPestrecogServiceImpl.java

@@ -29,7 +29,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 @Service
 public class IotPestrecogServiceImpl implements IIotPestrecogService {
@@ -45,6 +44,61 @@ public class IotPestrecogServiceImpl implements IIotPestrecogService {
 
     /**
      * @param reqVo
+     * @return
+     */
+    @Override
+    public List<IotPestrecogGroupByNameResVo> groupByName(IotDeviceDataListReqVo reqVo) {
+        String startTime = reqVo.getStartTime();
+        String endTime = reqVo.getEndTime();
+        String devBid = reqVo.getDevBid();
+        String cbdrecogType = reqVo.getCbdrecogType();
+        String cbdrecogMarktype = reqVo.getCbdrecogMarktype();
+
+        Criteria criteria = new Criteria()
+                .and("devBid").is(devBid)
+                .and("cbdimgDelstatus").is("0");
+        if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
+            criteria = criteria.andOperator(
+                    Criteria.where("cbdimgCreatedDate").gte(startTime),
+                    Criteria.where("cbdimgCreatedDate").lte(endTime)
+            );
+        } else if (StringUtils.isNotEmpty(startTime)) {
+            criteria = criteria.and("cbdimgCreatedDate").gte(startTime);
+        } else if (StringUtils.isNotEmpty(endTime)) {
+            criteria = criteria.and("cbdimgCreatedDate").lte(endTime);
+        }
+        MatchOperation matchOperation = Aggregation.match(criteria);
+        ProjectionOperation projectionOperation = Aggregation.project()
+                .and("cbdrecog." + cbdrecogType + ".pestrecog." + cbdrecogMarktype).as("pestrecog");
+
+        UnwindOperation unwindOperation = Aggregation.unwind("pestrecog", false);
+
+        GroupOperation groupOperation = Aggregation.group("pestrecog.pestBusid")
+                .first("pestrecog.pestName").as("pestName")
+                .sum("pestrecog.pestrecogNum").as("pestrecogNum");
+
+        ProjectionOperation projectionOperation2 = Aggregation.project()
+                .and("_id").as("pestBid")
+                .and("pestName").as("pestName")
+                .and("pestrecogNum").as("sum");
+
+        SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "sum");
+
+        Aggregation aggregation = Aggregation.newAggregation(
+                matchOperation,
+                projectionOperation,
+                unwindOperation,
+                groupOperation,
+                projectionOperation2,
+                sortOperation
+        );
+        return (List<IotPestrecogGroupByNameResVo>) mongoService.aggregate(
+                IotCbdimg.class, aggregation, IotPestrecogGroupByNameResVo.class
+        );
+    }
+
+    /**
+     * @param reqVo
      * @param pageDomain
      * @return
      */
@@ -515,105 +569,14 @@ public class IotPestrecogServiceImpl implements IIotPestrecogService {
      * @return
      */
     @Override
-    public List<IotPestrecogGroupByNameResVo> groupByName(IotDeviceDataListReqVo reqVo) {
-        String startTime = reqVo.getStartTime();
-        String endTime = reqVo.getEndTime();
-        String devBid = reqVo.getDevBid();
-        String cbdRecogType = reqVo.getCbdRecogType();
-        String pestrecogMarktype = reqVo.getPestrecogMarktype();
-
-        Criteria criteria = new Criteria()
-                .and("devBid").is(devBid)
-                .and("cbdimgDelstatus").is("0");
-        if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
-            criteria = criteria.andOperator(
-                    Criteria.where("cbdimgCreatedDate").gte(startTime),
-                    Criteria.where("cbdimgCreatedDate").lte(endTime)
-            );
-        } else if (StringUtils.isNotEmpty(startTime)) {
-            criteria = criteria.and("cbdimgCreatedDate").gte(startTime);
-        } else if (StringUtils.isNotEmpty(endTime)) {
-            criteria = criteria.and("cbdimgCreatedDate").lte(endTime);
-        }
-        MatchOperation matchOperation = Aggregation.match(criteria);
-
-        ProjectionOperation projectionOperation = Aggregation.project()
-                .andExclude("_id")
-                .and("$$ROOT").as("c");
-        LookupOperation lookupOperationIotCbdrecog = Aggregation.lookup(
-                "IotCbdrecog", "c.cbdimgBid", "cbdimgBid", "ce"
-        );
-        Criteria cbdRecogCriteria = new Criteria()
-                .and("ce.cbdrecogType").is(cbdRecogType)
-                .and("ce.cbdrecogMarktype").is(pestrecogMarktype);
-
-        MatchOperation cbdRecogMatchOperation = Aggregation.match(cbdRecogCriteria);
-        UnwindOperation unwindOperationCe = Aggregation.unwind("ce", true);
-
-        LookupOperation lookupOperationIotCbdpest = Aggregation.lookup(
-                "IotCbdpest", "ce.cbdrecogBid", "cbdrecogBid", "cp"
-        );
-        UnwindOperation unwindOperationCp = Aggregation.unwind("cp", true);
-
-        LookupOperation lookupOperationIotPestrecog = Aggregation.lookup(
-                "IotPestrecog", "cp.pestrecogBid", "pestrecogBid", "pr"
-        );
-        UnwindOperation unwindOperationPr = Aggregation.unwind("pr", true);
-        Criteria criteria2 = new Criteria()
-                .and("pr.pestrecogMarktype").is(pestrecogMarktype);
-        MatchOperation matchOperation2 = Aggregation.match(criteria2);
-
-        GroupOperation groupOperation = Aggregation.group("pr.pestBusid")
-                .first("pr.pestBusid").as("pestBusid")
-                .sum("pr.pestrecogNum").as("sum");
-
-        ProjectionOperation projectionOperation2 = Aggregation.project()
-                .and("pestBusid").as("pestBid")
-                .and("sum").as("sum");
-
-        SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "sum");
-
-        Aggregation aggregation = Aggregation.newAggregation(
-                matchOperation,
-                projectionOperation,
-                lookupOperationIotCbdrecog,
-                unwindOperationCe,
-                cbdRecogMatchOperation,
-                lookupOperationIotCbdpest,
-                unwindOperationCp,
-                lookupOperationIotPestrecog,
-                unwindOperationPr,
-                matchOperation2,
-                groupOperation,
-                projectionOperation2,
-                sortOperation
-        );
-        List<IotPestrecogGroupByNameResVo> iotPestrecogGroupByNameResVoList = mongoService.aggregate(
-                IotCbdimg.class, aggregation, IotPestrecogGroupByNameResVo.class
-        );
-
-        Map<String, IotPest> pestMap = iotPestService.selectIotPestMapAllInfo();
-        return  iotPestrecogGroupByNameResVoList.stream().filter(item->
-                {
-                    if(pestMap.containsKey(item.getPestBid())){
-                        item.setPestName(pestMap.get(item.getPestBid()).getPestName());
-                    }
-                    return StringUtils.isNotEmpty(item.getPestBid());
-                }
-        ).collect(Collectors.toList());
-    }
-
-    /**
-     * @param reqVo
-     * @return
-     */
-    @Override
     public List<IotPestrecog> groupByDateName(IotDeviceDataListReqVo reqVo) {
         String startTime = reqVo.getStartTime();
         String endTime = reqVo.getEndTime();
         String devBid = reqVo.getDevBid();
-        String cbdRecogType = reqVo.getCbdRecogType();
-        String pestrecogMarktype = reqVo.getPestrecogMarktype();
+        String cbdRecogType = "";
+        String pestrecogMarktype = "";
+//        String cbdRecogType = reqVo.getCbdRecogType();
+//        String pestrecogMarktype = reqVo.getPestrecogMarktype();
 
         Criteria criteria = new Criteria()
                 .and("devBid").is(devBid)

+ 1 - 1
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDeviceServiceImpl.java

@@ -64,7 +64,7 @@ public class IotDeviceServiceImpl implements IIotDeviceService
     @Autowired
     private IotDeviceRefreshService iotDeviceRefreshService;
 
-    @Value("${runMode.dev:1}")
+    @Value("${runMode.env:1}")
     private String runMode;
 
     /**

+ 2 - 1
src/main/resources/mapper/IotDeviceMapper.xml

@@ -58,7 +58,8 @@
     <select id="selectIotDeviceList" parameterType="IotDevice" resultMap="IotDeviceResult">
         <include refid="selectIotDeviceVo"/>
         <where>
-            d.tid = #{tid} and d.devDelstatus = '0'
+            d.devDelstatus = '0'
+            <if test="tid != null">and d.tid = #{tid}</if>
             <if test="devBid != null  and devBid != ''">and d.devBid = #{devBid}</if>
             <if test="devtypeBid != null  and devtypeBid != ''">and d.devtypeBid = #{devtypeBid}</if>
             <if test="firmBid != null  and firmBid != ''">and d.firmBid = #{firmBid}</if>

+ 1 - 1
src/main/resources/mapper/IotDeviceconnMapper.xml

@@ -103,7 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectIotDeviceconnByBid" parameterType="string" resultType="com.yunfeiyun.agmp.iot.common.domain.IotDeviceconn">
         SELECT dcn.devconnBid, dcn.devconnType, dcn.devconnName, dcn.devconnRemark, dc.devclassBid, dc.devclassCode,
-            dc.devclassName, dt.devtypeBid, dt.devtypeCode, dt.devtypeName, dcn.devconnCreateddate
+            dc.devclassName, dt.devtypeBid, dt.devtypeCode, dt.devtypeName, dcn.devconnCreateddate, dt.firmBid
         FROM IotDeviceconn AS dcn
             LEFT JOIN TosDevicetype AS dt ON dt.devtypeBid = dcn.devtypeBid
             LEFT JOIN TosDeviceclass AS dc ON dc.devclassBid = dt.devclassBid