"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getContactList = 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';
  var extraHeader = arguments.length > 3 ? arguments[3] : undefined;
  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: extraHeader
          });
        case 1:
          res = _context.v;
          return _context.a(2, res === null || res === void 0 ? void 0 : res.data);
      }
    }, _callee);
  }));
};
var getContactList = exports.getContactList = function getContactList(params) {
  return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
    var data, dataSource, total;
    return _regenerator().w(function (_context2) {
      while (1) switch (_context2.n) {
        case 0:
          _context2.n = 1;
          return query('/cloud/cc-reborn/api/v101/app/contractManagement/page', Object.assign({}, params));
        case 1:
          data = _context2.v;
          dataSource = [], total = 0;
          if (Array.isArray(data === null || data === void 0 ? void 0 : data.rows)) {
            dataSource = data.rows.map(function (item) {
              return Object.assign(Object.assign({}, item), {
                key: item.id
              });
            });
            total = data.total;
          }
          return _context2.a(2, {
            total: total,
            list: dataSource
          });
      }
    }, _callee2);
  }));
};
var BasicService = exports.BasicService = {
  // 详情
  info: function info(_ref) {
    var id = _ref.id;
    var _a, _b, _c, _d;
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/restaurant/get', {
          id: id,
          coordinateType: 'wgs84'
        }, 'get', {
          desensitized: true
        });
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest.data;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: 'restaurant'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      tabConfig = _useRequest2.data;
    return {
      basicInfo: data || {},
      tabIsFilter: !!((_b = (_a = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _a === void 0 ? void 0 : _a.popupConfigJson) === null || _b === void 0 ? void 0 : _b.length),
      tabConfig: ((_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.filter(function (ele) {
        return ele.display;
      }).map(function (ele) {
        return Object.assign(Object.assign({}, ele), {
          key: ele.code,
          title: ele.name
        });
      })) || [],
      visited: !!tabConfig
    };
  },
  contactInfo: function contactInfo(_ref2) {
    var id = _ref2.id;
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return (0, _tslib.__awaiter)(void 0, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
          var info, collectUnitByUser, signatureInfo;
          return _regenerator().w(function (_context3) {
            while (1) switch (_context3.n) {
              case 0:
                _context3.n = 1;
                return query('/cloud/cc-reborn/api/v101/app/contractManagement/get', {
                  id: id,
                  coordinateType: 'wgs84'
                }, 'get', {
                  desensitized: true
                });
              case 1:
                info = _context3.v;
                _context3.n = 2;
                return query('/cloud/management/api/v101/userAuth/getUserInfo', {});
              case 2:
                collectUnitByUser = _context3.v;
                _context3.n = 3;
                return query('/cloud/cc-reborn/api/v101/collectUnit/getSign', {
                  id: collectUnitByUser === null || collectUnitByUser === void 0 ? void 0 : collectUnitByUser.deptOrgId
                });
              case 3:
                signatureInfo = _context3.v;
                return _context3.a(2, Object.assign(Object.assign({}, signatureInfo || {}), info || {}));
            }
          }, _callee3);
        }));
      }, {
        refreshDeps: [id],
        ready: !!id
      }),
      data = _useRequest3.data;
    return data || {};
  },
  // 班次
  getPeriodList: function getPeriodList(_ref3) {
    var restaurantId = _ref3.restaurantId,
      startDay = _ref3.startDay,
      endDay = _ref3.endDay;
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/collectPeriod/getPeriodListByRestaurantId', {
          restaurantId: restaurantId,
          startDay: startDay,
          endDay: endDay
        });
      }, {
        refreshDeps: [restaurantId, startDay, endDay],
        ready: !!restaurantId
      }),
      data = _useRequest4.data;
    return data || [];
  },
  // 收运记录
  detailList: function detailList(_ref4) {
    var id = _ref4.id,
      startTime = _ref4.startTime,
      endTime = _ref4.endTime,
      garbageType = _ref4.garbageType;
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/rtCarDataDetail/list', {
          restaurantId: id,
          queryStartTime: startTime,
          queryEndTime: endTime,
          ccGarbageType: garbageType
        });
      }, {
        refreshDeps: [id, startTime, endTime, garbageType],
        ready: !!id
      }),
      data = _useRequest5.data;
    return data;
  },
  // 收运汇总
  summary: function summary(_ref5) {
    var id = _ref5.id,
      startDay = _ref5.startDay,
      endDay = _ref5.endDay,
      garbageType = _ref5.garbageType;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/gisOnePage/getRestaurantDaySummary', {
          restaurantId: id,
          startDay: startDay,
          endDay: endDay,
          garbageType: garbageType
        });
      }, {
        refreshDeps: [id, startDay, endDay, garbageType],
        ready: !!id
      }),
      data = _useRequest6.data;
    return data;
  },
  getCarRouteList: function getCarRouteList(syPointId) {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return query("/cloud/cc-reborn/api/v101/carRoute/list", {
          syPointId: syPointId
        });
      }, {
        refreshDeps: [syPointId],
        ready: !!syPointId
      }),
      _useRequest7$data = _useRequest7.data,
      data = _useRequest7$data === void 0 ? [] : _useRequest7$data;
    return data;
  },
  getSyPointMonthDetail: function getSyPointMonthDetail(pointId, startDay, month) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return query("/cloud/cc-reborn/api/v101/carRoute/getSyPointMonthDetail", {
          pointId: pointId,
          startDay: startDay,
          month: month
        });
      }, {
        refreshDeps: [pointId, startDay, month],
        ready: !!pointId
      }),
      _useRequest8$data = _useRequest8.data,
      data = _useRequest8$data === void 0 ? [] : _useRequest8$data;
    return data;
  },
  getConfigData: function getConfigData() {
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return query("/cloud/cc-reborn/api/v101/restaurantDataConfig/list");
      }),
      _useRequest9$data = _useRequest9.data,
      data = _useRequest9$data === void 0 ? [] : _useRequest9$data;
    return data;
  }
};
var AlarmService = exports.AlarmService = {
  typeAnalysis: function typeAnalysis(_ref6) {
    var id = _ref6.id,
      startDate = _ref6.startDate,
      endDate = _ref6.endDate;
    var _useRequest0 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/gisOnePage/getAbnormalTypeNums', {
          restaurantId: id,
          startDay: startDate,
          endDay: endDate
        });
      }, {
        refreshDeps: [id, startDate, endDate],
        ready: !!id
      }),
      _useRequest0$data = _useRequest0.data,
      data = _useRequest0$data === void 0 ? [] : _useRequest0$data;
    return data;
  },
  alarmTrend: function alarmTrend(_ref7) {
    var id = _ref7.id,
      startDate = _ref7.startDate,
      endDate = _ref7.endDate;
    var _useRequest1 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/gisOnePage/getAbnormalDayNums', {
          restaurantId: id,
          startDay: startDate,
          endDay: endDate
        });
      }, {
        refreshDeps: [id, startDate, endDate],
        ready: !!id
      }),
      _useRequest1$data = _useRequest1.data,
      data = _useRequest1$data === void 0 ? [] : _useRequest1$data;
    return data;
  },
  // 报警明细
  alarmRecord: function alarmRecord(_ref8) {
    var id = _ref8.id,
      startDate = _ref8.startDate,
      endDate = _ref8.endDate;
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return query('/cloud/cc-reborn/api/v101/workBench/abnormalEventRecordPage', {
          page: 0,
          size: 10000,
          alarmObjId: id,
          queryStartTime: (0, _moment["default"])(startDate).format('YYYY-MM-DD 00:00:00'),
          queryEndTime: (0, _moment["default"])(endDate).format('YYYY-MM-DD 23:59:59')
        });
      }, {
        refreshDeps: [id, startDate, endDate],
        ready: !!id
      }),
      data = _useRequest10.data;
    return data || {
      total: 0,
      rows: []
    };
  }
};
//# sourceMappingURL=api.js.map
