ParcelSync: PROPRIETARI_VECHI in enrichment + global DB summary tab (all UATs without login)
This commit is contained in:
@@ -125,6 +125,7 @@ export type FeatureEnrichment = {
|
||||
NR_TOPO: string;
|
||||
ADRESA: string;
|
||||
PROPRIETARI: string;
|
||||
PROPRIETARI_VECHI: string;
|
||||
SUPRAFATA_2D: number | string;
|
||||
SUPRAFATA_R: number | string;
|
||||
SOLICITANT: string;
|
||||
@@ -244,11 +245,14 @@ export async function enrichFeatures(
|
||||
const immovableListByCad = new Map<string, any>();
|
||||
const ownersByLandbook = new Map<string, Set<string>>();
|
||||
|
||||
const addOwner = (landbook: string, name: string) => {
|
||||
const cancelledOwnersByLandbook = new Map<string, Set<string>>();
|
||||
|
||||
const addOwner = (landbook: string, name: string, radiated = false) => {
|
||||
if (!landbook || !name) return;
|
||||
const existing = ownersByLandbook.get(landbook) ?? new Set<string>();
|
||||
const targetMap = radiated ? cancelledOwnersByLandbook : ownersByLandbook;
|
||||
const existing = targetMap.get(landbook) ?? new Set<string>();
|
||||
existing.add(name);
|
||||
ownersByLandbook.set(landbook, existing);
|
||||
targetMap.set(landbook, existing);
|
||||
};
|
||||
|
||||
let listPage = 0;
|
||||
@@ -301,15 +305,32 @@ export async function enrichFeatures(
|
||||
const idKey = normalizeId(item?.immovablePk);
|
||||
if (idKey) docByImmovable.set(idKey, item);
|
||||
});
|
||||
(docResponse?.partTwoRegs ?? []).forEach((item: any) => {
|
||||
if (
|
||||
String(item?.nodeType ?? "").toUpperCase() === "P" &&
|
||||
item?.landbookIE
|
||||
) {
|
||||
const name = String(item?.nodeName ?? "").trim();
|
||||
if (name) addOwner(String(item.landbookIE), name);
|
||||
// Build nodeId → entry map for radiated detection
|
||||
const regs: any[] = docResponse?.partTwoRegs ?? [];
|
||||
const nodeMap = new Map<number, any>();
|
||||
for (const reg of regs) {
|
||||
if (reg?.nodeId != null) nodeMap.set(Number(reg.nodeId), reg);
|
||||
}
|
||||
// Check if an entry or any ancestor "I" inscription is radiated
|
||||
const isRadiated = (entry: any, depth = 0): boolean => {
|
||||
if (!entry || depth > 10) return false;
|
||||
if (entry?.nodeStatus === -1) return true;
|
||||
const pid = entry?.parentId;
|
||||
if (pid != null) {
|
||||
const parent = nodeMap.get(Number(pid));
|
||||
if (parent) return isRadiated(parent, depth + 1);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
for (const reg of regs) {
|
||||
if (
|
||||
String(reg?.nodeType ?? "").toUpperCase() !== "P" ||
|
||||
!reg?.landbookIE
|
||||
)
|
||||
continue;
|
||||
const name = String(reg?.nodeName ?? "").trim();
|
||||
if (name) addOwner(String(reg.landbookIE), name, isRadiated(reg));
|
||||
}
|
||||
}
|
||||
|
||||
// ── Enrich each teren feature ──
|
||||
@@ -401,6 +422,22 @@ export async function enrichFeatures(
|
||||
Array.from(new Set([...owners, ...ownersByCad])).join("; ") ||
|
||||
proprietari;
|
||||
|
||||
// Cancelled/old owners
|
||||
const cancelledOwners =
|
||||
landbookIE && cancelledOwnersByLandbook.get(String(landbookIE))
|
||||
? Array.from(cancelledOwnersByLandbook.get(String(landbookIE)) ?? [])
|
||||
: [];
|
||||
const cancelledByCad =
|
||||
cadRefRaw && cancelledOwnersByLandbook.get(String(cadRefRaw))
|
||||
? Array.from(cancelledOwnersByLandbook.get(String(cadRefRaw)) ?? [])
|
||||
: [];
|
||||
const activeSet = new Set([...owners, ...ownersByCad]);
|
||||
const proprietariVechi = Array.from(
|
||||
new Set([...cancelledOwners, ...cancelledByCad]),
|
||||
)
|
||||
.filter((n) => !activeSet.has(n))
|
||||
.join("; ");
|
||||
|
||||
nrCF =
|
||||
docItem?.landbookIE ||
|
||||
listItem?.paperLbNo ||
|
||||
@@ -435,6 +472,7 @@ export async function enrichFeatures(
|
||||
NR_TOPO: nrTopo,
|
||||
ADRESA: addressText,
|
||||
PROPRIETARI: proprietari,
|
||||
PROPRIETARI_VECHI: proprietariVechi,
|
||||
SUPRAFATA_2D: areaValue !== null ? Number(areaValue.toFixed(2)) : "",
|
||||
SUPRAFATA_R: areaValue !== null ? Math.round(areaValue) : "",
|
||||
SOLICITANT: solicitant,
|
||||
|
||||
Reference in New Issue
Block a user