fix: POP sync detail fallback + 사이드바 카드 UI

- sync: header에 routing 없으면 detail에서 자동 가져오기 (PC→POP 연동 수정)
- sync: header routing/qty/item_id 자동 보정 (detail → header 동기화)
- 사이드바: 체크리스트/자재투입 카드 형태 UI로 변경
This commit is contained in:
SeongHyun Kim
2026-04-09 18:09:30 +09:00
parent 327b4d01c2
commit cdea504d90
2 changed files with 53 additions and 17 deletions

View File

@@ -359,11 +359,21 @@ export const syncWorkInstructions = async (
});
// 미동기화 작업지시 조회: routing이 있지만 work_order_process가 없는 항목
// header에 routing 없으면 detail에서 가져옴 (PC가 detail에만 저장하는 경우 대응)
const unsyncedResult = await pool.query(
`SELECT wi.id, wi.work_instruction_no, wi.routing, wi.qty
`SELECT wi.id, wi.work_instruction_no,
COALESCE(wi.routing, wid.routing_version_id) AS routing,
COALESCE(NULLIF(wi.qty, ''), wid.qty) AS qty,
COALESCE(wi.item_id, (SELECT id FROM item_info WHERE item_number = wid.item_number AND company_code = $1 LIMIT 1)) AS item_id
FROM work_instruction wi
LEFT JOIN LATERAL (
SELECT routing_version_id, qty, item_number
FROM work_instruction_detail
WHERE work_instruction_no = wi.work_instruction_no AND company_code = $1
LIMIT 1
) wid ON true
WHERE wi.company_code = $1
AND wi.routing IS NOT NULL
AND COALESCE(wi.routing, wid.routing_version_id) IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM work_order_process wop
WHERE wop.wo_id = wi.id AND wop.company_code = $1
@@ -373,6 +383,20 @@ export const syncWorkInstructions = async (
const unsynced = unsyncedResult.rows;
// header에 routing/qty/item_id가 비어있으면 자동 보정 (detail → header 동기화)
for (const wi of unsynced) {
await pool.query(
`UPDATE work_instruction SET
routing = COALESCE(routing, $2),
qty = COALESCE(NULLIF(qty, ''), $3),
item_id = COALESCE(item_id, $4),
updated_date = NOW()
WHERE id = $1 AND company_code = $5
AND (routing IS NULL OR qty IS NULL OR qty = '' OR item_id IS NULL)`,
[wi.id, wi.routing, wi.qty, wi.item_id, companyCode],
);
}
if (unsynced.length === 0) {
return res.json({
success: true,