2021-07-27 21:19:09 +01:00
|
|
|
import { Injectable } from '@angular/core';
|
2021-08-30 10:24:46 +01:00
|
|
|
import { customTask, fullTask, fullTaskList } from '../models/dailyworktask.model';
|
2021-08-20 17:41:51 +01:00
|
|
|
import { AttachmentList } from '../models/Excludetask';
|
2021-08-05 11:47:09 +01:00
|
|
|
import { PermissionService } from '../OtherService/permission.service';
|
2021-08-26 13:48:29 +01:00
|
|
|
import { CustomTaskPipe } from '../pipes/custom-task.pipe';
|
2021-07-27 21:19:09 +01:00
|
|
|
import { ProcessesService } from '../services/processes.service';
|
2021-08-26 13:48:29 +01:00
|
|
|
import { DespachoStore } from '../store/despacho-store.service';
|
|
|
|
|
import { LoaderService } from 'src/app/store/loader.service'
|
2021-07-27 21:19:09 +01:00
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
2021-07-30 22:03:48 +01:00
|
|
|
export class DespachoService {
|
2021-07-27 21:19:09 +01:00
|
|
|
/**
|
|
|
|
|
* @description para terminar o
|
|
|
|
|
* 95 - signfica
|
|
|
|
|
* 98 - significa
|
|
|
|
|
*/
|
|
|
|
|
ActionTypeId: 95 | 98
|
|
|
|
|
|
|
|
|
|
action: "Arquivo" | "Reencaminhar"
|
|
|
|
|
|
2021-08-05 16:59:17 +01:00
|
|
|
actions: {
|
|
|
|
|
'Tarefa do Despacho': 'Tarefa de Despacho' | 'Concluir' | 'rexecucao'
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
customTaskPipe = new CustomTaskPipe()
|
|
|
|
|
despachoStore = DespachoStore;
|
|
|
|
|
|
|
|
|
|
constructor(
|
2021-07-27 21:19:09 +01:00
|
|
|
private processes: ProcessesService,
|
2021-08-26 13:48:29 +01:00
|
|
|
public p: PermissionService,
|
|
|
|
|
public LoaderService: LoaderService
|
|
|
|
|
) { }
|
2021-07-30 22:03:48 +01:00
|
|
|
|
2021-08-20 17:41:51 +01:00
|
|
|
arquivar(note:string, documents:AttachmentList, serialnumber) {
|
2021-07-29 15:40:24 +01:00
|
|
|
|
2021-07-27 21:19:09 +01:00
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
|
|
|
|
"action": "Arquivo",
|
|
|
|
|
"ActionTypeId": 95,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
2021-07-28 14:18:02 +01:00
|
|
|
|
2021-07-27 21:19:09 +01:00
|
|
|
return this.processes.CompleteTask(body)
|
|
|
|
|
}
|
2021-07-30 22:03:48 +01:00
|
|
|
|
2021-08-05 16:59:17 +01:00
|
|
|
// reencaminhar(note:string, documents:any, serialnumber) {
|
2021-07-27 21:19:09 +01:00
|
|
|
|
2021-08-05 16:59:17 +01:00
|
|
|
// let body = {
|
|
|
|
|
// "serialNumber": serialnumber,
|
|
|
|
|
// "action": "Reencaminhar",
|
|
|
|
|
// "ActionTypeId": 98,
|
|
|
|
|
// "dataFields": {
|
|
|
|
|
// "ReviewUserComment": note,
|
|
|
|
|
// },
|
|
|
|
|
// "AttachmentList" :documents,
|
|
|
|
|
// }
|
|
|
|
|
// return this.processes.CompleteTask(body)
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
executado(note:string, documents:any , serialnumber) {
|
|
|
|
|
|
2021-07-27 21:19:09 +01:00
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
2021-08-05 16:59:17 +01:00
|
|
|
"action": "Conhecimento",
|
|
|
|
|
"ActionTypeId": 104,
|
2021-07-27 21:19:09 +01:00
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
2021-08-05 16:59:17 +01:00
|
|
|
|
2021-07-27 21:19:09 +01:00
|
|
|
return this.processes.CompleteTask(body)
|
|
|
|
|
}
|
2021-08-05 16:59:17 +01:00
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
solicitarParecer({note ='', documents = [], serialnumber}) {
|
|
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
|
|
|
|
"action": "Conhecimento",
|
|
|
|
|
"ActionTypeId": 92,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.processes.CompleteTask(body)
|
2021-08-05 16:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
EfectuarDespacho({note = '', documents = [], serialnumber}) {
|
|
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
|
|
|
|
"action": "Conhecimento",
|
|
|
|
|
"ActionTypeId": 94,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.processes.CompleteTask(body)
|
2021-08-05 16:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-20 17:41:51 +01:00
|
|
|
reexecute({note, documents, serialnumber}) {
|
2021-07-27 21:19:09 +01:00
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
2021-08-05 16:59:17 +01:00
|
|
|
"action": "Reexecução",
|
|
|
|
|
"ActionTypeId": 100000010,
|
2021-07-27 21:19:09 +01:00
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.processes.CompleteTask(body)
|
|
|
|
|
}
|
2021-07-30 22:03:48 +01:00
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
/**
|
|
|
|
|
* @description efetuar despacho
|
|
|
|
|
*/
|
2021-08-05 11:47:09 +01:00
|
|
|
CompleteTask({serialNumber}) {
|
|
|
|
|
|
|
|
|
|
const body = {
|
|
|
|
|
"serialNumber": serialNumber,
|
|
|
|
|
"action": "Despacho",
|
|
|
|
|
"ActionTypeId": 94,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": '',
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :null,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.processes.CompleteTask(body)
|
|
|
|
|
}
|
2021-07-27 21:26:31 +01:00
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
|
2021-08-06 09:42:34 +01:00
|
|
|
// Finalizar({serialNumber}) {
|
|
|
|
|
// const body = {
|
|
|
|
|
// "serialNumber": serialNumber,
|
|
|
|
|
// "action": "Conhecimento",
|
|
|
|
|
// "ActionTypeId": 104,
|
|
|
|
|
// "dataFields": {
|
|
|
|
|
// "ReviewUserComment": '',
|
|
|
|
|
// },
|
|
|
|
|
// "AttachmentList" :null,
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2021-08-05 16:08:49 +01:00
|
|
|
|
2021-08-05 11:47:09 +01:00
|
|
|
sendExpedienteToPending(serialnumber) {
|
2021-07-27 21:26:31 +01:00
|
|
|
return this.processes.SetTaskToPending(serialnumber)
|
|
|
|
|
}
|
2021-08-05 11:47:09 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param body any
|
|
|
|
|
* @returns promise
|
|
|
|
|
* @description for both profile PR and MDGPR
|
|
|
|
|
*/
|
|
|
|
|
createDespacho(body: any) {
|
|
|
|
|
if(this.p.userRole(['PR'])) {
|
|
|
|
|
return this.processes.postDespatchoPr(body)
|
|
|
|
|
} else {
|
|
|
|
|
return this.processes.postDespatcho(body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 16:46:57 +01:00
|
|
|
createParecer(body: any) {
|
|
|
|
|
if(this.p.userRole(['PR'])) {
|
|
|
|
|
return this.processes.postParecerPr(body)
|
|
|
|
|
} else {
|
|
|
|
|
return this.processes.postParecer(body)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-20 17:41:51 +01:00
|
|
|
generateDiploma({note = '', documents = [], serialnumber}) {
|
|
|
|
|
let body = {
|
|
|
|
|
"serialNumber": serialnumber,
|
|
|
|
|
"action": "Reencaminhar",
|
|
|
|
|
"ActionTypeId": 99999839,
|
|
|
|
|
"dataFields": {
|
|
|
|
|
"ReviewUserComment": note,
|
|
|
|
|
},
|
|
|
|
|
"AttachmentList" :documents,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.processes.CompleteTask(body)
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
async getList({updateStore = false}): Promise<customTask[]> | null {
|
2021-08-26 13:48:29 +01:00
|
|
|
|
2021-08-27 09:48:51 +01:00
|
|
|
if (this.LoaderService.loading) {
|
|
|
|
|
return this.despachoStore.list
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
this.LoaderService.push({})
|
|
|
|
|
|
2021-08-30 10:24:46 +01:00
|
|
|
let result: fullTaskList[] = []
|
|
|
|
|
let despachoList: customTask[] = [];
|
2021-08-26 13:48:29 +01:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
result = await this.processes.GetTasksList("Despacho", false).toPromise();
|
2021-08-30 10:24:46 +01:00
|
|
|
result = result.filter((data:fullTaskList) => data.workflowInstanceDataFields.Status == "Active")
|
|
|
|
|
result.forEach((element, index) => {
|
|
|
|
|
|
|
|
|
|
let task: customTask = this.customTaskPipe.transform(element);
|
|
|
|
|
despachoList.push(task);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
despachoList = this.sortArrayISODate(despachoList).reverse();
|
|
|
|
|
|
|
|
|
|
if(updateStore) {
|
|
|
|
|
this.despachoStore.reset(despachoList);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 13:48:29 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
this.LoaderService.pop({})
|
2021-08-30 10:24:46 +01:00
|
|
|
return this.despachoStore.list
|
2021-08-26 13:48:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sortArrayISODate(myArray: any) {
|
|
|
|
|
return myArray.sort(function(a, b) {
|
|
|
|
|
return (a.CreateDate < b.CreateDate) ? -1 : ((a.CreateDate > b.CreateDate) ? 1 : 0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-27 21:19:09 +01:00
|
|
|
}
|