Compare commits

...

2 Commits

View File

@ -647,7 +647,7 @@
rows: 1000,
sort: "displacement",
order: "asc",
unitId: '0533JS',
unitId: defaultUnitId,
},
// async: true,
// dataType: 'json',
@ -746,7 +746,7 @@
type: 'GET',
url: ext.contextPath + '/base/mainConfig/getJson.do',
async: true,
data: {unitId: unitId},
data: {unitId: defaultUnitId},
globle: false,
error: function () {
console.error('获取主配置数据失败');
@ -850,11 +850,12 @@
initPumpStations();
}
// 如果没有工艺配置,使用默认数据
var hasProcessConfig = mpcode.some(function(item) { return item.type === 'process'; });
if (!hasProcessConfig) {
initProcessList();
}
// // 如果没有工艺配置,使用默认数据
// var hasProcessConfig = mpcode.some(function(item) { return item.type === 'process'; });
// if (!hasProcessConfig) {
// initProcessList();
// }
initProcessListByConfig(code, divid);
// 如果没有告警配置,使用默认数据
var hasAlarmConfig = mpcode.some(function(item) { return item.type === 'alarm'; });
@ -900,7 +901,7 @@
page: page,
sort: 'equipmentcardid',
order: 'asc',
unitId: unitId,
unitId: defaultUnitId,
},
async: true,
globle: false,
@ -1109,39 +1110,96 @@
return data;
}
// 根据配置初始化工艺列表
// 根据配置初始化工艺列表 - 调用工艺段接口
// /TGLW/user/processSection/getlist.do?rows=50&page=1&order=asc&search_code=0533JS&unitId=0533JS&search_name=&_=1775558221772
function initProcessListByConfig(mpointCode, containerId) {
$.ajax({
type: 'GET',
url: ext.contextPath + '/work/mpoint/getProcessList.do?unitId=' + unitId + '&mpointCode=' + mpointCode,
url: ext.contextPath + '/user/processSection/getlist.do',
data: {
unitId: defaultUnitId,
rows: 50,
page: 1,
},
async: true,
dataType: 'json',
globle: false,
error: function () {
processData = generateProcessData();
renderProcessTable();
// processData = generateProcessData();
// renderProcessTable();
return false;
},
success: function (data) {
if (data != null && data !== '') {
try {
var result = eval('(' + data + ')');
if (result.status === 'pass' && result.processList) {
processData = result.processList;
if (data && data.rows) {
// 将接口返回的工艺段数据转换为表格格式
processData = [];
var rows = data.rows || [];
// 为每个工艺段获取测点值
var promises = [];
rows.forEach(function(item, index) {
var processItem = {
...item,
processName: item.text || item.name || '--',
param1: '--',
param2: '--',
param3: '--',
deviceId: item.id || ''
};
processData.push(processItem);
// 为param1, param2, param3创建获取值的Promise
['1', '2', '3'].forEach(function(suffix) {
var mpointCodeParam = item.id + '_' + suffix;
promises.push(
getMpointValueAsync(mpointCodeParam).then(function(value) {
if (suffix === '1') processItem.param1 = value;
else if (suffix === '2') processItem.param2 = value;
else if (suffix === '3') processItem.param3 = value;
})
);
});
});
// 等待所有测点值获取完成后渲染表格
Promise.all(promises).then(function() {
renderProcessTable();
}).catch(function() {
renderProcessTable();
});
} else {
processData = generateProcessData();
renderProcessTable();
// processData = generateProcessData();
// renderProcessTable();
}
} catch (e) {
processData = generateProcessData();
renderProcessTable();
}
});
}
// 异步获取测点值
function getMpointValueAsync(mpointCode) {
return new Promise(function(resolve) {
$.ajax({
type: 'GET',
url: ext.contextPath + '/work/mpoint/getValue.do',
data: {
unitId: defaultUnitId,
mpointCode: mpointCode
},
async: true,
dataType: 'json',
globle: false,
success: function(data) {
if (data && data.parmvalue !== undefined && data.parmvalue !== null) {
resolve(data.parmname + ':' + data.parmvalue + data.unit);
} else {
processData = generateProcessData();
renderProcessTable();
resolve('--');
}
},
error: function() {
resolve('--');
}
});
});
}
// 生成告警列表mock数据