VehicleController.ts 5.43 KB
import { AxiosResponse, AxiosStatic } from "axios";
import dayjs, { Dayjs } from "dayjs";
// region 前端扩展导入包
import { Vehicle } from "lib/src/entity/vehicle/entity/Vehicle";
import { Page } from "autumn-vue/lib/core/page/Page";
import { VehicleHistoryProjection } from "lib/src/entity/vehicle/domain/VehicleHistoryProjection";
import { NameCount } from "lib/src/entity/analysis/domain/NameCount";
import { FileInfo } from "autumn-vue/lib/core/bean/FileInfo";
// endregion

/**
 * 库存车辆(Vehicle) PI接口
 * @author gonglei
 * @since 2025-10-13 12:18:11
 */
export class VehicleController {
	/**
	 * 新增库存车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	static addVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/addVehicle", vehicle);
	}

	/**
	 */
	static exportCheckedVehicles(axios: AxiosStatic, vehicleIds: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportCheckedVehicles", vehicleIds, config);
	}

	/**
	 */
	static exportPriceVehicles(axios: AxiosStatic, pagination: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportPriceVehicles", pagination, config);
	}

	/**
	 * 导出车辆列表
	 * @param pagination
	 * @param response
	 * @throws IOException
	 */
	static exportVehicles(axios: AxiosStatic, pagination: any, config?: any): Promise<AxiosResponse<void>> {
		return axios.post("vehicle/exportVehicles", pagination, config);
	}

	/**
	 */
	static getTop3VehiclesByInventory(axios: AxiosStatic): Promise<AxiosResponse<Vehicle[]>> {
		return axios.get("vehicle/getTop3VehiclesByInventory");
	}

	/**
	 * 按车辆品牌统计车辆数量
	 * @return List
	 */
	static getVehicleBrandCounts(axios: AxiosStatic): Promise<AxiosResponse<NameCount[]>> {
		return axios.get("vehicle/getVehicleBrandCounts");
	}

	/**
	 * 根据id查询库存车辆
	 * @param vehicleId
	 * @return Vehicle
	 */
	static getVehicleById(axios: AxiosStatic, vehicleId: number): Promise<AxiosResponse<Vehicle>> {
		return axios.get("vehicle/getVehicleById", { params: { vehicleId: vehicleId } });
	}

	/**
	 */
	static getVehicleCountByProvinceName(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByProvinceName");
	}

	/**
	 */
	static getVehicleCountBySource(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountBySource");
	}

	/**
	 */
	static getVehicleCountByState(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByState");
	}

	/**
	 */
	static getVehicleCountByStateAndDateRange(
		axios: AxiosStatic,
		startDate: Dayjs | string,
		endDate: Dayjs | string,
	): Promise<AxiosResponse<any>> {
		if (startDate instanceof Object) {
			startDate = dayjs(startDate).format("YYYY-MM-DD");
		}
		if (endDate instanceof Object) {
			endDate = dayjs(endDate).format("YYYY-MM-DD");
		}

		return axios.get("vehicle/getVehicleCountByStateAndDateRange", {
			params: { startDate: startDate, endDate: endDate },
		});
	}

	/**
	 */
	static getVehicleCountByVehicleClass(axios: AxiosStatic): Promise<AxiosResponse<any>> {
		return axios.get("vehicle/getVehicleCountByVehicleClass");
	}

	/**
	 */
	static getVehicleHistories(
		axios: AxiosStatic,
		vehicleId: number,
	): Promise<AxiosResponse<VehicleHistoryProjection[]>> {
		return axios.get("vehicle/getVehicleHistories", { params: { vehicleId: vehicleId } });
	}

	/**
	 */
	static moveVehicleAlbum(
		axios: AxiosStatic,
		uid: string,
		fileSubtype: string,
		vehicleId: number,
	): Promise<AxiosResponse<number>> {
		return axios.get("vehicle/moveVehicleAlbum", {
			params: { uid: uid, fileSubtype: fileSubtype, vehicleId: vehicleId },
		});
	}

	/**
	 */
	static pagePriceVehicle(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Vehicle>>> {
		return axios.post("vehicle/pagePriceVehicle", pagination);
	}

	static PAGE_PRICE_VEHICLE = "vehicle/pagePriceVehicle";

	/**
	 * 分页查询库存车辆
	 * @param pagination
	 * @return Page
	 */
	static pageVehicle(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Vehicle>>> {
		return axios.post("vehicle/pageVehicle", pagination);
	}

	static PAGE_VEHICLE = "vehicle/pageVehicle";

	/**
	 * 删除库存车辆
	 * @param vehicleId
	 * @return int
	 */
	static removeVehicleById(axios: AxiosStatic, vehicleId: number): Promise<AxiosResponse<number>> {
		return axios.delete("vehicle/removeVehicleById", { params: { vehicleId: vehicleId } });
	}

	/**
	 * 修改库存车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	static updateVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/updateVehicle", vehicle);
	}

	/**
	 * x修改车辆地点
	 * @param vehicleVenue
	 * @return Vehicle
	 */
	static updateVehicleVenue(axios: AxiosStatic, vehicleVenue: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/updateVehicleVenue", vehicleVenue);
	}

	/**
	 * 更新车辆封面
	 */
	static uploadVehicleCover(axios: AxiosStatic, fileInfo: any, vehicleId: number): Promise<AxiosResponse<FileInfo>> {
		return axios.post("vehicle/uploadVehicleCover", fileInfo, { params: { vehicleId: vehicleId } });
	}

	/**
	 * 整备入库车辆
	 * @param vehicle
	 * @return Vehicle
	 */
	static warehousingVehicle(axios: AxiosStatic, vehicle: any): Promise<AxiosResponse<Vehicle>> {
		return axios.post("vehicle/warehousingVehicle", vehicle);
	}

	// region 前端扩展代码区
	// endregion
}