"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SyService = exports.ExeceptionService = exports.BaseService = exports.AlarmService = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var BaseService = exports.BaseService = {
  useBaseDetail: function useBaseDetail(id) {
    var _a, _b, _c, _d, _e, _f;
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/collect/point/get', {
          data: {
            id: id,
            coordinateType: 'bd09'
          }
        });
      }, {
        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
    }];
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: 'cp'
          }
        });
      }, {
        ready: !!((_a = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) === null || _a === void 0 ? void 0 : _a.collectPointTypeCode),
        refreshDeps: [(_b = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) === null || _b === void 0 ? void 0 : _b.collectPointTypeCode]
      }),
      tabConfig = _useRequest2.data;
    return {
      info: info,
      baseInfo: baseInfo,
      rules: (info === null || info === void 0 ? void 0 : info.rules) || [],
      tabIsFilter: !!((_d = (_c = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _c === void 0 ? void 0 : _c.popupConfigJson) === null || _d === void 0 ? void 0 : _d.length),
      tabConfig: ((_f = (_e = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _e === void 0 ? void 0 : _e.popupConfigJson) === null || _f === void 0 ? void 0 : _f.filter(function (ele) {
        return ele.display;
      }).map(function (ele) {
        return Object.assign(Object.assign({}, ele), {
          key: ele.code,
          title: ele.name
        });
      })) || [],
      visited: !!tabConfig
    };
  },
  useGetRule: function useGetRule(id) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/collect/point/getPointRuleList', {
          data: {
            id: id
          }
        });
      }, {
        refreshDeps: [id]
      }),
      data = _useRequest3.data;
    return (data === null || data === void 0 ? void 0 : data.data) || [];
  },
  useBaseInfo: function useBaseInfo(id, startDate, endDate) {
    // 今日作业
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/collectRateByProduct', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate,
            coordinateType: 'bd09'
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      todayWorkRes = _useRequest4.data;
    // 车辆作业信息
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/getCarCollectInfoByPointId', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate,
            coordinateType: 'bd09'
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      carWorkRes = _useRequest5.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 _a, _b, _c, _d;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/param/config/webList');
      }),
      config = _useRequest6.data;
    var paramConfigsList = {},
      productTypes = {};
    if (config === null || config === void 0 ? void 0 : config.data) {
      (_b = (_a = config.data) === null || _a === void 0 ? void 0 : _a.paramConfigs) === null || _b === void 0 ? void 0 : _b.forEach(function (element) {
        paramConfigsList[element.code] = Object.assign({}, element);
      });
      (_d = (_c = config.data) === null || _c === void 0 ? void 0 : _c.productTypes) === null || _d === void 0 ? void 0 : _d.forEach(function (element) {
        productTypes[element.id] = Object.assign({}, element);
      });
    }
    return {
      paramConfigsList: paramConfigsList,
      productTypes: productTypes
    };
  }
};
var SyService = exports.SyService = {
  useBaseInfo: function useBaseInfo(id, startDate, endDate) {
    var _a;
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/collectRateByProduct', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      baseInfoRes = _useRequest7.data;
    var baseInfo = ((_a = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) === null || _a === void 0 ? void 0 : _a.length) <= 2 ? baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data.filter(function (ele) {
      return ele.productTypeName !== '全部';
    }) : (baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) || [];
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/collectWeightAnalyze', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      collectWeightRes = _useRequest8.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 _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.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 = _useRequest9.data;
    var records = (recordRes === null || recordRes === void 0 ? void 0 : recordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      records: records
    };
  }
};
var AlarmService = exports.AlarmService = {
  //信息汇总
  useAlarmSummary: function useAlarmSummary(id, dateValue) {
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/getAlarmStatisticsByCollectPointId', {
          data: {
            collectPointId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      alarmSummaryRes = _useRequest10.data;
    var alarmSummary = (alarmSummaryRes === null || alarmSummaryRes === void 0 ? void 0 : alarmSummaryRes.data) || [];
    return {
      alarmSummary: alarmSummary
    };
  },
  // 类型分析
  useAlarmTrend: function useAlarmTrend(id, startDate, endDate) {
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/alarmStatisticsByAlarmType', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmTypeRes = _useRequest11.data;
    var alarmTypes = (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || [];
    return {
      alarmTypes: alarmTypes
    };
  },
  // 月度趋势分析
  useAlarmMonthTrend: function useAlarmMonthTrend(id, startDate, endDate) {
    var _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/alarmStatisticsByMonth', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmMonthTrendRes = _useRequest12.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 _a, _b;
    var _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.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 = _useRequest13.data;
    var dataSource = ((_a = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _a === void 0 ? void 0 : _a.rows) || [];
    var total = (_b = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _b === void 0 ? void 0 : _b.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
var ExeceptionService = exports.ExeceptionService = {
  //信息汇总
  useAlarmSummary: function useAlarmSummary(id, dateValue) {
    var _useRequest14 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/getAbnormalStatisticsByCollectPointId', {
          data: {
            collectPointId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      alarmSummaryRes = _useRequest14.data;
    var alarmSummary = (alarmSummaryRes === null || alarmSummaryRes === void 0 ? void 0 : alarmSummaryRes.data) || [];
    return {
      alarmSummary: alarmSummary
    };
  },
  // 类型分析
  useAlarmTrend: function useAlarmTrend(id, startDate, endDate) {
    var _useRequest15 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/abnormalStatisticsByAbnormalType', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmTypeRes = _useRequest15.data;
    var alarmTypes = (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || [];
    return {
      alarmTypes: alarmTypes
    };
  },
  // 月度趋势分析
  useAlarmMonthTrend: function useAlarmMonthTrend(id, startDate, endDate) {
    var _useRequest16 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/ljsy-reborn/api/kanban/abnormalStatisticsByMonth', {
          data: {
            collectPointId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      alarmMonthTrendRes = _useRequest16.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 _a, _b;
    var _useRequest17 = (0, _ahooks.useRequest)(function () {
        return _utils.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 = _useRequest17.data;
    var dataSource = ((_a = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _a === void 0 ? void 0 : _a.rows) || [];
    var total = (_b = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _b === void 0 ? void 0 : _b.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
//# sourceMappingURL=api.js.map
