"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.StaticService = exports.ConfigService = 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 ConfigService = exports.ConfigService = {
  useConfig: function useConfig() {
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyqs-zqb/api/v101/systemConfig/load');
      }, {
        onError: function onError(error) {
          if (error.status === 404) {
            //
          }
        }
      }),
      data = _useRequest.data,
      loading = _useRequest.loading;
    return {
      data: data === null || data === void 0 ? void 0 : data.data,
      loading: loading
    };
  }
};
var BaseService = exports.BaseService = {
  useBaseInfo: function useBaseInfo(id, date, service, loading, hasRule) {
    var _a, _b, _c, _d;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/v1.5/road/").concat(id));
      }, {
        refreshDeps: [id, loading, hasRule],
        ready: !loading && hasRule
      }),
      baseInfoRes = _useRequest2.data;
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _util["default"].getForTenantId('/cloud/jcss-reborn/facility/type/getByCode', {
          body: {
            code: 'tr',
            tenantId: ''
          }
        });
      }, {
        refreshDeps: [id]
      }),
      showConfig = _useRequest3.data;
    var info = baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data;
    var showbidSection = ((_a = showConfig === null || showConfig === void 0 ? void 0 : showConfig.data) === null || _a === void 0 ? void 0 : _a.code) == 'tr' ? (_c = (_b = showConfig === null || showConfig === void 0 ? void 0 : showConfig.data) === null || _b === void 0 ? void 0 : _b.fieldJson) === null || _c === void 0 ? void 0 : _c.find(function (item) {
      return item.key == 'tenderId' && item.enabled == true;
    }) : true;
    var baseInfo = (_d = [{
      label: '管理单位',
      key: 'manageUnitName',
      value: info === null || info === void 0 ? void 0 : info.manageUnitName
    }, {
      label: '路段长度',
      key: 'roadSpace',
      value: "".concat((info === null || info === void 0 ? void 0 : info.roadSpace) || '0', "m")
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }, {
      label: '路段宽度(m)',
      key: 'roadWidth',
      value: "".concat((info === null || info === void 0 ? void 0 : info.roadWidth) || '0', "m")
    }, !(0, _utils.getUrlParam)('hideType') && {
      label: '路段类型',
      key: 'roadTypeName',
      value: info === null || info === void 0 ? void 0 : info.roadTypeName
    }, showbidSection && {
      label: '所属标段',
      key: 'bidSectionName',
      value: info === null || info === void 0 ? void 0 : info.bidSectionName
    }, {
      label: '作业单位',
      key: 'companyName',
      value: info === null || info === void 0 ? void 0 : info.companyName
    }]) === null || _d === void 0 ? void 0 : _d.filter(Boolean);
    // 今日作业
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/kanban/workOverview"), {
          data: {
            roadId: id,
            date: date
          }
        });
      }, {
        refreshDeps: [id, loading],
        ready: !loading
      }),
      todayWorkRes = _useRequest4.data;
    return {
      baseInfo: baseInfo,
      rules: (info === null || info === void 0 ? void 0 : info.rules) || [],
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || [],
      info: baseInfoRes === null || baseInfoRes === void 0 ? void 0 : baseInfoRes.data
    };
  },
  useJcss: function useJcss(id, coordType) {
    var _a, _b, _c, _d, _e, _f;
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/get', {
          data: {
            id: id,
            coordType: coordType || 'bd09'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      jcssBaseInfoRes = _useRequest5.data;
    var jcssInfo = jcssBaseInfoRes === null || jcssBaseInfoRes === void 0 ? void 0 : jcssBaseInfoRes.data;
    var hasRule = ((_b = (_a = jcssInfo === null || jcssInfo === void 0 ? void 0 : jcssInfo.dataJson) === null || _a === void 0 ? void 0 : _a.roadWorkTypeId) === null || _b === void 0 ? void 0 : _b.indexOf('jxhbj')) > -1;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: 'tr'
          }
        });
      }, {
        refreshDeps: [id]
      }),
      tabConfig = _useRequest6.data;
    return {
      jcssInfo: jcssInfo,
      hasRule: hasRule,
      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 {
          key: ele.code,
          title: ele.name
        };
      })) || [],
      visited: !!tabConfig
    };
  },
  useRecordService: function useRecordService(id, date, service) {
    // 车辆作业信息
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/kanban/getCarWorkInfoByRoadId"), {
          data: {
            roadId: id,
            date: date
          }
        });
      }, {
        refreshDeps: [id, date, service]
      }),
      carWorkRecordRes = _useRequest7.data;
    return {
      carWorkRecord: (carWorkRecordRes === null || carWorkRecordRes === void 0 ? void 0 : carWorkRecordRes.data) || []
    };
  }
};
var StaticService = exports.StaticService = {
  useSummaryInfo: function useSummaryInfo(id, startDate, endDate, service) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/kanban/summaryStatistics"), {
          data: {
            roadId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, service]
      }),
      summaryInfoRes = _useRequest8.data;
    var summaryInfo = summaryInfoRes === null || summaryInfoRes === void 0 ? void 0 : summaryInfoRes.data;
    //完成率统计
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/kanban/completionRateStatistics"), {
          data: {
            roadId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, service]
      }),
      completionRateRes = _useRequest9.data;
    var completionRate = completionRateRes === null || completionRateRes === void 0 ? void 0 : completionRateRes.data;
    // 作业里程分析
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/".concat(service ? service : 'zyqs-reborn', "/api/kanban/workMileageAnalysis"), {
          data: {
            roadId: id,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, service]
      }),
      mileAnalysisRes = _useRequest10.data;
    var mileAnalysis = (mileAnalysisRes === null || mileAnalysisRes === void 0 ? void 0 : mileAnalysisRes.data) || [];
    return {
      summaryInfo: summaryInfo,
      completionRate: completionRate,
      mileAnalysis: mileAnalysis
    };
  }
};
//# sourceMappingURL=api.js.map
