diff --git a/BACKEND/app/controllers/auth_controller.ts b/BACKEND/app/controllers/auth_controller.ts index 22cabea..0281d54 100644 --- a/BACKEND/app/controllers/auth_controller.ts +++ b/BACKEND/app/controllers/auth_controller.ts @@ -32,7 +32,7 @@ export default class AuthController { const user = await User.query().where('user_name', userName).first() if (!user) { - const remoteUrl = process.env.ERP_URL || 'https://stage.nswteam.net' + const remoteUrl = process.env.ERP_URL_AUTH || 'https://stage.nswteam.net' const remoteResp = await axios.post(remoteUrl + '/api/login', { userEmail: userName, password: password, diff --git a/BACKEND/app/services/line_connection.ts b/BACKEND/app/services/line_connection.ts index cd240b5..1ff02a9 100644 --- a/BACKEND/app/services/line_connection.ts +++ b/BACKEND/app/services/line_connection.ts @@ -924,7 +924,7 @@ export default class LineConnection { }, ], } - const remoteUrl = process.env.ERP_URL || 'https://stage.nswteam.net' + const remoteUrl = process.env.ERP_URL_AUTH || 'https://stage.nswteam.net' const remoteResp = await axios.post( remoteUrl + '/api/transferPostData', { @@ -937,7 +937,6 @@ export default class LineConnection { }, } ) - console.log('AI detect log response:', remoteResp.data) return remoteResp.data?.Status === 'OK' ? remoteResp.data?.data : '' } catch (error: any) { console.log('[ERROR] Detect log from AI', error) @@ -1059,7 +1058,7 @@ export default class LineConnection { await sendMessageToMail( `[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Raw log issue ${result?.errors?.some((e) => e.category === 'SPECIAL_KEYWORD') ? '+ Special keywords' : ''}`, tableHTML + - `${` + `${`

Logs:

@@ -1100,9 +1099,9 @@ export default class LineConnection { ${r.rule} ${r.message} ${escapeHtml(r.log.trim()) - .split('*') - .filter((el) => el) - .join('
*')} + .split('*') + .filter((el) => el) + .join('
*')} ` ) @@ -1479,7 +1478,7 @@ Ports Missing/Down: ${missing.length}\n\n` await sendMessageToMail( `[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Load IOS Report`, body + - `${` + `${`

Logs:

@@ -1517,7 +1516,7 @@ Ports Missing/Down: ${missing.length}\n\n` await sendMessageToMail( `[ATC] - [${this.config.stationName} - Line: ${this.config.lineNumber}] - Load License Report`, body + - `${` + `${`

Logs:

@@ -1767,7 +1766,7 @@ Ports Missing/Down: ${missing.length}\n\n` }, ], } - const remoteUrl = process.env.ERP_URL || 'https://stage.nswteam.net' + const remoteUrl = process.env.ERP_URL_AUTH || 'https://stage.nswteam.net' const remoteResp = await axios.post( remoteUrl + '/api/transferPostData', { @@ -1806,15 +1805,15 @@ Ports Missing/Down: ${missing.length}\n\n`
${escapeHtml(output) - .replace('show ver', '') - .replace('sh ver', '') - .replace('show version', '') - .replace('sh version', '') - .replace(mem, `${mem}`) - .replace( - flash, - `${flash}` - )}
+ .replace('show ver', '') + .replace('sh ver', '') + .replace('show version', '') + .replace('sh version', '') + .replace(mem, `${mem}`) + .replace( + flash, + `${flash}` + )}
` await sendMessageToMail(subject, body) } @@ -1891,37 +1890,34 @@ Ports Missing/Down: ${missing.length}\n\n` IOS: ${dataShowVersion?.SOFTWARE_IMAGE ?? ''} ${dataShowVersion?.VERSION ?? ''}
MEM: ${dataShowVersion?.MEMORY ? convertFromKilobytesString(dataShowVersion?.MEMORY) : ''}
FLASH: ${dataShowVersion?.USB_FLASH ? convertFromKilobytesString(dataShowVersion?.USB_FLASH) : ''}
- Licenses: ${ - dataShowLic - ? dataShowLic - ?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent')) - ?.map((v) => v.FEATURE) - ?.join(', ') - : '' - }
+ Licenses: ${dataShowLic + ? dataShowLic + ?.filter((el) => el.LICENSE_TYPE?.toLowerCase()?.includes('permanent')) + ?.map((v) => v.FEATURE) + ?.join(', ') + : '' + }
Detect from AI: ${issue?.length ? `
- ` + issue.join(`
`) : 'No issues detected.'}

Total Ports: ${portPhysical?.length}
Ports Tested (Link UP): ${tested.length} (${testedPoE?.length} PoE, ${testedSFP?.length} SFP)
Ports Missing/Down: ${missing.length}
- ${ - missingPoE?.length - ? ` + ${missingPoE?.length + ? `
Ports Missing PoE
────────────────────────────────
${missingPoE.map((p) => physicalTest.normalizePortName(p.name)).join('
')}
` - : '' - } - ${ - missingSFP?.length - ? ` + : '' + } + ${missingSFP?.length + ? `
Ports Missing SFP
────────────────────────────────
${missingSFP.map((p) => physicalTest.normalizePortName(p.name)).join('
')}
` - : '' - } + : '' + } ${reasonSkipPhysical} @@ -2059,25 +2055,27 @@ Ports Missing/Down: ${missing.length}\n\n` // AI issue rows (one per real AI issue, fall back to file's hardcoded row when none) const aiIssueRowsHtml = issues.length > 0 - ? issues + ? issues.length > 1 + ? issues .slice(0, 1) .map( (issue) => `
★ AI${escapeHtml(issue)}
` ) .join('') + : `
★ AI${escapeHtml(issues[0].split('\n')[0] || '')}
` : `` // License boxes (real licenses if available, else file's hardcoded boxes) const licenseBoxesHtml = dataShowLic && dataShowLic.length > 0 ? dataShowLic - .filter((l) => l.LICENSE_TYPE && l.FEATURE) - .map( - (l: any) => - `
${escapeHtml(String(l.FEATURE || ''))}
${escapeHtml(String(l.LICENSE_TYPE || ''))}${l.STATUS ? ' · ' + escapeHtml(String(l.STATUS)) : ''}
` - ) - .join('') + .filter((l) => l.LICENSE_TYPE && l.FEATURE) + .map( + (l: any) => + `
${escapeHtml(String(l.FEATURE || ''))}
${escapeHtml(String(l.LICENSE_TYPE || ''))}${l.STATUS ? ' · ' + escapeHtml(String(l.STATUS)) : ''}
` + ) + .join('') : `` // Port stat values (real numbers if any port data, else file's defaults) @@ -2152,7 +2150,7 @@ Ports Missing/Down: ${missing.length}\n\n` const image = imageList[idx] const label = imageLabels[idx] return image && image.url - ? imageCellHtml(process.env.ERP_URL + image.url, label) + ? imageCellHtml(process.env.ERP_URL_AUTH + image.url, label) : photoCellHtml(label) } const photoGridRowsHtml = ` @@ -2460,14 +2458,13 @@ Ports Missing/Down: ${missing.length}\n\n`
Hardware Inventory
- ${ - this.config?.inventory?.listInventory - ?.map( - (item: any) => ` + ${this.config?.inventory?.listInventory + ?.map( + (item: any) => ` ` - ) - .join('') || '' - } + ) + .join('') || '' + }
${item.pid}${item.sn}
@@ -2483,7 +2480,6 @@ Ports Missing/Down: ${missing.length}\n\n`
${missingSFP.length > 0 || missingPoE.length > 0 ? 'WARN' : 'PASS'}
PoE+ Test
-
${totalPoE + totalSFP === 0 ? 100 : Math.round(((totalPoE + totalSFP - (missingPoE.length + missingSFP.length)) / (totalPoE + totalSFP)) * 100)}%
Throughput
${missingDetailsHtml} diff --git a/BACKEND/app/ultils/helper.ts b/BACKEND/app/ultils/helper.ts index 460b0b1..6298985 100644 --- a/BACKEND/app/ultils/helper.ts +++ b/BACKEND/app/ultils/helper.ts @@ -681,13 +681,29 @@ export async function updateNoteToERP(sn: string, note: string) { const header = { Authorization: 'Bearer ' + process.env.ERP_TOKEN, } + // const responseDataSN = await axios.post( + // 'https://stage.nswteam.net/api/transferGetData', + // { + // urlAPI: '/api/stock-model-serial/get-list-for-test-log', + // filter: { + // where: { + // _q: 'FOC1425Z3RN', + // }, + // orgId: ['5fadc798f070e4b64b53ac9c', '5fadc7b0f070e4b64b53ac9d'], + // }, + // }, + // { + // headers: header, + // } + // ) + const responseDataSN = await axios.get( remoteUrl + '/api/stock-model-serial/get-list-for-test-log', { params: { filter: { where: { - _q: 'FOC1425Z3RN', + _q: sn, }, }, orgId: ['5fadc798f070e4b64b53ac9c', '5fadc7b0f070e4b64b53ac9d'], @@ -716,13 +732,9 @@ export async function updateNoteToERP(sn: string, note: string) { testNotes: note + (dataSN?.testNotes || ''), } // console.log(payload) - await axios.post( - remoteUrl + '/api/stock-model-serial/data-save-for-test-log', - payload, - { - headers: header, - } - ) + await axios.post(remoteUrl + '/api/stock-model-serial/data-save-for-test-log', payload, { + headers: header, + }) } catch (error) { console.log('updateNoteToERP', error) } @@ -1441,6 +1453,21 @@ export async function getIncomingInfoBySN(sn: string) { const header = { Authorization: 'Bearer ' + process.env.ERP_TOKEN, } + // const responseDataSN = await axios.post( + // 'https://stage.nswteam.net/api/transferGetData', + // { + // urlAPI: '/api/package-po/get-incoming-by-sn', + // filter: { + // where: { + // serialNumber: sn, + // }, + // }, + // }, + // { + // headers: header, + // } + // ) + const responseDataSN = await axios.get( remoteUrl + '/api/package-po/get-incoming-by-sn', {