@ -27,6 +27,7 @@ import com.baiye.modules.telemarkting.entity.DoubleCallInfo;
import com.baiye.util.DateTimeUtil ;
import com.baiye.util.ExportExcelUtil ;
import lombok.extern.slf4j.Slf4j ;
import org.springframework.cache.annotation.Cacheable ;
import org.springframework.stereotype.Service ;
import javax.annotation.Resource ;
@ -105,7 +106,7 @@ public class ReportServiceImpl implements ReportService {
String organizationName = null ;
if ( CollUtil . isNotEmpty ( list ) ) {
Long organizeId = list . get ( 0 ) . getTeamId ( ) ;
Organize organizeById = or ganiz eReposi tory. find OrganizeById ( organizeId ) ;
Organize organizeById = getOrganize( organizeId ) ;
if ( ObjectUtil . isNotNull ( organizeById ) ) {
organizationName = organizeById . getOrganizeName ( ) ;
}
@ -140,8 +141,7 @@ public class ReportServiceImpl implements ReportService {
for ( long key : mapByMember . keySet ( ) ) {
//每个人的数据
List < CallClueInfo > list = mapByMember . get ( key ) ;
User userById = userRepository . findUserById ( key ) ;
User userById = getMember ( key ) ;
String userName = null ;
if ( ObjectUtil . isNotNull ( userById ) ) {
userName = userById . getUsername ( ) ;
@ -149,7 +149,7 @@ public class ReportServiceImpl implements ReportService {
String organizationName = null ;
if ( CollUtil . isNotEmpty ( list ) ) {
Long organizeId = list . get ( 0 ) . getTeamId ( ) ;
Organize organizeById = or ganiz eReposi tory. find OrganizeById ( organizeId ) ;
Organize organizeById = getOrganize( organizeId ) ;
if ( ObjectUtil . isNotNull ( organizeById ) ) {
organizationName = organizeById . getOrganizeName ( ) ;
}
@ -207,14 +207,14 @@ public class ReportServiceImpl implements ReportService {
if ( CollUtil . isEmpty ( callClueInfos ) ) {
return ;
}
User userById = userRepository. findUserById ( memberId ) ;
User userById = getMember ( memberId ) ;
String userName = null ;
if ( ObjectUtil . isNotNull ( userById ) ) {
userName = userById . getUsername ( ) ;
}
String organizationName = null ;
Long organizeId = callClueInfos . get ( 0 ) . getTeamId ( ) ;
Organize organizeById = or ganiz eReposi tory. find OrganizeById ( organizeId ) ;
Organize organizeById = getOrganize( organizeId ) ;
if ( ObjectUtil . isNotNull ( organizeById ) ) {
organizationName = organizeById . getOrganizeName ( ) ;
}
@ -503,19 +503,21 @@ public class ReportServiceImpl implements ReportService {
double breatheAverageDuration = 0 ;
if ( CollUtil . isNotEmpty ( callClueInfos ) ) {
for ( CallClueInfo info : callClueInfos ) {
if ( info . getStatus ( ) ! = 0 ) {
if ( info . getStatus ( ) = = CallStatusEnum . ANSWER . getValue ( ) ) {
turnOnNum + + ;
//接通时才会有通话时长
long clueId = info . getClueId ( ) ;
List < DoubleCallInfo > doubleCallInfo = doubleCallRepository . selectAllByTimeAndClueId ( begin , end , clueId ) ;
int doubleClueTime = doubleCallInfo . stream ( ) . mapToInt ( DoubleCallInfo : : getDuration ) . sum ( ) ;
breatheTotalDuration + = doubleClueTime ;
} else {
usrNum + + ;
if ( info . getStatus ( ) = = CallStatusEnum . ANSWER . getValue ( ) ) {
turnOnNum + + ;
}
}
long clueId = info . getClueId ( ) ;
List < DoubleCallInfo > doubleCallInfo = doubleCallRepository . selectAllByTimeAndClueId ( begin , end , clueId ) ;
int doubleClueTime = doubleCallInfo . stream ( ) . mapToInt ( DoubleCallInfo : : getDuration ) . sum ( ) ;
breatheTotalDuration + = doubleClueTime ;
}
breatheAverageDuration = NumberUtil . div ( breatheTotalDuration , callClueInfos . size ( ) , 2 ) ;
}
//这里使用数和接通数是分开的,真实的使用数 为 这里的使用数+接通数
usrNum + = turnOnNum ;
if ( usrNum ! = 0 ) {
//接通率=接通数/使用数
turnOnRate = NumberUtil . div ( turnOnNum , usrNum , 2 ) ;
@ -528,4 +530,19 @@ public class ReportServiceImpl implements ReportService {
memberInfoVO . setBreatheTotalDuration ( breatheTotalDuration ) ;
return memberInfoVO ;
}
/ * *
* 查 询 组 信 息
*
* @return
* /
@Cacheable ( cacheNames = { "organize" , "organize" } , key = "'id:' + #id" )
public Organize getOrganize ( Long id ) {
return organizeRepository . findOrganizeById ( id ) ;
}
@Cacheable ( cacheNames = { "user" , "user" } , key = "'id:' + #id" )
public User getMember ( Long id ) {
return userRepository . findUserById ( id ) ;
}
}