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
e614664f
Commit
e614664f
authored
Sep 21, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "modificando DAOHelper"
This reverts commit
af43c1b4
.
parent
54f2e783
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
92 deletions
+53
-92
Main.java
src/salidasautomaticas/main/Main.java
+22
-33
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+4
-4
EstandarDAO.java
src/salidasautomaticas/util/EstandarDAO.java
+0
-0
Metodos.java
src/salidasautomaticas/util/Metodos.java
+27
-55
No files found.
src/salidasautomaticas/main/Main.java
View file @
e614664f
...
...
@@ -17,38 +17,27 @@ import salidasautomaticas.util.Metodos;
public
class
Main
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
Main
.
class
);
public
static
void
main
(
String
[]
args
)
{
// setLogLevel(Level.TRACE);//DESARROLLO
//// setLogLevel(Level.INFO);//PRODUCCION
// log.info("Inicializando programa [Salidas Automaticas]...");
//
// Date horaInicio = Metodos.getHoraEjecucion("11:30");
// int periodo = 86400000;//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
//
// TimerTask task = new ProgramarSalidasTask();
// Timer timer = new Timer();
// timer.schedule(task, horaInicio, periodo);
int
i
=
1
;
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
sss
(
i
++);
}
}
private
static
void
setLogLevel
(
Level
l
)
{
log
.
info
(
"Setting log level to "
+
l
.
name
());
LoggerContext
ctx
=
(
LoggerContext
)
LogManager
.
getContext
(
false
);
Configuration
conf
=
ctx
.
getConfiguration
();
conf
.
getLoggerConfig
(
LogManager
.
ROOT_LOGGER_NAME
).
setLevel
(
l
);
ctx
.
updateLoggers
(
conf
);
}
private
static
void
sss
(
int
numero
)
{
System
.
out
.
println
(
"valor en sss="
+
numero
);
}
private
static
final
Logger
log
=
LogManager
.
getLogger
(
Main
.
class
);
public
static
void
main
(
String
[]
args
)
{
setLogLevel
(
Level
.
TRACE
);
//DESARROLLO
// setLogLevel(Level.INFO);//PRODUCCION
log
.
info
(
"Inicializando programa [Salidas Automaticas]..."
);
Date
horaInicio
=
Metodos
.
getHoraEjecucion
(
"11:30"
);
int
periodo
=
86400000
;
//El codigo se ejecutará cada 24h, 86400000 representa 24h en milisegundos
TimerTask
task
=
new
ProgramarSalidasTask
();
Timer
timer
=
new
Timer
();
timer
.
schedule
(
task
,
horaInicio
,
periodo
);
}
private
static
void
setLogLevel
(
Level
l
)
{
log
.
info
(
"Setting log level to "
+
l
.
name
());
LoggerContext
ctx
=
(
LoggerContext
)
LogManager
.
getContext
(
false
);
Configuration
conf
=
ctx
.
getConfiguration
();
conf
.
getLoggerConfig
(
LogManager
.
ROOT_LOGGER_NAME
).
setLevel
(
l
);
ctx
.
updateLoggers
(
conf
);
}
}
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
e614664f
...
...
@@ -14,7 +14,7 @@ import org.apache.logging.log4j.Logger;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
salidasautomaticas.dao.SalidasDAO
;
import
salidasautomaticas.util.
DAOHelper
;
import
salidasautomaticas.util.
EstandarDAO
;
/**
*
...
...
@@ -67,7 +67,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
JSONArray
parametrosQuery
=
new
JSONArray
();
parametrosQuery
.
put
(
getFechaHoy
());
jsonArray
=
DAOHelper
.
getInstance
().
consultar
(
cn
,
query
,
parametrosQuery
);
jsonArray
=
EstandarDAO
.
getInstance
().
consultar
(
cn
,
query
,
parametrosQuery
);
return
jsonArray
;
}
...
...
@@ -155,7 +155,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
JSONArray
parametros
=
new
JSONArray
();
parametros
.
put
(
horaProgramada
);
JSONArray
jsonArray
=
DAOHelper
.
getInstance
().
consultar
(
cn
,
query
,
parametros
);
JSONArray
jsonArray
=
EstandarDAO
.
getInstance
().
consultar
(
cn
,
query
,
parametros
);
return
jsonArray
;
}
...
...
@@ -196,7 +196,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
.
put
(
aleatorioMin
)
.
put
(
asistencia
.
getString
(
"codasis"
));
resultado
=
DAOHelper
.
getInstance
().
ejecutar
(
cn
,
queryPersonal
,
parametros
);
resultado
=
EstandarDAO
.
getInstance
().
ejecutar
(
cn
,
queryPersonal
,
parametros
);
updateCounts
[
i
]
=
resultado
.
getInt
(
"msg"
);
i
++;
...
...
src/salidasautomaticas/util/
DAOHelper
.java
→
src/salidasautomaticas/util/
EstandarDAO
.java
View file @
e614664f
This diff is collapsed.
Click to expand it.
src/salidasautomaticas/util/Metodos.java
View file @
e614664f
...
...
@@ -7,65 +7,37 @@ package salidasautomaticas.util;
import
java.util.Calendar
;
import
java.util.Date
;
import
org.json.JSONArray
;
/**
*
* @author sistem19user
*/
public
class
Metodos
{
/**
* Devuelve un objeto Date con la fecha de hoy y con la hora que le pasamos
* como parametro(en formato hh:mm en 24 horas).
*
* @param horaEjecucion hora que se va a setear al Date del dia de hoy.
* @return
*/
public
static
Date
getHoraEjecucion
(
String
horaEjecucion
)
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
String
[]
splitHoraSalida
=
horaEjecucion
.
split
(
":"
);
int
hora
=
Integer
.
parseInt
(
splitHoraSalida
[
0
]);
int
minuto
=
Integer
.
parseInt
(
splitHoraSalida
[
1
]);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
hora
);
calendar
.
set
(
Calendar
.
MINUTE
,
minuto
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
date
=
calendar
.
getTime
();
return
date
;
}
public
static
void
main
(
String
[]
args
)
{
JSONArray
array
=
new
JSONArray
();
array
.
put
(
Integer
.
class
)
.
put
(
String
.
class
)
.
put
(
Boolean
.
class
);
f
(
Integer
.
class
);
// System.out.println(array);
// ss(array);
// System.out.println(array.get(0));
// System.out.println(array);
}
private
static
void
f
(
Class
c
)
{
System
.
out
.
println
(
c
.
getName
());
switch
(
c
.
getName
())
{
case
"java.lang.Integer"
:
System
.
out
.
println
(
"entero"
);
}
}
private
static
void
ss
(
JSONArray
arr
)
{
System
.
out
.
println
(
arr
.
get
(
0
));
arr
.
put
(
0
,
1
);
arr
.
put
(
1
,
"hello"
);
arr
.
put
(
2
,
true
);
}
/**
* Devuelve un objeto Date con la fecha de hoy y con la hora
* que le pasamos como parametro(en formato hh:mm en 24 horas).
*
* @param horaEjecucion hora que se va a setear al Date del dia de hoy.
* @return
*/
public
static
Date
getHoraEjecucion
(
String
horaEjecucion
)
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
String
[]
splitHoraSalida
=
horaEjecucion
.
split
(
":"
);
int
hora
=
Integer
.
parseInt
(
splitHoraSalida
[
0
]);
int
minuto
=
Integer
.
parseInt
(
splitHoraSalida
[
1
]);
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
hora
);
calendar
.
set
(
Calendar
.
MINUTE
,
minuto
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
date
=
calendar
.
getTime
();
return
date
;
}
}
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