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
f04f6aa4
authored
Dec 11, 2019
by
Joneq
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
修改rows的获取与关闭
parent
1fe9e1c1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
67 deletions
cmd/static/Common.go
cmd/static/main.go
internal/dao/add_score.go
internal/dao/basic_info.go
internal/dao/com_basicinfos.go
internal/dao/com_credits.go
internal/dao/credit_score_fields.go
internal/dao/dao.go
internal/logic/common.go
internal/service/service.go
cmd/static/Common.go
View file @
f04f6aa4
...
...
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"kaopu-server/internal/dao"
"kaopu-server/internal/service"
"strconv"
"time"
)
...
...
@@ -13,28 +12,18 @@ import (
func
SetSumScore
(
c
context
.
Context
)
{
com_credits
.
Id
=
insertScoreMsg
.
ComCreditsId
com_credits
.
StaticCreditScore
=
CompanyInfo
()
+
AddScore
()
+
EnterPriseCredit
()
+
HistoryBussiness
()
+
PersonalCredit
()
connect
:=
dao
.
New
()
_
,
err
:=
connect
.
UpdateStaticSumScores
(
c
,
com_credits
)
_
,
err
:=
svclient
.
UpdateStaticSumScores
(
c
,
com_credits
)
fmt
.
Print
(
err
)
}
//协程增加分值记录
func
InsertRecord
(
c
context
.
Context
)
{
func
InsertRecord
()
{
for
insertScoreMsgRecord
:=
range
socreRecordChan
{
//声明service层
svc
:=
service
.
New
()
//CurrentScore64 := float64(insertScoreMsgRecord.CurrentScore)
//插入数据
//if !math.IsNaN(CurrentScore64) && CurrentScore64 != 0 {
//}
//svc.InsertScores(c,insertScoreMsgRecord)
insertId
,
err
:=
svc
.
InsertScores
(
c
,
insertScoreMsgRecord
)
insertId
,
err
:=
svclient
.
InsertScores
(
conclient
,
insertScoreMsgRecord
)
if
err
!=
nil
{
fmt
.
Print
(
err
)
}
//fmt.Print(err)
fmt
.
Print
(
insertId
)
}
defer
wg
.
Done
()
...
...
@@ -47,13 +36,10 @@ func SetInsertScoreChanFooter(_typy,project_pid,project_id int8) {
}
//获取详细的计算基本数据
func
GetCompanyRunInfo
(
c
context
.
Context
)
{
//声明service层
connect
:=
dao
.
New
()
companyBasicInfo
,
_
=
connect
.
GetCompanyBaseInfoByCid
(
c
,
insertScoreMsg
.
ComCreditsId
)
companySoreFields
,
_
=
connect
.
GetCompanyScoreFieldsByCid
(
c
,
insertScoreMsg
.
ComCreditsId
)
companyAddScore
,
_
=
connect
.
GetCompanyAddSoreByCid
(
c
,
insertScoreMsg
.
ComCreditsId
)
basicInfo
,
_
=
connect
.
GetBasicInfoByCid
(
c
,
insertScoreMsg
.
ComCreditsId
)
func
GetCompanyRunInfo
()
{
companyBasicInfo
,
_
=
svclient
.
GetCompanyBaseInfoByCid
(
conclient
,
insertScoreMsg
.
ComCreditsId
)
companySoreFields
,
_
=
svclient
.
GetCompanyScoreFieldsByCid
(
conclient
,
insertScoreMsg
.
ComCreditsId
)
companyAddScore
,
_
=
svclient
.
GetCompanyAddSoreByCid
(
conclient
,
insertScoreMsg
.
ComCreditsId
)
}
func
GetTimeStamp
()(
timestamp
int64
)
{
...
...
cmd/static/main.go
View file @
f04f6aa4
...
...
@@ -35,12 +35,20 @@ var (
companyAddScore
[]
map
[
string
]
string
//设置等待
wg
sync
.
WaitGroup
//设置svclient
svclient
*
service
.
Service
//content Client
conclient
context
.
Context
)
type
RecvPro
struct
{
}
type
Rabitmq
struct
{
Dsn
string
//rabitmq 配置1
}
func
(
t
*
RecvPro
)
FailAction
([]
byte
)
error
{
fmt
.
Print
(
1
)
panic
(
"implement me"
)
...
...
@@ -78,6 +86,8 @@ func main() {
//获取config
GetConfig
()
svclient
=
service
.
New
()
conclient
=
context
.
Background
()
if
os
.
Args
[
2
]
==
"one"
{
...
...
@@ -85,18 +95,17 @@ func main() {
wg
.
Add
(
1
)
c
:=
context
.
Background
()
go
InsertRecord
(
c
)
go
InsertRecord
()
//调用服务获取公司信息,然后进行全局赋值
svc
:=
service
.
New
()
companyData
,
_
=
svc
.
GetCompanyCresitsList
(
c
)
companyData
,
_
=
svclient
.
GetCompanyCresitsList
(
conclient
)
for
_
,
v
:=
range
companyData
{
insertScoreMsg
.
ComCreditsId
=
StringTurnInt64
(
v
[
"id"
])
GetCompanyRunInfo
(
c
)
SetSumScore
(
c
)
GetCompanyRunInfo
()
basicInfo
,
_
=
svclient
.
GetBasicInfoByCid
(
conclient
,
v
[
"erp_company_code"
])
SetSumScore
(
conclient
)
//break
}
...
...
@@ -108,13 +117,20 @@ func main() {
}
else
{
t
:=
&
RecvPro
{}
var
(
dc
struct
{
Dsn1
*
Rabitmq
// rab配置1
}
)
paladin
.
Get
(
"rabitmq.toml"
)
.
UnmarshalTOML
(
&
dc
)
//读取配置
queueExchange
:=
&
rabbitmq
.
QueueExchange
{
"fengkong_static_count"
,
"fengkong_static_count"
,
"fengkong_exchange"
,
"direct"
,
"amqp://
guest:guest@192.168.2.232:5672
/"
,
"amqp://
"
+
dc
.
Dsn1
.
Dsn
+
"
/"
,
}
for
{
...
...
@@ -146,12 +162,13 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
//设置协程数量
wg
.
Add
(
1
)
c
:
=
context
.
Background
()
go
InsertRecord
(
c
)
c
onclient
=
context
.
Background
()
go
InsertRecord
()
insertScoreMsg
.
ComCreditsId
=
StringTurnInt64
(
rbm
.
ComCreditsId
)
GetCompanyRunInfo
(
c
)
SetSumScore
(
c
)
GetCompanyRunInfo
()
basicInfo
,
_
=
svclient
.
GetBasicInfoByCid
(
conclient
,
rbm
.
ErpCompanyCode
)
SetSumScore
(
conclient
)
//赋值完关闭通道
close
(
socreRecordChan
)
...
...
internal/dao/add_score.go
View file @
f04f6aa4
...
...
@@ -18,7 +18,7 @@ func (d *dao) GetCompanyAddSoreByCid(c context.Context, companyId int64) (res []
return
}
defer
d
.
db
.
Close
()
defer
rows
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
...
...
internal/dao/basic_info.go
View file @
f04f6aa4
...
...
@@ -8,17 +8,17 @@ import (
)
//通过UID获取用户信息
func
(
d
*
dao
)
GetBasicInfoByCid
(
c
context
.
Context
,
companyId
int64
)
(
res
map
[
string
]
string
,
err
error
)
{
func
(
d
*
dao
)
GetBasicInfoByCid
(
c
context
.
Context
,
erp_company_code
string
)
(
res
map
[
string
]
string
,
err
error
)
{
var
(
rows
*
sql
.
Rows
)
if
rows
,
err
=
d
.
db
.
Query
(
c
,
"select "
+
SqlField
+
" from lie_basic_info where
com_credits_id = ?"
,
companyId
);
err
!=
nil
{
if
rows
,
err
=
d
.
db
.
Query
(
c
,
"select "
+
SqlField
+
" from lie_basic_info where
erp_company_code = ?"
,
erp_company_code
);
err
!=
nil
{
err
=
errors
.
WithStack
(
err
)
return
}
defer
d
.
db
.
Close
()
defer
rows
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
...
...
internal/dao/com_basicinfos.go
View file @
f04f6aa4
...
...
@@ -49,6 +49,7 @@ func (d *dao) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res m
func
(
d
*
dao
)
UpdateCompanyBaseInfoForTyc
(
c
context
.
Context
,
updateInfo
map
[
string
]
string
)
(
res
int64
)
{
var
(
execSql
string
rows
*
sql
.
Rows
)
execSql
=
"update `lie_com_basicinfos` set `customer_property` = ?, `establishment_time` = ?, `five_legal_change` = ?, `registered_capital` = ?, `social_security_participants` = ?, `two_years_no_lawsuit` = ? , `tyc_select_num` = ? , `tianyancha_json` = ? where com_credits_id = ? "
row
,
err
:=
d
.
db
.
Exec
(
c
,
execSql
,
updateInfo
[
"customer_property"
],
updateInfo
[
"establishment_time"
],
updateInfo
[
"five_legal_change"
],
updateInfo
[
"registered_capital"
],
updateInfo
[
"social_security_participants"
],
updateInfo
[
"two_years_no_lawsuit"
],
updateInfo
[
"tyc_select_num"
],
updateInfo
[
"tianyancha_json"
],
updateInfo
[
"com_credits_id"
])
...
...
@@ -56,6 +57,8 @@ func (d *dao)UpdateCompanyBaseInfoForTyc(c context.Context,updateInfo map[string
log
.
Error
(
"updateScoresdb.DemoExec.Exec(%s) error(%v)"
,
execSql
,
err
)
}
defer
rows
.
Close
()
affectNum
,
err
:=
row
.
RowsAffected
()
return
affectNum
...
...
internal/dao/com_credits.go
View file @
f04f6aa4
...
...
@@ -20,7 +20,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin
return
}
defer
d
.
db
.
Close
()
defer
rows
.
Close
()
if
err
!=
nil
{
fmt
.
Println
(
"select fail,err:"
,
err
)
...
...
@@ -47,8 +47,6 @@ func (d *dao) UpdateStaticSumScores(ctx context.Context,com_credits model.ComCre
row
.
RowsAffected
()
defer
d
.
db
.
Close
()
return
}
...
...
@@ -90,6 +88,8 @@ func (d *dao)UpdateComCredits(ctx context.Context,com_credits model.ComCredits)(
return
}
defer
rows
.
Close
()
twoMap
,
err
:=
GetAllParam
(
rows
)
for
_
,
v
:=
range
twoMap
{
...
...
@@ -130,6 +130,7 @@ func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]strin
return
}
twoMap
,
err
:=
GetAllParam
(
rows
)
for
_
,
v
:=
range
twoMap
{
...
...
internal/dao/credit_score_fields.go
View file @
f04f6aa4
...
...
@@ -34,7 +34,6 @@ func (d *dao) GetCompanyScoreFieldsByCid(c context.Context, companyId int64) (re
res
=
v
break
}
defer
d
.
db
.
Close
()
return
}
\ No newline at end of file
internal/dao/dao.go
View file @
f04f6aa4
...
...
@@ -30,7 +30,7 @@ type (
InsertScores
(
ctx
context
.
Context
,
score
model
.
Scores
)
(
insertId
int64
,
err
error
)
GetCompanyBaseInfoByCid
(
c
context
.
Context
,
companyId
int64
)
(
r
map
[
string
]
string
,
err
error
)
GetCompanyScoreFieldsByCid
(
c
context
.
Context
,
companyId
int64
)
(
r
map
[
string
]
string
,
err
error
)
GetBasicInfoByCid
(
c
context
.
Context
,
companyId
int64
)
(
r
map
[
string
]
string
,
err
error
)
GetBasicInfoByCid
(
c
context
.
Context
,
erpCompanyCode
string
)
(
r
map
[
string
]
string
,
err
error
)
GetCompanyAddSoreByCid
(
c
context
.
Context
,
companyId
int64
)
(
r
[]
map
[
string
]
string
,
err
error
)
GetCompanyModelByProjectid
(
c
context
.
Context
,
companyId
int64
)
(
r
map
[
string
]
string
,
err
error
)
GetModelTopsetByProjectId
(
c
context
.
Context
,
companyId
int64
)
(
r
map
[
string
]
string
,
err
error
)
...
...
internal/logic/common.go
View file @
f04f6aa4
...
...
@@ -10,10 +10,7 @@ import (
"encoding/csv"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"hash/crc32"
"html"
"io"
...
...
@@ -2239,24 +2236,6 @@ func Ternary(condition bool, trueVal, falseVal interface{}) interface{} {
}
//获取配置参数
func
GetConfig
()
{
//获取输入参数
flag
.
Parse
()
if
err
:=
paladin
.
Init
();
err
!=
nil
{
panic
(
err
)
}
//初始化日志目录
SetLog
(
"kaopuserver start"
,
0
)
}
func
SetLog
(
k
string
,
v
interface
{}){
//初始化日志目录
log
.
Init
(
&
log
.
Config
{
Dir
:
"logs"
})
defer
log
.
Close
()
log
.
Info
(
k
,
v
)
}
func
StringTurnInt64
(
val
string
)
(
int64
)
{
intval
,
_
:=
strconv
.
ParseInt
(
val
,
10
,
64
)
return
intval
...
...
internal/service/service.go
View file @
f04f6aa4
...
...
@@ -89,10 +89,10 @@ func (s *Service) GetCompanyScoreFieldsByCid(c context.Context, companyId int64)
}
// 获取公司历史信息
func
(
s
*
Service
)
GetBasicInfoByCid
(
c
context
.
Context
,
companyId
int64
)
(
res
map
[
string
]
string
,
err
error
)
{
func
(
s
*
Service
)
GetBasicInfoByCid
(
c
context
.
Context
,
erpCompanyCode
string
)
(
res
map
[
string
]
string
,
err
error
)
{
//调用DB方法,获取会员数据
res
,
err
=
s
.
dao
.
GetBasicInfoByCid
(
c
,
companyId
)
res
,
err
=
s
.
dao
.
GetBasicInfoByCid
(
c
,
erpCompanyCode
)
fmt
.
Print
(
err
)
return
}
...
...
@@ -130,8 +130,15 @@ func (s *Service) InsertScores(c context.Context,score model.Scores) (res int64,
//调用DB方法,获取会员数据
res
,
err
=
s
.
dao
.
InsertScores
(
c
,
score
)
defer
s
.
dao
.
Close
()
//fmt.Print(err)
fmt
.
Print
(
err
)
return
}
func
(
s
*
Service
)
GetCompanyAddSoreByCid
(
c
context
.
Context
,
companyId
int64
)
(
res
[]
map
[
string
]
string
,
err
error
){
//调用DB方法,获取会员数据
res
,
err
=
s
.
dao
.
GetCompanyAddSoreByCid
(
c
,
companyId
)
fmt
.
Print
(
err
)
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