diff --git a/APIServer.exe b/APIServer.exe index 23aacbe..3c26f22 100644 Binary files a/APIServer.exe and b/APIServer.exe differ diff --git a/ews/ews.go b/ews/ews.go index 7298786..3cd7690 100644 --- a/ews/ews.go +++ b/ews/ews.go @@ -53,8 +53,27 @@ func (e *EWS) RecordIssue(cfg cnf.Cfg, logger *log.Logger, host string, addr str firstAck = time.Now().Format("2006-01-02 15:04:05") } + line := "" + col := 0 + row := 0 + num := 0 + locTime := "" + loc := dbo.QueryRow(fmt.Sprintf(`SELECT line,col,row,num,DATE_FORMAT(update_time,'%%Y-%%m-%%d %%H:%%i:%%s') FROM locinfo WHERE mac='%s';`, params["MAC"])) + err := loc.Scan(&line, &col, &row, &num, &locTime) + if locTime == "" { + locTime = "0000-00-00 00:00:00" + } + if err != nil { + logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error()) + rst["RESULT"] = "NG" + rst["ErrMsg"] = err.Error() + return rst + } + stmt, err := dbo.Prepare( - fmt.Sprintf("INSERT INTO %s (usn,mac,ipaddr,relay,partno,mo,sku,line,stage,item,status,message,first_ack,last_change) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);", + fmt.Sprintf(`INSERT INTO %s + (usn,mac,ipaddr,relay,partno,mo,sku,line,stage,item,status,message,first_ack,last_change,locline,loccol,locrow,locnum,loctime) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);`, cfg.MySQL.IssuesTable), ) if err != nil { @@ -80,6 +99,11 @@ func (e *EWS) RecordIssue(cfg cnf.Cfg, logger *log.Logger, host string, addr str params["MESSAGE"], firstAck, time.Now().Format("2006-01-02 15:04:05"), + line, + col, + row, + num, + locTime, ) if err != nil { logger.Printf("[ERR] %s; %s; %#v; %s\r\n", addr, uri, params, err.Error()) @@ -124,6 +148,9 @@ func (e *EWS) SetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri return rst } + // fmt.Sprintf(`SELECT t1.usn,t1.mac,t1.ipaddr,t1.relay,t1.item,t1.status,t1.message,t1.partno,t1.mo,t1.sku,t1.line,t1.stage,t1.first_ack,t1.last_ack,t1.last_change,t2.model + // FROM uutinfo t1 LEFT JOIN modelfamily t2 ON t1.partno=t2.modelfamily + // WHERE t1.usn='%s';`, params["USN"])) rec := dbo.QueryRow( fmt.Sprintf(`SELECT usn,mac,ipaddr,relay,item,status,message,partno,mo,sku,line,stage,first_ack,last_ack,last_change FROM uutinfo @@ -447,6 +474,7 @@ func (e *EWS) GetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri } ul := new(UutInfo) + //model := "" partNO := "" mfgMO := "" mfgSKU := ""