20260627:接入深度位移计
This commit is contained in:
parent
1846f4e717
commit
4e467edb2b
@ -16,6 +16,12 @@ MODBUS_DATA_HEX = (
|
|||||||
"05031c41bd1c1941810000402bb38600000000bf4501bdc027dfcac2ae88538AEC"
|
"05031c41bd1c1941810000402bb38600000000bf4501bdc027dfcac2ae88538AEC"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 深部位移计
|
||||||
|
# "7e80DD33D43DFC5B7e",
|
||||||
|
# "0103204135317841ab8e39bf27bccd3f1fb19ac2b231bbc0b6f82040ae3207c3f9f80efa23",
|
||||||
|
# "020320413b9fa441acd34dc0024a003fa2a59ac2af34a0c18e17ea413167dbc3f9c7fe6d40",
|
||||||
|
# "0303204139565641ab21ddbff6af333fe26800c2aec626c18685244176ee82c3f9bd7568c8",
|
||||||
|
# "040320413a0d3e41a534d3bf461ccd403d7e00c2ade1e4c0d819c441ce9ca7c3f9a4d260bf"
|
||||||
# 01 03 1c 4268 442f 41d3 0000 418b 6685 0000 0000 4026 f4ca c00d 1fd3 c2ad 2a9d 6311
|
# 01 03 1c 4268 442f 41d3 0000 418b 6685 0000 0000 4026 f4ca c00d 1fd3 c2ad 2a9d 6311
|
||||||
# 从机地址 功能码 字节长度 2个字节 CRC校验
|
# 从机地址 功能码 字节长度 2个字节 CRC校验
|
||||||
|
|
||||||
|
|||||||
@ -71,15 +71,6 @@ public class DcpPlatformAdapter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IPlatformDeviceSubMappingService subMappingService;
|
private IPlatformDeviceSubMappingService subMappingService;
|
||||||
|
|
||||||
/** 传感器类型 → 推送接口路径 */
|
|
||||||
private static final Map<String, String> PUSH_PATH = new HashMap<>();
|
|
||||||
static {
|
|
||||||
PUSH_PATH.put("inclino", "/api/app/inclino-data/many");
|
|
||||||
PUSH_PATH.put("stress", "/api/app/stress-data/many");
|
|
||||||
PUSH_PATH.put("hyeto", "/api/app/hyeto-data/many");
|
|
||||||
PUSH_PATH.put("static_level", "/api/app/static-level-data/many");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送设备上报数据到 DCP(直连设备)
|
* 推送设备上报数据到 DCP(直连设备)
|
||||||
*/
|
*/
|
||||||
@ -93,13 +84,9 @@ public class DcpPlatformAdapter {
|
|||||||
PlatformInterface pushInterface = loadPushInterface(mapping);
|
PlatformInterface pushInterface = loadPushInterface(mapping);
|
||||||
JSONArray requestSchema = loadRequestSchema(pushInterface);
|
JSONArray requestSchema = loadRequestSchema(pushInterface);
|
||||||
String interfaceCode = resolveInterfaceCode(sensorType, pushInterface);
|
String interfaceCode = resolveInterfaceCode(sensorType, pushInterface);
|
||||||
String pushPath = resolvePushPath(sensorType, pushInterface);
|
|
||||||
if (pushPath == null) {
|
|
||||||
log.warn("[DCP] 未知传感器类型: {}", sensorType);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String pushPath = resolvePushPath(mapping, pushInterface);
|
||||||
handleNormalPush(
|
handleNormalPush(
|
||||||
platform, mapping, reportSerialNumber, payload, pushPath,
|
platform, mapping, reportSerialNumber, payload, pushPath,
|
||||||
interfaceCode, requestSchema);
|
interfaceCode, requestSchema);
|
||||||
@ -131,13 +118,9 @@ public class DcpPlatformAdapter {
|
|||||||
PlatformInterface pushInterface = loadPushInterface(mapping);
|
PlatformInterface pushInterface = loadPushInterface(mapping);
|
||||||
JSONArray requestSchema = loadRequestSchema(pushInterface);
|
JSONArray requestSchema = loadRequestSchema(pushInterface);
|
||||||
String interfaceCode = resolveInterfaceCode(sensorType, pushInterface);
|
String interfaceCode = resolveInterfaceCode(sensorType, pushInterface);
|
||||||
String pushPath = resolvePushPath(sensorType, pushInterface);
|
|
||||||
if (pushPath == null) {
|
|
||||||
log.warn("[DCP] 未知传感器类型: {}", sensorType);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String pushPath = resolvePushPath(mapping, pushInterface);
|
||||||
JSONObject reportData = parsePayloadToMap(payload);
|
JSONObject reportData = parsePayloadToMap(payload);
|
||||||
if (reportData == null || reportData.isEmpty()) {
|
if (reportData == null || reportData.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -702,11 +685,14 @@ public class DcpPlatformAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolvePushPath(String sensorType, PlatformInterface pushInterface) {
|
private String resolvePushPath(PlatformDeviceMapping mapping, PlatformInterface pushInterface) {
|
||||||
if (pushInterface != null && StringUtils.hasText(pushInterface.getPath())) {
|
if (pushInterface != null && StringUtils.hasText(pushInterface.getPath())) {
|
||||||
return pushInterface.getPath();
|
return pushInterface.getPath();
|
||||||
}
|
}
|
||||||
return PUSH_PATH.get(sensorType);
|
String sensorType = mapping == null ? null : mapping.getSensorType();
|
||||||
|
String serialNumber = mapping == null ? null : mapping.getSerialNumber();
|
||||||
|
throw new RuntimeException("未配置推送接口,请在设备绑定中选择推送接口"
|
||||||
|
+ ",设备=" + serialNumber + ",传感器类型=" + sensorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveInterfaceCode(String sensorType, PlatformInterface pushInterface) {
|
private String resolveInterfaceCode(String sensorType, PlatformInterface pushInterface) {
|
||||||
|
|||||||
@ -255,15 +255,16 @@ public class PlatformFlowExecutor {
|
|||||||
if (override instanceof Map) {
|
if (override instanceof Map) {
|
||||||
Map<String, Object> ov = (Map<String, Object>) override;
|
Map<String, Object> ov = (Map<String, Object>) override;
|
||||||
String src = (String) ov.get("source");
|
String src = (String) ov.get("source");
|
||||||
result.put(name, resolveValue(src, ov, authConfig, extraConfig, ctx));
|
String type = ov.get("type") != null ? String.valueOf(ov.get("type")) : field.getString("type");
|
||||||
|
result.put(name, normalizeValueByType(type, resolveValue(src, ov, authConfig, extraConfig, ctx)));
|
||||||
} else {
|
} else {
|
||||||
result.put(name, override);
|
result.put(name, normalizeValueByType(field.getString("type"), override));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String source = field.getString("source");
|
String source = field.getString("source");
|
||||||
result.put(name, resolveValue(source, field, authConfig, extraConfig, ctx));
|
result.put(name, normalizeValueByType(field.getString("type"), resolveValue(source, field, authConfig, extraConfig, ctx)));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1069,4 +1070,81 @@ public class PlatformFlowExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============== 先不使用 ===========
|
||||||
|
private Object normalizeValueByType(String type, Object value) {
|
||||||
|
if (value == null || !StringUtils.hasText(type)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String normalizedType = type.trim().toLowerCase(Locale.ROOT);
|
||||||
|
switch (normalizedType) {
|
||||||
|
case "array":
|
||||||
|
return normalizeArrayValue(value);
|
||||||
|
case "number":
|
||||||
|
return normalizeNumberValue(value);
|
||||||
|
case "boolean":
|
||||||
|
return normalizeBooleanValue(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object normalizeArrayValue(Object value) {
|
||||||
|
if (value instanceof List) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if (!(value instanceof String)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String text = ((String) value).trim();
|
||||||
|
if (!StringUtils.hasText(text)) {
|
||||||
|
return new JSONArray();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (text.startsWith("[")) {
|
||||||
|
return JSON.parseArray(text);
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Fall through to comma split.
|
||||||
|
}
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
for (String item : text.split(",")) {
|
||||||
|
String itemText = item.trim();
|
||||||
|
if (!itemText.isEmpty()) {
|
||||||
|
array.add(normalizeNumberValue(itemText));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object normalizeNumberValue(Object value) {
|
||||||
|
if (value instanceof Number) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if (!(value instanceof String)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String text = ((String) value).trim();
|
||||||
|
if (!StringUtils.hasText(text)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return text.contains(".") ? Double.parseDouble(text) : Long.parseLong(text);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object normalizeBooleanValue(Object value) {
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
if (!(value instanceof String)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
String text = ((String) value).trim();
|
||||||
|
if ("true".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text)) {
|
||||||
|
return Boolean.parseBoolean(text);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 多语言转换
|
* 多语言转换
|
||||||
*
|
* todo 还没有同步维护 sys_dict_data_translate 表 先🧑注释
|
||||||
* @param list
|
* @param list
|
||||||
* @param language
|
* @param language
|
||||||
* @return
|
* @return
|
||||||
@ -98,13 +98,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
|
|||||||
public List<SysDictData> selectDictDataByType(String dictType) {
|
public List<SysDictData> selectDictDataByType(String dictType) {
|
||||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||||
convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
//convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||||
if (StringUtils.isNotEmpty(dictDatas)) {
|
if (StringUtils.isNotEmpty(dictDatas)) {
|
||||||
DictUtils.setDictCache(dictType, dictDatas);
|
DictUtils.setDictCache(dictType, dictDatas);
|
||||||
convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
//convertDictLabel(dictDatas, SecurityUtils.getLanguage());
|
||||||
return dictDatas;
|
return dictDatas;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -1,6 +1,32 @@
|
|||||||
-- 平台对接模块 DDL
|
-- 平台对接模块 DDL
|
||||||
-- 创建时间: 2026-05-30
|
-- 创建时间: 2026-05-30
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- 0. 平台传感器类型字典
|
||||||
|
-- 页面从 platform_sensor_type 读取选项,新增类型只需维护字典。
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT IGNORE INTO `sys_dict_type` (`dict_name`, `dict_type`, `status`, `create_by`, `create_time`, `remark`)
|
||||||
|
VALUES ('平台传感器类型', 'platform_sensor_type', '0', 'system', NOW(), '第三方平台对接使用的传感器类型');
|
||||||
|
|
||||||
|
DELETE FROM `sys_dict_data`
|
||||||
|
WHERE `dict_type` = 'platform_sensor_type'
|
||||||
|
AND `dict_value` IN ('inclino', 'deep_inclino', 'stress', 'hyeto', 'static_level');
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_data` (`dict_sort`, `dict_label`, `dict_value`, `dict_type`, `list_class`, `is_default`, `status`, `create_by`, `create_time`, `remark`)
|
||||||
|
VALUES
|
||||||
|
(1, '倾角', 'inclino', 'platform_sensor_type', 'primary', 'N', '0', 'system', NOW(), 'DCP倾角'),
|
||||||
|
(2, '深部位移计', 'deep_inclino', 'platform_sensor_type', 'primary', 'N', '0', 'system', NOW(), 'DCP深部位移计'),
|
||||||
|
(3, '轴力计', 'stress', 'platform_sensor_type', 'primary', 'N', '0', 'system', NOW(), 'DCP轴力计'),
|
||||||
|
(4, '雨量计', 'hyeto', 'platform_sensor_type', 'primary', 'N', '0', 'system', NOW(), 'DCP雨量计'),
|
||||||
|
(5, '静力水准仪', 'static_level', 'platform_sensor_type', 'primary', 'N', '0', 'system', NOW(), 'DCP静力水准');
|
||||||
|
|
||||||
|
INSERT INTO `sys_dict_data_translate` (`id`,`zh_cn`, `en_us`)
|
||||||
|
VALUES (738,'倾角','inclino'),
|
||||||
|
(739,'深部位移','deepInclino'),
|
||||||
|
(740,'轴力','stress'),
|
||||||
|
(741,'雨量','hyeto'),
|
||||||
|
(742,'静力水准','staticLevel')
|
||||||
|
;
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 1. 平台实体
|
-- 1. 平台实体
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -58,7 +84,7 @@ CREATE TABLE IF NOT EXISTS `platform_flow` (
|
|||||||
`name` varchar(100) NOT NULL COMMENT '流程名称',
|
`name` varchar(100) NOT NULL COMMENT '流程名称',
|
||||||
`code` varchar(100) NOT NULL COMMENT '流程标识',
|
`code` varchar(100) NOT NULL COMMENT '流程标识',
|
||||||
`flow_type` tinyint(1) NOT NULL COMMENT '流程类型(1=平台初始化,2=设备入网,3=Token刷新)',
|
`flow_type` tinyint(1) NOT NULL COMMENT '流程类型(1=平台初始化,2=设备入网,3=Token刷新)',
|
||||||
`sensor_type` varchar(50) DEFAULT NULL COMMENT '传感器类型,flow_type=2时有效: inclino/stress/hyeto/static_level',
|
`sensor_type` varchar(50) DEFAULT NULL COMMENT '传感器类型,flow_type=2时有效,来自字典 platform_sensor_type',
|
||||||
`enable` char(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
|
`enable` char(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
|
||||||
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
|
||||||
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
`create_by` varchar(64) DEFAULT '' COMMENT '创建者',
|
||||||
@ -95,7 +121,7 @@ CREATE TABLE IF NOT EXISTS `platform_device_mapping` (
|
|||||||
`serial_number` varchar(64) NOT NULL COMMENT 'FastBee设备序列号',
|
`serial_number` varchar(64) NOT NULL COMMENT 'FastBee设备序列号',
|
||||||
`platform_device_id` varchar(100) DEFAULT NULL COMMENT 'DCP侧deviceId,入网后自动回填',
|
`platform_device_id` varchar(100) DEFAULT NULL COMMENT 'DCP侧deviceId,入网后自动回填',
|
||||||
`platform_point_id` varchar(100) DEFAULT NULL COMMENT 'DCP侧pointId,入网后自动回填',
|
`platform_point_id` varchar(100) DEFAULT NULL COMMENT 'DCP侧pointId,入网后自动回填',
|
||||||
`sensor_type` varchar(50) NOT NULL COMMENT '传感器类型: inclino/stress/hyeto/static_level',
|
`sensor_type` varchar(50) NOT NULL COMMENT '传感器类型,来自字典 platform_sensor_type',
|
||||||
`device_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '设备类型: 0=直连设备 1=网关设备(多子设备)',
|
`device_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '设备类型: 0=直连设备 1=网关设备(多子设备)',
|
||||||
`push_interface_id` bigint(20) DEFAULT NULL COMMENT '推送接口ID,用于字段映射参照',
|
`push_interface_id` bigint(20) DEFAULT NULL COMMENT '推送接口ID,用于字段映射参照',
|
||||||
`field_mapping` json DEFAULT NULL COMMENT '字段映射 [{identifier,platformField,transform}]',
|
`field_mapping` json DEFAULT NULL COMMENT '字段映射 [{identifier,platformField,transform}]',
|
||||||
|
|||||||
@ -126,6 +126,7 @@
|
|||||||
<el-option label="平台参数" value="extra" />
|
<el-option label="平台参数" value="extra" />
|
||||||
<el-option label="上一步结果" value="context" />
|
<el-option label="上一步结果" value="context" />
|
||||||
<el-option label="当前设备" value="device" />
|
<el-option label="当前设备" value="device" />
|
||||||
|
<el-option label="入网参数" value="onboard_config" />
|
||||||
<el-option label="自动UUID" value="uuid" />
|
<el-option label="自动UUID" value="uuid" />
|
||||||
<el-option label="子设备传感器列表" value="subDeviceSensorIds" />
|
<el-option label="子设备传感器列表" value="subDeviceSensorIds" />
|
||||||
<el-option label="基准点成对传感器列表" value="referenceSubDeviceSensorIdPairs" />
|
<el-option label="基准点成对传感器列表" value="referenceSubDeviceSensorIdPairs" />
|
||||||
@ -156,6 +157,7 @@
|
|||||||
<el-option label="平台测点ID" value="platform_point_id" />
|
<el-option label="平台测点ID" value="platform_point_id" />
|
||||||
<el-option label="系统设备编号" value="serial_number" />
|
<el-option label="系统设备编号" value="serial_number" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-input v-else-if="scope.row.source === 'onboard_config'" v-model="scope.row.field" size="mini" placeholder="入网参数字段,如 sensorDepths" />
|
||||||
<span v-else-if="scope.row.source === 'uuid'" class="schema-hint">每次请求自动生成UUID</span>
|
<span v-else-if="scope.row.source === 'uuid'" class="schema-hint">每次请求自动生成UUID</span>
|
||||||
<span v-else-if="scope.row.source === 'subDeviceSensorIds'" class="schema-hint">自动取设备绑定页子设备映射中的 sensorId 列表</span>
|
<span v-else-if="scope.row.source === 'subDeviceSensorIds'" class="schema-hint">自动取设备绑定页子设备映射中的 sensorId 列表</span>
|
||||||
<span v-else-if="scope.row.source === 'referenceSubDeviceSensorIdPairs'" class="schema-hint">按基准点与每个监测点成对拆分请求</span>
|
<span v-else-if="scope.row.source === 'referenceSubDeviceSensorIdPairs'" class="schema-hint">按基准点与每个监测点成对拆分请求</span>
|
||||||
@ -463,7 +465,7 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (r.source === 'fixed') field.value = r.value
|
if (r.source === 'fixed') field.value = r.value
|
||||||
if (r.source === 'auth' || r.source === 'extra' || r.source === 'device') field.field = r.field
|
if (r.source === 'auth' || r.source === 'extra' || r.source === 'device' || r.source === 'onboard_config') field.field = r.field
|
||||||
if (r.source === 'context') field.contextKey = r.contextKey
|
if (r.source === 'context') field.contextKey = r.contextKey
|
||||||
return field
|
return field
|
||||||
}))
|
}))
|
||||||
|
|||||||
@ -256,13 +256,9 @@ import { listPlatformInstance } from '@/api/platform/instance'
|
|||||||
import { listPlatformInterface } from '@/api/platform/interface'
|
import { listPlatformInterface } from '@/api/platform/interface'
|
||||||
import { listDevice, listThingsModel, getDevice } from '@/api/iot/device'
|
import { listDevice, listThingsModel, getDevice } from '@/api/iot/device'
|
||||||
import { listGateway } from '@/api/iot/gateway'
|
import { listGateway } from '@/api/iot/gateway'
|
||||||
|
import { getDicts } from '@/api/system/dict/data'
|
||||||
|
|
||||||
const DEFAULT_SENSOR_TYPES = [
|
const SENSOR_TYPE_DICT = 'platform_sensor_type'
|
||||||
{ value: 'inclino', label: '倾角' },
|
|
||||||
{ value: 'stress', label: '轴力计' },
|
|
||||||
{ value: 'hyeto', label: '雨量计' },
|
|
||||||
{ value: 'static_level', label: '静力水准' }
|
|
||||||
]
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PlatformDeviceMapping',
|
name: 'PlatformDeviceMapping',
|
||||||
@ -281,6 +277,7 @@ export default {
|
|||||||
itemFieldMappingRows: [],
|
itemFieldMappingRows: [],
|
||||||
// 子表缓存 (列表展开行使用)
|
// 子表缓存 (列表展开行使用)
|
||||||
subMappingCache: {},
|
subMappingCache: {},
|
||||||
|
sensorTypeDictOptions: [],
|
||||||
queryParams: { pageNum: 1, pageSize: 20, platformId: null, sensorType: '', netStatus: null },
|
queryParams: { pageNum: 1, pageSize: 20, platformId: null, sensorType: '', netStatus: null },
|
||||||
form: { enable: '1', deviceType: 0, reportIntervalSec: 300 },
|
form: { enable: '1', deviceType: 0, reportIntervalSec: 300 },
|
||||||
rules: {
|
rules: {
|
||||||
@ -304,7 +301,7 @@ export default {
|
|||||||
},
|
},
|
||||||
sensorTypeOptions() {
|
sensorTypeOptions() {
|
||||||
const optionMap = new Map()
|
const optionMap = new Map()
|
||||||
DEFAULT_SENSOR_TYPES.forEach(item => optionMap.set(item.value, { ...item }))
|
this.sensorTypeDictOptions.forEach(item => optionMap.set(item.value, { ...item }))
|
||||||
;(this.list || []).forEach(item => {
|
;(this.list || []).forEach(item => {
|
||||||
if (item && item.sensorType && !optionMap.has(item.sensorType)) {
|
if (item && item.sensorType && !optionMap.has(item.sensorType)) {
|
||||||
optionMap.set(item.sensorType, { value: item.sensorType, label: item.sensorType })
|
optionMap.set(item.sensorType, { value: item.sensorType, label: item.sensorType })
|
||||||
@ -314,10 +311,21 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.loadSensorTypeOptions()
|
||||||
listPlatformInstance({ pageNum: 1, pageSize: 100 }).then(res => { this.platformList = res.rows || [] })
|
listPlatformInstance({ pageNum: 1, pageSize: 100 }).then(res => { this.platformList = res.rows || [] })
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
loadSensorTypeOptions() {
|
||||||
|
getDicts(SENSOR_TYPE_DICT).then(res => {
|
||||||
|
this.sensorTypeDictOptions = ((res && res.data) || []).map(item => ({
|
||||||
|
value: item.dictValue,
|
||||||
|
label: item.dictLabel || item.dictValue
|
||||||
|
})).filter(item => item.value)
|
||||||
|
}).catch(() => {
|
||||||
|
this.sensorTypeDictOptions = []
|
||||||
|
})
|
||||||
|
},
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
listPlatformDeviceMapping(this.queryParams).then(res => {
|
listPlatformDeviceMapping(this.queryParams).then(res => {
|
||||||
|
|||||||
@ -178,6 +178,7 @@
|
|||||||
<el-option label="平台参数" value="extra" />
|
<el-option label="平台参数" value="extra" />
|
||||||
<el-option label="上一步结果" value="context" />
|
<el-option label="上一步结果" value="context" />
|
||||||
<el-option label="当前设备" value="device" />
|
<el-option label="当前设备" value="device" />
|
||||||
|
<el-option label="入网参数" value="onboard_config" />
|
||||||
<el-option label="自动UUID" value="uuid" />
|
<el-option label="自动UUID" value="uuid" />
|
||||||
<el-option label="子设备传感器列表" value="subDeviceSensorIds" />
|
<el-option label="子设备传感器列表" value="subDeviceSensorIds" />
|
||||||
<el-option label="基准点成对传感器列表" value="referenceSubDeviceSensorIdPairs" />
|
<el-option label="基准点成对传感器列表" value="referenceSubDeviceSensorIdPairs" />
|
||||||
@ -204,6 +205,7 @@
|
|||||||
<el-option label="平台测点ID" value="platform_point_id" />
|
<el-option label="平台测点ID" value="platform_point_id" />
|
||||||
<el-option label="系统设备编号" value="serial_number" />
|
<el-option label="系统设备编号" value="serial_number" />
|
||||||
</el-select>
|
</el-select>
|
||||||
|
<el-input v-else-if="scope.row.source === 'onboard_config'" v-model="scope.row.field" size="mini" placeholder="入网参数字段,如 sensorDepths" />
|
||||||
<span v-else-if="scope.row.source === 'uuid'" class="schema-hint">每次请求自动生成UUID</span>
|
<span v-else-if="scope.row.source === 'uuid'" class="schema-hint">每次请求自动生成UUID</span>
|
||||||
<span v-else-if="scope.row.source === 'subDeviceSensorIds'" class="schema-hint">自动取设备绑定页子设备映射中的 sensorId 列表</span>
|
<span v-else-if="scope.row.source === 'subDeviceSensorIds'" class="schema-hint">自动取设备绑定页子设备映射中的 sensorId 列表</span>
|
||||||
<span v-else-if="scope.row.source === 'referenceSubDeviceSensorIdPairs'" class="schema-hint">按基准点与每个监测点成对拆分请求</span>
|
<span v-else-if="scope.row.source === 'referenceSubDeviceSensorIdPairs'" class="schema-hint">按基准点与每个监测点成对拆分请求</span>
|
||||||
@ -252,18 +254,9 @@
|
|||||||
import { listPlatformFlow, getPlatformFlow, savePlatformFlow, delPlatformFlow, executePlatformFlow } from '@/api/platform/flow'
|
import { listPlatformFlow, getPlatformFlow, savePlatformFlow, delPlatformFlow, executePlatformFlow } from '@/api/platform/flow'
|
||||||
import { listPlatformInstance, getPlatformInstance } from '@/api/platform/instance'
|
import { listPlatformInstance, getPlatformInstance } from '@/api/platform/instance'
|
||||||
import { listPlatformInterface } from '@/api/platform/interface'
|
import { listPlatformInterface } from '@/api/platform/interface'
|
||||||
|
import { getDicts } from '@/api/system/dict/data'
|
||||||
|
|
||||||
const DEFAULT_SENSOR_TYPES = [
|
const SENSOR_TYPE_DICT = 'platform_sensor_type'
|
||||||
{ value: 'inclino', label: '倾角' },
|
|
||||||
{ value: 'stress', label: '轴力计' },
|
|
||||||
{ value: 'hyeto', label: '雨量计' },
|
|
||||||
{ value: 'static_level', label: '静力水准' }
|
|
||||||
]
|
|
||||||
|
|
||||||
const SENSOR_LABELS = DEFAULT_SENSOR_TYPES.reduce((acc, item) => {
|
|
||||||
acc[item.value] = item.label
|
|
||||||
return acc
|
|
||||||
}, {})
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PlatformFlow',
|
name: 'PlatformFlow',
|
||||||
@ -278,6 +271,7 @@ export default {
|
|||||||
interfaceOptions: [],
|
interfaceOptions: [],
|
||||||
platformAuthFields: [],
|
platformAuthFields: [],
|
||||||
platformExtraFields: [],
|
platformExtraFields: [],
|
||||||
|
sensorTypeDictOptions: [],
|
||||||
open: false,
|
open: false,
|
||||||
title: '',
|
title: '',
|
||||||
steps: [],
|
steps: [],
|
||||||
@ -301,17 +295,29 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
sensorTypeOptions() {
|
sensorTypeOptions() {
|
||||||
const optionMap = new Map()
|
const optionMap = new Map()
|
||||||
DEFAULT_SENSOR_TYPES.forEach(item => optionMap.set(item.value, { ...item }))
|
this.sensorTypeDictOptions.forEach(item => optionMap.set(item.value, { ...item }))
|
||||||
;(this.list || []).forEach(item => this.appendSensorTypeOption(optionMap, item && item.sensorType))
|
;(this.list || []).forEach(item => this.appendSensorTypeOption(optionMap, item && item.sensorType))
|
||||||
this.appendSensorTypeOption(optionMap, this.form.sensorType)
|
this.appendSensorTypeOption(optionMap, this.form.sensorType)
|
||||||
return Array.from(optionMap.values())
|
return Array.from(optionMap.values())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
this.loadSensorTypeOptions()
|
||||||
listPlatformInstance({ pageNum: 1, pageSize: 100 }).then(res => { this.platformList = res.rows || [] })
|
listPlatformInstance({ pageNum: 1, pageSize: 100 }).then(res => { this.platformList = res.rows || [] })
|
||||||
this.getList()
|
this.getList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
loadSensorTypeOptions() {
|
||||||
|
getDicts(SENSOR_TYPE_DICT).then(res => {
|
||||||
|
this.sensorTypeDictOptions = ((res && res.data) || []).map(item => {
|
||||||
|
const value = item.dict_value || item.dictValue
|
||||||
|
const label = item.dict_label || item.dictLabel || value
|
||||||
|
return { value, label }
|
||||||
|
}).filter(item => item.value)
|
||||||
|
}).catch(() => {
|
||||||
|
this.sensorTypeDictOptions = []
|
||||||
|
})
|
||||||
|
},
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
listPlatformFlow(this.queryParams).then(res => {
|
listPlatformFlow(this.queryParams).then(res => {
|
||||||
@ -322,7 +328,7 @@ export default {
|
|||||||
},
|
},
|
||||||
appendSensorTypeOption(optionMap, value) {
|
appendSensorTypeOption(optionMap, value) {
|
||||||
if (!value || optionMap.has(value)) return
|
if (!value || optionMap.has(value)) return
|
||||||
optionMap.set(value, { value, label: SENSOR_LABELS[value] || value })
|
optionMap.set(value, { value, label: value })
|
||||||
},
|
},
|
||||||
platformName(id) {
|
platformName(id) {
|
||||||
const platform = this.platformList.find(item => item.id === id)
|
const platform = this.platformList.find(item => item.id === id)
|
||||||
@ -453,6 +459,7 @@ export default {
|
|||||||
if (field.source === 'auth') return `认证参数 / ${field.field || ''}`
|
if (field.source === 'auth') return `认证参数 / ${field.field || ''}`
|
||||||
if (field.source === 'extra') return `平台参数 / ${field.field || ''}`
|
if (field.source === 'extra') return `平台参数 / ${field.field || ''}`
|
||||||
if (field.source === 'context') return `上一步结果 / ${field.contextKey || ''}`
|
if (field.source === 'context') return `上一步结果 / ${field.contextKey || ''}`
|
||||||
|
if (field.source === 'onboard_config') return `入网参数 / ${field.field || ''}`
|
||||||
if (field.source === 'device') {
|
if (field.source === 'device') {
|
||||||
const deviceLabels = {
|
const deviceLabels = {
|
||||||
platform_device_id: '平台设备ID',
|
platform_device_id: '平台设备ID',
|
||||||
@ -540,7 +547,7 @@ export default {
|
|||||||
if (!row.name || !row.source) return
|
if (!row.name || !row.source) return
|
||||||
const item = { source: row.source }
|
const item = { source: row.source }
|
||||||
if (row.source === 'fixed') item.value = row.value
|
if (row.source === 'fixed') item.value = row.value
|
||||||
if (row.source === 'auth' || row.source === 'extra' || row.source === 'device') item.field = row.field
|
if (row.source === 'auth' || row.source === 'extra' || row.source === 'device' || row.source === 'onboard_config') item.field = row.field
|
||||||
if (row.source === 'context') item.contextKey = row.contextKey
|
if (row.source === 'context') item.contextKey = row.contextKey
|
||||||
mappings[row.name] = item
|
mappings[row.name] = item
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user