作者 tangxuhui

日常提交保存

... ... @@ -45,6 +45,8 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
strTemp = append(strTemp, `'`+data[i].CreateDate.Format("2006-01-02 15:04:05.999")+`'`)
strTemp = append(strTemp, `'`+data[i].ModifyDate.Format("2006-01-02 15:04:05.999")+`'`)
strTemp = append(strTemp, strconv.Itoa(int(data[i].DataVersion)))
strTemp = append(strTemp, strconv.Itoa(data[i].PrdOrgId))
strTemp = append(strTemp, `'`+data[i].PrdOrgName+`'`)
sqlValues = append(sqlValues, "("+strings.Join(strTemp, ",")+")")
}
var valueTemp []string
... ... @@ -58,7 +60,8 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
"id","bill_no","work_shop_id","work_shop_name",
"material_id","material_name","material_number",
"plan_start_date","plan_finish_date","f_date",
"qty","create_date","modify_date","data_version" )
"qty","create_date","modify_date","data_version",
"prd_org_id","prd_org_name")
VALUES ` +
strings.Join(valueTemp, ",") +
` ON conflict ( "id" ) DO
... ... @@ -67,13 +70,15 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error
"bill_no","work_shop_id","work_shop_name",
"material_id","material_name","material_number",
"plan_start_date","plan_finish_date","f_date",
"qty","create_date","modify_date","data_version") = (
"qty","create_date","modify_date","data_version",
"prd_org_id","prd_org_name") = (
EXCLUDED."bill_no",EXCLUDED."work_shop_id",
EXCLUDED."work_shop_name",EXCLUDED."material_id",
EXCLUDED."material_name",EXCLUDED."material_number",
EXCLUDED."plan_start_date",EXCLUDED."plan_finish_date",
EXCLUDED."f_date",EXCLUDED."qty",EXCLUDED."create_date",
EXCLUDED."modify_date",EXCLUDED."data_version"
EXCLUDED."modify_date",EXCLUDED."data_version",
EXCLUDED."prd_org_id",EXCLUDED."prd_org_name"
)`
_, err := d.transactionContext.PgTx.Exec(sql)
if err != nil {
... ...
... ... @@ -20,6 +20,6 @@ type PrdMoK3cloud struct {
CreateDate time.Time `comment:"创建时间" pg:"create_date"`
ModifyDate time.Time `comment:"修改时间" pg:"modify_date"`
DataVersion int64 `comment:"数据版本" pg:"data_version"`
PrdOrgId int `comment:"生产组织" pg:"data_version"`
PrdOrgName string `comment:"生产组织名称" pg:"data_version"`
PrdOrgId int `comment:"生产组织" pg:"prd_org_id"`
PrdOrgName string `comment:"生产组织名称" pg:"prd_org_name"`
}
... ...