|
|
@@ -2,25 +2,25 @@ package com.yunfeiyun.agmp.iots.device.serviceImp;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.annotation.TableName;
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
import com.yunfeiyun.agmp.common.constant.ResConstants;
|
|
|
-import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
+import com.yunfeiyun.agmp.common.utils.JSONUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
-
|
|
|
-import com.yunfeiyun.agmp.iot.common.domain.*;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotCbdPestrecog;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotCbdimg;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotCbdrecog;
|
|
|
+import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
+import com.yunfeiyun.agmp.iot.common.enums.EnumCbdMarkType;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumCbdRecogType;
|
|
|
-import com.yunfeiyun.agmp.iot.common.model.IotWarncheck;
|
|
|
+import com.yunfeiyun.agmp.iot.common.exception.IotBizException;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.YfCbdRecogeService;
|
|
|
import com.yunfeiyun.agmp.iot.common.util.tmn.cbd.CbdInsectIdentifyUtil;
|
|
|
-
|
|
|
import com.yunfeiyun.agmp.iots.service.IIotDeviceService;
|
|
|
import com.yunfeiyun.agmp.iots.service.IIotPestService;
|
|
|
import com.yunfeiyun.agmp.iots.service.impl.WarnService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
-import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -58,10 +58,25 @@ public class IotCbdImgService {
|
|
|
return StringUtils.isNotEmpty(v) && !v.equals("0") ? v : "";
|
|
|
}
|
|
|
|
|
|
- private void saveRecogImgByA(IotDevice iotDevice, IotCbdimg iotCbdimg, JSONObject jsonObject, IotPestRecogService.PestRecogResult pestRecogResult){
|
|
|
- String cbdrecogResult = this.getJsonData("Result", jsonObject);
|
|
|
- String cbdrecogAddr = this.getJsonData("Result_image", jsonObject);
|
|
|
- String cbdrecogMachinemark = this.getJsonData("Result_code", jsonObject);
|
|
|
+ private IotCbdrecog makeRecogImg(EnumCbdRecogType enumCbdRecogType, EnumCbdMarkType enumCbdMarkType,
|
|
|
+ IotDevice iotDevice, IotCbdimg iotCbdimg, JSONObject jsonObject, long cbdrecogTotalnum){
|
|
|
+
|
|
|
+ String cbdRecogType = enumCbdRecogType.getCode();
|
|
|
+ String cbdMarkType = enumCbdMarkType.getCode();
|
|
|
+ String cbdrecogResult = null;
|
|
|
+ String cbdrecogAddr = null;
|
|
|
+ String cbdrecogMachinemark = null;
|
|
|
+ if(Objects.equals(cbdRecogType, EnumCbdRecogType.A.getCode())){
|
|
|
+ cbdrecogResult = this.getJsonData("Result", jsonObject);
|
|
|
+ cbdrecogAddr = this.getJsonData("Result_image", jsonObject);
|
|
|
+ cbdrecogMachinemark = this.getJsonData("Result_code", jsonObject);
|
|
|
+ }else if(Objects.equals(cbdRecogType, EnumCbdRecogType.B.getCode())){
|
|
|
+ cbdrecogResult = this.getJsonData("Result_b", jsonObject);
|
|
|
+ cbdrecogAddr = this.getJsonData("Result_image_b", jsonObject);
|
|
|
+ cbdrecogMachinemark = this.getJsonData("Result_code_b", jsonObject);
|
|
|
+ }else{
|
|
|
+ throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(), "不支持的识别类型:" + cbdRecogType);
|
|
|
+ }
|
|
|
|
|
|
String recogBid = iotCbdimg.getUUId();
|
|
|
JSONArray recogArray = JSONArray.parseArray(cbdrecogMachinemark);
|
|
|
@@ -73,43 +88,103 @@ public class IotCbdImgService {
|
|
|
cbdrecogAddr = getPestRecogImgOssUrl(iotCbdimg.getCbdimgAddr(), recogBid, points);
|
|
|
}
|
|
|
|
|
|
- // 保存 测报灯图片识别信息
|
|
|
- IotCbdrecog iotCbdrecog = iotCbdRecogService.saveIotCbdRecog(
|
|
|
- EnumCbdRecogType.A, recogBid, iotCbdimg, iotDevice, cbdrecogAddr, cbdrecogResult, cbdrecogMachinemark, pestRecogResult);
|
|
|
+ // 生成测报灯图片识别信息
|
|
|
+ IotCbdrecog iotCbdrecog = iotCbdRecogService.makeIotCbdRecog(recogBid, iotCbdimg, iotDevice, cbdrecogAddr,
|
|
|
+ cbdrecogResult, cbdrecogMachinemark);
|
|
|
|
|
|
- // 保存 虫情识别信息
|
|
|
- iotPestRecogService.savePestRecog(pestRecogResult, iotDevice, iotCbdrecog);
|
|
|
- }
|
|
|
+ iotCbdrecog.setCbdrecogType(cbdRecogType);
|
|
|
+ iotCbdrecog.setCbdrecogMarktype(cbdMarkType);
|
|
|
+ iotCbdrecog.setCbdrecogTotalnum(cbdrecogTotalnum);
|
|
|
|
|
|
- private void saveRecogImgByB(IotDevice iotDevice, IotCbdimg iotCbdimg, JSONObject jsonObject, IotPestRecogService.PestRecogResult pestRecogResult){
|
|
|
- String cbdrecogResultB = this.getJsonData("Result_b", jsonObject);
|
|
|
- String cbdrecogAddrB = this.getJsonData("Result_image_b", jsonObject);
|
|
|
- String cbdrecogMachinemarkB = this.getJsonData("Result_code_b", jsonObject);
|
|
|
+ IotPestRecogService.PestRecogResult pestRecogResult = iotPestRecogService.getIotPestrecogResult(
|
|
|
+ iotDevice, iotCbdrecog);
|
|
|
|
|
|
- String recogBid = iotCbdimg.getUUId();
|
|
|
- JSONArray recogArray = JSONArray.parseArray(cbdrecogMachinemarkB);
|
|
|
- if (recogArray != null){
|
|
|
- List<JSONObject> points = new ArrayList<>();
|
|
|
- for(Object o: JSONArray.parseArray(cbdrecogMachinemarkB)){
|
|
|
- points.add((JSONObject) o);
|
|
|
- }
|
|
|
- cbdrecogAddrB = getPestRecogImgOssUrl(iotCbdimg.getCbdimgAddr(), recogBid, points);
|
|
|
- }
|
|
|
+ List<IotCbdPestrecog> iotCbdPestrecogList = pestRecogResult.getIotCbdPestrecogList();
|
|
|
+ iotCbdrecog.setCbdrecogPestnum(pestRecogResult.getCbdimgRecognumTotal());
|
|
|
+ iotCbdrecog.setCbdrecogTypenum(pestRecogResult.getCbdrecogTypenum());
|
|
|
+ Map<String, List<IotCbdPestrecog>> pestrecogMap = new HashMap<>();
|
|
|
+ pestrecogMap.put(cbdMarkType, iotCbdPestrecogList);
|
|
|
+ iotCbdrecog.setPestrecog(pestrecogMap);
|
|
|
|
|
|
- // 保存 测报灯图片识别信息
|
|
|
- IotCbdrecog iotCbdrecog = iotCbdRecogService.saveIotCbdRecog(
|
|
|
- EnumCbdRecogType.B, recogBid, iotCbdimg, iotDevice, cbdrecogAddrB, cbdrecogResultB, cbdrecogMachinemarkB, pestRecogResult);
|
|
|
+ log.info("【测报灯生成解析图片】:{} 内容 {}",iotDevice, JSONUtils.toJSONString(iotCbdrecog));
|
|
|
|
|
|
// 保存 虫情识别信息
|
|
|
- iotPestRecogService.savePestRecog(pestRecogResult, iotDevice, iotCbdrecog);
|
|
|
+ iotPestRecogService.savePestRecog(pestRecogResult);
|
|
|
+ return iotCbdrecog;
|
|
|
}
|
|
|
+//
|
|
|
+// private IotCbdrecog saveRecogImgByA(IotDevice iotDevice, IotCbdimg iotCbdimg, JSONObject jsonObject,
|
|
|
+// long cbdrecogTotalnum){
|
|
|
+// String cbdrecogResult = this.getJsonData("Result", jsonObject);
|
|
|
+// String cbdrecogAddr = this.getJsonData("Result_image", jsonObject);
|
|
|
+// String cbdrecogMachinemark = this.getJsonData("Result_code", jsonObject);
|
|
|
+//
|
|
|
+// String recogBid = iotCbdimg.getUUId();
|
|
|
+// JSONArray recogArray = JSONArray.parseArray(cbdrecogMachinemark);
|
|
|
+// if (recogArray != null){
|
|
|
+// List<JSONObject> points = new ArrayList<>();
|
|
|
+// for(Object o: JSONArray.parseArray(cbdrecogMachinemark)){
|
|
|
+// points.add((JSONObject) o);
|
|
|
+// }
|
|
|
+// cbdrecogAddr = getPestRecogImgOssUrl(iotCbdimg.getCbdimgAddr(), recogBid, points);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 生成测报灯图片识别信息
|
|
|
+// IotCbdrecog iotCbdrecog = iotCbdRecogService.makeIotCbdRecog(recogBid, iotCbdimg, iotDevice, cbdrecogAddr,
|
|
|
+// cbdrecogResult, cbdrecogMachinemark);
|
|
|
+//
|
|
|
+// String enumCbdRecogType = EnumCbdRecogType.A.getCode();
|
|
|
+// String enumCbdMarkType = EnumCbdMarkType.AUTO.getCode();
|
|
|
+// iotCbdrecog.setCbdrecogType(enumCbdRecogType);
|
|
|
+// iotCbdrecog.setCbdrecogMarktype(enumCbdMarkType);
|
|
|
+// iotCbdrecog.setCbdrecogTotalnum(cbdrecogTotalnum);
|
|
|
+//
|
|
|
+// IotPestRecogService.PestRecogResult pestRecogResult = iotPestRecogService.getIotPestrecogResult(
|
|
|
+// iotDevice, iotCbdrecog);
|
|
|
+//
|
|
|
+// List<IotCbdPestrecog> iotCbdPestrecogList = pestRecogResult.getIotCbdPestrecogList();
|
|
|
+// iotCbdrecog.setCbdrecogPestnum(pestRecogResult.getCbdimgRecognumTotal());
|
|
|
+// iotCbdrecog.setCbdrecogTypenum(pestRecogResult.getCbdrecogTypenum());
|
|
|
+// Map<String, List<IotCbdPestrecog>> pestrecogMap = new HashMap<>();
|
|
|
+// pestrecogMap.put(enumCbdMarkType, iotCbdPestrecogList);
|
|
|
+// iotCbdrecog.setPestrecog(pestrecogMap);
|
|
|
+//
|
|
|
+// log.info("【测报灯生成解析图片】:{} 内容 {}",iotDevice, JSONUtils.toJSONString(iotCbdrecog));
|
|
|
+//
|
|
|
+// // 保存 虫情识别信息
|
|
|
+// iotPestRecogService.savePestRecog(pestRecogResult);
|
|
|
+// return iotCbdrecog;
|
|
|
+// }
|
|
|
+
|
|
|
+// private void saveRecogImgByB(IotDevice iotDevice, IotCbdimg iotCbdimg, JSONObject jsonObject, IotPestRecogService.PestRecogResult pestRecogResult){
|
|
|
+// String cbdrecogResultB = this.getJsonData("Result_b", jsonObject);
|
|
|
+// String cbdrecogAddrB = this.getJsonData("Result_image_b", jsonObject);
|
|
|
+// String cbdrecogMachinemarkB = this.getJsonData("Result_code_b", jsonObject);
|
|
|
+//
|
|
|
+// String recogBid = iotCbdimg.getUUId();
|
|
|
+// JSONArray recogArray = JSONArray.parseArray(cbdrecogMachinemarkB);
|
|
|
+// if (recogArray != null){
|
|
|
+// List<JSONObject> points = new ArrayList<>();
|
|
|
+// for(Object o: JSONArray.parseArray(cbdrecogMachinemarkB)){
|
|
|
+// points.add((JSONObject) o);
|
|
|
+// }
|
|
|
+// cbdrecogAddrB = getPestRecogImgOssUrl(iotCbdimg.getCbdimgAddr(), recogBid, points);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 保存 测报灯图片识别信息
|
|
|
+// IotCbdrecog iotCbdrecog = iotCbdRecogService.saveIotCbdRecog(
|
|
|
+// EnumCbdRecogType.B, recogBid, iotCbdimg, iotDevice, cbdrecogAddrB, cbdrecogResultB, cbdrecogMachinemarkB, pestRecogResult);
|
|
|
+//
|
|
|
+// // 保存 虫情识别信息
|
|
|
+// iotPestRecogService.savePestRecog(pestRecogResult, iotDevice, iotCbdrecog);
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 保存测报灯图片基础数据到mongodb
|
|
|
* @return
|
|
|
*/
|
|
|
public IotCbdimg insertIotCbdimg(IotDevice iotDevice, JSONObject jsonObject, String devUpdateddate){
|
|
|
- long cbdimgPestnum;
|
|
|
+ long cbdrecogTotalnum;
|
|
|
|
|
|
String cbdimgAddr = this.getJsonData("Image", jsonObject);
|
|
|
String cbdrecogResult = this.getJsonData("Result", jsonObject);
|
|
|
@@ -119,51 +194,63 @@ public class IotCbdImgService {
|
|
|
String cbdrecogResultB = this.getJsonData("Result_b", jsonObject);
|
|
|
|
|
|
try{
|
|
|
- cbdimgPestnum = Long.parseLong(cbdimgPestnumStr.split(",")[1]);
|
|
|
+ cbdrecogTotalnum = Long.parseLong(cbdimgPestnumStr.split(",")[1]);
|
|
|
} catch (Exception e) {
|
|
|
- cbdimgPestnum = 0L;
|
|
|
+ cbdrecogTotalnum = 0L;
|
|
|
}
|
|
|
|
|
|
- IotPestRecogService.PestRecogResult pestRecogResult = iotPestRecogService.getIotPestrecogResult(
|
|
|
- iotDevice, cbdrecogResult, devUpdateddate);
|
|
|
-
|
|
|
- IotPestRecogService.PestRecogResult pestRecogResultB = iotPestRecogService.getIotPestrecogResult(
|
|
|
- iotDevice, cbdrecogResultB, devUpdateddate);
|
|
|
-
|
|
|
+ Map<String, IotCbdrecog> cbdrecog = new HashMap<>();
|
|
|
// 保存 测报灯基础图片信息
|
|
|
IotCbdimg iotCbdimg = new IotCbdimg();
|
|
|
iotCbdimg.setCbdimgBid(iotCbdimg.getUUId());
|
|
|
iotCbdimg.setTid(iotDevice.getTid());
|
|
|
iotCbdimg.setDevBid(iotDevice.getDevBid());
|
|
|
+ iotCbdimg.setCbdimgTotalnum(cbdrecogTotalnum);
|
|
|
iotCbdimg.setCbdimgAddr(cbdimgAddr);
|
|
|
- iotCbdimg.setCbdimgPestnum(cbdimgPestnum);
|
|
|
- iotCbdimg.setCbdimgRecognum(pestRecogResult.getCbdimgRecognumTotal());
|
|
|
iotCbdimg.setCbdimgModifieddate(devUpdateddate);
|
|
|
iotCbdimg.setCbdimgCreatedDate(devUpdateddate);
|
|
|
+ iotCbdimg.setCbdrecog(cbdrecog);
|
|
|
iotCbdimg.setCbdimgDelstatus("0");
|
|
|
- mongoService.saveOne(iotCbdimg);
|
|
|
|
|
|
- log.info("【测报灯】 开始A模型识别图片:" + cbdimgAddr);
|
|
|
- saveRecogImgByA(iotDevice, iotCbdimg, jsonObject, pestRecogResult);
|
|
|
- log.info("【测报灯】 结束A模型识别图片:" + cbdimgAddr);
|
|
|
- log.info("【测报灯】 是否识别B模型:" + cbdimgAddrB + (StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")));
|
|
|
+ if(cbdrecogTotalnum == 0){
|
|
|
+ log.info("【测报灯】 {} 没有识别结果,识别终止。{}", iotDevice, jsonObject);
|
|
|
+ mongoService.saveOne(iotCbdimg);
|
|
|
+ return iotCbdimg;
|
|
|
+ }
|
|
|
+
|
|
|
+ IotCbdrecog iotCbdrecogA = null;
|
|
|
+ IotCbdrecog iotCbdrecogB = null;
|
|
|
+
|
|
|
+ log.info("【测报灯】 是否识别A模型:" + StringUtils.isNotEmpty(cbdrecogResult) + " " + iotDevice);
|
|
|
+ if(StringUtils.isNotEmpty(cbdrecogResult)){
|
|
|
+ log.info("【测报灯】 开始A模型识别图片:" + cbdimgAddr);
|
|
|
+ iotCbdrecogA = makeRecogImg(EnumCbdRecogType.A, EnumCbdMarkType.AUTO, iotDevice, iotCbdimg, jsonObject, cbdrecogTotalnum);
|
|
|
+ log.info("【测报灯】 结束A模型识别图片:" + cbdimgAddr);
|
|
|
+ cbdrecog.put(EnumCbdRecogType.A.getCode(), iotCbdrecogA);
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("【测报灯】 是否识别B模型:" + StringUtils.isNotEmpty(cbdrecogResultB) + " " + iotDevice);
|
|
|
// 保存 测报灯B模型图片识别信息
|
|
|
- if(StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")){
|
|
|
+ if(StringUtils.isNotEmpty(cbdrecogResultB)){
|
|
|
log.info("【测报灯】 开始B模型识别图片:" + cbdimgAddrB);
|
|
|
- saveRecogImgByB(iotDevice, iotCbdimg, jsonObject, pestRecogResultB);
|
|
|
+ iotCbdrecogB = makeRecogImg(EnumCbdRecogType.B, EnumCbdMarkType.AUTO, iotDevice, iotCbdimg, jsonObject, cbdrecogTotalnum);
|
|
|
log.info("【测报灯】 结束B模型识别图片:" + cbdimgAddrB);
|
|
|
+ cbdrecog.put(EnumCbdRecogType.B.getCode(), iotCbdrecogB);
|
|
|
}
|
|
|
|
|
|
- if("3".equals(warnService.getWarnVer()) ){
|
|
|
- //要求预警检查 V3
|
|
|
- IotWarncheck warncheck = new IotWarncheck();
|
|
|
- warncheck.setDevBid(iotDevice.getDevBid());
|
|
|
- // TODO
|
|
|
- // iotsMqService.sendMsg(IotMqConstant.TOPIC_WARNCHECK, IotMqConstant.TOPIC_WARNCHECK, warncheck);
|
|
|
- }else{
|
|
|
- //预警
|
|
|
- warnService.checkCbdData("0","",iotDevice.getDevBid());
|
|
|
- }
|
|
|
+ iotCbdimg.setCbdrecog(cbdrecog);
|
|
|
+ mongoService.saveOne(iotCbdimg);
|
|
|
+
|
|
|
+// if("3".equals(warnService.getWarnVer()) ){
|
|
|
+// //要求预警检查 V3
|
|
|
+// IotWarncheck warncheck = new IotWarncheck();
|
|
|
+// warncheck.setDevBid(iotDevice.getDevBid());
|
|
|
+// // TODO
|
|
|
+// // iotsMqService.sendMsg(IotMqConstant.TOPIC_WARNCHECK, IotMqConstant.TOPIC_WARNCHECK, warncheck);
|
|
|
+// }else{
|
|
|
+// //预警
|
|
|
+// warnService.checkCbdData("0","",iotDevice.getDevBid());
|
|
|
+// }
|
|
|
return iotCbdimg;
|
|
|
}
|
|
|
|
|
|
@@ -203,96 +290,99 @@ public class IotCbdImgService {
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void iotmAgainRecog(String content) throws Exception {
|
|
|
- JSONObject contentObject = JSONObject.parseObject(content);
|
|
|
- String devBid = contentObject.getString("devBid");
|
|
|
- String cbdimgBid = contentObject.getString("cbdimgBid");
|
|
|
- String cbdrecogType = contentObject.getString("cbdrecogType");
|
|
|
-
|
|
|
- JSONObject recogeData=null;
|
|
|
- try{
|
|
|
- recogeData = getRecogeResult(cbdimgBid, cbdrecogType);
|
|
|
-
|
|
|
- }catch (Exception e){
|
|
|
- log.error("{}",e);
|
|
|
-
|
|
|
- }
|
|
|
- if(recogeData==null){
|
|
|
- recogeData=new JSONObject();
|
|
|
- }
|
|
|
- String cbdrecogResult = this.getJsonData("Result", recogeData);
|
|
|
- String cbdrecogResultB = this.getJsonData("Result_b", recogeData);
|
|
|
- String cbdimgAddrB = this.getJsonData("Result_image_b", recogeData);
|
|
|
-
|
|
|
- String devUpdateddate = DateUtils.dateTimeNow();
|
|
|
-
|
|
|
- IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
-
|
|
|
- IotPestRecogService.PestRecogResult pestRecogResult = iotPestRecogService.getIotPestrecogResult(
|
|
|
- iotDevice, cbdrecogResult, devUpdateddate);
|
|
|
-
|
|
|
- IotPestRecogService.PestRecogResult pestRecogResultB = iotPestRecogService.getIotPestrecogResult(
|
|
|
- iotDevice, cbdrecogResultB, devUpdateddate);
|
|
|
-
|
|
|
- Criteria criteria = Criteria.where("cbdimgBid").is(cbdimgBid);
|
|
|
- Query query = new Query(criteria);
|
|
|
-
|
|
|
- Map<String, Object> updateField = new HashMap<>();
|
|
|
- updateField.put("cbdimgRecognum", pestRecogResult.getCbdimgRecognumTotal());
|
|
|
- updateField.put("cbdimgModifieddate", devUpdateddate);
|
|
|
- mongoService.update(IotCbdimg.class, query, updateField);
|
|
|
-
|
|
|
- IotCbdimg iotCbdimg = (IotCbdimg) mongoService.findOne("cbdimgBid", cbdimgBid, IotCbdimg.class);
|
|
|
- String cbdimgAddr = iotCbdimg.getCbdimgAddr();
|
|
|
-
|
|
|
- Map<String, String> recogeSelectMap = new HashMap<>();
|
|
|
- recogeSelectMap.put("cbdimgBid", cbdimgBid);
|
|
|
- recogeSelectMap.put("cbdrecogMarktype", "1");
|
|
|
- recogeSelectMap.put("cbdrecogType", cbdrecogType);
|
|
|
- List<IotCbdrecog> iotCbdrecogList = mongoService.findAll(IotCbdrecog.class, recogeSelectMap);
|
|
|
- List<String> cbdrecogBidList = new ArrayList<>();
|
|
|
- if(iotCbdrecogList != null && iotCbdrecogList.size() > 0){
|
|
|
- for(IotCbdrecog iotCbdrecog : iotCbdrecogList){
|
|
|
- String cbdrecogBid = iotCbdrecog.getCbdrecogBid();
|
|
|
- cbdrecogBidList.add(cbdrecogBid);
|
|
|
- }
|
|
|
- }
|
|
|
- // newList_picBid
|
|
|
- List<String> pestrecogBidList = new ArrayList<>();
|
|
|
- List<String> cbdpestBidList = new ArrayList<>();
|
|
|
- if(cbdrecogBidList.size() > 0){
|
|
|
- Map<String, Object> pestSelectMap = new HashMap<>();
|
|
|
- pestSelectMap.put("newList_cbdrecogBid", cbdrecogBidList);
|
|
|
- List<IotCbdpest> IotCbdpestList = mongoService.findAll(IotCbdpest.class, pestSelectMap);
|
|
|
- if(IotCbdpestList != null && IotCbdpestList.size() > 0){
|
|
|
- for(IotCbdpest iotCbdpest : IotCbdpestList) {
|
|
|
- String pestrecogBid = iotCbdpest.getPestrecogBid();
|
|
|
- String cbdpestBid = iotCbdpest.getCbdpestBid();
|
|
|
- pestrecogBidList.add(pestrecogBid);
|
|
|
- cbdpestBidList.add(cbdpestBid);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(cbdrecogBidList.size() > 0) {
|
|
|
- mongoService.removeAllByBatch("cbdrecogBid", cbdrecogBidList, IotCbdrecog.class.getAnnotation(TableName.class).value());
|
|
|
- }
|
|
|
- if(cbdpestBidList.size() > 0) {
|
|
|
- mongoService.removeAllByBatch("cbdpestBid", cbdpestBidList, IotCbdpest.class.getAnnotation(TableName.class).value());
|
|
|
- }
|
|
|
- if(pestrecogBidList.size() > 0) {
|
|
|
- mongoService.removeAllByBatch("pestrecogBid", pestrecogBidList, IotPestrecog.class.getAnnotation(TableName.class).value());
|
|
|
- }
|
|
|
-
|
|
|
- log.info("【测报灯】 开始A模型识别图片:" + cbdimgAddr);
|
|
|
- saveRecogImgByA(iotDevice, iotCbdimg, recogeData, pestRecogResult);
|
|
|
- log.info("【测报灯】 结束A模型识别图片:" + cbdimgAddr);
|
|
|
- log.info("【测报灯】 是否识别B模型:" + cbdimgAddrB + (StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")));
|
|
|
- // 保存 测报灯B模型图片识别信息
|
|
|
- if(StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")){
|
|
|
- log.info("【测报灯】 开始B模型识别图片:" + cbdimgAddrB);
|
|
|
- saveRecogImgByB(iotDevice, iotCbdimg, recogeData, pestRecogResultB);
|
|
|
- log.info("【测报灯】 结束B模型识别图片:" + cbdimgAddrB);
|
|
|
- }
|
|
|
- }
|
|
|
+ public void iotmAgainRecog(String content) throws Exception {}
|
|
|
+
|
|
|
+// @Transactional(rollbackFor = Exception.class)
|
|
|
+// public void iotmAgainRecog(String content) throws Exception {
|
|
|
+// JSONObject contentObject = JSONObject.parseObject(content);
|
|
|
+// String devBid = contentObject.getString("devBid");
|
|
|
+// String cbdimgBid = contentObject.getString("cbdimgBid");
|
|
|
+// String cbdrecogType = contentObject.getString("cbdrecogType");
|
|
|
+//
|
|
|
+// JSONObject recogeData=null;
|
|
|
+// try{
|
|
|
+// recogeData = getRecogeResult(cbdimgBid, cbdrecogType);
|
|
|
+//
|
|
|
+// }catch (Exception e){
|
|
|
+// log.error("{}",e);
|
|
|
+//
|
|
|
+// }
|
|
|
+// if(recogeData==null){
|
|
|
+// recogeData=new JSONObject();
|
|
|
+// }
|
|
|
+// String cbdrecogResult = this.getJsonData("Result", recogeData);
|
|
|
+// String cbdrecogResultB = this.getJsonData("Result_b", recogeData);
|
|
|
+// String cbdimgAddrB = this.getJsonData("Result_image_b", recogeData);
|
|
|
+//
|
|
|
+// String devUpdateddate = DateUtils.dateTimeNow();
|
|
|
+//
|
|
|
+// IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
+//
|
|
|
+// IotPestRecogService.PestRecogResult pestRecogResult = iotPestRecogService.getIotPestrecogResult(
|
|
|
+// iotDevice, cbdrecogResult, devUpdateddate);
|
|
|
+//
|
|
|
+// IotPestRecogService.PestRecogResult pestRecogResultB = iotPestRecogService.getIotPestrecogResult(
|
|
|
+// iotDevice, cbdrecogResultB, devUpdateddate);
|
|
|
+//
|
|
|
+// Criteria criteria = Criteria.where("cbdimgBid").is(cbdimgBid);
|
|
|
+// Query query = new Query(criteria);
|
|
|
+//
|
|
|
+// Map<String, Object> updateField = new HashMap<>();
|
|
|
+// updateField.put("cbdimgRecognum", pestRecogResult.getCbdimgRecognumTotal());
|
|
|
+// updateField.put("cbdimgModifieddate", devUpdateddate);
|
|
|
+// mongoService.update(IotCbdimg.class, query, updateField);
|
|
|
+//
|
|
|
+// IotCbdimg iotCbdimg = (IotCbdimg) mongoService.findOne("cbdimgBid", cbdimgBid, IotCbdimg.class);
|
|
|
+// String cbdimgAddr = iotCbdimg.getCbdimgAddr();
|
|
|
+//
|
|
|
+// Map<String, String> recogeSelectMap = new HashMap<>();
|
|
|
+// recogeSelectMap.put("cbdimgBid", cbdimgBid);
|
|
|
+// recogeSelectMap.put("cbdrecogMarktype", "1");
|
|
|
+// recogeSelectMap.put("cbdrecogType", cbdrecogType);
|
|
|
+// List<IotCbdrecog> iotCbdrecogList = mongoService.findAll(IotCbdrecog.class, recogeSelectMap);
|
|
|
+// List<String> cbdrecogBidList = new ArrayList<>();
|
|
|
+// if(iotCbdrecogList != null && iotCbdrecogList.size() > 0){
|
|
|
+// for(IotCbdrecog iotCbdrecog : iotCbdrecogList){
|
|
|
+// String cbdrecogBid = iotCbdrecog.getCbdrecogBid();
|
|
|
+// cbdrecogBidList.add(cbdrecogBid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // newList_picBid
|
|
|
+// List<String> pestrecogBidList = new ArrayList<>();
|
|
|
+// List<String> cbdpestBidList = new ArrayList<>();
|
|
|
+// if(cbdrecogBidList.size() > 0){
|
|
|
+// Map<String, Object> pestSelectMap = new HashMap<>();
|
|
|
+// pestSelectMap.put("newList_cbdrecogBid", cbdrecogBidList);
|
|
|
+// List<IotCbdpest> IotCbdpestList = mongoService.findAll(IotCbdpest.class, pestSelectMap);
|
|
|
+// if(IotCbdpestList != null && IotCbdpestList.size() > 0){
|
|
|
+// for(IotCbdpest iotCbdpest : IotCbdpestList) {
|
|
|
+// String pestrecogBid = iotCbdpest.getPestrecogBid();
|
|
|
+// String cbdpestBid = iotCbdpest.getCbdpestBid();
|
|
|
+// pestrecogBidList.add(pestrecogBid);
|
|
|
+// cbdpestBidList.add(cbdpestBid);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(cbdrecogBidList.size() > 0) {
|
|
|
+// mongoService.removeAllByBatch("cbdrecogBid", cbdrecogBidList, IotCbdrecog.class.getAnnotation(TableName.class).value());
|
|
|
+// }
|
|
|
+// if(cbdpestBidList.size() > 0) {
|
|
|
+// mongoService.removeAllByBatch("cbdpestBid", cbdpestBidList, IotCbdpest.class.getAnnotation(TableName.class).value());
|
|
|
+// }
|
|
|
+// if(pestrecogBidList.size() > 0) {
|
|
|
+// mongoService.removeAllByBatch("pestrecogBid", pestrecogBidList, IotPestrecog.class.getAnnotation(TableName.class).value());
|
|
|
+// }
|
|
|
+//
|
|
|
+// log.info("【测报灯】 开始A模型识别图片:" + cbdimgAddr);
|
|
|
+// saveRecogImgByA(iotDevice, iotCbdimg, recogeData, pestRecogResult);
|
|
|
+// log.info("【测报灯】 结束A模型识别图片:" + cbdimgAddr);
|
|
|
+// log.info("【测报灯】 是否识别B模型:" + cbdimgAddrB + (StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")));
|
|
|
+// // 保存 测报灯B模型图片识别信息
|
|
|
+// if(StringUtils.isNotEmpty(cbdimgAddrB) && cbdimgAddrB.startsWith("http")){
|
|
|
+// log.info("【测报灯】 开始B模型识别图片:" + cbdimgAddrB);
|
|
|
+// saveRecogImgByB(iotDevice, iotCbdimg, recogeData, pestRecogResultB);
|
|
|
+// log.info("【测报灯】 结束B模型识别图片:" + cbdimgAddrB);
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|