feat: Enhance process and work standard management functionalities

- Updated the processInfoController to allow for flexible use_yn filtering, supporting both "Y" and "N" values along with their corresponding "USE_Y" and "USE_N" mappings.
- Modified the processWorkStandardController to include selected_bom_items in work item details, enabling better management of BOM data.
- Improved the productionPlanService to handle order summaries more effectively, incorporating legacy and detail data through a unified query structure.
- Enhanced the receiving and outbound pages with new filtering and grouping functionalities, improving user experience and data handling.

These changes aim to streamline process management and improve overall functionality across various modules.
This commit is contained in:
kjs
2026-04-06 15:50:33 +09:00
parent b974139abe
commit cf9f53e4c5
10 changed files with 1293 additions and 177 deletions

View File

@@ -463,7 +463,7 @@ export async function getWorkItemDetails(req: AuthenticatedRequest, res: Respons
SELECT id, work_item_id, detail_type, content, is_required, sort_order, remark,
inspection_code, inspection_method, unit, lower_limit, upper_limit,
duration_minutes, input_type, lookup_target, display_fields,
created_date
selected_bom_items, created_date
FROM process_work_item_detail
WHERE work_item_id = $1 AND company_code = $2
ORDER BY sort_order, created_date
@@ -492,6 +492,7 @@ export async function createWorkItemDetail(req: AuthenticatedRequest, res: Respo
work_item_id, detail_type, content, is_required, sort_order, remark,
inspection_code, inspection_method, unit, lower_limit, upper_limit,
duration_minutes, input_type, lookup_target, display_fields,
selected_bom_items,
} = req.body;
if (!work_item_id || !content) {
@@ -514,11 +515,14 @@ export async function createWorkItemDetail(req: AuthenticatedRequest, res: Respo
INSERT INTO process_work_item_detail
(company_code, work_item_id, detail_type, content, is_required, sort_order, remark, writer,
inspection_code, inspection_method, unit, lower_limit, upper_limit,
duration_minutes, input_type, lookup_target, display_fields)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
duration_minutes, input_type, lookup_target, display_fields, selected_bom_items)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18)
RETURNING *
`;
// selected_bom_items: 배열이면 JSON 문자열로 변환
const bomItemsJson = Array.isArray(selected_bom_items) ? JSON.stringify(selected_bom_items) : selected_bom_items || null;
const result = await getPool().query(query, [
companyCode,
work_item_id,
@@ -537,6 +541,7 @@ export async function createWorkItemDetail(req: AuthenticatedRequest, res: Respo
input_type || null,
lookup_target || null,
display_fields || null,
bomItemsJson,
]);
logger.info("작업 항목 상세 생성", { companyCode, id: result.rows[0].id });
@@ -562,8 +567,11 @@ export async function updateWorkItemDetail(req: AuthenticatedRequest, res: Respo
detail_type, content, is_required, sort_order, remark,
inspection_code, inspection_method, unit, lower_limit, upper_limit,
duration_minutes, input_type, lookup_target, display_fields,
selected_bom_items,
} = req.body;
const bomItemsJson = Array.isArray(selected_bom_items) ? JSON.stringify(selected_bom_items) : selected_bom_items ?? null;
const query = `
UPDATE process_work_item_detail
SET detail_type = COALESCE($1, detail_type),
@@ -580,6 +588,7 @@ export async function updateWorkItemDetail(req: AuthenticatedRequest, res: Respo
input_type = $14,
lookup_target = $15,
display_fields = $16,
selected_bom_items = $17,
updated_date = NOW()
WHERE id = $6 AND company_code = $7
RETURNING *
@@ -602,6 +611,7 @@ export async function updateWorkItemDetail(req: AuthenticatedRequest, res: Respo
input_type || null,
lookup_target || null,
display_fields || null,
bomItemsJson,
]);
if (result.rowCount === 0) {
@@ -889,7 +899,22 @@ export async function registerItemsBatch(req: AuthenticatedRequest, res: Respons
RETURNING *`,
[screenCode, item.itemId, item.itemCode || null, companyCode, req.user?.userId || null]
);
if (result.rows[0]) inserted.push(result.rows[0]);
if (result.rows[0]) {
inserted.push(result.rows[0]);
// 기본 라우팅 버전이 없으면 자동 생성
const itemCode = item.itemCode || item.itemId;
const existingVersion = await client.query(
`SELECT id FROM item_routing_version WHERE item_code = $1 AND company_code = $2 LIMIT 1`,
[itemCode, companyCode]
);
if (existingVersion.rowCount === 0) {
await client.query(
`INSERT INTO item_routing_version (id, company_code, item_code, version_name, description, is_default, writer)
VALUES (gen_random_uuid()::text, $1, $2, '기본', '자동 생성된 기본 라우팅', true, $3)`,
[companyCode, itemCode, req.user?.userId || null]
);
}
}
}
await client.query("COMMIT");