add new record when relay server have changed

This commit is contained in:
r0n1n7an 2024-03-10 12:10:19 +08:00
parent 59f2beee8e
commit 0c1038b715
4 changed files with 33 additions and 26 deletions

Binary file not shown.

View File

@ -1,13 +1,16 @@
2023/11/26 13:55:57.704762 [MSG] Starting Service ... 2024/02/15 12:29:07.893024 [MSG] Starting Service ...
2023/11/26 13:55:57.705863 [MSG] Starting HTTP Server On Port: 9000 2024/02/15 12:29:07.893552 [MSG] Starting HTTP Server On Port: 9000
2023/11/26 14:18:51.150028 [MSG] Stopping Service ... 2024/02/15 12:59:01.722743 [ERR] [; /getuutinfo/; map[string]string{"ACTION":"QueryByFilter", "KEY":"USN", "VALUE":"8CG40510S8"}; Error 1044 (42000): Access denied for user 'apisvc'@'127.0.0.1' to database 'ewsv3_f715'
2023/11/26 14:18:51.490959 [MSG] Service Stop. 2024/02/27 14:04:51.488366 [MSG] Stopping Service ...
2023/11/26 16:47:50.371038 [MSG] Starting Service ... 2024/02/27 14:06:20.459743 [MSG] Starting Service ...
2023/11/26 16:47:50.371038 [MSG] Starting HTTP Server On Port: 9000 2024/02/27 14:06:20.460261 [MSG] Starting HTTP Server On Port: 9000
2023/11/26 16:47:50.371710 [MSG] Service Started. 2024/02/28 11:37:09.767931 [MSG] Stopping Service ...
2023/11/26 16:48:05.560613 [MSG] [; /getuutinfo/; Request: map[string]string{"QUERY":"Query", "USN":""} 2024/02/28 11:37:10.091309 [MSG] Service Stop.
2023/11/26 16:48:05.560613 [ERR] [; /getuutinfo/; map[string]string{"QUERY":"Query", "USN":""}; Invalid Parameters ! 2024/02/28 11:37:29.331979 [MSG] Service Started.
2023/11/26 16:48:14.359757 [MSG] [; /getuutinfo/; Request: map[string]string{"QUERY":"Query", "USN":"test"} 2024/02/28 11:37:29.339100 [MSG] Starting Service ...
2023/11/26 16:48:15.199717 [MSG] [; /getuutinfo/; Request: map[string]string{"QUERY":"Query", "USN":"test"} 2024/02/28 11:37:29.341232 [MSG] Starting HTTP Server On Port: 9000
2023/11/26 16:48:35.401080 [ERR] [; /getuutinfo/; map[string]string{"QUERY":"Query", "USN":"test"}; dial tcp 10.60.230.109:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 2024/03/06 23:12:38.142769 [MSG] Stopping Service ...
2023/11/26 16:48:36.225172 [ERR] [; /getuutinfo/; map[string]string{"QUERY":"Query", "USN":"test"}; dial tcp 10.60.230.109:3306: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 2024/03/07 19:35:00.984241 [MSG] Starting Service ...
2024/03/07 19:35:00.985457 [MSG] Starting HTTP Server On Port: 9000
2024/03/10 11:51:37.537326 [MSG] Stopping Service ...
2024/03/10 11:51:37.888580 [MSG] Service Stop.

View File

@ -9,7 +9,7 @@ Settings:
MySQL: MySQL:
Server: 127.0.0.1 Server: 127.0.0.1
Port: 3306 Port: 3306
Database: ewsv3_f716 Database: ewsv3_f715
User: apisvc User: apisvc
Password: wcqte Password: wcqte
IssuesTable: issues IssuesTable: issues

View File

@ -188,30 +188,34 @@ func (e *EWS) SetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri
return rst return rst
} }
//如果此USN的记录存在与uutinfo表中, 且此USN的MAC/Item/Status/Message已变化, 则: //如果此USN的记录存在于uutinfo表中, 且此USN的Relay/MAC/Item/Status/Message已变化, 则:
//1. 备份此USN对应记录行到uutinfobkup表 //1. 备份此USN对应记录行到uutinfobkup表
//2. 删除uutinfo表中对应USN记录的MAC/Item/Status/Message/PartNO/MO/SKU/Line/Stage //2. 删除uutinfo表中对应USN的记录行
//3. 新增此USN的最新记录到uutinfo表 //3. 新增此USN的最新记录到uutinfo表
extFlag := false isExist := false
chgFlag := false chgFlag := false
_, extFlag = params["MAC"] _, isExist = params["MAC"]
if extFlag && params["MAC"] != ui.MAC { if isExist && params["MAC"] != ui.MAC {
chgFlag = true chgFlag = true
} }
_, extFlag = params["ITEM"] _, isExist = params["ITEM"]
if extFlag && params["ITEM"] != ui.Item { if isExist && params["ITEM"] != ui.Item {
chgFlag = true chgFlag = true
} }
_, extFlag = params["STATUS"] _, isExist = params["STATUS"]
if extFlag && params["STATUS"] != ui.Status { if isExist && params["STATUS"] != ui.Status {
chgFlag = true chgFlag = true
} }
_, extFlag = params["MESSAGE"] _, isExist = params["MESSAGE"]
if extFlag && params["MESSAGE"] != ui.Message { if isExist && params["MESSAGE"] != ui.Message {
chgFlag = true
}
if host != ui.Relay {
chgFlag = true chgFlag = true
} }
@ -333,7 +337,7 @@ func (e *EWS) SetUutInfo(cfg cnf.Cfg, logger *log.Logger, host string, addr stri
return rst return rst
} }
//如果此USN的记录存在与uutinfo表中, 且MAC/Item/Status/Message未变化, 则更新此USN记录的ipaddr,relay,line,stage, 并更新last_ack栏位为当前时间 //如果此USN的记录存在于uutinfo表中, 且Relay/MAC/Item/Status/Message未变化, 则更新uutinfo表中此USN对应的last_ack栏位为当前时间
//dmlUpdate := fmt.Sprintf("UPDATE uutinfo SET ipaddr='%s', relay='%s', line='%s', stage='%s', last_ack=NOW() WHERE usn='%s';", //dmlUpdate := fmt.Sprintf("UPDATE uutinfo SET ipaddr='%s', relay='%s', line='%s', stage='%s', last_ack=NOW() WHERE usn='%s';",
// addr, host, params["LINE"], params["STAGE"], params["USN"]) // addr, host, params["LINE"], params["STAGE"], params["USN"])
//2024-01-26: 使用事务模式先删除再插入此USN的记录, 避免直接使用UPDATE导致自增键seqid不更新 //2024-01-26: 使用事务模式先删除再插入此USN的记录, 避免直接使用UPDATE导致自增键seqid不更新