Linear Flow (ทดสอบเฉพาะคำสั่ง C-PM-01) #224
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
This commit is contained in:
parent
9f7803cc74
commit
c26fb19c1c
3 changed files with 1368 additions and 953 deletions
1310
src/services/OfficerProfileService.ts
Normal file
1310
src/services/OfficerProfileService.ts
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -29,6 +29,7 @@ import { sendWebSocket } from "./webSocket";
|
|||
import { PayloadSendNoti } from "../interfaces/utils";
|
||||
import { PermissionProfile } from "../entities/PermissionProfile";
|
||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||
import { OfficerProfileService } from "./OfficerProfileService";
|
||||
|
||||
const redis = require("redis");
|
||||
const REDIS_HOST = process.env.REDIS_HOST;
|
||||
|
|
@ -320,13 +321,55 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
20,
|
||||
);
|
||||
|
||||
for (const chunk of chunks) {
|
||||
await new CallAPI().PostData(
|
||||
{ headers: { authorization: token } },
|
||||
path + "/excecute",
|
||||
{ refIds: chunk },
|
||||
false,
|
||||
);
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Linear Flow
|
||||
// ทดสอบเฉพาะ C-PM-01 รับ resultData จาก .NET แล้วเรียก OfficerProfileService ตรงๆ ไม่ผ่าน HTTP loopback
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
const isLinearFlow = command.commandType?.code === "C-PM-01";
|
||||
|
||||
if (isLinearFlow) {
|
||||
let resultData: any[] = [];
|
||||
|
||||
for (const chunk of chunks) {
|
||||
const res = await new CallAPI().PostData(
|
||||
{ headers: { authorization: token } },
|
||||
path + "/excecute",
|
||||
{ refIds: chunk },
|
||||
false,
|
||||
);
|
||||
// CallAPI.PostData คืน response.data.result (ตาม call-api.ts)
|
||||
if (res?.result && Array.isArray(res.result)) {
|
||||
resultData.push(...res.result);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`[AMQ] Received ${resultData.length} profiles from .NET (C-PM-01)`);
|
||||
|
||||
// เรียก OfficerProfileService
|
||||
if (resultData.length > 0) {
|
||||
// สร้าง pseudo-req สำหรับ setLogDataDiff/save({data: req})
|
||||
const pseudoReq = {
|
||||
headers: { authorization: token },
|
||||
user,
|
||||
};
|
||||
const ctx = {
|
||||
user: { sub: user?.sub ?? "system", name: user?.name ?? "System" },
|
||||
req: pseudoReq,
|
||||
};
|
||||
|
||||
await new OfficerProfileService().executeCreateOfficerProfile(resultData, ctx);
|
||||
console.log(`[AMQ] Processed ${resultData.length} profiles via OfficerProfileService`);
|
||||
}
|
||||
} else {
|
||||
// Flow เดิม
|
||||
for (const chunk of chunks) {
|
||||
await new CallAPI().PostData(
|
||||
{ headers: { authorization: token } },
|
||||
path + "/excecute",
|
||||
{ refIds: chunk },
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Object.assign(command, { status, lastUpdateUserId, lastUpdateFullName, lastUpdatedAt });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue