"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WorkConditionService = exports.MeteringService = exports.LmService = exports.CalendarService = 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, date) {
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/dataBoard/getSumData.smvc', {
          data: {
            disposeUnitCode: code,
            date: date
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [date]
      }),
      situationRes = _useRequest5.data;
    return {
      situationRes: situationRes === null || situationRes === void 0 ? void 0 : situationRes.data
    };
  },
  useSituationSummary: function useSituationSummary(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest6 = (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 = _useRequest6.data;
    return {
      situationRes: (situationRes === null || situationRes === void 0 ? void 0 : situationRes.data) || []
    };
  },
  useQyjcl: function useQyjcl(code, startDate, endDate) {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/dataBoard/getAreaSumData.smvc', {
          data: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [code, startDate, endDate]
      }),
      res = _useRequest7.data;
    return {
      areaSumData: res === null || res === void 0 ? void 0 : res.data
    };
  },
  useRealtimeMonitor: function useRealtimeMonitor(factoryCode) {
    var _a;
    // 实时监测
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataStatistics', {
          data: {
            factoryCode: factoryCode
          }
        });
      }, {
        ready: !!factoryCode,
        refreshDeps: [factoryCode]
      }),
      res = _useRequest8.data;
    return {
      realtimeMonitor: ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.deviceList) || []
    };
  },
  useRealtime: function useRealtime(deviceId) {
    // 实时监测情况
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _util["default"].getForTenantId('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataDeviceRealTime', {
          body: {
            deviceId: deviceId
          }
        });
      }, {
        ready: !!deviceId,
        refreshDeps: [deviceId]
      }),
      res = _useRequest9.data;
    return {
      realtimeRes: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  },
  useJczbqsfx: function useJczbqsfx(code, deviceId, startTime, endTime) {
    var _useRequest0 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataChart', {
          data: {
            monitorItemCode: code,
            deviceId: deviceId,
            startTime: startTime,
            endTime: endTime
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [code, deviceId, startTime, endTime]
      }),
      res = _useRequest0.data;
    return {
      timeSumData: code ? res === null || res === void 0 ? void 0 : res.data : {}
    };
  },
  useJcccsjfb: function useJcccsjfb(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest1 = (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 = _useRequest1.data;
    return {
      jcccsjfbRes: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.data) || []
    };
  }
};
var MeteringService = exports.MeteringService = {
  useRecord: function useRecord(code, startTime, endTime, page) {
    var _useRequest10 = (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 = _useRequest10.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 _useRequest11 = (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 = _useRequest11.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 _useRequest12 = (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 = _useRequest12.data;
    var situationData = (res === null || res === void 0 ? void 0 : res.data) || [];
    return {
      situationData: situationData
    };
  }
};
// 日历
var CalendarService = exports.CalendarService = {
  useFetchData: function useFetchData(code, startDate, endDate) {
    var _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/lm/api/cp/commonSummaryData/sumByDate', {
          data: {
            disposeUnitCodes: code,
            startDate: startDate,
            endDate: endDate,
            dateType: 'day'
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      res = _useRequest13.data;
    return {
      data1: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  },
  useFetchData2: function useFetchData2(code, startTime, endTime) {
    var _useRequest14 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataAlarmNumByDate', {
          data: {
            factoryCode: code,
            startTime: startTime,
            endTime: endTime
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startTime, endTime]
      }),
      res2 = _useRequest14.data;
    return {
      data2: (res2 === null || res2 === void 0 ? void 0 : res2.data) || []
    };
  }
};
// 是否有计量
var LmService = exports.LmService = {
  useLmDetail: function useLmDetail(id) {
    var _useRequest15 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zd/base/api/cp/commonFactory/getCommonFactoryById.smvc', {
          data: {
            factoryId: id
          }
        });
      }, {
        refreshDeps: [id]
      }),
      res = _useRequest15.data;
    return {
      detail: (res === null || res === void 0 ? void 0 : res.data) || {}
    };
  }
};
//# sourceMappingURL=api.js.map
