v4.6.9版本BUG
This commit is contained in:
parent
70626f9b6f
commit
1d8f127262
|
|
@ -5,10 +5,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ifish.entity.event.QueueEventBody;
|
|
||||||
import com.ifish.entity.event.QueueEventEntity;
|
|
||||||
import org.apache.mina.core.session.IoSession;
|
import org.apache.mina.core.session.IoSession;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobDataMap;
|
import org.quartz.JobDataMap;
|
||||||
|
|
@ -29,10 +25,6 @@ import com.ifish.netease.NeteaseIM;
|
||||||
import com.ifish.service.DeviceService;
|
import com.ifish.service.DeviceService;
|
||||||
import com.ifish.service.UserService;
|
import com.ifish.service.UserService;
|
||||||
import com.ifish.socketNew.SomeServer;
|
import com.ifish.socketNew.SomeServer;
|
||||||
import org.springframework.jms.core.JmsTemplate;
|
|
||||||
|
|
||||||
import javax.jms.Destination;
|
|
||||||
import javax.jms.Session;
|
|
||||||
|
|
||||||
public class ExecuteJob implements Job {
|
public class ExecuteJob implements Job {
|
||||||
|
|
||||||
|
|
@ -43,26 +35,22 @@ public class ExecuteJob implements Job {
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
|
||||||
private JmsTemplate jmsTemplate;
|
|
||||||
@Autowired
|
|
||||||
private Destination ifish7PushQueueDestination;
|
|
||||||
|
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
//任务传递的参数
|
//任务传递的参数
|
||||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||||
String macAddress = dataMap.getString("macAddress");
|
String macAddress = dataMap.getString("macAddress");
|
||||||
String timestamp = dataMap.getString("timestamp");
|
String timestamp = dataMap.getString("timestamp");
|
||||||
try {
|
try {
|
||||||
//移除为null的连接
|
//移除为null的连接
|
||||||
IoSession session_cz = SomeServer.sessions_cz.get(macAddress);
|
IoSession session_cz = SomeServer.sessions_cz.get(macAddress);
|
||||||
if(session_cz==null || session_cz.getRemoteAddress()==null){
|
if(session_cz==null || session_cz.getRemoteAddress()==null){
|
||||||
SomeServer.sessions_cz.remove(macAddress);
|
SomeServer.sessions_cz.remove(macAddress);
|
||||||
}
|
}
|
||||||
//设备是否存在
|
//设备是否存在
|
||||||
Device device = deviceService.getUniqueByProperty("macAddress", macAddress);
|
Device device = deviceService.getUniqueByProperty("macAddress", macAddress);
|
||||||
if(device!=null){
|
if(device!=null){
|
||||||
//记录次数
|
//记录次数
|
||||||
Integer number1 = device.getNumber1();
|
Integer number1 = device.getNumber1();
|
||||||
Integer number2 = device.getNumber2();
|
Integer number2 = device.getNumber2();
|
||||||
Integer number3 = device.getNumber3();
|
Integer number3 = device.getNumber3();
|
||||||
|
|
@ -77,50 +65,42 @@ public class ExecuteJob implements Job {
|
||||||
String title = PushTypeEnum.offline_push.getValue();
|
String title = PushTypeEnum.offline_push.getValue();
|
||||||
String msg = "【"+title+"】你的水族箱“"+showName+"”于"+timestamp+"离线,请及时查看!";
|
String msg = "【"+title+"】你的水族箱“"+showName+"”于"+timestamp+"离线,请及时查看!";
|
||||||
//发送云信消息
|
//发送云信消息
|
||||||
// boolean neteaseBln = false;
|
boolean neteaseBln = false;
|
||||||
// Map<String, String> neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg);
|
Map<String, String> neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg);
|
||||||
// if(neteaseMap!=null){
|
if(neteaseMap!=null){
|
||||||
// neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey());
|
neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey());
|
||||||
// }
|
}
|
||||||
//IOS极光推送
|
//IOS极光推送
|
||||||
// boolean jpushIosBln = false;
|
boolean jpushIosBln = false;
|
||||||
//推送记录
|
//推送记录
|
||||||
PushList pushList = new PushList();
|
PushList pushList = new PushList();
|
||||||
Integer deviceId = deviceUser.getPriId().getDeviceId();
|
Integer deviceId = deviceUser.getPriId().getDeviceId();
|
||||||
User user = userService.findById(userId);
|
User user = userService.findById(userId);
|
||||||
if(user!=null){
|
if(user!=null){
|
||||||
// String loginType = user.getLoginType();
|
String loginType = user.getLoginType();
|
||||||
// if(loginType!=null){
|
if(loginType!=null){
|
||||||
// Map<String,String> map = new HashMap<String, String>();
|
Map<String,String> map = new HashMap<String, String>();
|
||||||
// map.put("device_id", deviceId.toString());
|
map.put("device_id", deviceId.toString());
|
||||||
// map.put("device_name", showName);
|
map.put("device_name", showName);
|
||||||
// map.put("timestamp", timestamp);
|
map.put("timestamp", timestamp);
|
||||||
// map.put("msg_type", PushTypeEnum.offline_push.getKey());
|
map.put("msg_type", PushTypeEnum.offline_push.getKey());
|
||||||
//推送记录
|
//推送记录
|
||||||
pushList.setUserId(userId);
|
pushList.setUserId(userId);
|
||||||
pushList.setDeviceId(deviceId);
|
pushList.setDeviceId(deviceId);
|
||||||
pushList.setPhoneType("ALL");
|
pushList.setPhoneType(loginType.toLowerCase());
|
||||||
pushList.setShowName(showName);
|
pushList.setShowName(showName);
|
||||||
pushList.setPushType(PushTypeEnum.offline_push.getKey());
|
pushList.setPushType(PushTypeEnum.offline_push.getKey());
|
||||||
// pushList.setNeteaseStatus(neteaseBln?BooleanEnum.YES.getKey():BooleanEnum.NO.getKey());
|
pushList.setNeteaseStatus(neteaseBln?BooleanEnum.YES.getKey():BooleanEnum.NO.getKey());
|
||||||
pushList.setPushTitle(title);
|
pushList.setPushTitle(title);
|
||||||
pushList.setPushContext(msg);
|
pushList.setPushContext(msg);
|
||||||
// pushList.setCreateTime(new Date());
|
pushList.setCreateTime(new Date());
|
||||||
pushList.setNumber1(number1);
|
pushList.setNumber1(number1);
|
||||||
pushList.setNumber2(number2);
|
pushList.setNumber2(number2);
|
||||||
pushList.setNumber3(number3);
|
pushList.setNumber3(number3);
|
||||||
pushList.setNumber4(number4);
|
pushList.setNumber4(number4);
|
||||||
pushList.setNumber5(number5);
|
pushList.setNumber5(number5);
|
||||||
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
|
this.userService.save(pushList);
|
||||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
}
|
||||||
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
|
|
||||||
eventEntity.setEventProcess("deviceNotifcationPlus");
|
|
||||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList",data);
|
|
||||||
eventEntity.setEventBody(eventBody);
|
|
||||||
//推送至消息推送队列
|
|
||||||
sendPushQueueMessage(JSONObject.toJSONString(eventEntity));
|
|
||||||
// this.userService.save(pushList);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,14 +109,5 @@ public class ExecuteJob implements Job {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("error msg:{}",e.toString());
|
log.error("error msg:{}",e.toString());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送Push消息队列
|
|
||||||
* @param json 内容
|
|
||||||
*/
|
|
||||||
private void sendPushQueueMessage(final String json) {
|
|
||||||
jmsTemplate.send(ifish7PushQueueDestination,(Session session) -> session.createTextMessage(json));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
package com.ifish.socketNew;
|
package com.ifish.socketNew;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.ifish.entity.*;
|
import com.ifish.entity.*;
|
||||||
import com.ifish.entity.event.QueueEventBody;
|
|
||||||
import com.ifish.entity.event.QueueEventEntity;
|
|
||||||
import com.ifish.socketNew.model.receive.*;
|
import com.ifish.socketNew.model.receive.*;
|
||||||
|
import org.apache.mina.core.buffer.IoBuffer;
|
||||||
import org.apache.mina.core.session.IoSession;
|
import org.apache.mina.core.session.IoSession;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -34,10 +30,6 @@ import com.ifish.socketNew.model.send.OrderFunctionCode9;
|
||||||
import com.ifish.socketNew.util.OrderModel;
|
import com.ifish.socketNew.util.OrderModel;
|
||||||
import com.ifish.util.ByteUtil;
|
import com.ifish.util.ByteUtil;
|
||||||
import com.ifish.util.IfishUtil;
|
import com.ifish.util.IfishUtil;
|
||||||
import org.springframework.jms.core.JmsTemplate;
|
|
||||||
|
|
||||||
import javax.jms.Destination;
|
|
||||||
import javax.jms.Session;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,12 +45,6 @@ public class SomeServer {
|
||||||
private ScheduleJob scheduleJob;
|
private ScheduleJob scheduleJob;
|
||||||
@Autowired
|
@Autowired
|
||||||
private NeteaseIM neteaseIM;
|
private NeteaseIM neteaseIM;
|
||||||
@Autowired
|
|
||||||
private JmsTemplate jmsTemplate;
|
|
||||||
@Autowired
|
|
||||||
private Destination ifish7DataQueueDestination;
|
|
||||||
@Autowired
|
|
||||||
private Destination ifish7PushQueueDestination;
|
|
||||||
|
|
||||||
//是否回复心跳
|
//是否回复心跳
|
||||||
public static boolean isReplay = true;
|
public static boolean isReplay = true;
|
||||||
|
|
@ -76,18 +62,20 @@ public class SomeServer {
|
||||||
public void doSome(IoSession session, Object message) {
|
public void doSome(IoSession session, Object message) {
|
||||||
//通配字符串
|
//通配字符串
|
||||||
if(message instanceof byte[]){
|
if(message instanceof byte[]){
|
||||||
|
|
||||||
byte[] bytes = (byte[]) message;
|
byte[] bytes = (byte[]) message;
|
||||||
//长度
|
//长度
|
||||||
int length = bytes[14] & 0xff;
|
int length = bytes[14] & 0xff;
|
||||||
|
IoBuffer ioBuffer = ByteUtil.byteToIoBuffer(bytes, length);
|
||||||
|
byte type = ioBuffer.get();
|
||||||
|
// int Check_code = (int) ioBuffer.get();
|
||||||
//mac地址
|
//mac地址
|
||||||
byte[] srcByte = new byte[6];
|
byte[] srcByte = new byte[6];
|
||||||
for (int i = 2; i < 8; i++) {
|
for (int i = 2; i < 8; i++) {
|
||||||
srcByte[i-2] = bytes[i];
|
srcByte[i-2] = bytes[i];
|
||||||
}
|
}
|
||||||
String strSrc = ByteUtil.bytesToHexString(srcByte);
|
String strSrc = ByteUtil.bytesToHexString(srcByte);
|
||||||
//心跳
|
//如果为设备端返回 发送给app端
|
||||||
if(length>=28){
|
if(type == 1){
|
||||||
sendToApp(session,strSrc, message);
|
sendToApp(session,strSrc, message);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -98,31 +86,15 @@ public class SomeServer {
|
||||||
BackFunctionCodeHeater heater = (BackFunctionCodeHeater) message;
|
BackFunctionCodeHeater heater = (BackFunctionCodeHeater) message;
|
||||||
String macAddress = ByteUtil.bytesToHexString(heater.getSrc());
|
String macAddress = ByteUtil.bytesToHexString(heater.getSrc());
|
||||||
String hour = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
|
String hour = String.valueOf(Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
|
||||||
// List<DeviceHeater> deviceHeaters = deviceService.getDeviceHeaterByProperty(hour, macAddress,IfishUtil.format1(new Date()));
|
List<DeviceHeater> deviceHeaters = deviceService.getDeviceHeaterByProperty(hour, macAddress,IfishUtil.format1(new Date()));
|
||||||
// if (deviceHeaters.size() > 0) {
|
if (deviceHeaters.size() > 0) {
|
||||||
// DeviceHeater deviceHeater = deviceHeaters.get(0);
|
DeviceHeater deviceHeater = deviceHeaters.get(0);
|
||||||
// deviceHeater.setHeaterWaterTemperature(String.valueOf(heater.getWaterTemperature()));
|
deviceHeater.setHeaterWaterTemperature(String.valueOf(heater.getWaterTemperature()));
|
||||||
// deviceHeater.setHeaterPh(String.valueOf(heater.getPh()));
|
deviceHeater.setHeaterPh(String.valueOf(heater.getPh()));
|
||||||
// deviceService.update(deviceHeater);
|
deviceService.update(deviceHeater);
|
||||||
// } else {
|
} else {
|
||||||
// deviceService.save(heater);
|
deviceService.save(heater);
|
||||||
// }
|
}
|
||||||
JSONObject data = new JSONObject();
|
|
||||||
data.put("heaterMacAddress",macAddress);
|
|
||||||
data.put("heaterWaterTemperature",heater.getHeatingTemperature());
|
|
||||||
data.put("heaterPh",heater.getPh());
|
|
||||||
data.put("heaterGatheringDate",IfishUtil.format1(new Date()));
|
|
||||||
data.put("heaterGatheringTime",hour);
|
|
||||||
|
|
||||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
|
||||||
eventEntity.setEventName("com.ifish7.mq.queues.event.IntelligentHeatingRodEvent");
|
|
||||||
eventEntity.setEventProcess("intelligentHeatingRodSaveOrUpdate");
|
|
||||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDeviceHeater",data);
|
|
||||||
eventEntity.setEventBody(eventBody);
|
|
||||||
|
|
||||||
//智能加热棒数据更新及保存
|
|
||||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity));
|
|
||||||
|
|
||||||
//设备重新连接上,则移除延时推送的任务
|
//设备重新连接上,则移除延时推送的任务
|
||||||
JobGroup jobGroup = new JobGroup();
|
JobGroup jobGroup = new JobGroup();
|
||||||
jobGroup.setJobName(macAddress);
|
jobGroup.setJobName(macAddress);
|
||||||
|
|
@ -138,17 +110,7 @@ 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){
|
||||||
JSONObject data = new JSONObject();
|
deviceService.updateWarnOnoff(strDest,Onoff.toString());
|
||||||
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);
|
||||||
|
|
@ -192,41 +154,8 @@ public class SomeServer {
|
||||||
jobGroup.setTriggerName(strSrc);
|
jobGroup.setTriggerName(strSrc);
|
||||||
scheduleJob.deleteJob(jobGroup);
|
scheduleJob.deleteJob(jobGroup);
|
||||||
try {
|
try {
|
||||||
//macAddr地址
|
|
||||||
String stcMac = ByteUtil.bytesToHexString(model.getSrc());
|
|
||||||
//IP
|
|
||||||
byte[] log_Ip= receive.getLogin_ip();
|
|
||||||
StringBuilder ipStr = new StringBuilder();
|
|
||||||
for (int i = 0; i < log_Ip.length; i++) {
|
|
||||||
int v = log_Ip[i] & 0xff;
|
|
||||||
if(i==0){
|
|
||||||
ipStr.append(v);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ipStr.append("."+v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Integer version = receive.getVersion() & 0xff;
|
|
||||||
String factoryCode = ByteUtil.toHex(receive.getVendor());
|
|
||||||
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){
|
// 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);
|
||||||
|
|
@ -234,21 +163,10 @@ public class SomeServer {
|
||||||
// }
|
// }
|
||||||
// else{
|
// else{
|
||||||
//记录登录时间
|
//记录登录时间
|
||||||
JSONObject data1 = new JSONObject();
|
LoginRecord loginRecord = new LoginRecord();
|
||||||
data1.put("macAddress",stcMac);
|
loginRecord.setMacAddress(strSrc);
|
||||||
QueueEventEntity eventEntity1 = new QueueEventEntity();
|
loginRecord.setLoginTime(new Date());
|
||||||
eventEntity1.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
deviceService.save(loginRecord);
|
||||||
eventEntity1.setEventProcess("deviceLoginLogSave");
|
|
||||||
QueueEventBody eventBody1 = new QueueEventBody("com.ifish7.mq.business.device.entity.TblLoginRecord",data1);
|
|
||||||
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());
|
||||||
|
|
@ -298,34 +216,19 @@ public class SomeServer {
|
||||||
//查找设备
|
//查找设备
|
||||||
Device device = this.deviceService.getUniqueByProperty("macAddress", strSrc);
|
Device device = this.deviceService.getUniqueByProperty("macAddress", strSrc);
|
||||||
if(device!=null){
|
if(device!=null){
|
||||||
JSONObject data = new JSONObject();
|
|
||||||
data.put("macAddress",strSrc);
|
|
||||||
//是否升级
|
//是否升级
|
||||||
if(device.getIsUpgrade().equals(BooleanEnum.YES.getKey())){
|
if(device.getIsUpgrade().equals(BooleanEnum.YES.getKey())){
|
||||||
data.put("isUpgrade",BooleanEnum.NO.getKey());
|
device.setIsUpgrade(BooleanEnum.NO.getKey());
|
||||||
data.put("upgradeTime", LocalDateTime.now());
|
device.setUpgradeTime(new Date());
|
||||||
//
|
|
||||||
// device.setIsUpgrade(BooleanEnum.NO.getKey());
|
|
||||||
// device.setUpgradeTime(new Date());
|
|
||||||
//升级版本
|
//升级版本
|
||||||
int upgradeVersion = device.getUpgradeVersion();
|
int upgradeVersion = device.getUpgradeVersion();
|
||||||
OrderFunctionCode15 model = OrderModel.OrderFunctionCode15(macBytes,upgradeVersion);
|
OrderFunctionCode15 model = OrderModel.OrderFunctionCode15(macBytes,upgradeVersion);
|
||||||
session.write(model);
|
session.write(model);
|
||||||
}
|
}
|
||||||
data.put("sdkTime",IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
|
||||||
data.put("sdkVersion",receive.getVersion() & 0xff);
|
|
||||||
|
|
||||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
|
||||||
eventEntity.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
|
||||||
eventEntity.setEventProcess("deviceSdkUpdate");
|
|
||||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDevice",data);
|
|
||||||
eventEntity.setEventBody(eventBody);
|
|
||||||
//设备sdk更新
|
|
||||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity));
|
|
||||||
//记录参数
|
//记录参数
|
||||||
// device.setSdkVersion(receive.getVersion() & 0xff);
|
device.setSdkVersion(receive.getVersion() & 0xff);
|
||||||
// device.setSdkTime(IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
device.setSdkTime(IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
||||||
// this.deviceService.update(device);
|
this.deviceService.update(device);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("save device sdk version16 error:macAddress:{},error msg:{}",strSrc,e.toString());
|
log.error("save device sdk version16 error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||||
|
|
@ -339,46 +242,25 @@ public class SomeServer {
|
||||||
try {
|
try {
|
||||||
//查找设备
|
//查找设备
|
||||||
Device device = this.deviceService.getUniqueByProperty("macAddress", strSrc);
|
Device device = this.deviceService.getUniqueByProperty("macAddress", strSrc);
|
||||||
JSONObject data = new JSONObject();
|
|
||||||
data.put("macAddress",strSrc);
|
|
||||||
if(device!=null){
|
if(device!=null){
|
||||||
//是否升级
|
//是否升级
|
||||||
if(device.getIsUpgrade().equals(BooleanEnum.YES.getKey())){
|
if(device.getIsUpgrade().equals(BooleanEnum.YES.getKey())){
|
||||||
data.put("isUpgrade",BooleanEnum.NO.getKey());
|
device.setIsUpgrade(BooleanEnum.NO.getKey());
|
||||||
data.put("upgradeTime", LocalDateTime.now());
|
device.setUpgradeTime(new Date());
|
||||||
// device.setIsUpgrade(BooleanEnum.NO.getKey());
|
|
||||||
// device.setUpgradeTime(new Date());
|
|
||||||
//升级版本
|
//升级版本
|
||||||
int upgradeVersion = device.getUpgradeVersion();
|
int upgradeVersion = device.getUpgradeVersion();
|
||||||
OrderFunctionCode15 model = OrderModel.OrderFunctionCode15(macBytes,upgradeVersion);
|
OrderFunctionCode15 model = OrderModel.OrderFunctionCode15(macBytes,upgradeVersion);
|
||||||
session.write(model);
|
session.write(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
data.put("sdkTime",IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
|
||||||
data.put("sdkVersion",receive.getVersion() & 0xff);
|
|
||||||
data.put("number1",receive.getNumber1());
|
|
||||||
data.put("number2",receive.getNumber2());
|
|
||||||
data.put("number3",receive.getNumber3());
|
|
||||||
data.put("number4",receive.getNumber4());
|
|
||||||
data.put("number5",receive.getNumber5());
|
|
||||||
|
|
||||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
|
||||||
eventEntity.setEventName("com.ifish7.mq.queues.event.DeviceInfoEvent");
|
|
||||||
eventEntity.setEventProcess("deviceSdkUpdate");
|
|
||||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.device.entity.TblDevice",data);
|
|
||||||
eventEntity.setEventBody(eventBody);
|
|
||||||
//设备sdk更新
|
|
||||||
sendDataQueueMessage(JSONObject.toJSONString(eventEntity));
|
|
||||||
|
|
||||||
//记录参数
|
//记录参数
|
||||||
// device.setSdkVersion(receive.getVersion() & 0xff);
|
device.setSdkVersion(receive.getVersion() & 0xff);
|
||||||
// device.setSdkTime(IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
device.setSdkTime(IfishUtil.StrToDate(receive.getYear()+"-"+(receive.getMonth() & 0xff)+"-"+(receive.getDay() & 0xff)));
|
||||||
// device.setNumber1(receive.getNumber1());
|
device.setNumber1(receive.getNumber1());
|
||||||
// device.setNumber2(receive.getNumber2());
|
device.setNumber2(receive.getNumber2());
|
||||||
// device.setNumber3(receive.getNumber3());
|
device.setNumber3(receive.getNumber3());
|
||||||
// device.setNumber4(receive.getNumber4());
|
device.setNumber4(receive.getNumber4());
|
||||||
// device.setNumber5(receive.getNumber5());
|
device.setNumber5(receive.getNumber5());
|
||||||
// this.deviceService.update(device);
|
this.deviceService.update(device);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("save device sdk version17 error:macAddress:{},error msg:{}",strSrc,e.toString());
|
log.error("save device sdk version17 error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||||
|
|
@ -451,51 +333,43 @@ public class SomeServer {
|
||||||
User user = userService.findById(userId);
|
User user = userService.findById(userId);
|
||||||
if(user!=null){
|
if(user!=null){
|
||||||
//云信推送
|
//云信推送
|
||||||
// boolean neteaseBln = false;
|
boolean neteaseBln = false;
|
||||||
//极光推送
|
//极光推送
|
||||||
// boolean jpushIosBln = false;
|
boolean jpushIosBln = false;
|
||||||
// boolean jpushAndroidBln = false;
|
boolean jpushAndroidBln = false;
|
||||||
//发送云信消息
|
//发送云信消息
|
||||||
// Map<String, String> neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg);
|
Map<String, String> neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg);
|
||||||
// if(neteaseMap!=null){
|
if(neteaseMap!=null){
|
||||||
// neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey());
|
neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey());
|
||||||
// }
|
}
|
||||||
// String loginType = user.getLoginType();
|
String loginType = user.getLoginType();
|
||||||
// if(loginType!=null){
|
if(loginType!=null){
|
||||||
//推送记录
|
//推送记录
|
||||||
PushList pushList = new PushList();
|
PushList pushList = new PushList();
|
||||||
// Map<String,String> map = new HashMap<String, String>();
|
Map<String,String> map = new HashMap<String, String>();
|
||||||
// map.put("device_id", deviceId.toString());
|
map.put("device_id", deviceId.toString());
|
||||||
// map.put("device_name", showName);
|
map.put("device_name", showName);
|
||||||
// map.put("timestamp", timestamp);
|
map.put("timestamp", timestamp);
|
||||||
// map.put("msg_type", PushTypeEnum.wendu_warn.getKey());
|
map.put("msg_type", PushTypeEnum.wendu_warn.getKey());
|
||||||
//记录推送
|
//记录推送
|
||||||
// if(jpushIosBln || jpushAndroidBln || neteaseBln){
|
if(jpushIosBln || jpushAndroidBln || neteaseBln){
|
||||||
pushList.setUserId(userId);
|
pushList.setUserId(userId);
|
||||||
pushList.setDeviceId(deviceId);
|
pushList.setDeviceId(deviceId);
|
||||||
pushList.setPhoneType("ALL");
|
pushList.setPhoneType(loginType.toLowerCase());
|
||||||
pushList.setShowName(showName);
|
pushList.setShowName(showName);
|
||||||
pushList.setPushType(PushTypeEnum.wendu_warn.getKey());
|
pushList.setPushType(PushTypeEnum.wendu_warn.getKey());
|
||||||
pushList.setPushTitle(title);
|
pushList.setPushTitle(title);
|
||||||
pushList.setPushContext(msg);
|
pushList.setPushContext(msg);
|
||||||
// pushList.setNeteaseStatus(neteaseBln?BooleanEnum.YES.getKey():BooleanEnum.NO.getKey());
|
pushList.setNeteaseStatus(neteaseBln?BooleanEnum.YES.getKey():BooleanEnum.NO.getKey());
|
||||||
// pushList.setCreateTime(new Date());
|
pushList.setCreateTime(new Date());
|
||||||
pushList.setNumber1(device.getNumber1());
|
pushList.setNumber1(device.getNumber1());
|
||||||
pushList.setNumber2(device.getNumber2());
|
pushList.setNumber2(device.getNumber2());
|
||||||
pushList.setNumber3(device.getNumber3());
|
pushList.setNumber3(device.getNumber3());
|
||||||
pushList.setNumber4(device.getNumber4());
|
pushList.setNumber4(device.getNumber4());
|
||||||
pushList.setNumber5(device.getNumber5());
|
pushList.setNumber5(device.getNumber5());
|
||||||
JSONObject data = JSON.parseObject(JSON.toJSONString(pushList));
|
this.userService.save(pushList);
|
||||||
QueueEventEntity eventEntity = new QueueEventEntity();
|
}
|
||||||
eventEntity.setEventName("com.ifish7.mq.queues.event.PushNotifcationEvent");
|
}
|
||||||
eventEntity.setEventProcess("deviceNotifcationPlus");
|
|
||||||
QueueEventBody eventBody = new QueueEventBody("com.ifish7.mq.business.user.entity.TblPushList",data);
|
|
||||||
eventEntity.setEventBody(eventBody);
|
|
||||||
//推送至消息推送队列
|
|
||||||
sendPushQueueMessage(JSONObject.toJSONString(eventEntity));
|
|
||||||
// this.userService.save(pushList);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,20 +379,4 @@ public class SomeServer {
|
||||||
log.error("pushNotifcation error:macAddress:{},error msg:{}",strSrc,e.toString());
|
log.error("pushNotifcation error:macAddress:{},error msg:{}",strSrc,e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送Data消息队列
|
|
||||||
* @param json 内容
|
|
||||||
*/
|
|
||||||
private void sendDataQueueMessage(final String json){
|
|
||||||
jmsTemplate.send(ifish7DataQueueDestination,(Session session) -> session.createTextMessage(json));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 推送Push消息队列
|
|
||||||
* @param json 内容
|
|
||||||
*/
|
|
||||||
private void sendPushQueueMessage(final String json) {
|
|
||||||
jmsTemplate.send(ifish7PushQueueDestination,(Session session) -> session.createTextMessage(json));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
private void getValid(IoSession session, IoBuffer buf, ProtocolDecoderOutput out){
|
private void getValid(IoSession session, IoBuffer buf, ProtocolDecoderOutput out){
|
||||||
int limit = buf.remaining();
|
int limit = buf.remaining();
|
||||||
int check_code = buf.position(1).get() & 0xff;
|
int check_code = buf.position(1).get() & 0xff;
|
||||||
|
|
||||||
int length = buf.position(14).get() & 0xff;
|
int length = buf.position(14).get() & 0xff;
|
||||||
buf.position(0);
|
buf.position(0);
|
||||||
//计算包长度
|
//计算包长度
|
||||||
|
|
@ -101,11 +102,10 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
//crc16校验
|
//crc16校验
|
||||||
//boolean bln = CRC16.calcCrc16(ByteUtil.hexStringToBytes(hexDump));
|
//boolean bln = CRC16.calcCrc16(ByteUtil.hexStringToBytes(hexDump));
|
||||||
switch (length) {
|
switch (length) {
|
||||||
//长度为22
|
|
||||||
case 31: {
|
case 31: {
|
||||||
functionBackHeater(bytes,buf, out);
|
functionBackHeater(bytes,buf, out);
|
||||||
break;
|
break;
|
||||||
}
|
}//长度为22
|
||||||
case 22:{
|
case 22:{
|
||||||
//设置报警温度
|
//设置报警温度
|
||||||
if(check_code==5){
|
if(check_code==5){
|
||||||
|
|
@ -128,6 +128,8 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
case 24:{
|
case 24:{
|
||||||
if(check_code==1){
|
if(check_code==1){
|
||||||
functionCode1(buf, out);
|
functionCode1(buf, out);
|
||||||
|
} else {
|
||||||
|
out.write(bytes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -135,6 +137,8 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
case 25:{
|
case 25:{
|
||||||
if(check_code==0){
|
if(check_code==0){
|
||||||
functionCode0(buf, out);
|
functionCode0(buf, out);
|
||||||
|
} else {
|
||||||
|
out.write(bytes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -142,6 +146,8 @@ public class ServerDecode implements ProtocolDecoder {
|
||||||
case 42:{
|
case 42:{
|
||||||
if(check_code==17){
|
if(check_code==17){
|
||||||
functionCode17(buf, out);
|
functionCode17(buf, out);
|
||||||
|
} else {
|
||||||
|
out.write(bytes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,24 +90,22 @@
|
||||||
<property name="sessionCacheSize" value="100" />
|
<property name="sessionCacheSize" value="100" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
|
<!--<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
|
||||||
<property name="connectionFactory" ref="connectionFactory"/>
|
<property name="connectionFactory" ref="connectionFactory"/>
|
||||||
</bean>
|
</bean>-->
|
||||||
|
|
||||||
<!-- 定义数据存储消息队列(Queue) -->
|
<!-- 定义数据存储消息队列(Queue) -->
|
||||||
<bean id="ifish7DataQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
|
<!--<bean id="ifish7DataQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
|
||||||
<!-- 设置消息队列的名字 -->
|
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<value>${queue_data_name}</value>
|
<value>${queue_data_name}</value>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>-->
|
||||||
<!-- 定义消息推送消息队列(Queue) -->
|
<!-- 定义消息推送消息队列(Queue) -->
|
||||||
<bean id="ifish7PushQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
|
<!--<bean id="ifish7PushQueueDestination" class="org.apache.activemq.command.ActiveMQQueue">
|
||||||
<!-- 设置消息队列的名字 -->
|
|
||||||
<constructor-arg>
|
<constructor-arg>
|
||||||
<value>${queue_push_name}</value>
|
<value>${queue_push_name}</value>
|
||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</bean>-->
|
||||||
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
c3p0.driverClassName=com.mysql.jdbc.Driver
|
c3p0.driverClassName=com.mysql.jdbc.Driver
|
||||||
c3p0.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
#c3p0.url=jdbc\:mysql\://localhost\:3306/myfishdb?characterEncoding\=UTF-8
|
||||||
#c3p0.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
|
c3p0.url=jdbc\:mysql\://139.196.24.156\:3306/myfishdb?characterEncoding\=UTF-8
|
||||||
c3p0.username=ifish
|
#c3p0.username=ifish
|
||||||
c3p0.password=ifish7pwd
|
#c3p0.password=ifish7pwd
|
||||||
#c3p0.username=root
|
c3p0.username=root
|
||||||
#c3p0.password=ifish7mysql
|
c3p0.password=ifish7mysql
|
||||||
#c3p0.username=root
|
#c3p0.username=root
|
||||||
#c3p0.password=123456
|
#c3p0.password=123456
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#\u672c\u5730
|
#\u672c\u5730
|
||||||
#ifish.ip=192.168.31.83
|
#ifish.ip=192.168.1.13
|
||||||
#\u6d4b\u8bd5\u4e91
|
#\u6d4b\u8bd5\u4e91
|
||||||
#ifish.ip=139.196.24.156
|
#ifish.ip=139.196.24.156
|
||||||
#\u6b63\u5f0f\u4e91
|
#\u6b63\u5f0f\u4e91
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue