Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CnChunfeng
/
crm_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
545a2041
authored
Sep 16, 2020
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整任务脚本
parent
c6bad599
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
71 deletions
cmd/task/find_goods/main.go
cmd/task/have_order/main.go
cmd/task/multi_search/main.go
cmd/task/no_order/main.go
cmd/task/task_monitor/main.go
cmd/task/find_goods/main.go
View file @
545a2041
...
...
@@ -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
{
...
...
cmd/task/have_order/main.go
View file @
545a2041
...
...
@@ -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
)
{
...
...
cmd/task/multi_search/main.go
View file @
545a2041
...
...
@@ -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
{
...
...
cmd/task/no_order/main.go
View file @
545a2041
...
...
@@ -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
)
{
...
...
cmd/task/task_monitor/main.go
View file @
545a2041
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment