diff --git a/APIServer.exe b/APIServer.exe
index b6deb7e..e8548bc 100644
Binary files a/APIServer.exe and b/APIServer.exe differ
diff --git a/ews/ews.go b/ews/ews.go
index 1982eb4..2880202 100644
--- a/ews/ews.go
+++ b/ews/ews.go
@@ -414,13 +414,6 @@ func (e *EWS) GetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri
}
}
- //Get Location Information
- loc, locTime := "", ""
- if last != "" {
- qry := dbo.QueryRow(fmt.Sprintf(`SELECT CONCAT_WS(' ', line, CONCAT_WS('-',col,row,num)) AS loc, update_time FROM locinfo WHERE mac='%s'`, ul.MAC))
- qry.Scan(&loc, &locTime)
- }
-
//Get History Records
uh := new(UutInfo)
bkup := ""
@@ -463,6 +456,29 @@ func (e *EWS) GetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri
uh.USN, uh.MAC, uh.IPAddr, uh.Relay, uh.Item, uh.Status, uh.Message, uh.LastChg, "\r\n")
}
+ //Get Location Information
+ loc, locTime := "", ""
+ var locStmp int64 = 0
+ if ul.MAC != "" {
+ qry := dbo.QueryRow(fmt.Sprintf(`SELECT CONCAT_WS(' ', line, CONCAT_WS('-',col,row,num)) AS loc, update_time, update_stmp FROM locinfo WHERE mac='%s' ORDER BY seqid DESC;`, ul.MAC))
+ qry.Scan(&loc, &locTime, &locStmp)
+ } else {
+ qry := dbo.QueryRow(fmt.Sprintf(`SELECT CONCAT_WS(' ', line, CONCAT_WS('-',col,row,num)) AS loc, update_time, update_stmp FROM locinfo WHERE mac='%s' ORDER BY seqid DESC;`, uh.MAC))
+ qry.Scan(&loc, &locTime, &locStmp)
+ }
+
+ if loc == "" {
+ loc = `Unknown`
+ } else {
+ loc = fmt.Sprintf(`%s`, loc)
+ }
+
+ if time.Now().Unix()-locStmp >= 3600 {
+ locTime = fmt.Sprintf(`%s`, locTime)
+ } else {
+ locTime = fmt.Sprintf(`%s`, locTime)
+ }
+
//Get Misc. Info
if partNO == "" {
partNO = uh.PartNO
@@ -650,17 +666,6 @@ func (e *EWS) SimpleMsgHTML(clr, msg string) string {
func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
now := time.Now().Format("2006-01-02 15:04:05")
- if loc == "" {
- loc = `Unknown`
- }
-
- // if misc == "" {
- // misc = `NO Records !`
- // }
-
- // if bkup == "" {
- // bkup = `NO Records !`
- // }
resp := fmt.Sprintf(`