diff --git a/src/main/webapp/jsp/main_JS_Company.jsp b/src/main/webapp/jsp/main_JS_Company.jsp index d8f9ad6d..ff3e7c01 100644 --- a/src/main/webapp/jsp/main_JS_Company.jsp +++ b/src/main/webapp/jsp/main_JS_Company.jsp @@ -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('获取主配置数据失败'); @@ -849,12 +849,13 @@ if (!hasPumpConfig) { 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,41 +1110,98 @@ 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; - renderProcessTable(); - } else { - processData = generateProcessData(); - renderProcessTable(); - } - } catch (e) { - processData = generateProcessData(); + 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(); } } }); } + // 异步获取测点值 + 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 { + resolve('--'); + } + }, + error: function() { + resolve('--'); + } + }); + }); + } + // 生成告警列表mock数据 function generateAlarmData() { var processNames = ['粗格栅间', '细格栅间', '曝气沉砂池', '厌氧池', '缺氧池', '好氧池', '二沉池', '消毒池', '污泥浓缩池', '污泥脱水间'];