...
|
...
|
@@ -2,6 +2,7 @@ package dao |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
|
...
|
...
|
@@ -106,15 +107,15 @@ func (d *MaterialK3cloudDao) SyncDataMaterialK3cloud(data []models.MaterialK3clo |
|
|
}
|
|
|
|
|
|
//SyncDataProudct 同步MaterialK3cloud表数据到Proudct表
|
|
|
func (d *MaterialK3cloudDao) SyncDataProudct(version int64) error {
|
|
|
func (d *MaterialK3cloudDao) SyncDataProudct(version int64, orgName string) error {
|
|
|
// -- 插入或者更新
|
|
|
sql := `INSERT INTO "manufacture"."product"(
|
|
|
sql := fmt.Sprintf(`INSERT INTO "manufacture"."product"(
|
|
|
"company_id", "org_id", "product_id", "product_code", "product_name",
|
|
|
"product_category", "product_spec", "created_at", "updated_at"
|
|
|
"product_category", "product_spec", "created_at", "updated_at","ext"
|
|
|
)
|
|
|
SELECT 0,use_org_id,"join_product_id","number","name","material_group_name",
|
|
|
json_build_object('unit',specification),now(),now()
|
|
|
FROM "manufacture"."material_k3cloud" WHERE "data_version"=? AND "material_group_number" LIKE '05%'
|
|
|
SELECT %v,%v,"join_product_id","number","name","material_group_name",
|
|
|
json_build_object('unit',specification),now(),now(),json_build_object('orgName','%v')
|
|
|
FROM "manufacture"."material_k3cloud" WHERE "data_version"=? AND "material_group_number" LIKE '05%%'
|
|
|
ON conflict ( product_id ) DO
|
|
|
UPDATE
|
|
|
SET (
|
...
|
...
|
@@ -122,7 +123,7 @@ func (d *MaterialK3cloudDao) SyncDataProudct(version int64) error { |
|
|
"product_category", "product_spec", "updated_at")=(
|
|
|
EXCLUDED."company_id", EXCLUDED."org_id",EXCLUDED."product_id",
|
|
|
EXCLUDED."product_code",EXCLUDED."product_name",EXCLUDED."product_category",
|
|
|
EXCLUDED."product_spec", EXCLUDED."updated_at") `
|
|
|
EXCLUDED."product_spec", EXCLUDED."updated_at") `, constant.MANUFACTURE_DEFAULT_COMPANYID, constant.MANUFACTURE_DEFAULT_ORGID, orgName)
|
|
|
_, err := d.transactionContext.PgTx.Exec(sql, version)
|
|
|
return err
|
|
|
}
|
...
|
...
|
|