import { request } from '@vtx/utils';
import { useRequest } from 'ahooks';
import http from "../_util/http";
var BaseService = {
  useTrendInfo: function useTrendInfo(code, startDate, endDate) {
    // 进场趋势
    var _useRequest = useRequest(function () {
        return http.getForTenantId('/cloud/zd/lm/api/cp/dataBoard/getSumDataLineByFactory.smvc', {
          body: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate,
            tenantId: ''
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      trendRes = _useRequest.data;
    return {
      trendRes: (trendRes === null || trendRes === void 0 ? void 0 : trendRes.data) || []
    };
  },
  // 实时运行(进场)情况
  useSituation: function useSituation(code, date) {
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/zd/lm/api/cp/dataBoard/getSumData.smvc', {
          data: {
            disposeUnitCode: code,
            date: date,
            beenFilterProductNames: false
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [date]
      }),
      situationRes = _useRequest2.data;
    return {
      situationRes: situationRes === null || situationRes === void 0 ? void 0 : situationRes.data
    };
  },
  useSituationSummary: function useSituationSummary(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) || []
    };
  },
  useQyjcl: function useQyjcl(code, startDate, endDate) {
    var _useRequest4 = useRequest(function () {
        return request.get('/cloud/zd/lm/api/cp/dataBoard/getAreaSumData.smvc', {
          data: {
            disposeUnitCode: code,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [code, startDate, endDate]
      }),
      res = _useRequest4.data;
    return {
      areaSumData: res === null || res === void 0 ? void 0 : res.data
    };
  },
  useRealtimeMonitor: function useRealtimeMonitor(factoryCode) {
    var _res$data;
    // 实时监测
    var _useRequest5 = useRequest(function () {
        return request.get('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataStatistics', {
          data: {
            factoryCode: factoryCode
          }
        });
      }, {
        ready: !!factoryCode,
        refreshDeps: [factoryCode]
      }),
      res = _useRequest5.data;
    return {
      realtimeMonitor: (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.deviceList) || []
    };
  },
  useRealtime: function useRealtime(deviceId) {
    // 实时监测情况
    var _useRequest6 = useRequest(function () {
        return http.getForTenantId('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataDeviceRealTime', {
          body: {
            deviceId: deviceId
          }
        });
      }, {
        ready: !!deviceId,
        refreshDeps: [deviceId]
      }),
      res = _useRequest6.data;
    return {
      realtimeRes: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  },
  useJczbqsfx: function useJczbqsfx(code, deviceId, startTime, endTime) {
    var _useRequest7 = useRequest(function () {
        return 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 = _useRequest7.data;
    return {
      timeSumData: code ? res === null || res === void 0 ? void 0 : res.data : {}
    };
  },
  useJcccsjfb: function useJcccsjfb(code, startDate, endDate) {
    // 实时运行情况
    var _useRequest8 = 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 = _useRequest8.data;
    return {
      jcccsjfbRes: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.data) || []
    };
  }
};
var MeteringService = {
  useRecord: function useRecord(code, startTime, endTime, page) {
    var _useRequest9 = 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 = _useRequest9.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 = 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 = _useRequest10.data;
    var summary = (summaryRes === null || summaryRes === void 0 ? void 0 : summaryRes.data) || {};
    return {
      summary: summary
    };
  }
};

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

// 日历
var CalendarService = {
  useFetchData: function useFetchData(code, startDate, endDate) {
    var _useRequest12 = useRequest(function () {
        return request.get('/cloud/zd/lm/api/cp/commonSummaryData/sumByDate', {
          data: {
            disposeUnitCodes: code,
            startDate: startDate,
            endDate: endDate,
            dateType: 'day'
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startDate, endDate]
      }),
      res = _useRequest12.data;
    return {
      data1: (res === null || res === void 0 ? void 0 : res.data) || []
    };
  },
  useFetchData2: function useFetchData2(code, startTime, endTime) {
    var _useRequest13 = useRequest(function () {
        return request.get('/cloud/sjzt-reborn/api/v101/zdjg/jg/data/getJgDataAlarmNumByDate', {
          data: {
            factoryCode: code,
            startTime: startTime,
            endTime: endTime
          }
        });
      }, {
        ready: !!code,
        refreshDeps: [startTime, endTime]
      }),
      res2 = _useRequest13.data;
    return {
      data2: (res2 === null || res2 === void 0 ? void 0 : res2.data) || []
    };
  }
};
export { BaseService, CalendarService, MeteringService, WorkConditionService };