Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josue
ejercicio2-framework-back
Commits
2a7b2470
Commit
2a7b2470
authored
Dec 01, 2021
by
Cristian Aguirre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OperativeDashboardService
parent
b9b888c3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
42 deletions
+58
-42
BotSessionJDCBRepository.java
...ava/com/bytesw/bytebot/jdbc/BotSessionJDCBRepository.java
+2
-2
MetricMessageTypeEnum.java
...com/bytesw/bytebot/model/enums/MetricMessageTypeEnum.java
+30
-0
SchedulerTaskService.java
...java/com/bytesw/bytebot/service/SchedulerTaskService.java
+1
-1
WeekSchedulerService.java
...java/com/bytesw/bytebot/service/WeekSchedulerService.java
+1
-1
OperativeDashboardService.java
.../bytebot/service/dashboard/OperativeDashboardService.java
+20
-26
SessionMapper.xml
.../resources/config/mappers/bytebot/mysql/SessionMapper.xml
+2
-6
SessionMapper.xml
...sources/config/mappers/bytebot/postgres/SessionMapper.xml
+2
-6
No files found.
src/main/java/com/bytesw/bytebot/jdbc/BotSessionJDCBRepository.java
View file @
2a7b2470
...
...
@@ -20,14 +20,14 @@ public class BotSessionJDCBRepository {
@Qualifier
(
"sqlSessionFactory"
)
private
SqlSessionFactory
sqlSessionFactory
;
public
List
<
SessionByClientBean
>
countSessionInRange
(
OffsetDateTime
startDate
,
OffsetDateTime
endDate
)
{
public
int
countSessionInRange
(
OffsetDateTime
startDate
,
OffsetDateTime
endDate
)
{
SqlSession
session
=
sqlSessionFactory
.
openSession
();
try
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"startDate"
,
startDate
);
params
.
put
(
"endDate"
,
endDate
);
return
session
.
select
List
(
"com.bytesw.bytebot.dao.jdbc.SessionMapper.countSessionsInRange"
,
params
);
return
session
.
select
One
(
"com.bytesw.bytebot.dao.jdbc.SessionMapper.countSessionsInRange"
,
params
);
}
finally
{
session
.
close
();
}
...
...
src/main/java/com/bytesw/bytebot/model/enums/MetricMessageTypeEnum.java
0 → 100644
View file @
2a7b2470
package
com
.
bytesw
.
bytebot
.
model
.
enums
;
import
lombok.Getter
;
import
java.util.HashMap
;
import
java.util.Map
;
@Getter
public
enum
MetricMessageTypeEnum
{
RECEIVED
(
"received"
),
SENT
(
"sent"
),
SESSION
(
"session"
);
private
static
final
Map
<
String
,
MetricMessageTypeEnum
>
map
=
new
HashMap
<>();
private
String
name
;
MetricMessageTypeEnum
(
String
name
){
this
.
name
=
name
;}
public
String
getName
()
{
return
name
;}
static
{
for
(
MetricMessageTypeEnum
type
:
MetricMessageTypeEnum
.
values
())
{
map
.
put
(
type
.
name
,
type
);
}
}
public
static
MetricMessageTypeEnum
fromString
(
String
name
)
{
return
map
.
get
(
name
);
}
}
src/main/java/com/bytesw/bytebot/service/SchedulerTaskService.java
View file @
2a7b2470
...
...
@@ -46,7 +46,7 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
if
(!
calendarOptional
.
isPresent
())
{
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendarID
());
}
model
.
setCalendar
(
calendarOptional
.
get
());
//
model.setCalendar(calendarOptional.get());
return
model
;
}
...
...
src/main/java/com/bytesw/bytebot/service/WeekSchedulerService.java
View file @
2a7b2470
...
...
@@ -47,7 +47,7 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
if
(
bean
.
getCalendarID
()
==
null
)
{
throw
new
NotFoundException
(
"Calendar can not be null"
);
}
bean
.
setCalendarID
(
bean
.
getCalendarID
().
trim
());
Optional
<
Calendar
>
calendarOptional
=
calendarRepository
.
findById
(
bean
.
getCalendarID
().
trim
());
if
(!
calendarOptional
.
isPresent
())
{
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendarID
());
...
...
src/main/java/com/bytesw/bytebot/service/dashboard/OperativeDashboardService.java
View file @
2a7b2470
...
...
@@ -11,7 +11,7 @@ import com.bytesw.xdf.exception.NotFoundException;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.bytesw.bytebot.model.enums.MetricMessageTypeEnum
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.Timestamp
;
...
...
@@ -43,13 +43,14 @@ public class OperativeDashboardService extends DashboardService {
List
<
Object
[]>
messageByActivity
=
generateData
(
rangeList
);
//Cantidad de sesiones
List
<
SessionByClientBean
>
sessions_by_user
=
botSessionJDCBRepository
.
countSessionInRange
(
startDate
,
endDate
);
List
<
Object
[]>
sessions
=
generateDataVariablePeriod
(
rangeMinutsList
,
MetricMessageTypeEnum
.
SESSION
.
getName
());
int
totalSessions
=
botSessionJDCBRepository
.
countSessionInRange
(
startDate
,
endDate
);
// Mensajes recibidos
List
<
Object
[]>
recivedMessages
=
generateDataVariablePeriod
(
rangeMinutsList
,
true
);
List
<
Object
[]>
recivedMessages
=
generateDataVariablePeriod
(
rangeMinutsList
,
MetricMessageTypeEnum
.
RECEIVED
.
getName
()
);
int
totalrecivedMessages
=
messageJDBCRepository
.
countSessionInRange
(
startDate
,
endDate
);
// Mensajes enviados
List
<
Object
[]>
responseMessages
=
generateDataVariablePeriod
(
rangeMinutsList
,
false
);
List
<
Object
[]>
responseMessages
=
generateDataVariablePeriod
(
rangeMinutsList
,
MetricMessageTypeEnum
.
SENT
.
getName
()
);
int
totalresponseMessages
=
responseJDBCRepository
.
countSessionInRange
(
startDate
,
endDate
);
//Promedio primera respuesta en mili
...
...
@@ -61,9 +62,12 @@ public class OperativeDashboardService extends DashboardService {
avgFirstResponse
=
(
Double
)
avgFRObject
;
}
d
ouble
avgSessionsByCustomerRaw
=
botSessionJDCBRepository
.
getAvgSessionByCustomerInRange
(
startDate
,
endDate
);
D
ouble
avgSessionsByCustomerRaw
=
botSessionJDCBRepository
.
getAvgSessionByCustomerInRange
(
startDate
,
endDate
);
// Tomar solo parte entera
int
avgSessionsByCustomer
=
(
int
)
avgSessionsByCustomerRaw
;
if
(
avgSessionsByCustomerRaw
==
null
){
avgSessionsByCustomerRaw
=
0.0
;
}
int
avgSessionsByCustomer
=
avgSessionsByCustomerRaw
.
intValue
();
Timestamp
timestamp
=
botSessionJDCBRepository
.
getLastDateInRage
(
startDate
,
endDate
);
...
...
@@ -80,23 +84,11 @@ public class OperativeDashboardService extends DashboardService {
BigInteger
value
=
new
BigInteger
(
String
.
valueOf
(
difference
.
getSeconds
()));
sessionInactivity
.
setValue
(
value
);
// Adjutando el total de sesiones por cliente
SummaryBean
totalSessions
=
new
SummaryBean
();
totalSessions
.
setHistory
(
new
ArrayList
<>());
ArrayList
<
BigInteger
>
totalsessions
=
new
ArrayList
<
BigInteger
>();
// Total de sesiones
sessions_by_user
.
stream
().
forEach
(
x
->
{
ArrayList
<
Object
>
session
=
new
ArrayList
<
Object
>();
// Split de la data para obtener el número
String
sender_id
=
x
.
getSender_id
().
split
(
":"
)[
1
];
session
.
add
(
sender_id
);
session
.
add
(
x
.
getCount
());
totalsessions
.
add
(
x
.
getCount
());
totalSessions
.
getHistory
().
add
(
session
);
});
// Adjutando las sesiones totales
Map
<
String
,
Object
>
totalSession
=
new
HashMap
<>();
totalSession
.
put
(
"value"
,
totalSessions
);
totalSession
.
put
(
"history"
,
sessions
);
int
sum
=
totalsessions
.
stream
().
mapToInt
(
BigInteger:
:
intValue
).
sum
();
BigInteger
total
=
BigInteger
.
valueOf
(
sum
);
totalSessions
.
setValue
(
total
);
// Adjuntamos los mensajes recibidos
Map
<
String
,
Object
>
recivedMessage
=
new
HashMap
<>();
recivedMessage
.
put
(
"value"
,
totalrecivedMessages
);
...
...
@@ -109,7 +101,7 @@ public class OperativeDashboardService extends DashboardService {
Map
<
String
,
Object
>
summary
=
new
HashMap
<>();
summary
.
put
(
"sessionInactivity"
,
sessionInactivity
);
summary
.
put
(
"totalSessions"
,
totalSession
s
);
summary
.
put
(
"totalSessions"
,
totalSession
);
summary
.
put
(
"totalSentMessages"
,
responseMessage
);
summary
.
put
(
"totalReceivedMessages"
,
recivedMessage
);
...
...
@@ -125,16 +117,18 @@ public class OperativeDashboardService extends DashboardService {
info
.
put
(
"customerMessageDetail"
,
messageByActivity
);
}
private
List
<
Object
[]>
generateDataVariablePeriod
(
List
<
RangeBean
>
rangeList
,
boolean
recieved
)
{
private
List
<
Object
[]>
generateDataVariablePeriod
(
List
<
RangeBean
>
rangeList
,
String
metric
)
{
List
<
Object
[]>
data
=
new
ArrayList
<>();
Map
<
Long
,
Map
<
Integer
,
Integer
>>
accumulated
=
new
HashMap
<>();
int
cont
=
0
;
for
(
RangeBean
range
:
rangeList
)
{
int
cant
=
0
;
if
(
recieved
)
{
if
(
metric
.
equals
(
MetricMessageTypeEnum
.
RECEIVED
.
getName
())
)
{
cant
=
messageJDBCRepository
.
countMessageInRangeHour
(
range
.
getStartDate
(),
range
.
getEndDate
());
}
else
{
}
else
if
(
metric
.
equals
(
MetricMessageTypeEnum
.
SENT
.
getName
()))
{
cant
=
responseJDBCRepository
.
countSessionInRange
(
range
.
getStartDate
(),
range
.
getEndDate
());
}
else
if
(
metric
.
equals
(
MetricMessageTypeEnum
.
SESSION
.
getName
())){
cant
=
botSessionJDCBRepository
.
countSessionInRange
(
range
.
getStartDate
(),
range
.
getEndDate
());
}
LocalDateTime
times
=
range
.
getStartDate
().
toLocalDateTime
();
Long
timestamp
=
Timestamp
.
valueOf
(
times
).
getTime
();
...
...
src/main/resources/config/mappers/bytebot/mysql/SessionMapper.xml
View file @
2a7b2470
...
...
@@ -12,14 +12,10 @@
ORDER BY SESSION_LEDAT DESC LIMIT 1
</select>
<select
id=
"countSessionsInRange"
resultType=
"SessionByClient"
flushCache=
"true"
>
select au.user_ident as sender_id,
count(session_id) as count
FROM AVB_SESSION bas
join avb_user au on au.user_id=bas.user_id
<select
id=
"countSessionsInRange"
resultType=
"int"
flushCache=
"true"
>
select count(session_id) from avb_session
WHERE SESSION_LEDAT
<
= #{endDate}
AND SESSION_LEDAT
>
= #{startDate}
group by au.user_ident
</select>
<select
id=
"avgSessionsByCustomerInRange"
resultType=
"Double"
flushCache=
"true"
>
...
...
src/main/resources/config/mappers/bytebot/postgres/SessionMapper.xml
View file @
2a7b2470
...
...
@@ -12,14 +12,10 @@
ORDER BY SESSION_LEDAT DESC LIMIT 1
</select>
<select
id=
"countSessionsInRange"
resultType=
"SessionByClient"
flushCache=
"true"
>
select au.user_ident as sender_id,
count(session_id) as count
FROM AVB_SESSION bas
join avb_user au on au.user_id=bas.user_id
<select
id=
"countSessionsInRange"
resultType=
"int"
flushCache=
"true"
>
select count(session_id) from avb_session
WHERE SESSION_LEDAT
<
= #{endDate}
AND SESSION_LEDAT
>
= #{startDate}
group by au.user_ident
</select>
<select
id=
"avgSessionsByCustomerInRange"
resultType=
"Double"
flushCache=
"true"
>
...
...
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