Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
securityRemake
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
Juan Guevara Mayta
securityRemake
Commits
74389d53
Commit
74389d53
authored
Aug 23, 2023
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[EDIT] CAMBIOS DE CARGO PARA REPARAR LA CONSULTA QUE DEMORABA MUCHO
parent
a0a5e263
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
14 deletions
+69
-14
UsuarioDAO.java
...in/java/com/mycompany/moduloseguridad/dao/UsuarioDAO.java
+3
-0
UsuarioMYSQLDAO.java
...m/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
+51
-0
UsuarioService.java
...om/mycompany/moduloseguridad/services/UsuarioService.java
+11
-0
UsuarioServlet.java
...om/mycompany/moduloseguridad/servlets/UsuarioServlet.java
+3
-13
usuario.js
src/main/webapp/js/pages/usuario.js
+1
-1
No files found.
src/main/java/com/mycompany/moduloseguridad/dao/UsuarioDAO.java
View file @
74389d53
...
...
@@ -51,4 +51,6 @@ public interface UsuarioDAO {
public
int
validarAsignacion
(
int
codigo
)
throws
Exception
;
public
JSONObject
listarUsuarioManual
(
JSONObject
datos
)
throws
Exception
;
JSONObject
listarCargoUsuario
()
throws
Exception
;
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/mysqldao/UsuarioMYSQLDAO.java
View file @
74389d53
...
...
@@ -640,4 +640,54 @@ public class UsuarioMYSQLDAO implements UsuarioDAO {
}
return
new
JSONObject
(
response
);
}
@Override
public
JSONObject
listarCargoUsuario
(){
JSONObject
jreturn
=
new
JSONObject
();
JSONArray
lista
=
new
JSONArray
();
Connection
con
=
null
;
PreparedStatement
pst
=
null
;
ResultSet
rSet
=
null
;
String
sql
=
""
;
try
{
con
=
MySQLDAOFactory
.
getConnectionSQL
(
GeneralVariables
.
nameDB
);
sql
=
" select\n"
+
" descargo as nom_car\n"
+
" from seguridad.usuario\n"
+
" inner join nuevo.personal on usuario.cod_trabajador = personal.tmp_id\n"
+
" inner join nuevo.cargo on personal.codcargo = cargo.codcargo\n"
+
"group by descargo\n"
+
"order by descargo;"
;
pst
=
con
.
prepareStatement
(
sql
);
rSet
=
pst
.
executeQuery
();
while
(
rSet
.
next
())
{
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"nom_car"
,
rSet
.
getString
(
1
));
lista
.
put
(
obj
);
}
jreturn
.
put
(
"data"
,
lista
);
jreturn
.
put
(
"status"
,
true
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
jreturn
.
put
(
"data"
,
new
JSONArray
());
jreturn
.
put
(
"status"
,
false
);
}
finally
{
try
{
if
(
rSet
!=
null
)
{
rSet
.
close
();
}
if
(
pst
!=
null
)
{
pst
.
close
();
}
if
(
con
!=
null
)
{
con
.
close
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
jreturn
.
put
(
"data"
,
lista
);
jreturn
.
put
(
"status"
,
true
);
}
}
return
jreturn
;
}
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/services/UsuarioService.java
View file @
74389d53
...
...
@@ -208,4 +208,14 @@ public class UsuarioService {
}
return
obj
;
}
public
JSONObject
listarCargoUsuario
()
{
JSONObject
obj
=
null
;
try
{
obj
=
dao
.
listarCargoUsuario
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
obj
;
}
}
\ No newline at end of file
src/main/java/com/mycompany/moduloseguridad/servlets/UsuarioServlet.java
View file @
74389d53
...
...
@@ -424,18 +424,7 @@ public class UsuarioServlet extends HttpServlet {
response
.
setContentType
(
"application/json"
);
PrintWriter
out
=
response
.
getWriter
();
UsuarioService
srv
=
new
UsuarioService
();
JSONObject
json
=
srv
.
listarUsuarioManual
(
new
JSONObject
());
ArrayList
<
String
>
cargos
=
new
ArrayList
<>();
JSONArray
lista
=
json
.
getJSONArray
(
"results"
);
for
(
int
i
=
0
;
i
<
lista
.
length
();
i
++)
{
JSONObject
obj
=
lista
.
getJSONObject
(
i
);
JSONObject
prs
=
listarPersonalPorCodigo
(
obj
.
getString
(
"codigoTrabajador"
));
if
(!
prs
.
isNull
(
"nom_car"
)){
if
(!
cargos
.
contains
(
prs
.
getString
(
"nom_car"
)))
{
cargos
.
add
(
prs
.
getString
(
"nom_car"
));
}
}
}
out
.
print
(
new
JSONArray
(
cargos
));
JSONObject
json
=
srv
.
listarCargoUsuario
();
out
.
print
(
new
JSONArray
(
json
.
getJSONArray
(
"data"
)));
}
}
\ No newline at end of file
src/main/webapp/js/pages/usuario.js
View file @
74389d53
...
...
@@ -80,7 +80,7 @@ cargarCargos = () => {
listarCargosDeUsuario
()
.
then
(
data
=>
{
let
print
=
"<option value=''>TODOS</option>"
print
+=
data
.
map
(
obj
=>
`<option value="
${
obj
}
">
${
obj
}
</option>`
)
print
+=
data
.
map
(
obj
=>
`<option value="
${
obj
.
nom_car
}
">
${
obj
.
nom_car
}
</option>`
)
document
.
getElementById
(
'cboCargos'
).
innerHTML
=
print
})
.
then
(()
=>
{
...
...
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