|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
import com.yunfeiyun.agmp.common.constant.ResConstants;
|
|
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.JSONUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotCbdPestrecog;
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotCbdPestrecog;
|
|
@@ -112,72 +113,6 @@ public class IotCbdImgService {
|
|
|
iotPestRecogService.savePestRecog(pestRecogResult);
|
|
iotPestRecogService.savePestRecog(pestRecogResult);
|
|
|
return iotCbdrecog;
|
|
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
|
|
* 保存测报灯图片基础数据到mongodb
|
|
@@ -289,100 +224,89 @@ public class IotCbdImgService {
|
|
|
return recogeData;
|
|
return recogeData;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public IotCbdrecog updateCbdrecog(IotCbdrecog newIotCbdrecog, IotCbdrecog oldIotCbdrecog) {
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogManualaddr(oldIotCbdrecog.getCbdrecogManualaddr());
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogResultManual(oldIotCbdrecog.getCbdrecogResultManual());
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogManualmark(oldIotCbdrecog.getCbdrecogManualmark());
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogTotalnumManual(oldIotCbdrecog.getCbdrecogTotalnumManual());
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogPestnumManual(oldIotCbdrecog.getCbdrecogPestnumManual());
|
|
|
|
|
+ newIotCbdrecog.setCbdrecogTypenumManual(oldIotCbdrecog.getCbdrecogTypenumManual());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, List<IotCbdPestrecog>> oldPestrecog = oldIotCbdrecog.getPestrecog();
|
|
|
|
|
+ try{
|
|
|
|
|
+ List<IotCbdPestrecog> oldIotCbdPestrecogList = oldPestrecog.get(EnumCbdMarkType.HAND.getCode());
|
|
|
|
|
+ List<IotCbdPestrecog> newIotCbdPestrecogList = new ArrayList<>();
|
|
|
|
|
+ if(oldIotCbdPestrecogList != null && !oldIotCbdPestrecogList.isEmpty()){
|
|
|
|
|
+ for(IotCbdPestrecog iotCbdPestrecog : oldIotCbdPestrecogList) {
|
|
|
|
|
+ iotCbdPestrecog.setRecogBid(newIotCbdrecog.getCbdrecogBid());
|
|
|
|
|
+ newIotCbdPestrecogList.add(iotCbdPestrecog);
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, List<IotCbdPestrecog>> newPestrecog = newIotCbdrecog.getPestrecog();
|
|
|
|
|
+ if(newPestrecog == null){
|
|
|
|
|
+ newPestrecog = new HashMap<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ newPestrecog.put(EnumCbdMarkType.HAND.getCode(), newIotCbdPestrecogList);
|
|
|
|
|
+ newIotCbdrecog.setPestrecog(newPestrecog);
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){}
|
|
|
|
|
+
|
|
|
|
|
+ return newIotCbdrecog;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- 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);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ 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("[云飞测报灯手动识别服务] 识别异常: {}", content, e);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String cbdrecogResult = this.getJsonData("Result", recogeData);
|
|
|
|
|
+ String cbdrecogResultB = this.getJsonData("Result_b", recogeData);
|
|
|
|
|
+
|
|
|
|
|
+ IotCbdimg iotCbdimg = (IotCbdimg) mongoService.findOne("cbdimgBid", cbdimgBid, IotCbdimg.class);
|
|
|
|
|
+ iotCbdimg.setCbdimgModifieddate(DateUtils.dateTimeNow());
|
|
|
|
|
+
|
|
|
|
|
+ long cbdrecogTotalnum = iotCbdimg.getCbdimgTotalnum();
|
|
|
|
|
+ Map<String, IotCbdrecog> cbdrecog = iotCbdimg.getCbdrecog();
|
|
|
|
|
+
|
|
|
|
|
+ IotCbdrecog iotCbdrecogA = null;
|
|
|
|
|
+ IotCbdrecog iotCbdrecogB = null;
|
|
|
|
|
+ IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devBid);
|
|
|
|
|
+ log.info("【测报灯】 是否识别A模型:" + StringUtils.isNotEmpty(cbdrecogResult) + " " + iotDevice);
|
|
|
|
|
+ if(StringUtils.isNotEmpty(cbdrecogResult)){
|
|
|
|
|
+ log.info("【测报灯】 开始A模型识别图片:" + cbdimgBid);
|
|
|
|
|
+ iotCbdrecogA = makeRecogImg(EnumCbdRecogType.A, EnumCbdMarkType.AUTO, iotDevice, iotCbdimg, recogeData, cbdrecogTotalnum);
|
|
|
|
|
+ log.info("【测报灯】 结束A模型识别图片:" + cbdimgBid);
|
|
|
|
|
+ IotCbdrecog oldIotCbdrecogA = cbdrecog.get(EnumCbdRecogType.A.getCode());
|
|
|
|
|
+ if(oldIotCbdrecogA != null){
|
|
|
|
|
+ iotCbdrecogA = updateCbdrecog(iotCbdrecogA, oldIotCbdrecogA);
|
|
|
|
|
+ }
|
|
|
|
|
+ cbdrecog.put(EnumCbdRecogType.A.getCode(), iotCbdrecogA);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("【测报灯】 是否识别B模型:" + StringUtils.isNotEmpty(cbdrecogResultB) + " " + iotDevice);
|
|
|
|
|
+ // 保存 测报灯B模型图片识别信息
|
|
|
|
|
+ if(StringUtils.isNotEmpty(cbdrecogResultB)){
|
|
|
|
|
+ log.info("【测报灯】 开始B模型识别图片:" + cbdimgBid);
|
|
|
|
|
+ iotCbdrecogB = makeRecogImg(EnumCbdRecogType.B, EnumCbdMarkType.AUTO, iotDevice, iotCbdimg, recogeData, cbdrecogTotalnum);
|
|
|
|
|
+ log.info("【测报灯】 结束B模型识别图片:" + cbdimgBid);
|
|
|
|
|
+ IotCbdrecog oldIotCbdrecogB = cbdrecog.get(EnumCbdRecogType.B.getCode());
|
|
|
|
|
+ if(oldIotCbdrecogB != null){
|
|
|
|
|
+ iotCbdrecogB = updateCbdrecog(iotCbdrecogB, oldIotCbdrecogB);
|
|
|
|
|
+ }
|
|
|
|
|
+ cbdrecog.put(EnumCbdRecogType.B.getCode(), iotCbdrecogB);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ iotCbdimg.setCbdrecog(cbdrecog);
|
|
|
|
|
+ mongoService.saveOne(iotCbdimg);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|