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
21651919
Commit
21651919
authored
Apr 11, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modificando query de salida
parent
81d9c6bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
10 deletions
+35
-10
Main.java
src/salidasautomaticas/main/Main.java
+2
-3
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+32
-6
ProgramarSalidasTask.java
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
+1
-1
No files found.
src/salidasautomaticas/main/Main.java
View file @
21651919
package
salidasautomaticas
.
main
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Timer
;
import
java.util.TimerTask
;
...
...
@@ -11,8 +10,8 @@ public class Main {
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
"Inicializando programa..."
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"0
9
:10"
);
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h, representa 24h en milisegundos
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"0
8
:10"
);
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h,
86400000
representa 24h en milisegundos
TimerTask
task
=
new
ProgramarSalidasTask
();
Timer
timer
=
new
Timer
();
...
...
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
21651919
...
...
@@ -76,11 +76,28 @@ public class SalidasMysqlDAO implements SalidasDAO {
return
fechaHoy
;
}
private
String
getFechaAyer
(){
String
fechaAyer
;
LocalDate
date
=
LocalDate
.
now
();
date
.
plusDays
(-
1
);
int
anio
=
date
.
getYear
();
int
mes
=
date
.
getMonthValue
();
int
dia
=
date
.
getDayOfMonth
();
fechaAyer
=
String
.
format
(
"%s-%02d-%02d"
,
anio
,
mes
,
dia
);
return
fechaAyer
;
}
@Override
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
String
query
=
"SELECT "
String
query
=
"SELECT * from "
+
"(select "
+
" asistencia.codasis, "
+
"asistencia.fecha_asis, "
+
"{campo_salida} as salida "
...
...
@@ -91,12 +108,13 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
" 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
}') "
+
"OR asistencia.fecha_asis BETWEEN '2018-03-
17' AND '{fecha_ayer
}') "
+
"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 "
;
+
"AND NOT personal.pronoe = 1 "
+
"AND (WEEKDAY(asistencia.fecha_asis) + 1) !=7 AND personal.retirado=0) as tabla "
+
"where tabla.salida!=''"
;
String
campoSalida
=
"("
+
"case "
...
...
@@ -106,6 +124,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
campoSalida
);
query
=
query
.
replaceAll
(
"\\{fecha_hoy\\}"
,
getFechaHoy
());
query
=
query
.
replaceAll
(
"\\{fecha_ayer\\}"
,
getFechaAyer
());
JSONArray
parametros
=
new
JSONArray
();
...
...
@@ -189,8 +208,15 @@ public class SalidasMysqlDAO implements SalidasDAO {
System
.
out
.
println
(
"lista de asistencias para actualizar "
+
horaSalida
+
" "
+
listaAsistencias
);
for
(
Iterator
it
=
listaAsistencias
.
iterator
();
it
.
hasNext
();)
{
JSONObject
asistencia
=
(
JSONObject
)
it
.
next
();
String
[]
splitHoraConsulta
=
asistencia
.
getString
(
"salida"
).
split
(
":"
);
String
salidaPersonal
=
asistencia
.
getString
(
"salida"
);
// if(salidaPersonal==null || salidaPersonal.isEmpty()){
// continue;
// }
String
[]
splitHoraConsulta
=
salidaPersonal
.
split
(
":"
);
int
min
=
Integer
.
parseInt
(
splitHoraConsulta
[
1
]);
int
hora
=
Integer
.
parseInt
(
splitHoraConsulta
[
0
]);
System
.
out
.
println
(
"obj "
+
asistencia
);
...
...
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
View file @
21651919
...
...
@@ -32,7 +32,7 @@ public class ProgramarSalidasTask extends TimerTask {
try
{
// JSONArray listaHorarios = service.obtenerHorariosSalida();
JSONArray
listaHorarios
=
new
JSONArray
();
String
[]
arraySalidas
=
{
"1
7:08
"
,
"14:46"
,
"14:50"
,
"17:00"
,
"17:30"
,
"18:00"
};
String
[]
arraySalidas
=
{
"1
2:59
"
,
"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