flit-modulo-exportacoes 1.0.11 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dao/elastic-base.d.ts +10 -0
- package/dist/dao/elastic-base.js +38 -0
- package/dist/dao/empresas-elastic.d.ts +6 -0
- package/dist/dao/empresas-elastic.js +38 -0
- package/dist/dao/empresas-feriado-elastic.d.ts +9 -0
- package/dist/dao/empresas-feriado-elastic.js +43 -0
- package/dist/dao/eventos-exportacoes-elastic.d.ts +9 -0
- package/dist/dao/eventos-exportacoes-elastic.js +45 -0
- package/dist/dao/feriados-elastic.d.ts +10 -0
- package/dist/dao/feriados-elastic.js +56 -0
- package/dist/dao/jornadas-elastic.d.ts +11 -0
- package/dist/dao/jornadas-elastic.js +61 -0
- package/dist/dao/usuarios-elastic.d.ts +6 -0
- package/dist/dao/usuarios-elastic.js +33 -0
- package/dist/eventos-exportacoes-model.d.ts +15 -15
- package/dist/eventos-exportacoes-model.js +6 -6
- package/dist/index.d.ts +10 -1
- package/dist/index.js +113 -31
- package/dist/models.d.ts +11 -6
- package/dist/models.js +10 -5
- package/dist/unificacao-eventos-repetidos.d.ts +1 -1
- package/dist/unificacao-eventos-repetidos.js +8 -7
- package/dist/utils.d.ts +17 -0
- package/dist/utils.js +141 -0
- package/package.json +31 -28
- package/tslint.json +118 -118
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Client } from '@elastic/elasticsearch';
|
|
2
|
+
import { SearchHit, SearchResponse } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class ElasticBase {
|
|
4
|
+
protected readonly elasticClient: Client;
|
|
5
|
+
protected readonly totalRegistrosFiltradosElastic = 500;
|
|
6
|
+
constructor(elasticClient: Client);
|
|
7
|
+
private searchScrollObjectElastic;
|
|
8
|
+
private adicionarRegistrosPaginacaoElastic;
|
|
9
|
+
protected retornaTodosDadosPaginacaoElastic(filtroInicial: SearchResponse): Promise<Array<SearchHit<any>>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElasticBase = void 0;
|
|
4
|
+
class ElasticBase {
|
|
5
|
+
elasticClient;
|
|
6
|
+
totalRegistrosFiltradosElastic = 500;
|
|
7
|
+
constructor(elasticClient) {
|
|
8
|
+
this.elasticClient = elasticClient;
|
|
9
|
+
}
|
|
10
|
+
async searchScrollObjectElastic(scrollId) {
|
|
11
|
+
return await this.elasticClient.scroll({
|
|
12
|
+
scroll: '1m',
|
|
13
|
+
scroll_id: scrollId
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async adicionarRegistrosPaginacaoElastic({ scrollId, retorno }) {
|
|
17
|
+
let objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
|
|
18
|
+
while ((objetosPaginacao?.hits?.hits ?? []).length > 0) {
|
|
19
|
+
(objetosPaginacao?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
|
|
20
|
+
objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async retornaTodosDadosPaginacaoElastic(filtroInicial) {
|
|
24
|
+
const retorno = new Array();
|
|
25
|
+
(filtroInicial?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
|
|
26
|
+
if (filtroInicial?._scroll_id) {
|
|
27
|
+
if ((filtroInicial?.hits?.total ?? 0) > this.totalRegistrosFiltradosElastic) {
|
|
28
|
+
await this.adicionarRegistrosPaginacaoElastic({
|
|
29
|
+
retorno: retorno,
|
|
30
|
+
scrollId: filtroInicial?._scroll_id
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
await this.elasticClient.clearScroll({ scroll_id: filtroInicial?._scroll_id });
|
|
34
|
+
}
|
|
35
|
+
return retorno;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ElasticBase = ElasticBase;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class EmpresasElastic extends ElasticBase {
|
|
4
|
+
private internalGetEmpresasElastic;
|
|
5
|
+
getEmpresasElastic(contaId: string): Promise<Array<SearchHit<any>>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmpresasElastic = void 0;
|
|
4
|
+
const elastic_base_1 = require("./elastic-base");
|
|
5
|
+
class EmpresasElastic extends elastic_base_1.ElasticBase {
|
|
6
|
+
async internalGetEmpresasElastic(contaId) {
|
|
7
|
+
return await this.elasticClient.search({
|
|
8
|
+
scroll: '1m',
|
|
9
|
+
index: 'contas_jornadas',
|
|
10
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
11
|
+
_source: [
|
|
12
|
+
'i_id',
|
|
13
|
+
'endereco.uf',
|
|
14
|
+
'endereco.cidade'
|
|
15
|
+
],
|
|
16
|
+
query: {
|
|
17
|
+
bool: {
|
|
18
|
+
must: [{
|
|
19
|
+
match: {
|
|
20
|
+
i_parent_id: contaId
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
match: {
|
|
24
|
+
excluido: false
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
sort: [{
|
|
30
|
+
i_id: 'asc'
|
|
31
|
+
}]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async getEmpresasElastic(contaId) {
|
|
35
|
+
return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEmpresasElastic(contaId));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.EmpresasElastic = EmpresasElastic;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class EmpresasFeriadoElastic extends ElasticBase {
|
|
4
|
+
private internalGeEmpresasFeriadoElastic;
|
|
5
|
+
getEmpresasFeriadoElastic({ empresaId, feriadoId }: {
|
|
6
|
+
empresaId: string;
|
|
7
|
+
feriadoId: string;
|
|
8
|
+
}): Promise<Array<SearchHit<any>>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmpresasFeriadoElastic = void 0;
|
|
4
|
+
const elastic_base_1 = require("./elastic-base");
|
|
5
|
+
class EmpresasFeriadoElastic extends elastic_base_1.ElasticBase {
|
|
6
|
+
async internalGeEmpresasFeriadoElastic({ empresaId, feriadoId }) {
|
|
7
|
+
return await this.elasticClient.search({
|
|
8
|
+
scroll: '1m',
|
|
9
|
+
index: 'contas_feriados_empresasferiado',
|
|
10
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
11
|
+
_source: [
|
|
12
|
+
'i_id'
|
|
13
|
+
],
|
|
14
|
+
query: {
|
|
15
|
+
bool: {
|
|
16
|
+
must: [{
|
|
17
|
+
match: {
|
|
18
|
+
i_parent_id: feriadoId
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
match: {
|
|
22
|
+
'ref.i_id': empresaId
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
match: {
|
|
26
|
+
excluido: false
|
|
27
|
+
}
|
|
28
|
+
}]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
sort: [{
|
|
32
|
+
i_id: 'asc'
|
|
33
|
+
}]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async getEmpresasFeriadoElastic({ empresaId, feriadoId }) {
|
|
37
|
+
return await this.retornaTodosDadosPaginacaoElastic(await this.internalGeEmpresasFeriadoElastic({
|
|
38
|
+
empresaId: empresaId,
|
|
39
|
+
feriadoId: feriadoId
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.EmpresasFeriadoElastic = EmpresasFeriadoElastic;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class EventosExportacoesElastic extends ElasticBase {
|
|
4
|
+
private internalGetEventosExportacoesElastic;
|
|
5
|
+
getEventosExportacoesElastic({ contaId, tabelaEventosId }: {
|
|
6
|
+
contaId: string;
|
|
7
|
+
tabelaEventosId: string;
|
|
8
|
+
}): Promise<SearchHit<any>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EventosExportacoesElastic = void 0;
|
|
4
|
+
const elastic_base_1 = require("./elastic-base");
|
|
5
|
+
class EventosExportacoesElastic extends elastic_base_1.ElasticBase {
|
|
6
|
+
async internalGetEventosExportacoesElastic({ contaId, tabelaEventosId }) {
|
|
7
|
+
return await this.elasticClient.search({
|
|
8
|
+
scroll: '1m',
|
|
9
|
+
index: 'contas_eventosexportacoes',
|
|
10
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
11
|
+
_source: [
|
|
12
|
+
'eventos',
|
|
13
|
+
'forma_envio_faltas'
|
|
14
|
+
],
|
|
15
|
+
query: {
|
|
16
|
+
bool: {
|
|
17
|
+
must: [{
|
|
18
|
+
match: {
|
|
19
|
+
i_parent_id: contaId
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
match: {
|
|
23
|
+
i_id: tabelaEventosId
|
|
24
|
+
}
|
|
25
|
+
}, {
|
|
26
|
+
match: {
|
|
27
|
+
excluido: false
|
|
28
|
+
}
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
sort: [{
|
|
33
|
+
i_id: 'asc'
|
|
34
|
+
}]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async getEventosExportacoesElastic({ contaId, tabelaEventosId }) {
|
|
38
|
+
const retorno = await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEventosExportacoesElastic({
|
|
39
|
+
contaId: contaId,
|
|
40
|
+
tabelaEventosId: tabelaEventosId
|
|
41
|
+
}));
|
|
42
|
+
return retorno[0];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.EventosExportacoesElastic = EventosExportacoesElastic;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class FeriadosElastic extends ElasticBase {
|
|
4
|
+
private internalGetFeriadosElastic;
|
|
5
|
+
getFeriadosElastic({ contaId, dataFinal, dataInicial }: {
|
|
6
|
+
contaId: string;
|
|
7
|
+
dataFinal: Date;
|
|
8
|
+
dataInicial: Date;
|
|
9
|
+
}): Promise<Array<SearchHit<any>>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FeriadosElastic = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
const elastic_base_1 = require("./elastic-base");
|
|
9
|
+
class FeriadosElastic extends elastic_base_1.ElasticBase {
|
|
10
|
+
async internalGetFeriadosElastic({ contaId, dataFinal, dataInicial }) {
|
|
11
|
+
return await this.elasticClient.search({
|
|
12
|
+
scroll: '1m',
|
|
13
|
+
index: 'contas_feriados',
|
|
14
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
15
|
+
_source: [
|
|
16
|
+
'uf',
|
|
17
|
+
'i_id',
|
|
18
|
+
'tipo',
|
|
19
|
+
'data',
|
|
20
|
+
'municipio',
|
|
21
|
+
'todas_empresas'
|
|
22
|
+
],
|
|
23
|
+
query: {
|
|
24
|
+
bool: {
|
|
25
|
+
must: [{
|
|
26
|
+
match: {
|
|
27
|
+
i_parent_id: contaId
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
match: {
|
|
31
|
+
excluido: false
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
range: {
|
|
35
|
+
data_hora: {
|
|
36
|
+
gte: (0, moment_1.default)(dataInicial).format('YYYY-MM-DDTHH:mm:ss.SSS'),
|
|
37
|
+
lte: (0, moment_1.default)(dataFinal).format('YYYY-MM-DDTHH:mm:ss.SSS')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
sort: [{
|
|
44
|
+
i_id: 'asc'
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async getFeriadosElastic({ contaId, dataFinal, dataInicial }) {
|
|
49
|
+
return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetFeriadosElastic({
|
|
50
|
+
contaId: contaId,
|
|
51
|
+
dataFinal: dataFinal,
|
|
52
|
+
dataInicial: dataInicial
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.FeriadosElastic = FeriadosElastic;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class JornadasElastic extends ElasticBase {
|
|
4
|
+
private internalGetJornadasElastic;
|
|
5
|
+
getJornadasElastic({ contaId, dataFinal, usuarioId, dataInicial }: {
|
|
6
|
+
contaId: string;
|
|
7
|
+
dataFinal: Date;
|
|
8
|
+
usuarioId: string;
|
|
9
|
+
dataInicial: Date;
|
|
10
|
+
}): Promise<Array<SearchHit<any>>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.JornadasElastic = void 0;
|
|
7
|
+
const moment_1 = __importDefault(require("moment"));
|
|
8
|
+
const elastic_base_1 = require("./elastic-base");
|
|
9
|
+
class JornadasElastic extends elastic_base_1.ElasticBase {
|
|
10
|
+
async internalGetJornadasElastic({ fim, inicio, contaId, usuarioId }) {
|
|
11
|
+
const queryMust = new Array();
|
|
12
|
+
queryMust.push({
|
|
13
|
+
match: {
|
|
14
|
+
i_parent_id: contaId
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
queryMust.push({
|
|
18
|
+
match: {
|
|
19
|
+
'usuario.uid': usuarioId
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
queryMust.push({
|
|
23
|
+
range: {
|
|
24
|
+
data_hora: {
|
|
25
|
+
gte: (0, moment_1.default)(inicio).format('YYYY-MM-DDTHH:mm:ss.SSS'),
|
|
26
|
+
lte: (0, moment_1.default)(fim).format('YYYY-MM-DDTHH:mm:ss.SSS')
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return await this.elasticClient.search({
|
|
31
|
+
scroll: '1m',
|
|
32
|
+
index: 'contas_jornadas',
|
|
33
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
34
|
+
_source: [
|
|
35
|
+
'data_hora',
|
|
36
|
+
'usuario.uid',
|
|
37
|
+
'jornada_prevista',
|
|
38
|
+
'jornada_realizada',
|
|
39
|
+
'usuario.cargo.nome',
|
|
40
|
+
'marcacoes_ignoradas'
|
|
41
|
+
],
|
|
42
|
+
query: {
|
|
43
|
+
bool: {
|
|
44
|
+
must: queryMust
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
sort: [{
|
|
48
|
+
i_id: 'asc'
|
|
49
|
+
}]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async getJornadasElastic({ contaId, dataFinal, usuarioId, dataInicial }) {
|
|
53
|
+
return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetJornadasElastic({
|
|
54
|
+
fim: dataFinal,
|
|
55
|
+
contaId: contaId,
|
|
56
|
+
inicio: dataInicial,
|
|
57
|
+
usuarioId: usuarioId
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.JornadasElastic = JornadasElastic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ElasticBase } from './elastic-base';
|
|
2
|
+
import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
|
|
3
|
+
export declare class UsuariosElastic extends ElasticBase {
|
|
4
|
+
private internalGetUsuariosElastic;
|
|
5
|
+
getUsuariosElastic(idsUsuarios: Array<string>): Promise<Array<SearchHit<any>>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsuariosElastic = void 0;
|
|
4
|
+
const elastic_base_1 = require("./elastic-base");
|
|
5
|
+
class UsuariosElastic extends elastic_base_1.ElasticBase {
|
|
6
|
+
async internalGetUsuariosElastic(idsUsuarios) {
|
|
7
|
+
return await this.elasticClient.search({
|
|
8
|
+
scroll: '1m',
|
|
9
|
+
index: 'usuarios',
|
|
10
|
+
size: this.totalRegistrosFiltradosElastic,
|
|
11
|
+
_source: [
|
|
12
|
+
'pis',
|
|
13
|
+
'i_id'
|
|
14
|
+
],
|
|
15
|
+
query: {
|
|
16
|
+
bool: {
|
|
17
|
+
filter: {
|
|
18
|
+
terms: {
|
|
19
|
+
i_id: idsUsuarios
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
sort: [{
|
|
25
|
+
i_id: 'asc'
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async getUsuariosElastic(idsUsuarios) {
|
|
30
|
+
return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetUsuariosElastic(idsUsuarios));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.UsuariosElastic = UsuariosElastic;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
export declare enum EnumTipoEventosExportacoes {
|
|
2
|
-
Alterdata = "ALTERDATA",
|
|
3
2
|
Dominio = "DOMINIO",
|
|
4
3
|
Najason = "NAJASON",
|
|
5
|
-
NetSpeed = "NETSPEED",
|
|
6
4
|
Prosoft = "PROSOFT",
|
|
7
|
-
Questor = "QUESTOR"
|
|
5
|
+
Questor = "QUESTOR",
|
|
6
|
+
NetSpeed = "NETSPEED",
|
|
7
|
+
Alterdata = "ALTERDATA"
|
|
8
8
|
}
|
|
9
9
|
export declare enum EnumFormaEnvioFaltasEventosExportacoes {
|
|
10
|
-
|
|
10
|
+
Dias = "DIAS",
|
|
11
11
|
Horas = "HORAS",
|
|
12
|
-
|
|
12
|
+
Minutos = "MINUTOS"
|
|
13
13
|
}
|
|
14
14
|
export type PropsCodigosEventosExportacoes<T = any> = {
|
|
15
15
|
[Property in keyof CodigosEventosExportacoes]: T;
|
|
16
16
|
};
|
|
17
17
|
export interface EventosExportacoes {
|
|
18
|
-
descricao: string;
|
|
19
|
-
forma_envio_faltas: EnumFormaEnvioFaltasEventosExportacoes;
|
|
20
|
-
eventos: CodigosEventosExportacoes;
|
|
21
18
|
excluido: boolean;
|
|
19
|
+
descricao: string;
|
|
22
20
|
tipo: EnumTipoEventosExportacoes;
|
|
21
|
+
eventos: CodigosEventosExportacoes;
|
|
22
|
+
forma_envio_faltas: EnumFormaEnvioFaltasEventosExportacoes;
|
|
23
23
|
}
|
|
24
24
|
interface CodigosEventosExportacoes {
|
|
25
|
-
atraso: string;
|
|
26
25
|
falta: string;
|
|
26
|
+
atraso: string;
|
|
27
27
|
hora_normal?: string;
|
|
28
|
-
hora_extra_domingo?: string;
|
|
29
|
-
hora_extra_feriado: string;
|
|
30
|
-
hora_extra_sabado?: string;
|
|
31
28
|
hora_extra: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
hora_extra_sabado?: string;
|
|
30
|
+
hora_extra_feriado: string;
|
|
31
|
+
hora_extra_domingo?: string;
|
|
35
32
|
hora_extra_noturna: string;
|
|
33
|
+
hora_extra_noturna_sabado?: string;
|
|
34
|
+
hora_extra_noturna_feriado: string;
|
|
35
|
+
hora_extra_noturna_domingo?: string;
|
|
36
36
|
hora_extra_intrajornada?: string;
|
|
37
37
|
hora_extra_intrajornada_com_reducao?: string;
|
|
38
38
|
hora_noturna: string;
|
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EnumFormaEnvioFaltasEventosExportacoes = exports.EnumTipoEventosExportacoes = void 0;
|
|
4
4
|
var EnumTipoEventosExportacoes;
|
|
5
5
|
(function (EnumTipoEventosExportacoes) {
|
|
6
|
-
EnumTipoEventosExportacoes["Alterdata"] = "ALTERDATA";
|
|
7
6
|
EnumTipoEventosExportacoes["Dominio"] = "DOMINIO";
|
|
8
7
|
EnumTipoEventosExportacoes["Najason"] = "NAJASON";
|
|
9
|
-
EnumTipoEventosExportacoes["NetSpeed"] = "NETSPEED";
|
|
10
8
|
EnumTipoEventosExportacoes["Prosoft"] = "PROSOFT";
|
|
11
9
|
EnumTipoEventosExportacoes["Questor"] = "QUESTOR";
|
|
12
|
-
|
|
10
|
+
EnumTipoEventosExportacoes["NetSpeed"] = "NETSPEED";
|
|
11
|
+
EnumTipoEventosExportacoes["Alterdata"] = "ALTERDATA";
|
|
12
|
+
})(EnumTipoEventosExportacoes || (exports.EnumTipoEventosExportacoes = EnumTipoEventosExportacoes = {}));
|
|
13
13
|
var EnumFormaEnvioFaltasEventosExportacoes;
|
|
14
14
|
(function (EnumFormaEnvioFaltasEventosExportacoes) {
|
|
15
|
-
EnumFormaEnvioFaltasEventosExportacoes["Minutos"] = "MINUTOS";
|
|
16
|
-
EnumFormaEnvioFaltasEventosExportacoes["Horas"] = "HORAS";
|
|
17
15
|
EnumFormaEnvioFaltasEventosExportacoes["Dias"] = "DIAS";
|
|
18
|
-
|
|
16
|
+
EnumFormaEnvioFaltasEventosExportacoes["Horas"] = "HORAS";
|
|
17
|
+
EnumFormaEnvioFaltasEventosExportacoes["Minutos"] = "MINUTOS";
|
|
18
|
+
})(EnumFormaEnvioFaltasEventosExportacoes || (exports.EnumFormaEnvioFaltasEventosExportacoes = EnumFormaEnvioFaltasEventosExportacoes = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import { Client } from '@elastic/elasticsearch';
|
|
1
2
|
import { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportar, ValoresEventosExportacao } from './models';
|
|
2
3
|
export declare function validarDadosPayload(data: PayloadExportacaoPadrao, fn: () => Array<string>): boolean;
|
|
4
|
+
export declare function calcularValoresExportacao({ contaId, dataFinal, usuarioId, dataInicial, elasticClient, tabelaEventosId, }: {
|
|
5
|
+
contaId: string;
|
|
6
|
+
dataFinal: Date;
|
|
7
|
+
usuarioId: string;
|
|
8
|
+
dataInicial: Date;
|
|
9
|
+
elasticClient: Client;
|
|
10
|
+
tabelaEventosId: string;
|
|
11
|
+
}): Promise<ValoresEventosExportacao>;
|
|
3
12
|
export declare function retornaValorEvento(tipoEvento: TipoEventoExportacao, valoresEventos: ValoresEventosExportacao): number;
|
|
4
13
|
export declare function processarTiposEventosExportar(tiposEventos: Array<TiposEventosExportar>): {
|
|
5
14
|
enviarFaltas: boolean;
|
|
@@ -15,6 +24,6 @@ export declare function processarTiposEventosExportar(tiposEventos: Array<TiposE
|
|
|
15
24
|
enviarMinutosExtrasNoturnosDom: boolean;
|
|
16
25
|
enviarMinutosExtrasNoturnosFer: boolean;
|
|
17
26
|
enviarMinutosExtrasIntrajornada: boolean;
|
|
18
|
-
enviarMinutosExtrasIntrajornadaComReducao: boolean;
|
|
19
27
|
enviarMinutosExtrasNoturnosSegSex: boolean;
|
|
28
|
+
enviarMinutosExtrasIntrajornadaComReducao: boolean;
|
|
20
29
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.processarTiposEventosExportar = exports.retornaValorEvento = exports.validarDadosPayload = void 0;
|
|
3
|
+
exports.processarTiposEventosExportar = exports.retornaValorEvento = exports.calcularValoresExportacao = exports.validarDadosPayload = void 0;
|
|
4
|
+
const jornadas_elastic_1 = require("./dao/jornadas-elastic");
|
|
5
|
+
const feriados_elastic_1 = require("./dao/feriados-elastic");
|
|
6
|
+
const flit_calcular_jornada_1 = require("flit-calcular-jornada");
|
|
7
|
+
const unificacao_eventos_repetidos_1 = require("./unificacao-eventos-repetidos");
|
|
8
|
+
const eventos_exportacoes_elastic_1 = require("./dao/eventos-exportacoes-elastic");
|
|
9
|
+
const eventos_exportacoes_model_1 = require("./eventos-exportacoes-model");
|
|
4
10
|
const models_1 = require("./models");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
5
12
|
function validarCampo(fn, fieldName, campo) {
|
|
6
13
|
if (!campo || campo.length <= 0) {
|
|
7
14
|
fn().push(`${fieldName} não informada.`);
|
|
@@ -15,6 +22,96 @@ function validarDadosPayload(data, fn) {
|
|
|
15
22
|
return fn().length === 0;
|
|
16
23
|
}
|
|
17
24
|
exports.validarDadosPayload = validarDadosPayload;
|
|
25
|
+
async function calcularValoresExportacao({ contaId, dataFinal, usuarioId, dataInicial, elasticClient, tabelaEventosId, }) {
|
|
26
|
+
const jornadas = await new jornadas_elastic_1.JornadasElastic(elasticClient).getJornadasElastic({
|
|
27
|
+
contaId: contaId,
|
|
28
|
+
usuarioId: usuarioId,
|
|
29
|
+
dataFinal: dataFinal,
|
|
30
|
+
dataInicial: dataInicial
|
|
31
|
+
});
|
|
32
|
+
const feriados = await new feriados_elastic_1.FeriadosElastic(elasticClient).getFeriadosElastic({
|
|
33
|
+
contaId: contaId,
|
|
34
|
+
dataFinal: dataFinal,
|
|
35
|
+
dataInicial: dataInicial
|
|
36
|
+
});
|
|
37
|
+
const tabelaEventos = await new eventos_exportacoes_elastic_1.EventosExportacoesElastic(elasticClient).getEventosExportacoesElastic({
|
|
38
|
+
contaId: contaId,
|
|
39
|
+
tabelaEventosId: tabelaEventosId
|
|
40
|
+
});
|
|
41
|
+
const formaEnvioFaltas = (tabelaEventos._source?.forma_envio_faltas ?? eventos_exportacoes_model_1.EnumFormaEnvioFaltasEventosExportacoes.Dias);
|
|
42
|
+
const valoresEventos = {
|
|
43
|
+
ValorFaltas: 0,
|
|
44
|
+
ValorAtraso: 0,
|
|
45
|
+
ValorNormal: 0,
|
|
46
|
+
ValorNoturno: 0,
|
|
47
|
+
ValorExtraSegSex: 0,
|
|
48
|
+
ValorExtraSabado: 0,
|
|
49
|
+
ValorExtraDomingo: 0,
|
|
50
|
+
ValorExtraFeriado: 0,
|
|
51
|
+
ValorNoturnoTotal: 0,
|
|
52
|
+
ValorExtraIntrajornada: 0,
|
|
53
|
+
ValorExtraNoturnoSegSex: 0,
|
|
54
|
+
ValorExtraNoturnoSabado: 0,
|
|
55
|
+
ValorExtraNoturnoDomingo: 0,
|
|
56
|
+
ValorExtraNoturnoFeriado: 0,
|
|
57
|
+
ValorExtraIntrajornadaComReducao: 0
|
|
58
|
+
};
|
|
59
|
+
for (const jornadaElastic of jornadas) {
|
|
60
|
+
const jornada = jornadaElastic._source ?? {};
|
|
61
|
+
if ((0, utils_1.colaboradorFaltou)(jornada.jornada_realizada)) {
|
|
62
|
+
if (formaEnvioFaltas === eventos_exportacoes_model_1.EnumFormaEnvioFaltasEventosExportacoes.Dias) {
|
|
63
|
+
valoresEventos.ValorFaltas += 1;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const minutosFalta = (0, utils_1.retornaNumeroMinutosPrevistosEscala)(jornada.jornada_prevista);
|
|
67
|
+
valoresEventos.ValorFaltas += (0, utils_1.arredondarTempoDecimal)(minutosFalta / (formaEnvioFaltas === eventos_exportacoes_model_1.EnumFormaEnvioFaltasEventosExportacoes.Horas ? 60 : 1), 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
valoresEventos.ValorNormal += jornada.horas_normais ?? 0;
|
|
71
|
+
valoresEventos.ValorNoturno += jornada.horas_noturnas ?? 0;
|
|
72
|
+
valoresEventos.ValorNoturnoTotal += jornada.horas_noturnas ?? 0;
|
|
73
|
+
valoresEventos.ValorNoturnoTotal += jornada.horas_noturnas_extras ?? 0;
|
|
74
|
+
if ((jornada.regime_compensacao ?? flit_calcular_jornada_1.RegimesCompensacao.HorasExtras) === flit_calcular_jornada_1.RegimesCompensacao.HorasExtras) {
|
|
75
|
+
valoresEventos.ValorAtraso += jornada.horas_negativas ?? 0;
|
|
76
|
+
valoresEventos.ValorExtraIntrajornada += jornada.horas_extras_intrajornada ?? 0;
|
|
77
|
+
if (await (0, utils_1.feriado)({
|
|
78
|
+
contaId: contaId,
|
|
79
|
+
feriados: feriados,
|
|
80
|
+
elasticClient: elasticClient,
|
|
81
|
+
dataHoraJornada: new Date(jornada.data_hora),
|
|
82
|
+
ufEmpresaUsuarioJornada: jornada.usuario.empresa.uf,
|
|
83
|
+
idEmpresaUsuarioJornada: jornada.usuario.empresa.uid,
|
|
84
|
+
cidadeEmpresaUsuarioJornada: jornada.usuario.empresa.cidade,
|
|
85
|
+
tipoOcorrenciaFrequenciaJornadaPrevista: jornada.jornada_prevista.ocorrencia_frequencia.tipo
|
|
86
|
+
})) {
|
|
87
|
+
valoresEventos.ValorExtraFeriado += jornada.horas_extras ?? 0;
|
|
88
|
+
valoresEventos.ValorExtraNoturnoFeriado += jornada.horas_noturnas_extras ?? 0;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (jornada.data_hora && (0, utils_1.sabado)(jornada.data_hora.toDate())) {
|
|
92
|
+
valoresEventos.ValorExtraSabado += jornada.horas_extras ?? 0;
|
|
93
|
+
valoresEventos.ValorExtraNoturnoSabado += jornada.horas_noturnas_extras ?? 0;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (jornada.data_hora && (0, utils_1.domingo)(jornada.data_hora.toDate())) {
|
|
97
|
+
valoresEventos.ValorExtraDomingo += jornada.horas_extras ?? 0;
|
|
98
|
+
valoresEventos.ValorExtraNoturnoDomingo += jornada.horas_noturnas_extras ?? 0;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
valoresEventos.ValorExtraSegSex += jornada.horas_extras ?? 0;
|
|
102
|
+
valoresEventos.ValorExtraNoturnoSegSex += jornada.horas_noturnas_extras ?? 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
new unificacao_eventos_repetidos_1.UnificacaoEventosRepetidos().unificarEventosComCodigosRepetidos({
|
|
109
|
+
valoresEventos: valoresEventos,
|
|
110
|
+
parametrosIntegracao: tabelaEventos._source.eventos ?? {}
|
|
111
|
+
});
|
|
112
|
+
return valoresEventos;
|
|
113
|
+
}
|
|
114
|
+
exports.calcularValoresExportacao = calcularValoresExportacao;
|
|
18
115
|
function retornaValorEvento(tipoEvento, valoresEventos) {
|
|
19
116
|
switch (tipoEvento) {
|
|
20
117
|
case models_1.TipoEventoExportacao.HORA_EXTRA_NOTURNA_SEG_SEX:
|
|
@@ -54,36 +151,21 @@ function retornaValorEvento(tipoEvento, valoresEventos) {
|
|
|
54
151
|
exports.retornaValorEvento = retornaValorEvento;
|
|
55
152
|
function processarTiposEventosExportar(tiposEventos) {
|
|
56
153
|
return {
|
|
57
|
-
enviarFaltas: tiposEventos.length <= 0 ||
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_SEG_SEX),
|
|
73
|
-
enviarMinutosNoturnosTotais: tiposEventos.length <= 0 ||
|
|
74
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORAS_NOTURNAS_TOTAIS),
|
|
75
|
-
enviarMinutosExtrasNoturnosSab: tiposEventos.length <= 0 ||
|
|
76
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_SAB),
|
|
77
|
-
enviarMinutosExtrasNoturnosDom: tiposEventos.length <= 0 ||
|
|
78
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_DOM),
|
|
79
|
-
enviarMinutosExtrasNoturnosFer: tiposEventos.length <= 0 ||
|
|
80
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_FER),
|
|
81
|
-
enviarMinutosExtrasIntrajornada: tiposEventos.length <= 0 ||
|
|
82
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_INTRAJORNADA),
|
|
83
|
-
enviarMinutosExtrasIntrajornadaComReducao: tiposEventos.length <= 0 ||
|
|
84
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_INTRAJORNADA_COM_REDUCAO),
|
|
85
|
-
enviarMinutosExtrasNoturnosSegSex: tiposEventos.length <= 0 ||
|
|
86
|
-
tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_SEG_SEX),
|
|
154
|
+
enviarFaltas: (tiposEventos.length <= 0) || tiposEventos.includes(models_1.TiposEventosExportar.FALTA),
|
|
155
|
+
enviarAtrasos: (tiposEventos.length <= 0) || tiposEventos.includes(models_1.TiposEventosExportar.ATRASO),
|
|
156
|
+
enviarMinutosNormais: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_NORMAL),
|
|
157
|
+
enviarMinutosNoturnos: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_NOTURNA),
|
|
158
|
+
enviarMinutosExtrasSab: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_SAB),
|
|
159
|
+
enviarMinutosExtrasDom: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_DOM),
|
|
160
|
+
enviarMinutosExtrasFer: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_FER),
|
|
161
|
+
enviarMinutosExtrasSegSex: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_SEG_SEX),
|
|
162
|
+
enviarMinutosNoturnosTotais: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORAS_NOTURNAS_TOTAIS),
|
|
163
|
+
enviarMinutosExtrasNoturnosSab: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_SAB),
|
|
164
|
+
enviarMinutosExtrasNoturnosDom: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_DOM),
|
|
165
|
+
enviarMinutosExtrasNoturnosFer: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_FER),
|
|
166
|
+
enviarMinutosExtrasIntrajornada: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_INTRAJORNADA),
|
|
167
|
+
enviarMinutosExtrasNoturnosSegSex: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_NOTURNA_SEG_SEX),
|
|
168
|
+
enviarMinutosExtrasIntrajornadaComReducao: (tiposEventos.length) <= 0 || tiposEventos.includes(models_1.TiposEventosExportar.HORA_EXTRA_INTRAJORNADA_COM_REDUCAO)
|
|
87
169
|
};
|
|
88
170
|
}
|
|
89
171
|
exports.processarTiposEventosExportar = processarTiposEventosExportar;
|