...
|
...
|
@@ -30,8 +30,8 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error |
|
|
sqlValues := []string{}
|
|
|
var strTemp []string
|
|
|
for i := range data {
|
|
|
strTemp = make([]string, 0, 5)
|
|
|
strTemp = append(strTemp, strconv.Itoa(data[i].Id))
|
|
|
strTemp = make([]string, 0, 15)
|
|
|
strTemp = append(strTemp, `'`+data[i].RowId+`'`)
|
|
|
strTemp = append(strTemp, `'`+data[i].BillNo+`'`)
|
|
|
strTemp = append(strTemp, strconv.Itoa(data[i].WorkShopID))
|
|
|
strTemp = append(strTemp, `'`+data[i].WorkShopName+`'`)
|
...
|
...
|
@@ -47,6 +47,12 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error |
|
|
strTemp = append(strTemp, strconv.Itoa(int(data[i].DataVersion)))
|
|
|
strTemp = append(strTemp, strconv.Itoa(data[i].PrdOrgId))
|
|
|
strTemp = append(strTemp, `'`+data[i].PrdOrgName+`'`)
|
|
|
strTemp = append(strTemp, `'`+data[i].UnitName+`'`)
|
|
|
strTemp = append(strTemp, strconv.Itoa(data[i].UnitId))
|
|
|
strTemp = append(strTemp, `'`+data[i].Specification+`'`)
|
|
|
strTemp = append(strTemp, `'`+data[i].Description+`'`)
|
|
|
//关联的计划管理表id ,使用 product_plan 产品表的自增序列表
|
|
|
strTemp = append(strTemp, "nextval('manufacture.product_plan_product_plan_id_seq'::regclass)")
|
|
|
sqlValues = append(sqlValues, "("+strings.Join(strTemp, ",")+")")
|
|
|
}
|
|
|
var valueTemp []string
|
...
|
...
|
@@ -57,28 +63,32 @@ func (d *PrdMoK3cloudDao) SyncDataPrdMoK3cloud(data []models.PrdMoK3cloud) error |
|
|
valueTemp = sqlValues[i:]
|
|
|
}
|
|
|
sql := `INSERT INTO "manufacture"."prd_mo_k3cloud" (
|
|
|
"id","bill_no","work_shop_id","work_shop_name",
|
|
|
"row_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",
|
|
|
"prd_org_id","prd_org_name")
|
|
|
"prd_org_id","prd_org_name","unit_name","unit_id",
|
|
|
"specification","description","join_product_plan_id")
|
|
|
VALUES ` +
|
|
|
strings.Join(valueTemp, ",") +
|
|
|
` ON conflict ( "id" ) DO
|
|
|
` ON conflict ( "row_id" ) DO
|
|
|
UPDATE
|
|
|
SET (
|
|
|
"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",
|
|
|
"prd_org_id","prd_org_name") = (
|
|
|
"prd_org_id","prd_org_name","unit_name","unit_id",
|
|
|
"specification","description") = (
|
|
|
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."prd_org_id",EXCLUDED."prd_org_name"
|
|
|
EXCLUDED."prd_org_id",EXCLUDED."prd_org_name",
|
|
|
EXCLUDED."unit_name",EXCLUDED."unit_id",
|
|
|
EXCLUDED."specification",EXCLUDED."description"
|
|
|
)`
|
|
|
_, err := d.transactionContext.PgTx.Exec(sql)
|
|
|
if err != nil {
|
...
|
...
|
@@ -103,3 +113,8 @@ func (d *PrdMoK3cloudDao) GetLastVersion() (int64, error) { |
|
|
}
|
|
|
return prdMoData[0].DataVersion, nil
|
|
|
}
|
|
|
|
|
|
//SyncDataProductPlan 同步数据到
|
|
|
func (d *PrdMoK3cloudDao) SyncDataProductPlan() {
|
|
|
|
|
|
} |
...
|
...
|
|