Commit 8c26600a by Joneq

修改历史数据

parent 5aed1617
package bank_dong package main
import ( import (
"context" "context"
"encoding/json" "encoding/json"
......
...@@ -142,7 +142,7 @@ func (d *dao) BankDongMain(ctx context.Context,project_id int,erp_company_code s ...@@ -142,7 +142,7 @@ func (d *dao) BankDongMain(ctx context.Context,project_id int,erp_company_code s
scores.Current_rate = ladder_rate scores.Current_rate = ladder_rate
scores.Remark = remark scores.Remark = remark
insertid,err := d.InsertScores2(ctx,scores,logic.MyInt64(month_six_zi)) insertid,err := d.InsertBankScores(ctx,scores,logic.MyInt64(month_six_zi))
if err != nil { if err != nil {
logic.Loginfo("错误:"+err.Error(),log_pre) logic.Loginfo("错误:"+err.Error(),log_pre)
fmt.Print("错误:"+err.Error(),insertid,ladder_rate) fmt.Print("错误:"+err.Error(),insertid,ladder_rate)
......
...@@ -58,6 +58,7 @@ type ( ...@@ -58,6 +58,7 @@ type (
type dao struct { type dao struct {
db *sql.DB db *sql.DB
db2 *sql.DB db2 *sql.DB
db_bank *sql.DB
redis *redis.Pool redis *redis.Pool
redisExpire int32 redisExpire int32
mc *memcache.Memcache mc *memcache.Memcache
...@@ -77,6 +78,7 @@ func New() (Dao) { ...@@ -77,6 +78,7 @@ func New() (Dao) {
dc struct { dc struct {
Liexin_credit *sql.Config Liexin_credit *sql.Config
Liexin_credit_source *sql.Config Liexin_credit_source *sql.Config
Liexin_credit_lx *sql.Config
} }
rc struct { rc struct {
Demo *redis.Config Demo *redis.Config
...@@ -94,6 +96,7 @@ func New() (Dao) { ...@@ -94,6 +96,7 @@ func New() (Dao) {
// mysql // mysql
db: sql.NewMySQL(dc.Liexin_credit), db: sql.NewMySQL(dc.Liexin_credit),
db2: sql.NewMySQL(dc.Liexin_credit_source), db2: sql.NewMySQL(dc.Liexin_credit_source),
db_bank: sql.NewMySQL(dc.Liexin_credit_lx),
// redis // redis
redis: redis.NewPool(rc.Demo), redis: redis.NewPool(rc.Demo),
redisExpire: int32(time.Duration(rc.DemoExpire) / time.Second), redisExpire: int32(time.Duration(rc.DemoExpire) / time.Second),
...@@ -109,6 +112,7 @@ func (d *dao) Close() { ...@@ -109,6 +112,7 @@ func (d *dao) Close() {
d.redis.Close() d.redis.Close()
d.db.Close() d.db.Close()
d.db2.Close() d.db2.Close()
d.db_bank.Close()
} }
// Ping ping the resource. // Ping ping the resource.
......
...@@ -99,4 +99,48 @@ func (d *dao) InsertScores2(ctx context.Context,score model.Scores,month_six_zi ...@@ -99,4 +99,48 @@ func (d *dao) InsertScores2(ctx context.Context,score model.Scores,month_six_zi
return return
}
//增加或者修改记录(动态模型专用)
func (d *dao) InsertBankScores(ctx context.Context,score model.Scores,month_six_zi int64) (insertId int64,err error) {
//defer d.db.Close()
var(
exitId int
execSql string
affectNum int64
)
//ss := fmt.Sprintf("select id from lie_scores where `type` = %d and project_pid = %d and project_id = %d and com_credits_id = %d limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId)
//print(ss)
err = d.db_bank.QueryRow(ctx,"select id from lie_scores where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ? and month= ? limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId,month_six_zi).Scan(&exitId)
if err != nil {
//fmt.Print(err)
//sql := fmt.Sprintf("select id from lie_scores where `type` = %d and project_pid = %d and project_id = %d and com_credits_id = %d and month= %d limit 0,1", score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId,month_six_zi);
//fmt.Print("查询失败:"+sql)
//os.Exit(1)
}
if exitId == 0 {
execSql = "INSERT INTO `lie_scores` (`type`, `project_pid`, `project_id`, `total_score`, `current_score`, `weight`, `final_score`, `com_credits_id`, `create_time`,`current_rate`,`month`,`remark`)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"
row,err := d.db_bank.Exec(ctx,execSql,score.Type,score.ProjectPid,score.ProjectId,score.TotalScore,score.CurrentScore,score.Weight,score.FinalScore,score.ComCreditsId,time.Now().Unix(),score.Current_rate,score.Month,score.Remark)
if err != nil {
logic.CheckErr(err)
}else{
affectNum,_ = row.LastInsertId()
}
}else{
execSql = "update `lie_scores` set `type` = ?, `project_pid` = ?, `project_id` = ?, `total_score` = ?, `current_score` = ?, `weight` = ?, `final_score` = ?, `update_time` = ?, `current_rate` = ?, `remark` = ? where `type` = ? and project_pid = ? and project_id = ? and com_credits_id = ? and month = ?"
row,err := d.db_bank.Exec(ctx,execSql,score.Type,score.ProjectPid,score.ProjectId,score.TotalScore,score.CurrentScore,score.Weight,score.FinalScore,time.Now().Unix(), score.Current_rate,score.Remark,score.Type,score.ProjectPid,score.ProjectId,score.ComCreditsId,month_six_zi)
if err != nil {
logic.CheckErr(err)
}else{
affectNum,_ = row.RowsAffected()
}
}
insertId = affectNum
return
} }
\ No newline at end of file
...@@ -109,7 +109,7 @@ func HttpGet(companyName string)(returnDatas map[string]string) { ...@@ -109,7 +109,7 @@ func HttpGet(companyName string)(returnDatas map[string]string) {
json.Unmarshal(respBody,&totalNum) json.Unmarshal(respBody,&totalNum)
//防止sql执行字符串超长 //防止sql执行字符串超长
if len(string(respBody)) < 120000 { if len(string(respBody)) < 10000{
returnData["tianyancha_json"] += "||||"+string(respBody) returnData["tianyancha_json"] += "||||"+string(respBody)
} }
var changeInfoNum int64 var changeInfoNum int64
......
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