Browse Source

Actualización de mantenimiento preventivo

Jose Brito 4 hours ago
parent
commit
59b4a49d8c

BIN
public/favicon.ico


+ 8 - 0
src/app/components/corrective-maintenance/maintenance-planning/plan-register/plan-register.component.html

@@ -158,6 +158,14 @@
                     @if (plainFormGroup.controls['relatedCounterControl'].hasError('required')) {
                       <mat-error>Este campo es obligatorio.</mat-error>
                     }
+                    @if (relatedCounters.length <= 0 && this.plainFormGroup.controls['equipmentControl'].value != '') {
+                      <mat-hint align="end">
+                        <a style="color: rgb(35, 95, 172);"  [ngClass]="{ hint_button_disabled: plainFormGroup.controls['symptomControl'].value == '', 
+                        hint_button: plainFormGroup.controls['symptomControl'].value != '' }" (click)="openAddCounter()">
+                          Registrar contador
+                        </a>
+                      </mat-hint>
+                    }
                   </mat-form-field>
                 }
               </div>

+ 22 - 4
src/app/components/corrective-maintenance/maintenance-planning/plan-register/plan-register.component.ts

@@ -9,7 +9,7 @@ import { TempFileInfo } from '../../../../interfaces/temp-file-info.interface';
 import { FormControl, FormGroup, Validators } from '@angular/forms';
 import { debounceTime, distinctUntilChanged, filter, lastValueFrom, map, Observable, startWith, switchMap, tap } from 'rxjs';
 
-import { ActivatedRoute } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
 import { EquipmentManagementService } from '../../../../services/equipment-management.service';
 import { EncService } from '../../../../services/enc.service';
 import { ResourcesService } from '../../../../services/resources.service';
@@ -118,6 +118,7 @@ export class PlanRegisterComponent implements OnInit {
     private _countersActivatorsService: CountersActivatorsService,
     private _usersProfilesService: UsersProfilesService,
     private _inventoryManagementService: InventoryManagementService,
+    private _router: Router,
   ) {
     this.screenSize = window.innerWidth;
     this.action = "";
@@ -445,7 +446,9 @@ export class PlanRegisterComponent implements OnInit {
             this.plainFormGroup.controls['relatedCounterControl'].setValue(counter.ID_CONTADOR);
           }
           
-          equipmentCountersArr.push(counter);
+          if(counter.ID_ACTIVADOR == null){
+            equipmentCountersArr.push(counter);
+          }
         }
 
         this.relatedCounters = equipmentCountersArr;
@@ -1057,8 +1060,10 @@ export class PlanRegisterComponent implements OnInit {
           if(counter.ID_CONTADOR == counterSel){
             this.plainFormGroup.controls['relatedCounterControl'].setValue(counter.ID_CONTADOR);
           }
-
-          equipmentCountersArr.push(counter);
+          
+          if(counter.ID_ACTIVADOR == null){
+            equipmentCountersArr.push(counter);
+          }
         }
 
         this.relatedCounters = equipmentCountersArr;
@@ -1732,4 +1737,17 @@ export class PlanRegisterComponent implements OnInit {
     
     return `${cd - cr}`;
   }
+
+  async openAddCounter(){
+    let equipmentCode = this.plainFormGroup.controls['equipmentControl'].value;
+    let equipmentCodeEnc = await this._encService.encrypt(equipmentCode);
+    let idCounterEnc = await this._encService.encrypt('-');
+
+    this._router.navigate(['sam/COAC/CONT/GECO/nuevo'], {
+      queryParams: {
+        idCounter: idCounterEnc,
+        equipmentCode: equipmentCodeEnc,
+      }
+    })
+  }
 }

+ 31 - 5
src/app/components/counters-activators/counters-management/counter-form/counter-form.component.ts

@@ -83,12 +83,14 @@ export class CounterFormComponent implements OnInit {
     }
 
     this._activatedRoute.queryParams.subscribe(params => {
+      let equipmentCodeEnc = params['equipmentCode'];
       let idCounterEnc = params['idCounter'];
+
       if(idCounterEnc == null || idCounterEnc == undefined || idCounterEnc == ''){
         this._resourcesService.openSnackBar('No se envió información.');
         this.goBack(1);
       }else{
-        this.init(idCounterEnc);
+        this.init(idCounterEnc, equipmentCodeEnc);
       }
     });
 
@@ -107,7 +109,7 @@ export class CounterFormComponent implements OnInit {
     return this.scadasStr.filter(option => option.toLowerCase().includes(filterValue));
   }
 
-  async init(idCounterEnc: string){
+  async init(idCounterEnc: string, equipmentCodeEnc: string | undefined = undefined){
     let route = location.href;
     let routeArr = route.split('/').reverse();
     let typeArr = routeArr[0].split('?');
@@ -117,7 +119,7 @@ export class CounterFormComponent implements OnInit {
       this.isNew = true;
       this.action = "Registrar";
 
-      this.getEquipments();
+      this.getEquipments(equipmentCodeEnc);
     }else{
       this.isNew = false;
       this.idCounter = await this._encService.decrypt(idCounterEnc);
@@ -127,8 +129,19 @@ export class CounterFormComponent implements OnInit {
     }
   }
 
-  async getEquipments(){
+  async getEquipments(equipmentCodeEnc: string | undefined = undefined){
     try{
+      let fromCorrective = false;
+      let equipmentCodeDec: string | undefined = undefined;
+
+      if(equipmentCodeEnc != undefined && equipmentCodeEnc != ''){
+        let equipmentCodeIsEnc = await this._encService.isEncrypted(equipmentCodeEnc);
+        if(equipmentCodeIsEnc){
+          equipmentCodeDec = await this._encService.decrypt(equipmentCodeEnc);
+          fromCorrective = true;
+        }
+      }
+
       let idUser = localStorage.getItem('idusuario')!;
       let equipments: EquipmentsListResponse = await lastValueFrom(this._equipmentManagementService.equipmentConsult(idUser, 1));
 
@@ -146,7 +159,20 @@ export class CounterFormComponent implements OnInit {
           equipment.TIPO = `${codeDec} - ${equipment.TIPO}`;
           equipment.MODELO = `${equipment.MODELO} (${idDec})`;
 
-          if(equipment.EQUIPO_PADRE == null){
+          if(equipmentCodeDec != undefined){
+            let equipmentCodeArr = equipmentCodeDec.split(' - ');
+            if(equipmentCodeArr.length == 3){
+              let equipmentCode = equipmentCodeArr[0];
+              if(equipmentCode == codeDec){
+                this.counterFormGroup.controls['equipment0Control'].setValue(equipmentCode);
+                this.counterFormGroup.controls['equipment0Control'].disable();
+
+                equipmentsArr.push(equipment);
+              }
+            }
+          }
+
+          if(equipment.EQUIPO_PADRE == null && !fromCorrective){
             equipmentsArr.push(equipment);
           }
         }

+ 39 - 41
src/app/components/preventive-maintenance/active-orders/execution-dialog/execution-dialog.component.html

@@ -1,46 +1,44 @@
 <h1 mat-dialog-title>Orden #{{ idOrder }}</h1>
 <div mat-dialog-content class="prevent-select">
-  <div class="content-container animated fadeIn">
-    @if (isLoading) {
-      <div class="is-loading animated fadeIn fast">
-        <mat-spinner align="center"></mat-spinner>
-        <h3>Cargando datos ...</h3>
-      </div>
-    }
-    @if (!isLoading && hasError) {
-      <div class="has-error animated fadeIn">
-        <mat-icon class="red_primary_font">error</mat-icon>
-        <h2>{{ errorStr }}</h2>
-      </div>
-    }
-    @if (!isLoading && !hasError) {
-      <div class="execution-info-container animated fadeIn">
-        <h3 class="mb-8">Ejecución de la orden programada para el día {{ dateStr }}</h3>
-        <h3 class="mb-8"><span class="bold">Descripción: </span><br>{{ prevOrdExec!.DESCRIPCION }}</h3>
-        <h3 class="mb-8"><span class="bold">Equipamiento: </span><br>{{ prevOrdExec!.EQUIPAMIENTO }}</h3>
-        <h3 class="mb-8"><span class="bold">Fecha de inicio: </span><br>{{ orderDate(prevOrdExec!.FECHAINICIO) }}</h3>
-        <h3 class="mb-8"><span class="bold">Estado de la ejecución: </span><br>{{ prevOrdExec!.ESTADODEEJECUCION }}</h3>
-        @if (prevOrdExec!.ESTADODEEJECUCION == 'Finalizado' || prevOrdExec!.ESTADODEEJECUCION == 'Cancelacion') {
-          <h3 class="mb-8">
-            <span class="bold">Observaciones: </span><br>{{ prevOrdExec!.OBSERVACIONES }}
-          </h3>
-        }
-        @if (prevOrdExec!.ESTADODEEJECUCION == 'Programada') {
-          <div class="execution-actions-container">
-            <button mat-flat-button color="primary" (click)="closeDialog('execute')">Ejecutar ahora</button>
-            <button mat-flat-button class="red_primary_background white_font ml-10" (click)="closeDialog('cancel')">
-              Cancelar ejecución
-            </button>
-          </div>
-        }
-        @if (prevOrdExec!.ESTADODEEJECUCION == 'Ejecucion') {
-          <div class="execution-actions-container">
-            <button mat-flat-button color="primary" (click)="closeDialog('end')">Finalizar ejecución</button>
-          </div>
-        }
-      </div>
-    }
-  </div>
+  @if (isLoading) {
+    <div class="is-loading animated fadeIn fast">
+      <mat-spinner align="center"></mat-spinner>
+      <h3>Cargando datos ...</h3>
+    </div>
+  }
+  @if (!isLoading && hasError) {
+    <div class="has-error animated fadeIn">
+      <mat-icon class="red_primary_font">error</mat-icon>
+      <h2>{{ errorStr }}</h2>
+    </div>
+  }
+  @if (!isLoading && !hasError) {
+    <div class="execution-info-container animated fadeIn">
+      <h3 class="mb-8">Ejecución de la orden programada para el día {{ dateStr }}</h3>
+      <h3 class="mb-8"><span class="bold">Descripción: </span><br>{{ prevOrdExec!.DESCRIPCION }}</h3>
+      <h3 class="mb-8"><span class="bold">Equipamiento: </span><br>{{ prevOrdExec!.EQUIPAMIENTO }}</h3>
+      <h3 class="mb-8"><span class="bold">Fecha de inicio: </span><br>{{ orderDate(prevOrdExec!.FECHAINICIO) }}</h3>
+      <h3 class="mb-8"><span class="bold">Estado de la ejecución: </span><br>{{ prevOrdExec!.ESTADODEEJECUCION }}</h3>
+      @if (prevOrdExec!.ESTADODEEJECUCION == 'Finalizado' || prevOrdExec!.ESTADODEEJECUCION == 'Cancelacion') {
+        <h3 class="mb-8">
+          <span class="bold">Observaciones: </span><br>{{ prevOrdExec!.OBSERVACIONES }}
+        </h3>
+      }
+      @if (prevOrdExec!.ESTADODEEJECUCION == 'Programada') {
+        <div class="execution-actions-container">
+          <button mat-flat-button color="primary" (click)="closeDialog('execute')">Ejecutar ahora</button>
+          <button mat-flat-button class="red_primary_background white_font ml-10" (click)="closeDialog('cancel')">
+            Cancelar ejecución
+          </button>
+        </div>
+      }
+      @if (prevOrdExec!.ESTADODEEJECUCION == 'Ejecucion') {
+        <div class="execution-actions-container">
+          <button mat-flat-button color="primary" (click)="closeDialog('end')">Finalizar ejecución</button>
+        </div>
+      }
+    </div>
+  }
 </div>
 <div mat-dialog-actions align="end">
   <button mat-button mat-dialog-close>Cerrar</button>

+ 3 - 3
src/app/components/preventive-maintenance/active-orders/execution-dialog/execution-dialog.component.ts

@@ -111,8 +111,8 @@ export class ExecutionDialogComponent implements OnInit {
 }
 
 @Component({
-    selector: 'observations-dialog',
-    templateUrl: './observations-dialog.html',
-    standalone: false
+  selector: 'observations-dialog',
+  templateUrl: './observations-dialog.html',
+  standalone: false
 })
 export class ObservationsDialog {}

+ 18 - 1
src/app/components/preventive-maintenance/active-orders/order-execution-config/order-execution-config.component.ts

@@ -51,7 +51,24 @@ export class OrderExecutionConfigComponent implements OnInit {
   }
 
   ngOnInit(): void {
-    this.execDate = this._functionsService.orderDate(this._data.date);
+    let dateTimeArr = this._data.date.split(' ');
+    let dateArr = dateTimeArr[0].split('-');
+    let dateArrFn: string[] = [];
+
+    for(const item of dateArr){
+      if(item.includes('|')){
+        let itemArr = item.split('|');
+        dateArrFn.push(itemArr[0]);
+      }else{
+        dateArrFn.push(item);
+      }
+    }
+
+    let dateStr = dateArrFn.join('-');
+    dateTimeArr[0] = dateStr;
+
+    let dateTimeStr = dateTimeArr.join(' ');
+    this.execDate = this._functionsService.orderDate(dateTimeStr);
     this.idOrder = this._data.idOrder;
 
     this.getPreventiveOrder();

+ 1 - 1
src/app/components/template/template.component.ts

@@ -776,7 +776,7 @@ export class TemplateComponent implements OnInit {
     });
   }
 
-    openUploadData(){
+  openUploadData(){
     this._router.navigate(['sam/initial-data-upload'])
   }
 

+ 1 - 1
src/environments/environment.prod.ts

@@ -120,7 +120,7 @@ export const supportedFiles = [
 
 export const validateRFC = /^([A-ZÑ&]{3,4}) ?(?:- ?)?(\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])) ?(?:- ?)?([A-Z\d]{2})([A\d])$/;
 // export const socket = 'http://localhost:3200';
-export const socket = 'https://38934015f7aa.ngrok-free.app';
+export const socket = 'https://fd7e01aa9208.ngrok-free.app';
 // export const apiTemp = `http://192.168.100.105:8000/api/`;
 export const apiTemp = 'http://git.ittec.mx/sam/public/api/';