"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EquipmentService = exports.BaseService = exports.AttendanceService = exports.AlarmService = void 0;
var _utils = require("@vtx/utils");
var _ahooks = require("ahooks");
var _config = require("./config");
var BaseService = exports.BaseService = {
  useTabConfig: function useTabConfig(id) {
    var _a, _b, _c, _d, _e;
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
          data: {
            code: 'staff'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      tabConfig = _useRequest.data;
    return {
      tabIsFilter: !!((_b = (_a = tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.data) === null || _a === void 0 ? void 0 : _a.popupConfigJson) === null || _b === void 0 ? void 0 : _b.length),
      tabConfig: ((_e = (_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.filter(function (ele) {
        return ele.display;
      })) === null || _e === void 0 ? void 0 : _e.map(function (ele) {
        return {
          key: ele.code,
          title: ele.name
        };
      })) || []
    };
  },
  useBaseInfo: function useBaseInfo(id) {
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rygl/api/v101/cleaner/get', {
          data: {
            id: id,
            desensitization: true
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest2.data;
    var info = baseInfoRes ? baseInfoRes.data : {};
    var baseInfo = [{
      label: '编号',
      key: 'staffCode',
      value: info === null || info === void 0 ? void 0 : info.staffCode
    }, {
      label: '所属单位',
      key: 'unitName',
      value: info === null || info === void 0 ? void 0 : info.unitName
    }, {
      label: '性别',
      key: 'genderName',
      value: info === null || info === void 0 ? void 0 : info.genderName
    }, {
      label: '入职日期',
      key: 'entryDay',
      value: info === null || info === void 0 ? void 0 : info.entryDay
    }, {
      label: '在职状态',
      key: 'jobStatusName',
      value: info === null || info === void 0 ? void 0 : info.jobStatusName
    }, {
      label: '所属标段',
      key: 'tenderName',
      value: info === null || info === void 0 ? void 0 : info.tenderName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }];
    return {
      baseInfo: baseInfo,
      detail: info || {}
    };
  },
  // 实时信息
  useMapInfo: function useMapInfo(id, coordType) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j;
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/realtime/getStaffDetail', {
          data: {
            staffId: id,
            coordType: coordType || 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      mapInfoRes = _useRequest3.data;
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rygl/workElementCleaner/getByStaffId', {
          data: {
            staffId: id,
            coordType: coordType || 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      areas = _useRequest4.data;
    return {
      info: mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data,
      mapPoints: ((_a = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _a === void 0 ? void 0 : _a.lngDone) ? [{
        id: 'reaiPoint',
        name: mapInfoRes.data.staffName,
        canShowLabel: true,
        config: {
          labelContent: mapInfoRes.data.staffName
        },
        lng: mapInfoRes.data.lngDone,
        lat: mapInfoRes.data.latDone,
        labelClass: 'vtx-map-carCode',
        url: ((_b = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _b === void 0 ? void 0 : _b.icon) ? "/cloudFile/common/downloadFile?id=".concat((_c = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _c === void 0 ? void 0 : _c.icon, "&token=").concat((0, _utils.getVtxToken)('token')) : _config.treeIcons[((_d = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _d === void 0 ? void 0 : _d.statusCode) === 'Normal' ? 'onlinePeople' : 'offlinePeople']
      }] : [],
      pointLngLat: ((_e = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _e === void 0 ? void 0 : _e.lngDone) ? [mapInfoRes.data.lngDone, mapInfoRes.data.latDone] : [],
      mapPolygons: (areas === null || areas === void 0 ? void 0 : areas.data) ? (_g = (_f = areas.data) === null || _f === void 0 ? void 0 : _f.filter(function (ele) {
        return ele.shape !== 'circle';
      })) === null || _g === void 0 ? void 0 : _g.map(function (item) {
        return Object.assign(Object.assign({}, item), {
          rings: item.paramsDone,
          type: item.shape
        });
      }) : [],
      mapCircles: (_j = (_h = areas === null || areas === void 0 ? void 0 : areas.data) === null || _h === void 0 ? void 0 : _h.filter(function (ele) {
        return ele.shape === 'circle';
      })) === null || _j === void 0 ? void 0 : _j.map(function (item) {
        return {
          id: item.id,
          data: item.paramsDone.split(',').map(function (ele) {
            return Number(ele);
          }).concat([item.radius]),
          type: item.shape
        };
      })
    };
  },
  useFieldConfig: function useFieldConfig(id) {
    var _a;
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rygl/api/v101/staff/dataConfig/list', {
          data: {
            id: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      configRes = _useRequest5.data;
    return {
      showFields: ((_a = configRes === null || configRes === void 0 ? void 0 : configRes.data) === null || _a === void 0 ? void 0 : _a.filter(function (ele) {
        return ele.addVisible;
      })) || []
    };
  },
  getHistoryContract: function getHistoryContract(id) {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/contract/staffHistoryContract', {
          data: {
            staffId: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      data = _useRequest6.data;
    return {
      serviceList: data === null || data === void 0 ? void 0 : data.data
    };
  },
  useWorkInfo: function useWorkInfo(staffId, startDate, endDate) {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanWorkInfo', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      workInfoRes = _useRequest7.data;
    return {
      workInfoRes: (workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.data) || {}
    };
  },
  // 今日作业
  useTodayWork: function useTodayWork(staffId, startDate, endDate, page) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanShiftWorkInfoPage', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate,
            pageNo: page,
            pageSize: 20
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate, page]
      }),
      todayWorkRes = _useRequest8.data;
    return {
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || []
    };
  },
  // 作业统计
  useWorkStatic: function useWorkStatic(staffId, startDate, endDate) {
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanWorkInfoStatistics', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      workStaticRes = _useRequest9.data;
    return {
      workStaticRes: (workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.data) || {}
    };
  },
  // 里程分析
  useMileAnalysis: function useMileAnalysis(staffId, startDate, endDate) {
    var _useRequest0 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanWorkMileageAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      mileAnalysisRes = _useRequest0.data;
    return {
      mileAnalysisRes: (mileAnalysisRes === null || mileAnalysisRes === void 0 ? void 0 : mileAnalysisRes.data) || {}
    };
  },
  statisticsByMonth: function statisticsByMonth(id, month) {
    //日历
    var _useRequest1 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rygl/api/v101/attendanceRecord/statisticsByMonth', {
          data: {
            staffId: id,
            month: month
          }
        });
      }, {
        refreshDeps: [id, month]
      }),
      dailyCarRunRes = _useRequest1.data;
    return {
      dailyCarRunRes: (dailyCarRunRes === null || dailyCarRunRes === void 0 ? void 0 : dailyCarRunRes.data) || []
    };
  }
};
var AlarmService = exports.AlarmService = {
  // 报警类型
  useAlarmType: function useAlarmType(staffId, startTime, endTime) {
    var _a;
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/alarmInfo/pageAlarmCount', {
          data: {
            staffId: staffId,
            startTime: startTime,
            endTime: endTime
          }
        });
      }, {
        refreshDeps: [staffId, startTime, endTime]
      }),
      alarmTypeRes = _useRequest10.data;
    return {
      alarmTypeRes: ((_a = alarmTypeRes === null || alarmTypeRes === void 0 ? void 0 : alarmTypeRes.data) === null || _a === void 0 ? void 0 : _a.length) > 0 ? alarmTypeRes.data.map(function (ele) {
        return Object.assign({
          name: ele.alarmTypeName,
          value: ele.count,
          label: "".concat(ele.alarmTypeName, "(").concat(ele.count, ")"),
          key: ele.alarmTypeCode || 'all'
        }, ele);
      }) : []
    };
  },
  // 报警类型分析
  useAlarmAnalysis: function useAlarmAnalysis(staffId, startDate, endDate) {
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanAlarmAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      alarmAnalysisRes = _useRequest11.data;
    return {
      alarmAnalysisRes: (alarmAnalysisRes === null || alarmAnalysisRes === void 0 ? void 0 : alarmAnalysisRes.data) || {}
    };
  },
  // 报警列表
  useAlarmRecord: function useAlarmRecord(staffId, alarmTypeCode, startTime, endTime, pageNo, sortBy, order) {
    var _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/alarmInfo/page', {
          data: {
            staffId: staffId,
            alarmTypeCode: alarmTypeCode,
            startTime: startTime,
            endTime: endTime,
            pageNo: pageNo,
            pageSize: 10,
            sortBy: sortBy,
            order: order
          }
        });
      }, {
        refreshDeps: [staffId, alarmTypeCode, startTime, endTime, pageNo, sortBy, order]
      }),
      alarmRecordRes = _useRequest12.data;
    return {
      alarmRecordRes: (alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) || {}
    };
  }
};
// 考勤信息
var AttendanceService = exports.AttendanceService = {
  useTimeAnalysis: function useTimeAnalysis(staffId, startDate, endDate) {
    var _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanAttendanceTimeAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendTimeAnalysisRes = _useRequest13.data;
    return {
      attendTimeAnalysisRes: (attendTimeAnalysisRes === null || attendTimeAnalysisRes === void 0 ? void 0 : attendTimeAnalysisRes.data) || {}
    };
  },
  useAnalysis: function useAnalysis(staffId, startDate, endDate) {
    var _a;
    var _useRequest14 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/kanban/kanbanAttendanceAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendAnalysisRes = _useRequest14.data;
    return {
      attendAnalysisRes: ((_a = attendAnalysisRes === null || attendAnalysisRes === void 0 ? void 0 : attendAnalysisRes.data) === null || _a === void 0 ? void 0 : _a.length) > 0 ? attendAnalysisRes.data.map(function (ele) {
        return Object.assign({
          name: ele.alarmTypeName,
          value: ele.count
        }, ele);
      }) : []
    };
  },
  useAttendRecord: function useAttendRecord(staffId, startTime, endTime, pageNo, shiftClockWay) {
    var _useRequest15 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rygl/api/v101/attendanceRecord', {
          data: {
            staffId: staffId,
            startTime: startTime,
            endTime: endTime,
            pageNo: pageNo,
            pageSize: 10,
            DATA_TYPE: 'PAGE',
            shiftClockWay: shiftClockWay
          }
        });
      }, {
        refreshDeps: [staffId, shiftClockWay, startTime, endTime, pageNo]
      }),
      attendRecordRes = _useRequest15.data;
    return {
      attendRecordRes: (attendRecordRes === null || attendRecordRes === void 0 ? void 0 : attendRecordRes.data) || {}
    };
  }
};
var EquipmentService = exports.EquipmentService = {
  useDevice: function useDevice(staffId) {
    var _useRequest16 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/device/getByStaffId', {
          data: {
            staffId: staffId
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      deviceRes = _useRequest16.data;
    var _useRequest17 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/positionRealtime/getByStaffId', {
          data: {
            staffId: staffId
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      monitorRes = _useRequest17.data;
    return {
      deviceRes: (deviceRes === null || deviceRes === void 0 ? void 0 : deviceRes.data) || {},
      monitorRes: (monitorRes === null || monitorRes === void 0 ? void 0 : monitorRes.data) || {}
    };
  },
  useDeviceStatus: function useDeviceStatus(id) {
    var _useRequest18 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/rykq/api/v101/positionRealtime/deviceStatus', {
          data: {
            id: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      deviceStatusRes = _useRequest18.data;
    return {
      deviceStatusRes: (deviceStatusRes === null || deviceStatusRes === void 0 ? void 0 : deviceStatusRes.data) || '-'
    };
  }
};
//# sourceMappingURL=api.js.map
