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 = {
  useBaseDetail: function useBaseDetail(id, coordType) {
    var _useRequest = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/collect/point/get', {
          data: {
            id: id,
            coordinateType: 'wgs84'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var info = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    var baseInfo = [{
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }, {
      label: '垃圾类型',
      key: 'productTypeNames',
      value: info === null || info === void 0 ? void 0 : info.productTypeNames
    }, {
      label: '管理单位',
      key: 'manageUnitName',
      value: info === null || info === void 0 ? void 0 : info.manageUnitName
    }, {
      label: '收运单位',
      key: 'accUnitName',
      value: info === null || info === void 0 ? void 0 : info.accUnitNames
    }, {
      label: '地址',
      key: 'address',
      value: info === null || info === void 0 ? void 0 : info.address
    }];
    return {
      info: info,
      baseInfo: baseInfo,
      rules: (info === null || info === void 0 ? void 0 : info.rules) || []
    };
  },
  useGetRule: function useGetRule(id) {
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/collect/point/getPointRuleList', {
          data: {
            id: id
          }
        });
      }, {
        refreshDeps: [id]
      }),
      data = _useRequest2.data;
    return (data === null || data === void 0 ? void 0 : data.data) || [];
  },
  useBaseInfo: function useBaseInfo(id, startDate, endDate) {
    // 今日作业
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/collectRateByProduct', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate,
            coordinateType: 'wgs84'
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      todayWorkRes = _useRequest3.data;
    // 车辆作业信息
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/getCarCollectInfoByPointId', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate,
            coordinateType: ' wgs84'
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      carWorkRes = _useRequest4.data;
    return {
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || [],
      dataSource: (carWorkRes === null || carWorkRes === void 0 ? void 0 : carWorkRes.data) || []
    };
  },
  useConfig: function useConfig() {
    var _useRequest5 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/param/config/webList');
      }),
      config = _useRequest5.data;
    var paramConfigsList = {},
      productTypes = {};
    if (config !== null && config !== void 0 && config.data) {
      var _config$data, _config$data2;
      (_config$data = config.data) === null || _config$data === void 0 || (_config$data = _config$data.paramConfigs) === null || _config$data === void 0 || _config$data.forEach(function (element) {
        paramConfigsList[element.code] = _objectSpread({}, element);
      });
      (_config$data2 = config.data) === null || _config$data2 === void 0 || (_config$data2 = _config$data2.productTypes) === null || _config$data2 === void 0 || _config$data2.forEach(function (element) {
        productTypes[element.id] = _objectSpread({}, element);
      });
    }
    return {
      paramConfigsList: paramConfigsList,
      productTypes: productTypes
    };
  }
};
var SyService = {
  useBaseInfo: function useBaseInfo(id, startDate, endDate) {
    var _baseInfoRes$data, _baseInfoRes$data2;
    var _useRequest6 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/collectRateByProduct', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      baseInfoRes = _useRequest6.data;
    var baseInfo = (baseInfoRes === null || baseInfoRes === void 0 || (_baseInfoRes$data = baseInfoRes.data) === null || _baseInfoRes$data === void 0 ? void 0 : _baseInfoRes$data.length) <= 2 ? baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data.filter(function (ele) {
      return ele.productTypeName !== '全部';
    }) : (baseInfoRes === null || baseInfoRes === void 0 || (_baseInfoRes$data2 = baseInfoRes.data) === null || _baseInfoRes$data2 === void 0 ? void 0 : _baseInfoRes$data2.map(function (ele) {
      return _objectSpread(_objectSpread({}, ele), {}, {
        productTypeId: ele.productTypeName === '全部' ? 'all' : ele.productTypeId
      });
    })) || [];
    var _useRequest7 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/collectWeightAnalyze', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      collectWeightRes = _useRequest7.data;
    var collectWeight = collectWeightRes === null || collectWeightRes === void 0 ? void 0 : collectWeightRes.data;
    return {
      baseInfo: baseInfo,
      collectWeight: collectWeight
    };
  },
  useRecordInfo: function useRecordInfo(id, productTypeId, startTime, endTime, page, sort) {
    var _useRequest8 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/collect/record/day/page', {
          data: {
            collectPointId: id,
            productTypeId: productTypeId,
            startTime: startTime,
            endTime: endTime,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, productTypeId, startTime, endTime, page, sort]
      }),
      recordRes = _useRequest8.data;
    var records = (recordRes === null || recordRes === void 0 ? void 0 : recordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      records: records
    };
  }
};
var AlarmService = {
  //信息汇总
  useAlarmSummary: function useAlarmSummary(id, dateValue) {
    var _useRequest9 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/getAlarmStatisticsByCollectPointId', {
          data: {
            collectPointId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      alarmSummaryRes = _useRequest9.data;
    var alarmSummary = (alarmSummaryRes === null || alarmSummaryRes === void 0 ? void 0 : alarmSummaryRes.data) || [];
    return {
      alarmSummary: alarmSummary
    };
  },
  // 类型分析
  useAlarmTrend: function useAlarmTrend(id, startDate, endDate) {
    var _useRequest10 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/alarmStatisticsByAlarmType', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmTypeRes = _useRequest10.data;
    var alarmTypes = (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || [];
    return {
      alarmTypes: alarmTypes
    };
  },
  // 月度趋势分析
  useAlarmMonthTrend: function useAlarmMonthTrend(id, startDate, endDate) {
    var _useRequest11 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/alarmStatisticsByMonth', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmMonthTrendRes = _useRequest11.data;
    var alarmMonthTrend = (alarmMonthTrendRes === null || alarmMonthTrendRes === void 0 ? void 0 : alarmMonthTrendRes.data) || [];
    return {
      alarmMonthTrend: alarmMonthTrend
    };
  },
  // 报警记录
  useAlarmRecord: function useAlarmRecord(id, alarmTypeCode, start, end, page, sort) {
    var _alarmRecordRes$data, _alarmRecordRes$data2;
    var _useRequest12 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/collect/point/alarm/alarmPage', {
          data: {
            collectPointIds: id,
            alarmTypeCode: alarmTypeCode,
            startDate: start,
            endDate: end,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, alarmTypeCode, start, end, page, sort]
      }),
      alarmRecordRes = _useRequest12.data;
    var dataSource = (alarmRecordRes === null || alarmRecordRes === void 0 || (_alarmRecordRes$data = alarmRecordRes.data) === null || _alarmRecordRes$data === void 0 ? void 0 : _alarmRecordRes$data.rows) || [];
    var total = alarmRecordRes === null || alarmRecordRes === void 0 || (_alarmRecordRes$data2 = alarmRecordRes.data) === null || _alarmRecordRes$data2 === void 0 ? void 0 : _alarmRecordRes$data2.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
var ExeceptionService = {
  //信息汇总
  useAlarmSummary: function useAlarmSummary(id, dateValue) {
    var _useRequest13 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/getAbnormalStatisticsByCollectPointId', {
          data: {
            collectPointId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      alarmSummaryRes = _useRequest13.data;
    var alarmSummary = (alarmSummaryRes === null || alarmSummaryRes === void 0 ? void 0 : alarmSummaryRes.data) || [];
    return {
      alarmSummary: alarmSummary
    };
  },
  // 类型分析
  useAlarmTrend: function useAlarmTrend(id, startDate, endDate) {
    var _useRequest14 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/abnormalStatisticsByAbnormalType', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmTypeRes = _useRequest14.data;
    var alarmTypes = (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || [];
    return {
      alarmTypes: alarmTypes
    };
  },
  // 月度趋势分析
  useAlarmMonthTrend: function useAlarmMonthTrend(id, startDate, endDate) {
    var _useRequest15 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/kanban/abnormalStatisticsByMonth', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmMonthTrendRes = _useRequest15.data;
    var alarmMonthTrend = (alarmMonthTrendRes === null || alarmMonthTrendRes === void 0 ? void 0 : alarmMonthTrendRes.data) || [];
    return {
      alarmMonthTrend: alarmMonthTrend
    };
  },
  // 异常记录
  useAlarmRecord: function useAlarmRecord(id, abnormalType, start, end, page, sort) {
    var _alarmRecordRes$data3, _alarmRecordRes$data4;
    var _useRequest16 = useRequest(function () {
        return request.get('/cloud/ljsy-reborn/api/abnormal/reporting/page', {
          data: {
            collectPointId: id,
            abnormalType: abnormalType,
            startTime: start,
            endTime: end,
            page: page,
            size: 10,
            sort: sort
          }
        });
      }, {
        refreshDeps: [id, abnormalType, start, end, page, sort]
      }),
      alarmRecordRes = _useRequest16.data;
    var dataSource = (alarmRecordRes === null || alarmRecordRes === void 0 || (_alarmRecordRes$data3 = alarmRecordRes.data) === null || _alarmRecordRes$data3 === void 0 ? void 0 : _alarmRecordRes$data3.rows) || [];
    var total = alarmRecordRes === null || alarmRecordRes === void 0 || (_alarmRecordRes$data4 = alarmRecordRes.data) === null || _alarmRecordRes$data4 === void 0 ? void 0 : _alarmRecordRes$data4.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
export { AlarmService, BaseService, ExeceptionService, SyService };