Commit 73c1fe8e by Joneq

判断sql插入限制

parent c67d41ab
...@@ -205,7 +205,7 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems [] ...@@ -205,7 +205,7 @@ func (d *dao) BankDongRate(ctx context.Context,y map[string]string,modelItems []
case 48: // 账期使用倍数统计 case 48: // 账期使用倍数统计
last_month := time.Now().Format("2006")+time.Now().AddDate(0, -1, 0).Format("01") last_month := time.Now().Format("2006")+time.Now().AddDate(0, -1, 0).Format("01")
sql6 := fmt.Sprintf(bank_sql6,y["erp_company_code"],last_month) sql6 := fmt.Sprintf(bank_sql6,y["erp_company_code"],last_month)
c3,_ := d.QueryOne(ctx,1,sql6) c3,_ := d.QueryOne(ctx,3,sql6)
if c3 == nil || c3["period_use_times_six"] == "" { if c3 == nil || c3["period_use_times_six"] == "" {
ladder_rate = 0 ; ladder_rate = 0 ;
remark = "0" remark = "0"
...@@ -256,7 +256,7 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si ...@@ -256,7 +256,7 @@ func (d *dao) BankDongAddScore(ctx context.Context,com_credits_id int64,month_si
logic.LogWrite("统计动态分数完成,供应商id:"+logic.MyInt64ToStr(com_credits_id)+"总动态分:"+logic.MyFloat64ToStr(sum_dong_score),"dong_sum",1) logic.LogWrite("统计动态分数完成,供应商id:"+logic.MyInt64ToStr(com_credits_id)+"总动态分:"+logic.MyFloat64ToStr(sum_dong_score),"dong_sum",1)
//最后累计总分评分 //最后累计总分评分
affectNum,_ = d.UpdateMoveSumScores(ctx,com_credit) affectNum,_ = d.UpdateBankMoveSumScores(ctx,com_credit)
return return
} }
...@@ -15,7 +15,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin ...@@ -15,7 +15,7 @@ func (d *dao) GetCompanyCresitsList(ctx context.Context) (res []map[string]strin
var ( var (
rows *sql.Rows rows *sql.Rows
) )
if rows, err = d.db.Query(ctx, "SELECT "+SqlField+" FROM lie_com_credits where status = 5 or status = 10 "); err != nil { if rows, err = d.db.Query(ctx, "SELECT "+SqlField+" FROM lie_com_credits where id >=4907 "); err != nil {
err = errors.WithStack(err) err = errors.WithStack(err)
return return
} }
...@@ -66,6 +66,12 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi ...@@ -66,6 +66,12 @@ func (d *dao) UpdateMoveSumScores(ctx context.Context,com_credits model.ComCredi
return return
} }
func (d *dao)UpdateComCredits(ctx context.Context,com_credits model.ComCredits)(Id int64,err error) { func (d *dao)UpdateComCredits(ctx context.Context,com_credits model.ComCredits)(Id int64,err error) {
var ( var (
...@@ -141,5 +147,104 @@ func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]strin ...@@ -141,5 +147,104 @@ func (d *dao)GetGrade(ctx context.Context,sumScore float64)(res map[string]strin
//------------------银行方法-----------------//
//修改银行动态总分记录
func (d *dao) UpdateBankMoveSumScores(ctx context.Context,com_credits model.ComCredits) (insertId int64,err error) {
var(
execSql string
)
execSql = "update `lie_com_credits` set `dynamic_credit_score` = ? where id = ? "
row,err := d.db_bank.Exec(ctx,execSql,com_credits.DynamicCreditScore,com_credits.Id)
if err != nil {
log.Error("UpdateMoveSumScoresdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
d.UpdateBankComCredits(ctx,com_credits)
row.RowsAffected()
return
}
func (d *dao)UpdateBankComCredits(ctx context.Context,com_credits model.ComCredits)(Id int64,err error) {
var (
rows *sql.Rows
res map[string]string
)
//获取当前条的数据
if rows, err = d.db_bank.Query(ctx, "select "+ SqlField + " from lie_com_credits where id = ?",com_credits.Id); 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
}
//修改相应的参数
total_credit_score := logic.StringTurnFloat64(res["static_credit_score"]) + logic.StringTurnFloat64(res["dynamic_credit_score"])
grade,_ := d.GetBankGrade(ctx,total_credit_score)
execSql := "update `lie_com_credits` set `static_credit_score` = ?,`dynamic_credit_score` = ?, `total_credit_score` = ? , `ichunt_hunting_core` = ? , `recom_time_limit` = ? ,`recommended_amount` = ? ,`status` = 10 where id = ? "
row,err := d.db_bank.Exec(ctx,execSql,logic.StringTurnFloat64(res["static_credit_score"]),logic.StringTurnFloat64(res["dynamic_credit_score"]),total_credit_score,grade["grade"],grade["recommended_limit"],logic.StringTurnFloat64(grade["recommended_amount"]),com_credits.Id)
if err != nil {
log.Error("UpdateComCreditsdb.DemoExec.Exec(%s) error(%v)", execSql, err)
}
row.RowsAffected()
return
}
func (d *dao)GetBankGrade(ctx context.Context,sumScore float64)(res map[string]string,err error) {
var (
rows *sql.Rows
)
//获取当前条的数据
if rows, err = d.db_bank.Query(ctx, "select "+ SqlField + " from lie_grade where status = 1 and min_score <= ? and max_score > ?",sumScore,sumScore); err != nil {
err = errors.WithStack(err)
return
}
if err != nil{
fmt.Println("select fail,err:",err)
return
}
twoMap,err := GetAllParam(rows)
for _,v:=range twoMap{
res = v
break
}
return
}
//------------------银行方法-----------------//
...@@ -94,11 +94,30 @@ func (d *dao)QueryMany(ctx context.Context,db int,sql_str string)(res []map[stri ...@@ -94,11 +94,30 @@ func (d *dao)QueryMany(ctx context.Context,db int,sql_str string)(res []map[stri
var ( var (
rows1 *sql.Rows rows1 *sql.Rows
) )
//查询项目配置
if rows1, err = d.db.Query(ctx, sql_str); err != nil {
err = errors.WithStack(err) //fmt.Print(sql_str)
return if db == 1 {
//查询项目配置
if rows1, err = d.db.Query(ctx, sql_str); err != nil {
err = errors.WithStack(err)
return
}
}else if db == 3{
//查询项目配置
if rows1, err = d.db_bank.Query(ctx, sql_str); err != nil {
err = errors.WithStack(err)
return
}
}else {
//查询项目配置
if rows1, err = d.db2.Query(ctx, sql_str); err != nil {
err = errors.WithStack(err)
return
}
} }
defer rows1.Close() defer rows1.Close()
if err != nil{ if err != nil{
fmt.Println("error1001:"+sql_str,err) fmt.Println("error1001:"+sql_str,err)
......
...@@ -113,6 +113,10 @@ func HttpGet(companyName string)(returnDatas map[string]string) { ...@@ -113,6 +113,10 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
returnData["tianyancha_json"] += "||||"+string(respBody) returnData["tianyancha_json"] += "||||"+string(respBody)
} }
if len(returnData["tianyancha_json"]) > 130000 {
returnData["tianyancha_json"] = "字符串过长"
}
var changeInfoNum int64 var changeInfoNum int64
changeInfoNum = 0 changeInfoNum = 0
for _,v := range totalNum.Result.Items{ for _,v := range totalNum.Result.Items{
......
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