refactor: Update work instruction queries to use work_instruction_id for consistency

- Changed references from work_instruction_no to work_instruction_id in the popProductionController and workInstructionController for improved consistency and clarity.
- Updated SQL queries to ensure proper data handling and integrity by aligning with the new identifier.
- These changes aim to streamline the data retrieval process and enhance overall code maintainability across multiple company implementations.
This commit is contained in:
kjs
2026-04-14 12:09:06 +09:00
parent 0622a5c1b6
commit b0cc0fce9f
2 changed files with 11 additions and 14 deletions

View File

@@ -393,8 +393,7 @@ export const syncWorkInstructions = async (
-- detail에 routing이 있는 경우 (다중 품목 지원)
EXISTS (
SELECT 1 FROM work_instruction_detail wid
WHERE wid.work_instruction_no = wi.work_instruction_no
AND wid.company_code = $1
WHERE wid.work_instruction_id = wi.id
AND wid.routing_version_id IS NOT NULL
AND CAST(COALESCE(NULLIF(wid.qty, ''), '0') AS numeric) > 0
AND NOT EXISTS (
@@ -433,11 +432,11 @@ export const syncWorkInstructions = async (
const detailResult = await pool.query(
`SELECT wid.item_number, wid.routing_version_id, wid.qty
FROM work_instruction_detail wid
WHERE wid.work_instruction_no = $1 AND wid.company_code = $2
WHERE wid.work_instruction_id = $1
AND wid.routing_version_id IS NOT NULL
AND CAST(COALESCE(NULLIF(wid.qty, ''), '0') AS numeric) > 0
ORDER BY wid.created_date ASC`,
[wi.work_instruction_no, companyCode],
[wi.id],
);
const detailRows = detailResult.rows;
@@ -448,9 +447,9 @@ export const syncWorkInstructions = async (
const firstDetail = await pool.query(
`SELECT routing_version_id, qty, item_number
FROM work_instruction_detail
WHERE work_instruction_no = $1 AND company_code = $2
WHERE work_instruction_id = $1
LIMIT 1`,
[wi.work_instruction_no, companyCode],
[wi.id],
);
const wid = firstDetail.rows[0];
if (wid) {