fix(web): clarify act context and operational map
DH V2 CI / API · typecheck, tests, build (push) Successful in 36s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 9s
DH V2 CI / WEB · typecheck, build (push) Successful in 1m37s
DH V2 CI / Docker / migrations / production images (push) Successful in 1m52s
DH V2 CI / Promote verified main to deploy (push) Successful in 4s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 4m11s
DH V2 CI / API · typecheck, tests, build (push) Successful in 36s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 9s
DH V2 CI / WEB · typecheck, build (push) Successful in 1m37s
DH V2 CI / Docker / migrations / production images (push) Successful in 1m52s
DH V2 CI / Promote verified main to deploy (push) Successful in 4s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 4m11s
This commit is contained in:
@@ -59,9 +59,22 @@ interface ActReportSummary {
|
||||
code: string;
|
||||
status: string;
|
||||
pdfStatus: string;
|
||||
wordStatus: string;
|
||||
gedoIfIdentifier: string | null;
|
||||
gedoOfficializedAt: Date | null;
|
||||
generatedAt: Date;
|
||||
}
|
||||
|
||||
interface ActTerritorialContext {
|
||||
department: ActContextAsset | null;
|
||||
area: ActContextAsset | null;
|
||||
yacimiento: ActContextAsset | null;
|
||||
company: ActContextAsset | null;
|
||||
installations: ActContextAsset[];
|
||||
subinstallations: ActContextAsset[];
|
||||
legacyAreaScope: boolean;
|
||||
}
|
||||
|
||||
export interface InspectionActListItem {
|
||||
id: string;
|
||||
visitId: string;
|
||||
@@ -94,6 +107,7 @@ export interface InspectionActListItem {
|
||||
findingCount: number;
|
||||
companies: ActContextAsset[];
|
||||
areas: ActContextAsset[];
|
||||
context: ActTerritorialContext;
|
||||
report: ActReportSummary | null;
|
||||
createdBy: ActPerson | null;
|
||||
updatedBy: ActPerson | null;
|
||||
@@ -547,11 +561,23 @@ export class InspectionActsService {
|
||||
COALESCE(finding_count.total, 0)::integer AS "findingCount",
|
||||
COALESCE(context.companies, '[]'::jsonb) AS companies,
|
||||
COALESCE(context.areas, '[]'::jsonb) AS areas,
|
||||
JSONB_BUILD_OBJECT(
|
||||
'department', context.department,
|
||||
'area', context.area,
|
||||
'yacimiento', context.yacimiento,
|
||||
'company', context.company,
|
||||
'installations', COALESCE(context.installations, '[]'::jsonb),
|
||||
'subinstallations', COALESCE(context.subinstallations, '[]'::jsonb),
|
||||
'legacyAreaScope', context.legacy_area_scope
|
||||
) AS context,
|
||||
CASE WHEN report.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
'id', report.id,
|
||||
'code', report.code,
|
||||
'status', report.status,
|
||||
'pdfStatus', report.pdf_status,
|
||||
'wordStatus', report.word_status,
|
||||
'gedoIfIdentifier', report.gedo_if_identifier,
|
||||
'gedoOfficializedAt', report.gedo_officialized_at,
|
||||
'generatedAt', report.generated_at
|
||||
) END AS report,
|
||||
CASE WHEN creator.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
@@ -580,10 +606,64 @@ export class InspectionActsService {
|
||||
) END AS companies,
|
||||
CASE WHEN area.id IS NULL THEN '[]'::jsonb ELSE JSONB_BUILD_ARRAY(
|
||||
JSONB_BUILD_OBJECT('id',area.id,'code',area.code,'name',area.name)
|
||||
) END AS areas
|
||||
) END AS areas,
|
||||
CASE WHEN department.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
'id',department.id,'code',department.code,'name',department.name
|
||||
) END AS department,
|
||||
CASE WHEN area.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
'id',area.id,'code',area.code,'name',area.name
|
||||
) END AS area,
|
||||
CASE WHEN yacimiento.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
'id',yacimiento.id,'code',yacimiento.code,'name',yacimiento.name
|
||||
) END AS yacimiento,
|
||||
CASE WHEN company.id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT(
|
||||
'id',company.id,'code',company.code,'name',company.name
|
||||
) END AS company,
|
||||
COALESCE(affected.installations, '[]'::jsonb) AS installations,
|
||||
COALESCE(affected.subinstallations, '[]'::jsonb) AS subinstallations,
|
||||
(lower(COALESCE(scope_type.code,''))='area') AS legacy_area_scope
|
||||
FROM inspection_visits context_visit
|
||||
LEFT JOIN assets company ON company.id=context_visit.operator_company_id
|
||||
LEFT JOIN assets area ON area.id=context_visit.operational_area_id
|
||||
LEFT JOIN assets department ON department.id=area.parent_id
|
||||
LEFT JOIN assets scope_asset ON scope_asset.id=context_visit.scope_asset_id
|
||||
LEFT JOIN asset_types scope_type ON scope_type.id=scope_asset.asset_type_id
|
||||
LEFT JOIN assets yacimiento ON yacimiento.id=CASE
|
||||
WHEN lower(COALESCE(scope_type.code,''))='yacimiento' THEN scope_asset.id
|
||||
ELSE NULL
|
||||
END
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT
|
||||
COALESCE((
|
||||
SELECT JSONB_AGG(JSONB_BUILD_OBJECT('id',x.id,'code',x.code,'name',x.name) ORDER BY x.name,x.code)
|
||||
FROM (
|
||||
SELECT DISTINCT installation.id, installation.code, installation.name
|
||||
FROM inspection_findings finding_context
|
||||
INNER JOIN assets finding_asset ON finding_asset.id=finding_context.asset_id
|
||||
INNER JOIN asset_types finding_type ON finding_type.id=finding_asset.asset_type_id
|
||||
LEFT JOIN assets installation ON installation.id=CASE
|
||||
WHEN lower(finding_type.code)='instalacion' THEN finding_asset.id
|
||||
WHEN lower(finding_type.code)='subinstalacion' THEN finding_asset.parent_id
|
||||
ELSE NULL
|
||||
END
|
||||
WHERE finding_context.act_id=act.id
|
||||
AND finding_context.status<>'VOIDED'
|
||||
AND installation.id IS NOT NULL
|
||||
) x
|
||||
), '[]'::jsonb) AS installations,
|
||||
COALESCE((
|
||||
SELECT JSONB_AGG(JSONB_BUILD_OBJECT('id',x.id,'code',x.code,'name',x.name) ORDER BY x.name,x.code)
|
||||
FROM (
|
||||
SELECT DISTINCT finding_asset.id, finding_asset.code, finding_asset.name
|
||||
FROM inspection_findings finding_context
|
||||
INNER JOIN assets finding_asset ON finding_asset.id=finding_context.asset_id
|
||||
INNER JOIN asset_types finding_type ON finding_type.id=finding_asset.asset_type_id
|
||||
WHERE finding_context.act_id=act.id
|
||||
AND finding_context.status<>'VOIDED'
|
||||
AND lower(finding_type.code)='subinstalacion'
|
||||
) x
|
||||
), '[]'::jsonb) AS subinstallations
|
||||
) affected ON true
|
||||
WHERE context_visit.id=act.visit_id
|
||||
) context ON true
|
||||
LEFT JOIN LATERAL (
|
||||
|
||||
Reference in New Issue
Block a user