|
|
@@ -2,6 +2,7 @@ package com.yunfeiyun.agmp.iots.device.serviceImp;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
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.constant.devicetype.ServiceNameConst;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotDevice;
|
|
|
@@ -138,59 +139,56 @@ public class RunHaoSfDeviceImpl extends DeviceAbstractImpl implements IRunHaoSfD
|
|
|
public Object cmdData(JSONObject dataJson, String topic, String connectionId, String devUpdateddate) throws Exception {
|
|
|
log.info("杀虫灯数据解析 {},topic:{}", dataJson.toString(),topic);
|
|
|
|
|
|
-// IotDevice oldIotDevice = findIotDevice(topic, dataJson, connectionId);
|
|
|
-// if (oldIotDevice == null) {
|
|
|
-// log.error("未取到 iotDevice");
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-//
|
|
|
-// IotDevice iotDevice = new IotDevice();
|
|
|
-// iotDevice.setTid(oldIotDevice.getTid());
|
|
|
-// iotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
|
|
|
-// iotDevice.setDevBid(oldIotDevice.getDevBid());
|
|
|
-// iotDevice.setDevUpdateddate(devUpdateddate);
|
|
|
-// iotDevice.setDevStatus("1");//设备上线
|
|
|
-// iotDevice.setDevOriginalStatus(oldIotDevice.getDevOriginalStatus());
|
|
|
-// HashMap<String, String> keyMaps = new HashMap<>();
|
|
|
-// keyMaps.put("dver", "devVersion");
|
|
|
-// keyMaps.put("imei", "devCode");
|
|
|
-// keyMaps.put("gps", "devPositiontype");
|
|
|
-//
|
|
|
-// for (Map.Entry<String, String> entry : keyMaps.entrySet()) {
|
|
|
-// String k = entry.getValue();
|
|
|
-// String v = dataJson.getString(entry.getKey());
|
|
|
-// if (StringUtils.isNotEmpty(v)) {
|
|
|
-// ReflectUtils.invokeSetter(iotDevice, k, v);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// String lng = dataJson.getString("lng");
|
|
|
-// String lat = dataJson.getString("lat");
|
|
|
-// if (!Objects.equals(oldIotDevice.getDevPositionstatus(), "0") && StringUtils.isNotEmpty(lng) && StringUtils.isNotEmpty(lat)) {
|
|
|
-// iotDeviceAddressService.setDeviceAddress(iotDevice, lng, lat);
|
|
|
-// }
|
|
|
-//
|
|
|
-// String[] keyArrays = {
|
|
|
-// "ds",
|
|
|
-// "tt",
|
|
|
-// "dat_f",
|
|
|
-// "clt_t",
|
|
|
-// "ts",
|
|
|
-// "st",
|
|
|
-// "et",
|
|
|
-// "stm8vs"
|
|
|
-// };
|
|
|
-//
|
|
|
-// JSONObject extConf = new JSONObject();
|
|
|
-// for (String k : keyArrays) {
|
|
|
-// String v = "0";
|
|
|
-// if (dataJson.containsKey(k)) {
|
|
|
-// v = dataJson.getString(k);
|
|
|
-// }
|
|
|
-// extConf.put(k, v);
|
|
|
-// }
|
|
|
-// extConf.put("dver", iotDevice.getDevVersion());
|
|
|
-// String devConfig = JSONUtils.toJSONString(extConf);
|
|
|
+ IotDevice oldIotDevice = findIotDevice(topic, dataJson, connectionId);
|
|
|
+ if (oldIotDevice == null) {
|
|
|
+ log.error("未取到 iotDevice");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ IotDevice iotDevice = new IotDevice();
|
|
|
+ iotDevice.setTid(oldIotDevice.getTid());
|
|
|
+ iotDevice.setDevtypeBid(oldIotDevice.getDevtypeBid());
|
|
|
+ iotDevice.setDevBid(oldIotDevice.getDevBid());
|
|
|
+ iotDevice.setDevUpdateddate(devUpdateddate);
|
|
|
+ iotDevice.setDevStatus("1");//设备上线
|
|
|
+
|
|
|
+ String[] keyArrays = {
|
|
|
+ "Btn-dsdl", // 施肥模式 1 定时模式 0 定量模式
|
|
|
+ "Btn-zfxz", // 注肥开关 1 开 0 关
|
|
|
+ "Btn-jbms", // 搅拌模式 1 联动模式 0 搅拌模式
|
|
|
+ "Num-jbsjA", // 搅拌时间 A搅拌机 单位 分钟
|
|
|
+ "Num-jbsjB",
|
|
|
+ "Num-jbsjC",
|
|
|
+ "Num-jbsjD",
|
|
|
+ "Btn-jbA", // 搅拌开关 A搅拌机 1 开 0 关
|
|
|
+ "Btn-jbB",
|
|
|
+ "Btn-jbC",
|
|
|
+ "Btn-jbD",
|
|
|
+ "Num-jbsyA", // 剩余搅拌时间 A搅拌机 单位 分钟
|
|
|
+ "Num-jbsyB",
|
|
|
+ "Num-jbsyC",
|
|
|
+ "Num-jbsyD",
|
|
|
+ "Num-lgcs", // 轮灌次数 单位 次 0 - 10
|
|
|
+ "Num-lgjg", // 轮灌间隔 单位 分钟 0 - 1000
|
|
|
+ "Btn-zdsd" // 运行模式 1 自动 0 手动
|
|
|
+ };
|
|
|
//
|
|
|
+ JSONObject extConf = new JSONObject();
|
|
|
+ for (String k : keyArrays) {
|
|
|
+ String v = "0";
|
|
|
+ if (dataJson.containsKey(k)) {
|
|
|
+ v = dataJson.getString(k);
|
|
|
+ if("true".equals(v)){
|
|
|
+ v = "1";
|
|
|
+ }else if("false".equals(v)){
|
|
|
+ v = "0";
|
|
|
+ }
|
|
|
+ v = String.valueOf((int) Math.floor(Double.parseDouble(v)));
|
|
|
+ }
|
|
|
+ extConf.put(k, v);
|
|
|
+ }
|
|
|
+ String devConfig = JSONUtils.toJSONString(extConf);
|
|
|
+
|
|
|
// // 更新设备基础信息数据库 mysql
|
|
|
// iIotDeviceService.updateIotDevice(iotDevice);
|
|
|
// // 创建或更新设备配置信息
|