|
@@ -76,14 +76,17 @@ async function InsertAllDepartment(departList){
|
|
|
// },
|
|
|
let rowData = []
|
|
|
departList.forEach(depart=>{
|
|
|
- rowData.push([depart?.departmentId,depart?.organizationCode,depart?.name,depart?.description,depart?.parent?.name,depart?.parent?.departmentId,depart?.code,depart?.createdAt,depart?.updatedAt])
|
|
|
+ let objectId = depart?.departmentId
|
|
|
+ rowData.push([
|
|
|
+ objectId,depart?.organizationCode,depart?.name,depart?.description,depart?.parent?.name,
|
|
|
+ depart?.parent?.departmentId,depart?.code,depart?.createdAt || new Date(),depart?.updatedAt || new Date(),depart?.status])
|
|
|
})
|
|
|
let flattenedParams = rowData.flat();
|
|
|
|
|
|
let syncDepartSQL = `
|
|
|
INSERT INTO "Department" ("objectId", "organizationCode", "name", "description","branch","parent","code","createdAt","updatedAt")
|
|
|
VALUES
|
|
|
- ${rowData.map((_, i) => `($${i * 5 + 1}, $${i * 5 + 2}, $${i * 5 + 3}, $${i * 5 + 4}, $${i * 5 + 5}, $${i * 5 + 6}, $${i * 5 + 7}, $${i * 5 + 8}, $${i * 5 + 9})`).join(',\n')}
|
|
|
+ ${rowData.map((_, i) => `($${i * 10 + 1}, $${i * 10 + 2}, $${i * 10 + 3}, $${i * 10 + 4}, $${i * 10 + 5}, $${i * 10 + 6}, $${i * 10 + 7}, $${i * 10 + 8}, $${i * 10 + 9}, $${i * 10 + 10})`).join(',\n')}
|
|
|
ON CONFLICT ("objectId") DO UPDATE
|
|
|
SET
|
|
|
"organizationCode" = EXCLUDED."organizationCode",
|