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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
var BaseService = {
  useBaseInfo: function useBaseInfo(id) {
    var _baseInfoRes$data, _info$timePeriods;
    var _useRequest = useRequest(function () {
        return request.get('/cloud/jcss-reborn/facility/get', {
          data: {
            id: id,
            coordType: 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var info = _objectSpread(_objectSpread({}, baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data), baseInfoRes === null || baseInfoRes === void 0 || (_baseInfoRes$data = baseInfoRes.data) === null || _baseInfoRes$data === void 0 ? void 0 : _baseInfoRes$data.dataJson);
    var baseInfo = [{
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }, {
      label: '设施类型',
      key: 'facilityClassName',
      value: info === null || info === void 0 ? void 0 : info.facilityClassName
    }, {
      label: '所属小区',
      key: 'housingEstateName',
      value: info === null || info === void 0 ? void 0 : info.housingEstateName
    }, {
      label: '垃圾类型',
      key: 'garbageTypeName',
      value: info === null || info === void 0 ? void 0 : info.garbageTypeName
    }, {
      label: '投放时间',
      key: 'householdNum',
      value: info === null || info === void 0 || (_info$timePeriods = info.timePeriods) === null || _info$timePeriods === void 0 || (_info$timePeriods = _info$timePeriods.map(function (ele) {
        return "".concat(ele.startTime, "~").concat(ele.endTime);
      })) === null || _info$timePeriods === void 0 ? void 0 : _info$timePeriods.join('、')
    }, {
      label: '督导员',
      key: 'supervisorName',
      value: info === null || info === void 0 ? void 0 : info.supervisorName
    }];
    var photos = info !== null && info !== void 0 && info.photoIds ? JSON.parse(info.photoIds) : info !== null && info !== void 0 && info.typePhotoIds ? JSON.parse(info.typePhotoIds) : [];
    return {
      info: info,
      baseInfo: baseInfo,
      photos: photos
    };
  },
  useDeviceInfo: function useDeviceInfo(id) {
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/ljfljc/api/v101/equipment/list', {
          data: {
            throwPointId: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      res = _useRequest2.data;
    return {
      devices: res === null || res === void 0 ? void 0 : res.data
    };
  },
  useThrowInfo: function useThrowInfo(throwPointId, dateType, startDate, endDate) {
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/ljfljc/api/v101/throwBoard/throwAnalysis', {
          data: {
            throwPointId: throwPointId,
            dateType: dateType,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!throwPointId,
        refreshDeps: [throwPointId, dateType, startDate, endDate]
      }),
      res = _useRequest3.data;
    return {
      throwAnalysis: res === null || res === void 0 ? void 0 : res.data
    };
  },
  useAlarmInfo: function useAlarmInfo(throwPointId, dateType, startDate, endDate) {
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/ljfljc/api/v101/throwBoard/violationAnalysis', {
          data: {
            throwPointId: throwPointId,
            dateType: dateType,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!throwPointId,
        refreshDeps: [throwPointId, dateType, startDate, endDate]
      }),
      res = _useRequest4.data;
    return {
      alarmAnalysis: res === null || res === void 0 ? void 0 : res.data
    };
  }
};
export { BaseService };