Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SalidasAutomaticas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Billy Larru
SalidasAutomaticas
Commits
81d9c6bb
Commit
81d9c6bb
authored
Apr 06, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modificacion de query
parent
a45ef710
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
48 deletions
+67
-48
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+66
-47
ProgramarSalidasTask.java
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
+1
-1
No files found.
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
81d9c6bb
...
...
@@ -24,31 +24,31 @@ public class SalidasMysqlDAO implements SalidasDAO {
public
JSONArray
obtenerHorariosSalida
()
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
int
diaSemana
=
obtenerDiaSemana
();
String
query
=
"SELECT
? as salida FROM (\n
"
+
"SELECT
\n
"
+
" p.salidaLV,
\n
"
+
" p.salidaS
\n
"
+
"FROM
\n
"
+
" asistencia a
\n
"
+
"INNER JOIN personal p ON a.codper = p.codper
\n
"
+
"INNER JOIN salidas_update su ON p.codcargo = su.codcargo
\n
"
+
"WHERE
\n
"
+
" a.fecha_asis BETWEEN '2018-04-03' AND '2018-04-05'
\n
"
+
"AND p.retirado = 0
\n"
+
"AND p.horaing = su.horaLV
\n
"
+
"AND p.mining = su.minutoLV
\n
"
+
"AND p.horaingsabado = su.sabadoLV
\n
"
+
"AND p.miningsabado = su.sabadoS
\n
"
+
"AND NOT p.codlocal IN ('L035', 'L053', 'L038')
\n
"
+
"AND NOT p.pronoe = 1
\n
"
+
"AND NOT p.codcargo IN (71, 13)
\n
"
+
"AND NOT p.horaing > 19
\n
"
+
"AND NOT p.salidaS = '') as tabla WHERE NULLIF(
? , '') is NOT null GROUP BY ?
"
;
String
query
=
"SELECT
{campo_salida} as salida FROM (
"
+
"SELECT"
+
" p.salidaLV,
"
+
" p.salidaS
"
+
"FROM"
+
" asistencia a
"
+
"INNER JOIN personal p ON a.codper = p.codper
"
+
"INNER JOIN salidas_update su ON p.codcargo = su.codcargo
"
+
"WHERE
"
+
" a.fecha_asis BETWEEN '2018-04-03' AND '2018-04-05'
"
+
"AND p.retirado = 0
"
+
"AND p.horaing = su.horaLV
"
+
"AND p.mining = su.minutoLV
"
+
"AND p.horaingsabado = su.sabadoLV
"
+
"AND p.miningsabado = su.sabadoS
"
+
"AND NOT p.codlocal IN ('L035', 'L053', 'L038')
"
+
"AND NOT p.pronoe = 1
"
+
"AND NOT p.codcargo IN (71, 13)
"
+
"AND NOT p.horaing > 19
"
+
"AND NOT p.salidaS = '') as tabla WHERE NULLIF(
{campo_salida} , '') is NOT null GROUP BY {campo_salida}
"
;
if
(
diaSemana
>=
1
&&
diaSemana
<=
5
)
{
query
=
query
.
replaceAll
(
"\\
?
"
,
"tabla.salidaLV"
);
query
=
query
.
replaceAll
(
"\\
{campo_salida\\}
"
,
"tabla.salidaLV"
);
}
else
if
(
diaSemana
==
6
)
{
query
=
query
.
replaceAll
(
"\\
?
"
,
"tabla.salidaS"
);
query
=
query
.
replaceAll
(
"\\
{campo_salida\\}
"
,
"tabla.salidaS"
);
}
JSONArray
jsonArray
=
EstandarDAO
.
getInstance
().
consultar
(
cn
,
query
);
...
...
@@ -62,36 +62,55 @@ public class SalidasMysqlDAO implements SalidasDAO {
return
diaSemana
;
}
private
String
getFechaHoy
(){
String
fechaHoy
;
LocalDate
date
=
LocalDate
.
now
();
int
anio
=
date
.
getYear
();
int
mes
=
date
.
getMonthValue
();
int
dia
=
date
.
getDayOfMonth
();
fechaHoy
=
String
.
format
(
"%s-%02d-%02d"
,
anio
,
mes
,
dia
);
return
fechaHoy
;
}
@Override
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
int
diaSemana
=
obtenerDiaSemana
();
String
query
=
"SELECT\n"
+
" asistencia.codasis,\n"
+
"asistencia.fecha_asis,\n"
+
"(WEEKDAY(asistencia.fecha_asis) + 1) AS numDia,\n"
+
"{campo_salida} as salida \n"
+
"FROM\n"
+
" asistencia\n"
+
"INNER JOIN personal ON asistencia.codper = personal.codper\n"
+
"WHERE\n"
+
" asistencia.horasal = ''\n"
+
"AND asistencia.minsal = ''\n"
+
"AND ( {campo_salida} <= ? AND asistencia.fecha_asis='2018-04-05'\n"
+
"OR asistencia.fecha_asis BETWEEN '2018-03-31' AND '2018-04-04')\n"
+
"AND {campo_salida} is not NULL \n"
String
query
=
"SELECT "
+
" asistencia.codasis, "
+
"asistencia.fecha_asis, "
+
"{campo_salida} as salida "
+
"FROM "
+
" asistencia "
+
"INNER JOIN personal ON asistencia.codper = personal.codper "
+
"WHERE "
+
" asistencia.horasal = '' "
+
"AND asistencia.minsal = '' "
+
"AND ( {campo_salida} <= ? AND asistencia.fecha_asis='{fecha_hoy}' "
+
"OR asistencia.fecha_asis BETWEEN '2018-03-31' AND '{fecha_hoy}') "
+
"AND {campo_salida} is not NULL "
+
"AND NOT personal.codlocal IN ('L035', 'L053', 'L038') "
+
"AND NOT personal.codcargo IN (71, 13) "
+
"AND NOT p.pronoe = 1 "
+
"AND (WEEKDAY(asistencia.fecha_asis) + 1) !=7 AND personal.retirado=0 "
;
if
(
diaSemana
>=
1
&&
diaSemana
<=
5
)
{
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
"personal.salidaLV"
);
}
else
if
(
diaSemana
==
6
)
{
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
"personal.salidaS"
);
}
String
campoSalida
=
"("
+
"case "
+
"when (WEEKDAY(asistencia.fecha_asis) + 1)<6 then salidaLV "
+
"when (WEEKDAY(asistencia.fecha_asis) + 1)=6 then salidaS end "
+
") "
;
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
campoSalida
);
query
=
query
.
replaceAll
(
"\\{fecha_hoy\\}"
,
getFechaHoy
());
JSONArray
parametros
=
new
JSONArray
();
parametros
.
put
(
horaProgramada
);
JSONArray
jsonArray
=
EstandarDAO
.
getInstance
().
consultar
(
cn
,
query
,
parametros
);
return
jsonArray
;
...
...
@@ -150,7 +169,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
parametros
.
put
(
objPrograma
.
getString
(
"codasis"
));
// System.out.println("consulta "+queryPersonal+ " "+parametros);
resultado
=
EstandarDAO
.
getInstance
().
ejecutar
(
cn
,
queryPersonal
,
parametros
);
System
.
out
.
println
(
"Resultado updates ="
+
resultado
);
System
.
out
.
println
(
"Resultado updates ="
+
resultado
);
}
}
}
...
...
@@ -164,10 +183,10 @@ public class SalidasMysqlDAO implements SalidasDAO {
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
int
aleatorioHora
=
0
,
aleatorioMin
=
0
;
JSONArray
listaAsistencias
=
obtenerAsistencias
(
"17:00"
);
System
.
out
.
println
(
"lista de asistencias para actualizar "
+
horaSalida
+
" "
+
listaAsistencias
);
System
.
out
.
println
(
"lista de asistencias para actualizar "
+
horaSalida
+
" "
+
listaAsistencias
);
for
(
Iterator
it
=
listaAsistencias
.
iterator
();
it
.
hasNext
();)
{
JSONObject
asistencia
=
(
JSONObject
)
it
.
next
();
...
...
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
View file @
81d9c6bb
...
...
@@ -32,7 +32,7 @@ public class ProgramarSalidasTask extends TimerTask {
try
{
// JSONArray listaHorarios = service.obtenerHorariosSalida();
JSONArray
listaHorarios
=
new
JSONArray
();
String
[]
arraySalidas
=
{
"1
5:2
8"
,
"14:46"
,
"14:50"
,
"17:00"
,
"17:30"
,
"18:00"
};
String
[]
arraySalidas
=
{
"1
7:0
8"
,
"14:46"
,
"14:50"
,
"17:00"
,
"17:30"
,
"18:00"
};
for
(
String
salida
:
arraySalidas
)
{
listaHorarios
.
put
(
new
JSONObject
().
put
(
"salida"
,
salida
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment