|
|
@@ -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(
|