From cb37ca5077368d6651f04f105077667ff3fa95ae Mon Sep 17 00:00:00 2001 From: r0n1n7an Date: Mon, 5 May 2025 14:42:27 +0800 Subject: [PATCH] Show client IP and Server address in issue report and offline report --- ews/ews.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/ews/ews.go b/ews/ews.go index ca2dfb5..f83ce70 100644 --- a/ews/ews.go +++ b/ews/ews.go @@ -38,6 +38,8 @@ type ReportInfo struct { MfgMO string Line string Location string + IPAddr string + Relay string Item string Status string Message string @@ -694,7 +696,7 @@ func (e *EWS) GetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri } if loc == "" { - loc = `Unknown` + loc = `N/A` } else { loc = fmt.Sprintf(`%s`, loc) } @@ -764,9 +766,8 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr ri := new(ReportInfo) defect := "" rows, err := dbo.Query(fmt.Sprintf( - `SELECT usn,partno,sku,mo,line,location,item,status,message,first_ack,last_ack,last_change,diffmins - FROM %s - ORDER BY diffmins ASC;`, cfg.MySQL.IssuesView)) + `SELECT usn,partno,sku,mo,line,location,ipaddr,relay,item,status,message,first_ack,last_ack,last_change,diffmins + FROM %s;`, cfg.MySQL.IssuesView)) if err != nil { logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error()) rst["RESULT"] = "NG" @@ -784,11 +785,11 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr &ri.MfgMO, &ri.Line, &ri.Location, + &ri.IPAddr, + &ri.Relay, &ri.Item, &ri.Status, &ri.Message, - &ri.FirstAck, - &ri.LastAck, &ri.LastChg, &ri.DiffMins, ) @@ -796,13 +797,13 @@ func (e *EWS) GetIssueReport(cfg cnf.Cfg, logger *log.Logger, host string, addr break } temp := fmt.Sprintf(`%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s`, - num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.Item, ri.Status, ri.Message, ri.FirstAck, ri.LastAck, ri.LastChg, ri.DiffMins, "\r\n") + num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.IPAddr, ri.Relay, ri.Item, ri.Status, ri.Message, ri.LastChg, ri.DiffMins, "\r\n") defect = defect + temp num += 1 } rst["RESULT"] = "OK" - rst["ErrMsg"] = e.TemplateDefectInfo(defect) + rst["ErrMsg"] = e.TemplateReportInfo(defect) return rst } @@ -835,9 +836,8 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add ri := new(ReportInfo) offline := "" rows, err := dbo.Query(fmt.Sprintf( - `SELECT usn,partno,sku,mo,line,location,item,status,message,first_ack,last_ack,last_change,diffmins - FROM %s - ORDER BY diffmins DESC;`, cfg.MySQL.OfflineView)) + `SELECT usn,partno,sku,mo,line,location,ipaddr,relay,item,status,message,last_change,diffmins + FROM %s;`, cfg.MySQL.OfflineView)) if err != nil { logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error()) rst["RESULT"] = "NG" @@ -855,11 +855,11 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add &ri.MfgMO, &ri.Line, &ri.Location, + &ri.IPAddr, + &ri.Relay, &ri.Item, &ri.Status, &ri.Message, - &ri.FirstAck, - &ri.LastAck, &ri.LastChg, &ri.DiffMins, ) @@ -867,13 +867,13 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add break } temp := fmt.Sprintf(`%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s`, - num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.Item, ri.Status, ri.Message, ri.FirstAck, ri.LastAck, ri.LastChg, ri.DiffMins, "\r\n") + num, ri.USN, ri.PartNO, ri.MfgSKU, ri.MfgMO, ri.Line, ri.Location, ri.IPAddr, ri.Relay, ri.Item, ri.Status, ri.Message, ri.LastChg, ri.DiffMins, "\r\n") offline = offline + temp num += 1 } rst["RESULT"] = "OK" - rst["ErrMsg"] = e.TemplateDefectInfo(offline) + rst["ErrMsg"] = e.TemplateReportInfo(offline) return rst } @@ -972,7 +972,7 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string { MAC IP Address Server - Test Item + Item Status Message Last Change @@ -985,7 +985,7 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string { return resp } -func (e *EWS) TemplateDefectInfo(src string) string { +func (e *EWS) TemplateReportInfo(src string) string { now := time.Now().Format("2006-01-02 15:04:05") if src == "" { src = fmt.Sprintf(`[%s] NO Records !
`, now) @@ -1035,13 +1035,13 @@ func (e *EWS) TemplateDefectInfo(src string) string { MO Line Location + IP Address + Server Item Status Message - First Ack - Last Ack Last Change - Differ Time (Min) + Differ Mins %s