From d0f4f89f9d3d0b8af0bcc3bcc2b23bfca2703733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=B4=AA=E9=BE=99?= <599179587@qq.com> Date: Wed, 12 Jul 2017 13:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=95=B4=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nb-configuration.xml | 1 + src/main/java/com/ifish/bean/Tbl_Vender.java | 27 +- .../java/com/ifish/helper/DeviceHelper.java | 279 +++++++++++++----- .../java/com/ifish/helper/DeviceHelperI.java | 54 +++- .../java/com/ifish/helper/JpushHelper.java | 85 ++++++ .../java/com/ifish/helper/JpushHelperI.java | 31 ++ .../java/com/ifish/helper/RedisKeyHelper.java | 174 +++++++++++ .../com/ifish/helper/RedisKeyHelperI.java | 114 +++++++ .../java/com/ifish/helper/UserHelper.java | 8 +- .../com/ifish/mapper/Tbl_Device_Mapper.java | 13 +- src/main/java/com/ifish/push/JiGuangPush.java | 18 ++ .../socket/codeFactory/ServerDecode.java | 2 +- .../com/ifish/socket/config/ExecuteJob.java | 62 ++-- .../com/ifish/socket/config/SomeServer.java | 58 ++-- .../send/DeviceLoginContextLength24.java | 12 +- .../ifish/socket/webService/ServiceBean.java | 2 +- src/main/java/com/ifish/util/RedisKey.java | 66 ++--- src/main/resources/property.properties | 6 +- 18 files changed, 783 insertions(+), 229 deletions(-) create mode 100644 src/main/java/com/ifish/helper/JpushHelper.java create mode 100644 src/main/java/com/ifish/helper/JpushHelperI.java create mode 100644 src/main/java/com/ifish/helper/RedisKeyHelper.java create mode 100644 src/main/java/com/ifish/helper/RedisKeyHelperI.java create mode 100644 src/main/java/com/ifish/push/JiGuangPush.java diff --git a/nb-configuration.xml b/nb-configuration.xml index e4d870d..fd61576 100644 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -21,5 +21,6 @@ Any value defined here will override the pom.xml file value but is only applicab --> 1.7-web Tomcat + false diff --git a/src/main/java/com/ifish/bean/Tbl_Vender.java b/src/main/java/com/ifish/bean/Tbl_Vender.java index da691c8..c0a1010 100644 --- a/src/main/java/com/ifish/bean/Tbl_Vender.java +++ b/src/main/java/com/ifish/bean/Tbl_Vender.java @@ -24,7 +24,7 @@ public class Tbl_Vender implements java.io.Serializable { /** * 版本号 */ - private static final long serialVersionUID = -487543106603936914L; + private static final long serialVersionUID = 2462685903502867014L; /** * 鱼缸厂编号 @@ -33,13 +33,6 @@ public class Tbl_Vender implements java.io.Serializable { @Column(name = "brand_code", unique = true, nullable = false, length = 20) private String brandCode; - /** - * 电子厂代码 - */ - @Id - @Column(name = "factory_code", unique = true, nullable = false, length = 20) - private String factoryCode; - /** * logo */ @@ -106,24 +99,6 @@ public class Tbl_Vender implements java.io.Serializable { this.brandCode = brandCode; } - /** - * 获取电子厂代码 - * - * @return 电子厂代码 - */ - public String getFactoryCode() { - return this.factoryCode; - } - - /** - * 设置电子厂代码 - * - * @param factoryCode 电子厂代码 - */ - public void setFactoryCode(String factoryCode) { - this.factoryCode = factoryCode; - } - /** * 获取logo * diff --git a/src/main/java/com/ifish/helper/DeviceHelper.java b/src/main/java/com/ifish/helper/DeviceHelper.java index 9c7fae1..d8ba482 100644 --- a/src/main/java/com/ifish/helper/DeviceHelper.java +++ b/src/main/java/com/ifish/helper/DeviceHelper.java @@ -5,16 +5,15 @@ */ package com.ifish.helper; -import com.ifish.bean.LoginRecord; import com.ifish.bean.Tbl_Device; +import com.ifish.bean.Tbl_Device_Statistics; import com.ifish.bean.Tbl_Device_User; -import com.ifish.bean.Tbl_Factory_List; -import com.ifish.bean.Tbl_HardWare_Type; import com.ifish.mapper.Tbl_Device_Mapper; import com.ifish.mapper.Tbl_Hardware_Type_Mapper; import com.ifish.socket.model.send.DeviceLoginContextLength24; +import com.ifish.util.ByteUtil; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; +import java.util.Date; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -36,14 +35,27 @@ public class DeviceHelper implements DeviceHelperI { @Autowired private RedisHelperI redisHelperI; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + @Autowired private Tbl_Device_Mapper tbl_Device_Mapper; + /** + * 修改设备信息 + * + * @param device + * @return + */ @Override public Tbl_Device update(Tbl_Device device) { try { + if (device.getDeviceId() == 0) { + return null; + } int i = tbl_Device_Mapper.updateTbl_Device(device); if (i > 0) { + redisKeyHelperI.deleteRedisByTbl_Device(device); return device; } else { return null; @@ -53,85 +65,171 @@ public class DeviceHelper implements DeviceHelperI { } } + /** + * 登陆修改设备的厂家等信息 + * + * @param model + * @return + */ @Override - public Tbl_Device update(DeviceLoginContextLength24 model) { - return null; - } - - @Override - public void updateWarnOnoff(String macAddress, String onOff) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Tbl_Device getUniqueByProperty(String property, Object value) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public List getByProperty(String property, Object value) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Tbl_Device_User getUniqueByProperty(String macAddress) { - Tbl_Device device = getDeviceByMacAddress(macAddress); - Tbl_Device_User deviceUser = null; + public Tbl_Device updateDeviceWhenLogin(DeviceLoginContextLength24 model) { try { -// String key = RedisKey.DeviceUser_Key + "m" + macAddress; -// String redisString = redisHelperI.getRedis(key); -// if (StringUtils.isNotBlank(redisString)) { -// deviceUser = (Tbl_Device_User) IfishUtil.JsonToBean(redisString, Tbl_Device_User.class); -// } else { -// device = tbl_Device_Mapper.getDeviceUsersByUserIdAndDeviceId(device.get, deviceId); -// if (device != null && device.getDeviceId() > 0) { -// redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device)); -// } -// } - } catch (Exception e) { - } - return deviceUser; - } + //macAddr地址 + String stcMac = ByteUtil.bytesToHexString(model.getSrc()); + //IP + byte[] log_Ip = model.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 = model.getVersion() & 0xff; + //电子厂 + String factoryCode = ByteUtil.toHex(model.getfactoryCode()); + factoryCode = factoryCode.equals("01") ? "0a" : factoryCode; + //硬件类型 + String typeCode = ByteUtil.toHex(model.getHardware_type()); - @Override - public List getListByProperty(Integer deviceId) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } + Tbl_Device device = getDeviceByMacAddress(stcMac); + if (device != null) { + Tbl_Device_Statistics device_Statistics = getDeviceStatisticsByDeviceId(device.getDeviceId()); + Integer loginConut = device_Statistics.getLoginCount(); + if (loginConut != null) { + device_Statistics.setLoginCount(++loginConut); + } else { + device_Statistics.setLoginCount(1); + } + device.setFactoryCode(factoryCode); + device_Statistics.setFactoryCode(factoryCode); + device.setHardwareType(typeCode); + device_Statistics.setHardwareType(typeCode); + device_Statistics.setSoftwareVersion(version.toString()); + device.setDeviceIp(ipStr.toString()); + Date date = new Date(); + device.setLoginTime(date); + device_Statistics.setLoginTime(date); + tbl_Device_Mapper.updateTbl_Device(device); + redisKeyHelperI.deleteRedisByTbl_Device(device); - @Override - public LoginRecord save(LoginRecord loginRecord) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Tbl_Factory_List getFactoryListById(String factoryCode) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public Tbl_HardWare_Type getHardwareTypeById(String typeCode) { - - Tbl_HardWare_Type hardwareType = null; - try { - String key = RedisKey.HardWareType_key + typeCode; - String redisString = redisHelperI.getRedis(key); - if (StringUtils.isNotBlank(redisString)) { - hardwareType = (Tbl_HardWare_Type) IfishUtil.JsonToBean(redisString, Tbl_HardWare_Type.class); + tbl_Device_Mapper.updateDeviceStatistics(device_Statistics); + redisKeyHelperI.deleteRedisByTbl_Device_Statistics(device_Statistics); + return device; } else { - hardwareType = tbl_Hardware_Type_Mapper.getHardwareTypeByTypeCode(typeCode); - if (hardwareType != null && StringUtils.isNotBlank(hardwareType.getHardwareType())) { - redisHelperI.setRedis(key, IfishUtil.ObjectToJson(hardwareType)); + //新增 + //log.warn("macAddress not exist in database:{}",stcMac); + device = new Tbl_Device(); + device.setMacAddress(stcMac); + device.setFactoryCode(factoryCode); + device.setHardwareType(typeCode); + device.setDeviceIp(ipStr.toString()); + Date date = new Date(); + device.setLoginTime(date); + device.setCreateTime(date); + device.setIsCamera("0"); + int i = tbl_Device_Mapper.insertDevice(device); + if (i > 0) { + Tbl_Device_Statistics device_Statistics = new Tbl_Device_Statistics(); + device_Statistics.setSoftwareVersion(version.toString()); + device_Statistics.setLoginCount(1); + device_Statistics.setLoginTime(date); + device_Statistics.setCreateDate(date); + device_Statistics.setCreateTime(date); + device_Statistics.setMacAddress(stcMac); + device_Statistics.setFactoryCode(factoryCode); + device_Statistics.setHardwareType(typeCode); + device_Statistics.setDeviceId(device.getDeviceId()); + tbl_Device_Mapper.insertDeviceStatistics(device_Statistics); + } + return device; + } + } catch (Exception e) { + return null; + } + } + + /** + * 修改设备统计信息 + * + * @param device_Statistics + * @return + */ + public Tbl_Device_Statistics updateDevice_Statistics(Tbl_Device_Statistics device_Statistics) { + try { + if (device_Statistics.getDeviceId() != 0 || StringUtils.isNotBlank(device_Statistics.getMacAddress())) { + int i = tbl_Device_Mapper.updateDeviceStatistics(device_Statistics); + if (i > 0) { + //清楚已缓存的redis + redisKeyHelperI.deleteRedisByTbl_Device_Statistics(device_Statistics); + //返回修改成功的设备统计数据 + if (StringUtils.isNotBlank(device_Statistics.getMacAddress())) { + return getDeviceStatisticsByMacAddress(device_Statistics.getMacAddress()); + } else if (device_Statistics.getDeviceId() != 0) { + return getDeviceStatisticsByDeviceId(device_Statistics.getDeviceId()); + } } } } catch (Exception e) { } - return hardwareType; + return null; } + /** + * 设置温度是否报警 + * + * @param macAddress + * @param onOff + */ + @Override + public void updateWarnOnoff(String macAddress, String onOff) { + Tbl_Device device = getDeviceByMacAddress(macAddress); + if (device != null) { + device.setOnOff(onOff); + tbl_Device_Mapper.updateTbl_Device(device); + redisKeyHelperI.deleteRedisByTbl_Device(device); + } + } + + /** + * 根据设备ID获取此设备所有的用户关系列表 + * + * @param deviceId + * @return + */ + @Override + public List getTbl_Device_UsersListByDeviceId(Integer deviceId) { + List deviceUserList = null; + try { + String key = redisKeyHelperI.getListTbl_Device_UserKeyByDeviceId(deviceId); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + deviceUserList = (List) IfishUtil.JsonToList(redisString, Tbl_Device_User.class); + } else { + deviceUserList = tbl_Device_Mapper.getDeviceUsersByUserId(deviceId); + if (deviceUserList != null && deviceUserList.size() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(deviceUserList)); + } + } + } catch (Exception e) { + } + return deviceUserList; + } + + /** + * 根据mac地址查找设备 + * + * @param macAddress + * @return + */ + @Override public Tbl_Device getDeviceByMacAddress(String macAddress) { Tbl_Device device = null; try { - String key = RedisKey.Device_key + macAddress; + String key = redisKeyHelperI.getTbl_DeviceRedisKeyByMacAddress(macAddress); String redisString = redisHelperI.getRedis(key); if (StringUtils.isNotBlank(redisString)) { device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class); @@ -146,4 +244,47 @@ public class DeviceHelper implements DeviceHelperI { return device; } + /** + * 根据设备ID获取设备统计信息 + * + * @param deviceId + * @return + * @throws Exception + */ + public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception { + Tbl_Device_Statistics device = null; + String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByDeviceId(deviceId); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class); + } else { + device = tbl_Device_Mapper.getDevStatisticsByDeviceId(deviceId); + if (device != null && device.getDeviceId() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device)); + } + } + return device; + } + + /** + * 根据设备ID获取设备统计信息 + * + * @param deviceId + * @return + * @throws Exception + */ + public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String macAddress) throws Exception { + Tbl_Device_Statistics device = null; + String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByMacAddress(macAddress); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + device = (Tbl_Device_Statistics) IfishUtil.JsonToBean(redisString, Tbl_Device_Statistics.class); + } else { + device = tbl_Device_Mapper.getDevStatisticsByMacAddress(macAddress); + if (device != null && device.getDeviceId() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device)); + } + } + return device; + } } diff --git a/src/main/java/com/ifish/helper/DeviceHelperI.java b/src/main/java/com/ifish/helper/DeviceHelperI.java index f3bf135..64324b5 100644 --- a/src/main/java/com/ifish/helper/DeviceHelperI.java +++ b/src/main/java/com/ifish/helper/DeviceHelperI.java @@ -7,6 +7,7 @@ package com.ifish.helper; import com.ifish.bean.LoginRecord; import com.ifish.bean.Tbl_Device; +import com.ifish.bean.Tbl_Device_Statistics; import com.ifish.bean.Tbl_Device_User; import com.ifish.bean.Tbl_Factory_List; import com.ifish.bean.Tbl_HardWare_Type; @@ -19,23 +20,52 @@ import java.util.List; */ public interface DeviceHelperI { + /** + * 修改设备信息 + * + * @param device + * @return + */ public Tbl_Device update(Tbl_Device device); - public Tbl_Device update(DeviceLoginContextLength24 model); + /** + * 登陆时修改设备的厂家等信息 + * + * @param model + * @return + */ + public Tbl_Device updateDeviceWhenLogin(DeviceLoginContextLength24 model); + /** + * 设置温度是否报警 + * + * @param macAddress + * @param onOff + */ public void updateWarnOnoff(String macAddress, String onOff); - public Tbl_Device getUniqueByProperty(String property, Object value); + /** + * 根据mac地址查找设备 + * + * @param property + * @param value + * @return + */ + public Tbl_Device getDeviceByMacAddress(String macAddress); - public List getByProperty(String property, Object value); + /** + * 修改设备统计信息 + * + * @param device_Statistics + * @return + */ + public Tbl_Device_Statistics updateDevice_Statistics(Tbl_Device_Statistics device_Statistics); - public Tbl_Device_User getUniqueByProperty(String macAddress); - - public List getListByProperty(Integer deviceId); - - public LoginRecord save(LoginRecord loginRecord); - - public Tbl_Factory_List getFactoryListById(String factoryCode); - - public Tbl_HardWare_Type getHardwareTypeById(String typeCode); + /** + * 根据设备ID获取此设备所有的用户关系列表 + * + * @param deviceId + * @return + */ + public List getTbl_Device_UsersListByDeviceId(Integer deviceId); } diff --git a/src/main/java/com/ifish/helper/JpushHelper.java b/src/main/java/com/ifish/helper/JpushHelper.java new file mode 100644 index 0000000..fac3bc8 --- /dev/null +++ b/src/main/java/com/ifish/helper/JpushHelper.java @@ -0,0 +1,85 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import cn.jpush.api.JPushClient; +import cn.jpush.api.push.PushResult; +import cn.jpush.api.push.model.Platform; +import cn.jpush.api.push.model.PushPayload; +import cn.jpush.api.push.model.audience.Audience; +import cn.jpush.api.push.model.notification.Notification; +import java.util.Map; +import org.springframework.stereotype.Component; + +/** + * + * @author Administrator + */ +@Component +public class JpushHelper implements JpushHelperI { + + private static JPushClient jPushClient = null; + //正式 +// private static final String masterSecret = "60162c8cf195ce9f4dc76629"; +// private static final String appKey = "d970d5e193cb2a0bbe41653c"; + //测试 + private final static String masterSecret = "a7d41825e75082b13675c326"; + private final static String appKey = "d147124018074eb970474e48"; + + static { + jPushClient = new JPushClient(masterSecret, appKey); + } + + /** + * 向安卓手机推送一条信息 + * + * @param message + * @return + */ + @Override + public boolean pushMessageByAndroid(String message, String registrationID, Map map) { + try { + PushPayload payload = PushPayload.newBuilder() + .setPlatform(Platform.android()) + .setAudience(Audience.registrationId(registrationID)) + .setNotification(Notification.android("爱鱼奇提示", message, map)) + .build(); + + PushResult result = jPushClient.sendPush(payload); + if (result.msg_id > 0 && result.isResultOK()) { + return true; + } + } catch (Exception e) { + + } + return false; + } + + /** + * 向苹果手机推送一条信息 + * + * @param message + * @return + */ + @Override + public boolean pushMessageByIOS(String message, String registrationID, Map map) { + try { + PushPayload payload = PushPayload.newBuilder() + .setPlatform(Platform.ios()) + .setAudience(Audience.registrationId(registrationID)) + .setNotification(Notification.android("爱鱼奇提示", message, map)) + .build(); + + PushResult result = jPushClient.sendPush(payload); + if (result.msg_id > 0 && result.isResultOK()) { + return true; + } + } catch (Exception e) { + + } + return false; + } +} diff --git a/src/main/java/com/ifish/helper/JpushHelperI.java b/src/main/java/com/ifish/helper/JpushHelperI.java new file mode 100644 index 0000000..ae21f87 --- /dev/null +++ b/src/main/java/com/ifish/helper/JpushHelperI.java @@ -0,0 +1,31 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import java.util.Map; + +/** + * + * @author Administrator + */ +public interface JpushHelperI { + + /** + * 向安卓手机推送一条信息 + * + * @param message + * @return + */ + boolean pushMessageByAndroid(String message, String registrationID, Map map); + + /** + * 向苹果手机推送一条信息 + * + * @param message + * @return + */ + boolean pushMessageByIOS(String message, String registrationID, Map map); +} diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java new file mode 100644 index 0000000..12a8867 --- /dev/null +++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java @@ -0,0 +1,174 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.bean.Tbl_Device; +import com.ifish.bean.Tbl_Device_Statistics; +import com.ifish.bean.Tbl_Device_User; +import com.ifish.bean.Tbl_User; +import com.ifish.util.RedisKey; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * + * @author Administrator + */ +@Component +public class RedisKeyHelper implements RedisKeyHelperI { + + @Autowired + private RedisHelperI redisHelperI; + + /** + * 根据userId获取Tbl_User用户信息的Redis缓存key键值 + * + * @param userId + * @return + */ + public String getTbl_UserRedisKeyByUserId(Integer userId) { + return RedisKey.USER_ID_KEY + userId; + } + + /** + * 根据mac地址获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_DeviceRedisKeyByMacAddress(String macAddress) { + return RedisKey.DEVICE_KEY_MACADDRESS + macAddress; + } + + /** + * 根据Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_DeviceRedisKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_KEY_DEVICEID + deviceId; + } + + /** + * 根据设备ID和用户ID获取Tbl_Device_User的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + @Override + public String getTbl_Device_UserRedisKeyByDeviceIdAndUserId(Integer userId, Integer deviceId) { + return RedisKey.DEVICE_USER_DEVICEID_AND_USERID + "u_" + userId + "_d_" + deviceId; + } + + /** + * 根据设备ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + @Override + public String getListTbl_Device_UserKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_USER_LIST_DEVICEID + deviceId; + } + + /** + * 根据mac地址获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_Device_StatisticsRedisKeyByMacAddress(String macAddress) { + return RedisKey.DEVICE_STATISTICS_MACADDRESS + macAddress; + } + + /** + * 根据Id获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + @Override + public String getTbl_Device_StatisticsRedisKeyByDeviceId(Integer deviceId) { + return RedisKey.DEVICE_STATISTICS_DEVICEID + deviceId; + } + + /** + * 根据typeCode获取Tbl_HardWare_Type的redis缓存key键值 + * + * @param typeCode + * @return + */ + public String getTbl_HardWare_TypeRedisKeyByTypeCode(String typeCode) { + return RedisKey.HARD_WARE_TYPE + typeCode; + } + + /** + * 删除redis中某个设备详情Tbl_Device的缓存 + * + * @param device + * @return + */ + @Override + public void deleteRedisByTbl_Device(Tbl_Device device) { + if (device.getDeviceId() > 0) { + redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); + } + if (StringUtils.isNotBlank(device.getMacAddress())) { + redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress())); + } + } + + /** + * 删除redis中某个设备统计信息Tbl_Device_Statistics的缓存 + * + * @param device + * @return + */ + @Override + public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) { + if (device.getDeviceId() > 0) { + redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); + } + if (StringUtils.isNotBlank(device.getMacAddress())) { + redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress())); + } + } + + /** + * 删除redis中某个设备和用户关系Tbl_Device_User的缓存 + * + * @param tbl_Device_User + */ + @Override + public void deleteRedisByTbl_Device_User(Tbl_Device_User tbl_Device_User) { + if (tbl_Device_User.getDeviceId() > 0 && tbl_Device_User.getUserId() > 0) { + redisHelperI.deleteRedis(getTbl_Device_UserRedisKeyByDeviceIdAndUserId(tbl_Device_User.getUserId(), tbl_Device_User.getDeviceId())); + } + if (tbl_Device_User.getDeviceId() > 0) { + redisHelperI.deleteRedis(getListTbl_Device_UserKeyByDeviceId(tbl_Device_User.getDeviceId())); + } + } + + /** + * 删除redis中某个用户Tbl_User的缓存 + * + * @param tbl_User + */ + @Override + public void deleteRedisByTbl_User(Tbl_User tbl_User) { + if (tbl_User.getUserId() > 0) { + redisHelperI.deleteRedis(getTbl_UserRedisKeyByUserId(tbl_User.getUserId())); + } + } + +} diff --git a/src/main/java/com/ifish/helper/RedisKeyHelperI.java b/src/main/java/com/ifish/helper/RedisKeyHelperI.java new file mode 100644 index 0000000..b4797fc --- /dev/null +++ b/src/main/java/com/ifish/helper/RedisKeyHelperI.java @@ -0,0 +1,114 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.bean.Tbl_Device; +import com.ifish.bean.Tbl_Device_Statistics; +import com.ifish.bean.Tbl_Device_User; +import com.ifish.bean.Tbl_User; + +/** + * + * @author Administrator + */ +public interface RedisKeyHelperI { + + /** + * 根据userId获取Tbl_User用户信息的Redis缓存key键值 + * + * @param userId + * @return + */ + public String getTbl_UserRedisKeyByUserId(Integer userId); + + /** + * 根据mac地址获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_DeviceRedisKeyByMacAddress(String macAddress); + + /** + * 根据Id获取Tbl_Device的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_DeviceRedisKeyByDeviceId(Integer deviceId); + + /** + * 根据mac地址获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_Device_StatisticsRedisKeyByMacAddress(String macAddress); + + /** + * 根据Id获取Tbl_Device_Statistics的redis缓存key键值 + * + * @param macAddress + * @return + */ + public String getTbl_Device_StatisticsRedisKeyByDeviceId(Integer deviceId); + + /** + * 根据设备ID和用户ID获取Tbl_Device_User的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + public String getTbl_Device_UserRedisKeyByDeviceIdAndUserId(Integer userId, Integer deviceId); + + /** + * 根据设备ID获取Tbl_Device_User(列表)的redis缓存key键值 + * + * @param userId + * @param deviceId + * @return + */ + public String getListTbl_Device_UserKeyByDeviceId(Integer deviceId); + + /** + * 根据typeCode获取Tbl_HardWare_Type的redis缓存key键值 + * + * @param typeCode + * @return + */ + public String getTbl_HardWare_TypeRedisKeyByTypeCode(String typeCode); + + /** + * 删除redis中某个设备详情的缓存 + * + * @param device + * @return + */ + public void deleteRedisByTbl_Device(Tbl_Device device); + + /** + * 删除redis中某个设备统计信息Tbl_Device_Statistics的缓存 + * + * @param device + * @return + */ + public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device); + + /** + * 删除redis中某个设备和用户关系Tbl_Device_User的缓存 + * + * @param tbl_Device_User + */ + public void deleteRedisByTbl_Device_User(Tbl_Device_User tbl_Device_User); + + /** + * 删除redis中某个用户Tbl_User的缓存 + * + * @param tbl_User + */ + public void deleteRedisByTbl_User(Tbl_User tbl_User); +} diff --git a/src/main/java/com/ifish/helper/UserHelper.java b/src/main/java/com/ifish/helper/UserHelper.java index bd7a33d..ed6697e 100644 --- a/src/main/java/com/ifish/helper/UserHelper.java +++ b/src/main/java/com/ifish/helper/UserHelper.java @@ -10,7 +10,6 @@ import com.ifish.bean.Tbl_User; import com.ifish.mapper.Tbl_Push_List_Mapper; import com.ifish.mapper.Tbl_User_Mapper; import com.ifish.util.IfishUtil; -import com.ifish.util.RedisKey; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,11 +30,14 @@ public class UserHelper implements UserHelperI { @Autowired private Tbl_Push_List_Mapper tbl_Push_List_Mapper; + @Autowired + private RedisKeyHelperI redisKeyHelperI; + @Override public Tbl_User findById(Integer userId) { Tbl_User tmpUser = null; try { - String userKey = RedisKey.User_Key + userId; + String userKey = redisKeyHelperI.getTbl_UserRedisKeyByUserId(userId); String userString = redisHelperI.getRedis(userKey); //1.从数据库或缓存中读取用户对象 if (StringUtils.isNotBlank(userString)) { @@ -69,7 +71,7 @@ public class UserHelper implements UserHelperI { * @param user */ private void saveUserToRedis(Tbl_User user) throws Exception { - String key = RedisKey.User_Key + user.getUserId(); + String key = redisKeyHelperI.getTbl_UserRedisKeyByUserId(user.getUserId()); redisHelperI.setRedis(key, IfishUtil.ObjectToJson(user)); } } diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java index 5fc6a38..3371677 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java @@ -120,6 +120,16 @@ public interface Tbl_Device_Mapper { + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE device_id=#{deviceid}") Tbl_Device_Statistics getDevStatisticsByDeviceId(@Param("deviceid") Integer deviceid); + /** + * 根据设备ID查询设备统计信息 + * + * @param deviceid + * @return + */ + @Select("SELECT id,device_id,mac_address,login_count,login_time,first_activate,create_time,is_charge,sdk_version,sdk_time,create_date,is_upgrade,upgrade_version," + + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE mac_address=#{mac}") + Tbl_Device_Statistics getDevStatisticsByMacAddress(@Param("mac") String macAddress); + /** * 插入一条设备统计信息 * @@ -168,7 +178,6 @@ public interface Tbl_Device_Mapper { @Delete("DELETE from tbl_device where id = #{id}") int deleteDeviceById(@Param("id") Integer id); - /** * 修改设备信息 * @@ -186,5 +195,5 @@ public interface Tbl_Device_Mapper { */ @Update("UPDATE tbl_activa_code set is_used='1' WHERE active_code = #{code}") Integer updateTblActivaCodeIsUse(@Param("code") String activa_Code); - + } diff --git a/src/main/java/com/ifish/push/JiGuangPush.java b/src/main/java/com/ifish/push/JiGuangPush.java new file mode 100644 index 0000000..86d7c0c --- /dev/null +++ b/src/main/java/com/ifish/push/JiGuangPush.java @@ -0,0 +1,18 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.push; + +import cn.jiguang.common.ClientConfig; +import cn.jpush.api.JPushClient; +import cn.jpush.api.push.model.PushPayload; + +/** + * + * @author Administrator + */ +public class JiGuangPush { + +} diff --git a/src/main/java/com/ifish/socket/codeFactory/ServerDecode.java b/src/main/java/com/ifish/socket/codeFactory/ServerDecode.java index 5cc6dd2..ed9ed9a 100644 --- a/src/main/java/com/ifish/socket/codeFactory/ServerDecode.java +++ b/src/main/java/com/ifish/socket/codeFactory/ServerDecode.java @@ -168,7 +168,7 @@ public class ServerDecode implements ProtocolDecoder { model.setDest(dest); model.setRemote_len(buf.get()); //登陆信息 - model.setVendor(buf.get()); + model.setfactoryCode(buf.get()); model.setHardware_type(buf.get()); model.setVersion(buf.get()); byte[] login_ip = model.getLogin_ip(); diff --git a/src/main/java/com/ifish/socket/config/ExecuteJob.java b/src/main/java/com/ifish/socket/config/ExecuteJob.java index 81f2658..9382561 100644 --- a/src/main/java/com/ifish/socket/config/ExecuteJob.java +++ b/src/main/java/com/ifish/socket/config/ExecuteJob.java @@ -13,11 +13,13 @@ import com.ifish.bean.Tbl_Push_List; import com.ifish.bean.Tbl_User; import com.ifish.enums.PushTypeEnum; import com.ifish.helper.DeviceHelperI; +import com.ifish.helper.JpushHelperI; import com.ifish.helper.UserHelperI; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.apache.mina.core.session.IoSession; import org.quartz.Job; import org.quartz.JobDataMap; @@ -40,6 +42,8 @@ public class ExecuteJob implements Job { private UserHelperI userHelperI; @Autowired private DeviceHelperI deviceHelperI; + @Autowired + private JpushHelperI jpushHelperI; public void execute(JobExecutionContext context) throws JobExecutionException { //任务传递的参数 @@ -53,7 +57,7 @@ public class ExecuteJob implements Job { SomeServer.sessions_cz.remove(macAddress); } //设备是否存在 - Tbl_Device device = deviceHelperI.getUniqueByProperty("macAddress", macAddress); + Tbl_Device device = deviceHelperI.getDeviceByMacAddress(macAddress); Tbl_Device_Statistics device_Statistics = null; if (device != null) { //记录次数 @@ -62,7 +66,7 @@ public class ExecuteJob implements Job { Integer number3 = device_Statistics.getRouterCount(); Integer number4 = device_Statistics.getServerCount(); Integer number5 = device_Statistics.getServerTryCount(); - List list = deviceHelperI.getListByProperty(device.getDeviceId()); + List list = deviceHelperI.getTbl_Device_UsersListByDeviceId(device.getDeviceId()); //是否被绑定 if (list != null) { for (Tbl_Device_User deviceUser : list) { @@ -70,42 +74,44 @@ public class ExecuteJob implements Job { String showName = deviceUser.getShowName(); String title = PushTypeEnum.offline_push.getValue(); String msg = "【" + title + "】你的水族箱“" + showName + "”于" + timestamp + "离线,请及时查看!"; - //发送云信消息 - boolean neteaseBln = false; -// Map neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg); -// if (neteaseMap != null) { -// neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey()); -// } - //IOS极光推送 - boolean jpushIosBln = false; + Tbl_User user = userHelperI.findById(userId); //推送记录 Tbl_Push_List pushList = new Tbl_Push_List(); Integer deviceId = deviceUser.getDeviceId(); - Tbl_User user = userHelperI.findById(userId); if (user != null) { String loginType = user.getLoginType(); - if (loginType != null) { + String registrationID = user.getJiguangUserid(); + if (StringUtils.isNotBlank(loginType) && StringUtils.isNotBlank(registrationID)) { Map map = new HashMap(); map.put("device_id", deviceId.toString()); map.put("device_name", showName); map.put("timestamp", timestamp); map.put("msg_type", PushTypeEnum.offline_push.getKey()); - //推送记录 - pushList.setUserId(userId); - pushList.setDeviceId(deviceId); - pushList.setPhoneType(loginType.toLowerCase()); - pushList.setShowName(showName); - pushList.setPushType(PushTypeEnum.offline_push.getKey()); - pushList.setJpushStatus(neteaseBln ? "1" : "0"); - pushList.setPushTitle(title); - pushList.setPushContext(msg); - pushList.setCreateTime(new Date()); - pushList.setMcuCount(number1); - pushList.setModularCount(number2); - pushList.setRouterCount(number3); - pushList.setServerCount(number4); - pushList.setServerTryCount(number5); - userHelperI.save(pushList); + //极光推送 + boolean result = false; + if (loginType.equals("android")) { + result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map); + } else if (loginType.equals("ios")) { + result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map); + } + if (result) { + //推送记录 + pushList.setUserId(userId); + pushList.setDeviceId(deviceId); + pushList.setPhoneType(loginType.toLowerCase()); + pushList.setShowName(showName); + pushList.setPushType(PushTypeEnum.offline_push.getKey()); + pushList.setJpushStatus(result ? "1" : "0"); + pushList.setPushTitle(title); + pushList.setPushContext(msg); + pushList.setCreateTime(new Date()); + pushList.setMcuCount(number1); + pushList.setModularCount(number2); + pushList.setRouterCount(number3); + pushList.setServerCount(number4); + pushList.setServerTryCount(number5); + userHelperI.save(pushList); + } } } } diff --git a/src/main/java/com/ifish/socket/config/SomeServer.java b/src/main/java/com/ifish/socket/config/SomeServer.java index 3deb2eb..1899327 100644 --- a/src/main/java/com/ifish/socket/config/SomeServer.java +++ b/src/main/java/com/ifish/socket/config/SomeServer.java @@ -13,6 +13,7 @@ import com.ifish.bean.Tbl_Push_List; import com.ifish.bean.Tbl_User; import com.ifish.enums.PushTypeEnum; import com.ifish.helper.DeviceHelperI; +import com.ifish.helper.JpushHelperI; import com.ifish.helper.UserHelperI; import com.ifish.socket.model.JobGroup; import com.ifish.socket.model.OrderModel; @@ -33,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; +import org.apache.commons.lang3.StringUtils; import org.apache.mina.core.session.IoSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; * @author Administrator */ public class SomeServer { - + @Autowired private UserHelperI userHelperI; @Autowired @@ -53,9 +55,12 @@ public class SomeServer { // @Autowired // private NeteaseIM neteaseIM; + @Autowired + private JpushHelperI jpushHelperI; + //是否回复心跳 public static boolean isReplay = true; - + private static Logger log = LoggerFactory.getLogger(SomeServer.class); public static ConcurrentHashMap remoteAddress = new ConcurrentHashMap(); public static ConcurrentHashMap sessions_cz = new ConcurrentHashMap(); @@ -80,6 +85,7 @@ public class SomeServer { } String strSrc = ByteUtil.bytesToHexString(srcByte); //心跳 + if (length >= 28) { sendToApp(session, strSrc, message); } else { @@ -133,19 +139,7 @@ public class SomeServer { scheduleJob.deleteJob(jobGroup); try { //更新设备信息 - deviceHelperI.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); -// log.error("factoryCode or hardwareType not exist:macAddress:{},factoryCode:{},hardwareType:{}",strSrc,ByteUtil.toHex(receive.getVendor()),ByteUtil.toHex(receive.getHardware_type())); -// } -// else{ - //记录登录时间 - LoginRecord loginRecord = new LoginRecord(); - loginRecord.setMacAddress(strSrc); - loginRecord.setLoginTime(new Date()); - deviceHelperI.save(loginRecord); -// } + deviceHelperI.updateDeviceWhenLogin(receive); } catch (Exception e) { log.warn("save device login error:macAddress:{},error msg:{}", strSrc, e.toString()); } @@ -188,7 +182,7 @@ public class SomeServer { String strSrc = ByteUtil.bytesToHexString(macBytes); try { //查找设备 - Tbl_Device device = deviceHelperI.getUniqueByProperty("macAddress", strSrc); + Tbl_Device device = deviceHelperI.getDeviceByMacAddress(strSrc); Tbl_Device_Statistics device_Statistics = null; if (device != null) { //是否升级 @@ -215,7 +209,7 @@ public class SomeServer { String strSrc = ByteUtil.bytesToHexString(macBytes); try { //查找设备 - Tbl_Device device = deviceHelperI.getUniqueByProperty("macAddress", strSrc); + Tbl_Device device = deviceHelperI.getDeviceByMacAddress(strSrc); Tbl_Device_Statistics device_Statistics = null; if (device != null) { //是否升级 @@ -297,8 +291,7 @@ public class SomeServer { */ public void pushNotifcation(String strSrc, String title, String contont) { try { - //Device device = deviceService.getUniqueByProperty("macAddress", strSrc); - Tbl_Device device = deviceHelperI.getUniqueByProperty("macAddress", strSrc); + Tbl_Device device = deviceHelperI.getDeviceByMacAddress(strSrc); Tbl_Device_Statistics device_Statistics = null; if (device != null) { Integer deviceId = device.getDeviceId(); @@ -306,7 +299,7 @@ public class SomeServer { String onOff = device.getOnOff(); if (onOff != null && onOff.equals("1")) { //绑定设备的用户 - List list = deviceHelperI.getListByProperty(device.getDeviceId()); + List list = deviceHelperI.getTbl_Device_UsersListByDeviceId(device.getDeviceId()); for (Tbl_Device_User deviceUser : list) { Integer userId = deviceUser.getUserId(); String showName = deviceUser.getShowName(); @@ -314,18 +307,11 @@ public class SomeServer { String msg = "【" + title + "】你的水族箱“" + showName + "”在" + timestamp + contont; Tbl_User user = userHelperI.findById(userId); if (user != null) { - //云信推送 - boolean neteaseBln = false; //极光推送 - boolean jpushIosBln = false; - boolean jpushAndroidBln = false; - //发送云信消息 -// Map neteaseMap = neteaseIM.sendMsg("ifish", userId.toString(), msg); -// if (neteaseMap != null) { -// neteaseBln = neteaseMap.get("code").equals(NeteaseEnum.status200.getKey()); -// } + boolean result = false; String loginType = user.getLoginType(); - if (loginType != null) { + String registrationID = user.getJiguangUserid(); + if (StringUtils.isNotBlank(loginType) && StringUtils.isNotBlank(registrationID)) { //推送记录 Tbl_Push_List pushList = new Tbl_Push_List(); Map map = new HashMap(); @@ -333,8 +319,14 @@ public class SomeServer { map.put("device_name", showName); map.put("timestamp", timestamp); map.put("msg_type", PushTypeEnum.wendu_warn.getKey()); + + if (loginType.equals("android")) { + result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map); + } else if (loginType.equals("ios")) { + result = jpushHelperI.pushMessageByAndroid(msg, registrationID, map); + } //记录推送 - if (jpushIosBln || jpushAndroidBln || neteaseBln) { + if (result) { pushList.setUserId(userId); pushList.setDeviceId(deviceId); pushList.setPhoneType(loginType.toLowerCase()); @@ -342,7 +334,7 @@ public class SomeServer { pushList.setPushType(PushTypeEnum.wendu_warn.getKey()); pushList.setPushTitle(title); pushList.setPushContext(msg); - pushList.setJpushStatus(neteaseBln ? "1" : "0"); + pushList.setJpushStatus(result ? "1" : "0"); pushList.setCreateTime(new Date()); pushList.setMcuCount(device_Statistics.getMcuCount()); pushList.setModularCount(device_Statistics.getModuleCount()); @@ -354,7 +346,7 @@ public class SomeServer { } } } - + } } } catch (Exception e) { diff --git a/src/main/java/com/ifish/socket/model/send/DeviceLoginContextLength24.java b/src/main/java/com/ifish/socket/model/send/DeviceLoginContextLength24.java index 8adec41..bcaaa03 100644 --- a/src/main/java/com/ifish/socket/model/send/DeviceLoginContextLength24.java +++ b/src/main/java/com/ifish/socket/model/send/DeviceLoginContextLength24.java @@ -17,8 +17,8 @@ import java.io.Serializable; public class DeviceLoginContextLength24 extends HeadModel implements Serializable { private static final long serialVersionUID = 5329299292101065390L; - //厂商 - private byte vendor; + //鱼缸厂商 + private byte factoryCode; //硬件型号 private byte hardware_type; //版本 @@ -26,12 +26,12 @@ public class DeviceLoginContextLength24 extends HeadModel implements Serializabl //登陆IP private byte[] login_ip = new byte[4]; - public byte getVendor() { - return vendor; + public byte getfactoryCode() { + return factoryCode; } - public void setVendor(byte vendor) { - this.vendor = vendor; + public void setfactoryCode(byte factoryCode) { + this.factoryCode = factoryCode; } public byte getHardware_type() { diff --git a/src/main/java/com/ifish/socket/webService/ServiceBean.java b/src/main/java/com/ifish/socket/webService/ServiceBean.java index 47601e6..e779167 100644 --- a/src/main/java/com/ifish/socket/webService/ServiceBean.java +++ b/src/main/java/com/ifish/socket/webService/ServiceBean.java @@ -16,6 +16,6 @@ public class ServiceBean { private static boolean push = false; public ServiceBean() { - Endpoint.publish("http://localhost:9001/Service/webService", new MyService()); + Endpoint.publish("http://localhost:9002/Service/webService", new MyService()); } } diff --git a/src/main/java/com/ifish/util/RedisKey.java b/src/main/java/com/ifish/util/RedisKey.java index 331f03a..3afbc25 100644 --- a/src/main/java/com/ifish/util/RedisKey.java +++ b/src/main/java/com/ifish/util/RedisKey.java @@ -12,67 +12,43 @@ package com.ifish.util; public class RedisKey { /** - * 用户缓存前缀 + * 用户缓存前缀,以id进行存储 */ - public static final String User_Key = "userE:"; + public static final String USER_ID_KEY = "userE:id_"; /** - * 商家信息缓存前缀 + * 设备用户关系缓存前缀,以设备ID和用户ID进行存储 */ - public static final String ShopsInfo_Key = "shopsInfoE:"; + public static final String DEVICE_USER_DEVICEID_AND_USERID = "deviceUserE:"; /** - * 用户绑定设备缓存前缀 + * 设备用户关系缓存前缀(列表),以设备ID进行存储 */ - public static final String DeviceUser_Key = "deviceUserE:"; + public static final String DEVICE_USER_LIST_DEVICEID = "deviceUserlistE:id_"; /** - * 设备绑定摄像头缓存前缀 + * 设备详情缓存前缀,以macAddress进行存储 */ - public static final String DeviceCamera_key = "deviceCameraE:"; + public static final String DEVICE_KEY_MACADDRESS = "deviceE:mac_"; /** - * 设备详情缓存前缀 + * 设备详情缓存前缀,以deviceId进行存储 */ - public static final String Device_key = "deviceE:"; + public static final String DEVICE_KEY_DEVICEID = "deviceE:id_"; + + /** + * 设备统计信息表缓存前缀,以deviceId为前缀 + */ + public static final String DEVICE_STATISTICS_DEVICEID = "devicestatiE:id_"; + + /** + * 设备统计信息表缓存前缀,以mac地址为前缀 + */ + public static final String DEVICE_STATISTICS_MACADDRESS = "devicestatiE:mac_"; /** * 设备类型缓存前缀 */ - public static final String HardWareType_key = "hardwaretypeE:"; + public static final String HARD_WARE_TYPE = "hardwaretypeE:"; - /** - * 厂家列表缓存前缀 - */ - public static final String VenderList_key = "venderlistE:"; - - /** - * 用户和摄像头的绑定关系存前缀 - */ - public static final String CameraUser_key = "cameraUserE:"; - - /** - * 摄像头详情缓存前缀 - */ - public static final String Camera_key = "cameraE:"; - - /** - * 设备统计信息表缓存前缀 - */ - public static final String DeviceStatistic_key = "deviceStaticticsE:"; - - /** - * 直播间详情表缓存前缀 - */ - public static final String LiveRoom_key = "liveroomE:"; - - /** - * 直播间数量缓存前缀 - */ - public static final String LIVEROOM_COUNT_KEY = "liveroomcountE:"; - - /** - * 推送消息缓存前缀 - */ - public static final String PUSHLIST_KEY = "pushlistE:"; } diff --git a/src/main/resources/property.properties b/src/main/resources/property.properties index 8465d57..5f37be1 100644 --- a/src/main/resources/property.properties +++ b/src/main/resources/property.properties @@ -35,11 +35,11 @@ check_style=GIF,PNG,BMP,JPG,JPEG #\u662f\u5426\u5f00\u53d1\u6a21\u5f0f\uff0cfalse\u5219\u4ee3\u8868\u8981\u53d1\u5e03\u5230\u6d4b\u8bd5\u6216\u8005\u6b63\u5f0f\u73af\u5883\uff0c\u4f1a\u8fdb\u884c\u5168\u5c40\u5934\u90e8\u9a8c\u8bc1\uff0ctrue\u4ee3\u8868\u5728\u672c\u5730\u8fdb\u884c\u4ee3\u7801\u7f16\u5199\uff0c\u4e0d\u4f1a\u8fdb\u884c\u9a8c\u8bc1 devModel=true #\u672c\u5730 -#ifiship=192.168.199.129 -ifiship=192.168.2.146 +ifiship=192.168.199.129 +#ifiship=192.168.2.146 #\u6d4b\u8bd5\u4e91 #ifiship=139.196.24.156 #\u6b63\u5f0f\u4e91 #ifiship=120.55.190.56 #\u670d\u52a1\u5668\u7aef\u53e3 -ifishport=9955 \ No newline at end of file +ifishport=9956 \ No newline at end of file