Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
kaopu-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
9c1545f5
authored
Dec 06, 2019
by
huangchengyi
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1.0
parent
604a245b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
55 deletions
cmd/dong/main.go
internal/dao/common.go
internal/dao/dao.go
internal/dao/dong.go
internal/dao/dong_mod.go
cmd/dong/main.go
View file @
9c1545f5
...
...
@@ -6,12 +6,12 @@ import (
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"kaopu-server/internal/dao"
"kaopu-server/internal/logic"
"kaopu-server/internal/service"
"os"
"strconv"
"github.com/ichunt2019/go-msgserver/utils/rabbitmq"
"time"
)
...
...
@@ -50,13 +50,16 @@ func main() {
if
mod
>
0
{
svc
:=
service
.
New
()
svc
.
DongRun
(
ctx
,
mod
,
""
);
//运行main
svc
.
DongRun
(
ctx
,
999
,
""
);
//总计所有分数
svc
.
Close
()
//关闭数据库连接
logic
.
LogWrite
(
"统计"
+
dao
.
Model_dong
[
mod
]
+
"完成"
,
dao
.
Model_dong_log
[
mod
],
1
)
}
else
{
for
{
logic
.
LogWrite
(
"统计所有动态任务开始"
,
"_dong_main"
,
1
)
svc
:=
service
.
New
()
for
k
,
_
:=
range
model_dong
{
if
k
==
-
1
||
k
==
0
{
continue
;
...
...
@@ -66,15 +69,13 @@ func main() {
logic
.
LogWrite
(
"统计项目"
+
mod_name
+
"开始:"
+
strconv
.
Itoa
(
k
),
mod_name_log
,
1
)
svc
:=
service
.
New
()
svc
.
DongRun
(
ctx
,
k
,
""
);
//运行main
logic
.
LogWrite
(
"统计项目"
+
mod_name
+
"结束:"
+
strconv
.
Itoa
(
k
),
mod_name_log
,
1
)
}
//最后关闭数据连接
d
:=
dao
.
New
()
d
.
Close
()
//关闭数据库连接
svc
.
Close
()
//关闭数据库连接
time
.
Sleep
(
60
*
time
.
Second
)
}
...
...
@@ -104,7 +105,7 @@ func queues() {
fmt
.
Println
(
err
)
}
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
3
*
time
.
Second
)
}
}
...
...
@@ -119,6 +120,8 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
ctx
:=
context
.
Background
()
//上下文
model_dong
:=
dao
.
Model_dong
//所有动态模型算法列表
svc
:=
service
.
New
()
for
k
,
_
:=
range
model_dong
{
if
k
==
-
1
||
k
==
0
{
continue
;
...
...
@@ -129,15 +132,14 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
fmt
.
Println
(
"统计开始:"
+
strconv
.
Itoa
(
k
))
logic
.
Loginfo
(
"统计开始--"
+
mod_name
,
mod_name_log
);
svc
:=
service
.
New
()
svc
.
DongRun
(
ctx
,
k
,
rbm
.
ErpCompanyCode
);
//运行main
fmt
.
Println
(
"统计结束:"
+
strconv
.
Itoa
(
k
))
logic
.
Loginfo
(
"统计结束--"
+
mod_name
,
mod_name_log
);
}
//最后关闭数据连接
d
:=
dao
.
New
()
d
.
Close
()
//关闭数据库连接
svc
.
Close
()
//关闭数据库连接
//return errors.New("顶顶顶顶")
return
nil
...
...
internal/dao/common.go
View file @
9c1545f5
...
...
@@ -105,5 +105,6 @@ func (d *dao)QueryMany(ctx context.Context,db int,sql_str string)(res []map[stri
return
}
res
=
project_rows
return
}
internal/dao/dao.go
View file @
9c1545f5
...
...
@@ -41,14 +41,14 @@ type (
//---动态开始
DongMain
(
ctx
context
.
Context
,
project_id
int
,
erp_company_code
string
)
(
r
[]
map
[
string
]
interface
{},
err
error
)
//动态模型调用主函数
//1 计算逾期金额率 ,ladder_rate 计算出来的此算法对应梯度率,ladder_score 梯度对应的分数
DongYuqiRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
DongYuqiBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//2 发生逾期笔数率
DongYuqiDivDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//3 平均逾期支付时间
DongDivPayDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//4 平均付款时间
DongNormalPayRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//5 正常收款金额率
DongNormalPayBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//6 正常收款笔数率
DongInTimeRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//8 交货及时率
DongReturnRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
//9 退货率
DongYuqiRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
DongYuqiBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//2 发生逾期笔数率
DongYuqiDivDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//3 平均逾期支付时间
DongDivPayDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//4 平均付款时间
DongNormalPayRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//5 正常收款金额率
DongNormalPayBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//6 正常收款笔数率
DongInTimeRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//8 交货及时率
DongReturnRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
//9 退货率
DongAddScore
(
ctx
context
.
Context
,
com_credits_id
int64
)(
affectNum
int64
)
//统计动态分数,更新到每个公司
//---动态结束
}
...
...
internal/dao/dong.go
View file @
9c1545f5
...
...
@@ -11,7 +11,7 @@ import (
//存放动态模型所有常量
const
(
_sql1
=
"select m.full_score,m.weight,m.max_score,p.id,p.pid from lie_model m,lie_project p where m.project_id=p.id and p.id=%s"
//查询项目配置
_sql2_1
=
"select id,erp_company_code,company_name from lie_com_credits
ddd
order by id asc "
//查询公司所有信息
_sql2_1
=
"select id,erp_company_code,company_name from lie_com_credits order by id asc "
//查询公司所有信息
_sql2_2
=
"select id,erp_company_code,company_name from lie_com_credits where erp_company_code = '%s' order by id asc "
//查询单个公司所有信息
)
...
...
@@ -50,7 +50,7 @@ var Model_dong_log = map[int]string{
func
(
d
*
dao
)
DongMain
(
ctx
context
.
Context
,
project_id
int
,
erp_company_code
string
)
(
r
[]
map
[
string
]
interface
{},
err
error
)
{
var
(
weight
float64
//权重
ladder_rate
float64
//计算出来的各个动态分数率
ladder_rate
string
//计算出来的各个动态分数率
ladder_score
float64
=
0
;
//对应梯度分数
_sql2
string
;
//查询公司信息sql
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -84,6 +84,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
}
else
{
_sql2
=
fmt
.
Sprintf
(
_sql2_2
,
erp_company_code
)
//查询一个公司
}
fmt
.
Print
(
_sql2
)
company_info
,
err
:=
d
.
QueryMany
(
ctx
,
1
,
_sql2
);
if
err
!=
nil
{
...
...
@@ -121,7 +122,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
}
if
ladder_score
==
0
{
logic
.
LogWrite
(
"统计"
+
mod_name
+
"--没有梯度对应分数,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算
率:"
+
logic
.
MyFloat64ToStr
(
ladder_rate
)
,
log_pre
,
1
)
logic
.
LogWrite
(
"统计"
+
mod_name
+
"--没有梯度对应分数,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算
公式:"
+
ladder_rate
,
log_pre
,
1
)
continue
;
}
//计算得到的分数插入分数明细表
...
...
@@ -146,7 +147,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
fmt
.
Print
(
"错误:"
+
err
.
Error
(),
insertid
,
ladder_rate
)
}
//日志
logic
.
LogWrite
(
"统计"
+
mod_name
+
"--成功,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算得分:"
+
logic
.
MyFloat64ToStr
(
ladder_score
)
+
" 权重:"
+
logic
.
MyFloat64ToStr
(
weight
)
+
" 最终得分:"
+
logic
.
MyFloat64ToStr
(
weight
*
ladder_score
),
log_pre
,
1
)
logic
.
LogWrite
(
"统计"
+
mod_name
+
"--成功,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算
公式:"
+
ladder_rate
+
" 梯度
得分:"
+
logic
.
MyFloat64ToStr
(
ladder_score
)
+
" 权重:"
+
logic
.
MyFloat64ToStr
(
weight
)
+
" 最终得分:"
+
logic
.
MyFloat64ToStr
(
weight
*
ladder_score
),
log_pre
,
1
)
}
return
...
...
internal/dao/dong_mod.go
View file @
9c1545f5
This diff is collapsed.
Click to expand it.
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