Correcciones por pruebas de SAP

parent 0839533e
......@@ -3,7 +3,7 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/resources/general.properties</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/mx/dda/msjb/service.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/DDAExhibicion.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/bo/DDAExhibicionBO.java</file>
<file>file:/C:/Users/jfmj_/Documents/DDA/Githg/DDA_CRN_Exhibicion/src/mx/com/amx/mx/dda/crn/dao/DDAExhibicionDAO.java</file>
......
......@@ -231,6 +231,57 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
try {
//String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
//--Ejecucion
sb.append("SELECT ID_SAP,SUM(COSTO) AS COSTO,MIN(FECHA_INICIO) AS FECHA_INICIO ,MAX(VIDA_UTIL) AS VIDA_UTIL,MIN(FECHA_CONTABILIZACION) AS FECHA_CONTABILIZACION, ");
sb.append("MIN(ID_TITULO_CNTORIG) AS ID_TITULO_CNTORIG, SUBNUMERO, NUMERO_CONTRATO, MAX(FECHA_VENCIMIENTO) AS FECHA_VENCIMIENTO FROM ( ");
sb.append("select ");
sb.append("cnttit.ID_SAP, ");
sb.append("trunc(cnttit.COSTO,2) as COSTO, ");
sb.append("to_char(cnttit.FECHA_INICIO,'YYYYMMDD') as FECHA_INICIO, ");
sb.append("cnttit.VIDA_UTIL, ");
sb.append("to_char(cnttit.FECHA_INICIO,'DD/MM/YYYY') as FECHA_CONTABILIZACION, ");
sb.append("cnttit.ID_TITULO_CNTORIG, ");
sb.append("cnttit.SUBNUMERO, ");
sb.append("cnt.NUMERO_CONTRATO, ");
sb.append("to_char(cnt.FECHA_INICIO,'YYYYMMDD') AS FECHA_VENCIMIENTO ");
sb.append("from ");
sb.append("DDA_T_CONTRATO_TITULO cnttit, ");
sb.append("DDA_T_CONTRATO cnt ");
sb.append("where ");
sb.append("cnttit.ID_CONTRATO = cnt.ID_CONTRATO ");
sb.append("and cnttit.ID_SAP is not null ");
sb.append("and cnttit.SUBNUMERO is not null ");
sb.append("and cnt.ID_ESTATUS = ? ");
sb.append("and cnttit.FECHA_NOTIFSAP is null ");
sb.append("ORDER BY CNTTIT.FECHA_INICIO DESC) ");
sb.append("WHERE rownum < 901 ");
sb.append("GROUP BY ID_SAP, SUBNUMERO, NUMERO_CONTRATO");
//--Debug
LOG.debug(">Sql_D [obtenerTitulosRecienExhibidos]:" + sb.toString());
final String lstSQL = sb.toString();
qryParams.add(ESTATUS_VIGENTE);
//qryParams.add(lstFechaReferencia);
lobResultado = (ArrayList<DatosCntTituloExhibicionDTO>) getJdbcTemplate().query(lstSQL, qryParams.toArray(), new BeanPropertyRowMapper<>(DatosCntTituloExhibicionDTO.class));
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::obtenerTitulosRecienExhibidos]: " + e.getMessage());
throw new Exception(e.getMessage());
}
return lobResultado;
}
@Override
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception {
List<DatosCntTituloExhibicionDTO> lobResultado = new ArrayList<>();
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
try {
//String lstFechaReferencia = (pstFechaReferencia != null && pstFechaReferencia.length() > 0) ? pstFechaReferencia : "";
......@@ -339,7 +390,7 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception {
boolean resultado = Boolean.FALSE;
StringBuilder sb = new StringBuilder();
final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?";
final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada, ID_CONTRATO AS contrato FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?";
List<Object> qryParam = new ArrayList<>();
List<Object> qryParams = new ArrayList<>();
......@@ -366,8 +417,10 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sb.append("WHERE ");
sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? ");
sb.append("AND ID_CONTRATO = ? ");
qryParams.add(lobResultado.get(0).getNombre());
qryParams.add(lobResultado.get(0).getTemporada());
qryParams.add(lobResultado.get(0).getContrato());
LOG.debug(">Sql_D [Actualizacion de todos los titulos de la serie]:" + sb.toString());
}
}
......@@ -843,6 +896,12 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
StringBuffer sb = new StringBuffer();
StringBuffer sbD = new StringBuffer();
List<Object> qryParams = new ArrayList<Object>();
final String sbCon = "SELECT NOMBRE_UNICO AS nombre, TEMPORADA AS temporada, ID_CONTRATO AS contrato FROM DDA_T_CONTRATO_TITULO WHERE ID_TITULO_CNTORIG = ?";
List<Object> qryParam = new ArrayList<>();
qryParam.add(idtitulo);
try {
//--Debug
......@@ -851,15 +910,30 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
sbD.append("' WHERE ID_TITULO_CNT = ");
sbD.append(idtitulo);
LOG.debug(">Sql_D [actualizarEstatusSapTitulos]:" + sbD.toString());
List<TituloDTO> lobResultado = getJdbcTemplate().query(sbCon, qryParam.toArray(), new BeanPropertyRowMapper<>(TituloDTO.class));
if (Objects.nonNull(lobResultado) && lobResultado.size() > 0) {
if (Objects.isNull(lobResultado.get(0).getTemporada())) {
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append(" WHERE ID_TITULO_CNT = ? ");
qryParams.add(mensaje);
qryParams.add(idtitulo);
} else {
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append("WHERE ");
sb.append("NOMBRE_UNICO = ? ");
sb.append("AND TEMPORADA = ? ");
sb.append("AND ID_CONTRATO = ? ");
qryParams.add(mensaje);
qryParams.add(lobResultado.get(0).getNombre());
qryParams.add(lobResultado.get(0).getTemporada());
qryParams.add(lobResultado.get(0).getContrato());
}
}
//--Ejecucion
sb.append("UPDATE DDA_T_CONTRATO_TITULO SET ESTATUS_SAP = ? ");
sb.append(" WHERE ID_TITULO_CNT = ? ");
sb.append(idtitulo);
final String lstSQL = sb.toString();
qryParams.add(mensaje);
qryParams.add(idtitulo);
jdbcTemplate.update(lstSQL, qryParams.toArray());
......@@ -867,6 +941,34 @@ public class DDAExhibicionDAO implements IDDAExhibicionDAO {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::ejecutarSPAmortizacionAjustada]: " + e.getMessage());
}
}
public String validarIdSap(String numeroContrato){
StringBuilder sb = new StringBuilder();
List<Object> qryParams = new ArrayList<>();
String lstValor = "";
try {
sb.append("SELECT tit.ID_SAP AS ID_SAP FROM DDA_T_CONTRATO cnt inner join DDA_T_CONTRATO_TITULO tit on cnt.ID_CONTRATO = tit.ID_CONTRATO ");
sb.append("WHERE cnt.NUMERO_CONTRATO = '" + numeroContrato + "' AND tit.ID_SAP IS NOT NULL GROUP BY tit.ID_SAP ");
LOG.debug(">Sql_D [verificaEjecutandoseProcesoNotificacion]:" + sb.toString());
final String lstSQL = sb.toString();
lstValor = (String) jdbcTemplate.queryForObject(lstSQL, qryParams.toArray(), String.class);
if (Objects.nonNull(lstValor) && !lstValor.isEmpty()) {
lstValor = "";
}
} catch (EmptyResultDataAccessException er) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::verificaEjecutandoseProcesoNotificacion]: No se encontraron registros coincidentes con la clave especificada. " + er.getMessage());
} catch (Exception e) {
LOG.error("Exception[" + this.getClass().getSimpleName() + "::verificaEjecutandoseProcesoNotificacion]: " + e.getMessage());
}
return lstValor;
}
......
......@@ -17,6 +17,7 @@ public interface IDDAExhibicionDAO
public boolean verificaEjecutandoseProcesoNotificacion() throws Exception;
public boolean updateEjecutandoseProcesoNotificacion(String pstValor) throws Exception;
public List<DatosCntTituloExhibicionDTO> obtenerTitulosRecienExhibidos(String pstFechaReferencia) throws Exception;
public List<DatosCntTituloExhibicionDTO> obtenerContratosRecienExhibidos(String pstFechaReferencia) throws Exception;
public boolean actualizaFechaNotificacion(ContratoTituloDTO dto) throws Exception;
public boolean insertarRegistroSubnum(String pstIdTituloCnt) throws Exception;
public List<ItemActivoFijoDTO> obtenerTitulosSinIdSAP_RecienExhibidos(String pstFechaReferencia) throws Exception;
......
......@@ -5,56 +5,67 @@ import java.util.ArrayList;
import java.util.List;
/**
* Representa el manejo interno que se le dara al llamado del WS a SAP para Notificar Activos Fijos (Titulos recien exhibidos).
* considerando los posibles escenarios de exito y error.
* Si el objeto TransactionFaultDTO tiene valores, entonces ocurrio alguna excepcion en el llamado.
* Si la lista de RespSAPNotificaAFijoDTO tiene valores entonces la conexion al servicio se realizo satisfactoriamente.
* En resumen, ambos objetos deben ser mutuamente excluyentes, indicando el exito o el error segun haya sucedido.
* Representa el manejo interno que se le dara al llamado del WS a SAP para
* Notificar Activos Fijos (Titulos recien exhibidos). considerando los posibles
* escenarios de exito y error. Si el objeto TransactionFaultDTO tiene valores,
* entonces ocurrio alguna excepcion en el llamado. Si la lista de
* RespSAPNotificaAFijoDTO tiene valores entonces la conexion al servicio se
* realizo satisfactoriamente. En resumen, ambos objetos deben ser mutuamente
* excluyentes, indicando el exito o el error segun haya sucedido.
*/
public class ResultadoNotificacionDTO implements Serializable
{
private static final long serialVersionUID = 1L;
private List<RespSAPNotificaAFijoDTO> notificaciones = new ArrayList<RespSAPNotificaAFijoDTO>();
private TransactionFaultDTO transFault = new TransactionFaultDTO();
private boolean resultado;
public List<RespSAPNotificaAFijoDTO> getNotificaciones() {
return notificaciones;
}
public void setNotificaciones(List<RespSAPNotificaAFijoDTO> notificaciones) {
this.notificaciones = notificaciones;
}
public TransactionFaultDTO getTransFault() {
return transFault;
}
public void setTransFault(TransactionFaultDTO transFault) {
this.transFault = transFault;
}
public boolean getResultado() {
return resultado;
}
public void setResultado(boolean resultado) {
this.resultado = resultado;
}
public String toString()
{
StringBuilder result = new StringBuilder();
String NEW_LINE = System.getProperty("line.separator");
result.append(" [Begin of Class] " + NEW_LINE);
result.append(this.getClass().getSimpleName() + " Object {" + NEW_LINE);
result.append(" notificaciones: _" + this.getNotificaciones().size() + "_" + NEW_LINE);
result.append(" tFault: _" + this.getTransFault().toString() + "_" + NEW_LINE);
result.append(" resultado: _" + this.getResultado() + "_" + NEW_LINE);
result.append(" [End of Class] " + NEW_LINE);
result.append("}");
NEW_LINE = null;
return result.toString();
}
public class ResultadoNotificacionDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<RespSAPNotificaAFijoDTO> notificaciones = new ArrayList<RespSAPNotificaAFijoDTO>();
private TransactionFaultDTO transFault = new TransactionFaultDTO();
private Integer titulosEnviados;
private boolean resultado;
public Integer getTitulosEnviados() {
return titulosEnviados;
}
public void setTitulosEnviados(Integer titulosEnviados) {
this.titulosEnviados = titulosEnviados;
}
public List<RespSAPNotificaAFijoDTO> getNotificaciones() {
return notificaciones;
}
public void setNotificaciones(List<RespSAPNotificaAFijoDTO> notificaciones) {
this.notificaciones = notificaciones;
}
public TransactionFaultDTO getTransFault() {
return transFault;
}
public void setTransFault(TransactionFaultDTO transFault) {
this.transFault = transFault;
}
public boolean getResultado() {
return resultado;
}
public void setResultado(boolean resultado) {
this.resultado = resultado;
}
public String toString() {
StringBuilder result = new StringBuilder();
String NEW_LINE = System.getProperty("line.separator");
result.append(" [Begin of Class] " + NEW_LINE);
result.append(this.getClass().getSimpleName() + " Object {" + NEW_LINE);
result.append(" notificaciones: _" + this.getNotificaciones().size() + "_" + NEW_LINE);
result.append(" tFault: _" + this.getTransFault().toString() + "_" + NEW_LINE);
result.append(" resultado: _" + this.getResultado() + "_" + NEW_LINE);
result.append(" titulosEnviados: _" + this.getTitulosEnviados() + "_" + NEW_LINE);
result.append(" [End of Class] " + NEW_LINE);
result.append("}");
NEW_LINE = null;
return result.toString();
}
}
......@@ -13,6 +13,7 @@ public class TituloDTO {
private String nombre;
private String temporada;
private String contrato;
public String getNombre() {
return nombre;
......@@ -29,5 +30,13 @@ public class TituloDTO {
public void setTemporada(String temporada) {
this.temporada = temporada;
}
public String getContrato() {
return contrato;
}
public void setContrato(String contrato) {
this.contrato = contrato;
}
}
......@@ -32,40 +32,19 @@ public class service extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html");
response.setContentType("application/json");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Ejecucion Notificacion SAP</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Ejecucion Notificacion SAP<</h1>");
out.println("</body>");
out.println("</html>");
ejec();
String msg = ejec();
out.write("{\"rows\":\"" + msg + "\"}");
}
public void ejec() {
public String ejec() {
ScheduledExecutorService se = Executors.newScheduledThreadPool(5);
ScheduledFuture sf = se.schedule(new Callable() {
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));
@Override
public Object call() throws Exception {
// System.out.println("##################################_______________AQUI_______________");
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));
getEx().ejecutaProceso();
// System.out.println("##################################_______________AQUI2_______________");
return "Done";
}
}, 1, TimeUnit.SECONDS);//Retrazo de tiempo
// System.out.println("Result of ScheduledFuture: " );
se.shutdown();
getEx().ejecutaProceso();
return "OK";
}
/**
......
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