feat: Implement smart factory log management features

- Added new API endpoints for retrieving company-specific user lists and sending immediate logs for selected users.
- Enhanced the smartFactoryLogController with functions to handle user retrieval and immediate log sending, improving operational efficiency.
- Updated adminRoutes to include routes for the new functionalities, ensuring proper access control for super admins.
- Refactored the sendSmartFactoryLog function to improve logging and error handling, providing better insights into the log transmission process.

These changes aim to enhance the smart factory log management capabilities, facilitating better user interaction and operational tracking.
This commit is contained in:
kjs
2026-04-07 16:45:52 +09:00
parent 3be2b57c04
commit 1b7842c305
51 changed files with 30816 additions and 8949 deletions

View File

@@ -74,17 +74,19 @@ export async function sendSmartFactoryLog(params: {
dataUsgqty: "",
};
const encodedLogData = encodeURIComponent(JSON.stringify(logData));
const logDataJson = JSON.stringify(logData);
const response = await axios.get(SMART_FACTORY_LOG_URL, {
params: { logData: encodedLogData },
params: { logData: logDataJson },
timeout: 5000,
});
logger.info("스마트공장 로그 전송 완료", {
userId: params.userId,
status: response.status,
});
const responseBody = typeof response.data === "string" ? response.data : JSON.stringify(response.data);
logger.info(`스마트공장 로그 전송 완료: userId=${params.userId}, status=${response.status}, body=${responseBody}`);
// 응답 body에 에러가 있을 수 있음 (HTTP 200이지만 실제 실패)
const isRealSuccess = !responseBody.includes("FAIL") && !responseBody.includes("error") && !responseBody.includes("ERR");
await saveLog({
companyCode: params.companyCode || "",
@@ -92,9 +94,9 @@ export async function sendSmartFactoryLog(params: {
userName: params.userName,
useType,
connectIp: params.remoteAddr,
sendStatus: "SUCCESS",
sendStatus: isRealSuccess ? "SUCCESS" : "FAIL",
responseStatus: response.status,
errorMessage: null,
errorMessage: isRealSuccess ? null : responseBody,
logDt: logTimeToUse,
});
} catch (error) {