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
f6b7360a
Commit
f6b7360a
authored
Aug 28, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apuntando a la base de datos real
parent
2c7ca7d5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
15 deletions
+85
-15
Main.java
src/salidasautomaticas/main/Main.java
+8
-5
MysqlDAOFactory.java
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
+4
-0
Prueba.java
src/salidasautomaticas/mysqldao/Prueba.java
+50
-0
SalidasMysqlDAO.java
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
+20
-4
EstandarDAO.java
src/salidasautomaticas/util/EstandarDAO.java
+3
-6
No files found.
src/salidasautomaticas/main/Main.java
View file @
f6b7360a
package
salidasautomaticas
.
main
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.stream.Collectors
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -13,9 +16,10 @@ import salidasautomaticas.schedule.ProgramarSalidasTask;
import
salidasautomaticas.util.Metodos
;
public
class
Main
{
private
static
final
Logger
log
=
LogManager
.
getLogger
(
Main
.
class
);
public
static
void
main
(
String
[]
args
){
public
static
void
main
(
String
[]
args
)
{
setLogLevel
(
Level
.
TRACE
);
//DESARROLLO
// setLogLevel(Level.INFO);//PRODUCCION
log
.
info
(
"Inicializando programa [Salidas Automaticas]..."
);
...
...
@@ -27,9 +31,8 @@ public class Main {
Timer
timer
=
new
Timer
();
timer
.
schedule
(
task
,
horaInicio
,
periodo
);
}
private
static
void
setLogLevel
(
Level
l
)
{
private
static
void
setLogLevel
(
Level
l
)
{
log
.
info
(
"Setting log level to "
+
l
.
name
());
LoggerContext
ctx
=
(
LoggerContext
)
LogManager
.
getContext
(
false
);
Configuration
conf
=
ctx
.
getConfiguration
();
...
...
src/salidasautomaticas/mysqldao/MysqlDAOFactory.java
View file @
f6b7360a
...
...
@@ -29,6 +29,10 @@ public class MysqlDAOFactory extends DAOFactory {
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"
,
...
...
src/salidasautomaticas/mysqldao/Prueba.java
0 → 100644
View file @
f6b7360a
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
salidasautomaticas
.
mysqldao
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
salidasautomaticas.dao.DAOFactory
;
import
salidasautomaticas.dao.SalidasDAO
;
/**
*
* @author sistem08user
*/
public
class
Prueba
extends
DAOFactory
{
static
{
try
{
Class
.
forName
(
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
);
}
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:sqlserver://localhost:1433; databaseName=prueba; user=sa; password=Saco1357$;"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
conexion
;
}
@Override
public
SalidasDAO
getSalidasDAO
()
{
return
new
SalidasMysqlDAO
();
}
}
src/salidasautomaticas/mysqldao/SalidasMysqlDAO.java
View file @
f6b7360a
...
...
@@ -8,6 +8,7 @@ package salidasautomaticas.mysqldao;
import
java.sql.Connection
;
import
java.time.LocalDate
;
import
java.util.Iterator
;
import
java.util.logging.Level
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.json.JSONArray
;
...
...
@@ -45,7 +46,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 "
...
...
@@ -65,7 +66,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
JSONArray
parametrosQuery
=
new
JSONArray
();
parametrosQuery
.
put
(
getFechaHoy
());
jsonArray
=
EstandarDAO
.
getInstance
().
consultar
(
cn
,
query
,
parametrosQuery
);
return
jsonArray
;
...
...
@@ -109,7 +110,7 @@ public class SalidasMysqlDAO implements SalidasDAO {
public
JSONArray
obtenerAsistencias
(
String
horaProgramada
)
throws
Exception
{
Connection
cn
=
MysqlDAOFactory
.
obtenerConexion
(
"nuevo"
);
String
fechaPartida
=
"2018-0
1
-01"
;
String
fechaPartida
=
"2018-0
3
-01"
;
String
query
=
"SELECT * from "
+
"(select "
...
...
@@ -133,7 +134,8 @@ public class SalidasMysqlDAO implements SalidasDAO {
+
"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.codtipo!=3 "
//Que si registren asistencia
+
"AND personal.retirado=0) as tabla "
// + "AND personal.retirado=0) as tabla "
+
") as tabla "
+
"where tabla.salida!=''"
;
String
campoSalida
=
"("
...
...
@@ -250,4 +252,17 @@ 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/util/EstandarDAO.java
View file @
f6b7360a
...
...
@@ -79,7 +79,7 @@ public class EstandarDAO {
//Recorremos la lista de parametros y lo seteamos en el preparedstatement
for
(
Object
parametro
:
params
)
{
castingPS
(
ps
,
cont
,
parametro
);
setPreparedStatement
(
ps
,
cont
,
parametro
);
cont
++;
}
}
...
...
@@ -99,7 +99,6 @@ public class EstandarDAO {
// rs.close();
// cn.close();
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"error"
,
ex
);
...
...
@@ -127,12 +126,11 @@ public class EstandarDAO {
obj
.
put
(
"msg"
,
0
);
}
else
{
PreparedStatement
ps
=
cn
.
prepareStatement
(
query
);
if
(
parametros
!=
null
&&
parametros
.
length
>
0
)
{
JSONArray
params
=
parametros
[
0
];
int
cont
=
1
;
for
(
Object
parametro
:
params
)
{
castingPS
(
ps
,
cont
,
parametro
);
setPreparedStatement
(
ps
,
cont
,
parametro
);
cont
++;
}
}
...
...
@@ -144,7 +142,6 @@ public class EstandarDAO {
}
else
{
obj
.
put
(
"msg"
,
0
);
}
// cn.close();
}
}
catch
(
Exception
ex
)
{
log
.
error
(
"error"
,
ex
);
...
...
@@ -162,7 +159,7 @@ public class EstandarDAO {
* @param p parametro de la consulta sql
* @throws SQLException
*/
private
void
castingPS
(
PreparedStatement
ps
,
int
index
,
Object
p
)
throws
SQLException
{
private
void
setPreparedStatement
(
PreparedStatement
ps
,
int
index
,
Object
p
)
throws
SQLException
{
if
(
p
instanceof
Integer
)
{
ps
.
setInt
(
index
,
(
int
)
p
);
}
else
if
(
p
instanceof
String
)
{
...
...
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