Commit 864da239 by huangchengyi

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

# Conflicts:
#	logs/info.log
parents 66e1fb92 f0337fa7
package main
var(
currentScore float32
totalScore float32
)
//公司信息计算
func CompanyInfo() {
totalScore = 0
EstablishmentTime()
CompanyNature()
ChangeslegalInFiveYears()
......@@ -10,51 +22,134 @@ func CompanyInfo() {
AnnualTaxRate()
lawsuitsInPastTwoYars()
NumberOfSocial()
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = totalScore,totalScore,totalScore
insertScoreMsg.Weight = 50
setInserScoreChanFooter(1,0,1)
}
//成立时间(1分)
//成立时间(1分) 大于五年1分,小于零分
func EstablishmentTime() {
setInserScoreHeader(1,1,8)
insertScoreMsg.TotalScore = 5
insertScoreMsg.FinalScore = 5
insertScoreMsg.CurrentScore = 2
insertScoreMsg.Weight = 50
insertScoreMsg.ComCreditsId = 2
socreRecordChan <- insertScoreMsg
establishment_time := stringTurnInt64(companyBasicInfo["establishment_time"])
diffTime := getTimeStamp() - establishment_time
//两年以上有分
if diffTime > (3600 * 24 * 365 * 5) {
currentScore = 1
} else {
currentScore = 0
}
totalScore += currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInserScoreChanFooter(1,1,8)
}
//公司性质(1分)
//公司性质(1分)上,国,央,一分,其它零分
func CompanyNature() {
setInserScoreHeader(1,1,9)
customer_property := stringTurnInt64(companyBasicInfo["customer_property"])
if customer_property == 0 {
currentScore = 0
}else{
currentScore = 1
}
totalScore += currentScore
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.TotalScore,insertScoreMsg.CurrentScore = currentScore,currentScore,currentScore
insertScoreMsg.Weight = 50
setInserScoreChanFooter(1,1,9)
}
//5年内法人变更次数(1分)
func ChangeslegalInFiveYears() {
five_legal_change := stringTurnInt64(companyBasicInfo["five_legal_change"])
//两次以上0分,以下一分
if five_legal_change < 2 {
currentScore = 1
}else{
currentScore = 0
}
totalScore += currentScore
setInserScoreChanFooter(1,1,10)
}
//注册资本(2分)
func RegisteredCapital() {
registered_capital := stringTurnInt64(companyBasicInfo["registered_capital"])
if registered_capital < 500000 {
currentScore = 0
}else if registered_capital > 2000000 {
currentScore = 2
}else{
currentScore = 1
}
totalScore += currentScore
setInserScoreChanFooter(1,1,11)
}
//年纳税额(2分)
func AnnualTaxRate() {
year_tax_payable := stringTurnFloat64(companyBasicInfo["year_tax_payable"])
if year_tax_payable < 20000 {
currentScore = 0
}else if year_tax_payable > 50000{
currentScore = 2
}else{
currentScore = 1
}
totalScore += currentScore
setInserScoreChanFooter(1,1,12)
}
//近两年内有无诉讼(2分)
func lawsuitsInPastTwoYars() {
two_years_no_lawsuit := stringTurnInt64(companyBasicInfo["two_years_no_lawsuit"])
if two_years_no_lawsuit == 1 {
currentScore = 0
}else{
currentScore = 2
}
totalScore += currentScore
setInserScoreChanFooter(1,1,13)
}
//社保参保人数(1分)
func NumberOfSocial() {
social_security_participants := stringTurnInt64(companyBasicInfo["social_security_participants"])
if social_security_participants > 5 {
currentScore = 1
}else{
currentScore = 0
}
totalScore += currentScore
setInserScoreChanFooter(1,1,14)
}
......@@ -9,17 +9,22 @@ import (
"kaopu-server/internal/dao"
"kaopu-server/internal/model"
"kaopu-server/internal/service"
"strconv"
"time"
)
var (
//获取的公司信息
companyData []map[string]interface{}
companyData []map[string]string
//插入分值的通道,限制一千,超过等待
socreRecordChan = make(chan model.Scores, 1000)
//分数的数据
insertScoreMsg model.Scores
//公司的详细数据
companyBasicInfo map[string]string
isOver = make(chan int)
)
......@@ -35,18 +40,24 @@ func main() {
//调用服务获取公司信息,然后进行全局赋值
companyData,_ = svc.GetCompanyCresitsList(ctx)
CompanyInfo()
//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)
for _,v :=range companyData{
insertScoreMsg.ComCreditsId = stringTurnInt64(v["id"])
companyBasicInfo,_ = svc.GetCompanyBaseInfoByCid(ctx,insertScoreMsg.ComCreditsId)
CompanyInfo()
//EnterPriseCredit()
//HistoryBussiness()
//PersonalCredit()
//AddScore()
}
// 判断所有协程是否退出
for range isOver {
close(isOver)
}
}
......@@ -67,10 +78,10 @@ func getConfig() {
//协程增加分值记录
func insertRecord() {
//声明service层
connect := dao.New()
ctx := context.Background()
for {
//声明service层
connect := dao.New()
ctx := context.Background()
// 从通道中拿出消息
insertScoreMsg := <- socreRecordChan
insertId,err := connect.InsertScores(ctx,insertScoreMsg)
......@@ -78,11 +89,26 @@ func insertRecord() {
fmt.Print(insertId)
//插入数据
}
isOver <- 1
}
//设置插入的分数头
func setInserScoreHeader(_typy,project_pid,project_id int8) {
insertScoreMsg.Type = _typy
insertScoreMsg.ProjectPid = project_pid
insertScoreMsg.ProjectId = project_id
func setInserScoreChanFooter(_typy,project_pid,project_id int8) {
insertScoreMsg.Type,insertScoreMsg.ProjectPid,insertScoreMsg.ProjectId = _typy,project_pid,project_id
socreRecordChan <- insertScoreMsg
}
func getTimeStamp()(timestamp int64) {
return time.Now().Unix()
}
func stringTurnInt64(val string) (int64) {
intval,_ := strconv.ParseInt(val, 10, 64)
return intval
}
func stringTurnFloat64(val string)(float64) {
floatval,_ := strconv.ParseFloat(val, 64)
return floatval
}
\ No newline at end of file
package dao
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/bilibili/kratos/pkg/database/sql"
)
//通过UID获取用户信息
func (d *dao) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res map[string]string, err error) {
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_com_basicinfos where com_credits_id = ?",companyId); err != nil {
err = errors.WithStack(err)
return
}
defer rows.Close()
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
for _,v:=range twoMap{
res = v
break
}
return
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import (
)
//列表方式获取会员信息
func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]interface{}, err error) {
func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]string, err error) {
var (
rows *sql.Rows
)
......@@ -24,7 +24,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]inter
return
}
return getAllParam(rows)
return GetAllParam(rows)
}
......
......@@ -12,7 +12,7 @@ var(
)
//根据指针行获取所有的参数
func getAllParam(rows *sql.Rows)(res []map[string]interface{}, err error) {
func GetAllParam(rows *sql.Rows)(res []map[string]string, err error) {
cols,err := rows.Columns()
if err != nil{
fmt.Println("get columns fail,err:",err)
......@@ -20,13 +20,14 @@ func getAllParam(rows *sql.Rows)(res []map[string]interface{}, err error) {
}
vals := make([][]byte, len(cols))
scans := make([]interface{},len(cols))
for i := range vals{
scans[i] = &vals[i]
}
row := make(map[string]interface{})
row := make(map[string]string)
for rows.Next(){
err = rows.Scan(scans...)
......@@ -37,7 +38,7 @@ func getAllParam(rows *sql.Rows)(res []map[string]interface{}, err error) {
for k,v:=range vals{
key := cols[k]
row[key] = v
row[key] = string(v)
}
res = append(res,row)
}
......
......@@ -21,9 +21,9 @@ type (
GetUserList(ctx context.Context) (r []*model.Users, err error)
//---静态开始
GetCompanyCresitsList(ctx context.Context) (r []map[string]interface{}, err error)
GetCompanyCresitsList(ctx context.Context) (r []map[string]string, err error)
InsertScores(ctx context.Context, score model.Scores) (insertId int64, err error)
GetCompanyBaseInfoByCid(c context.Context, companyId int64) (r map[string]string, err error)
//---静态结束
CountYuqi(ctx context.Context,project_id int) (r []map[string]interface{},err error) //计算逾期
......
......@@ -2,18 +2,17 @@ package dao
import (
"context"
"fmt"
"kaopu-server/internal/model"
"github.com/bilibili/kratos/pkg/log"
"kaopu-server/internal/model"
"time"
)
//增加记录
func (d *dao) InsertScores(ctx context.Context,score model.Scores) (insertId int64,err error) {
insertSql := "INSERT INTO `lie_scores` (`type`)VALUES(?)"
insertSql := "INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
row,err := d.db.Exec(ctx,insertSql,1)
fmt.Print(11111)
row,err := d.db.Exec(ctx,insertSql,score.Type,score.ProjectPid,score.ProjectId,score.TotalScore,score.CurrentScore,score.Weight,score.FinalScore,score.ComCreditsId,time.Now().Unix())
if err != nil {
log.Error("db.DemoExec.Exec(%s) error(%v)", insertSql, err)
......
......@@ -20,6 +20,10 @@ type ComCreditsBasicInfos struct {
ComContact string `json:"com_contact"` //'企业联系人'
ContactFixTelephone string `json:"contact_fix_telephone"` //'企业联系人固定电话'
ContactMobilePhone string `json:"contact_mobile_phone"` //'企业联系人移动电话'
FiveLegalChange int8 `json:"five_legal_change"`
YearTaxPayable float64 `json:"year_tax_payable"`
TwoYearsnoLawsuit int8 `json:"two_years_no_lawsuit"`
SocialSecurityParticiPant int16 `json:"social_security_participants"`
CreateTime int64 `json:"create_time"` //'创建时间'
UpdateTime int64 `json:"update_time"` //'更新时间'
}
......@@ -34,7 +38,7 @@ type ComCreditsBasicInfos struct {
`establishment_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '公司成立时间',
`com_leader` varchar(60) NOT NULL DEFAULT '' COMMENT '公司负责人',
`registered_capital` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '注册资本',
`customer_property` varchar(50) NOT NULL DEFAULT '' COMMENT '客户性质',
`customer_property` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '客户性质 0 其它 1上市 2国企 3央企',
`score_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '评分时间',
`com_address` varchar(100) NOT NULL DEFAULT '' COMMENT '公司地址',
`legal_representative` varchar(50) NOT NULL DEFAULT '' COMMENT '法定代表人',
......@@ -46,6 +50,10 @@ type ComCreditsBasicInfos struct {
`com_contact` varchar(50) NOT NULL DEFAULT '' COMMENT '企业联系人',
`contact_fix_telephone` varchar(15) NOT NULL DEFAULT '' COMMENT '企业联系人',
`contact_mobile_phone` char(11) NOT NULL DEFAULT '' COMMENT '企业联系人移动电话',
`five_legal_change` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '5年内法人变更次数',
`year_tax_payable` decimal(14,4) unsigned NOT NULL DEFAULT '0.0000' COMMENT '年纳税额',
`two_years_no_lawsuit` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '近两年内有无诉讼 1有 ',
`social_security_participants` smallint(10) unsigned NOT NULL DEFAULT '0' COMMENT '社保参保人数',
`create_time` int(11) unsigned NOT NULL DEFAULT '0',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
......
......@@ -62,23 +62,22 @@ 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) {
func (s *Service) GetCompanyCresitsList(c context.Context) (res []map[string]string, err error) {
//调用DB方法,获取会员数据
res, err = s.dao.GetCompanyCresitsList(ctx)
res, err = s.dao.GetCompanyCresitsList(c)
fmt.Print(err)
return
}
//插入分数记录
func (s *Service) InsertScores(ctx context.Context,score model.Scores) (insertId int64, err error) {
// 获取公司用户列表
func (s *Service) GetCompanyBaseInfoByCid(c context.Context, companyId int64) (res map[string]string, 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
}
res, err = s.dao.GetCompanyBaseInfoByCid(c,companyId)
fmt.Print(err)
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