"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.MoniotrService = exports.BaseService = exports.AppraiseService = exports.AlarmService = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var BaseService = {
  useBaseInfo: function useBaseInfo(id, startDate, endDate) {
    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 baseInfo = [{
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }, {
      label: '管理单位',
      key: 'manageUnitName',
      value: info === null || info === void 0 ? void 0 : info.manageUnitName
    }, {
      label: '使用单位',
      key: 'useUnitName',
      value: info === null || info === void 0 ? void 0 : info.useUnitName
    }, {
      label: '公厕状态',
      key: 'facilityStatusName',
      value: info === null || info === void 0 ? void 0 : info.facilityStatusName,
      color: '#52C41A'
    }, {
      label: '详细地址',
      key: 'address',
      value: info === null || info === void 0 ? void 0 : info.address
    }];
    var photos = (info === null || info === void 0 ? void 0 : info.photoIds) ? JSON.parse(info.photoIds) : [];
    // 实时运行情况
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.post('/cloud/sjzt-reborn/api/v101/dataSet/execute', {
          data: JSON.stringify({
            code: 'ZHGC_DIFF_DATATYPE_SUM_MONITOR_VALUE_BY_TYPE',
            parameters: {
              gcId: id,
              startDate: startDate,
              endDate: endDate
            }
          })
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      situationRes = _useRequest2.data;
    return {
      baseInfo: baseInfo,
      photos: photos,
      situationRes: (situationRes === null || situationRes === void 0 ? void 0 : situationRes.data) || []
    };
  },
  useBaseAlarmInfo: function useBaseAlarmInfo(id, startTime, endTime) {
    //本月报警类型分析
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/statisticsByStandardCode', {
          data: {
            baseInfoId: id,
            startDateStr: startTime,
            endDateStr: endTime
          }
        });
      }, {
        refreshDeps: [id, startTime, endTime]
      }),
      alarmTypeRes = _useRequest3.data;
    return {
      alarmTypeRes: (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || []
    };
  },
  useBaseAlarmTypes: function useBaseAlarmTypes(id, startTime, endTime) {
    //报警明细类型
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/statisticsByStandardCode', {
          data: {
            baseInfoId: id,
            startDateStr: startTime,
            endDateStr: endTime
          }
        });
      }, {
        refreshDeps: [id, startTime, endTime]
      }),
      alarmTypeRes = _useRequest4.data;
    return {
      alarmTypeRes: (alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) || []
    };
  },
  useAlarmDetails: function useAlarmDetails(id, standardCode, start, end, page, rows) {
    var _a, _b;
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/queryList.smvc', {
          data: {
            baseInfoId: id,
            standardCode: standardCode,
            startDateStr: start,
            endDateStr: end,
            page: page,
            rows: rows
          }
        });
      }, {
        paginated: true,
        refreshDeps: [id, standardCode, start, end, page]
      }),
      res = _useRequest5.data;
    var dataSource = ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.rows) || [];
    var total = (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
exports.BaseService = BaseService;
var MoniotrService = {
  useRealtime: function useRealtime(id, date) {
    var _a;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/imageTextBoard/queryMonitorData.smvc', {
          data: {
            baseInfoId: id,
            date: date
          }
        });
      }, {
        refreshDeps: [id, date]
      }),
      realtimeRes = _useRequest6.data;
    return {
      realtimeList: ((_a = realtimeRes === null || realtimeRes === void 0 ? void 0 : realtimeRes.data) === null || _a === void 0 ? void 0 : _a.standardList) || []
    };
  },
  useMonitorType: function useMonitorType(id) {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/imageTextBoard/loadStandardType.smvc', {
          data: {
            baseInfoId: id
          }
        });
      }, {
        refreshDeps: [id]
      }),
      monitorTypeRes = _useRequest7.data;
    var names = ['PersonNum', 'OdorValue', 'SeatNum'];
    var monitorType = (monitorTypeRes === null || monitorTypeRes === void 0 ? void 0 : monitorTypeRes.data) ? monitorTypeRes.data.filter(function (ele) {
      return names.includes(ele.standardCode);
    }).map(function (ele) {
      return {
        label: ele.standardCodeName,
        key: ele.standardCode
      };
    }) : [];
    return {
      monitorType: monitorType
    };
  },
  useMonitorChart: function useMonitorChart(id, startDate, endDate, filterKey) {
    var _a;
    var url = getUrl(filterKey);
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get(url, {
          data: {
            baseInfoId: id,
            startDate: startDate,
            endDate: endDate,
            statisticalPeriod: 'day' // 默认按照天查询
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, filterKey]
      }),
      monitorChartRes = _useRequest8.data;
    var series = [];
    if (Array.isArray((_a = monitorChartRes === null || monitorChartRes === void 0 ? void 0 : monitorChartRes.data) === null || _a === void 0 ? void 0 : _a.series)) {
      series = monitorChartRes.data.series.map(function (ele) {
        return {
          data: ele.data,
          name: ele.name,
          type: 'line'
        };
      });
    }
    var monitorChart = Object.assign(Object.assign({}, monitorChartRes === null || monitorChartRes === void 0 ? void 0 : monitorChartRes.data), {
      series: series
    }) || {};
    return {
      monitorChart: monitorChart
    };
  }
};
// 监测信息，根据监测类型获取不同的url
exports.MoniotrService = MoniotrService;
var getUrl = function getUrl(key) {
  var url = '';
  switch (key) {
    case 'PersonNum':
      url = 'personNum/getEcharts.smvc';
      break;
    case 'OdorValue':
      url = 'odor/getEcharts.smvc';
      break;
    case 'temperature':
      url = 'temperature/getEcharts.smvc';
      break;
    case 'humidity':
      url = 'humidity/getEcharts.smvc';
      break;
    case 'WaterUse':
      url = 'waterBySensor/getEcharts.smvc';
      break;
    case 'ElecUse':
      url = 'electricityPowerBySensor/getEcharts.smvc';
      break;
    case 'SeatNum':
      url = 'seat/getEcharts.smvc';
      break;
    default:
      break;
  }
  return "/cloud/zhgc/api/np/v1/".concat(url);
};
var AlarmService = {
  //信息汇总
  useAlarmSummary: function useAlarmSummary(id, dateValue) {
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/statisticsByYearOnYear', {
          data: {
            baseInfoId: id,
            dateValue: dateValue
          }
        });
      }, {
        refreshDeps: [id, dateValue]
      }),
      alarmSummaryRes = _useRequest9.data;
    var alarmSummary = (alarmSummaryRes === null || alarmSummaryRes === void 0 ? void 0 : alarmSummaryRes.data) || [];
    return {
      alarmSummary: alarmSummary
    };
  },
  // 报警记录
  useAlarmRecord: function useAlarmRecord(id, standardCode, start, end, page) {
    var _a, _b;
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/queryList.smvc', {
          data: {
            baseInfoId: id,
            standardCode: standardCode,
            startDateStr: start,
            endDateStr: end,
            page: page,
            rows: 10
          }
        });
      }, {
        paginated: true,
        refreshDeps: [id, standardCode, start, end, page]
      }),
      alarmRecordRes = _useRequest10.data;
    var dataSource = ((_a = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _a === void 0 ? void 0 : _a.rows) || [];
    var total = (_b = alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) === null || _b === void 0 ? void 0 : _b.total;
    return {
      detail: {
        dataSource: dataSource,
        total: total
      }
    };
  },
  // 类型分析
  useAlarmTrend: function useAlarmTrend(id, startDateStr, endDateStr) {
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/standardDataAlarm/statisticsByMonth', {
          data: {
            baseInfoId: id,
            startDateStr: startDateStr,
            endDateStr: endDateStr
          }
        });
      }, {
        refreshDeps: [id]
      }),
      alarmTrendRes = _useRequest11.data;
    var alarmTrend = (alarmTrendRes === null || alarmTrendRes === void 0 ? void 0 : alarmTrendRes.data) || [];
    return {
      alarmTrend: alarmTrend
    };
  }
};
exports.AlarmService = AlarmService;
var AppraiseService = {
  //信息汇总
  useAppraisSummary: function useAppraisSummary(id, startDate, endDate) {
    var _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/baseInfoAssess/baseInfoAssessStatistics', {
          data: {
            baseInfoId: id,
            startDateStr: startDate,
            endDateStr: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate]
      }),
      appraiseSummaryRes = _useRequest12.data;
    var appraiseSummary = (appraiseSummaryRes === null || appraiseSummaryRes === void 0 ? void 0 : appraiseSummaryRes.data) || [];
    return {
      appraiseSummary: appraiseSummary
    };
  },
  // 报警记录
  useAppraiseRecord: function useAppraiseRecord(id, page) {
    var _a, _b;
    var _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zhgc/api/np/v1/baseInfoAssess/queryList.smvc', {
          data: {
            baseInfoId: id,
            page: page,
            rows: 10
          }
        });
      }, {
        paginated: true,
        refreshDeps: [id, page]
      }),
      appraiseRecordRes = _useRequest13.data;
    var dataSource = ((_a = appraiseRecordRes === null || appraiseRecordRes === void 0 ? void 0 : appraiseRecordRes.data) === null || _a === void 0 ? void 0 : _a.rows) || [];
    var total = (_b = appraiseRecordRes === null || appraiseRecordRes === void 0 ? void 0 : appraiseRecordRes.data) === null || _b === void 0 ? void 0 : _b.total;
    return {
      records: {
        dataSource: dataSource,
        total: total
      }
    };
  }
};
exports.AppraiseService = AppraiseService;
//# sourceMappingURL=api.js.map
