Commit e2cb1e13 by huangchengyi

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

# Conflicts:
#	go.mod
parents 478129dd e8618a1f
......@@ -71,20 +71,38 @@ func StringTurnFloat64(val string)(float64) {
return floatval
}
//获取项目详情
func getModelByProjectId(projectId int64)(modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetCompanyModelByProjectid(ctx,1)
res,_ := connect.GetCompanyModelByProjectid(ctx,projectId)
return res
}
//获取顶头详情
func GetModelTopsetByProjectId(projectId int64)(modelInfo map[string]string) {
ctx := context.Background()
connect := dao.New()
res,_ := connect.GetModelTopsetByProjectId(ctx,projectId)
return res
}
//设置分数
func setScore(curretScoreRelace float64,weightReplace float64) {
func SetScore(curretScoreRelace float64,modelId int64)(fimalScore float64) {
modelInfo := getModelByProjectId(modelId)
weightReplace := StringTurnFloat64(modelInfo["weight"])
if curretScoreRelace > StringTurnFloat64(modelInfo["full_score"]) {
curretScoreRelace = StringTurnFloat64(modelInfo["full_score"])
}
insertScoreMsg.TotalScore = curretScoreRelace
//设置分数
insertScoreMsg.FinalScore ,insertScoreMsg.CurrentScore = curretScoreRelace * weightReplace,curretScoreRelace * weightReplace
insertScoreMsg.Weight = weightReplace
return insertScoreMsg.FinalScore
}
//设置project总分
......@@ -98,15 +116,15 @@ func SetProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullS
for i :=0;i < len(totalScoreReplace) ; i++ {
if totalScoreReplace[i] > 0 {
joinNum += 1
sumScore += totalScoreReplace[i] * weightReplace
sumScore += totalScoreReplace[i]
}
}
insertScoreMsg.CurrentScore = sumScore
insertScoreMsg.CurrentScore,insertScoreMsg.TotalScore = sumScore,sumScore
//如果是0则不判断了
if sumScore == 0 {
insertScoreMsg.TotalScore,insertScoreMsg.FinalScore = 0,0
insertScoreMsg.FinalScore = 0
}else{
//如果最后金额大于满分,则算为最满分
if sumScore > fullScore {
......@@ -115,7 +133,7 @@ func SetProjectScore(totalScoreReplace [20]float64, weightReplace float64, fullS
insertScoreMsg.TotalScore = sumScore
}
//经过权重计算之后的总分值
insertScoreMsg.FinalScore = sumScore / joinNum
insertScoreMsg.FinalScore = sumScore * weightReplace
}
insertScoreMsg.Weight = weightReplace
......
......@@ -11,9 +11,6 @@ var(
//公司信息计算
func CompanyInfo()(finalScore float64) {
modelInfo := getModelByProjectId(1)
weight = StringTurnFloat64(modelInfo["weight"])
EstablishmentTime()
CompanyNature()
ChangeslegalInFiveYears()
......@@ -22,6 +19,9 @@ func CompanyInfo()(finalScore float64) {
lawsuitsInPastTwoYars()
NumberOfSocial()
modelInfo := GetModelTopsetByProjectId(1)
weight = StringTurnFloat64(modelInfo["weight"])
finalScore = SetProjectScore(c_totalScore,weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,1)
return finalScore
......@@ -41,9 +41,7 @@ func EstablishmentTime() {
c_currentScore = 0
}
c_totalScore[0]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[0]= SetScore(c_currentScore,8)
SetInsertScoreChanFooter(1,1,8)
}
......@@ -59,9 +57,8 @@ func CompanyNature() {
c_currentScore = 1
}
c_totalScore[1]= c_currentScore
c_totalScore[1]= SetScore(c_currentScore,9)
setScore(c_currentScore,weight)
SetInsertScoreChanFooter(1,1,9)
}
......@@ -77,9 +74,7 @@ func ChangeslegalInFiveYears() {
c_currentScore = 0
}
c_totalScore[2]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[2]= SetScore(c_currentScore,10)
SetInsertScoreChanFooter(1,1,10)
}
......@@ -96,9 +91,7 @@ func RegisteredCapital() {
c_currentScore = 1
}
c_totalScore[3]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[3]= SetScore(c_currentScore,11)
SetInsertScoreChanFooter(1,1,11)
}
......@@ -114,9 +107,7 @@ func AnnualTaxRate() {
c_currentScore = 1
}
c_totalScore[4]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[4]= SetScore(c_currentScore,12)
SetInsertScoreChanFooter(1,1,12)
}
......@@ -130,9 +121,7 @@ func lawsuitsInPastTwoYars() {
c_currentScore = 2
}
c_totalScore[5]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[5]= SetScore(c_currentScore,13)
SetInsertScoreChanFooter(1,1,13)
}
......@@ -147,9 +136,7 @@ func NumberOfSocial() {
c_currentScore = 0
}
c_totalScore[6]= c_currentScore
setScore(c_currentScore,weight)
c_totalScore[6]= SetScore(c_currentScore,14)
SetInsertScoreChanFooter(1,1,14)
}
......
......@@ -10,12 +10,11 @@ var(
//企业征信(10分)
func EnterPriseCredit()(finalScore float64) {
modelInfo := getModelByProjectId(2)
e_weight = StringTurnFloat64(modelInfo["weight"])
IsEnterpriseOverdueWhether()
IsHistoryOverdue()
modelInfo := GetModelTopsetByProjectId(2)
e_weight = StringTurnFloat64(modelInfo["weight"])
finalScore = SetProjectScore(e_totalScore,e_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,2)
return finalScore
......@@ -32,8 +31,7 @@ func IsEnterpriseOverdueWhether() {
e_currentScore = 5
}
e_totalScore[0]= e_currentScore
setScore(e_currentScore,e_weight)
e_totalScore[0]= SetScore(c_currentScore,15)
SetInsertScoreChanFooter(1,2,15)
}
......@@ -49,9 +47,7 @@ func IsHistoryOverdue() {
e_currentScore = 5
}
e_totalScore[1]= e_currentScore
setScore(e_currentScore,e_weight)
e_totalScore[1]= SetScore(c_currentScore,16)
SetInsertScoreChanFooter(1,2,16)
}
\ No newline at end of file
......@@ -9,8 +9,7 @@ var(
//历史交易情况(50分)
func HistoryBussiness()(finalScore float64) {
modelInfo := getModelByProjectId(4)
h_weight = StringTurnFloat64(modelInfo["weight"])
CooperationTime()
AccumulatedAmountOfCooperation()
......@@ -19,6 +18,8 @@ func HistoryBussiness()(finalScore float64) {
AverageMoneyThreeMonths()
AverageMoneySixMonths()
modelInfo := GetModelTopsetByProjectId(4)
h_weight = StringTurnFloat64(modelInfo["weight"])
finalScore = SetProjectScore(h_totalScore,h_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,4)
return finalScore
......@@ -42,10 +43,7 @@ func CooperationTime() {
h_currentScore = 0
}
h_totalScore[0]= h_currentScore
//设置分数
setScore(h_currentScore,h_weight)
h_totalScore[0]= SetScore(h_currentScore,29)
SetInsertScoreChanFooter(1,4,29)
}
......@@ -71,10 +69,7 @@ func AccumulatedAmountOfCooperation() {
h_currentScore = 0
}
h_totalScore[1]= h_currentScore
//设置分数
setScore(h_currentScore,h_weight)
h_totalScore[1]= SetScore(h_currentScore,30)
SetInsertScoreChanFooter(1,4,30)
}
......@@ -99,10 +94,7 @@ func AccumulatedGrossProfit() {
h_currentScore = 0
}
h_totalScore[2]= h_currentScore
//设置分数
setScore(h_currentScore,h_weight)
h_totalScore[2]= SetScore(h_currentScore,31)
SetInsertScoreChanFooter(1,4,31)
}
......@@ -120,11 +112,7 @@ func HistoricalOverdueTimes() {
h_currentScore = 0
}
h_totalScore[3]= h_currentScore
//设置分数
setScore(h_currentScore,h_weight)
h_totalScore[3]= SetScore(h_currentScore,32)
SetInsertScoreChanFooter(1,4,32)
}
......@@ -149,10 +137,7 @@ func AverageMoneyThreeMonths() {
h_currentScore = 0
}
h_totalScore[4]= h_currentScore
//设置分数
setScore(h_currentScore,h_weight)
h_totalScore[4]= SetScore(h_currentScore,33)
SetInsertScoreChanFooter(1,4,33)
}
......@@ -178,10 +163,7 @@ func AverageMoneySixMonths() {
h_currentScore = 0
}
h_totalScore[5]= h_currentScore
h_totalScore[5]= SetScore(h_currentScore,34)
//设置分数
setScore(h_currentScore,h_weight)
SetInsertScoreChanFooter(1,4,33)
SetInsertScoreChanFooter(1,4,34)
}
......@@ -41,6 +41,11 @@ type RecvPro struct {
}
func (t *RecvPro) FailAction([]byte) error {
fmt.Print(1)
panic("implement me")
}
type RabbitMsg struct {
ComCreditsId string `json:"com_credits_id"`
ErpCompanyCode string `json:"erp_company_code"`
......
......@@ -10,8 +10,7 @@ var(
//个人征信(30分)
func PersonalCredit()(finalScore float64) {
modelInfo := getModelByProjectId(3)
p_weight = StringTurnFloat64(modelInfo["weight"])
Age()
MaritalStatus()
......@@ -25,6 +24,8 @@ func PersonalCredit()(finalScore float64) {
TotalCreditCardLimit()
MaximumAmountOfSingleCreditCard()
modelInfo := GetModelTopsetByProjectId(3)
p_weight = StringTurnFloat64(modelInfo["weight"])
finalScore = SetProjectScore(p_totalScore,p_weight,StringTurnFloat64(modelInfo["full_score"]))
SetInsertScoreChanFooter(1,0,3)
return finalScore
......@@ -41,10 +42,7 @@ func Age() {
p_currentScore = 0
}
p_totalScore[0]= p_currentScore
setScore(p_currentScore,p_weight)
p_totalScore[0]= SetScore(p_currentScore,17)
SetInsertScoreChanFooter(1,3,17)
}
......@@ -59,10 +57,7 @@ func MaritalStatus() {
p_currentScore = 0
}
p_totalScore[1]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[1]= SetScore(p_currentScore,18)
SetInsertScoreChanFooter(1,3,18)
}
......@@ -78,10 +73,7 @@ func DefaultAccountRatio() {
p_currentScore = 0
}
p_totalScore[2]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[2]= SetScore(p_currentScore,19)
SetInsertScoreChanFooter(1,3,19)
}
......@@ -97,10 +89,7 @@ func ExternalGuarantee() {
p_currentScore = 5
}
p_totalScore[3]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[3]= SetScore(p_currentScore,20)
SetInsertScoreChanFooter(1,3,20)
}
......@@ -116,11 +105,7 @@ func SumBeOverdueMonthTwoYesar() {
p_currentScore = 0
}
p_totalScore[4]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[4]= SetScore(p_currentScore,22)
SetInsertScoreChanFooter(1,3,22)
}
......@@ -139,10 +124,7 @@ func MaxBeOverdueTwoYears() {
p_currentScore = 3
}
p_totalScore[5]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[5]= SetScore(p_currentScore,23)
SetInsertScoreChanFooter(1,3,23)
}
......@@ -160,10 +142,7 @@ func IsBeOverdue() {
}
p_totalScore[6]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[6]= SetScore(p_currentScore,24)
SetInsertScoreChanFooter(1,3,24)
}
......@@ -180,10 +159,7 @@ func IsMortgage() {
p_currentScore = 1
}
p_totalScore[7]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[7]= SetScore(p_currentScore,25)
SetInsertScoreChanFooter(1,3,25)
}
......@@ -207,10 +183,7 @@ func NumberOfCreditInquiryInThePastTwoMonths() {
p_currentScore = 0
}
p_totalScore[8]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[8]= SetScore(p_currentScore,26)
SetInsertScoreChanFooter(1,3,26)
}
......@@ -226,10 +199,7 @@ func TotalCreditCardLimit() {
p_currentScore = 0
}
p_totalScore[9]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[9]= SetScore(p_currentScore,27)
SetInsertScoreChanFooter(1,3,27)
}
......@@ -245,10 +215,7 @@ func MaximumAmountOfSingleCreditCard() {
p_currentScore = 0
}
p_totalScore[10]= p_currentScore
//设置分数
setScore(p_currentScore,p_weight)
p_totalScore[10]= SetScore(p_currentScore,28)
SetInsertScoreChanFooter(1,3,28)
}
......@@ -4,7 +4,7 @@ go 1.12
require (
github.com/bilibili/kratos v0.3.1
github.com/ichunt2019/go-msgserver v0.0.0-20191205082056-967d5dbbe7cd // indirect
github.com/ichunt2019/go-msgserver v0.0.0-20191205082056-967d5dbbe7cd
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/pkg/errors v0.8.1
)
......@@ -92,8 +92,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ichunt2019/go-msgserver v0.0.0-20191204053231-bd327f4f8ff1 h1:UK7gMV/AS+d3p0wFQLXndXyek3FUIYxUZjPTyx4tZ2g=
github.com/ichunt2019/go-msgserver v0.0.0-20191204053231-bd327f4f8ff1/go.mod h1:fWAvbry0W9nhmkqgT2agwRqYCWlguUJXgy2rgoWOUmA=
github.com/ichunt2019/go-msgserver v0.0.0-20191205082056-967d5dbbe7cd h1:H9X0AQdmFig5ywAQiRLaZgOLoGf2NnlbqN8XT34dbp4=
github.com/ichunt2019/go-msgserver v0.0.0-20191205082056-967d5dbbe7cd/go.mod h1:fWAvbry0W9nhmkqgT2agwRqYCWlguUJXgy2rgoWOUmA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
......
......@@ -33,6 +33,7 @@ type (
GetBasicInfoByCid(c context.Context, companyId int64) (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)
UpdateStaticSumScores(c context.Context,com_credits model.ComCredits) (resId int64, err error)
UpdateMoveSumScores(c context.Context,com_credits model.ComCredits) (resId int64, err error)
//---静态结束
......
package dao
import (
"context"
"fmt"
"github.com/pkg/errors"
"github.com/bilibili/kratos/pkg/database/sql"
)
//通过projectId获取该项信息
func (d *dao) GetModelTopsetByProjectId(c context.Context, projectId int64) (res map[string]string, err error) {
var (
rows *sql.Rows
)
if rows, err = d.db.Query(c, "select "+ SqlField + " from lie_model_topset where project_id = ?",projectId); 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
}
package model
//CREATE TABLE `lie_model_topset` (
//`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '模型ID',
//`type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '1静态 2动态 3银行',
//`project_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '项目ID',
//`project_name` varchar(128) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '项目名称',
//`full_score` int(5) unsigned NOT NULL DEFAULT '0' COMMENT '满分分值',
//`weight` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '权重',
//`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态,1-启用,-1-禁用',
//`creator` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT '创建人',
//`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
//`update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
//PRIMARY KEY (`id`),
//UNIQUE KEY `project_id` (`project_id`) USING BTREE,
//KEY `status_time` (`status`,`create_time`) USING BTREE,
//KEY `type_time` (`type`,`create_time`) USING BTREE
//) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COMMENT='模型配置表-一级分类配置';
\ 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