Przeglądaj źródła

新增 获取识别图片列表接口

zhaiyifei 1 rok temu
rodzic
commit
071a0afaf6

+ 17 - 32
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/controller/IotPestrecogController.java

@@ -1,12 +1,19 @@
 package com.yunfeiyun.agmp.iotm.device.pest.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.fasterxml.jackson.core.JsonProcessingException;
 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.utils.StringUtils;
 import com.yunfeiyun.agmp.iot.common.service.MongoService;
 import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestRecogPeriodReqVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogGroupByNameResVo;
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogListResVo;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
 import lombok.extern.slf4j.Slf4j;
@@ -51,25 +58,16 @@ public class IotPestrecogController extends BaseController {
         return AjaxResult.success(groupByNameResVoList);
     }
 
-//    /**
-//     * 识别数据列表
-//     */
-//    @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:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
+        PageDomain pageDomain = TableSupport.buildPageRequest();
+        IPage<IotPestrecogListResVo> listPage = iIotPestrecogService.selectIotPestrecogList(reqVo, pageDomain);
+        return getDataTable(listPage);
+    }
 //
 //    /**
 //     * 导出识别数据列表
@@ -300,19 +298,6 @@ public class IotPestrecogController extends BaseController {
 //
 //
 //
-//    /**
-//     * 根据害虫进行区分统计
-//     */
-//    @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);
-//    }
 //
 //    /**
 //     * 根据害虫业务标识查询始见期高峰期终见期

+ 0 - 13
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/domain/IotPestRecogPeriodReqVo.java

@@ -1,10 +1,8 @@
 package com.yunfeiyun.agmp.iotm.device.pest.domain;
 
-import com.yunfeiyun.agmp.iot.common.enums.EnumCbdRecogType;
 import lombok.Data;
 
 import java.util.List;
-import java.util.Objects;
 
 /**
  * 获取害虫周期
@@ -52,10 +50,6 @@ public class IotPestRecogPeriodReqVo {
     private String endTime;
 
     /**
-     * 标记类型 1 AI,0 人工
-     */
-    private String pestrecogMarktype;
-    /**
      * 设备ids
      */
     private List<String> devBids;
@@ -71,11 +65,4 @@ public class IotPestRecogPeriodReqVo {
      * 标记类型 1 AI,0 人工
      */
     private String cbdrecogMarktype;
-
-    public String getCbdRecogType() {
-        if(!Objects.equals(cbdrecogType, EnumCbdRecogType.A.getCode()) && !Objects.equals(cbdrecogType, EnumCbdRecogType.B.getCode())) {
-            return EnumCbdRecogType.A.getCode();
-        }
-        return cbdrecogType;
-    }
 }

+ 104 - 0
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/domain/IotPestrecogListResVo.java

@@ -0,0 +1,104 @@
+package com.yunfeiyun.agmp.iotm.device.pest.domain;
+
+import com.yunfeiyun.agmp.common.annotation.Excel;
+import lombok.Data;
+
+/**
+ * 虫情识别信息对象 IotPestrecog
+ *
+ * @author 杨晓辉
+ * @date 2024-01-04
+ */
+@Data
+public class IotPestrecogListResVo
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 图片基础业务标识 */
+    @Excel(name = "图片基础业务标识")
+    private String cbdimgBid;
+
+    /** 设备业务标识 */
+    @Excel(name = "设备业务标识")
+    private String devBid;
+
+    /** 原图地址 */
+    @Excel(name = "原图地址")
+    private String cbdimgAddr;
+
+    /** 修改时间 */
+    @Excel(name = "修改时间")
+    private String cbdimgModifieddate;
+
+    /** 创建时间 */
+    @Excel(name = "创建时间")
+    private String cbdimgCreatedDate;
+
+    /** 图片识别业务标识 */
+    @Excel(name = "图片识别业务标识")
+    private String cbdrecogBid;
+
+    /** 识别类型 */
+    @Excel(name = "识别类型")
+    private String cbdrecogType;
+
+    /** 标记类型 */
+    @Excel(name = "标记类型")
+    private String cbdrecogMarktype;
+
+    /** 识别图片地址 */
+    @Excel(name = "机器识别图片地址")
+    private String cbdrecogAddr;
+
+    /** 手动标记图片地址 */
+    @Excel(name = "手动标记图片地址")
+    private String cbdrecogManualaddr;
+
+    /** 害虫机器识别结果 */
+    @Excel(name = "害虫机器识别结果")
+    private String cbdrecogResult;
+
+    /** 害虫手动识别结果 */
+    @Excel(name = "害虫手动识别结果")
+    private String cbdrecogResultManual;
+
+    /** 手动标记结果 */
+    @Excel(name = "手动标记结果")
+    private String cbdrecogManualmark;
+
+    /** 机器标注结果 */
+    @Excel(name = "机器标注结果")
+    private String cbdrecogMachinemark;
+
+    /** 机器识别总数 */
+    @Excel(name = "机器识别总数")
+    private Long cbdrecogTotalnum;
+
+    /** 机器识别害虫数量 */
+    @Excel(name = "机器识别害虫数量")
+    private Long cbdrecogPestnum;
+
+    /** 识别类型 */
+    @Excel(name = "机器识别害虫类型数量")
+    private Long cbdrecogTypenum;
+
+    /** 手动识别总数 */
+    @Excel(name = "手动识别总数")
+    private Long cbdrecogTotalnumManual;
+
+    /** 手动识别害虫数量 */
+    @Excel(name = "手动识别害虫数量")
+    private Long cbdrecogPestnumManual;
+
+    /** 手动识别害虫类型数量 */
+    @Excel(name = "手动识别害虫类型数量")
+    private Long cbdrecogTypenumManual;
+
+    /** 修改时间 */
+    @Excel(name = "修改时间")
+    private String cbdrecogModifieddate;
+
+    /** 创建时间 */
+    @Excel(name = "创建时间")
+    private String cbdrecogCreatedDate;
+}

+ 2 - 3
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/service/IIotPestrecogService.java

@@ -8,16 +8,15 @@ import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestRecogPeriodReqVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogExportResVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogGroupByNameResVo;
-import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogResVo;
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogListResVo;
 import com.yunfeiyun.agmp.iotm.device.xy.domain.IotXyinfoPestTotalDto;
 
 import java.util.List;
 import java.util.Map;
 
 public interface IIotPestrecogService {
-    public IPage<IotPestrecogResVo> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo, PageDomain pageDomain) throws JsonProcessingException;
+    public IPage<IotPestrecogListResVo> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo, PageDomain pageDomain) throws JsonProcessingException;
 
-    public List<IotPestrecog> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException;
     public List<IotPestrecogExportResVo> exportIotPestrecogList(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException;
 
     public List<IotPestrecogGroupByNameResVo> groupByName(IotDeviceDataListReqVo reqVo);

+ 2 - 113
src/main/java/com/yunfeiyun/agmp/iotm/device/pest/service/impl/IotCbdimgServiceImpl.java

@@ -45,123 +45,12 @@ public class IotCbdimgServiceImpl implements IIotCbdimgService {
     @Autowired
     private MongoService mongoService;
 
-    /**
-     * @param reqVo
-     */
-//    @Override
-//    public IotCbdimgSumInfoResVo sumInfo(IotPestRecogPeriodReqVo reqVo) {
-//        String devBid = reqVo.getDevBid();
-//        String startTime = reqVo.getStartTime();
-//        String endTime = reqVo.getEndTime();
-//        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()
-//                .andExclude("_id")
-//                .and("$$ROOT").as("c");
-//        LookupWithPipelineOperation lookupWithPipelineOperation = new LookupWithPipelineOperation(
-//                "IotCbdrecog", "c.cbdimgBid", "cbdimgBid", "ce",
-//                new Document().append("$match", new Document().append("cbdrecogType", cbdRecogType).append("cbdrecogMarktype", "1")));
-//        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);
-//
-//        GroupOperation groupOperation = Aggregation.group("c.cbdimgBid")
-//                .push("cp").as("recogArray")
-//                .push("pr.pestrecogNum").as("pestArray")
-//                .addToSet("pr.pestBusid").as("pestTypeArray");
-//
-//        ProjectionOperation projectionOperationResult = Aggregation.project("_id")
-//                .and("_id").as("cbdimgBid")
-//                .andExpression("{'$cond': {'if': {'$eq': {{'$size': '$recogArray'},0}},'then': 1,'else':0}}").as("noRecog")
-//                .and("pestTypeArray").as("pestTypeArray")
-//                .andExpression("{$sum: '$pestArray'}").as("pestNum");
-//
-//        GroupOperation groupOperation2 = Aggregation.group()
-//                .count().as("imgCount")
-//                .sum("noRecog").as("noRecogImgCount")
-//                .sum("pestNum").as("sum")
-//                .push("pestTypeArray").as("pestTypeArray");
-//
-//        UnwindOperation unwindOperationPest = Aggregation.unwind("pestTypeArray", true);
-//        GroupOperation groupOperation3 = Aggregation.group()
-//                .first("imgCount").as("imgCount")
-//                .first("noRecogImgCount").as("noRecogImgCount")
-//                .first("sum").as("sum")
-//                .addToSet("pestTypeArray").as("pestTypeArray");
-//        ProjectionOperation projectionOperationResult2 = Aggregation.project("_id")
-//                .and("imgCount").as("imgCount")
-//                .and("sum").as("sum")
-//                .and("noRecogImgCount").as("noRecogImgCount")
-//                .andExpression("{$size: '$pestTypeArray'}").as("typeCount");
-//
-//        Aggregation aggregation = Aggregation.newAggregation(
-//                matchOperation,
-//                projectionOperation,
-//                lookupWithPipelineOperation,
-//                unwindOperationCe,
-//                lookupOperationIotCbdpest,
-//                unwindOperationCp,
-//                lookupOperationIotPestrecog,
-//                unwindOperationPr,
-//                groupOperation,
-//                projectionOperationResult,
-//                groupOperation2,
-//                unwindOperationPest,
-//                unwindOperationPest,
-//                groupOperation3,
-//                projectionOperationResult2
-//        );
-//
-//        List<IotCbdimgSumInfoResVo> iIotCbdimgSumInfoResVoList = mongoService.aggregate(
-//                IotCbdimg.class, aggregation, IotCbdimgSumInfoResVo.class
-//        );
-//
-//        IotCbdimgSumInfoResVo iotCbdimgSumInfoResVo = new IotCbdimgSumInfoResVo();
-//        iotCbdimgSumInfoResVo.setSum(0);
-//        iotCbdimgSumInfoResVo.setImgCount(0);
-//        iotCbdimgSumInfoResVo.setNoRecogImgCount(0);
-//        iotCbdimgSumInfoResVo.setTypeCount(0);
-//        iotCbdimgSumInfoResVo.setRecogImgCount(0);
-//
-//        if (iIotCbdimgSumInfoResVoList.size() > 0) {
-//            iotCbdimgSumInfoResVo = iIotCbdimgSumInfoResVoList.get(0);
-//            iotCbdimgSumInfoResVo.setRecogImgCount(iotCbdimgSumInfoResVo.getImgCount() - iotCbdimgSumInfoResVo.getNoRecogImgCount());
-//        }
-//        return iotCbdimgSumInfoResVo;
-//    }
-
     @Override
     public IotCbdimgSumInfoResVo sumInfo(IotPestRecogPeriodReqVo reqVo) {
         String devBid = reqVo.getDevBid();
         String startTime = reqVo.getStartTime();
         String endTime = reqVo.getEndTime();
-        String cbdrecogType = reqVo.getCbdRecogType();
+        String cbdrecogType = reqVo.getCbdrecogType();
         String cbdrecogMarktype = reqVo.getCbdrecogMarktype();
         String cbdrecogPestnumStr = ".cbdrecogPestnum";
         if(Objects.equals(cbdrecogMarktype, EnumCbdMarkType.HAND.getCode())){
@@ -238,7 +127,7 @@ public class IotCbdimgServiceImpl implements IIotCbdimgService {
         String devBid = reqV.getDevBid();
         String startTime = reqV.getStartTime();
         String endTime = reqV.getEndTime();
-        String cbdRecogType = reqV.getCbdRecogType();
+        String cbdRecogType = reqV.getCbdrecogType();
         Criteria criteria = new Criteria().and("cbdimgDelstatus").is("0");
         //支持单个设备查询/多个查询
         List<String> devBids = reqV.getDevBids();

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

@@ -1,6 +1,5 @@
 package com.yunfeiyun.agmp.iotm.device.pest.service.impl;
 
-import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -14,7 +13,7 @@ import com.yunfeiyun.agmp.iotm.device.common.domin.IotDeviceDataListReqVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestRecogPeriodReqVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogExportResVo;
 import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogGroupByNameResVo;
-import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogResVo;
+import com.yunfeiyun.agmp.iotm.device.pest.domain.IotPestrecogListResVo;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestService;
 import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
 import com.yunfeiyun.agmp.iotm.device.xy.domain.IotXyinfoPestTotalDto;
@@ -103,280 +102,52 @@ public class IotPestrecogServiceImpl implements IIotPestrecogService {
      * @return
      */
     @Override
-    public IPage<IotPestrecogResVo> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo, PageDomain pageDomain) throws JsonProcessingException {
+    public IPage<IotPestrecogListResVo> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo, PageDomain pageDomain) {
         String devBid = reqVo.getDevBid();
         String startTime = reqVo.getStartTime();
         String endTime = reqVo.getEndTime();
-        String pestrecogMarktype = reqVo.getPestrecogMarktype();
-        String cbdRecogType = reqVo.getCbdRecogType();
+        String cbdrecogMarktype = reqVo.getCbdrecogMarktype();
+        String cbdrecogType = reqVo.getCbdrecogType();
         List<String> pestBids = reqVo.getPestBids();
 
-        Criteria criteria = new Criteria().and("devBid").is(devBid);
-        if(StringUtils.isNotEmpty(pestrecogMarktype)){
-            criteria.and("pestrecogMarktype").is(pestrecogMarktype);
-        }
-        List<IotPest> iotPestList = new ArrayList<>();
-        if(pestBids != null){
-            criteria.and("pestBusid").in(pestBids);
-            iotPestList = iotPestService.selectIotPestListBatchByBid(pestBids);
-        }
-        Map<String, IotPest> iotPestMap = new HashMap<>();
-        if(iotPestList != null){
-            for(IotPest iotPest: iotPestList){
-                String pestId = iotPest.getPestId();
-                if(!iotPestMap.containsKey(pestId)){
-                    iotPestMap.put(pestId, iotPest);
-                }
-            }
-        }
-
-        MatchOperation matchOperation = Aggregation.match(criteria);
-
-        ProjectionOperation projectionOperation = Aggregation.project()
-                .andExclude("_id")
-                .and("$$ROOT").as("pr");
-
-        LookupOperation lookupOperationIotCbdpest = Aggregation.lookup(
-                "IotCbdpest", "pr.pestrecogBid", "pestrecogBid", "cp"
-        );
-        UnwindOperation unwindOperationCp = Aggregation.unwind("cp", true);
-
-        LookupOperation lookupOperationIotCbdrecog = Aggregation.lookup(
-                "IotCbdrecog", "cp.cbdrecogBid", "cbdrecogBid", "cr"
-        );
-        UnwindOperation unwindOperationCr = Aggregation.unwind("cr", true);
-
-        LookupOperation lookupOperationIotCbdimg = Aggregation.lookup(
-                "IotCbdimg", "cr.cbdimgBid", "cbdimgBid", "ci"
-        );
-        UnwindOperation unwindOperationCi = Aggregation.unwind("ci", true);
-
-        GroupOperation groupOperation = Aggregation.group("cr.cbdrecogBid")
-                .first("pr").as("pr")
-                .first("cr").as("cr")
-                .first("ci").as("ci")
-                .sum("pr.pestrecogNum").as("pestrecogNum");
-
-        Criteria criteria2 = new Criteria()
-                .and("ci.cbdimgDelstatus").is("0")
-                .and("cr.cbdrecogType").is(cbdRecogType)
-                .and("cr.cbdrecogMarktype").is(pestrecogMarktype);
+        Criteria criteria = new Criteria()
+                .and("devBid").is(devBid)
+                .and("cbdimgDelstatus").is("0");
 
         if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
-            criteria2 = criteria2.andOperator(
-                    Criteria.where("cr.cbdrecogCreatedDate").gte(startTime),
-                    Criteria.where("cr.cbdrecogCreatedDate").lte(endTime)
+            criteria = criteria.andOperator(
+                    Criteria.where("cbdrecog." + cbdrecogType + ".cbdrecogModifieddate").gte(startTime),
+                    Criteria.where("cbdrecog." + cbdrecogType + ".cbdrecogModifieddate").lte(endTime)
             );
         } else if (StringUtils.isNotEmpty(startTime)) {
-            criteria2 = criteria2.and("cr.cbdrecogCreatedDate").gte(startTime);
+            criteria = criteria.and("cbdrecog." + cbdrecogType + ".cbdrecogModifieddate").gte(startTime);
         } else if (StringUtils.isNotEmpty(endTime)) {
-            criteria2 = criteria2.and("cr.cbdrecogCreatedDate").lte(endTime);
+            criteria = criteria.and("cbdrecog." + cbdrecogType + ".cbdrecogModifieddate").lte(endTime);
         }
-        MatchOperation matchOperation2 = Aggregation.match(criteria2);
-
-        ProjectionOperation projectionOperationResult = Aggregation.project("_id")
-                .and("pr.pestrecogBid").as("pestrecogBid")
-                .and("pr.devBid").as("devBid")
-                .and("pr.devtypeBid").as("devtypeBid")
-                .and("pr.pestrecogAt").as("pestrecogAt")
-                .and("pr.pestrecogAh").as("pestrecogAh")
-                .and("pr.pestrecogLng").as("pestrecogLng")
-                .and("pr.pestrecogLat").as("pestrecogLat")
-                .and("pr.pestrecogProvince").as("pestrecogProvince")
-                .and("pr.pestrecogCity").as("pestrecogCity")
-                .and("pr.pestrecogDistrict").as("pestrecogDistrict")
-                .and("pr.pestBusid").as("pestBusid")
-
-                .and("pestrecogNum").as("pestrecogNum")
-                .and("cr.cbdrecogCreatedDate").as("pestrecogCreatedDate")
-                .and("cr.cbdrecogAddr").as("cbdrecogAddr")
-                .and("cr.cbdrecogManualaddr").as("cbdrecogManualaddr")
-                .and("cr.cbdrecogMarktype").as("cbdrecogMarktype")
-                .and("cr.cbdrecogManualmark").as("cbdrecogManualmark")
-                .and("cr.cbdrecogMachinemark").as("cbdrecogMachinemark")
-                .and("cr.cbdrecogBid").as("cbdrecogBid")
-
-                .and("cr.cbdrecogCreatedDate").as("cbdrecogCreatedDate")
-                .and("ci.cbdimgBid").as("cbdimgBid")
-                .and("ci.cbdimgPestnum").as("cbdimgPestnum")
-                .and("ci.cbdimgRecognum").as("cbdimgRecognum")
-                .and("ci.cbdimgAddr").as("cbdimgAddr");
-
-        SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "cbdrecogCreatedDate");
-
-        Aggregation aggregation = Aggregation.newAggregation(
-                matchOperation,
-                projectionOperation,
-                lookupOperationIotCbdpest,
-                unwindOperationCp,
-                lookupOperationIotCbdrecog,
-                unwindOperationCr,
-                lookupOperationIotCbdimg,
-                unwindOperationCi,
-                matchOperation2,
-                groupOperation,
-                projectionOperationResult,
-                sortOperation
-        );
-        IPage<IotPestrecogResVo> listPage = mongoService.aggregate(
-                IotPestrecog.class, aggregation, IotPestrecogResVo.class, pageDomain
-        );
-        List<IotPestrecogResVo> records = listPage.getRecords();
-
-        for(IotPestrecogResVo iotPestrecogResVo: records){
-            String cbdrecogMachinemark = iotPestrecogResVo.getCbdrecogMachinemark();
 
-            List pestList = (List) JSON.parse(cbdrecogMachinemark);
-            if(pestList == null){
-                continue;
-            }
-            StringBuilder newResult = new StringBuilder();
-            for(Object o: pestList){
-                JSONObject jsonObject = JSONObject.from(o);
-                for(String k: jsonObject.keySet()){
-                    if(iotPestMap.containsKey(k)){
-                        newResult.append("{'")
-                                .append(k).append("': ").append(jsonObject.getJSONArray(k))
-                                .append("}").append(",");
-                    }
-                }
-            }
-            if (newResult.length() > 0){
-                newResult.deleteCharAt(newResult.length()-1);
-                newResult.insert(0, "[");
-                newResult.append("]");
-                iotPestrecogResVo.setCbdrecogMachinemark(newResult.toString());
-                listPage.setRecords(records);
-            }
-        }
-        return listPage;
-    }
-
-    /**
-     * @param reqVo
-     * @return
-     * @throws JsonProcessingException
-     */
-    @Override
-    public List<IotPestrecog> selectIotPestrecogList(IotPestRecogPeriodReqVo reqVo) throws JsonProcessingException {
-        String devBid = reqVo.getDevBid();
-        String startTime = reqVo.getStartTime();
-        String endTime = reqVo.getEndTime();
-        String pestrecogMarktype = reqVo.getPestrecogMarktype();
-        String cbdRecogType = reqVo.getCbdRecogType();
-        List<String> pestBids = reqVo.getPestBids();
-
-        Criteria criteria = new Criteria().and("devBid").is(devBid);
-        if(StringUtils.isNotEmpty(pestrecogMarktype)){
-            criteria.and("pestrecogMarktype").is(pestrecogMarktype);
-        }
-        List<IotPest> iotPestList = new ArrayList<>();
-        if(pestBids != null){
-            criteria.and("pestBusid").in(pestBids);
-            iotPestList = iotPestService.selectIotPestListBatchByBid(pestBids);
-        }
-        Map<String, IotPest> iotPestMap = new HashMap<>();
-        if(iotPestList != null){
-            for(IotPest iotPest: iotPestList){
-                String pestId = iotPest.getPestId();
-                if(!iotPestMap.containsKey(pestId)){
-                    iotPestMap.put(pestId, iotPest);
-                }
-            }
+        if(pestBids != null && !pestBids.isEmpty()){
+            criteria = criteria.and("cbdrecog." + cbdrecogType + ".pestrecog." + cbdrecogMarktype + ".pestBusid").in(pestBids);
+        }else{
+            criteria = criteria.and("cbdrecog." + cbdrecogType + ".pestrecog." + cbdrecogMarktype + ".pestBusid").exists(true);
         }
 
         MatchOperation matchOperation = Aggregation.match(criteria);
+        SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "cbdrecog."+cbdrecogType+".cbdrecogModifieddate");
 
-        ProjectionOperation projectionOperation = Aggregation.project()
-                .andExclude("_id")
-                .and("$$ROOT").as("pr");
-
-        LookupOperation lookupOperationIotCbdpest = Aggregation.lookup(
-                "IotCbdpest", "pr.pestrecogBid", "pestrecogBid", "cp"
-        );
-        UnwindOperation unwindOperationCp = Aggregation.unwind("cp", true);
-
-        LookupOperation lookupOperationIotCbdrecog = Aggregation.lookup(
-                "IotCbdrecog", "cp.cbdrecogBid", "cbdrecogBid", "cr"
-        );
-        UnwindOperation unwindOperationCr = Aggregation.unwind("cr", true);
-
-        LookupOperation lookupOperationIotCbdimg = Aggregation.lookup(
-                "IotCbdimg", "cr.cbdimgBid", "cbdimgBid", "ci"
-        );
-        UnwindOperation unwindOperationCi = Aggregation.unwind("ci", true);
-
-        GroupOperation groupOperation = Aggregation.group("cr.cbdrecogBid")
-                .first("pr").as("pr")
-                .first("cr").as("cr")
-                .first("ci").as("ci")
-                .sum("pr.pestrecogNum").as("pestrecogNum");
-
-        Criteria criteria2 = new Criteria()
-                .and("ci.cbdimgDelstatus").is("0")
-                .and("cr.cbdrecogType").is(cbdRecogType)
-                .and("cr.cbdrecogMarktype").is(pestrecogMarktype);
-
-        if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
-            criteria2 = criteria2.andOperator(
-                    Criteria.where("cr.cbdrecogCreatedDate").gte(startTime),
-                    Criteria.where("cr.cbdrecogCreatedDate").lte(endTime)
-            );
-        } else if (StringUtils.isNotEmpty(startTime)) {
-            criteria2 = criteria2.and("cr.cbdrecogCreatedDate").gte(startTime);
-        } else if (StringUtils.isNotEmpty(endTime)) {
-            criteria2 = criteria2.and("cr.cbdrecogCreatedDate").lte(endTime);
-        }
-        MatchOperation matchOperation2 = Aggregation.match(criteria2);
-
-        ProjectionOperation projectionOperationResult = Aggregation.project("_id")
-                .and("pr.pestrecogBid").as("pestrecogBid")
-                .and("pr.devBid").as("devBid")
-                .and("pr.devtypeBid").as("devtypeBid")
-                .and("pr.pestrecogAt").as("pestrecogAt")
-                .and("pr.pestrecogAh").as("pestrecogAh")
-                .and("pr.pestrecogLng").as("pestrecogLng")
-                .and("pr.pestrecogLat").as("pestrecogLat")
-                .and("pr.pestrecogProvince").as("pestrecogProvince")
-                .and("pr.pestrecogCity").as("pestrecogCity")
-                .and("pr.pestrecogDistrict").as("pestrecogDistrict")
-                .and("pr.pestBusid").as("pestBusid")
-
-                .and("pestrecogNum").as("pestrecogNum")
-                .and("cr.cbdrecogCreatedDate").as("pestrecogCreatedDate")
-                .and("cr.cbdrecogAddr").as("cbdrecogAddr")
-                .and("cr.cbdrecogManualaddr").as("cbdrecogManualaddr")
-                .and("cr.cbdrecogMarktype").as("cbdrecogMarktype")
-                .and("cr.cbdrecogManualmark").as("cbdrecogManualmark")
-                .and("cr.cbdrecogMachinemark").as("cbdrecogMachinemark")
-                .and("cr.cbdrecogBid").as("cbdrecogBid")
-
-                .and("cr.cbdrecogCreatedDate").as("cbdrecogCreatedDate")
-                .and("ci.cbdimgBid").as("cbdimgBid")
-                .and("ci.cbdimgPestnum").as("cbdimgPestnum")
-                .and("ci.cbdimgRecognum").as("cbdimgRecognum")
-                .and("ci.cbdimgAddr").as("cbdimgAddr");
+        ReplaceRootOperation replaceRootOperation = Aggregation.replaceRoot("cbdrecog."+cbdrecogType);
 
-        SortOperation sortOperation = Aggregation.sort(Sort.Direction.DESC, "cbdrecogCreatedDate");
+        ProjectionOperation projectionOperation = Aggregation.project().andExclude("pestrecog");
 
         Aggregation aggregation = Aggregation.newAggregation(
                 matchOperation,
-                projectionOperation,
-                lookupOperationIotCbdpest,
-                unwindOperationCp,
-                lookupOperationIotCbdrecog,
-                unwindOperationCr,
-                lookupOperationIotCbdimg,
-                unwindOperationCi,
-                matchOperation2,
-                groupOperation,
-                projectionOperationResult,
-                sortOperation
+                sortOperation,
+                replaceRootOperation,
+                projectionOperation
         );
-        List<IotPestrecog> iotPestrecogList = mongoService.aggregate(
-                IotPestrecog.class, aggregation, IotPestrecog.class
+        IPage<IotPestrecogListResVo> listPage = mongoService.aggregate(
+                IotCbdimg.class, aggregation, IotPestrecogListResVo.class, pageDomain
         );
-        return iotPestrecogList;
+        return listPage;
     }
 
     /**
@@ -389,13 +160,13 @@ public class IotPestrecogServiceImpl implements IIotPestrecogService {
         String devBid = reqVo.getDevBid();
         String startTime = reqVo.getStartTime();
         String endTime = reqVo.getEndTime();
-        String pestrecogMarktype = reqVo.getPestrecogMarktype();
-        String cbdRecogType = reqVo.getCbdRecogType();
+        String cbdrecogMarktype = reqVo.getCbdrecogMarktype();
+        String cbdrecogType = reqVo.getCbdrecogType();
         List<String> pestBids = reqVo.getPestBids();
 
         Criteria criteria = new Criteria().and("devBid").is(devBid);
-        if(StringUtils.isNotEmpty(pestrecogMarktype)){
-            criteria.and("pestrecogMarktype").is(pestrecogMarktype);
+        if(StringUtils.isNotEmpty(cbdrecogMarktype)){
+            criteria.and("pestrecogMarktype").is(cbdrecogMarktype);
         }
         List<IotPest> iotPestList = new ArrayList<>();
         if(pestBids != null){
@@ -441,8 +212,8 @@ public class IotPestrecogServiceImpl implements IIotPestrecogService {
 
         Criteria criteria2 = new Criteria()
                 .and("ci.cbdimgDelstatus").is("0")
-                .and("cr.cbdrecogType").is(cbdRecogType)
-                .and("cr.cbdrecogMarktype").is(pestrecogMarktype);
+                .and("cr.cbdrecogType").is(cbdrecogType)
+                .and("cr.cbdrecogMarktype").is(cbdrecogMarktype);
 
         if (StringUtils.isNotEmpty(startTime) && StringUtils.isNotEmpty(endTime)) {
             criteria2 = criteria2.andOperator(