Commit b55457a9 by Joneq

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

parents a02143e8 6395abcf
......@@ -22,9 +22,7 @@ func main() {
if err := paladin.Init(); err != nil {
panic(err)
}
model_dong := dao.Model_dong
mod_name := dao.Model_dong[mod]
mod_name_log := dao.Model_dong_log[mod]
model_dong := dao.Model_dong //所有动态模型算法列表
_ ,ok := model_dong[mod]
if !ok {
......@@ -44,7 +42,8 @@ func main() {
for k,_ := range model_dong{
// 开启协程
wg.Add(1)
go func(k int,ctx context.Context) {
go func(k int,ctx context.Context,mod_name string,mod_name_log string) {
fmt.Println("--开始协程:"+strconv.Itoa(k))
logic.Loginfo("统计开始--"+mod_name,mod_name_log);
......@@ -55,7 +54,7 @@ func main() {
logic.Loginfo("统计结束--"+mod_name,mod_name_log);
defer wg.Add(-1)
}(k,ctx)
}(k,ctx,dao.Model_dong[k],dao.Model_dong_log[k])
}
wg.Wait()
......
......@@ -37,10 +37,14 @@ type (
//---动态开始
DongMain(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) //动态模型调用主函数
DongYuqiRate(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//计算逾期率
DongYuqiBi(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//计算逾期笔数率
//CountYuqiRate(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) //计算逾期率
//CountYuqiBi(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) //计算逾期笔数率
DongYuqiRate(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//1 计算逾期金额率
DongYuqiBi(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//2 发生逾期笔数率
DongYuqiDivDay(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//3 平均逾期支付时间
DongDivPayDay(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//4 平均付款时间
DongNormalPayRate(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//5 正常收款金额率
DongNormalPayBi(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//6 正常收款笔数率
DongInTimeRate(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//8 交货及时率
DongReturnRate(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int ) (zhi float64,fen float64,err error)//9 退货率
//---动态结束
}
)
......
......@@ -21,31 +21,26 @@ var Model_dong = map[int]string{
36:"发生逾期笔数率",
37:"平均逾期支付时间(天)",
38:"平均付款时间(天)",
39:"正常收款笔数率",
40:"近6个月账期变化率",
41:"交货及时率",
42:"退货率",
43:"近6个月逾期变化率",
44:"近6个月参保人数变化率",
39:"正常收款金额率",
40:"正常收款笔数率",
41:"近6个月账期变化率",
42:"交货及时率",
43:"退货率",
44:"近6个月逾期变化率",
45:"近6个月参保人数变化率",
}
//动态模型对应的日志文件名称
var Model_dong_log = map[int]string{
35:"_yuqilv",
36:"_yuqibi",
37:"",
38:"",
39:"",
40:"",
41:"",
42:"",
43:"",
44:"",
}
//动态模型对应梯度单位
var Model_dong_unit = map[int]float64{
35: 0.01, //百分比 等于乘以 0.01
36: 0.01,
35:"_yuqi_rate",
36:"_yuqi_bi",
37:"_yuqi_div_day",
38:"_div_pay_day",
39:"_normal_pay_rate",
40:"_normal_pay_bi",
41:"_six_month",
42:"_in_time_rate",
43:"_return_rate",
44:"_shebao_rate",
}
......@@ -94,10 +89,22 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
if v["erp_company_code"] != "" {
//调用公共动态算法去查对应得分
switch project_id{
case 35:
zhi,score_one,err = d.DongYuqiRate(ctx,v,modelItems,project_id)
case 36:
zhi,score_one,err = d.DongYuqiRate(ctx,v,modelItems,project_id)
case 35: //逾期金额率
zhi,score_one,_ = d.DongYuqiRate(ctx,v,modelItems,project_id)
case 36: //发生逾期笔数率
zhi,score_one,_ = d.DongYuqiBi(ctx,v,modelItems,project_id)
case 37: //平均逾期支付时间
zhi,score_one,_ = d.DongYuqiDivDay(ctx,v,modelItems,project_id)
case 38: //平均付款时间
zhi,score_one,_ = d.DongDivPayDay(ctx,v,modelItems,project_id)
case 39: //正常收款金额率
zhi,score_one,_ = d.DongNormalPayRate(ctx,v,modelItems,project_id)
case 40: //正常收款笔数率
zhi,score_one,_ = d.DongNormalPayBi(ctx,v,modelItems,project_id)
case 42: //交货及时率
zhi,score_one,_ = d.DongInTimeRate(ctx,v,modelItems,project_id)
case 43: //退货率
zhi,score_one,_ = d.DongReturnRate(ctx,v,modelItems,project_id)
default:
continue;
}
......@@ -106,9 +113,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
fmt.Print(mod_name+"不存在对应梯度,erp_company_code:"+v["erp_company_code"]+" zhi:"+logic.MyFloat64ToStr(zhi)+"\r\n")
continue;
}
//拼接最终得分,权重*单位*分数
final_score = weight*Model_dong_unit[project_id]*score_one
//计算得到的分数插入分数明细表
var scores model.Scores //插入分数结构体
scores.Type=2;
scores.ProjectPid = logic.MyInt8(yuqilv_project["pid"]);
......@@ -116,7 +121,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
scores.TotalScore = score_one;
scores.CurrentScore = score_one;
scores.Weight= weight;
scores.FinalScore = final_score;
scores.FinalScore = weight*score_one; //权重乘以单位
scores.ComCreditsId = logic.MyInt64(v["id"]);
insertid,err := d.InsertScores(ctx,scores)
......@@ -125,7 +130,7 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
fmt.Print("错误:"+err.Error(),insertid)
}
log1 := "统计"+mod_name+"成功--公司编码:"+v["erp_company_code"]+"计算得分:"+logic.MyFloat64ToStr(score_one)+" 最终得分:"+logic.MyFloat64ToStr(final_score);
log1 := "统计"+mod_name+"成功--公司编码:"+v["erp_company_code"]+"计算得分:"+logic.MyFloat64ToStr(weight*score_one)+" 最终得分:"+logic.MyFloat64ToStr(final_score);
fmt.Print(log1)
logic.Loginfo(log1,log_pre)
}
......
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