作者 钟来

修改告警bug

正在显示 27 个修改的文件 包含 163 行增加39 行删除
... ... @@ -24,7 +24,7 @@ public class DeviceTask {
public void terminalOnline()
{
int time = DateUtils.getNowTimeMilly()-6*60;
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT id FROM `iot_terminal` a LEFT JOIN `iot_device` b ON a.`device_id`=b.`client_id` WHERE "+time+"-a.`data_update_time`>=b.`device_life` AND online=3");
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT id FROM `iot_terminal` a LEFT JOIN `iot_device` b ON a.`device_id`=b.`client_id` WHERE "+time+"-a.`data_update_time`>=(b.`device_life`+15) AND online=3");
StringBuffer stringBuffer = new StringBuffer();
Optional.ofNullable(list).orElse(new ArrayList<>()).forEach(stringObjectMap -> {
... ... @@ -49,7 +49,7 @@ public class DeviceTask {
public void deviceOnline()
{
int time = DateUtils.getNowTimeMilly();
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT client_id FROM `iot_device` WHERE "+time+"-data_update_time>=device_life AND status=3");
List<Map<String,Object>> list = publicService.getObjectListBySQL("SELECT client_id FROM `iot_device` WHERE "+time+"-data_update_time>=(device_life+15) AND status=3");
StringBuffer stringBuffer = new StringBuffer();
Optional.ofNullable(list).orElse(new ArrayList<>()).forEach(stringObjectMap -> {
... ...
... ... @@ -14,4 +14,6 @@ public interface ThingsModelBase<T> {
String getSaveView();
Object getCmdView(Object value);
boolean checkValue();
void setSaveView(String value);
}
... ...
... ... @@ -59,6 +59,44 @@ public abstract class ThingsModelItemBase<T> implements ThingsModelBase<T>
return null;
}
public static ThingsModelItemBase newhingsModelItemFromControl(ThingsModelDataTypeEnum thingsModelDataTypeEnum,IotThingsModel thingsModel,JsonElement jsonElement)
{
if (!jsonElement.isJsonNull())
{
String specs = thingsModel.getSpecs();
if(StringUtils.isEmpty(specs))
{
specs = new JsonObject().toString();
}
ThingsModelItemBase thingsModelItemBase = GsonConstructor.get().fromJson(specs,StringModelOutput.class);
switch (thingsModelDataTypeEnum)
{
case STRING:
thingsModelItemBase.setSaveView(jsonElement.getAsString());
break;
case BOOL:
thingsModelItemBase = GsonConstructor.get().fromJson(specs,BoolModelOutput.class);
break;
case ENUM:
thingsModelItemBase = GsonConstructor.get().fromJson(specs,EnumModelOutput.class);
break;
case ARRAY:
thingsModelItemBase = GsonConstructor.get().fromJson(specs,ArrayModelOutput.class);
break;
case DECIMAL:
thingsModelItemBase = GsonConstructor.get().fromJson(specs,DecimalModelOutput.class);
break;
case INTEGER:
thingsModelItemBase = GsonConstructor.get().fromJson(specs,IntegerModelOutput.class);
break;
}
thingsModelItemBase.setSaveView(jsonElement.getAsString());
thingsModelItemBase.conversionThingsModel(thingsModel);
return thingsModelItemBase;
}
return null;
}
public static ThingsModelItemBase newhingsModelItem(JsonObject jsonObject)
{
... ...
... ... @@ -7,6 +7,8 @@ import com.google.gson.JsonElement;
import com.zhonglai.luhui.device.analysis.comm.dto.thingsmodels.ThingsModelItemBase;
import lombok.Data;
import java.util.ArrayList;
@Data
public class ArrayModelOutput extends ThingsModelItemBase<JsonArray>
{
... ... @@ -41,4 +43,9 @@ public class ArrayModelOutput extends ThingsModelItemBase<JsonArray>
public boolean checkValue() {
return true;
}
@Override
public void setSaveView(String value) {
setValue(JSONArray.parseObject(value, JsonArray.class));
}
}
... ...
... ... @@ -43,4 +43,9 @@ public class BoolModelOutput extends ThingsModelItemBase<Boolean>
public boolean checkValue() {
return true;
}
@Override
public void setSaveView(String value) {
setValue(value.equals("1") || Boolean.parseBoolean(value) );
}
}
... ...
... ... @@ -54,4 +54,9 @@ public class DecimalModelOutput extends ThingsModelItemBase<BigDecimal>
}
return false;
}
@Override
public void setSaveView(String value) {
setValue(new BigDecimal(value));
}
}
... ...
... ... @@ -64,6 +64,11 @@ public class EnumModelOutput extends ThingsModelItemBase<String>
return true;
}
@Override
public void setSaveView(String value) {
setValue(value);
}
private static Object conversion(Object data ,String clas) {
try {
return stringToTarget(String.valueOf(data),Class.forName(clas));
... ...
... ... @@ -71,4 +71,10 @@ public class IntegerModelOutput extends ThingsModelItemBase<Integer>
}
return false;
}
@Override
public void setSaveView(String value) {
BigDecimal bigDecimal = new BigDecimal(value);
setValue(bigDecimal.multiply(new BigDecimal(acy)).intValue());
}
}
... ...
... ... @@ -35,4 +35,9 @@ public class StringModelOutput extends ThingsModelItemBase<String>
}
return false;
}
@Override
public void setSaveView(String value) {
setValue(value);
}
}
... ...
... ... @@ -128,8 +128,8 @@ public class IotDeviceController extends BaseController
@ApiImplicitParam(value = "标签(多个英文逗号分割)",name = "label"),
@ApiImplicitParam(value = "设备主键",name = "client_id")
})
@PreAuthorize("@ss.hasPermi('iot:IotDevice:add')")
@Log(title = "主机/网关", businessType = BusinessType.INSERT)
@PreAuthorize("@ss.hasPermi('iot:IotDevice:tagging')")
@Log(title = "主机/网关", businessType = BusinessType.UPDATE)
@PostMapping("tagging/{client_id}")
public AjaxResult tagging(@PathVariable String client_id, String label)
{
... ...
# 项目相关配置 jhlt: # 名称 name: zhonglai # 版本 version: 3.8.2 # 版权年份 copyrightYear: 2022 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 accept-count: 1000 threads: # tomcat最大线程数,默认为200 max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # redis 配置 redis: # 地址 host: 47.112.163.61 # 端口,默认为6379 port: 9527 # 数据库索引 database: 1 # 密码 password: Luhui586 # 连接超时时间 timeout: 10s lettuce: pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # token配置 token: # 令牌自定义标识 header: Authorization # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 1440 rediskey: lh-admin # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain,com.zhonglai.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* mqtt: client: device_life: 180 sys: ## // 对于登录login 注册register 验证码captchaImage 允许匿名访问 antMatchers: /login,/register,/captchaImage,/getCacheObject,/v2/api-docs,/tool/gen/generatorCodeFromDb,/data/** # NameServer地址 rocketmq: name-server: 47.115.144.179:9876 # 默认的消息组 producer: group: deviceCommand send-message-timeout: 30000 send-topic: lh-mqtt-service-deviceCommand-test send-tags: 1
\ No newline at end of file
# 项目相关配置 jhlt: # 名称 name: zhonglai # 版本 version: 3.8.2 # 版权年份 copyrightYear: 2022 # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数组计算 char 字符验证 captchaType: math # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 port: 8080 servlet: # 应用的访问路径 context-path: / tomcat: # tomcat的URI编码 uri-encoding: UTF-8 # 连接数满后的排队数,默认为100 accept-count: 1000 threads: # tomcat最大线程数,默认为200 max: 800 # Tomcat启动初始化的线程数,默认值10 min-spare: 100 # 日志配置 logging: level: com.ruoyi: debug org.springframework: warn com.zhonglai.luhui: debug # Spring配置 spring: # 资源信息 messages: # 国际化资源文件路径 basename: i18n/messages profiles: active: druid # 文件上传 servlet: multipart: # 单个文件大小 max-file-size: 10MB # 设置总上传的文件大小 max-request-size: 20MB # 服务模块 devtools: restart: # 热部署开关 enabled: true # redis 配置 redis: # 地址 host: 47.112.163.61 # 端口,默认为6379 port: 9527 # 数据库索引 database: 1 # 密码 password: Luhui586 # 连接超时时间 timeout: 10s lettuce: pool: # 连接池中的最小空闲连接 min-idle: 0 # 连接池中的最大空闲连接 max-idle: 8 # 连接池的最大数据库连接数 max-active: 8 # #连接池最大阻塞等待时间(使用负值表示没有限制) max-wait: -1ms # token配置 token: # 令牌自定义标识 header: Authorization # 令牌密钥 secret: abcdefghijklmnopqrstuvwxyz # 令牌有效期(默认30分钟) expireTime: 1440 rediskey: lh-admin # MyBatis配置 mybatis: # 搜索指定包别名 typeAliasesPackage: com.ruoyi.**.domain,com.zhonglai.**.domain # 配置mapper的扫描,找到所有的mapper.xml映射文件 mapperLocations: classpath*:mapper/**/*Mapper.xml # 加载全局的配置文件 configLocation: classpath:mybatis/mybatis-config.xml # PageHelper分页插件 pagehelper: helperDialect: mysql supportMethodsArguments: true params: count=countSql # Swagger配置 swagger: # 是否开启swagger enabled: true # 请求前缀 pathMapping: /dev-api # 防止XSS攻击 xss: # 过滤开关 enabled: true # 排除链接(多个用逗号分隔) excludes: /system/notice # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/* mqtt: client: device_life: 180 sys: ## // 对于登录login 注册register 验证码captchaImage 允许匿名访问 antMatchers: /login,/register,/captchaImage,/getCacheObject,/v2/api-docs,/tool/gen/generatorCodeFromDb,/data/** # NameServer地址 rocketmq: name-server: 47.115.144.179:9876 # 默认的消息组 producer: group: deviceCommand send-message-timeout: 30000 send-topic: lh-mqtt-service-deviceCommand-test send-tags: 1
\ No newline at end of file
... ...
... ... @@ -14,10 +14,10 @@ public class LhAlarmMain {
CachAlarmConfig.loadConfig();
//启动触发告警服务
TriggerAlarmService.start();
// TriggerAlarmService.start();
//启动定时任务告警
TimerAlarmService.start();
// TimerAlarmService.start();
//启动告警定时发送
SendAlarmService.start();
... ...
... ... @@ -43,6 +43,22 @@ public class IotDeviceAlarm extends UpAlarmFactory<IotDevice> implements Seriali
//通过变更的数据获得对应的告警规则
valueUp(beforeupAlarmDb.getClient_id(),CachAlarmConfig.getDeviceProduct(beforeupAlarmDb.getClient_id()),beforeupAlarmDb.getThings_model_value(),afterupAlarmDb.getThings_model_value(),null,"主机"+afterupAlarmDb.getClient_id());
//在线状态
if(null != afterupAlarmDb.getStatus() && null != beforeupAlarmDb.getStatus() && beforeupAlarmDb.getStatus()-afterupAlarmDb.getStatus()!=0)
{
switch (afterupAlarmDb.getStatus())
{
case 3:
// IotAlertLog iotAlertLog = new IotAlertLog(2l,"在线",2,2,afterupAlarmDb.getClient_id(),System.currentTimeMillis(),1,CachAlarmConfig.getDeviceUser(afterupAlarmDb.getClient_id()) ,"主机"+afterupAlarmDb.getClient_id(),1);
// list.add(iotAlertLog);
break;
case 4:
IotAlertLog iotAlertLog = new IotAlertLog(1l,"离线",1,2,afterupAlarmDb.getClient_id(),System.currentTimeMillis(),1,CachAlarmConfig.getDeviceUser(afterupAlarmDb.getClient_id()) ,"主机"+afterupAlarmDb.getClient_id(),1);
list.add(iotAlertLog);
break;
}
}
}
Object getNowValue(Object model_name,Integer type) {
if(null != afterupAlarmDb )
... ...
... ... @@ -2,6 +2,7 @@ package com.zhonglai.luhui.alarm.clas;
import com.alibaba.fastjson.JSONObject;
import com.zhonglai.luhui.alarm.config.CachAlarmConfig;
import com.zhonglai.luhui.alarm.dto.IotAlertLog;
import com.zhonglai.luhui.alarm.dto.IotDevice;
import com.zhonglai.luhui.alarm.dto.IotTerminal;
import com.zhonglai.luhui.service.dao.util.StringUtils;
... ... @@ -40,6 +41,21 @@ public class IotTerminalAlarm extends UpAlarmFactory<IotTerminal> implements Ser
//通过变更的数据获得对应的告警规则
valueUp(beforeupAlarmDb.getId(), CachAlarmConfig.getDeviceProduct(beforeupAlarmDb.getId()),beforeupAlarmDb.getThings_model_value(),afterupAlarmDb.getThings_model_value(),beforeupAlarmDb.getUser_info_id(),null==beforeupAlarmDb.getName()?beforeupAlarmDb.getId():beforeupAlarmDb.getName());
//在线状态
if(null != afterupAlarmDb.getOnline() && null != beforeupAlarmDb.getOnline() && beforeupAlarmDb.getOnline()-afterupAlarmDb.getOnline()!=0)
{
switch (afterupAlarmDb.getOnline())
{
case 3:
// IotAlertLog iotAlertLog = new IotAlertLog(2l,"在线",2,2,afterupAlarmDb.getId(),System.currentTimeMillis(),1,CachAlarmConfig.getDeviceUser(afterupAlarmDb.getId()) ,afterupAlarmDb.getName(),1);
// list.add(iotAlertLog);
break;
case 4:
IotAlertLog iotAlertLog = new IotAlertLog(1l,"离线",1,2,afterupAlarmDb.getId(),System.currentTimeMillis(),1,CachAlarmConfig.getDeviceUser(afterupAlarmDb.getId()) ,afterupAlarmDb.getName(),1);
list.add(iotAlertLog);
break;
}
}
}
@Override
... ...
... ... @@ -107,6 +107,10 @@ public abstract class UpAlarmFactory<T> {
{
nv = newjson.get(key);
ov = oldjson.get(key);
}catch (NullPointerException exception)
{
logger.error("告警属性解析时异常",exception);
continue;
}
if(!nv.equals(ov)) //新老不一致,触发告警
... ...
... ... @@ -424,7 +424,7 @@ public class CachAlarmConfig {
public static List<UserAlarmNoticeConfig> getUserAlarmNoticeConfig(Integer user_id,Integer getAlert_config_type,Long alert_id)
{
IotAlertUserNotice iotAlertUserNotice = user_alarm_config.get(user_id+"|"+getAlert_config_type);
if(null != iotAlertUserNotice && "*".equals(iotAlertUserNotice.getAlert_ids()) || (","+iotAlertUserNotice.getAlert_ids()+",").indexOf(","+alert_id+",")>=0) //*或者包含
if(null != iotAlertUserNotice && ("*".equals(iotAlertUserNotice.getAlert_ids()) || (","+iotAlertUserNotice.getAlert_ids()+",").indexOf(","+alert_id+",")>=0)) //*或者包含
{
return channelIdsToUserAlarmNoticeConfig(iotAlertUserNotice.getChannels());
}
... ...
... ... @@ -52,7 +52,9 @@ public class DbOperateUtil {
public static List<IotAlertLog> getIotAlertLogList(Integer status,Integer limit)
{
List<IotAlertLog> list = baseDao.findBysql("select * from iot_alert_log where `status`=? limit ?",IotAlertLog.class,status,limit);
List<IotAlertLog> list = baseDao.findBysql("select * from iot_alert_log where alert_log_id=11408",IotAlertLog.class);
// List<IotAlertLog> list = baseDao.findBysql("select * from iot_alert_log where `status`=? limit ?",IotAlertLog.class,status,limit);
return list;
}
... ...
... ... @@ -15,6 +15,15 @@ public class IotDevice {
/** 物模型值 */
private String things_model_value;
private Integer product_id;
private Integer status;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getProduct_id() {
return product_id;
... ... @@ -70,6 +79,9 @@ public class IotDevice {
case "product_id":
iotDevice.setProduct_id ( null!=column.getValue()&&!"".equals(column.getValue())?Integer.parseInt(column.getValue()):null);
break;
case "status":
iotDevice.setStatus ( null!=column.getValue()&&!"".equals(column.getValue())?Integer.parseInt(column.getValue()):null);
break;
}
}
if(null == iotDevice.getSummary() || null == iotDevice.getThings_model_value() || null == iotDevice.getClient_id() )
... ...
... ... @@ -25,6 +25,15 @@ public class IotTerminal {
private Integer user_info_id;
private String name;
private Integer online;
public Integer getOnline() {
return online;
}
public void setOnline(Integer online) {
this.online = online;
}
public String getName() {
return name;
... ... @@ -113,6 +122,9 @@ public class IotTerminal {
case "name":
iotTerminal.setName(column.getValue());
break;
case "online":
iotTerminal.setOnline ( null!=column.getValue()&&!"".equals(column.getValue())?Integer.parseInt(column.getValue()):null);
break;
}
}
if(null == iotTerminal.getThings_model_value() || null == iotTerminal.getThings_model_config() || null == iotTerminal.getId())
... ...
... ... @@ -113,13 +113,14 @@ public class WeiXinMessage {
public static String getWechatServerToken(String appid, String secret) {
Token token = tokenMap.get(appid);
int time =new Long(System.currentTimeMillis()).intValue();
int time =new Long(System.currentTimeMillis()/1000).intValue();
if(null != token && token.getExpires_in()-time>0)
{
return token.getAccess_token();
}
token = TokenAPI.token(appid,secret);
token.setExpires_in(time+token.getExpires_in()-600); //提前10分钟
tokenMap.put(appid,token);
return token.getAccess_token();
}
}
... ...
... ... @@ -29,7 +29,7 @@ public class TriggerAlarmService {
// 创建Canal连接器
private static CanalConnector connector = CanalConnectors.newSingleConnector(
new InetSocketAddress("127.0.0.1", 11111),
new InetSocketAddress("8.129.82.37", 11111),
"example",
"",
""
... ...
... ... @@ -76,10 +76,10 @@ public class UserInfoController extends BaseController {
//更新用户通知
IotAlertUserNotice iotAlertUserNotice = new IotAlertUserNotice();
iotAlertUserNotice.setUser_id(user_id);
ct = publicService.getObjectListTotle(userOpenid,null);
ct = publicService.getObjectListTotle(iotAlertUserNotice,null);
if(0 < ct)
{
return AjaxResult.success("您已经开通过通知服务了,请到通知服务编辑页面进行编辑");
return AjaxResult.error("您已经开通过通知服务了,请到通知服务编辑页面进行编辑");
}
IotAlertUserNotice sysIotAlertUserNotice = new IotAlertUserNotice();
... ...
package com.zhonglai.luhui.device.protocol.factory.config;
import com.zhonglai.luhui.device.analysis.comm.dao.BaseDao;
import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceHostDto;
import com.zhonglai.luhui.device.protocol.factory.dto.ParserDeviceInfoDto;
import com.zhonglai.luhui.device.protocol.factory.service.impl.DefaultDbService;
import net.jodah.expiringmap.ExpirationListener;
import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
... ... @@ -24,21 +26,17 @@ public class DeviceCach {
// 清零过期时间也就是重置过期时间,重新计算过期时间.
private static ExpiringMap<String, ParserDeviceInfoDto> parserDeviceInfoDtoMap = ExpiringMap.builder().maxSize(20000).expiration(60, TimeUnit.SECONDS)
.variableExpiration()
.asyncExpirationListener(new ExpirationListener<String, ParserDeviceInfoDto>() {
@Override
public void expired(String s, ParserDeviceInfoDto parserDeviceInfoDto) {
log.info("超时清除>>>>>>>:{} ",s);
}
.asyncExpirationListener((ExpirationListener<String, ParserDeviceInfoDto>) (s, parserDeviceInfoDto) -> {
log.info("超时清除>>>>>>>:{} ",s);
DefaultDbService.baseDao.updateBySql("update iot_terminal set online=4 where id='"+s+"'");
})
.expirationPolicy(ExpirationPolicy.ACCESSED).build();
private static ExpiringMap<String, ParserDeviceHostDto> parserDeviceHostDtoMap = ExpiringMap.builder().maxSize(20000).expiration(60, TimeUnit.SECONDS)
.variableExpiration()
.asyncExpirationListener(new ExpirationListener<String, ParserDeviceHostDto>() {
@Override
public void expired(String s, ParserDeviceHostDto parserDeviceHostDto) {
log.info("超时清除>>>>>>>:{} ",s);
}
.asyncExpirationListener((ExpirationListener<String, ParserDeviceHostDto>) (s, parserDeviceHostDto) -> {
log.info("超时清除>>>>>>>:{} ",s);
DefaultDbService.baseDao.updateBySql("update iot_device set status=4 where client_id='"+s+"'");
})
.expirationPolicy(ExpirationPolicy.ACCESSED).build();
... ... @@ -48,7 +46,7 @@ public class DeviceCach {
{
parserDeviceInfoDtoMap.put(parserDeviceInfoDto.getId(),parserDeviceInfoDto);
}else{
parserDeviceInfoDtoMap.put(parserDeviceInfoDto.getId(),parserDeviceInfoDto,device_life*3,TimeUnit.SECONDS);
parserDeviceInfoDtoMap.put(parserDeviceInfoDto.getId(),parserDeviceInfoDto,device_life+15,TimeUnit.SECONDS);
}
}
... ... @@ -58,7 +56,7 @@ public class DeviceCach {
{
parserDeviceHostDtoMap.put(parserDeviceHostDto.getId(),parserDeviceHostDto);
}else {
parserDeviceHostDtoMap.put(parserDeviceHostDto.getId(),parserDeviceHostDto,device_life*3,TimeUnit.SECONDS);
parserDeviceHostDtoMap.put(parserDeviceHostDto.getId(),parserDeviceHostDto,device_life+15,TimeUnit.SECONDS);
}
}
public static void cleanDeviceHost(String deviceId)
... ...
... ... @@ -93,7 +93,7 @@ public class MqttSubscribeService {
sts[i++] = s;
}
mqttclient.subscribe(sts);
log.info("-----------topic【{}】订阅成功--------------------",sts);
log.info("-----------topic【{}】订阅成功--------------------",ts);
if (!"1".equals(System.getProperty("RunInIDEA"))) //如果是本地环境不需要跟新服务器地址
{
... ...
... ... @@ -29,7 +29,7 @@ import java.util.Map;
public class DefaultDbService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private BaseDao baseDao = new BaseDao();
public static BaseDao baseDao = new BaseDao();
@Autowired
private DeviceCommandListenService deviceCommandListenService;
... ...
... ... @@ -133,21 +133,11 @@ public class MqttDeviceService extends DeviceService{
thingsModel.setSpecs(spes.toString());
}
String data_type = thingsModel.getData_type().toUpperCase();
// Class<ThingsModelBase> aClass = Enum.valueOf(ThingsModelDataTypeEnum.class,data_type).getaClass();
// ThingsModelBase thingsModelBase = JSON.parseObject(thingsModel.getSpecs(),aClass);
// thingsModelBase.conversionThingsModel(thingsModel);
Object object = jsonObject.get(skey);
// Type clas = ((ParameterizedType)aClass.getGenericSuperclass()).getActualTypeArguments()[0];
// if(null != object && object.getClass()!=clas)
// {
// return new Message(MessageCode.DEFAULT_FAIL_CODE,skey+" 参数数据类型和模型数据类型("+clas+")不一致");
// }
// ThingsModelItemBase thingsModelItemBase = (ThingsModelItemBase) thingsModelBase;
ThingsModelItemBase thingsModelItemBase = ThingsModelItemBase.newhingsModelItem(Enum.valueOf(ThingsModelDataTypeEnum.class,data_type),thingsModel,gsonobject.get(skey));
ThingsModelItemBase thingsModelItemBase = ThingsModelItemBase.newhingsModelItemFromControl(Enum.valueOf(ThingsModelDataTypeEnum.class,data_type),thingsModel,gsonobject.get(skey));
jsonObject.put(skey,thingsModelItemBase.getCmdView(object));
// thingsModelItemBase.setValue(thingsModelItemBase.getCmdView(object));
String id = clienid+"_"+key;
logDeviceOperationList.add(dviceLogService.newLogDeviceOperation(id,thingsModelItemBase.getSaveView(),null,"远程控制"+thingsModelItemBase.getName()+"为"+thingsModelItemBase.getView(),null));
... ...
... ... @@ -49,7 +49,7 @@ mqtt:
mqtt_usernames: 6_WP
#订阅的topic
topics: ADD_POST,ALL_POST,DB_TOPIC_DISTRIBUTE,GET/+,online,PUT_REQ/+,READ_REQ/+
sub_clientid: '863482065281251'
sub_clientid: '+'
topicconfig: "/{{roleid}}/{{username}}/{{clientid}}/{{payloadtype}}/{{topicType}}/{{messageid}}"
top_return_map: '{"PUT":"PUT_REQ","READ":"READ_REQ"}'
username: sysuser
... ...