Filter POP defect-types to 공정검사 master only
- Drop item_inspection_info branch in getDefectTypes
- Always source from defect_standard_mng with inspection_type containing 공정검사 (CAT_MMEBA4LJ_UFJ9)
- Fix is_active filter to category code CAT_DA_01 ('사용') — old 'Y' literal returned zero rows
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1186,9 +1186,13 @@ export const controlGroupTimer = async (
|
||||
|
||||
/**
|
||||
* 불량 유형 목록 조회
|
||||
* - item_code 쿼리 파라미터가 있으면: item_inspection_info 의 공정검사 항목을 반환 (품목별 검사항목)
|
||||
* - 없으면: defect_standard_mng 마스터 반환 (기존 호환)
|
||||
* - defect_standard_mng 중 inspection_type 에 공정검사(CAT_MMEBA4LJ_UFJ9) 가 포함된 활성 행 반환
|
||||
* - inspection_type 은 콤마 구분 다중값으로 저장됨
|
||||
* - is_active 는 카테고리 코드(CAT_DA_01='사용')로 저장됨
|
||||
*/
|
||||
const PROCESS_INSPECTION_CODE = "CAT_MMEBA4LJ_UFJ9";
|
||||
const ACTIVE_CODE = "CAT_DA_01";
|
||||
|
||||
export const getDefectTypes = async (
|
||||
req: AuthenticatedRequest,
|
||||
res: Response,
|
||||
@@ -1197,68 +1201,27 @@ export const getDefectTypes = async (
|
||||
|
||||
try {
|
||||
const companyCode = req.user!.companyCode;
|
||||
const itemCode =
|
||||
typeof req.query.item_code === "string" && req.query.item_code.trim()
|
||||
? req.query.item_code.trim()
|
||||
: null;
|
||||
const applyProcess =
|
||||
typeof req.query.apply_process === "string" &&
|
||||
req.query.apply_process.trim()
|
||||
? req.query.apply_process.trim()
|
||||
: null;
|
||||
|
||||
let query: string;
|
||||
let params: unknown[];
|
||||
|
||||
if (itemCode) {
|
||||
if (companyCode === "*") {
|
||||
const processFilter = applyProcess ? ` AND apply_process = $2` : "";
|
||||
query = `
|
||||
SELECT id,
|
||||
inspection_standard_id AS defect_code,
|
||||
inspection_item_name AS defect_name,
|
||||
inspection_type AS defect_type,
|
||||
'' AS severity,
|
||||
company_code
|
||||
FROM item_inspection_info
|
||||
WHERE item_code = $1
|
||||
AND inspection_type = '공정검사'
|
||||
AND is_active IN ('사용', 'Y')${processFilter}
|
||||
ORDER BY sort_order, inspection_item_name`;
|
||||
params = applyProcess ? [itemCode, applyProcess] : [itemCode];
|
||||
} else {
|
||||
const processFilter = applyProcess ? ` AND apply_process = $3` : "";
|
||||
query = `
|
||||
SELECT id,
|
||||
inspection_standard_id AS defect_code,
|
||||
inspection_item_name AS defect_name,
|
||||
inspection_type AS defect_type,
|
||||
'' AS severity,
|
||||
company_code
|
||||
FROM item_inspection_info
|
||||
WHERE company_code = $1
|
||||
AND item_code = $2
|
||||
AND inspection_type = '공정검사'
|
||||
AND is_active IN ('사용', 'Y')${processFilter}
|
||||
ORDER BY sort_order, inspection_item_name`;
|
||||
params = applyProcess
|
||||
? [companyCode, itemCode, applyProcess]
|
||||
: [companyCode, itemCode];
|
||||
}
|
||||
} else if (companyCode === "*") {
|
||||
if (companyCode === "*") {
|
||||
query = `
|
||||
SELECT id, defect_code, defect_name, defect_type, severity, company_code
|
||||
FROM defect_standard_mng
|
||||
WHERE is_active = 'Y'
|
||||
WHERE is_active = $1
|
||||
AND (',' || COALESCE(inspection_type, '') || ',') LIKE '%,' || $2 || ',%'
|
||||
ORDER BY defect_code`;
|
||||
params = [];
|
||||
params = [ACTIVE_CODE, PROCESS_INSPECTION_CODE];
|
||||
} else {
|
||||
query = `
|
||||
SELECT id, defect_code, defect_name, defect_type, severity, company_code
|
||||
FROM defect_standard_mng
|
||||
WHERE is_active = 'Y' AND company_code = $1
|
||||
WHERE is_active = $1
|
||||
AND company_code = $2
|
||||
AND (',' || COALESCE(inspection_type, '') || ',') LIKE '%,' || $3 || ',%'
|
||||
ORDER BY defect_code`;
|
||||
params = [companyCode];
|
||||
params = [ACTIVE_CODE, companyCode, PROCESS_INSPECTION_CODE];
|
||||
}
|
||||
|
||||
const result = await pool.query(query, params);
|
||||
|
||||
Reference in New Issue
Block a user