|
|
@@ -73,11 +73,13 @@ public class RunHaoSfDeviceImpl extends DeviceAbstractImpl implements IRunHaoSfD
|
|
|
}
|
|
|
String topic = IotMqttConstant.RunHaoSfTopic.TOPIC_RUNHAO_SF_REPORT_PREFIX + devCode;
|
|
|
try{
|
|
|
+ // 延迟1秒 模拟设备上报延迟
|
|
|
+ Thread.sleep(1000);
|
|
|
String sendMsg = jsonObject.toString();
|
|
|
mqttManager.publishMsg(iotDevice.getDevconnBid(), topic, sendMsg);
|
|
|
- log.info("【YFSCD】发送指令完毕!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
+ log.info("【润浩水肥机】发送指令完毕!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
}catch (Exception e){
|
|
|
- log.error("【YFSCD】发送指令失败!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
+ log.error("【润浩水肥机】发送指令失败!connectionId:{},topic :{} mqttMsgContent: {}",iotDevice.getDevconnBid(),topic, mqttMsgContent);
|
|
|
}
|
|
|
}
|
|
|
//设备暂未对接mqtt,先注释掉
|
|
|
@@ -117,9 +119,11 @@ public class RunHaoSfDeviceImpl extends DeviceAbstractImpl implements IRunHaoSfD
|
|
|
|
|
|
String mqttMsgContent = "";
|
|
|
String clogSendresult = "发送指令成功";
|
|
|
+ JSONObject jobjParam = null;
|
|
|
+
|
|
|
switch (methodName) {
|
|
|
case CmdDef.RunHaoSfCmdDef.CMD_GROUP_CONFIG:
|
|
|
- JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
+ jobjParam = cmdDistribution.getJsons();
|
|
|
String groupCode = jobjParam.getString("sfCode");
|
|
|
int groupIndex = Integer.parseInt(groupCode.replace("Btn-qx", ""));
|
|
|
String groupIndexStr = String.valueOf(groupIndex);
|
|
|
@@ -133,39 +137,16 @@ public class RunHaoSfDeviceImpl extends DeviceAbstractImpl implements IRunHaoSfD
|
|
|
payloadMap.put(key, groupIndexStr);
|
|
|
}
|
|
|
|
|
|
- mqttMsgContent = payloadMap.toString();
|
|
|
+ mqttMsgContent = JSONUtils.toJSONString(payloadMap);
|
|
|
log.info("【润浩水肥机】发送指令【" + CmdDef.RunHaoSfCmdDef.CMD_GROUP_CONFIG + "】 mqttMsgContent={}", mqttMsgContent);
|
|
|
break;
|
|
|
|
|
|
-// case CmdDef.YfScdCmdDef.CMD_CONFIG: {
|
|
|
-// JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
-// Map<String, String> keyMap = new HashMap<>();
|
|
|
-// keyMap.put("ds", "ds");
|
|
|
-// keyMap.put("tt", "tt");
|
|
|
-// keyMap.put("dat_f", "dattim");
|
|
|
-// keyMap.put("ts", "ts");
|
|
|
-// keyMap.put("st", "st");
|
|
|
-// keyMap.put("et", "et");
|
|
|
-//
|
|
|
-// JSONObject configObj = new JSONObject();
|
|
|
-// for (Map.Entry<String, String> entry : keyMap.entrySet()) {
|
|
|
-// String key = entry.getKey();
|
|
|
-// String keyName = entry.getValue();
|
|
|
-//
|
|
|
-// if (jobjParam.containsKey(key)) {
|
|
|
-// Object value = jobjParam.get(key);
|
|
|
-// if (value != null) {
|
|
|
-// configObj.put(keyName, value);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// JSONObject devConfig = new JSONObject();
|
|
|
-// devConfig.put("cmd", "paramconf");
|
|
|
-// devConfig.put("ext", configObj);
|
|
|
-// mqttMsgContent = devConfig.toString();
|
|
|
-// log.info("【杀虫灯】发送指令【config】 mqttMsgContent={}", mqttMsgContent);
|
|
|
-// break;
|
|
|
-// }
|
|
|
+ case CmdDef.RunHaoSfCmdDef.CMD_CONFIG:
|
|
|
+ jobjParam = cmdDistribution.getJsons();
|
|
|
+ mqttMsgContent = JSONUtils.toJSONString(jobjParam);
|
|
|
+ log.info("【润浩水肥机】发送指令【config】 mqttMsgContent={}", mqttMsgContent);
|
|
|
+ break;
|
|
|
+
|
|
|
// case CmdDef.YfScdCmdDef.CMD_REFRESH:{
|
|
|
// JSONObject jobjParam = cmdDistribution.getJsons();
|
|
|
// mqttMsgContent = JSONUtils.toJSONString(jobjParam);
|
|
|
@@ -253,6 +234,9 @@ public class RunHaoSfDeviceImpl extends DeviceAbstractImpl implements IRunHaoSfD
|
|
|
if(key.startsWith("Btn-fx")){
|
|
|
try{
|
|
|
int groupIndex = (int)Math.floor(Double.parseDouble(jsonObject.getString(key)));
|
|
|
+ if(groupIndex == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String groupCode = String.format("Btn-qx%02d", groupIndex);
|
|
|
int valveIndex = Integer.parseInt(key.replace("Btn-fx", ""));
|
|
|
String valveCode = String.format("Btn-fa%d", valveIndex);
|