"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SxyxService = exports.SjfxService = exports.SbxlService = exports.BasicService = exports.AlarmService = void 0;
var _tslib = require("tslib");
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 query = function query(url, params) {
  var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'get';
  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[method](url, {
            data: params,
            extraHeader: {
              tenantId: (0, _utils.getVtxToken)('tenantId')
            }
          });
        case 1:
          res = _context.v;
          return _context.a(2, res === null || res === void 0 ? void 0 : res.data);
      }
    }, _callee);
  }));
};
var BasicService = exports.BasicService = {
  //基础设施详情展示字段
  viewDetail: function viewDetail(code) {
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return query('/cloud/jcss-reborn/facility/type/view/detail', {
          code: code
        });
      }, {
        refreshDeps: [code],
        ready: !!code
      }),
      data = _useRequest.data;
    return data || {};
  },
  // 基础设施详情：泵房
  facilityInfo: function facilityInfo(_ref) {
    var id = _ref.id;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/jcss-reborn/facility/get', {
          id: id,
          desensitization: false,
          coordType: 'bd09',
          url: window.location.origin
        });
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest2.data;
    return data || {};
  },
  getTabList: function getTabList(_ref2) {
    var typeCode = _ref2.typeCode;
    var _a, _b, _c, _d, _e, _f, _g;
    var res = (0, _ahooks.useRequest)(function () {
      return query('/cloud/jcss-reborn/facility/type/config/getByCode', {
        code: typeCode
      });
    }, {
      refreshDeps: [typeCode],
      ready: !!typeCode
    });
    var tabIsFilter = !!((_c = (_b = (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.popupConfigJson) === null || _c === void 0 ? void 0 : _c.length);
    var tabConfig = ((_g = (_f = (_e = (_d = res === null || res === void 0 ? void 0 : res.data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.popupConfigJson) === null || _f === void 0 ? void 0 : _f.filter(function (ele) {
      return ele.display;
    })) === null || _g === void 0 ? void 0 : _g.map(function (ele) {
      return {
        key: ele.code,
        title: ele.name
      };
    })) || [];
    return {
      tabIsFilter: tabIsFilter,
      tabConfig: tabConfig
    };
  },
  // 视频
  hasVideo: function hasVideo(_ref3) {
    var billId = _ref3.billId;
    return query('/cloud/vis/base/np/videoCommon/loadVideoInfos.smvc', {
      billId: billId
    }).then(function (res) {
      return res;
    });
  },
  //配件信息
  pjList: function pjList(jcssId) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/ecgs/api/record/pumpAccessoryInfo/list', {
          jcssId: jcssId
        });
      }, {
        refreshDeps: [jcssId],
        ready: !!jcssId
      }),
      data = _useRequest3.data;
    return data || [];
  },
  //小区信息
  xqInfo: function xqInfo(id) {
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/ecgs/api/kanban/zh/management/jcss/gsxq/get', {
          id: id
        });
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest4.data;
    return data || {};
  },
  //加压区信息
  jyqInfo: function jyqInfo(id) {
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/ecgs/api/kanban/zh/management/jcss/device/get', {
          id: id
        });
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest5.data;
    return data || [];
  },
  //水箱信息
  sxInfo: function sxInfo(id) {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/ecgs/api/kanban/zh/management/jcss/water/tank/get', {
          id: id
        });
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest6.data;
    return data || [];
  },
  // 数据类型
  dataType: function dataType() {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/device/entity/dataTypeSelect', {});
      }),
      data = _useRequest7.data;
    return data || [];
  }
};
//水箱运行
var SxyxService = exports.SxyxService = {
  //水箱信息
  sxyxData: function sxyxData(pumpId) {
    return query('/cloud/ecgs/api/kanban/zh/management/pump/water/tank/list', {
      pumpId: pumpId
    }).then(function (data) {
      return data || [];
    });
  },
  //液位趋势分析
  ywTrendData: function ywTrendData(_ref4) {
    var ids = _ref4.ids;
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/ecgs/common/monitorCount', {
          facilityIds: ids,
          startTime: (0, _moment["default"])().startOf('day').format('YYYY-MM-DD HH:mm:ss'),
          endTime: (0, _moment["default"])().endOf('day').format('YYYY-MM-DD HH:mm:ss'),
          monitorItemCode: 'w_rg_108',
          collectFrequency: 'hour'
        });
      }, {
        refreshDeps: [ids],
        ready: !!ids
      }),
      data = _useRequest8.data;
    return data || [];
  }
};
//数据分析
var SjfxService = exports.SjfxService = {
  //根据泵房获取监测类型
  monitorTypeList: function monitorTypeList(pumpId) {
    return query('/cloud/ecgs/common/monitor/type/list', {
      pumpId: pumpId
    }).then(function (data) {
      return data || [];
    });
  },
  //左侧监测项目数据
  leftTableData: function leftTableData(_ref5) {
    var pumpId = _ref5.pumpId,
      monitorTypeId = _ref5.monitorTypeId;
    return query('/cloud/ecgs/api/kanban/zh/management/pump/data/fx/list', {
      pumpId: pumpId,
      monitorTypeId: monitorTypeId
    }).then(function (data) {
      return data || [];
    });
  },
  //右侧趋势图
  rightTrendData: function rightTrendData(_ref6) {
    var startTime = _ref6.startTime,
      endTime = _ref6.endTime,
      monitorItemCode = _ref6.monitorItemCode,
      collectFrequency = _ref6.collectFrequency,
      facilityIds = _ref6.facilityIds;
    return query('/cloud/ecgs/common/monitorCount', {
      startTime: startTime,
      endTime: endTime,
      monitorItemCode: monitorItemCode,
      collectFrequency: collectFrequency,
      facilityIds: facilityIds
    }).then(function (data) {
      return data || [];
    });
  },
  // 获取时间段
  listCollectFrequency: function listCollectFrequency(pumpId, monitorTypeIds) {
    return query('/cloud/device/monitor/factor/listCollectFrequency', {
      facilityIds: pumpId,
      deviceTypeIds: 'PRESSURE_DEVICE',
      collectFrequencies: 'realtime,minute1,minute5,minute10,minute15,hour',
      monitorTypeIds: monitorTypeIds
    }).then(function (data) {
      return data || [];
    });
  }
};
//报警记录
var AlarmService = exports.AlarmService = {
  //当前报警-报警list
  alarmList: function alarmList(_ref7) {
    var facilityIds = _ref7.facilityIds,
      alarmStartTimeBegin = _ref7.alarmStartTimeBegin,
      alarmStartTimeEnd = _ref7.alarmStartTimeEnd,
      dimension = _ref7.dimension,
      alarmTypes = _ref7.alarmTypes;
    return query('/cloud/device/alarmInfo/list', JSON.stringify({
      facilityIds: facilityIds,
      alarmStartTimeBegin: alarmStartTimeBegin,
      alarmStartTimeEnd: alarmStartTimeEnd,
      // alarmEndTimeBegin,
      // alarmEndTimeEnd,
      dimension: dimension,
      deviceTypeIds: ['PRESSURE_DEVICE'],
      alarmTypes: alarmTypes
    }), 'post').then(function (data) {
      return data || [];
    });
  },
  //趋势
  trend: function trend(_ref8) {
    var facilityIds = _ref8.facilityIds,
      alarmStartTimeBegin = _ref8.alarmStartTimeBegin,
      alarmStartTimeEnd = _ref8.alarmStartTimeEnd,
      dimension = _ref8.dimension,
      alarmTypes = _ref8.alarmTypes,
      type = _ref8.type;
    return query('/cloud/device/alarmInfo/trend', JSON.stringify({
      facilityIds: facilityIds,
      alarmStartTimeBegin: alarmStartTimeBegin,
      alarmStartTimeEnd: alarmStartTimeEnd,
      dimension: dimension,
      alarmTypes: alarmTypes,
      type: type,
      deviceTypeIds: ['PRESSURE_DEVICE']
    }), 'post').then(function (data) {
      return data || [];
    });
  },
  //枚举
  enumList: function enumList(className) {
    return query('/cloud/device/common/enumList', {
      className: className
    }).then(function (data) {
      return data || [];
    });
  }
};
//水泵效率
var SbxlService = exports.SbxlService = {
  //区位信息
  jyqInfo: function jyqInfo(id) {
    return query('/cloud/ecgs/api/kanban/zh/management/jcss/device/get', {
      id: id
    }).then(function (data) {
      return data || [];
    });
  },
  //水泵效率分析
  sbxlfx: function sbxlfx(_ref9) {
    var facilityId = _ref9.facilityId,
      deviceId = _ref9.deviceId,
      startTime = _ref9.startTime,
      endTime = _ref9.endTime;
    return query('/cloud/ecgs/api/kanban/zh/management/efficiency/duration', {
      facilityId: facilityId,
      deviceId: deviceId,
      startTime: startTime,
      endTime: endTime
    }).then(function (data) {
      return data || [];
    });
  },
  //水泵效率分析
  findWaterPumpDayEfficiencyRecord: function findWaterPumpDayEfficiencyRecord(_ref0) {
    var facilityId = _ref0.facilityId,
      deviceId = _ref0.deviceId,
      begin = _ref0.begin,
      end = _ref0.end;
    return query('/cloud/ecgs/api/waterPumpRunStatistic/findWaterPumpDayEfficiencyRecord', {
      facilityId: facilityId,
      deviceId: deviceId,
      begin: begin,
      end: end
    }).then(function (data) {
      return data || [];
    });
  },
  //水泵运行情况
  sbyxqk: function sbyxqk(_ref1) {
    var facilityId = _ref1.facilityId,
      deviceId = _ref1.deviceId,
      startTime = _ref1.startTime,
      endTime = _ref1.endTime;
    return query('/cloud/ecgs/api/kanban/zh/management/yx/duration', {
      facilityId: facilityId,
      deviceId: deviceId,
      startTime: startTime,
      endTime: endTime
    }).then(function (data) {
      return data || [];
    });
  },
  //水泵运行情况
  findWaterPumpRunView: function findWaterPumpRunView(_ref10) {
    var facilityId = _ref10.facilityId,
      deviceId = _ref10.deviceId,
      begin = _ref10.begin,
      end = _ref10.end;
    return query('/cloud/ecgs/api/waterPumpRunStatistic/findWaterPumpRunView', {
      facilityId: facilityId,
      deviceId: deviceId,
      begin: begin,
      end: end
    }).then(function (data) {
      return data || [];
    });
  }
};
//# sourceMappingURL=api.js.map
