提交 ee53c280 authored 作者: 林业通's avatar 林业通

保存记录

上级 5a0f3684
...@@ -50,9 +50,6 @@ public class OutletParse implements IParse { ...@@ -50,9 +50,6 @@ public class OutletParse implements IParse {
@Autowired @Autowired
private TimeParseUtils timeParseUtils; private TimeParseUtils timeParseUtils;
@Autowired
private SpeakerService speakerService;
@Autowired @Autowired
private MqProducer mqProducer; private MqProducer mqProducer;
...@@ -126,7 +123,7 @@ public class OutletParse implements IParse { ...@@ -126,7 +123,7 @@ public class OutletParse implements IParse {
logger.info("已删除重复 : {}", redisUtils.hasKey(device.getNumbering() + "cf")); logger.info("已删除重复 : {}", redisUtils.hasKey(device.getNumbering() + "cf"));
String content = datas.get("content"); String content = datas.get("content");
//开关状态 //开关状态
if (content.equals("00")) { /* if (content.equals("00")) {
//保存开关记录 //保存开关记录
String action = redisUtils.get(datas.get("receiveId") + "action"); String action = redisUtils.get(datas.get("receiveId") + "action");
if (action != null) { if (action != null) {
...@@ -136,7 +133,7 @@ public class OutletParse implements IParse { ...@@ -136,7 +133,7 @@ public class OutletParse implements IParse {
shDeviceRecordService.save(recordEntity); shDeviceRecordService.save(recordEntity);
redisUtils.delete(datas.get("receiveId") + "action"); redisUtils.delete(datas.get("receiveId") + "action");
} }
} }*/
ws.put("action", content); ws.put("action", content);
}else if("1A".equals(datas.get("cmd"))) {//温控响应 }else if("1A".equals(datas.get("cmd"))) {//温控响应
...@@ -160,6 +157,15 @@ public class OutletParse implements IParse { ...@@ -160,6 +157,15 @@ public class OutletParse implements IParse {
} }
redisUtils.delete(device.getNumbering() + "temp"); redisUtils.delete(device.getNumbering() + "temp");
}else if("20".equals(datas.get("cmd"))) {//事件上报
//保存开关记录
String content = datas.get("content");
String action = content.substring(6, 8);
ShDeviceRecordEntity recordEntity = new ShDeviceRecordEntity();
recordEntity.setDeviceId(device.getId());
recordEntity.setAction(action.equals("01") ? 1 : 2);
shDeviceRecordService.save(recordEntity);
} }
new Thread(() -> { new Thread(() -> {
//检测有没待下发指令 //检测有没待下发指令
......
...@@ -119,7 +119,7 @@ public class SwitchParse implements IParse { ...@@ -119,7 +119,7 @@ public class SwitchParse implements IParse {
String content = datas.get("content"); String content = datas.get("content");
logger.info("开关响应 : {}", content); logger.info("开关响应 : {}", content);
//开关状态 //开关状态
if (content.equals("00")) { /*if (content.equals("00")) {
//保存开关记录 //保存开关记录
logger.info("receiveId : {}", datas.get("receiveId")); logger.info("receiveId : {}", datas.get("receiveId"));
String action = redisUtils.get(datas.get("receiveId") + "action1"); String action = redisUtils.get(datas.get("receiveId") + "action1");
...@@ -140,7 +140,7 @@ public class SwitchParse implements IParse { ...@@ -140,7 +140,7 @@ public class SwitchParse implements IParse {
redisUtils.delete(datas.get("receiveId") + "action2"); redisUtils.delete(datas.get("receiveId") + "action2");
} }
} }*/
ws.put("action", content); ws.put("action", content);
}else if("1A".equals(datas.get("cmd"))) {//温控响应 }else if("1A".equals(datas.get("cmd"))) {//温控响应
...@@ -168,6 +168,23 @@ public class SwitchParse implements IParse { ...@@ -168,6 +168,23 @@ public class SwitchParse implements IParse {
} }
redisUtils.delete(device.getNumbering() + "temp"); redisUtils.delete(device.getNumbering() + "temp");
}else if("20".equals(datas.get("cmd"))) {//事件上报
//保存开关记录
String content = datas.get("content");
String type = content.substring(2, 4);
String action = content.substring(6, 8);
ShDeviceRecordEntity recordEntity = new ShDeviceRecordEntity();
recordEntity.setDeviceId(device.getId());
if (type.equals("01")) {
//开关1 1:开 2:关
recordEntity.setAction(action.equals("01") ? 1 : 2);
}else {
//开关2 3:开 4:关
recordEntity.setAction(action.equals("01") ? 3 : 4);
}
shDeviceRecordService.save(recordEntity);
} }
return ws; return ws;
} }
......
...@@ -349,15 +349,15 @@ public class ShDeviceController { ...@@ -349,15 +349,15 @@ public class ShDeviceController {
protocol.setDeviceType(type); protocol.setDeviceType(type);
protocol.setCmd("18"); protocol.setCmd("18");
if (flag == null) { if (flag == null) {
redisUtils.set(mac + "action", action.substring(0, 2), 50); // redisUtils.set(mac + "action", action.substring(0, 2), 50);
protocol.setContent(action + "000000000001"); protocol.setContent(action + "000000000001");
}else { }else {
if (flag == 1) { if (flag == 1) {
protocol.setContent(action + "000000000001"); protocol.setContent(action + "000000000001");
redisUtils.set(mac + "action1", action.substring(0, 2).equals("01") ? 1 : 2, 50); // redisUtils.set(mac + "action1", action.substring(0, 2).equals("01") ? 1 : 2, 50);
}else { }else {
protocol.setContent(action + "000000000002"); protocol.setContent(action + "000000000002");
redisUtils.set(mac + "action2", action.substring(2, 4).equals("01") ? 3 : 4, 50); // redisUtils.set(mac + "action2", action.substring(2, 4).equals("01") ? 3 : 4, 50);
} }
} }
mqProducer.sendT(JSON.toJSONString(protocol)); mqProducer.sendT(JSON.toJSONString(protocol));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论