Browse Source

Avances Gestión de Mantenimiento Preventivo

Jose Brito 2 years ago
parent
commit
1d21add4ed

+ 2 - 2
sistema-mantenimiento-front/src/app/components/preventive-maintenance/maintenance-simulation/simulation-dialog/simulation-dialog.component.html

@@ -10,11 +10,11 @@
   </div>
   <div class="simulation-column animated fadeIn" *ngIf="!isLoading && !hasError">
     <div class="actions-row mb-16 mt-16">
-      <mat-slide-toggle [disabled]="simulating" [(ngModel)]="includeCharge">Incluir carga inducida</mat-slide-toggle>
-      <button mat-flat-button color="primary" class="ml-8" (click)="startSimulation()" [disabled]="simulating">
+      <button mat-flat-button color="primary" class="mr-8" (click)="startSimulation()" [disabled]="simulating">
         <mat-icon>play_arrow</mat-icon> Iniciar simulación
       </button>
       <a class="hidden" target="_blank" id="download"></a>
+      <mat-slide-toggle [disabled]="simulating" [(ngModel)]="includeCharge">Incluir carga inducida</mat-slide-toggle>
     </div>
     <div class="simulation-loader-container animated fadeIn" *ngIf="starting">
       <h1>Iniciando simulación</h1>

+ 152 - 37
sistema-mantenimiento-front/src/app/components/preventive-maintenance/maintenance-simulation/simulation-dialog/simulation-dialog.component.ts

@@ -379,56 +379,171 @@ export class SimulationDialogComponent implements OnInit {
     await this.timeout(750);
     idStep++;
 
-    let stepFive: ExecutionStep = {
-      id: idStep,
-      icon: 'attach_money',
-      label: 'Resultado del costo de los operadores de mantenimiento',
-      isMain: true
-    }
-
-    this.steps.push(stepFive);
-    this.scrollToBottom();
-    await this.timeout(750);
-    idStep++;
-
-    let analisisObj = JSON.parse(this.orderSimulation?.ANALISIS!);
-    let presonalObj = JSON.parse(this.orderSimulation?.PERSONAL!);
-    let teamsConf = analisisObj.teamsConf;
-    let totalCost = 0;
-    let keys = Object.keys(teamsConf);
+    if(this.includeCharge){
+      let stepFive: ExecutionStep = {
+        id: idStep,
+        icon: 'attach_money',
+        label: 'Resultado del costo de los operadores de mantenimiento',
+        isMain: true
+      }
+  
+      this.steps.push(stepFive);
+      this.scrollToBottom();
+      await this.timeout(750);
+      idStep++;
+  
+      let analisisObj = JSON.parse(this.orderSimulation?.ANALISIS!);
+      let personalObj = JSON.parse(this.orderSimulation?.PERSONAL!);
+      let teamsConf = analisisObj.teamsConf;
+      let personalTotalCost = 0;
+      let keys = Object.keys(teamsConf);
+  
+      for(const key of keys){
+        let teamConf = personalObj.filter((item: any) => item.ID == key)[0];
+        let team = teamsConf[key];
+  
+        for(const user of team){
+          let usrLabel = `${user.USER}, ${teamConf.NOMB} - ${teamConf.ESP}, costo por hora: $${user.COST}, horas requeridas: ${user.HOURS}, costo total: $${parseInt(user.COST) * parseInt(user.HOURS)}`;
+          let usrStep: ExecutionStep = {
+            id: idStep,
+            icon: 'remove',
+            label: usrLabel,
+            isMain: false
+          };
+  
+          personalTotalCost += parseInt(user.COST) * parseInt(user.HOURS);
+  
+          this.steps.push(usrStep);
+          this.scrollToBottom();
+          await this.timeout(500);
+          idStep++;
+        }
+      }
+  
+      let stepSix: ExecutionStep = {
+        id: idStep,
+        icon: 'payments',
+        label: `Costo total de los operadores: $${personalTotalCost}`,
+        isMain: true
+      };
+  
+      this.steps.push(stepSix);
+      this.scrollToBottom();
+      await this.timeout(750);
+      idStep++;
+  
+      let stepSeven: ExecutionStep = {
+        id: idStep,
+        icon: 'attach_money',
+        label: `Resultado del costo de las herramientas y refacciones`,
+        isMain: true
+      };
+  
+      this.steps.push(stepSeven);
+      this.scrollToBottom();
+      await this.timeout(750);
+      idStep++;
 
-    for(const key of keys){
-      let teamConf = presonalObj.filter((item: any) => item.ID == key)[0];
-      let team = teamsConf[key];
+      let toolsConf = analisisObj.toolsConf;
+      let toolsTotalCost = 0;
 
-      for(const user of team){
-        let usrLabel = `${user.USER}, ${teamConf.NOMB} - ${teamConf.ESP}, costo por hora: $${user.COST}, horas requeridas: ${user.HOURS}, costo total: $${parseInt(user.COST) * parseInt(user.HOURS)}`;
-        let usrStep: ExecutionStep = {
+      for(const tool of toolsConf){
+        let toolLabel = `${tool.NOM} - ${tool.REQ} ${tool.UNIT}(s) requerida(s), costo unitario: $${tool.COSTUNIT}, costo total: $${tool.COSTTOTAL}`;
+        let toolStep: ExecutionStep = {
           id: idStep,
           icon: 'remove',
-          label: usrLabel,
+          label: toolLabel,
           isMain: false
         };
+  
+        toolsTotalCost += tool.COSTTOTAL;
+  
+        this.steps.push(toolStep);
+        this.scrollToBottom();
+        await this.timeout(500);
+        idStep++;
+      }
 
-        totalCost += parseInt(user.COST) * parseInt(user.HOURS);
+      let sparePartsConf = analisisObj.sparePartsConf;
 
-        this.steps.push(usrStep);
+      for(const part of sparePartsConf){
+        let partLabel = `${part.NOM} - ${part.REQ} ${part.UNIT}(s) requerida(s), costo unitario: $${part.COSTUNIT}, costo total: $${part.COSTTOTAL}`;
+        let partStep: ExecutionStep = {
+          id: idStep,
+          icon: 'remove',
+          label: partLabel,
+          isMain: false
+        };
+  
+        toolsTotalCost += part.COSTTOTAL;
+  
+        this.steps.push(partStep);
         this.scrollToBottom();
         await this.timeout(500);
         idStep++;
       }
-    }
+  
+      let stepEight: ExecutionStep = {
+        id: idStep,
+        icon: 'payments',
+        label: `Costo total de las herramientas y refacciones: $${toolsTotalCost}`,
+        isMain: true
+      };
+  
+      this.steps.push(stepEight);
+      this.scrollToBottom();
+      await this.timeout(750);
+      idStep++;
+  
+      let stepNine: ExecutionStep = {
+        id: idStep,
+        icon: 'payments',
+        label: `Costo total de la operación: $${personalTotalCost + toolsTotalCost}`,
+        isMain: true
+      };
+  
+      this.steps.push(stepNine);
+      this.scrollToBottom();
+    }else{
+      let stepFive: ExecutionStep = {
+        id: idStep,
+        icon: 'engineering',
+        label: 'Operadores de mantenimiento',
+        isMain: true
+      }
 
-    let stepSix: ExecutionStep = {
-      id: idStep,
-      icon: 'payments',
-      label: `Costo total de los operadores: $${totalCost}`,
-      isMain: true
-    };
+      this.steps.push(stepFive);
+      this.scrollToBottom();
+      await this.timeout(750);
 
-    this.steps.push(stepSix);
-    this.scrollToBottom();
-    idStep++;
+      let analisisObj = JSON.parse(this.orderSimulation?.ANALISIS!);
+      let personalObj = JSON.parse(this.orderSimulation?.PERSONAL!);
+      let teamsConf = analisisObj.teamsConf;
+      let totalCost = 0;
+      let keys = Object.keys(teamsConf);
+
+      for(const key of keys){
+        let teamConf = personalObj.filter((item: any) => item.ID == key)[0];
+        let team = teamsConf[key];
+  
+        for(const user of team){
+          let usrLabel = `${user.USER}, ${teamConf.NOMB} - ${teamConf.ESP}`;
+          let usrStep: ExecutionStep = {
+            id: idStep,
+            icon: 'remove',
+            label: usrLabel,
+            isMain: false
+          };
+  
+          totalCost += parseInt(user.COST) * parseInt(user.HOURS);
+  
+          this.steps.push(usrStep);
+          this.scrollToBottom();
+          await this.timeout(500);
+          idStep++;
+        }
+      }
+    }
 
     this.simulating = false;
     this.hasBeenSimulated = true;
@@ -450,7 +565,7 @@ export class SimulationDialogComponent implements OnInit {
       }else if(error.error.msg == undefined){
         this.openSnackBar('Ocurrió un error inesperado.');
       }else{
-        this.openSnackBar(error.error.msg );
+        this.openSnackBar(error.error.msg);
       }
     }
   }

+ 1 - 1
sistema-mantenimiento-front/src/app/components/preventive-maintenance/work-orders/work-orders.component.html

@@ -124,7 +124,7 @@
                   <mat-icon>done</mat-icon>
                   <span>Aprobar orden</span>
                 </button>
-                <button mat-menu-item (click)="openAnalysisDialog(row.IDORDEN)">
+                <button mat-menu-item (click)="openAnalysisDialog(row.IDORDEN)" *ngIf="row.ESTATUS == 'R'">
                   <mat-icon>edit_note</mat-icon>
                   <span>Asignar análisis presupuestario</span>
                 </button>