|
|
@@ -128,29 +128,6 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
|
|
|
}
|
|
|
|
|
|
- public String xctData(JSONObject ext, String cId, IotDevice iotDevice) {
|
|
|
-
|
|
|
- String[] keyArrays = {
|
|
|
- "dat_f",
|
|
|
- "shake_sec",
|
|
|
- "shake",
|
|
|
- "ds",
|
|
|
- "dver",
|
|
|
- "st",
|
|
|
- "et"
|
|
|
- };
|
|
|
-
|
|
|
- JSONObject extConf = new JSONObject();
|
|
|
- for (String k : keyArrays) {
|
|
|
- String v = "0";
|
|
|
- if (ext.containsKey(k)) {
|
|
|
- v = ext.getString(k);
|
|
|
- }
|
|
|
- extConf.put(k, v);
|
|
|
- }
|
|
|
- return JSONUtils.toJSONString(extConf);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param ext
|
|
|
* @param devUpdateddate
|
|
|
@@ -312,15 +289,15 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
*/
|
|
|
|
|
|
public Object receivePicData(JSONObject jsonObject, String devUpdateddate, String topic, String connectionId) {
|
|
|
- String devId = mqttManager.getDevIdByTopic(connectionId, topic);
|
|
|
- IotDevice iotDevice = iIotDeviceService.selectIotDeviceByDevBid(devId);
|
|
|
- if (iotDevice == null) {
|
|
|
- return "设备不存在 就不在处理";
|
|
|
+ IotDevice oldIotDevice = findIotDevice(topic, jsonObject, connectionId);
|
|
|
+ if (oldIotDevice == null) {
|
|
|
+ log.info("【吸虫塔】未取到设备:" + topic);
|
|
|
+ return null;
|
|
|
}
|
|
|
- String devtypeBid = iotDevice.getDevtypeBid();
|
|
|
- String deviceTypeId = iotDevice.getDevtypeBid();
|
|
|
- String devCode = jsonObject.getString("device_id");
|
|
|
- log.info("【解析测报灯图片数据】:devtypeBid:{},deviceTypeId,{},devCode:{}", devtypeBid, deviceTypeId, devCode);
|
|
|
+ String devtypeBid = oldIotDevice.getDevtypeBid();
|
|
|
+ String deviceTypeId = oldIotDevice.getDevtypeBid();
|
|
|
+ String devCode = oldIotDevice.getDevCode();
|
|
|
+ log.info("【解析吸虫塔图片数据】:devtypeBid:{},deviceTypeId,{},devCode:{}", devtypeBid, deviceTypeId, devCode);
|
|
|
String cbdimgAddr = jsonObject.getString("img");
|
|
|
if (StringUtils.isEmpty(cbdimgAddr)) {
|
|
|
return "图片地址不存在,则不处理";
|
|
|
@@ -331,31 +308,49 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
jsonObject = transXctDataToCbdData(jsonObject);
|
|
|
|
|
|
// 保存测报灯图片数据到mongodb
|
|
|
- iotCbdImgService.insertIotCbdimg(iotDevice, jsonObject, devUpdateddate);
|
|
|
+ iotCbdImgService.insertIotCbdimg(oldIotDevice, jsonObject, devUpdateddate);
|
|
|
|
|
|
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",jsonObject.get("label"));
|
|
|
+ result.put("Result", return_string);
|
|
|
result.put("Result_image",jsonObject.get("img"));
|
|
|
- result.put("Result_code",jsonObject.get("return_string"));
|
|
|
+ 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",jsonObject.get("Result_c"));
|
|
|
+ result.put("Result_c", Result_c);
|
|
|
result.put("disable","0");
|
|
|
return result;
|
|
|
}
|
|
|
private void transXctPestPoint(JSONObject dataJson){
|
|
|
- String cbdrecogMachinemark = dataJson.getString("return_string");
|
|
|
- String cbdrecogResult = dataJson.getString("label");
|
|
|
+ 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 jsonArray = JSONArray.parseArray(cbdrecogMachinemark);
|
|
|
JSONArray transAfterData = new JSONArray();
|
|
|
|
|
|
int totalPestNum = 0;
|
|
|
@@ -372,14 +367,17 @@ public class IYfXctDeviceImpl extends DeviceAbstractImpl implements IYfXctDevic
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- dataJson.put("return_string",transAfterData.toJSONString());
|
|
|
+ String label = "";
|
|
|
+ if(!transAfterData.isEmpty()){
|
|
|
+ label = transAfterData.toJSONString();
|
|
|
+ }
|
|
|
+ dataJson.put("label", label);
|
|
|
for(int i = 1;i<=3;i++){
|
|
|
cbdrecogResult = cbdrecogResult.replaceFirst(i+",","xct"+i+",");
|
|
|
}
|
|
|
cbdrecogResult = cbdrecogResult.replaceAll("4,\\d+#|#4,\\d+","");
|
|
|
- dataJson.put("label",cbdrecogResult);
|
|
|
- dataJson.put("Result_c",totalPestNum);
|
|
|
+ dataJson.put("return_string",cbdrecogResult);
|
|
|
+ dataJson.put("Result_c", totalPestNum);
|
|
|
}
|
|
|
|
|
|
/**
|