excluded_filename 排重
This commit is contained in:
parent
956261f82b
commit
141dd7088d
BIN
iniDataForLinux
BIN
iniDataForLinux
Binary file not shown.
BIN
iniDataForMacOs
BIN
iniDataForMacOs
Binary file not shown.
54
main.go
54
main.go
@ -122,16 +122,32 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
switch task.TaskData.Command {
|
||||
case "lastCall":
|
||||
//判断lastCall是否有执行中
|
||||
if exists, _ := redisClient.Exists("iniLastCallDataStatus").Result(); exists == 1 {
|
||||
returnMessage = []byte(`{"code": 2007,"err": "有lastCall执行中,请稍后重试"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
break
|
||||
}
|
||||
//判断ExcludedFilename是否执行过
|
||||
lastCallTask := fmt.Sprintf("lastCallTask:%s", task.TaskData.ExcludedFilename)
|
||||
if exists, _ := redisClient.Exists(lastCallTask).Result(); exists == 1 {
|
||||
returnMessage = []byte(`{"code": 2008,"err": "ExcludedFilename重复跳过执行"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
break
|
||||
}
|
||||
//判断ExcludedFilename是否存在
|
||||
if !fileExists(path.Join(executableDir, lastCallPath, task.TaskData.ExcludedFilename)) {
|
||||
returnMessage = []byte(`{"code": 2003,"err": "task.ExcludedFilename 不存在"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
break
|
||||
}
|
||||
//判断BatchFilename是否存在
|
||||
if !fileExists(path.Join(executableDir, txtPath, task.TaskData.BatchFilename)) {
|
||||
returnMessage = []byte(`{"code": 2004,"err": "task.BatchFilename 不存在"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
break
|
||||
}
|
||||
//判断DataFilename是否存在
|
||||
if !fileExists(path.Join(executableDir, txtPath, task.TaskData.DataFilename)) {
|
||||
returnMessage = []byte(`{"code": 2005,"err": "task.DataFilename 不存在"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
@ -139,6 +155,7 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
returnMessage = []byte(`{"code": 2000,"err": "开始处理lastCall"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
//读取排重文件
|
||||
lastCallKeys, err := readExcludedFile(path.Join(executableDir, lastCallPath, task.TaskData.ExcludedFilename))
|
||||
if err != nil {
|
||||
returnMessage = []byte(`{"code": 2006,"err": "打开ExcludedFilename失败"}`)
|
||||
@ -148,29 +165,24 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
|
||||
returnMessage = []byte(`{"code": 2000,"err": "ExcludedFilename读取完成"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
}
|
||||
if exists, _ := redisClient.Exists("iniLastCallDataStatus").Result(); exists == 1 {
|
||||
returnMessage = []byte(`{"code": 2007,"err": "有lastCall执行中,请稍后重试"}`)
|
||||
//无错误,执行逻辑代码,
|
||||
subject := "丝芙兰短信处理程序异常"
|
||||
err = redisClient.Set("iniLastCallDataStatus", 1, 0).Err()
|
||||
if err != nil {
|
||||
body := fmt.Sprintf("写入lastCall任务执行中标记失败:%v", err)
|
||||
applogger.Error(body)
|
||||
returnMessage = []byte(fmt.Sprintf(`{"code": 2008,"err": "写入lastCall任务执行中标记失败%v"}`, err))
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
|
||||
SendEmail(subject, body) //发送邮件
|
||||
} else {
|
||||
//无错误,执行逻辑代码,
|
||||
subject := "丝芙兰短信处理程序异常"
|
||||
err := redisClient.Set("iniLastCallDataStatus", 1, 0).Err()
|
||||
if err != nil {
|
||||
body := fmt.Sprintf("写入lastCall任务执行中标记失败:%v", err)
|
||||
applogger.Error(body)
|
||||
returnMessage = []byte(fmt.Sprintf(`{"code": 2008,"err": "写入lastCall任务执行中标记失败%v"}`, err))
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
SendEmail(subject, body) //发送邮件
|
||||
} else {
|
||||
batchInsert(task.TaskData.BatchFilename, true, task.TaskData.ExcludedFilename) //创建批次
|
||||
returnMessage = []byte(`{"code": 2000,"err": "批次创建完成"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
batchDataInsert(task.TaskData.DataFilename, lastCallKeys, task.TaskData.ExcludedFilename) //添加数据
|
||||
redisClient.Del("iniLastCallDataStatus") //删除任务执行中标记
|
||||
returnMessage = []byte(`{"code": 2000,"err": "结束处理lastCall"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
}
|
||||
batchInsert(task.TaskData.BatchFilename, true, task.TaskData.ExcludedFilename) //创建批次
|
||||
returnMessage = []byte(`{"code": 2000,"err": "批次创建完成"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
batchDataInsert(task.TaskData.DataFilename, lastCallKeys, task.TaskData.ExcludedFilename) //添加数据
|
||||
redisClient.Del("iniLastCallDataStatus") //删除任务执行中标记
|
||||
returnMessage = []byte(`{"code": 2000,"err": "结束处理lastCall"}`)
|
||||
conn.WriteMessage(websocket.TextMessage, returnMessage) //发送消息给客户端
|
||||
redisClient.Set(lastCallTask, 1, 0).Err() //记录ExcludedFilename执行完成
|
||||
}
|
||||
default:
|
||||
returnMessage = []byte(`{"code": 2002,"err": "task.Command 不存在"}`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user