"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 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 _a;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.post('/cloud/sjzt-reborn/api/v101/dataSet/execute', {
          data: JSON.stringify({
            code: 'ZYRY_STAFF_INFO',
            parameters: {
              staffId: id
            }
          })
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest2.data;
    var info = baseInfoRes ? (_a = baseInfoRes.data) === null || _a === void 0 ? void 0 : _a[0] : {};
    var baseInfo = [{
      label: '编号',
      key: 'code',
      value: info === null || info === void 0 ? void 0 : info.code
    }, {
      label: '所属单位',
      key: 'deptName',
      value: info === null || info === void 0 ? void 0 : info.deptName
    }, {
      label: '性别',
      key: 'gender',
      value: info === null || info === void 0 ? void 0 : info.gender
    }, {
      label: '入职日期',
      key: 'entryDay',
      value: info === null || info === void 0 ? void 0 : info.entryDay
    }, {
      label: '在职状态',
      key: 'isLeaveName',
      value: info === null || info === void 0 ? void 0 : info.isLeaveName
    }, {
      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,
      info: info
    };
  },
  // 实时信息
  useMapInfo: function useMapInfo(id, coordType) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/realtime/getStaffDetail', {
          data: {
            staffId: id,
            coordType: coordType || 'bd09'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      mapInfoRes = _useRequest3.data;
    // 获取排班记录的作业区域
    var shiftId = ((_b = (_a = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _a === void 0 ? void 0 : _a.currentShifts) === null || _b === void 0 ? void 0 : _b.length) ? (_d = (_c = mapInfoRes.data.currentShifts) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.shiftId : '';
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/realtime/getShift', {
          data: {
            shiftId: shiftId,
            coordType: coordType || 'bd09'
          }
        });
      }, {
        ready: !!shiftId,
        refreshDeps: [shiftId]
      }),
      shifts = _useRequest4.data;
    return {
      mapPoints: ((_e = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _e === void 0 ? void 0 : _e.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: ((_f = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _f === void 0 ? void 0 : _f.icon) ? "/cloudFile/common/downloadFile?id=".concat((_g = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _g === void 0 ? void 0 : _g.icon, "&token=").concat((0, _utils.getVtxToken)('token')) : ''
      }] : [],
      pointLngLat: ((_h = mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data) === null || _h === void 0 ? void 0 : _h.lngDone) ? [mapInfoRes.data.lngDone, mapInfoRes.data.latDone] : [],
      mapPolygons: ((_j = shifts === null || shifts === void 0 ? void 0 : shifts.data) === null || _j === void 0 ? void 0 : _j.length) ? (_k = shifts.data) === null || _k === void 0 ? void 0 : _k.map(function (item) {
        return Object.assign(Object.assign({}, item), {
          rings: item === null || item === void 0 ? void 0 : item.lngLatDones,
          config: {
            color: 'red',
            lineColor: 'red',
            lineWidth: 1
          }
        });
      }) : []
    };
  },
  useDetailInfo: function useDetailInfo(id) {
    var _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/cleaner/get', {
          data: {
            id: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      detailInfoRes = _useRequest5.data;
    return {
      detail: (detailInfoRes === null || detailInfoRes === void 0 ? void 0 : detailInfoRes.data) || {}
    };
  },
  useFieldConfig: function useFieldConfig(id) {
    var _a;
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/staff/dataConfig/list', {
          data: {
            id: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      configRes = _useRequest6.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 _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/contract/staffHistoryContract', {
          data: {
            staffId: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      data = _useRequest7.data;
    return {
      serviceList: data === null || data === void 0 ? void 0 : data.data
    };
  },
  useWorkInfo: function useWorkInfo(staffId, startDate, endDate) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkInfo', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      workInfoRes = _useRequest8.data;
    return {
      workInfoRes: (workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.data) || {}
    };
  },
  // 今日作业
  useTodayWork: function useTodayWork(staffId, startDate, endDate, page) {
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanShiftWorkInfoPage', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate,
            page: page,
            size: 20
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate, page]
      }),
      todayWorkRes = _useRequest9.data;
    return {
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || []
    };
  },
  // 作业统计
  useWorkStatic: function useWorkStatic(staffId, startDate, endDate) {
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkInfoStatistics', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      workStaticRes = _useRequest10.data;
    return {
      workStaticRes: (workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.data) || {}
    };
  },
  // 里程分析
  useMileAnalysis: function useMileAnalysis(staffId, startDate, endDate) {
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkMileageAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      mileAnalysisRes = _useRequest11.data;
    return {
      mileAnalysisRes: (mileAnalysisRes === null || mileAnalysisRes === void 0 ? void 0 : mileAnalysisRes.data) || {}
    };
  },
  useDailyCarRun: function useDailyCarRun(id, beginTime, endTime) {
    //今日运行
    var _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/gps-reborn/report/dailyCarRun/list', {
          data: {
            carIds: id,
            reportDateStart: beginTime,
            reportDateEnd: endTime
          }
        });
      }, {
        refreshDeps: [id, beginTime, endTime]
      }),
      dailyCarRunRes = _useRequest12.data;
    return {
      dailyCarRunRes: (dailyCarRunRes === null || dailyCarRunRes === void 0 ? void 0 : dailyCarRunRes.data) || []
    };
  },
  statisticsByMonth: function statisticsByMonth(id, month) {
    //日历
    var _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByMonth', {
          data: {
            staffId: id,
            month: month
          }
        });
      }, {
        refreshDeps: [id, month]
      }),
      dailyCarRunRes = _useRequest13.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 _useRequest14 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/alarmInfo/pageAlarmCount', {
          data: {
            staffId: staffId,
            startTime: startTime,
            endTime: endTime
          }
        });
      }, {
        refreshDeps: [staffId, startTime, endTime]
      }),
      alarmTypeRes = _useRequest14.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 _useRequest15 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAlarmAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      alarmAnalysisRes = _useRequest15.data;
    return {
      alarmAnalysisRes: (alarmAnalysisRes === null || alarmAnalysisRes === void 0 ? void 0 : alarmAnalysisRes.data) || {}
    };
  },
  // 报警列表
  useAlarmRecord: function useAlarmRecord(staffId, alarmTypeCode, startTime, endTime, pageNo, sortBy, order) {
    var _useRequest16 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/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 = _useRequest16.data;
    return {
      alarmRecordRes: (alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) || {}
    };
  }
};
// 考勤信息
var AttendanceService = exports.AttendanceService = {
  useTimeAnalysis: function useTimeAnalysis(staffId, startDate, endDate) {
    var _useRequest17 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAttendanceTimeAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendTimeAnalysisRes = _useRequest17.data;
    return {
      attendTimeAnalysisRes: (attendTimeAnalysisRes === null || attendTimeAnalysisRes === void 0 ? void 0 : attendTimeAnalysisRes.data) || {}
    };
  },
  useAnalysis: function useAnalysis(staffId, startDate, endDate) {
    var _a;
    var _useRequest18 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAttendanceAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendAnalysisRes = _useRequest18.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) {
    var _useRequest19 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord', {
          data: {
            staffId: staffId,
            startTime: startTime,
            endTime: endTime,
            pageNo: pageNo,
            pageSize: 10
          }
        });
      }, {
        refreshDeps: [staffId, startTime, endTime, pageNo]
      }),
      attendRecordRes = _useRequest19.data;
    return {
      attendRecordRes: (attendRecordRes === null || attendRecordRes === void 0 ? void 0 : attendRecordRes.data) || {}
    };
  }
};
var EquipmentService = exports.EquipmentService = {
  useDevice: function useDevice(staffId) {
    var _useRequest20 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/device/getByStaffId', {
          data: {
            staffId: staffId
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      deviceRes = _useRequest20.data;
    var _useRequest21 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/positionRealtime/getByStaffId', {
          data: {
            staffId: staffId
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      monitorRes = _useRequest21.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 _useRequest22 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/positionRealtime/deviceStatus', {
          data: {
            id: id
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      deviceStatusRes = _useRequest22.data;
    return {
      deviceStatusRes: (deviceStatusRes === null || deviceStatusRes === void 0 ? void 0 : deviceStatusRes.data) || '-'
    };
  }
};
//# sourceMappingURL=api.js.map
