Commit b594a22d by Luis Gangas

[EDIT] querys de fichaAdministrativa

parent 9f483ec3
......@@ -83,13 +83,13 @@ public class CargaFamiliarMysqlDAO implements CargaFamiliarDAO {
+ "cargafamiliar.apellido_materno apellidoMaterno , "
+ "cargafamiliar.nombre nombre, "
+ "parentesco.nombre parentesco, "
+ "Format(cargafamiliar.fecha_nacimiento, 'dd/MM/yyyy') fechaNacimiento , "
+ "(cast(datediff(dd,cargafamiliar.fecha_nacimiento,getdate()) / 365.25 as int)) edad, "
+ "date_format(cargafamiliar.fecha_nacimiento, '%d/%m/%Y') fechaNacimiento , "
+ "(cast(datediff(now(),cargafamiliar.fecha_nacimiento) / 365.25 as decimal)) edad, "
+ "tipodocumento.descripcion_larga tipoDocumentoDescripcionLarga, "
+ "tipodocumento.descripcion_corta tipoDocumentoDescripcionCorta, "
+ "cargafamiliar.numero_documento numeroDocumento , "
+ "cargafamiliar.sexo sexo, "
+ "Isnull(cargafamiliar.telefono, '-') telefono "
+ "ifnull(cargafamiliar.telefono,'-') telefono "
+ "FROM carga_familiar cargafamiliar "
+ "INNER JOIN parentesco parentesco ON parentesco.codigo_parentesco = cargafamiliar.codigo_parentesco "
+ "INNER JOIN tipo_documento tipodocumento ON tipodocumento.codigo_tipo_documento = cargafamiliar.codigo_tipo_documento "
......
......@@ -30,9 +30,9 @@ public class ExperienciaLaboralMysqlDAO implements ExperienciaLaboralDAO {
= "SELECT "
+ "experiencialaboral.nombre_empresa nombreEmpresa, "
+ "experiencialaboral.nombre_cargo nombreCargo, "
+ "Format(experiencialaboral.fecha_inicio, 'dd/MM/yyyy') fechaInicio, "
+ "Format(experiencialaboral.fecha_fin, 'dd/MM/yyyy') fechaFin, "
+ "Isnull(experiencialaboral.telefono, '-') telefono "
+ "date_format(experiencialaboral.fecha_inicio, '%d/%m/%Y') fechaInicio, "
+ "date_format(experiencialaboral.fecha_fin, '%d/%m/%Y') fechaFin, "
+ "ifnull(experiencialaboral.telefono,'-') telefono "
+ "FROM experiencia_laboral experiencialaboral "
+ "WHERE experiencialaboral.codigo_persona = ?";
ps = cnx.prepareStatement(sql);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -31,13 +31,13 @@ public class FormacionAcademicaMysqlDAO implements FormacionAcademicaDAO {
+ "formacionacademica.nombre_centro_estudio centroEstudios, "
+ "nivelestudio.nombre nivelEstudio, "
+ "estadoestudio.nombre estadoEstudio, "
+ "Format(formacionacademica.fecha_inicio, 'dd/MM/yyyy') fechaInicio, "
+ "isnull(Format(formacionacademica.fecha_fin, 'dd/MM/yyyy'),'-') fechaFin, "
+ "Isnull(formacionacademica.documento_adjunto, 'NO TIENE DOCUMENTO ADJUNTO') documentoAdjunto,"
+ "IsNull(formacionacademica.carrera_profesional,'-') carreraProfesional, "
+ "date_format(formacionacademica.fecha_inicio, '%d/%m/%Y') fechaInicio, "
+ "ifnull(date_format(formacionacademica.fecha_fin, '%d/%m/%Y'),'-') fechaFin, "
+ "ifnull(formacionacademica.documento_adjunto,'NO TIENE DOCUMENTO ADJUNTO') documentoAdjunto,"
+ "ifNull(formacionacademica.carrera_profesional,'-') carreraProfesional, "
+ "formacionacademica.sector_institucion sectorInstitucion, "
+ "Isnull(formacionacademica.numero_colegiatura, '-') numeroColegiatura, "
+ "Isnull(formacionacademica.observacion, '-') observacion "
+ "ifnull(formacionacademica.numero_colegiatura,'-') numeroColegiatura, "
+ "ifnull(formacionacademica.observacion,'-') observacion "
+ "FROM formacion_academica formacionacademica "
+ "INNER JOIN nivel_estado nivelestado ON nivelestado.codigo_nivel_estado = formacionacademica.codigo_nivel_estado "
+ "INNER JOIN estado_estudio estadoestudio ON estadoestudio.codigo_estado_estudio = nivelestado.codigo_estado_estudio "
......
......@@ -41,9 +41,6 @@ import trismegistoplanilla.dao.UbigeoDAO;
import trismegistoplanilla.dao.VacanteDAO;
public class MysqlDAOFactory extends DAOFactory {
public static void main(String[] args) {
new MysqlDAOFactory().obtenerConexion("nuevo");
}
static {
try {
......@@ -67,7 +64,6 @@ public class MysqlDAOFactory extends DAOFactory {
// url = "jdbc:mysql://localhost:3306/nuevo";
try {
conexion = DriverManager.getConnection(url, user, pwd);
System.out.println("Conexion existosa.");
} catch (SQLException e) {
e.printStackTrace();
}
......
......@@ -14,232 +14,232 @@ import trismegistoplanilla.utilities.Variables;
public class TipoExpedienteMysqlDAO implements TipoExpedienteDAO {
@Override
public JSONObject listarTipoExpediente() {
System.out.println("TipoExpedienteMysqlDAO: listarTipoExpediente");
JSONObject JOlistarTipoExpediente = null;
JSONArray JArrayArea = new JSONArray();
ResponseHelper response = new ResponseHelper();
@Override
public JSONObject listarTipoExpediente() {
System.out.println("TipoExpedienteMysqlDAO: listarTipoExpediente");
JSONObject JOlistarTipoExpediente = null;
JSONArray JArrayArea = new JSONArray();
ResponseHelper response = new ResponseHelper();
String sql = ""
+ "select "
+ "codigo_tipo_expediente codigoTipoExpediente, "
+ "nombre, "
+ "estado_registro estado "
+ "from tipo_expediente";
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
TipoExpedienteBean te = new TipoExpedienteBean();
te.setCodigoTipoExpediente(rs.getInt("codigoTipoExpediente"));
te.setNombre(rs.getString("nombre"));
JSONObject obj = new JSONObject(te);
JArrayArea.put(obj);
}
JSONObject obj = new JSONObject();
obj.put("tipoexpedientes", JArrayArea);
response.setStatus(true);
response.setMessage("Los tipo de expediente se listaron correctamente");
response.setData(obj);
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOlistarTipoExpediente = new JSONObject(response);
return JOlistarTipoExpediente;
}
String sql = ""
+ "select "
+ "codigo_tipo_expediente codigoTipoExpediente, "
+ "nombre, "
+ "estado_registro estado "
+ "from tipo_expediente";
@Override
public JSONObject registrarTipoExpediente(TipoExpedienteBean te) {
System.out.println("TipoExpedienteMysqlDAO: registrarTipoExpediente");
JSONObject JOregistrarTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
TipoExpedienteBean te = new TipoExpedienteBean();
te.setCodigoTipoExpediente(rs.getInt("codigoTipoExpediente"));
te.setNombre(rs.getString("nombre"));
JSONObject obj = new JSONObject(te);
JArrayArea.put(obj);
}
JSONObject obj = new JSONObject();
obj.put("tipoexpedientes", JArrayArea);
response.setStatus(true);
response.setMessage("Los tipo de expediente se listaron correctamente");
response.setData(obj);
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOlistarTipoExpediente = new JSONObject(response);
return JOlistarTipoExpediente;
}
String sql = "insert into tipo_expediente (nombre, estado_registro) values (upper(?) ,1)";
Connection conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion.setAutoCommit(false);
// validar existencia de tipo de expediente
JSONObject validarExistenciaTipoExpediente = validarExistenciaTipoExpediente(te);
if (validarExistenciaTipoExpediente.getBoolean("status")) {
response.setStatus(false);
response.setMessage("El tipo de expediente ingresado, ya existe en el sistema");
conexion.rollback();
} else {
ps = conexion.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, te.getNombre());
int resultadoRegistroTipoExpediente = ps.executeUpdate();
if (resultadoRegistroTipoExpediente > 0) {
rs = ps.getGeneratedKeys();
rs.next();
int codigoTipoExpediente = rs.getInt(1);
JSONObject objTipoExpediente = new JSONObject();
objTipoExpediente.put("id", codigoTipoExpediente);
objTipoExpediente.put("data", te.getNombre());
response.setStatus(true);
response.setMessage("El tipo de expediente ha sido registrado con exito");
response.setData(objTipoExpediente);
conexion.commit();
} else {
response.setStatus(false);
response.setMessage("Error: no se pudo registrar el tipo de expediente ingresado");
conexion.rollback();
}
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
try {
conexion.rollback();
} catch (SQLException ex) {
ex.printStackTrace();
}
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOregistrarTipoExpediente = new JSONObject(response);
return JOregistrarTipoExpediente;
}
@Override
public JSONObject registrarTipoExpediente(TipoExpedienteBean te) {
System.out.println("TipoExpedienteMysqlDAO: registrarTipoExpediente");
JSONObject JOregistrarTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
@Override
public JSONObject validarExistenciaTipoExpediente(TipoExpedienteBean te) {
System.out.println("TipoExpedienteMysqlDAO: validarExistenciaTipoExpediente");
JSONObject JOvalidarExistenciaTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
String sql = "insert into tipo_expediente (nombre, estado_registro) values (upper(?) ,1)";
String sql = "select count(1) existe from tipo_expediente where nombre = upper(?)";
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
ps.setString(1, te.getNombre());
rs = ps.executeQuery();
rs.next();
int existeTipoExpediente = rs.getInt("existe");
if (existeTipoExpediente > 0) {
response.setStatus(true);
} else {
response.setStatus(false);
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOvalidarExistenciaTipoExpediente = new JSONObject(response);
return JOvalidarExistenciaTipoExpediente;
}
Connection conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion.setAutoCommit(false);
// validar existencia de tipo de expediente
JSONObject validarExistenciaTipoExpediente = validarExistenciaTipoExpediente(te);
if (validarExistenciaTipoExpediente.getBoolean("status")) {
response.setStatus(false);
response.setMessage("El tipo de expediente ingresado, ya existe en el sistema");
conexion.rollback();
} else {
ps = conexion.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, te.getNombre());
int resultadoRegistroTipoExpediente = ps.executeUpdate();
if (resultadoRegistroTipoExpediente > 0) {
rs = ps.getGeneratedKeys();
rs.next();
int codigoTipoExpediente = rs.getInt(1);
JSONObject objTipoExpediente = new JSONObject();
objTipoExpediente.put("id", codigoTipoExpediente);
objTipoExpediente.put("data", te.getNombre());
response.setStatus(true);
response.setMessage("El tipo de expediente ha sido registrado con exito");
response.setData(objTipoExpediente);
conexion.commit();
} else {
response.setStatus(false);
response.setMessage("Error: no se pudo registrar el tipo de expediente ingresado");
conexion.rollback();
}
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
try {
conexion.rollback();
} catch (SQLException ex) {
ex.printStackTrace();
}
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOregistrarTipoExpediente = new JSONObject(response);
return JOregistrarTipoExpediente;
}
@Override
public JSONObject validarTipoExpedienteSeleccionadoByID(JSONArray ja) {
System.out.println("TipoExpedienteMysqlDAO: validarTipoExpedienteSeleccionadoByID");
JSONObject JOvalidarExistenciaTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
@Override
public JSONObject validarExistenciaTipoExpediente(TipoExpedienteBean te) {
System.out.println("TipoExpedienteMysqlDAO: validarExistenciaTipoExpediente");
JSONObject JOvalidarExistenciaTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
String sql = ""
+ "select "
+ "count(1) existe "
+ "from tipo_expediente "
+ "where codigo_tipo_expediente = ?";
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
int existe = 0;
for (int i = 0; i < ja.length(); i++) {
JSONObject obj = ja.getJSONObject(i);
ps.setInt(1, obj.getInt("id"));
rs = ps.executeQuery();
rs.next();
existe = rs.getInt("existe");
if (existe == 0) {
break;
}
}
if (existe > 0) {
response.setStatus(true);
} else {
response.setStatus(false);
response.setMessage("Al parecer ha seleccionado un tipo de expediente que no se encuentra registrardo, por favor seleccione un elemento correcto y vuelva a intentarlo");
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOvalidarExistenciaTipoExpediente = new JSONObject(response);
return JOvalidarExistenciaTipoExpediente;
}
String sql = "select count(1) existe from tipo_expediente where nombre = upper(?)";
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
ps.setString(1, te.getNombre());
rs = ps.executeQuery();
rs.next();
int existeTipoExpediente = rs.getInt("existe");
if (existeTipoExpediente > 0) {
response.setStatus(true);
} else {
response.setStatus(false);
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOvalidarExistenciaTipoExpediente = new JSONObject(response);
return JOvalidarExistenciaTipoExpediente;
}
@Override
public JSONObject validarTipoExpedienteSeleccionadoByID(JSONArray ja) {
System.out.println("TipoExpedienteMysqlDAO: validarTipoExpedienteSeleccionadoByID");
JSONObject JOvalidarExistenciaTipoExpediente = null;
ResponseHelper response = new ResponseHelper();
String sql = ""
+ "select "
+ "count(1) existe "
+ "from tipo_expediente "
+ "where codigo_tipo_expediente = ?";
Connection conexion = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conexion = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
ps = conexion.prepareStatement(sql);
int existe = 0;
for (int i = 0; i < ja.length(); i++) {
JSONObject obj = ja.getJSONObject(i);
ps.setInt(1, obj.getInt("id"));
rs = ps.executeQuery();
rs.next();
existe = rs.getInt("existe");
if (existe == 0) {
break;
}
}
if (existe > 0) {
response.setStatus(true);
} else {
response.setStatus(false);
response.setMessage("Al parecer ha seleccionado un tipo de expediente que no se encuentra registrardo, por favor seleccione un elemento correcto y vuelva a intentarlo");
}
} catch (SQLException e) {
e.printStackTrace();
response.setStatus(false);
response.setMessage("Error: " + e.getMessage() + " \n Error Code: [" + e.getErrorCode() + "]");
} finally {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (conexion != null) {
conexion.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
JOvalidarExistenciaTipoExpediente = new JSONObject(response);
return JOvalidarExistenciaTipoExpediente;
}
}
......@@ -187,22 +187,23 @@ public class TokenFichaMysqlDAO implements TokenFichaDAO {
PreparedStatement ps = null;
ResultSet rs = null;
String sql = ""
+ "select top 1 "
+ "select "
+ "token_ficha.codigo_sede_area codigoSedeArea, "
+ "token_ficha.codigo_area_cargo codigoAreaCargo, "
+ "sede.nombre nombreSede, "
+ "sede.deslocal nombreSede, "
+ "area.nombre nombreArea, "
+ "cargo.nombre nombreCargo "
+ "FROM token_ficha "
+ "inner join ficha ON ficha.codigo_ficha = token_ficha.codigo_ficha "
+ "inner join persona ON persona.codigo_persona = ficha.codigo_persona "
+ "inner join personal ON personal.codper = ficha.codigo_persona "
+ "inner join sede_area on token_ficha.codigo_sede_area = sede_area.codigo_sede_area "
+ "inner join sede ON sede.codigo_sede = sede_area.codigo_sede "
+ "inner join locales sede ON sede.codigo_sede = sede_area.codigo_sede "
+ "inner join area ON area.codigo_area = sede_area.codigo_area "
+ "inner join area_cargo on token_ficha.codigo_area_cargo = area_cargo.codigo_area_cargo "
+ "inner join cargo ON cargo.codigo_cargo = area_cargo.codigo_cargo "
+ "where persona.codigo_persona = ? "
+ "order by 1 desc";
+ "where personal.codper = ? "
+ "order by 1 desc "
+ "limit 1 ";
try {
cnx = MysqlDAOFactory.obtenerConexion(Variables.MYSQL_NUEVO_BD_NAME);
......
......@@ -246,7 +246,7 @@ public class TrabajadorResponsableMysqlDAO implements TrabajadorResponsableDAO {
+ "INNER JOIN estado_ficha ON estado_ficha.codigo_ficha = ficha.codigo_ficha "
+ "INNER JOIN trabajador_responsable ON estado_ficha.codigo_usuario = trabajador_responsable.codigo_usuario "
+ "WHERE "
+ " ficha.codigo_ficha = 1 "
+ " ficha.codigo_ficha = ? "
+ "ORDER BY "
+ " 1 DESC "
+ "LIMIT 1";
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment