fix: Improve numbering rule handling and item routing functionality
- Added temporary debug response in `numberingRuleController` for better troubleshooting. - Refactored SQL queries in `NumberingRuleService` to enhance parameter handling and improve clarity. - Updated `ItemInfoPage` to correctly handle manual input values for user-generated codes. - Implemented sorting logic in `ItemRoutingTab` to prioritize default routing versions and added functionality to set a version as default. These changes aim to enhance the reliability and user experience in managing numbering rules and item routing processes.
This commit is contained in:
@@ -323,6 +323,9 @@ router.post(
|
||||
formData,
|
||||
manualInputValue
|
||||
);
|
||||
// TODO: 디버그용 임시 응답 (나중에 제거)
|
||||
const { getPool } = require("../database/db");
|
||||
const dbPool = getPool();
|
||||
return res.json({ success: true, data: { generatedCode: previewCode } });
|
||||
} catch (error: any) {
|
||||
logger.error("코드 미리보기 실패", { error: error.message });
|
||||
|
||||
@@ -305,26 +305,26 @@ class NumberingRuleService {
|
||||
if (hasCompanyCode && companyCode !== "*") {
|
||||
sql = `
|
||||
SELECT MAX(
|
||||
CAST(SUBSTRING("${columnName}" FROM $1 FOR $2) AS INTEGER)
|
||||
CAST(SUBSTRING("${columnName}" FROM ${seqStart} FOR ${seqLength}) AS INTEGER)
|
||||
) as max_seq
|
||||
FROM "${tableName}"
|
||||
WHERE "${columnName}" LIKE $3
|
||||
AND company_code = $4
|
||||
AND LENGTH("${columnName}") = $5
|
||||
AND SUBSTRING("${columnName}" FROM $1 FOR $2) ~ '^[0-9]+$'
|
||||
WHERE "${columnName}" LIKE $1
|
||||
AND company_code = $2
|
||||
AND LENGTH("${columnName}") = $3
|
||||
AND SUBSTRING("${columnName}" FROM ${seqStart} FOR ${seqLength}) ~ '^[0-9]+$'
|
||||
`;
|
||||
params = [seqStart, seqLength, likePattern, companyCode, prefixLen + seqLength + codeSuffix.length];
|
||||
params = [likePattern, companyCode, prefixLen + seqLength + codeSuffix.length];
|
||||
} else {
|
||||
sql = `
|
||||
SELECT MAX(
|
||||
CAST(SUBSTRING("${columnName}" FROM $1 FOR $2) AS INTEGER)
|
||||
CAST(SUBSTRING("${columnName}" FROM ${seqStart} FOR ${seqLength}) AS INTEGER)
|
||||
) as max_seq
|
||||
FROM "${tableName}"
|
||||
WHERE "${columnName}" LIKE $3
|
||||
AND LENGTH("${columnName}") = $4
|
||||
AND SUBSTRING("${columnName}" FROM $1 FOR $2) ~ '^[0-9]+$'
|
||||
WHERE "${columnName}" LIKE $1
|
||||
AND LENGTH("${columnName}") = $2
|
||||
AND SUBSTRING("${columnName}" FROM ${seqStart} FOR ${seqLength}) ~ '^[0-9]+$'
|
||||
`;
|
||||
params = [seqStart, seqLength, likePattern, prefixLen + seqLength + codeSuffix.length];
|
||||
params = [likePattern, prefixLen + seqLength + codeSuffix.length];
|
||||
}
|
||||
|
||||
const result = await client.query(sql, params);
|
||||
@@ -1436,6 +1436,7 @@ class NumberingRuleService {
|
||||
psInfo.prefix, psInfo.suffix, psInfo.seqLength, companyCode
|
||||
);
|
||||
|
||||
|
||||
if (maxFromTable > baseSeq) {
|
||||
logger.info("미리보기: 테이블 내 최대값이 카운터보다 높음", {
|
||||
ruleId, companyCode, currentSeq, maxFromTable,
|
||||
|
||||
Reference in New Issue
Block a user