20260329:网关计算物模型无法找到对应设备bug修复(模板改回来)
This commit is contained in:
parent
3f3d14f492
commit
60cb958daa
@ -57,6 +57,7 @@ public class RedisKeyBuilder {
|
||||
/**
|
||||
* 物模型缓存key(产品级)
|
||||
* 物模型命名空间:Key:TSL:{productId} hkey: identity value: thingsModel
|
||||
* TSL:222
|
||||
*/
|
||||
public static String buildTSLCacheKey(Long productId) {
|
||||
return FastBeeConstant.REDIS.TSL_PRE_KEY + productId;
|
||||
@ -65,6 +66,7 @@ public class RedisKeyBuilder {
|
||||
/**
|
||||
* 设备级计算物模型缓存key
|
||||
* 物模型命名空间:Key:TSLD:{SerialNumber} hkey: identity value: thingsModel
|
||||
* TSLD:D199Y030XTSQ
|
||||
*/
|
||||
public static String buildDeviceTSLCacheKey(String serialNumber) {
|
||||
return FastBeeConstant.REDIS.TSLD_PRE_KEY + serialNumber;
|
||||
|
||||
@ -206,12 +206,12 @@ public class ThingsModelPushHandler {
|
||||
List<String> varNames = extractVarNames(msgParams.getContent());
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
String deviceDisplay = StringUtils.isNotEmpty(config.getDeviceName())
|
||||
? config.getDeviceName() : serialNumber;
|
||||
// String deviceDisplay = StringUtils.isNotEmpty(config.getDeviceName())
|
||||
// ? config.getDeviceName() : serialNumber;
|
||||
for (int i = 0; i < varNames.size(); i++) {
|
||||
String varName = varNames.get(i);
|
||||
if (i == 0) {
|
||||
map.put(varName, deviceDisplay);
|
||||
map.put(varName, serialNumber);
|
||||
} else if (i == 1) {
|
||||
map.put(varName, level.getLabel());
|
||||
} else if (i == 2) {
|
||||
|
||||
@ -36,6 +36,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
@ -107,7 +108,8 @@ public class ModbusProtocol implements IProtocol {
|
||||
//起始地址
|
||||
String address0304 = getCacheModbusAddress(productId, slaveId, code);
|
||||
//读输入、保持寄存器
|
||||
handleRead0304(deviceData.getSerialNumber(), productId, message, address0304, values, hexDump);
|
||||
String sn = StringUtils.isEmpty(serialNumber) ? deviceData.getSerialNumber() : serialNumber;
|
||||
handleRead0304(sn, productId, message, address0304, values, hexDump);
|
||||
break;
|
||||
case Write06:
|
||||
case Write05:
|
||||
@ -186,7 +188,7 @@ public class ModbusProtocol implements IProtocol {
|
||||
/**
|
||||
* 处理读保持寄存器/输入寄存器
|
||||
*
|
||||
* @param serialNumber 设备序列号
|
||||
* @param serialNumber 设备序列号(如果是网关设备会找到自身的子设备ID)
|
||||
* @param productId 产品id
|
||||
* @param message 数据
|
||||
* @param address 起始地址
|
||||
@ -330,13 +332,14 @@ public class ModbusProtocol implements IProtocol {
|
||||
Map<String, ThingsModelValueItem> calculatedModelMap = itslCache.getDeviceCalculatedModelMap(serialNumber);
|
||||
|
||||
// 构造 ThingsModelSimpleItem,值为 "0"
|
||||
Date nowDate = DateUtils.getNowDate(); // 统一当前时间
|
||||
for (Map.Entry<String, ThingsModelValueItem> entry : calculatedModelMap.entrySet()) {
|
||||
String identifier = entry.getKey();
|
||||
|
||||
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
|
||||
simpleItem.setId(identifier);
|
||||
simpleItem.setValue("0"); // 初始值设为0,后续在计算环节会重新计算
|
||||
simpleItem.setTs(DateUtils.getNowDate());
|
||||
simpleItem.setTs(nowDate);
|
||||
simpleItem.setCalculated(true);
|
||||
simpleItemList.add(simpleItem);
|
||||
log.debug("=>添加纯计算物模型到上报列表,设备:[{}],标识符:[{}]", serialNumber, identifier);
|
||||
|
||||
@ -1639,7 +1639,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
ILocationService service = locationServiceFactory.getLocationService();
|
||||
|
||||
// Modbus设备采用LBS定位(从设备获取经纬度)
|
||||
if (Objects.equals(1, device.getLocationWay()) && FastBeeConstant.PROTOCOL.ModbusRtu.equals(device.getTransport())) {
|
||||
if (/*Objects.equals(1, device.getLocationWay()) && */FastBeeConstant.PROTOCOL.ModbusRtu.equals(device.getTransport())) {
|
||||
log.info("Modbus设备采用LBS定位{}", device.getSerialNumber());
|
||||
// 将经纬度转换为地址编码 networkAddress
|
||||
if (StringUtils.isEmpty(device.getNetworkAddress()) && device.getLongitude() != null && device.getLatitude() != null) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user