"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 _moment = _interopRequireDefault(require("moment"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var BaseService = exports.BaseService = {
  useBaseInfo: function useBaseInfo(id, coordType) {
    var _a, _b, _c, _d;
    var _useRequest = (0, _ahooks.useRequest)(function () {
        return _utils.request.get("/cloud/management/workElement/findbyid/".concat(id, ".read"), {
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var _useRequest2 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByWorkElement', {
          data: {
            workElementId: id,
            needRealtimeInfo: true,
            date: (0, _moment["default"])().format('YYYY-MM-DD'),
            coordType: coordType || 'bd09'
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id && !!coordType,
        refreshDeps: [id, coordType]
      }),
      numInfo = _useRequest2.data;
    var info = baseInfoRes || {};
    var mapPolygons = ((_a = info === null || info === void 0 ? void 0 : info.paramsDone) === null || _a === void 0 ? void 0 : _a.length) ? [{
      id: 'polygon',
      rings: info === null || info === void 0 ? void 0 : info.paramsDone,
      config: {
        color: 'red',
        lineColor: 'red',
        lineWidth: 1
      }
    }] : [];
    var mapPoints = ((_c = (_b = numInfo === null || numInfo === void 0 ? void 0 : numInfo.data) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.length) ? numInfo.data.list.map(function (item) {
      return Object.assign(Object.assign({}, item), {
        id: item.staffId,
        canShowLabel: true,
        labelClass: 'vtx-map-carCode',
        lng: item.lngDone,
        lat: item.latDone,
        layerType: 'staff',
        staffName: item.staffName,
        url: item.icon ? "/cloudFile/common/downloadFile?id=".concat(item.icon, "&token=").concat((0, _utils.getVtxToken)('token')) : _config.treeIcons[item.statusCode === 'Normal' ? 'onlinePeople' : 'offlinePeople'],
        config: {
          width: 30,
          height: 30,
          labelContent: item.staffName
        }
      });
    }) : [];
    var baseInfo = [{
      label: '编码',
      key: 'code',
      value: info === null || info === void 0 ? void 0 : info.code
    }, {
      label: '区域类型',
      key: 'workElementTypeName',
      value: info === null || info === void 0 ? void 0 : info.workElementTypeName
    }, {
      label: '所属机构',
      key: 'departmentName',
      value: info === null || info === void 0 ? void 0 : info.departmentName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }];
    return {
      baseInfo: baseInfo,
      numInfo: ((_d = numInfo === null || numInfo === void 0 ? void 0 : numInfo.data) === null || _d === void 0 ? void 0 : _d.realtime) || {},
      mapPolygons: mapPolygons,
      mapPoints: mapPoints
    };
  },
  useDetailInfo: function useDetailInfo(id) {
    var _useRequest3 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/cleaner/get', {
          data: {
            id: id
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      detailInfoRes = _useRequest3.data;
    return {
      detail: (detailInfoRes === null || detailInfoRes === void 0 ? void 0 : detailInfoRes.data) || {}
    };
  },
  useFieldConfig: function useFieldConfig(id) {
    var _a;
    var _useRequest4 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/staff/dataConfig/list', {
          data: {
            id: id
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      configRes = _useRequest4.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 _useRequest5 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/jcss-reborn/contract/staffHistoryContract', {
          data: {
            staffId: id
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      data = _useRequest5.data;
    return {
      serviceList: data === null || data === void 0 ? void 0 : data.data
    };
  },
  useWorkInfo: function useWorkInfo(id, date) {
    var _useRequest6 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByWorkElement', {
          data: {
            workElementId: id,
            date: date
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [id, date]
      }),
      workInfoRes = _useRequest6.data;
    return {
      workInfoRes: (workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.data) || {}
    };
  },
  // 今日作业
  useTodayWork: function useTodayWork(id, startDate, endDate, page) {
    var _useRequest7 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord', {
          data: {
            matchWorkElementId: id,
            startTime: startDate,
            endTime: endDate,
            pageNo: page,
            pageSize: 20
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [id, startDate, endDate, page]
      }),
      todayWorkRes = _useRequest7.data;
    return {
      todayWorkRes: (todayWorkRes === null || todayWorkRes === void 0 ? void 0 : todayWorkRes.data) || []
    };
  },
  // 作业统计
  useWorkStatic: function useWorkStatic(staffId, startDate, endDate) {
    var _useRequest8 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkInfoStatistics', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      workStaticRes = _useRequest8.data;
    return {
      workStaticRes: (workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.data) || {}
    };
  },
  // 里程分析
  useMileAnalysis: function useMileAnalysis(staffId, startDate, endDate) {
    var _useRequest9 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanWorkMileageAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      mileAnalysisRes = _useRequest9.data;
    return {
      mileAnalysisRes: (mileAnalysisRes === null || mileAnalysisRes === void 0 ? void 0 : mileAnalysisRes.data) || {}
    };
  },
  useDailyCarRun: function useDailyCarRun(id, beginTime, endTime) {
    //今日运行
    var _useRequest10 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/gps-reborn/report/dailyCarRun/list', {
          data: {
            carIds: id,
            reportDateStart: beginTime,
            reportDateEnd: endTime
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [id, beginTime, endTime]
      }),
      dailyCarRunRes = _useRequest10.data;
    return {
      dailyCarRunRes: (dailyCarRunRes === null || dailyCarRunRes === void 0 ? void 0 : dailyCarRunRes.data) || []
    };
  },
  statisticsByMonth: function statisticsByMonth(id, month) {
    //日历
    var _useRequest11 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/attendanceRecord/statisticsByMonth', {
          data: {
            staffId: id,
            month: month
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [id, month]
      }),
      dailyCarRunRes = _useRequest11.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 _useRequest12 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/alarmInfo/pageAlarmCount', {
          data: {
            staffId: staffId,
            startTime: startTime,
            endTime: endTime
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startTime, endTime]
      }),
      alarmTypeRes = _useRequest12.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 _useRequest13 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAlarmAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      alarmAnalysisRes = _useRequest13.data;
    return {
      alarmAnalysisRes: (alarmAnalysisRes === null || alarmAnalysisRes === void 0 ? void 0 : alarmAnalysisRes.data) || {}
    };
  },
  // 报警列表
  useAlarmRecord: function useAlarmRecord(staffId, alarmTypeCode, startTime, endTime, pageNo, sortBy, order) {
    var _useRequest14 = (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
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, alarmTypeCode, startTime, endTime, pageNo, sortBy, order]
      }),
      alarmRecordRes = _useRequest14.data;
    return {
      alarmRecordRes: (alarmRecordRes === null || alarmRecordRes === void 0 ? void 0 : alarmRecordRes.data) || {}
    };
  }
};
// 考勤信息
var AttendanceService = exports.AttendanceService = {
  useTimeAnalysis: function useTimeAnalysis(staffId, startDate, endDate) {
    var _useRequest15 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAttendanceTimeAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendTimeAnalysisRes = _useRequest15.data;
    return {
      attendTimeAnalysisRes: (attendTimeAnalysisRes === null || attendTimeAnalysisRes === void 0 ? void 0 : attendTimeAnalysisRes.data) || {}
    };
  },
  useAnalysis: function useAnalysis(staffId, startDate, endDate) {
    var _a;
    var _useRequest16 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/kanban/kanbanAttendanceAnalysis', {
          data: {
            staffId: staffId,
            startDate: startDate,
            endDate: endDate
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startDate, endDate]
      }),
      attendAnalysisRes = _useRequest16.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 _useRequest17 = (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
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId, startTime, endTime, pageNo]
      }),
      attendRecordRes = _useRequest17.data;
    return {
      attendRecordRes: (attendRecordRes === null || attendRecordRes === void 0 ? void 0 : attendRecordRes.data) || {}
    };
  }
};
var EquipmentService = exports.EquipmentService = {
  useDevice: function useDevice(staffId) {
    var _useRequest18 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/device/getByStaffId', {
          data: {
            staffId: staffId
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      deviceRes = _useRequest18.data;
    var _useRequest19 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/positionRealtime/getByStaffId', {
          data: {
            staffId: staffId
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        refreshDeps: [staffId]
      }),
      monitorRes = _useRequest19.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 _useRequest20 = (0, _ahooks.useRequest)(function () {
        return _utils.request.get('/cloud/zyry-reborn/api/v101/positionRealtime/deviceStatus', {
          data: {
            id: id
          },
          extraHeader: {
            systemCode: (0, _utils.getUrlParam)('systemCode')
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      deviceStatusRes = _useRequest20.data;
    return {
      deviceStatusRes: (deviceStatusRes === null || deviceStatusRes === void 0 ? void 0 : deviceStatusRes.data) || '-'
    };
  }
};
//# sourceMappingURL=api.js.map
