"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BaseService = void 0;
var _tslib = require("tslib");
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _lodash = _interopRequireWildcard(require("lodash"));
var _dayjs = _interopRequireDefault(require("dayjs"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
var sortClass = function sortClass(sortData, key) {
  var groupBy = function groupBy(array, f) {
    var groups = {};
    array.forEach(function (o) {
      var group = JSON.stringify(f(o));
      groups[group] = groups[group] || [];
      groups[group].push(o);
    });
    return Object.keys(groups).map(function (group) {
      return groups[group];
    });
  };
  var sorted = groupBy(sortData, function (item) {
    return item[key]; // 返回需要分组的对象
  });
  return sorted;
};
// 总览信息
var BaseService = exports.BaseService = {
  useBaseInfo: function useBaseInfo(id, coordType) {
    var _a, _b, _c, _d, _e, _f;
    // 基本信息
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/device/entity/getBasicInfo', {
          body: {
            deviceId: id,
            coordinateType: 'wgs84'
          }
        });
      }, {
        refreshDeps: [id, coordType]
      }),
      baseInfoRes = _useRequest.data;
    var info = (baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) || {};
    if ((_a = info === null || info === void 0 ? void 0 : info.monitorItems) === null || _a === void 0 ? void 0 : _a.length) {
      var _monitorItems = info.monitorItems.map(function (item) {
        return item.value;
      });
      info.monitorItemsName = _monitorItems.join(',');
    }
    if ((_b = info === null || info === void 0 ? void 0 : info.projects) === null || _b === void 0 ? void 0 : _b.length) {
      var projectsNameItems = info.projects.map(function (item) {
        return item.value;
      });
      info.projectsName = projectsNameItems.join(',');
    }
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: 'device'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      tabConfig = _useRequest2.data;
    var monitorItems = info.monitorItems;
    var monitorItemsName = (monitorItems === null || monitorItems === void 0 ? void 0 : monitorItems.length) ? monitorItems.map(function (v) {
      return v.value;
    }).join(',') : '';
    var unitObj = {
      YEAR: '年',
      MONYH: '月',
      DAY: '日'
    };
    var baseInfo = [{
      label: '设备编码',
      key: 'code',
      value: info === null || info === void 0 ? void 0 : info.code
    }, {
      label: '设备名称',
      key: 'name',
      value: info === null || info === void 0 ? void 0 : info.name
    }, {
      label: '设备类型',
      key: 'deviceTypeName',
      value: info === null || info === void 0 ? void 0 : info.deviceTypeName
    }, {
      label: '设备型号',
      key: 'modelName',
      value: info === null || info === void 0 ? void 0 : info.modelName
    }, {
      label: '设备厂家',
      key: 'factoryName',
      value: info === null || info === void 0 ? void 0 : info.factoryName
    }, {
      label: '安装位置',
      key: 'facilityName',
      value: info === null || info === void 0 ? void 0 : info.facilityName
    }, {
      label: '设备ID',
      key: 'iotId',
      value: info === null || info === void 0 ? void 0 : info.iotId
    }, {
      label: '监测项',
      key: 'monitorItems',
      value: monitorItemsName
    }, {
      label: '资产编号',
      key: 'assetNumber',
      value: info === null || info === void 0 ? void 0 : info.assetNumber
    }, {
      label: '设备位号',
      key: 'tagNumber',
      value: info === null || info === void 0 ? void 0 : info.tagNumber
    }, {
      label: '性能参数',
      key: 'performanceParameter',
      value: info === null || info === void 0 ? void 0 : info.performanceParameter
    }, {
      label: '主要材质',
      key: 'mainMaterial',
      value: info === null || info === void 0 ? void 0 : info.mainMaterial
    }, {
      label: '出厂编号',
      key: 'factoryNumber',
      value: info === null || info === void 0 ? void 0 : info.factoryNumber
    }, {
      label: '出厂日期',
      key: 'factoryDate',
      value: info === null || info === void 0 ? void 0 : info.factoryDate
    }, {
      label: '设备供应商',
      key: 'supplier',
      value: info === null || info === void 0 ? void 0 : info.supplier
    }, {
      label: '启用时间',
      key: 'enableDate',
      value: info === null || info === void 0 ? void 0 : info.enableDate
    }, {
      label: '寿命周期',
      key: 'expectServiceLifeUnit',
      value: unitObj[info === null || info === void 0 ? void 0 : info.expectServiceLifeUnit]
    }, {
      label: '预计使用寿命',
      key: 'expectServiceLifeNumber',
      value: info === null || info === void 0 ? void 0 : info.expectServiceLifeNumber
    }, {
      label: '所属单位',
      key: 'manageUnitName',
      value: info === null || info === void 0 ? void 0 : info.manageUnitName
    }, {
      label: '设备负责人',
      key: 'responsiblePersonName',
      value: info === null || info === void 0 ? void 0 : info.responsiblePersonName
    }, {
      label: '联系方式',
      key: 'phone',
      value: info === null || info === void 0 ? void 0 : info.phone
    }];
    return {
      baseInfo: baseInfo,
      info: info,
      tabIsFilter: !!((_d = (_c = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _c === void 0 ? void 0 : _c.popupConfigJson) === null || _d === void 0 ? void 0 : _d.length),
      tabConfig: ((_f = (_e = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _e === void 0 ? void 0 : _e.popupConfigJson) === null || _f === void 0 ? void 0 : _f.filter(function (ele) {
        return ele.display;
      }).map(function (ele) {
        return {
          key: ele.code,
          title: ele.name
        };
      })) || [],
      visited: !!tabConfig
    };
  },
  useRealtimeList: function useRealtimeList(id) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
          var res;
          return _regenerator().w(function (_context) {
            while (1) switch (_context.n) {
              case 0:
                _context.n = 1;
                return _utils.request.get('/cloud/device/realtime/monitor/data/realtimeFactorValueList', {
                  data: {
                    deviceId: id
                  }
                });
              case 1:
                res = _context.v;
                return _context.a(2, (res === null || res === void 0 ? void 0 : res.data) || []);
            }
          }, _callee);
        }));
      }, {
        refreshDeps: [id]
      }),
      _useRequest3$data = _useRequest3.data,
      data = _useRequest3$data === void 0 ? [] : _useRequest3$data;
    return {
      data: data
    };
  },
  useGetChartData: function useGetChartData(_ref) {
    var monitorItemIds = _ref.monitorItemIds,
      deviceId = _ref.deviceId,
      collectFrequency = _ref.collectFrequency,
      startTime = _ref.startTime,
      endTime = _ref.endTime;
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
          var res;
          return _regenerator().w(function (_context2) {
            while (1) switch (_context2.n) {
              case 0:
                if (!((0, _lodash.isEmpty)(monitorItemIds) || !startTime || !endTime || !collectFrequency)) {
                  _context2.n = 1;
                  break;
                }
                return _context2.a(2, []);
              case 1:
                _context2.n = 2;
                return _utils.request.get('/cloud/device/realtime/monitor/data/eCharts', {
                  data: {
                    monitorItemIds: monitorItemIds,
                    deviceId: deviceId,
                    collectFrequency: collectFrequency,
                    startTime: startTime,
                    endTime: endTime
                  }
                });
              case 2:
                res = _context2.v;
                return _context2.a(2, (res === null || res === void 0 ? void 0 : res.data) || []);
            }
          }, _callee2);
        }));
      }, {
        refreshDeps: [JSON.stringify(monitorItemIds), collectFrequency, startTime, endTime]
      }),
      _useRequest4$data = _useRequest4.data,
      data = _useRequest4$data === void 0 ? [] : _useRequest4$data,
      loading = _useRequest4.loading;
    return {
      data: data,
      loading: loading
    };
  },
  useGetDeviceTree: function useGetDeviceTree(id) {
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
          var res, treeData, _data;
          return _regenerator().w(function (_context3) {
            while (1) switch (_context3.n) {
              case 0:
                _context3.n = 1;
                return _utils.request.get('/cloud/device/realtime/monitor/data/generateDeviceJsonTree', {
                  data: {
                    showDeviceFlag: true,
                    onlyDeviceFacilityFlag: true
                  }
                });
              case 1:
                res = _context3.v;
                treeData = [];
                if ((res === null || res === void 0 ? void 0 : res.result) == 0 && (res === null || res === void 0 ? void 0 : res.data)) {
                  _data = res.data || {};
                  treeData = (0, _utils.parseTreeData)(_data.children || [], {
                    renderNode: function renderNode(node) {
                      var _a;
                      return Object.assign(Object.assign({}, node), {
                        title: node.type === 'device' ? "".concat(((_a = node === null || node === void 0 ? void 0 : node.attributes) === null || _a === void 0 ? void 0 : _a.deviceTypeName) ? "".concat(node.attributes.deviceTypeName, "-") : '').concat(node.name) : node.name
                      });
                    },
                    filterNode: function filterNode(node) {
                      return node.key !== id;
                    },
                    filterEmptyNodes: function filterEmptyNodes() {
                      return null;
                    }
                  });
                }
                return _context3.a(2, treeData);
            }
          }, _callee3);
        }));
      }),
      _useRequest5$data = _useRequest5.data,
      data = _useRequest5$data === void 0 ? [] : _useRequest5$data;
    return {
      data: data
    };
  },
  useGetMonitor: function useGetMonitor(_ref2) {
    var deviceIds = _ref2.deviceIds;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee4() {
          var res, data;
          return _regenerator().w(function (_context4) {
            while (1) switch (_context4.n) {
              case 0:
                _context4.n = 1;
                return _utils.request.get('/cloud/device/monitor/item/loadItemTree', {
                  data: {
                    deviceIds: deviceIds.join(',')
                  }
                });
              case 1:
                res = _context4.v;
                data = (res === null || res === void 0 ? void 0 : res.data) || {};
                return _context4.a(2, (0, _utils.parseTreeData)(data.children || [], {
                  renderNode: function renderNode(node) {
                    var selectable = node.type === 'monitorItem';
                    return Object.assign(Object.assign({}, node), {
                      selectable: selectable,
                      title: node.name
                    });
                  },
                  filterEmptyNodes: function filterEmptyNodes() {
                    return null;
                  }
                }));
            }
          }, _callee4);
        }));
      }, {
        refreshDeps: [deviceIds]
      }),
      _useRequest6$data = _useRequest6.data,
      data = _useRequest6$data === void 0 ? [] : _useRequest6$data;
    return {
      data: data
    };
  },
  useCollectList: function useCollectList(_ref3) {
    var deviceIds = _ref3.deviceIds,
      monitorItemIds = _ref3.monitorItemIds;
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee5() {
          var res;
          return _regenerator().w(function (_context5) {
            while (1) switch (_context5.n) {
              case 0:
                if (!((0, _lodash.isEmpty)(deviceIds) || (0, _lodash.isEmpty)(monitorItemIds))) {
                  _context5.n = 1;
                  break;
                }
                return _context5.a(2, []);
              case 1:
                _context5.n = 2;
                return _utils.request.get('/cloud/device/monitor/factor/listCollectFrequency', {
                  data: {
                    deviceIds: deviceIds.join(','),
                    monitorItemIds: monitorItemIds.join(',')
                  }
                });
              case 2:
                res = _context5.v;
                return _context5.a(2, (res === null || res === void 0 ? void 0 : res.data) || []);
            }
          }, _callee5);
        }));
      }, {
        refreshDeps: [deviceIds, monitorItemIds]
      }),
      _useRequest7$data = _useRequest7.data,
      data = _useRequest7$data === void 0 ? [] : _useRequest7$data;
    return {
      data: data
    };
  },
  useGetAnalysis: function useGetAnalysis(_ref4) {
    var timeType = _ref4.timeType,
      danTimeEndTime = _ref4.danTimeEndTime,
      duoTimeType = _ref4.duoTimeType,
      duoTimeList = _ref4.duoTimeList,
      danTimeType = _ref4.danTimeType,
      danTimeStartTime = _ref4.danTimeStartTime,
      month = _ref4.month,
      year = _ref4.year,
      monitorItemIds = _ref4.monitorItemIds,
      deviceIds = _ref4.deviceIds,
      collectFrequency = _ref4.collectFrequency;
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee6() {
          var chartDataList, format, startTime, endTime, res, dataList, newDataList, _t;
          return _regenerator().w(function (_context6) {
            while (1) switch (_context6.n) {
              case 0:
                if (!((0, _lodash.isEmpty)(monitorItemIds) || (0, _lodash.isEmpty)(deviceIds) || !collectFrequency)) {
                  _context6.n = 1;
                  break;
                }
                return _context6.a(2, []);
              case 1:
                format = 'YYYY-MM-DD HH:mm:ss';
                if (!(timeType === 'danTime')) {
                  _context6.n = 12;
                  break;
                }
                //单时段
                startTime = '', endTime = '';
                _t = danTimeType;
                _context6.n = _t === '1h' ? 2 : _t === '24h' ? 3 : _t === '3days' ? 4 : _t === '7days' ? 5 : _t === 'self' ? 6 : _t === 'month' ? 7 : _t === 'year' ? 8 : 9;
                break;
              case 2:
                startTime = (0, _dayjs["default"])().subtract(1, 'hours').format(format);
                endTime = (0, _dayjs["default"])().format(format);
                return _context6.a(3, 10);
              case 3:
                startTime = (0, _dayjs["default"])().subtract(24, 'hours').format(format);
                endTime = (0, _dayjs["default"])().format(format);
                return _context6.a(3, 10);
              case 4:
                startTime = (0, _dayjs["default"])().subtract(3, 'days').format(format);
                endTime = (0, _dayjs["default"])().format(format);
                return _context6.a(3, 10);
              case 5:
                startTime = (0, _dayjs["default"])().subtract(7, 'days').format(format);
                endTime = (0, _dayjs["default"])().format(format);
                return _context6.a(3, 10);
              case 6:
                startTime = (0, _dayjs["default"])(danTimeStartTime).startOf('day').format(format);
                endTime = (0, _dayjs["default"])(danTimeEndTime).endOf('day').format(format);
                return _context6.a(3, 10);
              case 7:
                startTime = (0, _dayjs["default"])(month).startOf('month').startOf('day').format(format);
                endTime = (0, _dayjs["default"])(month).endOf('month').endOf('day').format(format);
                return _context6.a(3, 10);
              case 8:
                startTime = (0, _dayjs["default"])(year).startOf('year').startOf('day').format(format);
                endTime = (0, _dayjs["default"])(year).endOf('year').endOf('day').format(format);
                return _context6.a(3, 10);
              case 9:
                startTime = (0, _dayjs["default"])().subtract(1, 'hours').startOf('day').format(format);
                endTime = (0, _dayjs["default"])().endOf('day').format(format);
              case 10:
                _context6.n = 11;
                return _utils.request.get('/cloud/device/realtime/monitor/data/eCharts', {
                  data: {
                    deviceIds: deviceIds,
                    monitorItemIds: (monitorItemIds || []).join(','),
                    startTime: startTime,
                    endTime: endTime,
                    collectFrequency: collectFrequency
                  }
                });
              case 11:
                res = _context6.v;
                if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                  dataList = (res === null || res === void 0 ? void 0 : res.data) || [];
                  chartDataList = dataList.map(function (item) {
                    var values = item.values;
                    var xData = [],
                      yData = [],
                      markLine = [],
                      dataList = [];
                    var type = (item === null || item === void 0 ? void 0 : item.monitorItemDefaultChartType) || 'line';
                    if (values.length) {
                      values.map(function (one) {
                        xData.push(one.x);
                        yData.push(one.y);
                        dataList.push({
                          date: one.x,
                          value: type === 'stack' ? one.yformat || one.y : Number(one.y) ? Number(one.y) : one.y,
                          originValue: one.y
                        });
                        if (!markLine.map(function (m) {
                          return (0, _dayjs["default"])(m).format('YYYY-MM-DD');
                        }).includes((0, _dayjs["default"])(one.x).format('YYYY-MM-DD'))) {
                          markLine.push(one.x);
                        }
                      });
                    }
                    item.name = "".concat(item.typeChs ? "".concat(item.typeChs, "-") : '').concat(item.monitorItemName);
                    item.dataList = dataList;
                    item.markLine = markLine;
                    item.xData = xData;
                    item.yData = yData;
                    item.showMode = type;
                    var yDataList = yData.map(function (ele) {
                      return Number(ele);
                    });
                    item.maximumValue = _lodash["default"].max(yDataList);
                    item.minimumValue = _lodash["default"].min(yDataList);
                    return item;
                  });
                }
                _context6.n = 14;
                break;
              case 12:
                newDataList = [];
                _context6.n = 13;
                return Promise.all(duoTimeList.map(function (item) {
                  return _utils.request.get('/cloud/device/realtime/monitor/data/eCharts', {
                    data: {
                      startTime: (0, _dayjs["default"])(item.time).startOf(duoTimeType).format(format),
                      endTime: (0, _dayjs["default"])(item.time).endOf(duoTimeType).format(format),
                      deviceIds: deviceIds,
                      monitorItemIds: monitorItemIds,
                      collectFrequency: collectFrequency
                    }
                  }).then(function (res) {
                    if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
                      return {
                        time: item.time,
                        data: res.data || []
                      };
                    }
                    return [];
                  });
                })).then(function (dataList) {
                  newDataList = dataList.map(function (list) {
                    return ((list === null || list === void 0 ? void 0 : list.data) || []).map(function (one) {
                      return Object.assign(Object.assign({}, one), {
                        newName: "".concat(one.facilityName, "-").concat(one.name, "(").concat(list.time, ")")
                      });
                    }).map(function (item) {
                      var type = (item === null || item === void 0 ? void 0 : item.monitorItemDefaultChartType) || 'line';
                      var values = item.values;
                      var xData = [],
                        yData = [],
                        dataList = [];
                      if (values.length) {
                        values.map(function (one) {
                          xData.push(one.x);
                          yData.push(one.y);
                          dataList.push({
                            date: one.x,
                            value: type === 'stack' ? one.yformat || one.y : Number(one.y),
                            originValue: one.y
                          });
                        });
                      }
                      item.dataList = dataList;
                      item.showMode = type;
                      item.xData = xData;
                      item.yData = yData;
                      var yDataList = yData.map(function (ele) {
                        return Number(ele);
                      });
                      item.maximumValue = _lodash["default"].max(yDataList);
                      item.minimumValue = _lodash["default"].min(yDataList);
                      return item;
                    });
                  }).flat();
                });
              case 13:
                chartDataList = sortClass(newDataList, 'name').map(function (item) {
                  return {
                    showMode: 'chart',
                    list: item
                  };
                });
              case 14:
                return _context6.a(2, chartDataList);
            }
          }, _callee6);
        }));
      }, {
        refreshDeps: [timeType, danTimeEndTime, duoTimeType, duoTimeList, danTimeType, danTimeStartTime, month, year, monitorItemIds, deviceIds, collectFrequency]
      }),
      _useRequest8$data = _useRequest8.data,
      data = _useRequest8$data === void 0 ? [] : _useRequest8$data,
      loading = _useRequest8.loading;
    return {
      data: data,
      loading: loading
    };
  }
};
//# sourceMappingURL=api.js.map
