Commit 9608608a by huangchengyi

1.0

parent 6395abcf
...@@ -73,7 +73,7 @@ func (d *dao) QueryOne(ctx context.Context,db int,sql_str string)(res map[string ...@@ -73,7 +73,7 @@ func (d *dao) QueryOne(ctx context.Context,db int,sql_str string)(res map[string
} }
project_rows,err := GetAllParam(rows); project_rows,err := GetAllParam(rows);
if project_rows == nil { if err != nil {
fmt.Println("error1002"+sql_str,err) fmt.Println("error1002"+sql_str,err)
return return
} }
......
...@@ -17,6 +17,7 @@ const ( ...@@ -17,6 +17,7 @@ const (
//项目对应的id //项目对应的id
var Model_dong = map[int]string{ var Model_dong = map[int]string{
0:"所有",
35:"逾期金额率", 35:"逾期金额率",
36:"发生逾期笔数率", 36:"发生逾期笔数率",
37:"平均逾期支付时间(天)", 37:"平均逾期支付时间(天)",
...@@ -43,13 +44,12 @@ var Model_dong_log = map[int]string{ ...@@ -43,13 +44,12 @@ var Model_dong_log = map[int]string{
44:"_shebao_rate", 44:"_shebao_rate",
} }
//计算逾期金额率:延期支付时间超过平均账期的金额/收款总额: //计算逾期金额率:延期支付时间超过平均账期的金额/收款总额:
func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) { func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code string) (r []map[string]interface{},err error) {
var ( var (
final_score,zhi float64 zhi float64 //计算出来的各个动态分数率
score_one float64 =0; //分数 score_one float64 =0; //对应梯度分数
_sql2 string; // _sql2 string; //
mod_name string = Model_dong[project_id] //统计动态模型名称 mod_name string = Model_dong[project_id] //统计动态模型名称
log_pre string = Model_dong_log[project_id] //日志文件名称 log_pre string = Model_dong_log[project_id] //日志文件名称
...@@ -58,7 +58,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin ...@@ -58,7 +58,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
sql_str1 := fmt.Sprintf(_sql1,strconv.Itoa(project_id)) sql_str1 := fmt.Sprintf(_sql1,strconv.Itoa(project_id))
yuqilv_project,err := d.QueryOne(ctx,1,sql_str1) yuqilv_project,err := d.QueryOne(ctx,1,sql_str1)
if yuqilv_project == nil { if yuqilv_project == nil {
logic.Loginfo("不存在该项目配置lie_model ,project_id:"+strconv.Itoa(project_id),log_pre) log3 := "不存在该项目配置lie_model ,project_id:"+strconv.Itoa(project_id)
fmt.Print(log3)
logic.Loginfo(log3,log_pre)
return return
} }
weight,_ := strconv.ParseFloat(yuqilv_project["weight"],64) weight,_ := strconv.ParseFloat(yuqilv_project["weight"],64)
...@@ -67,7 +69,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin ...@@ -67,7 +69,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
sql_str4 := fmt.Sprintf(_sql4,strconv.Itoa(project_id)) sql_str4 := fmt.Sprintf(_sql4,strconv.Itoa(project_id))
modelItems,err := d.QueryMany(ctx,1,sql_str4) modelItems,err := d.QueryMany(ctx,1,sql_str4)
if modelItems == nil { if modelItems == nil {
logic.Loginfo("不存在该项目配置详情lie_model_items,project_id:"+strconv.Itoa(project_id),log_pre) log4 := "不存在该项目配置详情lie_model_items,project_id:"+strconv.Itoa(project_id)
logic.Loginfo(log4,log_pre)
fmt.Print(log4)
return return
} }
...@@ -110,7 +114,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin ...@@ -110,7 +114,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
} }
if score_one == 0 { if score_one == 0 {
fmt.Print(mod_name+"不存在对应梯度,erp_company_code:"+v["erp_company_code"]+" zhi:"+logic.MyFloat64ToStr(zhi)+"\r\n") log1 := "统计"+mod_name+"--跳过,没有分数,公司编码:"+v["erp_company_code"]+" 计算率:"+logic.MyFloat64ToStr(zhi)+"\r\n"
fmt.Print(log1)
logic.Loginfo(log1,log_pre)
continue; continue;
} }
//计算得到的分数插入分数明细表 //计算得到的分数插入分数明细表
...@@ -130,9 +136,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin ...@@ -130,9 +136,9 @@ func (d *dao) DongMain(ctx context.Context,project_id int,erp_company_code strin
fmt.Print("错误:"+err.Error(),insertid) fmt.Print("错误:"+err.Error(),insertid)
} }
log1 := "统计"+mod_name+"成功--公司编码:"+v["erp_company_code"]+"计算得分:"+logic.MyFloat64ToStr(weight*score_one)+" 最终得分:"+logic.MyFloat64ToStr(final_score); log2 := "统计"+mod_name+"--成功,公司编码:"+v["erp_company_code"]+" 计算得分:"+logic.MyFloat64ToStr(score_one)+" 最终得分:"+logic.MyFloat64ToStr(weight*score_one);
fmt.Print(log1) fmt.Print(log2)
logic.Loginfo(log1,log_pre) logic.Loginfo(log2,log_pre)
} }
} }
logic.Loginfo("统计"+mod_name+"完成",log_pre) logic.Loginfo("统计"+mod_name+"完成",log_pre)
......
...@@ -31,19 +31,12 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems [] ...@@ -31,19 +31,12 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
var ( var (
score_one float64 =0; //分数 score_one float64 =0; //分数
mod_name string = Model_dong[project_id] //统计动态模型名称
log_pre string = Model_dong_log[project_id] //日志文件名称
) )
//查询逾期率 //查询逾期率
oneyu,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql3,y["erp_company_code"])) oneyu,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql3,y["erp_company_code"]))
if oneyu["yuqilv"] == "" || oneyu == nil { //没有结果 if oneyu["yuqilv"] == "" || oneyu == nil { //没有结果
log1 := "公司编码:"+y["erp_company_code"]+"逾期金额率为空,跳过";
fmt.Print(log1)
logic.Loginfo("统计--"+mod_name+log1,log_pre)
return return
} }
fmt.Print("\r\n公司编码:"+y["erp_company_code"]+mod_name+"为:"+oneyu["yuqilv"])
//查询逾期率对应分数 //查询逾期率对应分数
yuqilv,_ := strconv.ParseFloat(oneyu["yuqilv"],64) yuqilv,_ := strconv.ParseFloat(oneyu["yuqilv"],64)
for _,y := range modelItems{ for _,y := range modelItems{
...@@ -52,7 +45,6 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems [] ...@@ -52,7 +45,6 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
if (ladder_range_min <= yuqilv && yuqilv < ladder_range_max ) { if (ladder_range_min <= yuqilv && yuqilv < ladder_range_max ) {
score_one = logic.MyFloat64(y["score"]) //得到的分数 score_one = logic.MyFloat64(y["score"]) //得到的分数
} }
//fmt.Print("\r\n\r\n :",ladder_range_min,ladder_range_max,yuqilv)
} }
zhi = yuqilv zhi = yuqilv
fen = score_one fen = score_one
...@@ -63,15 +55,11 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems [] ...@@ -63,15 +55,11 @@ func (d *dao) DongYuqiRate(ctx context.Context,y map[string]string,modelItems []
func (d *dao) DongYuqiBi(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int) (zhi float64,fen float64,err error) { func (d *dao) DongYuqiBi(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int) (zhi float64,fen float64,err error) {
var ( var (
score_one float64 =0; //分数 score_one float64 =0; //分数
mod_name string = Model_dong[project_id] //统计动态模型名称
log_pre string = Model_dong_log[project_id] //日志文件名称
) )
//查询逾期笔数 //查询逾期笔数
yuqibi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql5,y["erp_company_code"])) yuqibi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql5,y["erp_company_code"]))
if yuqibi["yuqibi"] == "0" { //没有结果 if yuqibi["yuqibi"] == "0" { //没有结果
log1 := "公司编码:"+y["erp_company_code"]+"没有逾期笔数,跳过"; return
fmt.Print(log1)
logic.Loginfo("统计--"+mod_name+log1,log_pre)
} }
//收款总笔数 //收款总笔数
allbi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql6,y["erp_company_code"])) allbi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql6,y["erp_company_code"]))
...@@ -95,15 +83,10 @@ func (d *dao) DongYuqiBi(ctx context.Context,y map[string]string,modelItems []ma ...@@ -95,15 +83,10 @@ func (d *dao) DongYuqiBi(ctx context.Context,y map[string]string,modelItems []ma
func (d *dao) DongYuqiDivDay(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int) (zhi float64,fen float64,err error) { func (d *dao) DongYuqiDivDay(ctx context.Context,y map[string]string,modelItems []map[string]string,project_id int) (zhi float64,fen float64,err error) {
var ( var (
score_one float64 =0; //分数 score_one float64 =0; //分数
mod_name string = Model_dong[project_id] //统计动态模型名称
log_pre string = Model_dong_log[project_id] //日志文件名称
) )
//每笔逾期账款的逾期时间合计 //每笔逾期账款的逾期时间合计
yuqibi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql8,y["erp_company_code"])) yuqibi,_ := d.QueryOne(ctx,2,fmt.Sprintf(_sql8,y["erp_company_code"]))
if yuqibi["sum_delay_day"] == "0" { //没有结果 if yuqibi["sum_delay_day"] == "0" { //没有结果
log1 := "公司编码:"+y["erp_company_code"]+"每笔逾期账款的逾期时间合计为0,跳过";
fmt.Print(log1)
logic.Loginfo("统计--"+mod_name+log1,log_pre)
return return
} }
//发生逾期总笔数 //发生逾期总笔数
......
...@@ -4,7 +4,6 @@ import ( ...@@ -4,7 +4,6 @@ import (
"io" "io"
"os" "os"
"time" "time"
"fmt"
) )
func check(e error) { func check(e error) {
...@@ -41,8 +40,9 @@ func Loginfo(writeString string,log_file_pre string) { ...@@ -41,8 +40,9 @@ func Loginfo(writeString string,log_file_pre string) {
f, err1 = os.Create(filename) //创建文件 f, err1 = os.Create(filename) //创建文件
} }
check(err1) check(err1)
_,err := io.WriteString(f,"\r\n"+date2+"----"+writeString) //写入文件(字符串) ss := StrReplace("\r\n","",writeString,1) //替换多余换行
fmt.Print(err) io.WriteString(f,"\r\n"+date2+"----"+ss) //写入文件(字符串)
//fmt.Print(err)
} }
/** /**
......
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