"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ThrowData = 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 _baseInfo$geometryInf, _baseInfo$geometryInf2;

    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;

    var _useRequest2 = (0, _ahooks.useRequest)(function () {
      return _utils.request.get('/cloud/ljfljc/api/v101/community/getStatistics', {
        data: {
          jcssId: id
        }
      });
    }, {
      refreshDeps: [id]
    }),
        statInfoRes = _useRequest2.data;

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

    var info = [{
      label: '行政区划',
      key: 'divisionName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.divisionName
    }, {
      label: '居民户数（户）',
      key: 'householdNum',
      value: statInfo === null || statInfo === void 0 ? void 0 : statInfo.householdNum
    }, {
      label: '居民人数（人）',
      key: 'peopleNum',
      value: statInfo === null || statInfo === void 0 ? void 0 : statInfo.personNum
    }, {
      label: '小区类型',
      key: 'classTypeName',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.dataJson.classTypeName
    }, {
      label: '地址',
      key: 'address',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.address
    }, {
      label: '分类开始时间',
      key: 'implementTime',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.dataJson.implementTime
    }, {
      label: '投放点数量（个）',
      key: 'throwPointNum',
      value: statInfo === null || statInfo === void 0 ? void 0 : statInfo.throwPointNum
    }, {
      label: '责任人',
      key: 'sqzrr',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.dataJson.sqzrr
    }, {
      label: '联系方式',
      key: 'sqzrrlxfs',
      value: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.dataJson.sqzrrlxfs
    }];
    var coords = (baseInfo === null || baseInfo === void 0 ? void 0 : (_baseInfo$geometryInf = baseInfo.geometryInfo) === null || _baseInfo$geometryInf === void 0 ? void 0 : (_baseInfo$geometryInf2 = _baseInfo$geometryInf.lngLats) === null || _baseInfo$geometryInf2 === void 0 ? void 0 : _baseInfo$geometryInf2.split(',').map(function (i) {
      return Number(i);
    })) || null;
    return {
      info: info,
      coords: coords
    };
  },
  useBaseProdStat: function useBaseProdStat(id, start, end) {
    var _useRequest3 = (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 = _useRequest3.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  useBaseProdTrend: function useBaseProdTrend(id, start, end) {
    var _useRequest4 = (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 = _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;
    });
  },
  useThrowStat: function useThrowStat(id, start, end) {
    var _useRequest6 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljfljc/api/v101/throwDataAnalysis/memberAnalysis', {
      data: {
        jcssId: id,
        startDate: start,
        endDate: end
      }
    }), {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest6.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  useCollectStat: function useCollectStat(id, start, end) {
    var _useRequest7 = (0, _ahooks.useRequest)(_utils.request.get('/cloud/ljsy-reborn/api/collect/record/detail/sum', {
      data: {
        collectPointIds: id,
        startTime: start,
        endTime: end
      }
    }), {
      refreshDeps: [id, start, end]
    }),
        data = _useRequest7.data;

    return data === null || data === void 0 ? void 0 : data.data;
  },
  getCollectList: function getCollectList(page, size, id, start, end) {
    return _utils.request.get('/cloud/ljsy-reborn/api/collect/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;
    });
  },
  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;
//# sourceMappingURL=api.js.map
