设备数据更新队列

This commit is contained in:
yiyan 2019-04-10 18:42:15 +08:00
parent c5dbae94d8
commit a5909f4294
1 changed files with 40 additions and 6 deletions

View File

@ -136,7 +136,17 @@ public class SomeServer {
try { try {
Integer Onoff = receive.getOnoff() & 0xff; Integer Onoff = receive.getOnoff() & 0xff;
if(Onoff==1 || Onoff==0){ 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{ else{
log.error("error Onoff:{},macAddress:{}",Onoff,strDest); log.error("error Onoff:{},macAddress:{}",Onoff,strDest);
@ -199,9 +209,22 @@ public class SomeServer {
factoryCode = factoryCode.equals("01")?"0a":factoryCode; factoryCode = factoryCode.equals("01")?"0a":factoryCode;
String typeCode = ByteUtil.toHex(receive.getHardware_type()); 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){ // 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()); // 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); // log.error("HexDump:{}",HexDump);
@ -209,10 +232,21 @@ public class SomeServer {
// } // }
// else{ // else{
//记录登录时间 //记录登录时间
LoginRecord loginRecord = new LoginRecord(); JSONObject data1 = new JSONObject();
loginRecord.setMacAddress(strSrc); data1.put("macAddress",stcMac);
loginRecord.setLoginTime(new Date()); QueueEventEntity eventEntity1 = new QueueEventEntity();
deviceService.save(loginRecord); 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) { } catch (Exception e) {
log.error("save device login error:macAddress:{},error msg:{}",strSrc,e.toString()); log.error("save device login error:macAddress:{},error msg:{}",strSrc,e.toString());