...
|
...
|
@@ -115,24 +115,26 @@ func (d *PrdMoK3cloudDao) GetLastVersion() (int64, error) { |
|
|
}
|
|
|
|
|
|
//SyncDataProductPlan 同步数据到
|
|
|
func (d *PrdMoK3cloudDao) SyncDataProductPlan(version int64) error {
|
|
|
sql := `
|
|
|
func (d *PrdMoK3cloudDao) SyncDataProductPlan(version int64, companyId, orgId int, orgName string) error {
|
|
|
sql := fmt.Sprintf(`
|
|
|
INSERT INTO "manufacture"."product_plan"(
|
|
|
"company_id","org_id",
|
|
|
"product_plan_id","batch_number","product_date","workshop",
|
|
|
"plan_product_name","plan_devoted","plan_status","remark",
|
|
|
"ext","created_at","updated_at"
|
|
|
)
|
|
|
SELECT prd_mo_k3cloud."join_product_plan_id",prd_mo_k3cloud."bill_no",
|
|
|
SELECT ?,?,
|
|
|
prd_mo_k3cloud."join_product_plan_id",prd_mo_k3cloud."bill_no",
|
|
|
prd_mo_k3cloud."plan_start_date",
|
|
|
json_build_object('workshopId',COALESCE("workshop"."workshop_id",0),'workshopName',prd_mo_k3cloud."work_shop_name"),
|
|
|
prd_mo_k3cloud."material_name", json_build_object('unit',prd_mo_k3cloud."unit_name",'quantity',prd_mo_k3cloud."qty"),
|
|
|
2,prd_mo_k3cloud."description",
|
|
|
json_build_object('productPlanExt',json_build_object('productId',prd_mo_k3cloud."join_product_plan_id",'productCode',prd_mo_k3cloud."material_number",'productName',prd_mo_k3cloud."material_name")),
|
|
|
json_build_object('orgName','%v','productPlanExt',json_build_object('productId',prd_mo_k3cloud."join_product_plan_id",'productCode',prd_mo_k3cloud."material_number",'productName',prd_mo_k3cloud."material_name")),
|
|
|
now(),now()
|
|
|
FROM "manufacture"."prd_mo_k3cloud"
|
|
|
LEFT JOIN "manufacture"."material_k3cloud" ON "prd_mo_k3cloud"."material_id"="material_k3cloud"."material_id"
|
|
|
LEFT JOIN "manufacture"."workshop" ON "workshop"."workshop_name" = "prd_mo_k3cloud"."work_shop_name"
|
|
|
WHERE prd_mo_k3cloud."data_version">=?
|
|
|
-- LEFT JOIN "manufacture"."material_k3cloud" ON "prd_mo_k3cloud"."material_id"="material_k3cloud"."material_id"
|
|
|
INNER JOIN "manufacture"."workshop" ON "workshop"."workshop_name" = "prd_mo_k3cloud"."work_shop_name"
|
|
|
WHERE prd_mo_k3cloud."data_version">=?
|
|
|
ON conflict ("product_plan_id") DO
|
|
|
UPDATE
|
|
|
SET (
|
...
|
...
|
@@ -150,7 +152,7 @@ func (d *PrdMoK3cloudDao) SyncDataProductPlan(version int64) error { |
|
|
"product_plan"."ext"||EXCLUDED."ext",
|
|
|
EXCLUDED."updated_at"
|
|
|
)
|
|
|
`
|
|
|
_, err := d.transactionContext.PgTx.Exec(sql, version)
|
|
|
`, orgName)
|
|
|
_, err := d.transactionContext.PgTx.Exec(sql, companyId, orgId, version)
|
|
|
return err
|
|
|
} |
...
|
...
|
|