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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
65 deletions
+45
-65
Main.java
src/salidasautomaticas/main/Main.java
+1
-1
MysqlDAOFactory.java
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
+30
-33
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 {
// setLogLevel(Level.INFO);//PRODUCCION
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
TimerTask
task
=
new
ProgramarSalidasTask
();
...
...
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
View file @
5ab90dbc
...
...
@@ -16,38 +16,35 @@ import salidasautomaticas.dao.SalidasDAO;
*/
public
class
MysqlDAOFactory
extends
DAOFactory
{
static
{
try
{
Class
.
forName
(
"com.mysql.jdbc.Driver"
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
public
static
Connection
obtenerConexion
(
String
base
)
{
Connection
conexion
=
null
;
if
(
base
.
equals
(
"nuevo"
))
{
try
{
// conexion = DriverManager.getConnection(
// "jdbc:mysql://172.16.2.39:3306/nuevo",
// "melani",
// "melani");
conexion
=
DriverManager
.
getConnection
(
"jdbc:mysql://172.16.2.39:3306/nuevo"
,
"melani"
,
"melani"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
conexion
;
}
@Override
public
SalidasDAO
getSalidasDAO
()
{
return
new
SalidasMysqlDAO
();
}
static
{
try
{
Class
.
forName
(
"com.mysql.jdbc.Driver"
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
public
static
Connection
obtenerConexion
(
String
base
)
{
Connection
conexion
=
null
;
if
(
base
.
equals
(
"nuevo"
))
{
try
{
String
url
=
"jdbc:mysql://172.16.2.43:3306/nuevo"
;
String
username
=
"billy"
;
String
password
=
"billy"
;
conexion
=
DriverManager
.
getConnection
(
url
,
username
,
password
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
conexion
;
}
@Override
public
SalidasDAO
getSalidasDAO
()
{
return
new
SalidasMysqlDAO
();
}
}
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
5ab90dbc
...
...
@@ -6,6 +6,8 @@
package
salidasautomaticas
.
mysqldao
;
import
java.sql.Connection
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.util.Iterator
;
import
java.util.logging.Level
;
...
...
@@ -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
+
"AND p.codtipo!=3 "
//Que registren asistencia
+
"AND a.fecha_asis=? "
//
+ "AND p.retirado = 0 "
+
"AND p.retirado = 0 "
// + "AND p.horaing = su.horaLV "
// + "AND p.mining = su.minutoLV "
// + "AND p.horaingsabado = su.sabadoLV "
...
...
@@ -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.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 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.salidaS = '') as tabla WHERE NULLIF( {campo_salida} , '') is NOT null GROUP BY {campo_salida} "
;
...
...
@@ -110,7 +112,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
String
fechaPartida
=
"2018-0
3
-01"
;
String
fechaPartida
=
"2018-0
1
-01"
;
String
query
=
"SELECT * from "
+
"(select "
...
...
@@ -132,10 +134,9 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"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 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.retirado=0) as tabla "
+
") as tabla "
+
"AND personal.retirado=0) as tabla "
//Que no esten retirados
+
"where tabla.salida!=''"
;
String
campoSalida
=
"("
...
...
@@ -168,8 +169,8 @@ public class SalidasMysqlDAO implements SalidasDAO {
int
aleatorioHora
=
0
,
aleatorioMin
=
0
;
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
()];
boolean
updateAll
=
false
;
...
...
@@ -200,9 +201,11 @@ public class SalidasMysqlDAO implements SalidasDAO {
updateCounts
[
i
]
=
resultado
.
getInt
(
"msg"
);
i
++;
}
Instant
finEjecucion
=
Instant
.
now
();
Duration
duracionProceso
=
Duration
.
between
(
inicioEjecucion
,
finEjecucion
);
log
.
info
(
"El proceso ha durado "
+
duracionProceso
);
int
cont0
=
0
;
int
cont1
=
0
;
...
...
@@ -251,18 +254,4 @@ public class SalidasMysqlDAO implements SalidasDAO {
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 {
public
void
run
()
{
try
{
// 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
));
}
JSONArray
listaHorarios
=
service
.
obtenerHorariosSalida
();
Timer
timer
;
TimerTask
task
;
...
...
@@ -56,7 +51,7 @@ public class ProgramarSalidasTask extends TimerTask {
log
.
trace
(
"Timer "
+
timer
);
}
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