| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- import { HttpClient, HttpHeaders } from '@angular/common/http';
- import { Injectable } from '@angular/core';
- import { map } from 'rxjs';
- import { apiTemp } from '../../environments/environment.prod';
- @Injectable({
- providedIn: 'root',
- })
- export class PreventiveMaintenanceService {
- constructor(private _http: HttpClient) {}
- getWorkOrdersByDay(
- day: number,
- month: number,
- year: number,
- idUser: string,
- line: number
- ) {
- return this.getQuery(
- `get-work-orders-by-day/${day}/${month}/${year}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getWorkOrder(id: string, idUser: string, line: number) {
- return this.getQuery(`get-work-order/${id}/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getStartedWorkOrders(idUser: string, line: number) {
- return this.getQuery(`get-started-work-orders/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getExecRegister(date: string, idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `get-exec-register/${date}/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getWorkOrders(idUser: string, line: number) {
- return this.getQuery(`get-work-orders/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getActiveWorkOrders(idUser: string, line: number) {
- return this.getQuery(`get-active-orders/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getPreventiveCalendar(
- fecIni: string,
- fecFin: string,
- idUser: string,
- line: number
- ) {
- return this.getQuery(
- `get-preventive-calendar/${fecIni}/${fecFin}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getUnprogrammedVisits(idUser: string, line: number) {
- return this.getQuery(`get-unprogrammed-visits/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getUnprogrammedVisit(idVisit: string, idUser: string, line: number) {
- return this.getQuery(
- `get-unprogrammed-visit/${idVisit}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getVisitAttendance(idVisit: string, idUser: string, line: number) {
- return this.getQuery(
- `get-visit-attendance/${idVisit}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getVisitStaff(idVisit: string, idUser: string, line: number) {
- return this.getQuery(`get-visit-staff/${idVisit}/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getMaintenanceSimulation(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `get-maintenance-simulation/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getOrderWithActivator(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `get-order-with-activator/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- printOrderSimulation(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `print-order-simulation/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- printOrderDetails(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `print-order-details/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- extractMaintenancePlan(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `extract-maintenance-plan/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getMaintenancePlanAnalysis(idFile: string, idUser: string, line: number) {
- return this.getQuery(
- `get-maintenance-plan-analysis/${idFile}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getFileToMSProject(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `get-file-to-ms-project/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getOrderStaff(idOrder: string, idUser: string, line: number) {
- return this.getQuery(`get-order-staff/${idOrder}/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getOrderExecutionDetails(idExecution: string, idUser: string, line: number) {
- return this.getQuery(
- `get-order-execution-details/${idExecution}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getWorkOrdersByEquipment(
- equipmentCode: string,
- idUser: string,
- line: number
- ) {
- return this.getQuery(
- `get-work-orders-by-equipment/${equipmentCode}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- getVisit(id: string, idUser: string, line: number) {
- return this.getQuery(`get-visit/${id}/${idUser}/${line}`).pipe(
- map((data: any) => data)
- );
- }
- getVisitStatusHistory(idOrder: string, idUser: string, line: number) {
- return this.getQuery(
- `get-visit-status-history/${idOrder}/${idUser}/${line}`
- ).pipe(map((data: any) => data));
- }
- assignOperariosToPreventiveVisit(body: any) {
- return this.postQuery('assign-operarios-to-visit', body).pipe(
- map((data: any) => data)
- );
- }
- setVisitAttendance(body: any) {
- return this.postQuery('attend-preventive-visit', body).pipe(
- map((data: any) => data)
- );
- }
- registerWorkOrder(body: any) {
- return this.postQuery('register-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- executePreventiveWorkOrder(body: any) {
- return this.postQuery('execute-preventive-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- cancelWorkOrder(body: any) {
- return this.postQuery('cancel-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- deleteWorkOrder(body: any) {
- return this.postQuery('delete-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- updateWorkOrder(body: any) {
- return this.postQuery('update-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- endOrderExecution(body: any) {
- return this.postQuery('end-order-execution', body).pipe(
- map((data: any) => data)
- );
- }
- copyWorkOrder(body: any) {
- return this.postQuery('copy-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- savePresetWorkOrder(body: any) {
- return this.postQuery('save-preset-work-order', body).pipe(
- map((data: any) => data)
- );
- }
- newUnprogrammedOrder(body: any) {
- return this.postQuery('new-unprogrammed-order', body).pipe(
- map((data: any) => data)
- );
- }
- updateVisitStatus(body: any) {
- return this.postQuery('update-visit-status', body).pipe(
- map((data: any) => data)
- );
- }
- startVisit(body: any) {
- return this.postQuery('start-preventive-visit', body).pipe(
- map((data: any) => data)
- );
- }
- registerOperatorClosingComment(body: any) {
- return this.postQuery('register-operator-closing-comment', body).pipe(
- map((data: any) => data)
- );
- }
- updateOrderStatus(body: any) {
- return this.postQuery('update-order-status', body).pipe(
- map((data: any) => data)
- );
- }
- setBudgetAnalysis(body: any) {
- return this.postQuery('set-budget-analysis', body).pipe(
- map((data: any) => data)
- );
- }
- updateOrderWithActivator(body: any) {
- return this.postQuery('update-order-with-activator', body).pipe(
- map((data: any) => data)
- );
- }
- saveOrderSimulation(body: any) {
- return this.postQuery('save-order-simulation', body).pipe(
- map((data: any) => data)
- );
- }
- getQuery(query: string, tk?: string) {
- const URL = `${apiTemp}${query}`;
- let token = '';
- if (tk == undefined || tk == null || tk == '') {
- token = `Bearer ${localStorage.getItem('token')!}`;
- } else {
- token = `Bearer ${tk!}`;
- }
- return this._http.get(URL, {
- headers: new HttpHeaders({
- Authorization: token,
- }),
- });
- }
- postQuery(query: string, body: any) {
- const JWT = `Bearer ${localStorage.getItem('token')}`;
- const URL = `${apiTemp}${query}`;
- return this._http.post(URL, body, {
- headers: new HttpHeaders({
- Authorization: JWT!,
- }),
- });
- }
- }
|