20260909:优化查询问题
This commit is contained in:
parent
d6377494b4
commit
175a001fe7
@ -254,20 +254,19 @@ public class ToolController extends BaseController {
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.error("发生错误:{}", ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("mqtt钩子处理")
|
||||
@PostMapping("/mqtt/webhookv5")
|
||||
public void webHookProcessv5(@RequestBody JSONObject json) {
|
||||
public void webHookProcessV5(@RequestBody JSONObject json) {
|
||||
try {
|
||||
String clientid = json.getString("clientid");
|
||||
String event = json.getString("event");
|
||||
String peername = json.getString("peername"); // 类似 127.0.0.1:8812
|
||||
String ipAddress = peername;
|
||||
if (peername.indexOf(":") != -1) {
|
||||
if (peername.contains(":")) {
|
||||
ipAddress = peername.substring(0, peername.indexOf(":"));
|
||||
}
|
||||
log.info("webhook:{},clientid:{},peername:{}", event, clientid, peername);
|
||||
@ -310,18 +309,17 @@ public class ToolController extends BaseController {
|
||||
// 影子模式,发布属性和功能
|
||||
if (device.getIsShadow() == 1) {
|
||||
ThingsModelShadow shadow = deviceService.getDeviceShadowThingsModel(device);
|
||||
if (shadow.getProperties().size() > 0) {
|
||||
if (!shadow.getProperties().isEmpty()) {
|
||||
messagePublish.publishProperty(device.getProductId(), device.getSerialNumber(), shadow.getProperties(), 3);
|
||||
}
|
||||
if (shadow.getFunctions().size() > 0) {
|
||||
if (!shadow.getFunctions().isEmpty()) {
|
||||
messagePublish.publishFunction(device.getProductId(), device.getSerialNumber(), shadow.getFunctions(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
log.error("发生错误:" + ex.getMessage());
|
||||
log.error("发生错误:{}", ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ public class DataRepairServiceImpl implements IDataRepairService {
|
||||
public void executeDataRepair(String serialNumber, boolean isShadow, List<DeviceLog> currentLogs) {
|
||||
|
||||
if (CollectionUtils.isEmpty(currentLogs) || isShadow) {
|
||||
log.debug("无数据或为影子模式,不执行数据修复: serialNumber={}, isShadow={}", serialNumber, isShadow);
|
||||
//log.debug("无数据或为影子模式,不执行数据修复: serialNumber={}, isShadow={}", serialNumber, isShadow);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -648,8 +648,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
*/
|
||||
@Override
|
||||
@DSTransactional
|
||||
public List<ThingsModelSimpleItem> reportDeviceThingsModelValue(ThingsModelValuesInput input, int type,
|
||||
boolean isShadow) {
|
||||
public List<ThingsModelSimpleItem> reportDeviceThingsModelValue(ThingsModelValuesInput input, int type, boolean isShadow) {
|
||||
String serialNumber = input.getDeviceNumber();
|
||||
String key = RedisKeyBuilder.buildTSLVCacheKey(input.getProductId(), serialNumber);
|
||||
Map<String, String> maps = new HashMap<>();
|
||||
@ -675,6 +674,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
ThingsModelSimpleItem::getValue,
|
||||
(oldValue, newValue) -> oldValue));
|
||||
}
|
||||
// 查询设备信息
|
||||
Device device = this.selectDeviceBySerialNumber(serialNumber);
|
||||
|
||||
for (ThingsModelSimpleItem item : thingsModelValueRemarkItem) {
|
||||
String identity = item.getId();
|
||||
if (identity.startsWith("array_")) {
|
||||
@ -746,11 +748,9 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
valueItem.setId(identity);
|
||||
if (id.startsWith("array_")) {
|
||||
// 查询是否有缓存,如果没有先进行缓存
|
||||
if (!redisCache.containsKey(key)) {
|
||||
Device device = this.selectDeviceBySerialNumber(serialNumber);
|
||||
this.selectDeviceByDeviceId(device.getDeviceId());
|
||||
}
|
||||
|
||||
// if (!redisCache.containsKey(key)) {
|
||||
// itslValueCache.addCacheDeviceStatus(input.getProductId(), serialNumber);
|
||||
// }
|
||||
int index = Integer.parseInt(id.substring(6, 8));
|
||||
if (isShadow) {
|
||||
String[] shadows = cacheIdentifier.getShadow().split(",");
|
||||
@ -791,7 +791,6 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
|
||||
/* ★★★★★★★★★★★★★★★★★★★★★★ 存储数据 - 开始 ★★★★★★★★★★★★★★★★★★★★★★ */
|
||||
ThingsModelType modelType = ThingsModelType.getType(thingModels.getType());
|
||||
Device device = this.selectDeviceBySerialNumber(serialNumber);
|
||||
switch (modelType) {
|
||||
case PROP:
|
||||
if (1 == thingModels.getIsHistory()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user