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
01e96f87
authored
Nov 29, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'dev' of
http://119.23.72.7/sunlong_v5/kaopu-server
into dev
parents
b55457a9
9608608a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
31 deletions
internal/dao/common.go
internal/dao/dong.go
internal/dao/dong_mod.go
internal/logic/mylog.go
internal/dao/common.go
View file @
01e96f87
...
...
@@ -73,7 +73,7 @@ func (d *dao) QueryOne(ctx context.Context,db int,sql_str string)(res map[string
}
project_rows
,
err
:=
GetAllParam
(
rows
);
if
project_rows
=
=
nil
{
if
err
!
=
nil
{
fmt
.
Println
(
"error1002"
+
sql_str
,
err
)
return
}
...
...
internal/dao/dong.go
View file @
01e96f87
...
...
@@ -17,6 +17,7 @@ const (
//项目对应的id
var
Model_dong
=
map
[
int
]
string
{
0
:
"所有"
,
35
:
"逾期金额率"
,
36
:
"发生逾期笔数率"
,
37
:
"平均逾期支付时间(天)"
,
...
...
@@ -43,13 +44,12 @@ var Model_dong_log = map[int]string{
44
:
"_shebao_rate"
,
}
//计算逾期金额率:延期支付时间超过平均账期的金额/收款总额:
func
(
d
*
dao
)
DongMain
(
ctx
context
.
Context
,
project_id
int
,
erp_company_code
string
)
(
r
[]
map
[
string
]
interface
{},
err
error
)
{
var
(
final_score
,
zhi
float64
score_one
float64
=
0
;
//分数
zhi
float64
//计算出来的各个动态分数率
score_one
float64
=
0
;
//
对应梯度
分数
_sql2
string
;
//
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
log_pre
string
=
Model_dong_log
[
project_id
]
//日志文件名称
...
...
@@ -58,7 +58,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
sql_str1
:=
fmt
.
Sprintf
(
_sql1
,
strconv
.
Itoa
(
project_id
))
yuqilv_project
,
err
:=
d
.
QueryOne
(
ctx
,
1
,
sql_str1
)
if
yuqilv_project
==
nil
{
logic
.
Loginfo
(
"不存在该项目配置lie_model ,project_id:"
+
strconv
.
Itoa
(
project_id
),
log_pre
)
log3
:=
"不存在该项目配置lie_model ,project_id:"
+
strconv
.
Itoa
(
project_id
)
fmt
.
Print
(
log3
)
logic
.
Loginfo
(
log3
,
log_pre
)
return
}
weight
,
_
:=
strconv
.
ParseFloat
(
yuqilv_project
[
"weight"
],
64
)
...
...
@@ -67,7 +69,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
sql_str4
:=
fmt
.
Sprintf
(
_sql4
,
strconv
.
Itoa
(
project_id
))
modelItems
,
err
:=
d
.
QueryMany
(
ctx
,
1
,
sql_str4
)
if
modelItems
==
nil
{
logic
.
Loginfo
(
"不存在该项目配置详情lie_model_items,project_id:"
+
strconv
.
Itoa
(
project_id
),
log_pre
)
log4
:=
"不存在该项目配置详情lie_model_items,project_id:"
+
strconv
.
Itoa
(
project_id
)
logic
.
Loginfo
(
log4
,
log_pre
)
fmt
.
Print
(
log4
)
return
}
...
...
@@ -110,7 +114,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
}
if
score_one
==
0
{
fmt
.
Print
(
mod_name
+
"不存在对应梯度,erp_company_code:"
+
v
[
"erp_company_code"
]
+
" zhi:"
+
logic
.
MyFloat64ToStr
(
zhi
)
+
"
\r\n
"
)
log1
:=
"统计"
+
mod_name
+
"--跳过,没有分数,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算率:"
+
logic
.
MyFloat64ToStr
(
zhi
)
+
"
\r\n
"
fmt
.
Print
(
log1
)
logic
.
Loginfo
(
log1
,
log_pre
)
continue
;
}
//计算得到的分数插入分数明细表
...
...
@@ -130,9 +136,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
fmt
.
Print
(
"错误:"
+
err
.
Error
(),
insertid
)
}
log
1
:=
"统计"
+
mod_name
+
"成功--公司编码:"
+
v
[
"erp_company_code"
]
+
"计算得分:"
+
logic
.
MyFloat64ToStr
(
weight
*
score_one
)
+
" 最终得分:"
+
logic
.
MyFloat64ToStr
(
final_scor
e
);
fmt
.
Print
(
log
1
)
logic
.
Loginfo
(
log
1
,
log_pre
)
log
2
:=
"统计"
+
mod_name
+
"--成功,公司编码:"
+
v
[
"erp_company_code"
]
+
" 计算得分:"
+
logic
.
MyFloat64ToStr
(
score_one
)
+
" 最终得分:"
+
logic
.
MyFloat64ToStr
(
weight
*
score_on
e
);
fmt
.
Print
(
log
2
)
logic
.
Loginfo
(
log
2
,
log_pre
)
}
}
logic
.
Loginfo
(
"统计"
+
mod_name
+
"完成"
,
log_pre
)
...
...
internal/dao/dong_mod.go
View file @
01e96f87
...
...
@@ -31,19 +31,12 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
log_pre
string
=
Model_dong_log
[
project_id
]
//日志文件名称
)
//查询逾期率
oneyu
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql3
,
y
[
"erp_company_code"
]))
if
oneyu
[
"yuqilv"
]
==
""
||
oneyu
==
nil
{
//没有结果
log1
:=
"公司编码:"
+
y
[
"erp_company_code"
]
+
"逾期金额率为空,跳过"
;
fmt
.
Print
(
log1
)
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
fmt
.
Print
(
"
\r\n
公司编码:"
+
y
[
"erp_company_code"
]
+
mod_name
+
"为:"
+
oneyu
[
"yuqilv"
])
//查询逾期率对应分数
yuqilv
,
_
:=
strconv
.
ParseFloat
(
oneyu
[
"yuqilv"
],
64
)
for
_
,
y
:=
range
modelItems
{
...
...
@@ -52,7 +45,6 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
if
(
ladder_range_min
<=
yuqilv
&&
yuqilv
<
ladder_range_max
)
{
score_one
=
logic
.
MyFloat64
(
y
[
"score"
])
//得到的分数
}
//fmt.Print("\r\n\r\n :",ladder_range_min,ladder_range_max,yuqilv)
}
zhi
=
yuqilv
fen
=
score_one
...
...
@@ -63,15 +55,11 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
func
(
d
*
dao
)
DongYuqiBi
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
zhi
float64
,
fen
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
log_pre
string
=
Model_dong_log
[
project_id
]
//日志文件名称
)
//查询逾期笔数
yuqibi
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql5
,
y
[
"erp_company_code"
]))
if
yuqibi
[
"yuqibi"
]
==
"0"
{
//没有结果
log1
:=
"公司编码:"
+
y
[
"erp_company_code"
]
+
"没有逾期笔数,跳过"
;
fmt
.
Print
(
log1
)
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
//收款总笔数
allbi
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql6
,
y
[
"erp_company_code"
]))
...
...
@@ -95,15 +83,10 @@ func (d *dao) DongYuqiBi(ctx context.Context,y map[string]string,modelItems []ma
func
(
d
*
dao
)
DongYuqiDivDay
(
ctx
context
.
Context
,
y
map
[
string
]
string
,
modelItems
[]
map
[
string
]
string
,
project_id
int
)
(
zhi
float64
,
fen
float64
,
err
error
)
{
var
(
score_one
float64
=
0
;
//分数
mod_name
string
=
Model_dong
[
project_id
]
//统计动态模型名称
log_pre
string
=
Model_dong_log
[
project_id
]
//日志文件名称
)
//每笔逾期账款的逾期时间合计
yuqibi
,
_
:=
d
.
QueryOne
(
ctx
,
2
,
fmt
.
Sprintf
(
_sql8
,
y
[
"erp_company_code"
]))
if
yuqibi
[
"sum_delay_day"
]
==
"0"
{
//没有结果
log1
:=
"公司编码:"
+
y
[
"erp_company_code"
]
+
"每笔逾期账款的逾期时间合计为0,跳过"
;
fmt
.
Print
(
log1
)
logic
.
Loginfo
(
"统计--"
+
mod_name
+
log1
,
log_pre
)
return
}
//发生逾期总笔数
...
...
internal/logic/mylog.go
View file @
01e96f87
...
...
@@ -4,7 +4,6 @@ import (
"io"
"os"
"time"
"fmt"
)
func
check
(
e
error
)
{
...
...
@@ -41,8 +40,9 @@ func Loginfo(writeString string,log_file_pre string) {
f
,
err1
=
os
.
Create
(
filename
)
//创建文件
}
check
(
err1
)
_
,
err
:=
io
.
WriteString
(
f
,
"
\r\n
"
+
date2
+
"----"
+
writeString
)
//写入文件(字符串)
fmt
.
Print
(
err
)
ss
:=
StrReplace
(
"
\r\n
"
,
""
,
writeString
,
1
)
//替换多余换行
io
.
WriteString
(
f
,
"
\r\n
"
+
date2
+
"----"
+
ss
)
//写入文件(字符串)
//fmt.Print(err)
}
/**
...
...
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