Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
ConsumoSriAutorizacion
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GERMAN PATRICIO ROMERO QUISHPE
ConsumoSriAutorizacion
Commits
5e2a72b3
Commit
5e2a72b3
authored
May 16, 2023
by
GERMAN PATRICIO ROMERO QUISHPE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consumo facturacion autorizacion autorizacion correo ftp
parent
dd8ba99f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
27 deletions
+80
-27
src/main/java/ec/edu/epn/consumosriautorizacion/Tasks/Task_cargaDocumentacion.java
+15
-10
src/main/java/ec/edu/epn/consumosriautorizacion/controller/ConsultasFacturacionController.java
+13
-4
src/main/java/ec/edu/epn/consumosriautorizacion/controller/GeneracionFactOfflineXML.java
+2
-2
src/main/java/ec/edu/epn/consumosriautorizacion/controller/SriAutorizacionController.java
+43
-6
src/main/java/ec/edu/epn/consumosriautorizacion/service/EmailService.java
+2
-2
src/main/java/ec/edu/epn/consumosriautorizacion/service/FileServiceImp.java
+5
-3
No files found.
src/main/java/ec/edu/epn/consumosriautorizacion/Tasks/Task_cargaDocumentacion.java
View file @
5e2a72b3
...
...
@@ -34,11 +34,11 @@ import static java.nio.charset.StandardCharsets.UTF_8;
@Component
public
class
Task_cargaDocumentacion
implements
Tasklet
{
/*
@Autowired
@Autowired
ConsultasFacturacionController
consultas
;
@Autowired
/*
@Autowired
FTPService ftpService;*/
...
...
@@ -80,6 +80,8 @@ public class Task_cargaDocumentacion implements Tasklet {
/**CARGAR FTP FACTURACION*/
ftpService
.
connectToFTP
();
ftpService
.
uploadFileToFTP
(
buffIn
,
dto
.
getRucCli
().
trim
()
+
"_Facturas"
,
dto
.
getIdFactura
().
trim
()
+
"-"
+
dto
.
getRucCli
().
trim
()
+
".pdf"
);
...
...
@@ -92,16 +94,19 @@ public class Task_cargaDocumentacion implements Tasklet {
BufferedInputStream
buffInXml
=
null
;
buffInXml
=
new
BufferedInputStream
(
new
FileInputStream
(
attchemnXml
));
ftpService
.
connectToFTP
();
ftpService
.
uploadFileToFTP
(
buffInXml
,
dto
.
getRucCli
().
trim
()
+
"_Facturas"
,
dto
.
getIdFactura
().
trim
()
+
"-"
+
dto
.
getRucCli
().
trim
()
+
".xml"
);
dto
.
setPath
(
dto
.
getRucCli
().
trim
()
+
"_Facturas/"
+
dto
.
get
RucCli
().
trim
()
+
".pdf"
);
dto
.
setPathxml
(
dto
.
getRucCli
().
trim
()
+
"_Facturas/"
+
dto
.
getRucCli
().
trim
()
+
".xml"
);
dto
.
setPath
(
dto
.
getRucCli
().
trim
()
+
"_Facturas/"
+
dto
.
get
IdFactura
().
trim
()
+
".pdf"
);
dto
.
setPathxml
(
dto
.
getRucCli
().
trim
()
+
"_Facturas/"
+
dto
.
getIdFactura
().
trim
()
+
".xml"
);
consultas
.
actualizarPathPdf
(
dto
);
this
.
enviarCorreo
(
dto
,
attchment
);
UserFactDTO
userF
=
this
.
usuarioFact
(
dto
.
getRucCli
().
trim
());
this
.
enviarCorreo
(
dto
,
attchment
,
userF
);
...
...
@@ -115,9 +120,9 @@ public class Task_cargaDocumentacion implements Tasklet {
public
void
enviarCorreo
(
FacturaDTO
factura
,
String
attachment
)
{
public
void
enviarCorreo
(
FacturaDTO
factura
,
String
attachment
,
UserFactDTO
userF
)
{
UserFactDTO
userF
=
this
.
usuarioFact
(
factura
.
getRucCli
().
trim
());
//
UserFactDTO userF = this.usuarioFact(factura.getRucCli().trim());
java
.
util
.
List
<
String
>
para
=
new
ArrayList
<
String
>();
...
...
@@ -204,13 +209,13 @@ public class Task_cargaDocumentacion implements Tasklet {
public
UserFactDTO
usuarioFact
(
String
ciRucCli
)
{
ConsultasFacturacionController
consultas
=
new
ConsultasFacturacionController
();
//
ConsultasFacturacionController consultas= new ConsultasFacturacionController();
UserFactDTO
usuario
=
new
UserFactDTO
();
usuario
=
consultas
.
consumoUserFact
(
ciRucCli
.
trim
());
try
{
if
(
usuario
!=
null
)
{
if
(
usuario
.
getClave
().
trim
().
equals
(
""
)){
usuario
.
setClave
(
this
.
encriptar
(
this
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
+
ESPECIALES
,
12
)));
usuario
.
setClave
(
this
.
encriptar
(
this
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
,
12
)));
consultas
.
actualizarUserFact
(
usuario
);
}
return
usuario
;
...
...
@@ -218,7 +223,7 @@ public class Task_cargaDocumentacion implements Tasklet {
}
else
{
usuario
=
new
UserFactDTO
();
usuario
.
setUsuario
(
ciRucCli
.
trim
());
usuario
.
setClave
(
this
.
encriptar
(
this
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
+
ESPECIALES
,
12
)));
usuario
.
setClave
(
this
.
encriptar
(
this
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
,
12
)));
consultas
.
ingresarUserFact
(
usuario
);
return
usuario
;
}
...
...
src/main/java/ec/edu/epn/consumosriautorizacion/controller/ConsultasFacturacionController.java
View file @
5e2a72b3
...
...
@@ -23,9 +23,9 @@ import javax.sql.DataSource;
import
java.io.Serializable
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Configuration
...
...
@@ -335,8 +335,17 @@ public class ConsultasFacturacionController implements Serializable {
public
void
ingresarUserFact
(
UserFactDTO
userFactDTO
){
try
{
String
sql
=
"INSERT INTO \"Facturacion\".userfact(usuario, clave) VALUES (?, ?);;"
;
jdbcTemplate
().
update
(
sql
,
userFactDTO
.
getUsuario
()
,
userFactDTO
.
getClave
());
/* Map<String, Object> params = new HashMap<>();
params.put("var1",userFactDTO.getUsuario());
params.put("var2",userFactDTO.getClave());
String sql= "INSERT INTO \"Facturacion\".userfact(usuario, clave) VALUES (:var1, :var2);";
jdbcTemplate().update(sql, params);*/
String
sql
=
"INSERT INTO \"Facturacion\".userfact(usuario, clave) VALUES (?, ?);"
;
jdbcTemplate
().
update
(
sql
,
userFactDTO
.
getUsuario
()
,
userFactDTO
.
getClave
());
System
.
out
.
println
(
"USER FACT INGRESADA CORRECTAMENTE"
);
}
catch
(
Exception
e
){
...
...
src/main/java/ec/edu/epn/consumosriautorizacion/controller/GeneracionFactOfflineXML.java
View file @
5e2a72b3
...
...
@@ -22,8 +22,8 @@ public class GeneracionFactOfflineXML {
BufferedWriter
writer
=
null
;
String
pathXml
=
""
;
//pathXml = "C:/facturacion_electronica/facturaUtils/" + factura.getRucCli().trim() + "-" + factura.getIdFactura
().trim() + ".xml";
pathXml
=
"/datos/FacturaUtils/"
+
factura
.
get
RucCli
().
trim
()
+
"-"
+
factura
.
getIdFactura
().
trim
()
+
".xml"
;
// pathXml = "C:/facturacion_electronica/facturaUtils/" + factura.getIdFactura().trim() + "-" + factura.getRucCli
().trim() + ".xml";
pathXml
=
"/datos/FacturaUtils/"
+
factura
.
get
IdFactura
().
trim
()
+
"-"
+
factura
.
getRucCli
().
trim
()
+
".xml"
;
File
file
=
new
File
(
pathXml
);
try
{
...
...
src/main/java/ec/edu/epn/consumosriautorizacion/controller/SriAutorizacionController.java
View file @
5e2a72b3
...
...
@@ -3,10 +3,7 @@ package ec.edu.epn.consumosriautorizacion.controller;
import
ec.edu.epn.consumosriautorizacion.Tasks.Task_autorizacion
;
import
ec.edu.epn.consumosriautorizacion.Tasks.Task_cargaDocumentacion
;
import
ec.edu.epn.consumosriautorizacion.dto.DetallefacturaDTO
;
import
ec.edu.epn.consumosriautorizacion.dto.FacturaDTO
;
import
ec.edu.epn.consumosriautorizacion.dto.FacturacionOfflineDTO
;
import
ec.edu.epn.consumosriautorizacion.dto.PagosDTO
;
import
ec.edu.epn.consumosriautorizacion.dto.*
;
import
ec.edu.epn.consumosriautorizacion.exceptions.FTPErrors
;
import
ec.edu.epn.consumosriautorizacion.service.EmailService
;
import
ec.edu.epn.consumosriautorizacion.service.FTPService
;
...
...
@@ -57,6 +54,12 @@ public class SriAutorizacionController {
}
private
static
String
NUMEROS
=
"0123456789"
;
private
static
String
MAYUSCULAS
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
private
static
String
MINUSCULAS
=
"abcdefghijklmnopqrstuvwxyz"
;
private
static
String
ESPECIALES
=
"ñÑ"
;
...
...
@@ -213,7 +216,7 @@ public class SriAutorizacionController {
//emailService.sendEmail(para, subject, text, attchment
);
emailService
.
sendEmail
(
para
,
subject
,
text
,
attchment
,
facturaDTO
.
getIdFactura
()
);
offlineDTO
.
setMensaje
(
"CORREO ENVIADO CORRECTAMENTE"
);
return
offlineDTO
;
...
...
@@ -325,6 +328,8 @@ public class SriAutorizacionController {
FacturacionOfflineDTO
offlineDTOerror
=
new
FacturacionOfflineDTO
();
try
{
/**OBTENER LA FECHA ACTUAL**/
Date
date
=
new
Date
();
DateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
...
...
@@ -349,6 +354,8 @@ public class SriAutorizacionController {
/**CARGAR FTP FACTURACION*/
ftpService
.
connectToFTP
();
ftpService
.
uploadFileToFTP
(
buffIn
,
dto
.
getRucCli
().
trim
()
+
"_Facturas"
,
dto
.
getIdFactura
().
trim
()
+
"-"
+
dto
.
getRucCli
().
trim
()
+
".pdf"
);
...
...
@@ -361,6 +368,8 @@ public class SriAutorizacionController {
BufferedInputStream
buffInXml
=
null
;
buffInXml
=
new
BufferedInputStream
(
new
FileInputStream
(
attchemnXml
));
ftpService
.
connectToFTP
();
ftpService
.
uploadFileToFTP
(
buffInXml
,
dto
.
getRucCli
().
trim
()
+
"_Facturas"
,
dto
.
getIdFactura
().
trim
()
+
"-"
+
dto
.
getRucCli
().
trim
()
+
".xml"
);
...
...
@@ -370,7 +379,35 @@ public class SriAutorizacionController {
dto
.
setPathxml
(
dto
.
getRucCli
().
trim
()
+
"_Facturas/"
+
dto
.
getIdFactura
().
trim
()
+
"-"
+
dto
.
getRucCli
().
trim
()
+
".xml"
);
consultas
.
actualizarPathPdf
(
dto
);
tarea
.
enviarCorreo
(
dto
,
attchment
);
UserFactDTO
usuario
=
new
UserFactDTO
();
usuario
=
consultas
.
consumoUserFact
(
dto
.
getRucCli
().
trim
());
try
{
if
(
usuario
!=
null
)
{
if
(
usuario
.
getClave
().
trim
().
equals
(
""
)){
usuario
.
setClave
(
tarea
.
encriptar
(
tarea
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
,
12
)));
consultas
.
actualizarUserFact
(
usuario
);
}
}
else
{
usuario
=
new
UserFactDTO
();
usuario
.
setUsuario
(
dto
.
getRucCli
().
trim
());
usuario
.
setClave
(
tarea
.
encriptar
(
tarea
.
generaClaves
(
NUMEROS
+
MAYUSCULAS
+
MINUSCULAS
,
12
)));
consultas
.
ingresarUserFact
(
usuario
);
}
}
catch
(
Exception
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
return
null
;
}
tarea
.
enviarCorreo
(
dto
,
attchment
,
usuario
);
...
...
src/main/java/ec/edu/epn/consumosriautorizacion/service/EmailService.java
View file @
5e2a72b3
...
...
@@ -62,10 +62,10 @@ public class EmailService {
File
initialFile
=
new
File
(
attachment
);
InputStream
targetStream
=
new
FileInputStream
(
initialFile
);
DataSource
content
=
new
ByteArrayDataSource
(
targetStream
,
"application/octet-stream"
);
messageHelper
.
addAttachment
(
"pruebas
.pdf"
,
messageHelper
.
addAttachment
(
idFactura
+
"
.pdf"
,
content
);
javaMailSender
.
send
(
mimeMessage
);
System
.
out
.
printf
(
"SEND MAILIN PE.."
);
}
...
...
src/main/java/ec/edu/epn/consumosriautorizacion/service/FileServiceImp.java
View file @
5e2a72b3
...
...
@@ -108,17 +108,19 @@ public class FileServiceImp implements FTPService {
* @throws FTPErrors Set of possible errors associated with upload process.
*/
// @Async("threadPoolTaskExecutor")
@Async
//
@Async
@Override
public
void
uploadFileToFTP
(
BufferedInputStream
input
,
String
ftpHostDir
,
String
serverFilename
)
throws
FTPErrors
{
try
{
serverFilename
=
new
String
(
serverFilename
.
getBytes
(
"utf-8"
));
String
nombreArchivo
=
""
;
nombreArchivo
=
new
String
(
serverFilename
.
getBytes
(
"utf-8"
));
int
creacion
=
this
.
ftpconnection
.
mkd
(
ftpHostDir
);
this
.
ftpconnection
.
changeWorkingDirectory
(
"\\"
+
ftpHostDir
);
this
.
ftpconnection
.
setFileType
(
FTP
.
BINARY_FILE_TYPE
);
this
.
ftpconnection
.
storeFile
(
serverFilename
,
input
);
this
.
ftpconnection
.
storeFile
(
nombreArchivo
,
input
);
this
.
ftpconnection
.
logout
();
this
.
ftpconnection
.
disconnect
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment