过滤规则增加个性化字段1
This commit is contained in:
parent
5c0498c102
commit
3c9a16cf2f
BIN
iniDataForLinux
BIN
iniDataForLinux
Binary file not shown.
BIN
iniDataForMacOs
BIN
iniDataForMacOs
Binary file not shown.
18
main.go
18
main.go
@ -159,7 +159,7 @@ func init() {
|
|||||||
batchSize = 5000 //提交数据
|
batchSize = 5000 //提交数据
|
||||||
insertSize = 500 //一次性入库
|
insertSize = 500 //一次性入库
|
||||||
insertChanSize = 50 //通道缓冲数
|
insertChanSize = 50 //通道缓冲数
|
||||||
goSize = 10 //协程数
|
goSize = 50 //协程数
|
||||||
taskTime = 60
|
taskTime = 60
|
||||||
to = []string{"chejiulong@wemediacn.com", "xiayujuan@wemediacn.com", "wangyuanbing@wemediacn.com", "tangweiqi@wemediacn.com"}
|
to = []string{"chejiulong@wemediacn.com", "xiayujuan@wemediacn.com", "wangyuanbing@wemediacn.com", "tangweiqi@wemediacn.com"}
|
||||||
default:
|
default:
|
||||||
@ -179,6 +179,7 @@ func init() {
|
|||||||
Password: redisPassword,
|
Password: redisPassword,
|
||||||
DB: redisDB,
|
DB: redisDB,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -204,11 +205,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
logOutput := io.MultiWriter(os.Stdout, logFileHook) // 将日志同时输出到控制台和文件
|
logOutput := io.MultiWriter(os.Stdout, logFileHook) // 将日志同时输出到控制台和文件
|
||||||
applogger.SetOutput(logOutput)
|
applogger.SetOutput(logOutput)
|
||||||
applogger.Info(fmt.Sprintf("程序启动,加载%s环境,尝试第1次执行...", env))
|
applogger.Info(fmt.Sprintf("程序启动,加载%s环境,尝试执行...", env))
|
||||||
go downloadDecompression() // 启动立即执行一次
|
go downloadDecompression() // 启动立即执行一次
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Duration(taskTime) * time.Minute) // 创建一个定时器
|
ticker := time.NewTicker(time.Duration(taskTime) * time.Minute) // 创建一个定时器
|
||||||
tickCount := 2 //记录循环次数
|
|
||||||
defer ticker.Stop() // 延迟关闭定时器,确保所有的定时器事件都被处理完毕
|
defer ticker.Stop() // 延迟关闭定时器,确保所有的定时器事件都被处理完毕
|
||||||
// 循环处理任务
|
// 循环处理任务
|
||||||
for {
|
for {
|
||||||
@ -222,10 +222,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
logOutput := io.MultiWriter(os.Stdout, logFileHook) // 将日志同时输出到控制台和文件
|
logOutput := io.MultiWriter(os.Stdout, logFileHook) // 将日志同时输出到控制台和文件
|
||||||
applogger.SetOutput(logOutput)
|
applogger.SetOutput(logOutput)
|
||||||
//fmt.Printf("尝试第%d次执行....\n", tickCount)
|
applogger.Info("尝试执行...")
|
||||||
applogger.Info(fmt.Sprintf("尝试第%d次执行...", tickCount))
|
go downloadDecompression()
|
||||||
go downloadDecompression() // 在新协程中异步执行
|
|
||||||
tickCount++
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +291,7 @@ func downloadDecompression() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//fmt.Printf("%s(数据包)下载完成\n", file.Name())
|
//fmt.Printf("%s(数据包)下载完成\n", file.Name())
|
||||||
applogger.Error(fmt.Sprintf("%s(数据包)下载完成", file.Name()))
|
applogger.Info(fmt.Sprintf("%s(数据包)下载完成", file.Name()))
|
||||||
// Unzip file
|
// Unzip file
|
||||||
zipReader, err := zip.OpenReader(path.Join(executableDir, zipPath, file.Name()))
|
zipReader, err := zip.OpenReader(path.Join(executableDir, zipPath, file.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -485,7 +483,7 @@ func batchDataInsert(fileName string) {
|
|||||||
duplicateCount[row[2]] = 0
|
duplicateCount[row[2]] = 0
|
||||||
}
|
}
|
||||||
// Check if record exists in hashset
|
// Check if record exists in hashset
|
||||||
key := fmt.Sprintf("%s-%s", row[2], row[3])
|
key := fmt.Sprintf("%s-%s-%s", row[2], row[3], row[5])
|
||||||
if _, exists := hs[key]; exists { //如果批次数据重复
|
if _, exists := hs[key]; exists { //如果批次数据重复
|
||||||
bi++
|
bi++
|
||||||
// Increment duplicate count
|
// Increment duplicate count
|
||||||
@ -571,7 +569,7 @@ func batchDataInsert(fileName string) {
|
|||||||
subject := "丝芙兰数据包处理完成"
|
subject := "丝芙兰数据包处理完成"
|
||||||
body := "数据包:" + fileName + ";\n总数:" + strconv.Itoa(count+bi) + ";\n过滤重复数:" + strconv.Itoa(bi) + ";\n过滤后总数:" + strconv.Itoa(count) + ";\n处理完成,请前往管理平台查看处理。"
|
body := "数据包:" + fileName + ";\n总数:" + strconv.Itoa(count+bi) + ";\n过滤重复数:" + strconv.Itoa(bi) + ";\n过滤后总数:" + strconv.Itoa(count) + ";\n处理完成,请前往管理平台查看处理。"
|
||||||
SendEmail(subject, body) //发送邮件
|
SendEmail(subject, body) //发送邮件
|
||||||
applogger.Info(fmt.Sprintf(fmt.Sprintf("%s(数据包) ,入库完成", fileName)))
|
applogger.Info(fmt.Sprintf(fmt.Sprintf("%s(数据包) 入库完成", fileName)))
|
||||||
applogger.Info(fmt.Sprintf("%s(数据包)执行时间:%s 插入数据:%d条 过滤数数:%d条", fileName, elapsed, count, bi))
|
applogger.Info(fmt.Sprintf("%s(数据包)执行时间:%s 插入数据:%d条 过滤数数:%d条", fileName, elapsed, count, bi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user