엑셀업로드 제어로직 개선
This commit is contained in:
@@ -4446,6 +4446,8 @@ export class NodeFlowExecutionService {
|
||||
|
||||
/**
|
||||
* 산술 연산 계산
|
||||
* 다중 연산 지원: (leftOperand operator rightOperand) 이후 additionalOperations 순차 적용
|
||||
* 예: (width * height) / 1000000 * qty
|
||||
*/
|
||||
private static evaluateArithmetic(
|
||||
arithmetic: any,
|
||||
@@ -4472,27 +4474,67 @@ export class NodeFlowExecutionService {
|
||||
const leftNum = Number(left) || 0;
|
||||
const rightNum = Number(right) || 0;
|
||||
|
||||
switch (arithmetic.operator) {
|
||||
// 기본 연산 수행
|
||||
let result = this.applyOperator(leftNum, arithmetic.operator, rightNum);
|
||||
|
||||
if (result === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 추가 연산 처리 (다중 연산 지원)
|
||||
if (arithmetic.additionalOperations && Array.isArray(arithmetic.additionalOperations)) {
|
||||
for (const addOp of arithmetic.additionalOperations) {
|
||||
const operandValue = this.getOperandValue(
|
||||
addOp.operand,
|
||||
sourceRow,
|
||||
targetRow,
|
||||
resultValues
|
||||
);
|
||||
const operandNum = Number(operandValue) || 0;
|
||||
|
||||
result = this.applyOperator(result, addOp.operator, operandNum);
|
||||
|
||||
if (result === null) {
|
||||
logger.warn(`⚠️ 추가 연산 실패: ${addOp.operator}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.info(` 추가 연산: ${addOp.operator} ${operandNum} = ${result}`);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 단일 연산자 적용
|
||||
*/
|
||||
private static applyOperator(
|
||||
left: number,
|
||||
operator: string,
|
||||
right: number
|
||||
): number | null {
|
||||
switch (operator) {
|
||||
case "+":
|
||||
return leftNum + rightNum;
|
||||
return left + right;
|
||||
case "-":
|
||||
return leftNum - rightNum;
|
||||
return left - right;
|
||||
case "*":
|
||||
return leftNum * rightNum;
|
||||
return left * right;
|
||||
case "/":
|
||||
if (rightNum === 0) {
|
||||
if (right === 0) {
|
||||
logger.warn(`⚠️ 0으로 나누기 시도`);
|
||||
return null;
|
||||
}
|
||||
return leftNum / rightNum;
|
||||
return left / right;
|
||||
case "%":
|
||||
if (rightNum === 0) {
|
||||
if (right === 0) {
|
||||
logger.warn(`⚠️ 0으로 나머지 연산 시도`);
|
||||
return null;
|
||||
}
|
||||
return leftNum % rightNum;
|
||||
return left % right;
|
||||
default:
|
||||
throw new Error(`지원하지 않는 연산자: ${arithmetic.operator}`);
|
||||
throw new Error(`지원하지 않는 연산자: ${operator}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user