Commit 545a2041 by 朱继来

调整任务脚本

parent c6bad599
......@@ -8,7 +8,6 @@ package main
*/
import (
"crm-server/cmd/task/common"
_"crm-server/cmd/task/common"
"crm-server/configs"
"crm-server/internal/dao"
"crm-server/internal/model"
......@@ -17,9 +16,7 @@ import (
"fmt"
"github.com/ichunt2019/logger"
"strconv"
"strings"
"time"
"github.com/robfig/cron"
)
// 日志目录
......@@ -42,25 +39,28 @@ func main () {
// 查看未下单任务是否开启
task_setup := common.GetTaskSetup(4)
task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
var cron_time string
if task_setup_details.TaskExecTimeType == 1 {
str := strings.Split(task_setup_details.TsakExecTime, ":")
cron_time = "0 " + str[1] + " " + str[0] + " * * *"
} else {
cron_time = "0 " + task_setup_details.TsakExecTime + " * * * *"
}
c := cron.New()
c.AddFunc(cron_time, func() {
fmt.Println(cron_time)
go setFindGoods(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
})
c.Start()
defer c.Stop()
select {
}
//task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
//var cron_time string
//if task_setup_details.TaskExecTimeType == 1 {
// str := strings.Split(task_setup_details.TsakExecTime, ":")
// cron_time = "0 " + str[1] + " " + str[0] + " * * *"
//} else {
// cron_time = "0 " + task_setup_details.TsakExecTime + " * * * *"
//}
//
//c := cron.New()
//c.AddFunc(cron_time, func() {
// fmt.Println(cron_time)
// go setFindGoods(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
//})
//c.Start()
//defer c.Stop()
//select {
//}
setFindGoods(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
fmt.Println("任务执行完成")
}
func setFindGoods(status, task_id, task_type, task_display_degree int) {
......@@ -70,7 +70,7 @@ func setFindGoods(status, task_id, task_type, task_display_degree int) {
db := dao.GetNewDb()
// 获取快速找料的用户
row, err := db.Queryx("select * from lie_feedback where type = ? and is_add_task = ? order by id desc limit 100", 7, 0)
row, err := db.Queryx("select * from lie_feedback where type = ? and is_add_task = ? order by id desc", 7, 0)
defer db.Close()
if err != nil {
......
......@@ -38,21 +38,24 @@ func main () {
task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
// 定时执行
task_exec_time, _ := strconv.Atoi(task_setup_details.TsakExecTime)
ticker := time.NewTicker(time.Minute * time.Duration(task_exec_time))
//task_exec_time, _ := strconv.Atoi(task_setup_details.TsakExecTime)
//ticker := time.NewTicker(time.Minute * time.Duration(task_exec_time))
//ticker := time.NewTicker(time.Second * 5)
for {
select {
case <- ticker.C:
fmt.Println("ticker...")
go setHaveOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
default:
time.Sleep(time.Microsecond * 100)
}
}
//for {
// select {
// case <- ticker.C:
// fmt.Println("ticker...")
//
// go setHaveOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
// default:
// time.Sleep(time.Microsecond * 100)
// }
//}
setHaveOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
fmt.Println("任务执行完成")
}
func setHaveOrderTask(status, task_id, task_type, task_display_degree int, task_end_time int64) {
......
......@@ -14,9 +14,7 @@ import (
"flag"
"fmt"
"github.com/ichunt2019/logger"
"github.com/robfig/cron"
"strconv"
"strings"
"time"
)
......@@ -40,25 +38,28 @@ func main () {
// 查看未下单任务是否开启
task_setup := common.GetTaskSetup(5)
task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
var cron_time string
if task_setup_details.TaskExecTimeType == 1 {
str := strings.Split(task_setup_details.TsakExecTime, ":")
cron_time = "0 " + str[1] + " " + str[0] + " * * *"
} else {
cron_time = "0 " + task_setup_details.TsakExecTime + " * * * *"
}
c := cron.New()
c.AddFunc(cron_time, func() {
fmt.Println(cron_time)
go setMultiSearch(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
})
c.Start()
defer c.Stop()
select {
}
//task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
//
//var cron_time string
//if task_setup_details.TaskExecTimeType == 1 {
// str := strings.Split(task_setup_details.TsakExecTime, ":")
// cron_time = "0 " + str[1] + " " + str[0] + " * * *"
//} else {
// cron_time = "0 " + task_setup_details.TsakExecTime + " * * * *"
//}
//
//c := cron.New()
//c.AddFunc(cron_time, func() {
// fmt.Println(cron_time)
// go setMultiSearch(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
//})
//c.Start()
//defer c.Stop()
//select {
//}
setMultiSearch(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree)
fmt.Println("任务执行完成")
}
func setMultiSearch(status, task_id, task_type, task_display_degree int) {
......@@ -68,7 +69,7 @@ func setMultiSearch(status, task_id, task_type, task_display_degree int) {
db := dao.GetNewDb()
// 获取快速找料的用户
row, err := db.Queryx("select * from lie_feedback where type = ? and is_add_task = ? order by id desc limit 100", 6, 0)
row, err := db.Queryx("select * from lie_feedback where type = ? and is_add_task = ? order by id desc", 6, 0)
defer db.Close()
if err != nil {
......
......@@ -38,21 +38,24 @@ func main () {
task_setup_details := common.GetTaskSetupDetails(task_setup.Id)
// 定时执行
task_exec_time, _ := strconv.Atoi(task_setup_details.TsakExecTime)
ticker := time.NewTicker(time.Minute * time.Duration(task_exec_time))
//task_exec_time, _ := strconv.Atoi(task_setup_details.TsakExecTime)
//ticker := time.NewTicker(time.Minute * time.Duration(task_exec_time))
//ticker := time.NewTicker(time.Second * 3)
for {
select {
case <- ticker.C:
fmt.Println("ticker...")
go setNoOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
default:
time.Sleep(time.Microsecond * 100)
}
}
//for {
// select {
// case <- ticker.C:
// fmt.Println("ticker...")
//
// go setNoOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
// default:
// time.Sleep(time.Microsecond * 100)
// }
//}
setNoOrderTask(task_setup.Status, task_setup.Id, task_setup.TaskType, task_setup.TaskDisplayDegree, task_setup_details.TaskEndTime)
fmt.Println("任务执行完成")
}
func setNoOrderTask(status, task_id, task_type, task_display_degree int, task_end_time int64) {
......
......@@ -51,8 +51,9 @@ func main() {
}
func updateOverTime() {
db := dao.GetDb()
row, err := db.Queryx("select * from lie_task_info where status = 1 limit 100")
db := dao.GetNewDb()
// 查询有截止时间且待处理的任务记录(1-领取分配, 2-未成交释放(30), 3-已成交释放(180))
row, err := db.Queryx("select * from lie_task_info where task_type in (1, 2, 3) and status = 1 limit 10")
defer db.Close()
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment