"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BaseService = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var BaseService = exports.BaseService = {
  useRepairMaintain: function useRepairMaintain(id, dateValue, endDate) {
    // 汇总
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/maintainRecord/getMaintainRecordStatisticsByFacilityId', {
          data: {
            facilityId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      rmSummaryRes = _useRequest.data;
    var rmSummary = (rmSummaryRes === null || rmSummaryRes === void 0 ? void 0 : rmSummaryRes.data) || {};
    //维保类型
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/maintainRecord/maintainRecordStatisticsByType', {
          data: {
            facilityId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      rmTypeRes = _useRequest2.data;
    var rmType = [];
    if (Array.isArray(rmTypeRes === null || rmTypeRes === void 0 ? void 0 : rmTypeRes.data)) {
      rmType = rmTypeRes.data.map(function (ele) {
        return {
          name: ele.typeName,
          value: ele.count
        };
      });
    }
    //月度趋势
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/maintainRecord/maintainRecordStatisticsByMonth', {
          data: {
            facilityId: id,
            startDate: dateValue,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, dateValue, endDate]
      }),
      rmMonthTrendRes = _useRequest3.data;
    var rmMonthTrend = (rmMonthTrendRes === null || rmMonthTrendRes === void 0 ? void 0 : rmMonthTrendRes.data) || {
      legends: [],
      names: [],
      values: []
    };
    return {
      rmSummary: rmSummary,
      rmType: rmType,
      rmMonthTrend: rmMonthTrend
    };
  },
  useRmRecord: function useRmRecord(id, applyTimeBegin, applyTimeEnd, page, sort) {
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/maintainRecord/maintainAllPage', {
          data: {
            facilityIds: id,
            applyTimeBegin: applyTimeBegin,
            applyTimeEnd: applyTimeEnd,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, applyTimeBegin, applyTimeEnd, page, sort]
      }),
      rmRecordRes = _useRequest4.data;
    var rmRecord = (rmRecordRes === null || rmRecordRes === void 0 ? void 0 : rmRecordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      rmRecord: rmRecord
    };
  }
};
//# sourceMappingURL=api.js.map
