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
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
...
...
@@ -29,7 +29,7 @@ const (
@param ladder_score 分数,最终对应哪个梯度得分
*/
//1 计算逾期金额率:延期支付时间超过平均账期的金额/收款总额:
func
(
d
*
dao
)
DongYuqiRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongYuqiRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
...
...
@@ -48,42 +48,42 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
yuqilv
ladder_rate
=
oneyu
[
"yuqilv"
]
ladder_score
=
score_one
return
}
//2 发生逾期笔数率: 发生逾期笔数/收款总笔数
func
(
d
*
dao
)
DongYuqiBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongYuqiBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
)
//查询逾期笔数
yuqibi
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql5
,
y
[
"erp_company_code"
]))
if
yuqibi
[
"yuqibi"
]
==
"0"
{
//没有结果
c1
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql5
,
y
[
"erp_company_code"
]))
if
c1
[
"yuqibi"
]
==
"0"
{
//没有结果
return
}
//收款总笔数
allbi
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql6
,
y
[
"erp_company_code"
]))
birate
:=
logic
.
MyFloat64
(
yuqibi
[
"yuqibi"
])
/
logic
.
MyFloat64
(
allbi
[
"allbi"
])
c2
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql6
,
y
[
"erp_company_code"
]))
chrate
:=
logic
.
MyFloat64
(
c1
[
"yuqibi"
])
/
logic
.
MyFloat64
(
c2
[
"allbi"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
birate
&&
bi
rate
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
ch
rate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
//fmt.Print(modelItems,birate,score_one)
ladder_rate
=
birate
ladder_rate
=
c1
[
"yuqibi"
]
+
"/"
+
c2
[
"allbi"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//3 平均逾期支付时间(天): 每笔逾期账款的逾期时间合计/发生逾期总笔数
func
(
d
*
dao
)
DongYuqiDivDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongYuqiDivDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
)
...
...
@@ -94,24 +94,24 @@ func (d *dao) DongYuqiDivDay(ctx context.Context,y map[string]string,modelItems
}
//发生逾期总笔数
c2
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql5
,
y
[
"erp_company_code"
]))
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_delay_day"
])
/
logic
.
MyFloat64
(
c2
[
"yuqibi"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_delay_day"
])
/
logic
.
MyFloat64
(
c2
[
"yuqibi"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_delay_day"
]
+
"/"
+
c2
[
"yuqibi"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//4 平均付款时间(天): 每笔付款账期合计/收款总笔数
func
(
d
*
dao
)
DongDivPayDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongDivPayDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -133,24 +133,24 @@ func (d *dao) DongDivPayDay(ctx context.Context,y map[string]string,modelItems [
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_zhang"
])
/
logic
.
MyFloat64
(
c2
[
"allbi"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_zhang"
])
/
logic
.
MyFloat64
(
c2
[
"allbi"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_zhang"
]
+
"/"
+
c2
[
"allbi"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//5 正常收款金额率: 容差范围内的收款(还款)金额/收款总金额
func
(
d
*
dao
)
DongNormalPayRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongNormalPayRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -172,24 +172,24 @@ func (d *dao) DongNormalPayRate(ctx context.Context,y map[string]string,modelIte
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_huan"
])
/
logic
.
MyFloat64
(
c2
[
"sum_shou"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_huan"
])
/
logic
.
MyFloat64
(
c2
[
"sum_shou"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_rongcha_huan"
]
+
"/"
+
c2
[
"sum_shou"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//6 正常收款笔数率:完成容差范围内收款的笔数/收款总笔数
func
(
d
*
dao
)
DongNormalPayBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongNormalPayBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -211,24 +211,24 @@ func (d *dao) DongNormalPayBi(ctx context.Context,y map[string]string,modelItems
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_bi"
])
/
logic
.
MyFloat64
(
c2
[
"allbi"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_bi"
])
/
logic
.
MyFloat64
(
c2
[
"allbi"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_rongcha_bi"
]
+
"/"
+
c2
[
"allbi"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//8 交货及时率: 按期交货总金额/交货总金额(下单总金额) PS按期交货:逾期交付天数<0
func
(
d
*
dao
)
DongInTimeRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongInTimeRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -250,24 +250,24 @@ func (d *dao) DongInTimeRate(ctx context.Context,y map[string]string,modelItems
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_huan"
])
/
logic
.
MyFloat64
(
c2
[
"sum_jiaohuo"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_rongcha_huan"
])
/
logic
.
MyFloat64
(
c2
[
"sum_jiaohuo"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_rongcha_huan"
]
+
"/"
+
c2
[
"sum_jiaohuo"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
//9 退货率 : 退货总金额/出库总金额(下单总金额) PS退货总金额金额为负数的订单
func
(
d
*
dao
)
DongReturnRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
float64
,
ladder_score
float64
,
err
error
)
{
func
(
d
*
dao
)
DongReturnRate
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
ladder_rate
string
,
ladder_score
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
...
...
@@ -289,18 +289,18 @@ func (d *dao) DongReturnRate(ctx context.Context,y map[string]string,modelItems
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
rate_res
:=
logic
.
MyFloat64
(
c1
[
"sum_tuihuo"
])
/
logic
.
MyFloat64
(
c2
[
"sum_chuhuo"
])
chrate
:=
logic
.
MyFloat64
(
c1
[
"sum_tuihuo"
])
/
logic
.
MyFloat64
(
c2
[
"sum_chuhuo"
])
//计算分数
for
_
,
y
:=
range
modelItems
{
ladder_range_min
:=
logic
.
MyFloat64
(
y
[
"ladder_range_min"
])
ladder_range_max
:=
logic
.
MyFloat64
(
y
[
"ladder_range_max"
])
if
(
ladder_range_min
<=
rate_res
&&
rate_res
<
ladder_range_max
)
{
if
(
ladder_range_min
<=
chrate
&&
chrate
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
}
ladder_rate
=
rate_res
ladder_rate
=
c1
[
"sum_tuihuo"
]
+
"/"
+
c2
[
"sum_chuhuo"
]
+
"="
+
logic
.
MyFloat64ToStr
(
chrate
)
ladder_score
=
score_one
return
}
...
...
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