"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WorkConditionService = exports.MeteringService = exports.LmService = exports.BaseService = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _util = _interopRequireDefault(require("../util"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var BaseService = exports.BaseService = {
  useBaseInfo: function useBaseInfo(id) {
    var _a, _b, _c, _d, _e, _f;
    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 info = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: baseInfoRes.data.typeCode
          }
        });
      }, {
        ready: !!((_a = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) === null || _a === void 0 ? void 0 : _a.typeCode),
        refreshDeps: [(_b = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data) === null || _b === void 0 ? void 0 : _b.typeCode]
      }),
      tabConfig = _useRequest2.data;
    var photos = (info === null || info === void 0 ? void 0 : info.photoIds) ? JSON.parse(info.photoIds) : (info === null || info === void 0 ? void 0 : info.typePhotoIds) ? JSON.parse(info.typePhotoIds) : [];
    return {
      photos: photos,
      code: info === null || info === void 0 ? void 0 : info.code,
      info: info,
      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
    };
  },
  //基础设施详情展示字段
  getFields: function getFields(code) {
    var _a;
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/view/detail', {
          data: {
            code: code
          }
        });
      }, {
        refreshDeps: [code],
        ready: !!code
      }),
      data = _useRequest3.data;
    return (data === null || data === void 0 ? void 0 : data.data) ? ((_a = data.data.baseFields) === null || _a === void 0 ? void 0 : _a.filter(function (ele) {
      return !['photoIds', 'geometryInfo', 'orderIndex', 'geoPointLocation', 'geoLineLocation', 'geoPolygonLocation'].includes(ele.key);
    }).concat(data.data.customFields)) || [] : [];
  },
  useTrendInfo: function useTrendInfo(code, startDate, endDate) {
    // 进场趋势
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _util["default"].getForTenantId('/cloud/zd/lm/api/cp/dataBoard/getSumDataLineByFactory.smvc', {
          body: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate,
            tenantId: ''
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      trendRes = _useRequest4.data;
    return {
      trendRes: (trendRes === null || trendRes === void 0 ? void 0 : trendRes.data) || []
    };
  },
  useSituation: function useSituation(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/dataBoard/getSumOperationData.smvc', {
          data: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      situationRes = _useRequest5.data;
    return {
      situationRes: (situationRes === null || situationRes === void 0 ? void 0 : situationRes.data) || []
    };
  },
  // 实时运行情况-运行指标报警
  useSituationAlarm: function useSituationAlarm(code, startDate, endDate) {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/jg/api/cp/alarmInfo/getSummaryByFactory.smvc', {
          data: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      situationAlarmRes = _useRequest6.data;
    return {
      situationAlarmRes: situationAlarmRes === null || situationAlarmRes === void 0 ? void 0 : situationAlarmRes.data
    };
  },
  useRealtime: function useRealtime(code) {
    // 实时运行情况
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _util["default"].getForTenantId('/cloud/zd/jg/api/cp/realTime/deviceBoardByFactory.smvc', {
          body: {
            factoryCode: code,
            tenantId: ''
          }
        });
      }, {
        ready: !!code
      }),
      realtimeRes = _useRequest7.data;
    return {
      realtimeRes: (realtimeRes === null || realtimeRes === void 0 ? void 0 : realtimeRes.data) || []
    };
  },
  useJcccsjfb: function useJcccsjfb(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _util["default"].getForTenantId('/cloud/zd/lm/api/cp/dataBoard/getSumCarNumHourLineByFactory.smvc', {
          body: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate,
            tenantId: ''
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      jcccsjfbRes = _useRequest8.data;
    return {
      jcccsjfbRes: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.data) || []
    };
  },
  useMonitorCarExeception: function useMonitorCarExeception(code, dateValue, num) {
    // 车辆监测指标异常
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/dataBoard/getAlarmDescriptionByFactory.smvc', {
          data: {
            disposeUnitCode: code,
            dateValue: dateValue
          }
        });
      }, {
        ready: num == null && !!code,
        refreshDeps: [dateValue]
      }),
      execeptionCarRes = _useRequest9.data;
    return {
      execeptionCar: (execeptionCarRes === null || execeptionCarRes === void 0 ? void 0 : execeptionCarRes.data) || ''
    };
  },
  useMonitorPointExeception: function useMonitorPointExeception(code, num) {
    // 点位监测指标异常
    var _useRequest0 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/jg/api/cp/realTime/getAlarmDescriptionByFactory.smvc', {
          data: {
            factoryCode: code
          }
        });
      }, {
        ready: !!code && num !== null && num >= 0
      }),
      execeptionPointRes = _useRequest0.data;
    return {
      execeptionPoint: (execeptionPointRes === null || execeptionPointRes === void 0 ? void 0 : execeptionPointRes.data) || ''
    };
  }
};
var MeteringService = exports.MeteringService = {
  useRecord: function useRecord(code, startTime, endTime, page) {
    var _useRequest1 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/zdjgLmWeighData/pageList.smvc', {
          data: {
            disposeUnitCode: code,
            startTime: startTime,
            endTime: endTime,
            page: page,
            rows: 10
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startTime, endTime, page]
      }),
      recordRes = _useRequest1.data;
    var records = (recordRes === null || recordRes === void 0 ? void 0 : recordRes.data) || {
      total: 0,
      rows: []
    };
    return {
      records: records
    };
  },
  useSummary: function useSummary(code, startTime, endTime) {
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/zdjgLmWeighData/summary.smvc', {
          data: {
            disposeUnitCode: code,
            startTime: startTime,
            endTime: endTime,
            page: 1,
            rows: 10000
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startTime, endTime]
      }),
      summaryRes = _useRequest10.data;
    var summary = (summaryRes === null || summaryRes === void 0 ? void 0 : summaryRes.data) || {};
    return {
      summary: summary
    };
  }
};
// 工况
var WorkConditionService = exports.WorkConditionService = {
  useFetchData: function useFetchData(code, startDateTime, endDateTime) {
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/jg/api/cp/historyValue/getMonitorItemSum.smvc', {
          data: {
            factoryCode: code,
            startDateTime: startDateTime,
            endDateTime: endDateTime,
            monitorItemCodes: 'MI_TRW_LJ_RL,MI_CW_FDL,MI_CW_SLY,MI_CW_FH,MI_CW_LZH'
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDateTime, endDateTime]
      }),
      res = _useRequest11.data;
    var situationData = (res === null || res === void 0 ? void 0 : res.data) || [];
    return {
      situationData: situationData
    };
  }
};
// 是否有计量
var LmService = exports.LmService = {
  useLmDetail: function useLmDetail(id) {
    var _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/base/api/cp/commonFactory/getCommonFactoryById.smvc', {
          data: {
            factoryId: id
          }
        });
      }, {
        refreshDeps: [id]
      }),
      res = _useRequest12.data;
    return {
      detail: (res === null || res === void 0 ? void 0 : res.data) || {}
    };
  }
};
//# sourceMappingURL=api.js.map
