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
379d31e1
Commit
379d31e1
authored
May 10, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quitando los datos de pruebas
parent
3fdb2946
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
54 deletions
+31
-54
Main.java
src/salidasautomaticas/main/Main.java
+1
-1
MysqlDAOFactory.java
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
+0
-2
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+23
-31
ActualizarSalidaTask.java
src/salidasautomaticas/schedule/ActualizarSalidaTask.java
+2
-9
ProgramarSalidasTask.java
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
+5
-11
No files found.
src/salidasautomaticas/main/Main.java
View file @
379d31e1
...
...
@@ -10,7 +10,7 @@ public class Main {
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
"Inicializando programa..."
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"
08:1
0"
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"
12:0
0"
);
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 @
379d31e1
...
...
@@ -7,8 +7,6 @@ package salidasautomaticas.mysqldao;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
javax.sql.DataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
salidasautomaticas.dao.DAOFactory
;
import
salidasautomaticas.dao.SalidasDAO
;
...
...
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
379d31e1
...
...
@@ -23,10 +23,12 @@ public class SalidasMysqlDAO implements SalidasDAO {
public
JSONArray
obtenerHorariosSalida
()
throws
Exception
{
JSONArray
jsonArray
=
new
JSONArray
();
int
diaSemana
=
obtenerDiaSemana
();
if
(
diaSemana
==
7
)
return
jsonArray
;
if
(
diaSemana
==
7
)
{
return
jsonArray
;
}
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
String
query
=
"SELECT {campo_salida} as salida FROM ("
+
"SELECT"
+
" p.salidaLV, "
...
...
@@ -53,7 +55,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
}
else
if
(
diaSemana
==
6
)
{
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
"tabla.salidaS"
);
}
JSONArray
parametros
=
new
JSONArray
();
parametros
.
put
(
getFechaHoy
());
...
...
@@ -124,9 +126,9 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"when (WEEKDAY(asistencia.fecha_asis) + 1)<6 then salidaLV "
+
"when (WEEKDAY(asistencia.fecha_asis) + 1)=6 then salidaS end "
+
") "
;
String
fechaPartida
=
"2018-04-01"
;
query
=
query
.
replaceAll
(
"\\{campo_salida\\}"
,
campoSalida
);
query
=
query
.
replaceAll
(
"\\{fecha_hoy\\}"
,
getFechaHoy
());
query
=
query
.
replaceAll
(
"\\{fecha_partida\\}"
,
fechaPartida
);
...
...
@@ -147,18 +149,25 @@ public class SalidasMysqlDAO implements SalidasDAO {
int
aleatorioHora
=
0
,
aleatorioMin
=
0
;
JSONArray
listaAsistencias
=
obtenerAsistencias
(
"17:00"
);
JSONArray
listaAsistencias
=
obtenerAsistencias
(
horaSalida
);
System
.
out
.
println
(
"tamaño lista="
+
listaAsistencias
.
length
());
System
.
out
.
println
(
"lista de asistencias para actualizar "
+
horaSalida
+
" "
+
listaAsistencias
);
int
[]
updateCounts
=
new
int
[
listaAsistencias
.
length
()];
boolean
updateAll
=
false
;
int
i
=
0
;
for
(
Iterator
it
=
listaAsistencias
.
iterator
();
it
.
hasNext
();)
{
JSONObject
asistencia
=
(
JSONObject
)
it
.
next
();
String
salidaPersonal
=
asistencia
.
getString
(
"salida"
);
// if(salidaPersonal==null || salidaPersonal.isEmpty()){
// continue;
// }
if
(
salidaPersonal
==
null
||
salidaPersonal
.
isEmpty
())
{
updateCounts
[
i
]
=
-
1
;
continue
;
}
int
[]
aleatorio
=
generarHoraMinutoAleatorio
(
salidaPersonal
);
aleatorioHora
=
aleatorio
[
0
];
aleatorioMin
=
aleatorio
[
1
];
...
...
@@ -171,6 +180,10 @@ public class SalidasMysqlDAO implements SalidasDAO {
.
put
(
asistencia
.
getString
(
"codasis"
));
resultado
=
EstandarDAO
.
getInstance
().
ejecutar
(
cn
,
queryPersonal
,
parametros
);
updateCounts
[
i
]
=
resultado
.
getInt
(
"msg"
);
i
++;
System
.
out
.
println
(
"Asistencia actualizada"
);
}
...
...
@@ -202,27 +215,6 @@ public class SalidasMysqlDAO implements SalidasDAO {
return
aleatorio
;
}
public
static
void
main
(
String
[]
args
)
{
SalidasMysqlDAO
s
=
new
SalidasMysqlDAO
();
// try {
// JSONObject obj = s.actualizarSalida("17:00");
// System.out.println(obj);
// } catch (Exception ex) {
// Logger.getLogger(SalidasMysqlDAO.class.getName()).log(Level.SEVERE, null, ex);
// }
// System.out.println(s.getFechaAyer());
// String hora = "09:30";
// Integer h = new Integer(1);
// Integer m = new Integer(1);
//
// s.generarHoraMinutoAleatorio(hora, h, m);
//
// System.out.println("hora=" + h.intValue() + ", minuto=" + m.intValue());
// int[] i = s.generarHoraMinutoAleatorio("10:00");
// System.out.println("h=" + i[0] + ", m=" + i[1]);
}
@Override
public
JSONObject
asignarHorarioSalida
()
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
...
...
src/salidasautomaticas/schedule/ActualizarSalidaTask.java
View file @
379d31e1
...
...
@@ -32,20 +32,13 @@ public class ActualizarSalidaTask extends TimerTask{
JSONObject
objJSON
=
services
.
actualizarSalidas
(
horaSalida
);
JSONObject
objSalidaAsignada
=
services
.
asignarHorarioSalida
();
if
(
objSalidaAsignada
.
getInt
(
"msg"
)>
0
){
System
.
out
.
println
(
"Se asignaron horarios de salida correctamente, filas afectadas="
+
objSalidaAsignada
.
getInt
(
"msg"
));
}
else
{
System
.
out
.
println
(
"No
se pudo asignar horarios de salida
"
);
System
.
out
.
println
(
"No
hubo horarios de salida que asignar
"
);
}
// JSONArray objNuevasSalidas = services.obtenerSalidasNuevas();
// JSONArray objPersonalSinSalida = services.obtenerPersonalNuevoSinSalida();
System
.
out
.
println
(
"Matando timer "
+
timer
);
timer
.
cancel
();
}
...
...
src/salidasautomaticas/schedule/ProgramarSalidasTask.java
View file @
379d31e1
...
...
@@ -14,6 +14,7 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
salidasautomaticas.services.SalidasServices
;
import
salidasautomaticas.util.Metodos
;
/**
...
...
@@ -21,21 +22,14 @@ import salidasautomaticas.util.Metodos;
* @author sistem19user
*/
public
class
ProgramarSalidasTask
extends
TimerTask
{
private
SalidasServices
service
=
new
SalidasServices
();
@Override
public
void
run
()
{
try
{
// JSONArray listaHorarios = service.obtenerHorariosSalida();
JSONArray
listaHorarios
=
new
JSONArray
();
String
[]
arraySalidas
=
{
"10:29"
,
"14:46"
,
"14:50"
,
"17:00"
,
"17:30"
,
"18:00"
};
for
(
String
salida
:
arraySalidas
)
{
listaHorarios
.
put
(
new
JSONObject
().
put
(
"salida"
,
salida
));
}
System
.
out
.
println
(
"Listando horarios "
+
listaHorarios
+
"\n"
);
JSONArray
listaHorarios
=
service
.
obtenerHorariosSalida
();
Timer
timer
;
TimerTask
task
;
for
(
Iterator
it
=
listaHorarios
.
iterator
();
it
.
hasNext
();)
{
...
...
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