Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions src/controllers/fichas-tombos-controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from 'moment-timezone';
import path from 'path';

import { converteDecimalParaGMSSinal } from '~/helpers/coordenadas';
import { converteDecimalParaGrausMinutosSegundos } from '~/helpers/coordenadas';

// import identificador from '~/routes/identificador';

Expand Down Expand Up @@ -218,25 +218,16 @@ export default function fichaTomboController(request, response, next) {
});
})
.then(async resultado => {
const { tombo, identificacao, fotos } = resultado;
// IMPORTANTE: Ao mexerem na ficha tombo, deixem os
// campos como opcionais, pois a ficha pode ser gerada
// mesmo sem possuirem todos os dados preenchidos no tombo

// await Subfamilia.findAll({
// where: {
// familia_id: dadosTombo.familia?.id,
// },
// include: [
// {
// model: Autor,
// attributes: ['id', 'nome'],
// as: 'autor',
// },
// ],
// });
const { tombo, identificacao, fotos } = resultado;

const coletores = `${!!tombo?.coletore?.nome !== false ? tombo?.coletore?.nome?.concat(' ') : ''}${tombo?.coletor_complementar ? tombo.coletor_complementar?.complementares : ''}`;

const localColeta = tombo.local_coleta;
const cidade = localColeta.cidade || '';
const localColeta = tombo?.local_coleta;
const cidade = localColeta?.cidade || '';
const estado = cidade?.estado || '';
const pais = estado?.pais || '';

Expand Down Expand Up @@ -265,8 +256,8 @@ export default function fichaTomboController(request, response, next) {
tombo: {
...tombo,
coletores,
latitude: converteDecimalParaGMSSinal(tombo.latitude, true),
longitude: converteDecimalParaGMSSinal(tombo.longitude, true),
latitude: tombo.latitude && converteDecimalParaGrausMinutosSegundos(tombo.latitude, true, true),
longitude: tombo.longitude && converteDecimalParaGrausMinutosSegundos(tombo.longitude, false, true),
data_tombo: formataDataSaida(tombo.data_tombo),
data_coleta: formataColunasSeparadas(tombo.data_coleta_dia, tombo.data_coleta_mes, tombo.data_coleta_ano),
},
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/relatorios-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export const obtemDadosDoRelatorioDeLocalDeColeta = async (req, res, next) => {
let whereData = {};
if (local) {
whereLocal = {
descricao: { [Op.like]: `%${local}%` },
id: local,
};
}
if (dataInicio) {
Expand Down Expand Up @@ -589,7 +589,7 @@ export const obtemDadosDoRelatorioDeLocalDeColeta = async (req, res, next) => {
ReportLocalColeta, {
dados: dadosFormatados.locais,
total: dadosFormatados?.quantidadeTotal || 0,
textoFiltro: formataTextFilter(local, dataInicio, dataFim || new Date()),
textoFiltro: formataTextFilter(undefined, dataInicio, dataFim || new Date()),
showCoord: showCoord === 'true',
});
const readable = new Readable();
Expand Down
37 changes: 37 additions & 0 deletions src/helpers/coordenadas.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,40 @@ export const converteDecimalParaGMSSinal = (decimal, isLat) => {

return result;
};

export const converteDecimalParaGrausMinutosSegundos = (gDec, ehLat, formatada) => {
let graus;
let minutos;
let aux;
let segundos;
let direcao;

graus = parseInt(gDec);
aux = (graus - gDec) * 60;
minutos = parseInt(aux);
aux = (aux - minutos) * 60;
segundos = aux;

if (ehLat) {
// Eixo X
if (graus < 0) direcao = 'W';
else direcao = 'E';
} else {
// Eixo Y
if (graus >= 0) direcao = 'N';
else direcao = 'S';
}

if (formatada) {
return `${Math.abs(graus)}°${Math.abs(minutos)}'${Math.abs(segundos).toFixed(2)
.replace('.', ',')}" ${direcao}`;
}

return {
graus: Math.abs(graus),
minutos: Math.abs(minutos),
segundos: Math.abs(segundos).toFixed(2)
.replace('.', ','),
direcao,
};
};
13 changes: 10 additions & 3 deletions src/reports/assets/styles/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ tfoot {

.grupoLocalColeta {
display: flex;
align-items: center;
gap: 1rem;
width: 100%;
}

.grupoLocalColeta div:first-child {
Expand All @@ -124,12 +124,19 @@ tfoot {
}

.grupoLocalColeta div h1 {
white-space: nowrap; /* impede quebra de linha */
overflow: hidden; /* esconde o que ultrapassa */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: left;
}

.grupoLocalColeta div h1.longText {
text-align: left;
word-break: break-word;
max-width: 100%;
white-space: normal;
}

.grade-imagens {
display: grid;
grid-template-columns: repeat(3, 1fr); /* 3 colunas */
Expand Down
2 changes: 1 addition & 1 deletion src/reports/templates/LocaisColeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function RelacaoLocaisColeta({ dados, total, textoFiltro, showCoord = false }: R
<h1>Município: {item.municipio}</h1>
</div>
<div>
<h1>Local: {item.local}</h1>
<h1 className="longText">Local: {item.local}</h1>
</div>
</div>
{renderTable(item.registros)}
Expand Down
19 changes: 13 additions & 6 deletions src/views/ficha-tombo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,24 @@
<div>
<b class="fs-14">Identificador:</b> <%- identificador %>
</div>
<div>
<b class="fs-14">Data:</b> <%- romano_data_identificacao %>
</div>
<% if (romano_data_identificacao) { %>
<div>
<b class="fs-14">Data:</b> <%- romano_data_identificacao %>
</div>
<% } %>
<% if (!romano_data_identificacao) { %>
<div>
<b class="fs-14" style="margin-right: 6.5rem;">Data:</b>
</div>
<% } %>
</div>
<div>
<b class="fs-14">Local de Coleta:</b>
<% if (localColeta && localColeta.complemento) { %>
<%- localColeta.complemento %>
<% } %>
<% if (localColeta && localColeta.descricao) { %>
- <%- localColeta.descricao %>
<%- localColeta.descricao %>
<% } %>
<% if (cidade && cidade.nome) { %>
- <%- cidade.nome %>
Expand All @@ -236,8 +243,8 @@
<% if (tombo.relevo) { %>
- Relevo: <%- tombo.relevo.nome %>
<% } %>
<% if (tombo.vegetacao) { %>
- Vegetação: <%- tombo.vegetacao.nome %>
<% if (tombo.vegetaco) { %>
- Vegetação: <%- tombo.vegetaco.nome %>
<% } %>
<% if (tombo && tombo.latitude) { %>
- Latitude: <%- tombo.latitude %>
Expand Down
Loading