Commit 46601ca6 by huangchengyi

Merge branch 'dev' of http://119.23.72.7/sunlong_v5/kaopu-server into dev

# Conflicts:
#	internal/dao/dao.go
#	logs/info.log
parents 349bc9ab 90dc6642
package main
import "fmt"
//公司信息计算
func CompanyInfo() {
fmt.Print(companyData)
EstablishmentTime()
CompanyNature()
ChangeslegalInFiveYears()
......@@ -17,12 +15,20 @@ func CompanyInfo() {
//成立时间(1分)
func EstablishmentTime() {
setInserScoreHeader(1,1,8)
insertScoreMsg.TotalScore = 5
insertScoreMsg.FinalScore = 5
insertScoreMsg.CurrentScore = 2
insertScoreMsg.Weight = 50
insertScoreMsg.ComCreditsId = 2
socreRecordChan <- insertScoreMsg
}
//公司性质(1分)
func CompanyNature() {
setInserScoreHeader(1,1,9)
}
//5年内法人变更次数(1分)
......
......@@ -3,18 +3,23 @@ package main
import (
"context"
"flag"
"fmt"
"github.com/bilibili/kratos/pkg/conf/paladin"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/dao"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
"time"
)
var (
//获取的公司信息
companyData []map[string]interface{}
//插入分值的通道
socreRecord = make(chan model.Scores, 1000)
//插入分值的通道,限制一千,超过等待
socreRecordChan = make(chan model.Scores, 1000)
//分数的数据
insertScoreMsg model.Scores
)
......@@ -24,19 +29,24 @@ func main() {
getConfig()
//声明service层
go insertRecord()
svc := service.New()
ctx := context.Background()
go insertRecord()
//调用服务获取公司信息,然后进行全局赋值
companyData,_ = svc.GetCompanyCresitsList(ctx)
AddScore()
CompanyInfo()
EnterPriseCredit()
HistoryBussiness()
PersonalCredit()
//insertId,err := svc.InsertScores(ctx,insertScoreMsg)
//fmt.Print(err)
//fmt.Print(insertId)
//fmt.Print(companyData)
//EnterPriseCredit()
//HistoryBussiness()
//PersonalCredit()
//AddScore()
//延迟100秒用来执行协程的错误返回
time.Sleep(100000 * time.Millisecond)
}
......@@ -56,12 +66,23 @@ func getConfig() {
//协程增加分值记录
func insertRecord() {
for {
//声明service层
connect := dao.New()
ctx := context.Background()
for {
// 从通道中拿出消息
insertRecord := <-socreRecord
insertScoreMsg := <- socreRecordChan
insertId,err := connect.InsertScores(ctx,insertScoreMsg)
fmt.Print(err)
fmt.Print(insertId)
//插入数据
}
}
//设置插入的分数头
func setInserScoreHeader(_typy,project_pid,project_id int8) {
insertScoreMsg.Type = _typy
insertScoreMsg.ProjectPid = project_pid
insertScoreMsg.ProjectId = project_id
}
\ No newline at end of file
......@@ -12,15 +12,23 @@ import (
xtime "github.com/bilibili/kratos/pkg/time"
)
// Dao dao interface
type Dao interface {
type (
// Dao dao interface
Dao interface {
Close()
Ping(ctx context.Context) (err error)
GetUserInfoByUserId(ctx context.Context,user_id int64) (r *model.Users,err error)
GetUserList(ctx context.Context) (r []*model.Users,err error)
GetCompanyCresitsList(ctx context.Context) (r []map[string]interface{},err error)
GetUserInfoByUserId(ctx context.Context, user_id int64) (r *model.Users, err error)
GetUserList(ctx context.Context) (r []*model.Users, err error)
//---静态开始
GetCompanyCresitsList(ctx context.Context) (r []map[string]interface{}, err error)
InsertScores(ctx context.Context, score model.Scores) (insertId int64, err error)
//---静态结束
CountYuqi(ctx context.Context,project_id int) (r []map[string]interface{},err error) //计算逾期
}
}
)
// dao dao.
type dao struct {
......@@ -31,6 +39,7 @@ type dao struct {
mcExpire int32
}
func checkErr(err error) {
if err != nil {
panic(err)
......
......@@ -4,18 +4,23 @@ import (
"context"
"fmt"
"kaopu-server/internal/model"
"github.com/bilibili/kratos/pkg/log"
)
//增加记录
func (d *dao) insert(ctx context.Context,score *model.Scores) (int64, error) {
func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int64,err error) {
stmt,_:= d.db.Prepare("INSERT INTO chat_list (roomstr, urid,srid) VALUES (?,?,?)")
insertSql := "INSERT INTO `lie_scores` (`type`)VALUES(?)"
var row, err = stmt.Exec(ctx,score.CreateTime,score.CurrentScore)
if err != nil{
fmt.Println("select fail,err:",err)
row,err := d.db.Exec(ctx,insertSql,1)
fmt.Print(11111)
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", insertSql, err)
return
}
row.LastInsertId()
defer d.db.Close()
return row.LastInsertId()
return
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ type Scores struct {
TotalScore float32 `json:"total_score"`
CurrentScore float32 `json:"current_score"`
Weight float32 `json:"weight"`
FinalScore float64 `json:"final_score"`
FinalScore float32 `json:"final_score"`
ComCreditsId int64 `json:"com_credits_id"`
CreateTime int64 `json:"create_time"`
UpdateTime int64 `json:"update_time"`
......
......@@ -59,7 +59,9 @@ func (s *Service) GetUserList(ctx context.Context) (res []*model.Users, err erro
}
//获取用户列表
//----------静态开始
// 获取公司用户列表
func (s *Service) GetCompanyCresitsList(ctx context.Context) (res []map[string]interface{}, err error) {
//调用DB方法,获取会员数据
......@@ -67,3 +69,16 @@ func (s *Service) GetCompanyCresitsList(ctx context.Context) (res []map[string]i
fmt.Print(err)
return
}
//插入分数记录
func (s *Service) InsertScores(ctx context.Context,score model.Scores) (insertId int64, err error) {
//调用DB方法,获取会员数据
insertId,err = s.dao.InsertScores(ctx,score)
if err != nil {
panic(err.Error()) // proper error handling instead of panic in your app
}
return
}
//----------静态结束
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment