|
@@ -58,7 +58,7 @@ export function exportToExcel(datas, fn) {
|
|
|
|
|
|
// 多级表头
|
|
|
const multiHeader = [[
|
|
|
- '项目名称', '盒子名称', '在线状态', '运行模式',
|
|
|
+ '盒子名称', '在线状态', '运行模式',
|
|
|
'主机', '', '', '', '', '',
|
|
|
'新风机', '', '', '', '', '',
|
|
|
'换热站', '', '', '', '', '', '',
|
|
@@ -67,7 +67,7 @@ export function exportToExcel(datas, fn) {
|
|
|
|
|
|
// 二级表头
|
|
|
let header = [
|
|
|
- '项目名称', '盒子名称', '在线状态', '运行模式',
|
|
|
+ '盒子名称', '在线状态', '运行模式',
|
|
|
'编号', '通讯状态', '故障', '供水水温(℃)', '回水水温(℃)', '温差',
|
|
|
'编号', '通讯状态', '故障', '送风温度(℃)', '送风湿度(%)', '露点(℃)',
|
|
|
'编号', '通讯状态', '故障', '供水水温(℃)', '回水水温(℃)', '温差', '水泵状态',
|
|
@@ -76,40 +76,42 @@ export function exportToExcel(datas, fn) {
|
|
|
|
|
|
// 数据
|
|
|
let expand = _transferDataToXlsx(datas)
|
|
|
+ console.log("expand: ", expand);
|
|
|
|
|
|
// 合并表头
|
|
|
- const merges = ['A1:A2', 'B1:B2', 'C1:C2', 'D1:D2', 'E1:J1', 'K1:P1', 'Q1:W1', 'X1:AD1']
|
|
|
+ const merges = ['A1:A2', 'B1:B2', 'C1:C2', 'D1:I1', 'J1:O1', 'P1:V1', 'W1:AC1']
|
|
|
|
|
|
// 合并列
|
|
|
- let projectSet = _calcProjectRowMap(expand)
|
|
|
+ // let projectSet = _calcProjectRowMap(expand)
|
|
|
let boxSet = _calcBoxRowMap(expand)
|
|
|
+ console.log("boxSet: ", boxSet);
|
|
|
// 计算项目合并列
|
|
|
- if (projectSet.length > 0) {
|
|
|
- let first = projectSet[0]
|
|
|
- merges.push('A'+(3+first.s)+':A'+(3+first.l-1))
|
|
|
- for (let i = 1; i < projectSet.length; i++) {
|
|
|
- let pre = projectSet[i - 1]
|
|
|
- let cur = projectSet[i]
|
|
|
- let start = 3 + pre.s + pre.l
|
|
|
- merges.push('A'+start+':A'+(start+cur.l-1))
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (projectSet.length > 0) {
|
|
|
+ // let first = projectSet[0]
|
|
|
+ // merges.push('A'+(3+first.s)+':A'+(3+first.l-1))
|
|
|
+ // for (let i = 1; i < projectSet.length; i++) {
|
|
|
+ // let pre = projectSet[i - 1]
|
|
|
+ // let cur = projectSet[i]
|
|
|
+ // let start = 3 + pre.s + pre.l
|
|
|
+ // merges.push('A'+start+':A'+(start+cur.l-1))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
// 计算盒子/盒子运行状态/盒子运行模式合并列
|
|
|
if (boxSet.length > 0) {
|
|
|
let first = boxSet[0]
|
|
|
- merges.push('B'+(3+first.s)+':B'+(3+first.l-1))
|
|
|
- merges.push('C'+(3+first.s)+':C'+(3+first.l-1))
|
|
|
- merges.push('D'+(3+first.s)+':D'+(3+first.l-1))
|
|
|
+ merges.push('A'+(2+first.s)+':A'+(2+first.l-1))
|
|
|
+ merges.push('B'+(2+first.s)+':B'+(2+first.l-1))
|
|
|
+ merges.push('C'+(2+first.s)+':C'+(2+first.l-1))
|
|
|
for (let i = 1; i < boxSet.length; i++) {
|
|
|
let pre = boxSet[i - 1]
|
|
|
let cur = boxSet[i]
|
|
|
- let start = 3 + pre.s + pre.l
|
|
|
+ let start = 2 + pre.s + pre.l
|
|
|
+ merges.push('A'+start+':A'+(start+cur.l-1))
|
|
|
merges.push('B'+start+':B'+(start+cur.l-1))
|
|
|
merges.push('C'+start+':C'+(start+cur.l-1))
|
|
|
- merges.push('D'+start+':D'+(start+cur.l-1))
|
|
|
}
|
|
|
}
|
|
|
- // console.log("merges: ", merges)
|
|
|
+ console.log("merges: ", merges);
|
|
|
|
|
|
// 导出
|
|
|
Export2ExcelMerge({
|
|
@@ -119,6 +121,7 @@ export function exportToExcel(datas, fn) {
|
|
|
filename: defaultFilename,
|
|
|
merges
|
|
|
})
|
|
|
+
|
|
|
fn()
|
|
|
}
|
|
|
|
|
@@ -145,106 +148,104 @@ function _listAllProjects(fn) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function _transferDataToXlsx(projects) {
|
|
|
+function _transferDataToXlsx(boxList) {
|
|
|
let tableData = []
|
|
|
- projects.forEach(p => {
|
|
|
- if (Array.isArray(p.boxList)) {
|
|
|
- p.boxList.forEach(b => {
|
|
|
- // 继续判断有多少单机,主机、新风机、换热站、末端单机数量取最大值
|
|
|
- let maxCnt = define.calcMaxStandaloneCnt(b)
|
|
|
- for (let i = 0; i < maxCnt; i++) {
|
|
|
- let hpStandalone = b.hostCtrl && i < b.hostCtrl.length ? b.hostCtrl[i] : undefined
|
|
|
- let dhStandalone = b.newTrendCtrl && i < b.newTrendCtrl.length ? b.newTrendCtrl[i] : undefined
|
|
|
- let hexStandalone = b.hex && i < b.hex.length ? b.hex[i] : undefined
|
|
|
- let cbStandalone = i > 0 ? undefined : define.calcEndMinAndMaxValue(b.end || [])
|
|
|
- let row = [
|
|
|
- p.projectName,
|
|
|
- b.boxName,
|
|
|
- define.runStatDict[b.runStatus]
|
|
|
- ? define.runStatDict[b.runStatus].label
|
|
|
- : "/",
|
|
|
- define.runModeDict[b.runMode]
|
|
|
- ? define.runModeDict[b.runMode].label
|
|
|
- : "/",
|
|
|
- hpStandalone ? hpStandalone.host_order : "/",
|
|
|
- hpStandalone && b.runStatus == 1
|
|
|
- ? _getConnectState(hpStandalone.host_connect_status)
|
|
|
- : "/",
|
|
|
- hpStandalone && b.runStatus == 1
|
|
|
- ? _getFault(hpStandalone.host_fault)
|
|
|
- : "/",
|
|
|
- hpStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(hpStandalone.host_su_temp)
|
|
|
- : "/",
|
|
|
- hpStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(hpStandalone.host_re_temp)
|
|
|
- : "/",
|
|
|
- hpStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(hpStandalone, "host_temp_diff")
|
|
|
- : "/",
|
|
|
- dhStandalone ? dhStandalone.nt_order : "/",
|
|
|
- dhStandalone && b.runStatus == 1
|
|
|
- ? _getConnectState(dhStandalone.nt_connect_status)
|
|
|
- : "/",
|
|
|
- dhStandalone && b.runStatus == 1
|
|
|
- ? _getFault(dhStandalone.nt_fault)
|
|
|
- : "/",
|
|
|
- dhStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(dhStandalone.nt_in_temp)
|
|
|
- : "/",
|
|
|
- dhStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(dhStandalone.nt_in_humidity)
|
|
|
- : "/",
|
|
|
- dhStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(dhStandalone.nt_dew_point)
|
|
|
- : "/",
|
|
|
- hexStandalone ? hexStandalone.hex_order : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _getConnectState(hexStandalone.hex_connect_status)
|
|
|
- : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _getFault(hexStandalone.hex_fault)
|
|
|
- : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(hexStandalone.hex_su_temp)
|
|
|
- : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(hexStandalone.hex_re_temp)
|
|
|
- : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _fixVal(hexStandalone.hex_temp_diff)
|
|
|
- : "/",
|
|
|
- hexStandalone && b.runStatus == 1
|
|
|
- ? _getHexPumpState(hexStandalone.hex_pump_status)
|
|
|
- : "/",
|
|
|
- // cbStandalone ? cbStandalone.end_order : '/',
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? cbStandalone.end_exception_num
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_min_temp")
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_min_humidity")
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_min_dew_point")
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_max_temp")
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_max_humidity")
|
|
|
- : "/",
|
|
|
- cbStandalone && b.runStatus == 1
|
|
|
- ? _noneZero(cbStandalone, "end_max_dew_point")
|
|
|
- : "/",
|
|
|
- ];
|
|
|
- tableData.push(row)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ boxList.forEach((b) => {
|
|
|
+ // 继续判断有多少单机,主机、新风机、换热站、末端单机数量取最大值
|
|
|
+ let maxCnt = define.calcMaxStandaloneCntExt(b);
|
|
|
+ for (let i = 0; i < maxCnt; i++) {
|
|
|
+ let hpStandalone =
|
|
|
+ b.hostCtrl && i < b.hostCtrl.length ? b.hostCtrl[i] : undefined;
|
|
|
+ let dhStandalone =
|
|
|
+ b.newTrendCtrl && i < b.newTrendCtrl.length
|
|
|
+ ? b.newTrendCtrl[i]
|
|
|
+ : undefined;
|
|
|
+ let hexStandalone = b.hex && i < b.hex.length ? b.hex[i] : undefined;
|
|
|
+ let cbStandalone =
|
|
|
+ i > 0 ? undefined : define.calcEndMinAndMaxValue(b.end || []);
|
|
|
+ let row = [
|
|
|
+ b.boxName,
|
|
|
+ define.runStatDict[b.runStatus]
|
|
|
+ ? define.runStatDict[b.runStatus].label
|
|
|
+ : "/",
|
|
|
+ define.runModeDict[b.runMode]
|
|
|
+ ? define.runModeDict[b.runMode].label
|
|
|
+ : "/",
|
|
|
+ hpStandalone ? hpStandalone.host_order : "/",
|
|
|
+ hpStandalone && b.runStatus == 1
|
|
|
+ ? _getConnectState(hpStandalone.host_connect_status)
|
|
|
+ : "/",
|
|
|
+ hpStandalone && b.runStatus == 1
|
|
|
+ ? _getFault(hpStandalone.host_fault)
|
|
|
+ : "/",
|
|
|
+ hpStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(hpStandalone.host_su_temp)
|
|
|
+ : "/",
|
|
|
+ hpStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(hpStandalone.host_re_temp)
|
|
|
+ : "/",
|
|
|
+ hpStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(hpStandalone, "host_temp_diff")
|
|
|
+ : "/",
|
|
|
+ dhStandalone ? dhStandalone.nt_order : "/",
|
|
|
+ dhStandalone && b.runStatus == 1
|
|
|
+ ? _getConnectState(dhStandalone.nt_connect_status)
|
|
|
+ : "/",
|
|
|
+ dhStandalone && b.runStatus == 1
|
|
|
+ ? _getFault(dhStandalone.nt_fault)
|
|
|
+ : "/",
|
|
|
+ dhStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(dhStandalone.nt_in_temp)
|
|
|
+ : "/",
|
|
|
+ dhStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(dhStandalone.nt_in_humidity)
|
|
|
+ : "/",
|
|
|
+ dhStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(dhStandalone.nt_dew_point)
|
|
|
+ : "/",
|
|
|
+ hexStandalone ? hexStandalone.hex_order : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _getConnectState(hexStandalone.hex_connect_status)
|
|
|
+ : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _getFault(hexStandalone.hex_fault)
|
|
|
+ : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(hexStandalone.hex_su_temp)
|
|
|
+ : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(hexStandalone.hex_re_temp)
|
|
|
+ : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _fixVal(hexStandalone.hex_temp_diff)
|
|
|
+ : "/",
|
|
|
+ hexStandalone && b.runStatus == 1
|
|
|
+ ? _getHexPumpState(hexStandalone.hex_pump_status)
|
|
|
+ : "/",
|
|
|
+ // cbStandalone ? cbStandalone.end_order : '/',
|
|
|
+ cbStandalone && b.runStatus == 1 ? cbStandalone.end_exception_num : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_min_temp")
|
|
|
+ : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_min_humidity")
|
|
|
+ : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_min_dew_point")
|
|
|
+ : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_max_temp")
|
|
|
+ : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_max_humidity")
|
|
|
+ : "/",
|
|
|
+ cbStandalone && b.runStatus == 1
|
|
|
+ ? _noneZero(cbStandalone, "end_max_dew_point")
|
|
|
+ : "/",
|
|
|
+ ];
|
|
|
+ tableData.push(row);
|
|
|
+ }
|
|
|
+ });
|
|
|
return tableData
|
|
|
}
|
|
|
|
|
@@ -270,21 +271,21 @@ function _calcProjectRowMap(datas) {
|
|
|
|
|
|
// 计算盒子的合并行(每个盒子的合并数)
|
|
|
function _calcBoxRowMap(datas) {
|
|
|
- let boxNames = datas.map(v => v[1])
|
|
|
- let nameset = Array.from(new Set(boxNames))
|
|
|
+ let boxIds = datas.map(v => v[0])
|
|
|
+ let idset = Array.from(new Set(boxIds));
|
|
|
let rows = []
|
|
|
- nameset.forEach(name => {
|
|
|
- let row = { name: name }
|
|
|
- for (let i = 0; i < datas.length; i++) {
|
|
|
- if (datas[i][1] === name) {
|
|
|
- row.s = i
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- let list = datas.filter(d => d[1] === name)
|
|
|
- row.l = list.length || 1
|
|
|
- rows.push(row)
|
|
|
- })
|
|
|
+ idset.forEach((boxId) => {
|
|
|
+ let row = { boxId: boxId };
|
|
|
+ for (let i = 0; i < datas.length; i++) {
|
|
|
+ if (datas[i][1] === boxId) {
|
|
|
+ row.s = i;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let list = datas.filter((d) => d[1] === boxId);
|
|
|
+ row.l = list.length || 1;
|
|
|
+ rows.push(row);
|
|
|
+ });
|
|
|
return rows
|
|
|
}
|
|
|
|