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
5ab90dbc
Commit
5ab90dbc
authored
Sep 21, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EDIT retirando codigo de pruebas]
parent
e614664f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
40 deletions
+20
-40
Main.java
src/salidasautomaticas/main/Main.java
+1
-1
MysqlDAOFactory.java
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
+5
-8
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+12
-24
ProgramarSalidasTask.java
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
+2
-7
No files found.
src/salidasautomaticas/main/Main.java
View file @
5ab90dbc
...
@@ -24,7 +24,7 @@ public class Main {
...
@@ -24,7 +24,7 @@ public class Main {
// setLogLevel(Level.INFO);//PRODUCCION
// setLogLevel(Level.INFO);//PRODUCCION
log
.
info
(
"Inicializando programa [Salidas Automaticas]..."
);
log
.
info
(
"Inicializando programa [Salidas Automaticas]..."
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"1
1
:30"
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"1
2
:30"
);
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
TimerTask
task
=
new
ProgramarSalidasTask
();
TimerTask
task
=
new
ProgramarSalidasTask
();
...
...
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
View file @
5ab90dbc
...
@@ -29,14 +29,11 @@ public class MysqlDAOFactory extends DAOFactory {
...
@@ -29,14 +29,11 @@ public class MysqlDAOFactory extends DAOFactory {
Connection
conexion
=
null
;
Connection
conexion
=
null
;
if
(
base
.
equals
(
"nuevo"
))
{
if
(
base
.
equals
(
"nuevo"
))
{
try
{
try
{
// conexion = DriverManager.getConnection(
String
url
=
"jdbc:mysql://172.16.2.43:3306/nuevo"
;
// "jdbc:mysql://172.16.2.39:3306/nuevo",
String
username
=
"billy"
;
// "melani",
String
password
=
"billy"
;
// "melani");
conexion
=
DriverManager
.
getConnection
(
conexion
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
"jdbc:mysql://172.16.2.39:3306/nuevo"
,
"melani"
,
"melani"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
5ab90dbc
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
package
salidasautomaticas
.
mysqldao
;
package
salidasautomaticas
.
mysqldao
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
...
@@ -46,7 +48,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -46,7 +48,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"estado in (1, 2, 5) "
//Que sean asistencias 1=Asistio, 2=No marco y 5=Tardanza
+
"estado in (1, 2, 5) "
//Que sean asistencias 1=Asistio, 2=No marco y 5=Tardanza
+
"AND p.codtipo!=3 "
//Que registren asistencia
+
"AND p.codtipo!=3 "
//Que registren asistencia
+
"AND a.fecha_asis=? "
+
"AND a.fecha_asis=? "
//
+ "AND p.retirado = 0 "
+
"AND p.retirado = 0 "
// + "AND p.horaing = su.horaLV "
// + "AND p.horaing = su.horaLV "
// + "AND p.mining = su.minutoLV "
// + "AND p.mining = su.minutoLV "
// + "AND p.horaingsabado = su.sabadoLV "
// + "AND p.horaingsabado = su.sabadoLV "
...
@@ -54,7 +56,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -54,7 +56,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"AND NOT p.codlocal IN ('L035', 'L053', 'L038') "
//Que no sea profesores por horas, pronoe belisario y grupo MH
+
"AND NOT p.codlocal IN ('L035', 'L053', 'L038') "
//Que no sea profesores por horas, pronoe belisario y grupo MH
+
"AND NOT p.pronoe = 1 "
//Que no sea pronoe
+
"AND NOT p.pronoe = 1 "
//Que no sea pronoe
+
"AND NOT p.codcargo IN (71, 13, 96, 41) "
//Que no sea policia ni de cafeteria ni vigilante ni interna psicologa
+
"AND NOT p.codcargo IN (71, 13, 96, 41) "
//Que no sea policia ni de cafeteria ni vigilante ni interna psicologa
//
+ "AND p.tmp_id not in (99998, 9998, 99999, 9888) "//Que esten en planilla
+
"AND p.tmp_id not in (99998, 9998, 99999, 9888) "
//Que esten en planilla
+
"AND NOT p.horaing > 19 "
+
"AND NOT p.horaing > 19 "
+
"AND NOT p.salidaS = '') as tabla WHERE NULLIF( {campo_salida} , '') is NOT null GROUP BY {campo_salida} "
;
+
"AND NOT p.salidaS = '') as tabla WHERE NULLIF( {campo_salida} , '') is NOT null GROUP BY {campo_salida} "
;
...
@@ -110,7 +112,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -110,7 +112,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
String
fechaPartida
=
"2018-0
3
-01"
;
String
fechaPartida
=
"2018-0
1
-01"
;
String
query
=
"SELECT * from "
String
query
=
"SELECT * from "
+
"(select "
+
"(select "
...
@@ -132,10 +134,9 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -132,10 +134,9 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"AND (WEEKDAY(asistencia.fecha_asis) + 1) !=7 "
//Que no sea domingo
+
"AND (WEEKDAY(asistencia.fecha_asis) + 1) !=7 "
//Que no sea domingo
+
"AND NOT ( (WEEKDAY(asistencia.fecha_asis) + 1)=6 and personal.codcargo in ({cod_cargo_primaria}) ) "
//Que no sean de primaria los sabados
+
"AND NOT ( (WEEKDAY(asistencia.fecha_asis) + 1)=6 and personal.codcargo in ({cod_cargo_primaria}) ) "
//Que no sean de primaria los sabados
+
"AND asistencia.estado in (1, 2, 5) "
//Que sean asistio, tardanza y no marco
+
"AND asistencia.estado in (1, 2, 5) "
//Que sean asistio, tardanza y no marco
//
+ "AND personal.tmp_id not in (99998, 9998, 99999, 9888) "//Que esten en planilla
+
"AND personal.tmp_id not in (99998, 9998, 99999, 9888) "
//Que esten en planilla
+
"AND personal.codtipo!=3 "
//Que si registren asistencia
+
"AND personal.codtipo!=3 "
//Que si registren asistencia
// + "AND personal.retirado=0) as tabla "
+
"AND personal.retirado=0) as tabla "
//Que no esten retirados
+
") as tabla "
+
"where tabla.salida!=''"
;
+
"where tabla.salida!=''"
;
String
campoSalida
=
"("
String
campoSalida
=
"("
...
@@ -168,8 +169,8 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -168,8 +169,8 @@ public class SalidasMysqlDAO implements SalidasDAO {
int
aleatorioHora
=
0
,
aleatorioMin
=
0
;
int
aleatorioHora
=
0
,
aleatorioMin
=
0
;
JSONArray
listaAsistencias
=
obtenerAsistencias
(
horaSalida
);
JSONArray
listaAsistencias
=
obtenerAsistencias
(
horaSalida
);
log
.
info
(
"hora="
+
horaSalida
+
", asistencias para actualizar="
+
listaAsistencias
.
length
());
log
.
info
(
"hora
de salida
="
+
horaSalida
+
", asistencias para actualizar="
+
listaAsistencias
.
length
());
Instant
inicioEjecucion
=
Instant
.
now
();
int
[]
updateCounts
=
new
int
[
listaAsistencias
.
length
()];
int
[]
updateCounts
=
new
int
[
listaAsistencias
.
length
()];
boolean
updateAll
=
false
;
boolean
updateAll
=
false
;
...
@@ -200,9 +201,11 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -200,9 +201,11 @@ public class SalidasMysqlDAO implements SalidasDAO {
updateCounts
[
i
]
=
resultado
.
getInt
(
"msg"
);
updateCounts
[
i
]
=
resultado
.
getInt
(
"msg"
);
i
++;
i
++;
}
}
Instant
finEjecucion
=
Instant
.
now
();
Duration
duracionProceso
=
Duration
.
between
(
inicioEjecucion
,
finEjecucion
);
log
.
info
(
"El proceso ha durado "
+
duracionProceso
);
int
cont0
=
0
;
int
cont0
=
0
;
int
cont1
=
0
;
int
cont1
=
0
;
...
@@ -251,18 +254,4 @@ public class SalidasMysqlDAO implements SalidasDAO {
...
@@ -251,18 +254,4 @@ public class SalidasMysqlDAO implements SalidasDAO {
return
aleatorio
;
return
aleatorio
;
}
}
public
static
void
main
(
String
[]
args
)
{
SalidasMysqlDAO
dao
=
new
SalidasMysqlDAO
();
try
{
JSONObject
a
=
dao
.
actualizarSalida
(
"17:30"
);
System
.
out
.
println
(
a
);
// System.out.println(a.length());
}
catch
(
Exception
ex
)
{
java
.
util
.
logging
.
Logger
.
getLogger
(
SalidasMysqlDAO
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
}
\ No newline at end of file
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
View file @
5ab90dbc
...
@@ -30,12 +30,7 @@ public class ProgramarSalidasTask extends TimerTask {
...
@@ -30,12 +30,7 @@ public class ProgramarSalidasTask extends TimerTask {
public
void
run
()
{
public
void
run
()
{
try
{
try
{
// JSONArray listaHorarios = service.obtenerHorariosSalida();
JSONArray
listaHorarios
=
service
.
obtenerHorariosSalida
();
JSONArray
listaHorarios
=
new
JSONArray
();
String
[]
arraySalidas
=
{
"16:13"
,
"14:46"
,
"14:50"
,
"17:00"
,
"17:30"
,
"18:00"
};
for
(
String
salida
:
arraySalidas
)
{
listaHorarios
.
put
(
new
JSONObject
().
put
(
"salida"
,
salida
));
}
Timer
timer
;
Timer
timer
;
TimerTask
task
;
TimerTask
task
;
...
@@ -56,7 +51,7 @@ public class ProgramarSalidasTask extends TimerTask {
...
@@ -56,7 +51,7 @@ public class ProgramarSalidasTask extends TimerTask {
log
.
trace
(
"Timer "
+
timer
);
log
.
trace
(
"Timer "
+
timer
);
}
else
{
}
else
{
log
.
trace
(
"Ya pasó la hora
"
);
log
.
trace
(
"Ya pasó la hora
"
+
horaSalida
);
}
}
}
}
...
...
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