"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WorkCondition = exports.WeighData = exports.BaseData = exports.Audio = void 0;

var _utils = require("@vtx/utils");

var _ahooks = require("ahooks");

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _getUrlParam = (0, _utils.getUrlParam)(),
    tenantId = _getUrlParam.tenantId;

var BaseData = {
  useBaseInfo: function useBaseInfo(id, setCode) {
    var _useRequest = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/jcss-reborn/facility/get', {
        data: {
          id: id,
          coordType: 'bd09'
        }
      });
    }, {
      refreshDeps: [id]
    }),
        baseInfoRes = _useRequest.data;

    var baseInfo = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    setCode("".concat(baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.typeCode, "_").concat(baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.code)); // 基础信息

    var info = [{
      label: '名称',
      key: 'name',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.name
    }, {
      label: '收集点编码',
      key: 'code',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.code
    }, {
      label: '管理单位',
      key: 'manageUnitName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.manageUnitName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.divisionName
    }, {
      label: '收运单位',
      key: 'collectUnitName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.collectUnitName
    }, {
      label: '地址',
      key: 'address',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.address
    }]; // 图片

    var photos = JSON.parse((baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.photoIds) || '[]');
    return {
      info: info,
      photos: photos
    };
  }
};
exports.BaseData = BaseData;
var WeighData = {
  // 列表统计
  useWeighStat: function useWeighStat(id, startTime, endTime, page, size, code) {
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/zd/lm/api/cp/zdjgLmWeighData/summary.smvc', {
        data: {
          id: id,
          startTime: startTime,
          endTime: endTime,
          tenantId: tenantId,
          page: page,
          size: size,
          disposeUnitCode: code.split('_')[1]
        }
      });
    }, {
      refreshDeps: [id, startTime, endTime, page, size]
    }),
        data = _useRequest2.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  // 列表数据
  useWeighList: function useWeighList(id, startTime, endTime, page, size, code) {
    return _utils.request.get('/cloud/zd/lm/api/cp/zdjgLmWeighData/pageList.smvc', {
      data: {
        id: id,
        page: page,
        rows: size,
        startTime: startTime,
        endTime: endTime,
        beenPermission: 'false',
        disposeUnitCode: code.split('_')[1]
      }
    }).then(function (res) {
      if (res.result === 0) {
        res.data.list = res.data.rows;
      }

      return res.data;
    });
  },
  // 列表导出
  useWeighExport: function useWeighExport(params) {
    return (0, _utils.downloadFile)('/cloud/zd/lm/api/cp/zdjgLmWeighData/exportData.smvc', {
      data: _objectSpread(_objectSpread({}, params), {}, {
        tenantId: tenantId,
        beenPermission: 'false'
      })
    }, 'blob');
  },
  // 图表数据
  useEchartsList: function useEchartsList(id, startTime, endTime) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/zd/lm/api/np/weighSummary/sumDataByDate.smvc', {
        data: {
          id: id,
          startDate: startTime,
          endDate: endTime,
          tenantId: tenantId
        }
      });
    }, {
      refreshDeps: [id, startTime, endTime]
    }),
        data = _useRequest3.data;

    return data === null || data === void 0 ? void 0 : data.data;
  }
};
exports.WeighData = WeighData;
var WorkCondition = {
  // 图表数据
  useEchartsTrend: function useEchartsTrend(startTime, endTime, collectFrequency, deviceId, monitorTypeCodes) {
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/zd/jg/api/cp/historyValue/eCharts.smvc', {
        data: {
          tenantId: tenantId,
          startDateTime: startTime,
          endDateTime: endTime,
          collectFrequency: collectFrequency,
          deviceId: deviceId,
          monitorTypeCodes: monitorTypeCodes
        }
      });
    }, {
      refreshDeps: [startTime, endTime, deviceId, monitorTypeCodes]
    }),
        data = _useRequest4.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  // 左上角页签值
  useDeviceList: function useDeviceList(selectKey) {
    return _utils.request.get('/cloud/zd/jg/api/cp/monitorType/getMonitorTypesByDeviceId.smvc', {
      data: {
        deviceId: selectKey,
        tenantId: tenantId
      }
    });
  },
  // 监测点下拉
  useSelectList: function useSelectList(id) {
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/zd/jg/api/np/device/select.smvc', {
        data: {
          factoryId: id,
          tenantId: tenantId
        }
      });
    }, {
      refreshDeps: [id]
    }),
        data = _useRequest5.data;

    return data === null || data === void 0 ? void 0 : data.data;
  }
};
exports.WorkCondition = WorkCondition;
var Audio = {
  // 下拉列表
  useVisTree: function useVisTree(code) {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/vis/base/np/videoCommon/loadVideoInfos.smvc', {
        data: {
          tenantId: tenantId,
          billId: code
        }
      });
    }),
        data = _useRequest6.data;

    return data === null || data === void 0 ? void 0 : data.data;
  }
};
exports.Audio = Audio;
//# sourceMappingURL=api.js.map
