|
|
@@ -1,7 +1,6 @@
|
|
|
package com.yunfeiyun.agmp.iots.device.serviceImp;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
-import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.yunfeiyun.agmp.common.service.LocationService;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
@@ -17,6 +16,7 @@ import com.yunfeiyun.agmp.iot.common.domain.IotXctdata;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.IotDeviceStatusTypeEnum;
|
|
|
import com.yunfeiyun.agmp.iot.common.model.cmd.CmdModel;
|
|
|
import com.yunfeiyun.agmp.iot.common.service.MongoService;
|
|
|
+import com.yunfeiyun.agmp.iot.common.util.dev.XctToCbdUtil;
|
|
|
import com.yunfeiyun.agmp.iots.core.manager.MqttManager;
|
|
|
import com.yunfeiyun.agmp.iots.device.common.DeviceAbstractImpl;
|
|
|
import com.yunfeiyun.agmp.iots.device.domain.cbd.YfCbdConfigMsg;
|
|
|
@@ -304,10 +304,9 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
if (StringUtils.isEmpty(cbdimgAddr)) {
|
|
|
return "图片地址不存在,则不处理";
|
|
|
}
|
|
|
- // 由于吸虫塔和测报灯的害虫编号重复将吸虫塔中的虫子编号进行转化
|
|
|
- transXctPestPoint(jsonObject);
|
|
|
+
|
|
|
// 将吸虫塔的数据格式转化成测报灯的数据格式
|
|
|
- jsonObject = transXctDataToCbdData(jsonObject);
|
|
|
+ jsonObject = XctToCbdUtil.xctToCbdData(jsonObject);
|
|
|
|
|
|
// 保存测报灯图片数据到mongodb
|
|
|
iotCbdImgService.insertIotCbdimg(oldIotDevice, jsonObject, devUpdateddate);
|
|
|
@@ -315,81 +314,6 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
return "测报灯指令上报的图片结果";
|
|
|
}
|
|
|
|
|
|
- private JSONObject transXctDataToCbdData(JSONObject jsonObject) {
|
|
|
- String return_string = jsonObject.getString("return_string");
|
|
|
- if(StringUtils.isEmpty(return_string)){
|
|
|
- return_string = "0";
|
|
|
- }
|
|
|
-
|
|
|
- String label = jsonObject.getString("label");
|
|
|
- if(StringUtils.isEmpty(label)){
|
|
|
- label = "0";
|
|
|
- }
|
|
|
-
|
|
|
- String Result_c = "0," + jsonObject.getString("Result_c");
|
|
|
-
|
|
|
- JSONObject result = new JSONObject();
|
|
|
- result.put("imei",jsonObject.get("device_id"));
|
|
|
- result.put("Image",jsonObject.get("img"));
|
|
|
- result.put("Result", return_string);
|
|
|
- result.put("Result_image",jsonObject.get("img"));
|
|
|
- result.put("Result_code", label);
|
|
|
- result.put("Image_b","0");
|
|
|
- result.put("Result_b","0");
|
|
|
- result.put("Result_image_b","0");
|
|
|
- result.put("Result_code_b","0");
|
|
|
- result.put("Result_c", Result_c);
|
|
|
- result.put("disable","0");
|
|
|
- return result;
|
|
|
- }
|
|
|
- private void transXctPestPoint(JSONObject dataJson){
|
|
|
- String cbdrecogMachinemark = dataJson.getString("label");
|
|
|
- String cbdrecogResult = dataJson.getString("return_string");
|
|
|
-
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- try{
|
|
|
- if(StringUtils.isNotEmpty(cbdrecogMachinemark)){
|
|
|
- jsonArray = JSONArray.parseArray(cbdrecogMachinemark);
|
|
|
- }
|
|
|
- }catch (Exception e){}
|
|
|
-
|
|
|
- JSONArray transAfterData = new JSONArray();
|
|
|
-
|
|
|
- int totalPestNum = 0;
|
|
|
- for(int i = jsonArray.size()-1;i>=0;i--){
|
|
|
- JSONObject returnStrItem = jsonArray.getJSONObject(i);
|
|
|
- for(Map.Entry<String,Object> entry : returnStrItem.entrySet()){
|
|
|
- String key = entry.getKey();
|
|
|
- Object value = entry.getValue();
|
|
|
- totalPestNum++;
|
|
|
- if(!"4".equals(key)) {
|
|
|
- returnStrItem.remove(key);
|
|
|
- returnStrItem.put("xct"+key,value);
|
|
|
- transAfterData.add(returnStrItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- String label = "";
|
|
|
- if(!transAfterData.isEmpty()){
|
|
|
- label = transAfterData.toJSONString();
|
|
|
- }
|
|
|
-
|
|
|
- for(int i = 1;i<=3;i++){
|
|
|
- cbdrecogResult = cbdrecogResult.replaceFirst(i+",","xct"+i+",");
|
|
|
- }
|
|
|
- cbdrecogResult = cbdrecogResult.replaceAll("4,\\d+#|#4,\\d+","");
|
|
|
-
|
|
|
- if(StringUtils.isEmpty(label) || StringUtils.isEmpty(cbdrecogResult)){
|
|
|
- label = "";
|
|
|
- cbdrecogResult = "";
|
|
|
- totalPestNum = 0;
|
|
|
- }
|
|
|
-
|
|
|
- dataJson.put("label", label);
|
|
|
- dataJson.put("return_string",cbdrecogResult);
|
|
|
- dataJson.put("Result_c", totalPestNum);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param jobjMsg
|
|
|
* @return
|