|
@@ -1,39 +1,23 @@
|
|
|
package com.yunfeiyun.agmp.iotm.device.pest.controller;
|
|
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.constant.ErrorCode;
|
|
|
import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
|
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
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.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.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.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.IIotPestService;
|
|
|
import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
|
|
import com.yunfeiyun.agmp.iotm.device.pest.service.IIotPestrecogService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.bson.Document;
|
|
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
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.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
|
|
* 虫情识别信息表Controller
|
|
@@ -55,179 +39,69 @@ public class IotPestrecogController extends BaseController {
|
|
|
private MongoTemplate mongoTemplate;
|
|
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())) {
|
|
if (StringUtils.isEmpty(reqVo.getStartTime()) || StringUtils.isEmpty(reqVo.getEndTime())) {
|
|
|
return AjaxResult.error(ErrorCode.INVALID_PARAMETER.getCode(), "时间不能为空");
|
|
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 criteria = new Criteria();
|
|
|
// criteria.and("devBid").is(reqVo.getDevBid());
|
|
// criteria.and("devBid").is(reqVo.getDevBid());
|
|
|
// if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
|
|
// if (StringUtils.isNotEmpty(reqVo.getPestrecogMarktype())) {
|
|
|
// criteria.and("pestrecogMarktype").is(reqVo.getPestrecogMarktype());
|
|
// criteria.and("pestrecogMarktype").is(reqVo.getPestrecogMarktype());
|
|
|
// }
|
|
// }
|
|
|
// if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isEmpty(reqVo.getEndTime())) {
|
|
// 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())) {
|
|
// 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())) {
|
|
// if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
|
|
|
// criteria.and("pestrecogCreatedDate").gte(reqVo.getStartTime()).lte(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);
|
|
// UnwindOperation unwindOperationCe = Aggregation.unwind("ce", true);
|
|
|
// Criteria criteria2 = new Criteria()
|
|
// 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);
|
|
// 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为需要求和的字段名称
|
|
// .sum("c.pestrecogNum").as("pestrecogNum");// fieldName为要分组的字段名称,totalField为需要求和的字段名称
|
|
|
//
|
|
//
|
|
|
//
|
|
//
|
|
@@ -267,8 +140,38 @@ public class IotPestrecogController extends BaseController {
|
|
|
// unwindOperationCe,
|
|
// unwindOperationCe,
|
|
|
// matchOperation2,
|
|
// matchOperation2,
|
|
|
// group
|
|
// 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);
|
|
// List<IotPest> iotPests2 = getIotPestList(results);
|
|
@@ -300,8 +203,103 @@ public class IotPestrecogController extends BaseController {
|
|
|
// }
|
|
// }
|
|
|
// return AjaxResult.success(list1);
|
|
// 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(), "时间不能为空");
|
|
// 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<String, Object> map = new HashMap<>();
|
|
|
// map.put("devBid", reqVo.getDevBid());
|
|
// 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())) {
|
|
// if (StringUtils.isNotEmpty(reqVo.getStartTime()) && StringUtils.isNotEmpty(reqVo.getEndTime())) {
|
|
|
// map.put("time_pestrecogCreatedDate", reqVo.getStartTime() + "," + 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;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|