"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Service = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _upIcon = _interopRequireDefault(require("./assets/upIcon.png"));
var _downIcon = _interopRequireDefault(require("./assets/downIcon.png"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var handelData = function handelData(data, timeType) {
  var subLabelList = {
    1: '日同比',
    2: '月同比',
    3: '年同比'
  };
  var newData = (data || []).map(function (v) {
    var label = '';
    if (v.isTotal) {
      label = '全部';
    } else {
      label = "".concat(v.factorName);
    }
    var subValue = "".concat(v.compareValue, "%"),
      subIcon = '';
    if (v.compareValue || String(v.compareValue) === '0') {
      subIcon = v.compareValue < 0 ? _downIcon["default"] : v.compareValue > 0 ? _upIcon["default"] : '';
    }
    return Object.assign(Object.assign({}, v), {
      label: label,
      value: v.nowWarnCount,
      subLabel: (subLabelList === null || subLabelList === void 0 ? void 0 : subLabelList[timeType]) || '月同比',
      subValue: subValue,
      subIcon: subIcon
    });
  });
  return newData;
};
var Service = exports.Service = {
  UseAlarmData: function UseAlarmData(_ref) {
    var id = _ref.id,
      publicUrlJCSS = _ref.publicUrlJCSS,
      startTime = _ref.startTime,
      endTime = _ref.endTime,
      timeType = _ref.timeType,
      filterParams = _ref.filterParams;
    // 报警情况
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("".concat(publicUrlJCSS, "/api/facility/warnInfo"), {
          data: Object.assign({
            facilityId: id,
            startTime: startTime,
            endTime: endTime,
            timeType: timeType,
            alarmType: 1
          }, filterParams || {})
        });
      }, {
        refreshDeps: [id, timeType]
      }),
      baseInfoRes = _useRequest.data;
    var alarmData = handelData(baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data, timeType);
    return {
      alarmData: alarmData
    };
  },
  UseAlarmDetail: function UseAlarmDetail(_ref2) {
    var id = _ref2.id,
      publicUrlJCSS = _ref2.publicUrlJCSS,
      startTime = _ref2.startTime,
      endTime = _ref2.endTime,
      factorCode = _ref2.factorCode,
      filterParams = _ref2.filterParams;
    // 报警情况记录-穿透
    return _utils.request.get("".concat(publicUrlJCSS, "/api/facility/warnRecord"), {
      data: Object.assign({
        facilityId: id,
        startTime: startTime,
        endTime: endTime,
        factorCode: factorCode
      }, filterParams || {})
    });
  }
};
//# sourceMappingURL=api.js.map
