codigo comentado, metodos sin usar y archivos con terminacion bak orig dos fuera

parent 0e72f5b3
#-- Version desarrollo
log4j.logger.com.mx.dla.dda=DEBUG, LOGFILE
log4j.logger.app=DEBUG, app
log4j.logger.excelMapper=DEBUG, excel
log4j.appender.app=org.apache.log4j.RollingFileAppender
log4j.appender.app.File=logs/dla/app.log
log4j.appender.app.MaxFileSize=10MB
log4j.appender.app.MaxBackupIndex=5
log4j.appender.app.layout=org.apache.log4j.PatternLayout
log4j.appender.app.layout.ConversionPattern=%-5p - [%d{DATE}] - [%42C{1}\:%4L] - %m%n
log4j.appender.excel=org.apache.log4j.RollingFileAppender
log4j.appender.excel.File=logs/dla/excel.log
log4j.appender.excel.MaxFileSize=10MB
log4j.appender.excel.MaxBackupIndex=5
log4j.appender.excel.layout=org.apache.log4j.PatternLayout
log4j.appender.excel.layout.ConversionPattern=%-5p - [%d{DATE}] - [%42C{1}\:%4L] - %m%n
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.File=logs/dla/appDLA.log
log4j.appender.LOGFILE.MaxFileSize=10MB
log4j.appender.LOGFILE.MaxBackupIndex=5
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-5p - [%d{DATE}] - [%42C{1}\:%4L] - %m%n
\ No newline at end of file
...@@ -173,10 +173,12 @@ function procesaRespuestaObtenerPermisos(jsonData) {//************* ...@@ -173,10 +173,12 @@ function procesaRespuestaObtenerPermisos(jsonData) {//*************
} }
} }
if (vpermisos[i].selector == "bFinalizar" && varea.autorizaContrato == 0) { if (vpermisos[i].selector == "bFinalizar") {
if (varea.autorizaContrato == 0) {
$("#" + vpermisos[i].selector).prop("disabled", true);//ocultaba el boton de finalizar registro $("#" + vpermisos[i].selector).prop("disabled", true);//ocultaba el boton de finalizar registro
} }
} }
}
} //************* } //*************
function llamaObtenerPermisos() { function llamaObtenerPermisos() {
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<url>http://maven.apache.org</url>
<groupId>com.mx.dla</groupId>
<artifactId>dla-m</artifactId>
<packaging>pom</packaging>
<version>1.1</version>
<name>dla-m</name>
<properties>
<spring.version>3.1.4.RELEASE</spring.version>
<struts.version>2.3.24</struts.version>
<aspectj.version>1.6.11</aspectj.version>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>MM-dd-yyyy</maven.build.timestamp.format>
</properties>
<modules>
<module>front</module>
<module>dominio</module>
<module>servicios</module>
<module>persistencia</module>
</modules>
<!-- <repositories>
<repository>
<id>laptop</id>
<layout>default</layout>
<url>http://200.57.181.10:8090/jenkins/plugin/chucknorris/images/repository/</url>
</repository>
</repositories> -->
<dependencies>
<!-- SPRING dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.2.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- STRUTS 2 dependencies -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<!-- MYBATIS 2 dependencies -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
</dependency>
<!-- JEE -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Jackson -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.8.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.6</version>
</dependency>
<!-- UTILS -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!-- Application loggin libraries -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<!-- Application test libraries -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<!-- DLA -->
<dependency>
<groupId>com.mx.dla</groupId>
<artifactId>domain-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
</exclusion>
<exclusion>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<!-- GSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<p.resources.dir>profiles/development/resources</p.resources.dir>
</properties>
<build>
<finalName>dla</finalName>
</build>
</profile>
<profile>
<id>qa</id>
<properties>
<p.resources.dir>profiles/qa/resources</p.resources.dir>
</properties>
<build>
<finalName>dla_qa</finalName>
</build>
</profile>
<profile>
<id>production</id>
<properties>
<p.resources.dir>profiles/production/resources</p.resources.dir>
</properties>
<build>
<finalName>portal_dda</finalName>
</build>
</profile>
</profiles>
<build>
<testResources>
<!-- Que use los por default de maven -->
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>${project.basedir}/../${p.resources.dir}</directory>
<filtering>false</filtering>
</resource>
<resource> <!-- Que use los por default de maven -->
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- Plugin para poner el valor del release -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>${basedir}/target/classes/message.properties</include>
</includes>
<replacements>
<!-- Variable del maven -->
<replacement>
<token>@cooking.date@</token>
<value>${maven.build.timestamp}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Para la compatibilidad del import a eclipse via command line -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>iso-8859-1</encoding>
</configuration>
</plugin>
<!-- Esta opcion es para las pruebas en command line -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
<!-- Plugin para deployment de wars -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>${server.url}</url>
<server>${server.id}</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
<!--Comentario-->
# Archivo de configuraciones para ambientes de QA o Produccion (con tomcat)
#uri.file.store =/home/scm/server/dda/doctosContratos/
#uri.file.titulos =/home/scm/server/dda/titulos/error/
#uri.file.carga.fees =/home/scm/server/dda/cargaFees/excel/
#uri.file.carga.broadview =/home/scm/server/dda/actualizaIdBV/excel/
#uri.file.carga.suscriptores=/home/scm/server/dda/cargaSuscriptores/excel/
#uri.file.carga.titulos =/home/scm/server/dda/cargaTitulos/excel/
#uri.file.carga.titulosLF =/home/scm/server/dda/cargaTitulosLF/excel/
#uri.file.carga.titulosLF =/home/admonDLA/dda/cargaTitulosLF/excel/
#uri.file.store =/home/admonDLA/dda/doctosContratos/
#uri.file.titulos =/home/admonDLA/dda/titulos/error/
#uri.file.carga.fees =/home/admonDLA/dda/cargaFees/excel/
#uri.file.carga.broadview =/home/admonDLA/dda/actualizaIdBV/excel/
#uri.file.carga.suscriptores=/home/admonDLA/dda/cargaSuscriptores/excel/
#uri.file.carga.titulos =/home/admonDLA/dda/cargaTitulos/excel/
#uri.file.carga.transacciones = /home/admonDLA/dda/cargaTitulosPN/excel/
#uri.file.carga.titulosTR =/home/admonDLA/dda/cargaTitulosTR/excel/
#uri.file.carga.visualizaciones = /home/scm/server/dda/cargaTitulosVS/excel/
#uri.file.reporte.baseActivosSQL= /home/admonDLA/dda/sqlReportes/sql/
#uri.file.reporte.TransaccionesvistaPrevia = /home/admonDLA/dda/sqlReportes/js/vistaprevia.js
#uri.file.reporte.txtcpv= /home/admonDLA/dda/sqlReportes/txt/
uri.file.store =/home/scm/server/dda/doctosContratos/
uri.file.titulos =/home/scm/server/dda/titulos/error/
uri.file.carga.fees =/home/scm/server/dda/cargaFees/excel/
uri.file.carga.broadview =/home/scm/server/dda/actualizaIdBV/excel/
uri.file.carga.suscriptores=/home/scm/server/dda/cargaSuscriptores/excel/
uri.file.carga.titulos =/home/scm/server/dda/cargaTitulos/excel/
uri.file.carga.titulosLF =/home/scm/server/dda/cargaTitulosLF/excel/
uri.file.carga.transacciones = /home/scm/server/dda/cargaTitulosPN/excel/
uri.file.carga.titulosTR =/home/scm/server/dda/cargaTitulosTR/excel/
uri.file.carga.visualizaciones = /home/scm/server/dda/cargaTitulosVS/excel/
uri.file.reporte.baseActivosSQL= /home/scm/server/dda/sqlReportes/sql/
uri.file.reporte.txtcpv= /home/scm/server/dda/sqlReportes/txt/
#servidor.rest.ws=200.57.181.10:8090
#TELMEX
#servidor.rest.ws=10.192.24.136:8006
#servidor.rest.ws=127.0.0.1:8090
servidor.rest.ws=localhost:8080
\ No newline at end of file
#***Propiedades para notificacion de sap desde pantalla de generales***
#Development version
ordenInterna.idPosicion=00010
ordenInterna.idMaterial.suscripcion=400000010
ordenInterna.idMaterial.transaccines=300000004
ordenInterna.idMaterial.licenseFee=300000104
ordenInterna.centro=NT09
ordenInterna.cantidad=12000.00
ordenInterna.precio=1
ordenInterna.indicadorIva=U0
ordenInterna.tipoImputacion.noAmortizable=K
ordenInterna.tipoImputacion.siAmortizable=F
ordenInterna.idPosicionAcc=00010
ordenInterna.centroCostos=07A01US501
ordenInterna.idOrden=1000040
ordenInterna.sociedad=NT09
ordenInterna.claseDoc.t=NT08
ordenInterna.claseDoc.a=CD06
ordenInterna.claseDoc.na=CD06
ordenInterna.idProveedor=3001000056
ordenInterna.orgCompras=AMCO
ordenInterna.grupoCompras=N06
adendumEnmienda.idPosicion=00010
#************************************************************************
#URL'S DE CONEXION DLA---->WEB SERVICES SAP (Rest Methods)
uri.rest.entradaMercancia = http://${servidor.rest.ws}/ddaContratoCWS/services/entradaMercancia
uri.rest.facturaNotifica = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarFactura
uri.rest.movimientoFinal = http://${servidor.rest.ws}/ddaPedidoCompraCWS/services/pedidoCompraWS/enviaMovimientoFinal
uri.rest.ordenesInternas.apartado = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/crearOrdenInterna
uri.rest.ordenesInternas.presupuesto = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/modificarOrdenInterna
uri.rest.envia.correo = http://${servidor.rest.ws}/dla-services/email/enviaCorreo
uri.rest.validaPresupuesto = http://${servidor.rest.ws}/dla-services/presupuesto/validaPresupuesto
uri.rest.generaAmortizacion = http://${servidor.rest.ws}/dla-services/presupuesto/generaAmortizacion
uri.rest.enviaCorreoCalend = http://${servidor.rest.ws}/dla-services/seguimiento/getSeguimiento
uri.rest.obtenerSuscriptoresContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerSuscriptoresContrato
uri.rest.carga.titulos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulos
uri.rest.calcularAmortizacionPorContrato= http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.generaAmortizacion2 = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.costoSuscriptores = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularCostoSuscriptores
uri.rest.validaMinimoSeleccion = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarMinimoSeleccion
uri.rest.costoTitulo = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerCostoTitulo
uri.rest.validarPresupuestoPorContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarPresupuestoPorContrato
uri.rest.actualizar.id.broadview = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/actualizarIdBroadView
uri.rest.registro.sap.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPSuscripcion
uri.rest.registro.sap.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPTransaccional
uri.rest.registro.sap.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPLicenseFee
uri.rest.registro.sap.enmienda.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaSuscripcion
uri.rest.registro.sap.enmienda.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaTransaccional
uri.rest.registro.sap.enmienda.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaLicenseFee
uri.rest.notaCreditoCarga = http://${servidor.rest.ws}/ddaFacturacionCWS/services/facturasWS/cargarNotaCredito
uri.ws.carga.transacciones.procesarCargaTitulosPN = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosPN
uri.ws.carga.transacciones.asociarTitulosTransCntVigentes = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/asociarTitulosTransCntVigentes
uri.ws.contrato.transaccion.titulos.notificarInventarioTitulos = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarInventarioTitulos
uri.ws.contrato.transaccion.titulos.procesarCargaTitulosTR = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosTR
uri.rest.carga.transaccion.vistaprevia = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/generarReporte
uri.rest.carga.titulos.license = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosLF
uri.rest.reporte.amortizacion.baseActivos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/generarReporte
uri.ws.carga.visualizaciones.procesa = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosVS
uri.rest.titulosBroadView = http://localhost:5001/v1/broadview/titulos/
uri.rest.crnExhibicion = http://localhost:8080/DDA_CRN_Exhibicion/servicio
uri.rest.crnClienteSAP = http://localhost:8080/DDA_CRN_ClienteSAP/servicioEnmienda
#*************************Propiedades para Facturacion*******************
#sociedad tambien se usa en Nota Credito
factura.header.sociedad =NT07
factura.header.indicador =X
factura.header.tipoDocumento=RE
#moneda tambien se usa en Nota Credito
factura.header.moneda =USD
factura.detalle.impuesto =U0
#cantidad tambien se usa en Nota Credito
factura.detalle.cantidad =1
factura.detalle.isoMedida =90000163
envMov.indEntregaFinal =X
envMov.indFacturaFinal =X
envMov.noItem =00010
#*************************Propiedades para Nota Credito*******************
notaCredito.header.tipoDocumento=KG
notaCredito.detalle.isoMedida =SRV
\ No newline at end of file
# Archivo de configuraciones para ambientes de QA o Produccion (con tomcat)
uri.file.store =/home/scm/server/dda/doctosContratos/
uri.file.titulos =/home/scm/server/dda/titulos/error/
uri.file.carga.fees =/home/scm/server/dda/cargaFees/excel/
uri.file.carga.broadview =/home/scm/server/dda/actualizaIdBV/excel/
uri.file.carga.suscriptores=/home/scm/server/dda/cargaSuscriptores/excel/
uri.file.carga.titulos =/home/scm/server/dda/cargaTitulos/excel/
uri.file.carga.titulosLF =/home/scm/server/dda/cargaTitulosLF/excel/
uri.file.carga.transacciones = /home/scm/server/dda/cargaTitulosPN/excel/
uri.file.carga.titulosTR =/home/scm/server/dda/cargaTitulosTR/excel/
uri.file.carga.visualizaciones = /home/scm/server/dda/cargaTitulosVS/excel/
uri.file.reporte.baseActivosSQL= /home/scm/server/dda/sqlReportes/sql/
uri.file.reporte.txtcpv= /home/scm/server/dda/sqlReportes/txt/
servidor.rest.ws=localhost:5000
# Archivo de configuraciones
excel.shellPath =/home/DLASilicon/dda/generadorExcel
excel.process.path =/home/DLASilicon/dda/generadorExcel
excel.process.source.path =/home/DLASilicon/dda/generadorExcel/entradas
excel.process.target.path =/home/DLASilicon/dda/generadorExcel/salidas
excel.shellName =vti_crearExcelXlsx.sh
excel.process.source.data =CTV_VistaPrevia_Chile_01092015.xml
excel.process.source.style =vti_css.xml
excel.process.targetName =resultado.xlsx
excel.process.tipo =1
excel.process.bloqueo =2
excel.process.password =
#***Propiedades para notificacion de sap desde pantalla de generales***
#Production version
ordenInterna.idPosicion=00010
ordenInterna.idMaterial.suscripcion=300000259
ordenInterna.idMaterial.transaccines=300000259
ordenInterna.idMaterial.licenseFee=300000259
ordenInterna.centro=NT09
ordenInterna.cantidad=12000.00
ordenInterna.precio=1
ordenInterna.indicadorIva=U0
ordenInterna.tipoImputacion.noAmortizable=K
ordenInterna.tipoImputacion.siAmortizable=F
ordenInterna.idPosicionAcc=00010
ordenInterna.centroCostos=07UOVA0001
ordenInterna.idOrden=000000400098
ordenInterna.sociedad=NT09
ordenInterna.claseDoc.t=CD06
ordenInterna.claseDoc.a=CD06
ordenInterna.claseDoc.na=CD06
ordenInterna.idProveedor=0030800000
ordenInterna.orgCompras=AMCO
ordenInterna.grupoCompras=N06
adendumEnmienda.idPosicion=00010
#************************************************************************
#URL'S DE CONEXION DLA---->WEB SERVICES SAP (Rest Methods)
uri.rest.entradaMercancia = http://${servidor.rest.ws}/ddaContratoCWS/services/entradaMercancia
uri.rest.facturaNotifica = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarFactura
uri.rest.movimientoFinal = http://${servidor.rest.ws}/ddaPedidoCompraCWS/services/pedidoCompraWS/enviaMovimientoFinal
uri.rest.ordenesInternas.apartado = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/crearOrdenInterna
uri.rest.ordenesInternas.presupuesto = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/modificarOrdenInterna
uri.rest.envia.correo = http://${servidor.rest.ws}/dla-services/email/enviaCorreo
uri.rest.validaPresupuesto = http://${servidor.rest.ws}/dla-services/presupuesto/validaPresupuesto
uri.rest.generaAmortizacion = http://${servidor.rest.ws}/dla-services/presupuesto/generaAmortizacion
uri.rest.enviaCorreoCalend = http://${servidor.rest.ws}/dla-services/seguimiento/getSeguimiento
uri.rest.obtenerSuscriptoresContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerSuscriptoresContrato
uri.rest.carga.titulos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulos
uri.rest.calcularAmortizacionPorContrato= http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.generaAmortizacion2 = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.costoSuscriptores = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularCostoSuscriptores
uri.rest.validaMinimoSeleccion = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarMinimoSeleccion
uri.rest.costoTitulo = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerCostoTitulo
uri.rest.validarPresupuestoPorContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarPresupuestoPorContrato
uri.rest.actualizar.id.broadview = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/actualizarIdBroadView
uri.rest.registro.sap.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPSuscripcion
uri.rest.registro.sap.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPTransaccional
uri.rest.registro.sap.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPLicenseFee
uri.rest.registro.sap.enmienda.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaSuscripcion
uri.rest.registro.sap.enmienda.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaTransaccional
uri.rest.registro.sap.enmienda.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaLicenseFee
uri.rest.notaCreditoCarga = http://${servidor.rest.ws}/ddaFacturacionCWS/services/facturasWS/cargarNotaCredito
uri.ws.carga.transacciones.procesarCargaTitulosPN = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosPN
uri.ws.carga.transacciones.asociarTitulosTransCntVigentes = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/asociarTitulosTransCntVigentes
uri.ws.contrato.transaccion.titulos.notificarInventarioTitulos = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarInventarioTitulos
uri.ws.contrato.transaccion.titulos.procesarCargaTitulosTR = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosTR
uri.rest.carga.titulos.license = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosLF
uri.rest.reporte.amortizacion.baseActivos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/generarReporte
uri.ws.carga.visualizaciones.procesa = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosVS
#*************************Propiedades para Facturacion*******************
#sociedad tambien se usa en Nota Credito
factura.header.sociedad =NT09
factura.header.indicador =X
factura.header.tipoDocumento=RE
#moneda tambien se usa en Nota Credito
factura.header.moneda =USD
factura.detalle.impuesto =U0
#cantidad tambien se usa en Nota Credito
factura.detalle.cantidad =1
factura.detalle.isoMedida =90000163
envMov.indEntregaFinal =X
envMov.indFacturaFinal =X
envMov.noItem =00010
#*************************Propiedades para Nota Credito*******************
notaCredito.header.tipoDocumento=KG
notaCredito.detalle.isoMedida =SRV
#***Propiedades para notificacion de sap desde pantalla de generales***
#QA version
ordenInterna.idPosicion=00010
ordenInterna.idMaterial.suscripcion=300000259
ordenInterna.idMaterial.transaccines=300000166
ordenInterna.idMaterial.licenseFee=300000166
ordenInterna.centro=NT09
ordenInterna.cantidad=12000.00
ordenInterna.precio=1
ordenInterna.indicadorIva=U0
ordenInterna.tipoImputacion.noAmortizable=K
ordenInterna.tipoImputacion.siAmortizable=F
ordenInterna.idPosicionAcc=00010
ordenInterna.centroCostos=0908A05000
ordenInterna.idOrden=000000400098
ordenInterna.sociedad=NT09
ordenInterna.claseDoc.t=CD06
ordenInterna.claseDoc.a=CD06
ordenInterna.claseDoc.na=CD06
ordenInterna.idProveedor=0030800000
ordenInterna.orgCompras=AMCO
ordenInterna.grupoCompras=N06
adendumEnmienda.idPosicion=00010
#************************************************************************
#URL'S DE CONEXION DLA---->WEB SERVICES SAP (Rest Methods)
uri.rest.entradaMercancia = http://${servidor.rest.ws}/ddaContratoCWS/services/entradaMercancia
uri.rest.facturaNotifica = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarFactura
uri.rest.movimientoFinal = http://${servidor.rest.ws}/ddaPedidoCompraCWS/services/pedidoCompraWS/enviaMovimientoFinal
uri.rest.ordenesInternas.apartado = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/crearOrdenInterna
uri.rest.ordenesInternas.presupuesto = http://${servidor.rest.ws}/ddaOrdenesInternasCWS/services/ordenesInternasWS/modificarOrdenInterna
uri.rest.envia.correo = http://${servidor.rest.ws}/dla-services/email/enviaCorreo
uri.rest.validaPresupuesto = http://${servidor.rest.ws}/dla-services/presupuesto/validaPresupuesto
uri.rest.generaAmortizacion = http://${servidor.rest.ws}/dla-services/presupuesto/generaAmortizacion
uri.rest.enviaCorreoCalend = http://${servidor.rest.ws}/dla-services/seguimiento/getSeguimiento
uri.rest.obtenerSuscriptoresContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerSuscriptoresContrato
uri.rest.carga.titulos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulos
uri.rest.calcularAmortizacionPorContrato= http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.generaAmortizacion2 = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularAmortizacionPorContrato
uri.rest.costoSuscriptores = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/calcularCostoSuscriptores
uri.rest.validaMinimoSeleccion = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarMinimoSeleccion
uri.rest.costoTitulo = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/obtenerCostoTitulo
uri.rest.validarPresupuestoPorContrato = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/validarPresupuestoPorContrato
uri.rest.actualizar.id.broadview = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/actualizarIdBroadView
uri.rest.registro.sap.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPSuscripcion
uri.rest.registro.sap.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPTransaccional
uri.rest.registro.sap.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPLicenseFee
uri.rest.registro.sap.enmienda.suscripcion = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaSuscripcion
uri.rest.registro.sap.enmienda.transaccional = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaTransaccional
uri.rest.registro.sap.enmienda.license.fee = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/registrarSAPEnmiendaLicenseFee
uri.rest.notaCreditoCarga = http://${servidor.rest.ws}/ddaFacturacionCWS/services/facturasWS/cargarNotaCredito
uri.ws.carga.transacciones.procesarCargaTitulosPN = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosPN
uri.ws.carga.transacciones.asociarTitulosTransCntVigentes = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/asociarTitulosTransCntVigentes
uri.ws.contrato.transaccion.titulos.notificarInventarioTitulos = http://${servidor.rest.ws}/DDA_WSB_ClienteSAP/services/contrato/notificarInventarioTitulos
uri.ws.contrato.transaccion.titulos.procesarCargaTitulosTR = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosTR
uri.rest.carga.transaccion.vistaprevia = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/generarReporte
uri.rest.carga.titulos.license = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosLF
uri.rest.reporte.amortizacion.baseActivos = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/generarReporte
uri.ws.carga.visualizaciones.procesa = http://${servidor.rest.ws}/DDA_WSB_Procesos/services/proceso/procesarCargaTitulosVS
uri.rest.titulosBroadView = http://localhost:5000/v1/broadview/titulos/
uri.rest.crnExhibicion = http://localhost:8080/DDA_CRN_Exhibicion/servicio
uri.rest.crnClienteSAP = http://localhost:8080/DDA_CRN_ClienteSAP/servicioEnmienda
#*************************Propiedades para Facturacion*******************
#sociedad tambien se usa en Nota Credito
factura.header.sociedad =NT09
factura.header.indicador =X
factura.header.tipoDocumento=RE
#moneda tambien se usa en Nota Credito
factura.header.moneda =USD
factura.detalle.impuesto =U0
#cantidad tambien se usa en Nota Credito
factura.detalle.cantidad =1
factura.detalle.isoMedida =90000163
envMov.indEntregaFinal =X
envMov.indFacturaFinal =X
envMov.noItem =00010
#*************************Propiedades para Nota Credito*******************
notaCredito.header.tipoDocumento=KG
notaCredito.detalle.isoMedida =SRV
package com.mx.dla.dda.reporte.cpview.bos;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.mx.dla.dda.excelMapper.bos.ExcelMapperTransform;
import com.mx.dla.dda.excelMapper.constants.ExcelMapperDataType;
import com.mx.dla.dda.excelMapper.context.ExcelMapperContext;
import com.mx.dla.dda.excelMapper.dtos.ExcelMapper;
import com.mx.dla.dda.excelMapper.dtos.ExcelRule;
import com.mx.dla.dda.excelMapper.exceptions.ExcelMapperException;
import com.mx.dla.dda.general.constants.MesesAnio;
import com.mx.dla.dda.general.utilerias.FechaUtilerias;
import com.mx.dla.dda.reporte.amortizacion.baseActivos.bos.BaseActivosBO;
import com.mx.dla.dda.reporte.cpview.daos.ReporteCostPerViewDAO;
import com.mx.dla.dda.reporte.cpview.dtos.CargaVisualizacionesDetalleDTO;
import com.mx.dla.dda.reporte.cpview.dtos.CargaVisualizacionesPrincipalDTO;
import com.mx.dla.dda.reporte.cpview.dtos.CostPerViewEstudioAnualDatosDTO;
import com.mx.dla.dda.reporte.cpview.dtos.CostPerViewEstudioMensualDatosDTO;
import com.mx.dla.dda.reporte.cpview.dtos.ParamCargaTitulosVSDTO;
import com.mx.dla.dda.reporte.cpview.dtos.ReporteCostPerViewVistaDTO;
import com.mx.dla.dda.reporte.cpview.dtos.ResponseCargaTitulosVSDTO;
import com.mx.dla.dda.reporte.cpview.dtos.VisualizacionesCostPerViewVistaDTO;
import com.mx.dla.dda.reporte.cpview.exception.ReportCostPerViewException;
import com.mx.dla.dda.reporte.ws.dtos.ResponseGeneraReporteDTO;
import com.mx.dla.dda.restClient.bos.DLARestClient;
import com.mx.dla.dda.restClient.bos.DLARestClientFactory;
import com.mx.dla.dda.restClient.constants.DLARestServices;
import com.mx.dla.global.bos.BaseBO;
import com.mx.dla.global.bos.CustomResourceLoader;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@Service
public class ReporteCostoPerViewBO extends BaseBO {
@Autowired
private ReporteCostPerViewDAO reporteCostPerViewDAO;
@Autowired
protected ExcelMapperTransform excelMapperTransform;
@Autowired
private ExcelMapperContext excelMapperContext;
@Autowired
private DLARestClientFactory dlaRestClientFactory;
@Value("${uri.file.carga.visualizaciones}")
private String uriCarga;
@Autowired
private CustomResourceLoader customResourceLoader;
@Autowired
private BaseActivosBO baseActivosBO;
@Value("${uri.file.reporte.baseActivosSQL}")
protected String uriSQL;
public String[][] obtenReporteMensualTabla(Long anio, Long mes, Long idEstudio, Boolean consulta) throws IllegalArgumentException, IllegalAccessException {
String[][] tabla = null;
int tamanio = (3 * (mes.intValue())) + 1;
Comparator<CostPerViewEstudioMensualDatosDTO> comparator = new Comparator<CostPerViewEstudioMensualDatosDTO>() {
public int compare(CostPerViewEstudioMensualDatosDTO o1, CostPerViewEstudioMensualDatosDTO o2) {
return o1.getEstudio().compareTo(o2.getEstudio());
}
};
List<CostPerViewEstudioMensualDatosDTO> datos = null;
List<CostPerViewEstudioMensualDatosDTO> diciembre = null;
if (idEstudio == null) {
if (consulta) {
datos = reporteCostPerViewDAO.obtenerCostPerViewMensualDatosEstudioNivel(mes, anio);
diciembre = reporteCostPerViewDAO.obtenerCostPerViewDiciembreDatosEstudioNivel(anio - 1);
} else {
datos = reporteCostPerViewDAO.obtenerCostPerViewMensualDatosTituloNivel(mes, anio, idEstudio);
diciembre = reporteCostPerViewDAO.obtenerCostPerViewDiciembreDatosTituloNivel(anio - 1, idEstudio);
}
} else {
datos = reporteCostPerViewDAO.obtenerCostPerViewMensualDatosTituloNivel(mes, anio, idEstudio);
diciembre = reporteCostPerViewDAO.obtenerCostPerViewDiciembreDatosTituloNivel(anio - 1, idEstudio);
}
boolean dicFlag = diciembre != null && !diciembre.isEmpty();
Integer amorIdxEnero = 0;
Integer visIdxEnero = 1;
Integer cpvIdxEnero = 2;
Integer amorIdxDiciembre = 34;
if (datos != null && !datos.isEmpty()) {
if (dicFlag) {
Collections.sort(diciembre, comparator);
}
for (CostPerViewEstudioMensualDatosDTO item : datos) {
String[] fila = item.getFieldsAsRow();
String[] tfila = Arrays.copyOfRange(fila, 0, 1);
String[] sfila = Arrays.copyOfRange(fila, 1, tamanio);
String[] afila = Arrays.copyOfRange(fila, fila.length - 4, fila.length);
if (dicFlag) {
int i = Collections.binarySearch(diciembre, item, comparator);
if (i >= 0) {
CostPerViewEstudioMensualDatosDTO found = diciembre.get(i);
String[] arowDic = found.getFieldsAsRow();
if (sfila[visIdxEnero] == null || new Double(sfila[visIdxEnero]) == 0) {
sfila[cpvIdxEnero] = "0.0";
} else if (sfila[amorIdxEnero] == null || new Double(sfila[amorIdxEnero]) == 0) {
if (arowDic[amorIdxDiciembre] != null) {
sfila[cpvIdxEnero] = new Double(new Double(arowDic[amorIdxDiciembre]) / new Double(sfila[visIdxEnero])).toString();
}
}
}
}
Double sumatoriaAmor = 0.0;
Double sumatoriaVis = 0.0;
for (int i = 0; i < sfila.length; i++) {
if (i % 3 == 0) {
sumatoriaAmor = sumatoriaAmor + new Double(sfila[i]);
}
if (i % 3 == 1) {
sumatoriaVis = sumatoriaVis + new Double(sfila[i]);
}
}
afila[0] = String.format("%.2f", sumatoriaAmor);
afila[1] = String.format("%.2f", sumatoriaVis);
Double cpv = sumatoriaAmor / sumatoriaVis;
if (!cpv.isInfinite()) {
afila[2] = String.format("%.2f", cpv);
} else {
afila[2] = "";
}
String[] row = ArrayUtils.addAll(ArrayUtils.addAll(tfila, sfila), afila);
if (tabla == null) {
tabla = new String[1][row.length];
} else {
tabla = Arrays.copyOf(tabla, tabla.length + 1);
}
tabla[tabla.length - 1] = row;
}
}
return tabla;
}
public String[][] obtenReporteAnualTabla(Long anio, Long mes, Long idEstudio, Boolean consulta) throws IllegalArgumentException, IllegalAccessException {
String[][] tabla = null;
String pivot_date = "";
Integer fanio = anio.intValue();
for (int anios = (fanio - 4), i = 0; anios <= fanio; anios++, i++) {
pivot_date = pivot_date + anios + " AS ANIO_" + i + ",";
}
List<CostPerViewEstudioAnualDatosDTO> datos = null;
if (idEstudio == null) {
if (consulta) {
datos = reporteCostPerViewDAO.obtenerCostPerViewAnualDatosEstudioNivel(anio - 4, anio, mes, pivot_date.substring(0, pivot_date.length() - 1));
} else {
datos = reporteCostPerViewDAO.obtenerCostPerViewAnualDatosTituloNivel(anio - 4, anio, mes, pivot_date.substring(0, pivot_date.length() - 1), idEstudio);
}
} else {
datos = reporteCostPerViewDAO.obtenerCostPerViewAnualDatosTituloNivel(anio - 4, anio, mes, pivot_date.substring(0, pivot_date.length() - 1), idEstudio);
}
if (datos != null && !datos.isEmpty()) {
for (CostPerViewEstudioAnualDatosDTO item : datos) {
String[] fila = item.getFieldsAsRow();
String[] tfila = Arrays.copyOfRange(fila, 0, 1);
String[] sfila = Arrays.copyOfRange(fila, 1, fila.length - 4);
String[] afila = Arrays.copyOfRange(fila, fila.length - 4, fila.length);
Double sumatoriaAmor = 0.0;
Double sumatoriaVis = 0.0;
for (int i = 0; i < sfila.length; i++) {
if (i % 3 == 0) {
sumatoriaAmor = sumatoriaAmor + new Double(sfila[i]);
}
if (i % 3 == 1) {
sumatoriaVis = sumatoriaVis + new Double(sfila[i]);
}
}
afila[0] = String.format("%.2f", sumatoriaAmor);
afila[1] = String.format("%.2f", sumatoriaVis);
Double cpv = sumatoriaAmor / sumatoriaVis;
if (!cpv.isInfinite()) {
afila[2] = String.format("%.2f", cpv);
} else {
afila[2] = "";
}
String[] row = ArrayUtils.addAll(ArrayUtils.addAll(tfila, sfila), afila);
if (tabla == null) {
tabla = new String[1][row.length];
} else {
tabla = Arrays.copyOf(tabla, tabla.length + 1);
}
tabla[tabla.length - 1] = row;
}
}
return tabla;
}
public String[] obtenerMesesTabla(Long anio, Long mes) {
List<String> meses = new ArrayList<String>();
for (int i = 1; i <= mes.intValue(); i++) {
MesesAnio ames = MesesAnio.parse("" + i);
meses.add(ames.getDesc() + " - " + anio);
}
meses.add("ACUMULADO");
String[] mesesArr = new String[meses.size()];
mesesArr = meses.toArray(mesesArr);
return mesesArr;
}
public String[] obtenerAniosTabla(Long anio) {
List<String> anios = new ArrayList<String>();
for (int i = anio.intValue() - 4; i <= anio.intValue(); i++) {
anios.add("" + i);
}
anios.add("ACUMULADO");
String[] aniosArr = new String[anios.size()];
aniosArr = anios.toArray(aniosArr);
return aniosArr;
}
public String[] obtenerHeaderRubro(Long tamanio) {
List<String> rubros = new ArrayList<String>();
for (int i = 0; i < tamanio + 1; i++) {
rubros.add("Amortizacin");
rubros.add("Visualizaciones");
rubros.add("CPV");
}
String[] rubrosArr = new String[rubros.size()];
rubrosArr = rubros.toArray(rubrosArr);
return rubrosArr;
}
public ReporteCostPerViewVistaDTO obtenerReporteMensualVista(String fecha, Long idEstudio, Boolean consulta) throws ParseException, IllegalArgumentException, IllegalAccessException {
ReporteCostPerViewVistaDTO reporte = new ReporteCostPerViewVistaDTO();
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
reporte.setTabla(obtenReporteMensualTabla(anio, mes, idEstudio, consulta));
reporte.setPheader(obtenerMesesTabla(anio, mes));
reporte.setRheader(obtenerHeaderRubro(mes));
return reporte;
}
public ReporteCostPerViewVistaDTO obtenerReporteAnualVista(String fecha, Long idEstudio, Boolean consulta) throws ParseException, IllegalArgumentException, IllegalAccessException {
ReporteCostPerViewVistaDTO reporte = new ReporteCostPerViewVistaDTO();
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
reporte.setTabla(obtenReporteAnualTabla(anio, mes, idEstudio, consulta));
reporte.setPheader(obtenerAniosTabla(anio));
reporte.setRheader(obtenerHeaderRubro(5L));
return reporte;
}
public InputStream obtenerStreamReporte(String tipoReporte, String fecha, Long idEstudio)
throws IllegalArgumentException, IllegalAccessException, ParseException, ExcelMapperException, IOException, ReportCostPerViewException {
ReporteCostPerViewVistaDTO reporte = null;
ExcelMapper mapper = new ExcelMapper();
List<ExcelRule> rules = new ArrayList<ExcelRule>();
InputStream stream = null;
byte[] info = null;
if (tipoReporte.equals("mensual")) {
reporte = obtenerReporteMensualVista(fecha, idEstudio, false);
}
if (tipoReporte.equals("anual")) {
reporte = obtenerReporteAnualVista(fecha, idEstudio, false);
}
String[][] tabla = reporte.getTabla();
String[] rheader = reporte.getRheader();
String[] pheader = reporte.getPheader();
String[] apheader = new String[rheader.length + 1];
String[] arheader = new String[rheader.length + 1];
int j = 0;
for (int i = 0; i < rheader.length; i++) {
if (i == 0) {
apheader[i] = "Estudio";
} else if ((i - 1) % 3 == 0) {
apheader[i] = pheader[j];
j++;
} else {
apheader[i] = "";
}
}
for (int i = 0; i < arheader.length; i++) {
if (i == 0) {
arheader[i] = "";
} else {
arheader[i] = rheader[i - 1];
}
}
mapper.setClassName(ReporteCostPerViewVistaDTO.class.getName());
mapper.setFirstRow(2);
mapper.setId("reporteCostPerView");
mapper.setParent(null);
mapper.setSkipErrors(true);
mapper.setStartRowIndex(0);
for (int i = 0; i < tabla[0].length - 1; i++) {
ExcelRule rule = new ExcelRule();
List<String> headers = new ArrayList<String>();
rule.setColumn(getExcelColumnName(i + 1));
headers.add(apheader[i]);
headers.add(arheader[i]);
rule.setHeaders(headers);
if (i > 0) {
rule.setType(ExcelMapperDataType.numeric);
}
rules.add(rule);
}
mapper.setRules(rules);
info = excelMapperTransform.transformObjectToExcel(tabla, mapper, String.class);
stream = new ByteArrayInputStream(info);
return stream;
}
public HashMap<String, HashMap<String, String>> obtenerDataQueryDetalleMensual(String fecha) throws IOException, ParseException, InvalidFormatException {
String header_1 = "SELECT '";
String header_2 = "SELECT 'Estudio";
String detalleMensual = "SELECT ESTUDIO";
String amortizaciones = "";
String visualizaciones = "";
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
logger.info("{}", mes);
logger.info("{}", anio);
SimpleDateFormat formater = new SimpleDateFormat("MM/yyyy");
Calendar beginCalendar = Calendar.getInstance();
Calendar finishCalendar = Calendar.getInstance();
beginCalendar.setTime(formater.parse("1" + "/" + anio));
finishCalendar.setTime(formater.parse(mes + "/" + anio));
Integer index = 1;
while (beginCalendar.before(finishCalendar) || beginCalendar.equals(finishCalendar)) {
MesesAnio ames = MesesAnio.parse("" + index);
header_1 = header_1 + "|||" + ames.getDesc();
header_2 = header_2 + "|Amortizacion_" + index + "|Visualizaciones_" + index + "|CPV_" + index;
detalleMensual = detalleMensual + "||'|'||AMOR_" + index + "||'|'||VIS_" + index + "||'|'||CPV_" + index;
amortizaciones = amortizaciones + "AMOR_" + index + "+";
visualizaciones = visualizaciones + "VIS_" + index + "+";
beginCalendar.add(Calendar.MONTH, 1);
index++;
}
header_1 = header_1 + "|||ACUMULADO|' as X from dual;";
header_2 = header_2 + "|AmortizacionT|VisualizacionesT|CPVT|' as X from dual;";
amortizaciones = amortizaciones.substring(0, amortizaciones.length() - 1);
visualizaciones = visualizaciones.substring(0, visualizaciones.length() - 1);
detalleMensual = detalleMensual + "|| '|' || (" + amortizaciones + ") || '|' || (" + visualizaciones + ") || '|' || ROUND((" + amortizaciones + ")/(" + visualizaciones + "), 2) FROM (";
logger.info("{}", header_1);
logger.info("{}", header_2);
logger.info("{}", amortizaciones);
logger.info("{}", visualizaciones);
logger.info("{}", detalleMensual);
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("header_0", header_1);
headers.put("header_1", header_2);
HashMap<String, String> bheaders = new HashMap<String, String>();
bheaders.put("bheader_0", detalleMensual);
HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("anio", anio.toString());
parameters.put("mes", mes.toString());
HashMap<String, HashMap<String, String>> customData = new HashMap<String, HashMap<String, String>>();
customData.put("HEADERS", headers);
customData.put("BHEADERS", bheaders);
customData.put("PARAMETERS", parameters);
return customData;
}
public HashMap<String, HashMap<String, String>> obtenerDataQueryDetalleAnual(String fecha) throws IOException, ParseException, InvalidFormatException {
String header_1 = "SELECT '";
String header_2 = "SELECT 'Estudio";
String detalleMensual = "SELECT ESTUDIO";
String amortizaciones = "";
String visualizaciones = "";
String pivot_data = "";
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
logger.info("{}", mes);
logger.info("{}", anio);
SimpleDateFormat formater = new SimpleDateFormat("MM/yyyy");
Calendar beginCalendar = Calendar.getInstance();
Calendar finishCalendar = Calendar.getInstance();
beginCalendar.setTime(formater.parse("1" + "/" + anio));
finishCalendar.setTime(formater.parse(mes + "/" + anio));
Integer fanio = anio.intValue();
Integer index = 1;
for (int anios = (fanio - 4), i = 0; anios <= fanio; anios++, i++) {
header_1 = header_1 + "|||" + anios;
header_2 = header_2 + "|Amortizacion_" + index + "|Visualizaciones_" + index + "|CPV_" + index;
detalleMensual = detalleMensual + "||'|'||AMOR_ANIO_" + index + "||'|'||VIS_ANIO_" + index + "||'|'||CPV_ANIO_" + index;
amortizaciones = amortizaciones + "AMOR_ANIO_" + index + "+";
visualizaciones = visualizaciones + "VIS_ANIO_" + index + "+";
pivot_data = pivot_data + anios + " AS ANIO_" + i + ",";
beginCalendar.add(Calendar.MONTH, 1);
index++;
}
header_1 = header_1 + "|||ACUMULADO|' as X from dual;";
header_2 = header_2 + "|AmortizacionT|VisualizacionesT|CPVT|' as X from dual;";
amortizaciones = amortizaciones.substring(0, amortizaciones.length() - 1);
visualizaciones = visualizaciones.substring(0, visualizaciones.length() - 1);
pivot_data = pivot_data.substring(0, pivot_data.length() - 1);
detalleMensual = detalleMensual + "|| '|' || (" + amortizaciones + ") || '|' || (" + visualizaciones + ") || '|' || ROUND((" + amortizaciones + ")/(" + visualizaciones + "), 2) FROM (";
logger.info("{}", header_1);
logger.info("{}", header_2);
logger.info("{}", amortizaciones);
logger.info("{}", visualizaciones);
logger.info("{}", detalleMensual);
HashMap<String, String> headers = new HashMap<String, String>();
headers.put("header_0", header_1);
headers.put("header_1", header_2);
HashMap<String, String> bheaders = new HashMap<String, String>();
bheaders.put("bheader_0", detalleMensual);
HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("anio_final", anio.toString());
parameters.put("anio_inicial", new Long(fanio - 4).toString());
parameters.put("mes", mes.toString());
parameters.put("pivot_data", pivot_data);
HashMap<String, HashMap<String, String>> customData = new HashMap<String, HashMap<String, String>>();
customData.put("HEADERS", headers);
customData.put("BHEADERS", bheaders);
customData.put("PARAMETERS", parameters);
return customData;
}
public InputStream obtenerStreamZipReporte(String tipoReporte, String fecha) throws InvalidFormatException, IOException, ParseException {
String finalQueryNameFile = "cpvDetalle";
String baseQueryNameFile = "";
HashMap<String, HashMap<String, String>> customData = obtenerDataQueryDetalleMensual(fecha);
if (tipoReporte.equals("mensual")) {
baseQueryNameFile = "queryCpvDetalleMensual.txt";
customData = obtenerDataQueryDetalleMensual(fecha);
}
if (tipoReporte.equals("anual")) {
baseQueryNameFile = "queryCpvDetalleAnual.txt";
customData = obtenerDataQueryDetalleAnual(fecha);
}
if (creaQueryDetalleCpv(customData, baseQueryNameFile, finalQueryNameFile)) {
return creaStreamZipFileCpv(finalQueryNameFile);
} else {
return null;
}
}
private Boolean creaQueryDetalleCpv(HashMap<String, HashMap<String, String>> customData, String baseQueryNameFile, String finalQueryNameFile) {
try {
InputStream queryStream;
queryStream = customResourceLoader.getFile2ItputStream("classpath:templateFees/" + baseQueryNameFile);
FileWriter fw = new FileWriter(uriSQL + finalQueryNameFile + ".sql");
String lineSeparador = System.getProperty("line.separator");
fw.write("--[BEGIN]");
fw.write(lineSeparador);
HashMap<String, String> headers = customData.get("HEADERS");
for (int i = 0; i < headers.size(); i++) {
fw.write(headers.get("header_" + i));
fw.write(lineSeparador);
}
fw.write("--[END_HEADER]");
fw.write(lineSeparador);
HashMap<String, String> bheaders = customData.get("BHEADERS");
for (int i = 0; i < bheaders.size(); i++) {
fw.write(bheaders.get("bheader_" + i));
fw.write(lineSeparador);
}
BufferedReader in = new BufferedReader(new InputStreamReader(queryStream));
String line = null;
HashMap<String, String> parameters = customData.get("PARAMETERS");
while ((line = in.readLine()) != null) {
if (line != null) {
for (Map.Entry<String, String> entry : parameters.entrySet()) {
line = line.replace("#{" + entry.getKey() + "}", entry.getValue());
}
fw.write(line);
fw.write(lineSeparador);
}
}
if (bheaders.size() > 0) {
for (int i = 0; i < bheaders.size(); i++) {
fw.write(")");
}
fw.write(";");
fw.write(lineSeparador);
}
fw.write("--[END]");
fw.write(lineSeparador);
fw.close();
} catch (InvalidFormatException | IOException e) {
return false;
}
return true;
}
private InputStream creaStreamZipFileCpv(String finalQueryNameFile) {
File file = new File(uriSQL + finalQueryNameFile + ".sql");
InputStream zipStream = null;
ResponseGeneraReporteDTO responseDTO = new ResponseGeneraReporteDTO();
if (file.exists()) {
try {
responseDTO = baseActivosBO.generaReporteWS(finalQueryNameFile);
if (responseDTO != null && responseDTO.getMensaje().contains("OK") && responseDTO.getRuta() != null) {
File zipFile = new File(responseDTO.getRuta());
if (zipFile != null && zipFile.exists()) {
zipStream = new FileInputStream(zipFile);
}
}
} catch (Exception e) {
logger.debug(e.toString());
}
}
return zipStream;
}
public void procesarStreamArchivoCarga(File archivo, String nombreArchivo, String fecha, String expediente) throws ParseException, IOException, ReportCostPerViewException {
logger.info("Procesando ...");
logger.info("{}", archivo);
logger.info("{}", nombreArchivo);
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
ParamCargaTitulosVSDTO request = new ParamCargaTitulosVSDTO();
ResponseCargaTitulosVSDTO response = null;
DLARestClient client = null;
String fileName = StringUtils.leftPad(String.valueOf(mes), 2, "0") + StringUtils.leftPad(String.valueOf(anio), 4, "0") + expediente + nombreArchivo;
String absoluteFileName = uriCarga + fileName;
byte[] file = FileUtils.readFileToByteArray(archivo);
File d = new File(absoluteFileName);
d.setExecutable(true, false);
d.setReadable(true, false);
d.setWritable(true, false);
FileUtils.writeByteArrayToFile(d, file);
logger.info("Archivo: [{}]", absoluteFileName);
String separador = "/";
client = dlaRestClientFactory.getClient(DLARestServices.WS_CARGA_ARCHIVO_VISUALIZACIONES);
request.setNombreArchivo(fileName);
request.setExpediente(expediente);
request.setMesCarga("01" + separador + StringUtils.leftPad(String.valueOf(mes), 2, "0") + separador + StringUtils.leftPad(String.valueOf(anio), 4, "0"));
logger.debug("request : [{}]", request);
logger.debug("client!!! : [{}]", client);
response = client.get(request, ResponseCargaTitulosVSDTO.class);
logger.debug("response : [{}]", response);
if (response != null && !response.isResultado()) {
throw new ReportCostPerViewException("Error servicio carga: " + response.getMensaje());
}
}
public static String getExcelColumnName(int number) {
final StringBuilder sb = new StringBuilder();
int num = number - 1;
while (num >= 0) {
int numChar = (num % 26) + 65;
sb.append((char) numChar);
num = (num / 26) - 1;
}
return sb.reverse().toString();
}
public VisualizacionesCostPerViewVistaDTO obtenerCargaVisualizacionesMensualVista(String fecha)
throws ParseException, IllegalArgumentException, IllegalAccessException, ReportCostPerViewException {
VisualizacionesCostPerViewVistaDTO reporte = new VisualizacionesCostPerViewVistaDTO();
VisualizacionesCostPerViewVistaDTO response = new VisualizacionesCostPerViewVistaDTO();
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
DateFormat formatoEntrada = new SimpleDateFormat("MM/yyyy");
Date date = formatoEntrada.parse(fecha);
if (FechaUtilerias.monthGreatherThan(date, new Date())) {
throw new ReportCostPerViewException("Mes elegido es mayor al mes actual");
}
response = obtenCargaVisualizacionesPrincipalTabla(fecha);
reporte.setHeader(obtenerHeaderTablaCargaVisualizaciones());
if (response != null) {
reporte.setTabla(obtenCargaVisualizacionesDetalleTabla(anio, mes));
reporte.setCorrectos(response.getCorrectos());
reporte.setErroneos(response.getErroneos());
reporte.setLeidos(response.getLeidos());
}
return reporte;
}
public String[][] obtenCargaVisualizacionesDetalleTabla(Long anio, Long mes) throws IllegalArgumentException, IllegalAccessException {
String[][] tabla = null;
List<CargaVisualizacionesDetalleDTO> datos = reporteCostPerViewDAO.obtenerVisualizaciones(mes, anio);
if (datos != null && !datos.isEmpty()) {
for (CargaVisualizacionesDetalleDTO item : datos) {
String[] arow = item.getFieldsAsRow();
String[] row = {arow[2], arow[3], arow[4]};
if (tabla == null) {
tabla = new String[1][row.length];
} else {
tabla = Arrays.copyOf(tabla, tabla.length + 1);
}
tabla[tabla.length - 1] = row;
}
}
return tabla;
}
public VisualizacionesCostPerViewVistaDTO obtenCargaVisualizacionesPrincipalTabla(String fecha)
throws ParseException, IllegalArgumentException, IllegalAccessException, ReportCostPerViewException {
VisualizacionesCostPerViewVistaDTO reporte = null;
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
DateFormat formatoEntrada = new SimpleDateFormat("MM/yyyy");
Date date = formatoEntrada.parse(fecha);
if (FechaUtilerias.monthGreatherThan(date, new Date())) {
throw new ReportCostPerViewException("Mes elegido es mayor al mes actual");
}
List<CargaVisualizacionesPrincipalDTO> datos = reporteCostPerViewDAO.obtenerVisualizacionesPrincipal(mes, anio);
if (datos != null && !datos.isEmpty()) {
reporte = new VisualizacionesCostPerViewVistaDTO();
LinkedList<CargaVisualizacionesPrincipalDTO> lista = new LinkedList<CargaVisualizacionesPrincipalDTO>(datos);
reporte.setLeidos(lista.getFirst().getTotalRegistros());
reporte.setCorrectos(lista.getFirst().getTotalCargados());
reporte.setErroneos(lista.getFirst().getTotalError());
}
return reporte;
}
public String[] obtenerHeaderTablaCargaVisualizaciones() {
String[] header = {"Id Broadview", "Nombre del Ttulo", "Visualizaciones"};
return header;
}
public InputStream obtenerStreamVisualizaciones(String fecha) throws IllegalArgumentException, IllegalAccessException, ParseException, ExcelMapperException, IOException {
List<CargaVisualizacionesDetalleDTO> reporte = null;
ExcelRule newRule = new ExcelRule();
InputStream stream = null;
byte[] info = null;
ExcelMapper mapper = excelMapperContext.getExcelMapper("plantillaVisualizacionesCostPerView");
newRule.setAttribute("comentarios");
newRule.setColumn("E");
newRule.setHeader("Comentarios");
mapper.getRules().add(newRule);
HashMap<String, Long> fechaSplit = FechaUtilerias.getFechaValores(fecha, "MM/yyyy");
Long mes = fechaSplit.get("Month");
Long anio = fechaSplit.get("Year");
reporte = reporteCostPerViewDAO.obtenerVisualizacionesDetalle(mes, anio);
info = excelMapperTransform.transformObjectToExcel(reporte, mapper, CargaVisualizacionesDetalleDTO.class);
stream = new ByteArrayInputStream(info);
return stream;
}
public InputStream obtenerStreamPlantilla() throws IllegalArgumentException, IllegalAccessException, ParseException, ExcelMapperException, IOException, InvalidFormatException {
InputStream stream = null;
byte[] info = null;
info = customResourceLoader.getFile2ByteArray("classpath:templateFees/plantillaCargaVS.xlsx");
stream = new ByteArrayInputStream(info);
return stream;
}
public String logStringArray(String[] array) {
String log = "";
if (array != null && array.length != 0) {
for (String item : array) {
log = log + "[" + item + "] ";
}
}
return log;
}
}
\ No newline at end of file
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