设备数据更新队列
This commit is contained in:
parent
c5dbae94d8
commit
a5909f4294
|
|
@ -136,7 +136,17 @@ public class SomeServer {
|
|||
try {
|
||||
Integer Onoff = receive.getOnoff() & 0xff;
|
||||
if(Onoff==1 || Onoff==0){
|
||||
deviceService.updateWarnOnoff(strDest,Onoff.toString());
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("onOff",Onoff);
|
||||
data.put("macAddress",strDest);
|
||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
||||
eventEntity.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
||||
eventEntity.setEventProcess("updateWarnOnoff");
|
||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDevice",data);
|
||||
eventEntity.setEventBody(eventBody);
|
||||
//温度开关更新
|
||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity));
|
||||
// deviceService.updateWarnOnoff(strDest,Onoff.toString());
|
||||
}
|
||||
else{
|
||||
log.error("error Onoff:{},macAddress:{}",Onoff,strDest);
|
||||
|
|
@ -199,9 +209,22 @@ public class SomeServer {
|
|||
factoryCode = factoryCode.equals("01")?"0a":factoryCode;
|
||||
String typeCode = ByteUtil.toHex(receive.getHardware_type());
|
||||
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("macAddress",stcMac);
|
||||
data.put("deviceIp",ipStr.toString());
|
||||
data.put("factoryCode",factoryCode);
|
||||
data.put("hardwareType",typeCode);
|
||||
data.put("softwareVersion",version);
|
||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
||||
eventEntity.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
||||
eventEntity.setEventProcess("deviceLoginSaveOrUpdate");
|
||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDevice",data);
|
||||
eventEntity.setEventBody(eventBody);
|
||||
//温度开关更新
|
||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity));
|
||||
|
||||
//更新设备信息
|
||||
deviceService.update(receive);
|
||||
// deviceService.update(receive);
|
||||
// if(device==null){
|
||||
// String HexDump = ByteUtil.toHex(receive.getType())+ByteUtil.toHex(receive.getCheck_code())+ByteUtil.bytesToHexString(receive.getSrc())+ByteUtil.bytesToHexString(destBytes)+ByteUtil.toHex(receive.getRemote_len())+ByteUtil.toHex(receive.getVendor())+ByteUtil.toHex(receive.getHardware_type())+ByteUtil.toHex(receive.getVersion())+ByteUtil.bytesToHexString(receive.getLogin_ip())+ByteUtil.bytesToHexString(receive.getCrc16_code());
|
||||
// log.error("HexDump:{}",HexDump);
|
||||
|
|
@ -209,10 +232,21 @@ public class SomeServer {
|
|||
// }
|
||||
// else{
|
||||
//记录登录时间
|
||||
LoginRecord loginRecord = new LoginRecord();
|
||||
loginRecord.setMacAddress(strSrc);
|
||||
loginRecord.setLoginTime(new Date());
|
||||
deviceService.save(loginRecord);
|
||||
JSONObject data1 = new JSONObject();
|
||||
data1.put("macAddress",stcMac);
|
||||
QueueEventEntity eventEntity1 = new QueueEventEntity();
|
||||
eventEntity1.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
||||
eventEntity1.setEventProcess("deviceLoginLogSave");
|
||||
QueueEventBody eventBody1 = new QueueEventBody("com.ifish7.mq.business.device.entity.TblLoginRecord",data);
|
||||
eventEntity1.setEventBody(eventBody1);
|
||||
//登录记录保存
|
||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity1));
|
||||
|
||||
|
||||
// LoginRecord loginRecord = new LoginRecord();
|
||||
// loginRecord.setMacAddress(strSrc);
|
||||
// loginRecord.setLoginTime(new Date());
|
||||
// deviceService.save(loginRecord);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
log.error("save device login error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||
|
|
|
|||
Loading…
Reference in New Issue