- receivingController: 헤더-디테일 JOIN 구조로 변경, 검색/조회 로직 개선 - materialStatusController: work_instruction 테이블 기반으로 쿼리 수정 - analyticsReportController: 구매 리포트 company_code 필터링 로직 개선 - material-status 페이지: COMPANY_29/COMPANY_7 프론트엔드 업데이트 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
94 lines
2.2 KiB
TypeScript
94 lines
2.2 KiB
TypeScript
/**
|
|
* 자재현황 API 클라이언트
|
|
*/
|
|
|
|
import { apiClient } from "./client";
|
|
|
|
export interface WorkOrder {
|
|
id: string;
|
|
plan_no: string;
|
|
item_code: string;
|
|
item_name: string;
|
|
plan_qty: number;
|
|
completed_qty: number;
|
|
plan_date: string;
|
|
start_date: string | null;
|
|
end_date: string | null;
|
|
status: string;
|
|
work_order_no: string | null;
|
|
company_code: string;
|
|
}
|
|
|
|
export interface MaterialLocation {
|
|
location: string;
|
|
warehouse: string;
|
|
qty: number;
|
|
}
|
|
|
|
export interface MaterialData {
|
|
code: string;
|
|
name: string;
|
|
required: number;
|
|
current: number;
|
|
unit: string;
|
|
locations: MaterialLocation[];
|
|
}
|
|
|
|
export interface WarehouseData {
|
|
warehouse_code: string;
|
|
warehouse_name: string;
|
|
warehouse_type: string | null;
|
|
}
|
|
|
|
interface ApiResponse<T> {
|
|
success: boolean;
|
|
data?: T;
|
|
message?: string;
|
|
}
|
|
|
|
export async function getWorkOrders(params: {
|
|
dateFrom?: string;
|
|
dateTo?: string;
|
|
itemCode?: string;
|
|
itemName?: string;
|
|
}): Promise<ApiResponse<WorkOrder[]>> {
|
|
try {
|
|
const queryParams = new URLSearchParams();
|
|
if (params.dateFrom) queryParams.append("dateFrom", params.dateFrom);
|
|
if (params.dateTo) queryParams.append("dateTo", params.dateTo);
|
|
if (params.itemCode) queryParams.append("itemCode", params.itemCode);
|
|
if (params.itemName) queryParams.append("itemName", params.itemName);
|
|
|
|
const qs = queryParams.toString();
|
|
const url = `/material-status/work-orders${qs ? `?${qs}` : ""}`;
|
|
const response = await apiClient.get(url);
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|
|
|
|
export async function getMaterialStatus(params: {
|
|
planIds: string[];
|
|
warehouseCode?: string;
|
|
}): Promise<ApiResponse<MaterialData[]>> {
|
|
try {
|
|
const response = await apiClient.post(
|
|
"/material-status/materials",
|
|
params
|
|
);
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|
|
|
|
export async function getWarehouses(): Promise<ApiResponse<WarehouseData[]>> {
|
|
try {
|
|
const response = await apiClient.get("/material-status/warehouses");
|
|
return response.data;
|
|
} catch (error: any) {
|
|
return { success: false, message: error.message };
|
|
}
|
|
}
|