"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ThrowData = exports.DeviceData = exports.CollectData = exports.BaseData = 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 BaseData = {
  useBaseInfo: function useBaseInfo(id) {
    var _useRequest = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/throwPoint/queryById', {
        data: {
          id: id,
          coordinateType: 'bd09'
        }
      });
    }, {
      refreshDeps: [id]
    }),
        baseInfoRes = _useRequest.data;

    var baseInfo = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    /** 基础信息 */

    var info = [{
      label: '名称',
      key: 'pointName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.pointName
    }, {
      label: '投放点类型',
      key: 'pointTypeDesc',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.pointTypeDesc
    }, {
      label: '所属小区',
      key: 'jcssName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.jcssName
    }, {
      label: '行政区划',
      key: 'classTypeName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.divisionName
    }, {
      label: '投放点地址',
      key: 'specificAddress',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.specificAddress
    }, {
      label: '投放时段',
      key: 'implementTime',
      value: ((baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.pointThrowPeriods) || []).map(function (res) {
        return res.startTime + ' ~ ' + res.endTime;
      }).join(',')
    }];
    var coords = (baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.latLngDTO.lngLats.split(',').map(function (i) {
      return Number(i);
    })) || null;
    return {
      info: info,
      coords: coords
    };
  },
  useBaseProdStat: function useBaseProdStat(id, start, end) {
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/throwDataAnalysis/productionAnalysis', {
        data: {
          jcssId: id,
          startDate: start,
          endDate: end
        }
      });
    }, {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest2.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  useBaseProdTrend: function useBaseProdTrend(id, start, end) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/throwDataAnalysis/productionTrend', {
        data: {
          jcssId: id,
          startDate: start,
          endDate: end,
          dateDimension: 'day'
        }
      });
    }, {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest3.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  getGarbageType: function getGarbageType() {
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/jcss-reborn/garbageType/list', {});
    }),
        data = _useRequest4.data;

    return data === null || data === void 0 ? void 0 : data.data;
  }
};
exports.BaseData = BaseData;
var ThrowData = {
  useThrowList: function useThrowList(_ref, _ref2) {
    var page = _ref.page,
        size = _ref.size;
    var id = _ref2.id,
        start = _ref2.start,
        end = _ref2.end;

    var _useRequest5 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/trow/record/detail/page', {
        data: {
          page: page,
          size: size,
          subjectId: id,
          startTime: start,
          endTime: end,
          beenPermission: 'false'
        }
      });
    }, {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest5.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  getThrowList: function getThrowList(page, size, id, start, end) {
    return _utils.request.get('/cloud/ljfljc/api/v101/trow/record/detail/page', {
      data: {
        page: page,
        size: size,
        subjectId: id,
        startTime: start,
        endTime: end,
        beenPermission: 'false'
      }
    }).then(function (res) {
      if (res.result === 0) {
        res.data.list = res.data.rows;
      }

      return res.data;
    });
  },
  getSum: function getSum() {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/trow/record/detail/sum', {});
    }),
        data = _useRequest6.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  exportData: function exportData(params) {
    return (0, _utils.downloadFile)('/cloud/ljfljc/api/v101/trow/record/detail/export', {
      data: _objectSpread(_objectSpread({}, params), {}, {
        beenPermission: 'false'
      })
    }, 'blob');
  }
};
exports.ThrowData = ThrowData;
var DeviceData = {
  deviceList: function deviceList(id) {
    var _useRequest7 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/equipment/select', {
      data: {
        throwPointId: id
      }
    }), {
      refreshDeps: [id]
    }),
        data = _useRequest7.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  deviceData: function deviceData(id) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/equipment/get', {
        data: {
          id: id
        }
      });
    }, {
      refreshDeps: [id]
    }),
        baseInfoRes = _useRequest8.data;

    var baseInfo = (baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) || {};
    /** 基础信息 */

    var info = [{
      label: '设备编码',
      key: 'code',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.code
    }, {
      label: '设备名称',
      key: 'name',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.name
    }, {
      label: '设备类型',
      key: 'typeName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.typeName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.divisionName
    }, {
      label: '所属主体名称',
      key: 'housingEstateName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.housingEstateName
    }, {
      label: '所属投放点',
      key: 'throwPointName',
      value: baseInfo.throwPointName
    }, {
      label: '投用时间',
      key: 'putTime',
      value: baseInfo.putTime
    }, {
      label: '运营单位',
      key: 'operateUnitName',
      value: baseInfo.operateUnitName
    }, {
      label: '负责人',
      key: 'inChargeStaffName',
      value: baseInfo.inChargeStaffName
    }, {
      label: '联系电话',
      key: 'contactTel',
      value: baseInfo.contactTel
    }];
    return {
      info: info
    };
  },
  getThrowList: function getThrowList(page, size, id, start, end) {
    return _utils.request.get('/cloud/ljfljc/api/v101/trow/record/detail/page', {
      data: {
        page: page,
        size: size,
        subjectId: id,
        startTime: start,
        endTime: end,
        beenPermission: 'false'
      }
    }).then(function (res) {
      if (res.result === 0) {
        res.data.list = res.data.rows;
      }

      return res.data;
    });
  },
  overflowList: function overflowList(id, start, end) {
    var _useRequest9 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/overflowRecord/page', {
      data: {
        throwPointId: id,
        startDate: start,
        endDate: end
      }
    }), {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest9.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  operation: function operation(id, month) {
    var _useRequest10 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/equipment/getOperationCalendar', {
      data: {
        equipmentId: id,
        month: month
      }
    }), {
      refreshDeps: [id, month]
    }),
        data = _useRequest10.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  useThrowStat: function useThrowStat(id, start, end) {
    var _useRequest11 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/throwDataAnalysis/memberAnalysis', {
      data: {
        jcssId: id,
        startDate: start,
        endDate: end
      }
    }), {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest11.data;

    return data === null || data === void 0 ? void 0 : data.data;
  }
};
exports.DeviceData = DeviceData;
var CollectData = {
  deviceList: function deviceList(id) {
    var _useRequest12 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/equipment/select', {
      data: {
        throwPointId: id
      }
    }), {
      refreshDeps: [id]
    }),
        data = _useRequest12.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  collectDataList: function collectDataList(_ref3) {
    var page = _ref3.page,
        size = _ref3.size,
        id = _ref3.id,
        start = _ref3.start,
        end = _ref3.end,
        productTypeIds = _ref3.productTypeIds;
    return _utils.request.get('/cloud/ljsy-reborn/api/collect/record/detail/page', {
      data: {
        collectPointIds: id,
        startTime: start,
        endTime: end,
        productTypeIds: productTypeIds,
        page: page,
        size: size
      }
    }).then(function (res) {
      if (res.result === 0) {
        res.data.list = res.data.rows;
      }

      return res.data;
    });
  },
  getSum: function getSum(id, start, end, productTypeIds) {
    var _useRequest13 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljsy-reborn/api/collect/record/detail/sum', {
      data: {
        collectPointIds: id,
        startTime: start,
        endTime: end,
        productTypeIds: productTypeIds
      }
    }), {
      refreshDeps: [id]
    }),
        data = _useRequest13.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  exportData: function exportData(params) {
    return (0, _utils.downloadFile)('/cloud/ljsy-reborn/api/collect/record/detail/exportExcel', {
      data: _objectSpread(_objectSpread({}, params), {}, {
        beenPermission: 'false'
      })
    }, 'blob');
  }
};
exports.CollectData = CollectData;
//# sourceMappingURL=api.js.map
