Linear Flow (C-PM-01, C-PM-02, C-PM-14) #224
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m11s

This commit is contained in:
harid 2026-06-18 15:48:52 +07:00
parent c26fb19c1c
commit 9dddaf40db

View file

@ -323,11 +323,13 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
// ─────────────────────────────────────────────────────────────
// Linear Flow
// ทดสอบเฉพาะ C-PM-01 รับ resultData จาก .NET แล้วเรียก OfficerProfileService ตรงๆ ไม่ผ่าน HTTP loopback
// ทดสอบคำสั่ง "C-PM-01", "C-PM-02", "C-PM-14"
// รับ resultData จาก .NET แล้วเรียก OfficerProfileService ตรงๆ ไม่ผ่าน HTTP loopback
// ─────────────────────────────────────────────────────────────
const isLinearFlow = command.commandType?.code === "C-PM-01";
const isLinearFlow = ["C-PM-01", "C-PM-02", "C-PM-14"].includes(command.commandType?.code);
if (isLinearFlow) {
console.log(`[AMQ] Linear Flow`);
let resultData: any[] = [];
for (const chunk of chunks) {
@ -337,13 +339,14 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
{ refIds: chunk },
false,
);
// CallAPI.PostData คืน response.data.result (ตาม call-api.ts)
if (res?.result && Array.isArray(res.result)) {
resultData.push(...res.result);
// response (resultData) จาก .NET
if (Array.isArray(res)) {
console.log(`[AMQ] Push result data`);
resultData.push(...res);
}
}
console.log(`[AMQ] Received ${resultData.length} profiles from .NET (C-PM-01)`);
console.log(`[AMQ] Received ${resultData.length} profiles from .NET (${command.commandType?.code})`);
// เรียก OfficerProfileService
if (resultData.length > 0) {
@ -361,7 +364,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
console.log(`[AMQ] Processed ${resultData.length} profiles via OfficerProfileService`);
}
} else {
// Flow เดิม
console.log(`[AMQ] Circular Flow`);
for (const chunk of chunks) {
await new CallAPI().PostData(
{ headers: { authorization: token } },