20251225:百度地图
This commit is contained in:
parent
1e70af6110
commit
bec58ecbf2
@ -44,7 +44,7 @@ public class DeviceJobInvoke {
|
|||||||
*/
|
*/
|
||||||
public static void invokeMethod(DeviceJob deviceJob) throws Exception {
|
public static void invokeMethod(DeviceJob deviceJob) throws Exception {
|
||||||
if (deviceJob.getJobType() == 1) {
|
if (deviceJob.getJobType() == 1) {
|
||||||
System.out.println("------------------------执行定时任务-----------------------------");
|
log.info("------------------------1、执行设备定时任务-----------------------------");
|
||||||
List<Action> actions = JSON.parseArray(deviceJob.getActions(), Action.class);
|
List<Action> actions = JSON.parseArray(deviceJob.getActions(), Action.class);
|
||||||
List<ThingsModelSimpleItem> propertys = new ArrayList<>();
|
List<ThingsModelSimpleItem> propertys = new ArrayList<>();
|
||||||
List<ThingsModelSimpleItem> functions = new ArrayList<>();
|
List<ThingsModelSimpleItem> functions = new ArrayList<>();
|
||||||
@ -69,20 +69,20 @@ public class DeviceJobInvoke {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (deviceJob.getJobType() == 3) {
|
} else if (deviceJob.getJobType() == 3) {
|
||||||
System.out.println("------------------[定时执行场景联动]---------------------");
|
log.info("------------------3、[定时执行场景联动]---------------------");
|
||||||
Scene scene = sceneMapper.selectSceneBySceneId(deviceJob.getSceneId());
|
Scene scene = sceneMapper.selectSceneBySceneId(deviceJob.getSceneId());
|
||||||
// 执行场景规则,异步非阻塞
|
// 执行场景规则,异步非阻塞
|
||||||
SceneContext context = new SceneContext("", 0L, 0, null);
|
SceneContext context = new SceneContext("", 0L, 0, null);
|
||||||
String requestId = "scene/" + scene.getChainName();
|
String requestId = "scene/" + scene.getChainName();
|
||||||
flowExecutor.execute2FutureWithRid(scene.getChainName(), null, requestId, context);
|
flowExecutor.execute2FutureWithRid(scene.getChainName(), null, requestId, context);
|
||||||
} else if (4 == deviceJob.getJobType()) {
|
} else if (4 == deviceJob.getJobType()) {
|
||||||
System.out.println("------------------[定时执行场景运算型变量]---------------------");
|
log.info("------------------4、[定时执行场景运算型变量]---------------------");
|
||||||
String s = dataHandler.calculateSceneModelTagValue(deviceJob.getDatasourceId());
|
String s = dataHandler.calculateSceneModelTagValue(deviceJob.getDatasourceId());
|
||||||
if (StringUtils.isEmpty(s)) {
|
if (StringUtils.isEmpty(s)) {
|
||||||
System.out.println("------------------[定时执行场景运算型变量失败:+" + s + "]---------------------");
|
log.info("------------------[定时执行场景运算型变量失败:+{}]---------------------", s);
|
||||||
}
|
}
|
||||||
} else if (5 == deviceJob.getJobType()) {
|
} else if (5 == deviceJob.getJobType()) {
|
||||||
log.info("----------------执行modbus轮训指令----------------------");
|
log.info("----------------5、执行modbus轮训指令----------------------");
|
||||||
ModbusPollJob job = new ModbusPollJob();
|
ModbusPollJob job = new ModbusPollJob();
|
||||||
job.setType(2);
|
job.setType(2);
|
||||||
job.setDeviceJob(deviceJob);
|
job.setDeviceJob(deviceJob);
|
||||||
|
|||||||
@ -65,6 +65,11 @@ public class ModbusJob extends BaseEntity {
|
|||||||
@ApiModelProperty("状态")
|
@ApiModelProperty("状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注释使用方式
|
||||||
|
* {@link com.fastbee.iot.enums.DeviceType}
|
||||||
|
* @see com.fastbee.iot.enums.DeviceType
|
||||||
|
*/
|
||||||
@ApiModelProperty("设备类型")
|
@ApiModelProperty("设备类型")
|
||||||
private Integer deviceType;
|
private Integer deviceType;
|
||||||
|
|
||||||
|
|||||||
@ -1221,7 +1221,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
// 设备编号唯一检查
|
// 设备编号唯一检查
|
||||||
int count = deviceMapper.selectDeviceCountBySerialNumber(serialNumber);
|
int count = deviceMapper.selectDeviceCountBySerialNumber(serialNumber);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
log.error("设备编号:" + serialNumber + "已经存在了,新增设备失败");
|
log.error("设备编号:{}已经存在了,新增设备失败", serialNumber);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Product product = productService.selectProductByProductId(productId);
|
Product product = productService.selectProductByProductId(productId);
|
||||||
@ -1273,7 +1273,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
List<ValueItem> thingsModelValueItems = itslValueCache.getCacheDeviceStatus(device.getProductId(), device.getSerialNumber());
|
List<ValueItem> thingsModelValueItems = itslValueCache.getCacheDeviceStatus(device.getProductId(), device.getSerialNumber());
|
||||||
ThingsModelShadow shadow = new ThingsModelShadow();
|
ThingsModelShadow shadow = new ThingsModelShadow();
|
||||||
// 查询出设置的影子值
|
// 查询出设置的影子值
|
||||||
List<ThingsModelValueItem> shadowList = new ArrayList<>();
|
//List<ThingsModelValueItem> shadowList = new ArrayList<>();
|
||||||
for (ValueItem item : thingsModelValueItems) {
|
for (ValueItem item : thingsModelValueItems) {
|
||||||
if (!item.getShadow().equals(item.getValue()) && !item.getShadow().isEmpty()) {
|
if (!item.getShadow().equals(item.getValue()) && !item.getShadow().isEmpty()) {
|
||||||
//处理id
|
//处理id
|
||||||
@ -1410,17 +1410,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
|
|
||||||
// 如果有上电触发任务,则在Redis中标记,等待第一个数据包
|
// 如果有上电触发任务,则在Redis中标记,等待第一个数据包
|
||||||
// 无论标记是否存在,都重新设置标记,确保恢复任务后能重新触发
|
// 无论标记是否存在,都重新设置标记,确保恢复任务后能重新触发
|
||||||
if (hasPowerOnTrigger) {
|
|
||||||
String serialNumber = device.getSerialNumber().toUpperCase();
|
String serialNumber = device.getSerialNumber().toUpperCase();
|
||||||
String cacheKey = RedisKeyBuilder.buildPowerOnTriggerPendingKey(serialNumber);
|
String cacheKey = RedisKeyBuilder.buildPowerOnTriggerPendingKey(serialNumber);
|
||||||
|
if (hasPowerOnTrigger) {
|
||||||
// 设置过期时间为10分钟,防止长时间未收到数据包导致标记一直存在
|
// 设置过期时间为10分钟,防止长时间未收到数据包导致标记一直存在
|
||||||
// 无论之前是否有标记,都重新设置,确保恢复任务后能重新触发
|
// 无论之前是否有标记,都重新设置,确保恢复任务后能重新触发
|
||||||
redisCache.setCacheObject(cacheKey, "1", 600, TimeUnit.SECONDS);
|
redisCache.setCacheObject(cacheKey, "1", 600, TimeUnit.SECONDS);
|
||||||
log.info("标记设备需要触发上电任务,等待第一个数据包,设备编号:{}", serialNumber);
|
log.info("标记设备需要触发上电任务,等待第一个数据包,设备编号:{}", serialNumber);
|
||||||
} else {
|
} else {
|
||||||
// 如果没有上电触发任务,清除可能存在的旧标记
|
// 如果没有上电触发任务,清除可能存在的旧标记
|
||||||
String serialNumber = device.getSerialNumber().toUpperCase();
|
|
||||||
String cacheKey = RedisKeyBuilder.buildPowerOnTriggerPendingKey(serialNumber);
|
|
||||||
if (redisCache.hasKey(cacheKey)) {
|
if (redisCache.hasKey(cacheKey)) {
|
||||||
redisCache.deleteObject(cacheKey);
|
redisCache.deleteObject(cacheKey);
|
||||||
log.debug("清除设备上电触发任务标记,设备编号:{}", serialNumber);
|
log.debug("清除设备上电触发任务标记,设备编号:{}", serialNumber);
|
||||||
@ -1437,8 +1435,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
*/
|
*/
|
||||||
public void triggerPowerOnTasks(Device device) {
|
public void triggerPowerOnTasks(Device device) {
|
||||||
try {
|
try {
|
||||||
// 延迟1秒执行,确保设备完全上线并准备好接收指令
|
|
||||||
//Thread.sleep(1000);
|
|
||||||
|
|
||||||
// 查询该设备的所有设备上电触发任务
|
// 查询该设备的所有设备上电触发任务
|
||||||
DeviceJob queryJob = new DeviceJob();
|
DeviceJob queryJob = new DeviceJob();
|
||||||
|
|||||||
@ -11,7 +11,7 @@ VUE_APP_BASE_API = '/prod-api'
|
|||||||
VUE_APP_MQTT_SERVER_URL = ''
|
VUE_APP_MQTT_SERVER_URL = ''
|
||||||
|
|
||||||
# 百度地图AK
|
# 百度地图AK
|
||||||
VUE_APP_BAI_DU_AK = 'U6Bxj9AoI4tXY4qeelqWzAjYCFNMkkRT'
|
VUE_APP_BAI_DU_AK = 's9mUXN9a7bKgVu6U6Z3bXhKSxtz97YPI'
|
||||||
|
|
||||||
# 心知天气key
|
# 心知天气key
|
||||||
VUE_APP_XIN_ZHI_KEY = 'PK9uumV_HJhjnpxZy'
|
VUE_APP_XIN_ZHI_KEY = 'PK9uumV_HJhjnpxZy'
|
||||||
|
|||||||
@ -13,7 +13,7 @@ VUE_APP_BASE_API = '/stage-api'
|
|||||||
VUE_APP_MQTT_SERVER_URL = 'ws://localhost:8083/mqtt'
|
VUE_APP_MQTT_SERVER_URL = 'ws://localhost:8083/mqtt'
|
||||||
|
|
||||||
# 百度地图AK
|
# 百度地图AK
|
||||||
VUE_APP_BAI_DU_AK = 'nAtaBg9FYzav6c8P9rF9qzsWZXXXXXX'
|
VUE_APP_BAI_DU_AK = 's9mUXN9a7bKgVu6U6Z3bXhKSxtz97YPI'
|
||||||
|
|
||||||
# 心知天气key
|
# 心知天气key
|
||||||
VUE_APP_XIN_ZHI_KEY = 'SBh45_yy21FU5ErV_'
|
VUE_APP_XIN_ZHI_KEY = 'SBh45_yy21FU5ErV_'
|
||||||
Loading…
Reference in New Issue
Block a user