feat: Update equipment handling in process management
- Enhanced the `getProcessEquipments` function to support matching both legacy equipment codes and new IDs, improving data retrieval accuracy. - Updated the `availableEquipments` logic in the `ProcessMasterTab` component to handle both equipment codes and IDs, ensuring a seamless user experience when adding equipment. - Improved error handling for equipment selection, providing user feedback when a selected equipment cannot be found. - Refactored the display of equipment names to ensure accurate representation, even when equipment codes are not available.
This commit is contained in:
@@ -67,7 +67,7 @@ export async function getProductionReportData(req: any, res: Response): Promise<
|
||||
const dataQuery = `
|
||||
SELECT
|
||||
COALESCE(wi.start_date, wi.created_date::date::text) as date,
|
||||
COALESCE(wi.routing, '미지정') as process,
|
||||
COALESCE(NULLIF(rv.version_name, ''), '미지정') as process,
|
||||
COALESCE(ei.equipment_name, wi.equipment_id, '미지정') as equipment,
|
||||
COALESCE(ii.item_name, wi.item_id, '미지정') as item,
|
||||
COALESCE(wi.worker, '미지정') as worker,
|
||||
@@ -79,6 +79,8 @@ export async function getProductionReportData(req: any, res: Response): Promise<
|
||||
wi.status,
|
||||
wi.company_code
|
||||
FROM work_instruction wi
|
||||
LEFT JOIN item_routing_version rv
|
||||
ON wi.routing = rv.id AND wi.company_code = rv.company_code
|
||||
LEFT JOIN (
|
||||
SELECT wo_id, company_code,
|
||||
SUM(CAST(COALESCE(NULLIF(production_qty, ''), '0') AS numeric)) as production_qty,
|
||||
|
||||
@@ -154,10 +154,13 @@ export async function getProcessEquipments(req: AuthenticatedRequest, res: Respo
|
||||
const companyCode = req.user!.companyCode;
|
||||
const { processCode } = req.params;
|
||||
|
||||
// equipment_code 컬럼에 코드(legacy) 또는 id(신규)가 들어올 수 있어 두 경우 모두 매칭
|
||||
const result = await pool.query(
|
||||
`SELECT pe.*, em.equipment_name
|
||||
FROM process_equipment pe
|
||||
LEFT JOIN equipment_mng em ON pe.equipment_code = em.equipment_code AND pe.company_code = em.company_code
|
||||
LEFT JOIN equipment_mng em
|
||||
ON pe.company_code = em.company_code
|
||||
AND (pe.equipment_code = em.equipment_code OR pe.equipment_code = em.id)
|
||||
WHERE pe.process_code = $1 AND pe.company_code = $2
|
||||
ORDER BY pe.equipment_code`,
|
||||
[processCode, companyCode]
|
||||
|
||||
Reference in New Issue
Block a user