import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
import http from "../_util/http";
var BaseService = {
  //类型配置
  useGetFacConfig: function useGetFacConfig(code) {
    var _useRequest = useRequest(function () {
        return request.get('/cloud/jcss-reborn/facility/type/getByCode', {
          data: {
            code: code
          }
        });
      }, {
        refreshDeps: [code],
        ready: !!code
      }),
      facConfig = _useRequest.data;
    return {
      facConfig: facConfig
    };
  },
  useTrendInfo: function useTrendInfo(code, startDate, endDate) {
    // 进场趋势
    var _useRequest2 = useRequest(function () {
        return http.getForTenantId('/cloud/zd/lm/api/cp/dataBoard/getSumDataLineByFactory.smvc', {
          body: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate,
            tenantId: '',
            beenFilterProductNames: false
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      trendRes = _useRequest2.data;
    return {
      trendRes: (trendRes === null || trendRes === void 0 ? void 0 : trendRes.data) || []
    };
  },
  useSituation: function useSituation(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/zd/lm/api/cp/dataBoard/getSumOperationData.smvc', {
          data: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      situationRes = _useRequest3.data;
    return {
      situationRes: (situationRes === null || situationRes === void 0 ? void 0 : situationRes.data) || []
    };
  },
  useRealtime: function useRealtime(code) {
    // 实时运行情况
    var _useRequest4 = useRequest(function () {
        return http.getForTenantId('/cloud/zd/jg/api/cp/realTime/deviceBoardByFactory.smvc', {
          body: {
            factoryCode: code,
            tenantId: ''
          }
        });
      }, {
        ready: !!code
      }),
      realtimeRes = _useRequest4.data;
    return {
      realtimeRes: (realtimeRes === null || realtimeRes === void 0 ? void 0 : realtimeRes.data) || []
    };
  },
  useJcccsjfb: function useJcccsjfb(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest5 = useRequest(function () {
        return http.getForTenantId('/cloud/zd/lm/api/cp/dataBoard/getSumCarNumHourLineByFactory.smvc', {
          body: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate,
            tenantId: ''
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      jcccsjfbRes = _useRequest5.data;
    return {
      jcccsjfbRes: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.data) || []
    };
  }
};
var MeteringService = {
  useRecord: function useRecord(code, startTime, endTime, page) {
    var _useRequest6 = useRequest(function () {
        return 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 = _useRequest6.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 _useRequest7 = useRequest(function () {
        return 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 = _useRequest7.data;
    var summary = (summaryRes === null || summaryRes === void 0 ? void 0 : summaryRes.data) || {};
    return {
      summary: summary
    };
  }
};

// 工况
var WorkConditionService = {
  useFetchData: function useFetchData(code, startDateTime, endDateTime) {
    var _useRequest8 = useRequest(function () {
        return 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 = _useRequest8.data;
    var situationData = (res === null || res === void 0 ? void 0 : res.data) || [];
    return {
      situationData: situationData
    };
  }
};
export { BaseService, MeteringService, WorkConditionService };