mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-16 12:18:10 +00:00
update modules/kbase: add 2 mod 330 files
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.agent;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class FreeSwitchAgentEntity extends BaseEntity {
|
||||
/**
|
||||
* 最后状态变更时间
|
||||
*/
|
||||
private LocalDateTime lastStatusChange;
|
||||
private ZonedDateTime lastStatusChange;
|
||||
|
||||
/**
|
||||
* 当前处理的呼叫UUID
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.freeswitch.agent;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -31,8 +31,8 @@ public class FreeSwitchAgentService {
|
||||
|
||||
agent.setStatus(FreeSwitchAgentEntity.AgentStatus.OFFLINE);
|
||||
agent.setMode(FreeSwitchAgentEntity.AgentMode.MANUAL);
|
||||
agent.setCreatedAt(LocalDateTime.now());
|
||||
agent.setUpdatedAt(LocalDateTime.now());
|
||||
agent.setCreatedAt(ZonedDateTime.now());
|
||||
agent.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return agentRepository.save(agent);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class FreeSwitchAgentService {
|
||||
existingAgent.setName(agent.getName());
|
||||
existingAgent.setSkills(agent.getSkills());
|
||||
existingAgent.setNotes(agent.getNotes());
|
||||
existingAgent.setUpdatedAt(LocalDateTime.now());
|
||||
existingAgent.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return agentRepository.save(existingAgent);
|
||||
}
|
||||
@@ -84,8 +84,8 @@ public class FreeSwitchAgentService {
|
||||
.orElseThrow(() -> new RuntimeException("坐席不存在: " + agentId));
|
||||
|
||||
agent.setStatus(status);
|
||||
agent.setLastStatusChange(LocalDateTime.now());
|
||||
agent.setUpdatedAt(LocalDateTime.now());
|
||||
agent.setLastStatusChange(ZonedDateTime.now());
|
||||
agent.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return agentRepository.save(agent);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class FreeSwitchAgentService {
|
||||
.orElseThrow(() -> new RuntimeException("坐席不存在: " + agentId));
|
||||
|
||||
agent.setMode(mode);
|
||||
agent.setUpdatedAt(LocalDateTime.now());
|
||||
agent.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return agentRepository.save(agent);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class FreeSwitchAgentService {
|
||||
.orElseThrow(() -> new RuntimeException("坐席不存在: " + agentId));
|
||||
|
||||
agent.setSkills(skills);
|
||||
agent.setUpdatedAt(LocalDateTime.now());
|
||||
agent.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return agentRepository.save(agent);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.freeswitch.call;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
|
||||
@@ -61,12 +61,12 @@ public class FreeSwitchCallEntity extends BaseEntity {
|
||||
/**
|
||||
* 呼叫开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
private ZonedDateTime startTime;
|
||||
|
||||
/**
|
||||
* 呼叫结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
private ZonedDateTime endTime;
|
||||
|
||||
/**
|
||||
* 呼叫时长(秒)
|
||||
|
||||
@@ -116,7 +116,7 @@ public class FreeSwitchCallEventListener {
|
||||
private void updateUserActivity(String username) {
|
||||
try {
|
||||
// if (userService.findByUsername(username).isPresent()) {
|
||||
// userService.updateLastRegistration(username, LocalDateTime.now());
|
||||
// userService.updateLastRegistration(username, ZonedDateTime.now());
|
||||
// log.debug("已更新用户活动时间: {}", username);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.call;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -57,7 +57,7 @@ public interface FreeSwitchCallRepository extends JpaRepository<FreeSwitchCallEn
|
||||
/**
|
||||
* 根据时间范围查找呼叫列表
|
||||
*/
|
||||
List<FreeSwitchCallEntity> findByStartTimeBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||
List<FreeSwitchCallEntity> findByStartTimeBetween(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 根据主叫号码查找呼叫列表
|
||||
@@ -78,28 +78,28 @@ public interface FreeSwitchCallRepository extends JpaRepository<FreeSwitchCallEn
|
||||
* 统计指定时间范围内的呼叫总数
|
||||
*/
|
||||
@Query("SELECT COUNT(c) FROM FreeSwitchCallEntity c WHERE c.startTime BETWEEN ?1 AND ?2")
|
||||
long countCallsInTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
long countCallsInTimeRange(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内的已接听呼叫数
|
||||
*/
|
||||
@Query("SELECT COUNT(c) FROM FreeSwitchCallEntity c WHERE c.startTime BETWEEN ?1 AND ?2 AND c.status = 'ANSWERED'")
|
||||
long countAnsweredCallsInTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
long countAnsweredCallsInTimeRange(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 计算指定时间范围内的通话总时长
|
||||
*/
|
||||
@Query("SELECT COALESCE(SUM(c.duration), 0) FROM FreeSwitchCallEntity c WHERE c.startTime BETWEEN ?1 AND ?2 AND c.status = 'ANSWERED'")
|
||||
long sumDurationInTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
long sumDurationInTimeRange(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 计算指定时间范围内的等待总时长
|
||||
*/
|
||||
@Query("SELECT COALESCE(SUM(c.waitTime), 0) FROM FreeSwitchCallEntity c WHERE c.startTime BETWEEN ?1 AND ?2")
|
||||
long sumWaitTimeInTimeRange(LocalDateTime startTime, LocalDateTime endTime);
|
||||
long sumWaitTimeInTimeRange(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 删除指定时间之前的呼叫记录
|
||||
*/
|
||||
void deleteByStartTimeBefore(LocalDateTime time);
|
||||
void deleteByStartTimeBefore(ZonedDateTime time);
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.call;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -472,7 +472,7 @@ public class FreeSwitchCallService {
|
||||
try {
|
||||
// Optional<FreeSwitchNumberEntity> userOptional = userService.findByUsername(username);
|
||||
// if (userOptional.isPresent()) {
|
||||
// userService.updateLastRegistration(username, LocalDateTime.now());
|
||||
// userService.updateLastRegistration(username, ZonedDateTime.now());
|
||||
// log.debug("已更新用户最后注册时间: {}", username);
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
@@ -493,15 +493,15 @@ public class FreeSwitchCallService {
|
||||
cdr.setUid(callInfo.getCallUuid());
|
||||
cdr.setCallerIdNumber(callInfo.getCallerNumber());
|
||||
cdr.setDestinationNumber(callInfo.getCalleeNumber());
|
||||
cdr.setStartStamp(LocalDateTime.now().minusSeconds(
|
||||
cdr.setStartStamp(ZonedDateTime.now().minusSeconds(
|
||||
(System.currentTimeMillis() - callInfo.getStartTime()) / 1000));
|
||||
|
||||
if (callInfo.getStartTime() > 0) {
|
||||
cdr.setAnswerStamp(LocalDateTime.now().minusSeconds(
|
||||
cdr.setAnswerStamp(ZonedDateTime.now().minusSeconds(
|
||||
(System.currentTimeMillis() - callInfo.getStartTime()) / 1000));
|
||||
}
|
||||
|
||||
cdr.setEndStamp(LocalDateTime.now());
|
||||
cdr.setEndStamp(ZonedDateTime.now());
|
||||
cdr.setDuration((int) ((System.currentTimeMillis() - callInfo.getStartTime()) / 1000));
|
||||
cdr.setHangupCause(hangupCause);
|
||||
cdr.setDirection(callInfo.getType().toLowerCase());
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -53,8 +53,8 @@ public class FreeSwitchCdrController {
|
||||
@RequestParam(defaultValue = "desc") String direction,
|
||||
@RequestParam(required = false) String callerNumber,
|
||||
@RequestParam(required = false) String destinationNumber,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") ZonedDateTime startTime,
|
||||
@RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") ZonedDateTime endTime,
|
||||
@AuthenticationPrincipal UserEntity currentUser) {
|
||||
|
||||
try {
|
||||
@@ -207,8 +207,8 @@ public class FreeSwitchCdrController {
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public ResponseEntity<?> getCallStatistics(
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) {
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") ZonedDateTime startTime,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") ZonedDateTime endTime) {
|
||||
|
||||
try {
|
||||
FreeSwitchCdrService.CallStatistics statistics = cdrService.getCallStatistics(startTime, endTime);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.cdr;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
|
||||
@@ -66,17 +66,17 @@ public class FreeSwitchCdrEntity extends BaseEntity {
|
||||
/**
|
||||
* 通话开始时间
|
||||
*/
|
||||
private LocalDateTime startStamp;
|
||||
private ZonedDateTime startStamp;
|
||||
|
||||
/**
|
||||
* 通话接通时间
|
||||
*/
|
||||
private LocalDateTime answerStamp;
|
||||
private ZonedDateTime answerStamp;
|
||||
|
||||
/**
|
||||
* 通话结束时间
|
||||
*/
|
||||
private LocalDateTime endStamp;
|
||||
private ZonedDateTime endStamp;
|
||||
|
||||
/**
|
||||
* 通话总时长(秒)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.cdr;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -67,21 +67,21 @@ public class FreeSwitchCdrExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "开始时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime startStamp;
|
||||
private ZonedDateTime startStamp;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "接听时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime answerStamp;
|
||||
private ZonedDateTime answerStamp;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "结束时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime endStamp;
|
||||
private ZonedDateTime endStamp;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.cdr;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -65,7 +65,7 @@ public interface FreeSwitchCdrRepository extends JpaRepository<FreeSwitchCdrEnti
|
||||
/**
|
||||
* 查找指定时间范围内的CDR记录
|
||||
*/
|
||||
List<FreeSwitchCdrEntity> findByStartStampBetween(LocalDateTime startTime, LocalDateTime endTime);
|
||||
List<FreeSwitchCdrEntity> findByStartStampBetween(ZonedDateTime startTime, ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 查找成功接通的通话记录
|
||||
@@ -93,19 +93,19 @@ public interface FreeSwitchCdrRepository extends JpaRepository<FreeSwitchCdrEnti
|
||||
* 统计指定时间范围内的通话数量
|
||||
*/
|
||||
@Query("SELECT COUNT(c) FROM FreeSwitchCdrEntity c WHERE c.startStamp BETWEEN :startTime AND :endTime")
|
||||
long countCallsInTimeRange(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||
long countCallsInTimeRange(@Param("startTime") ZonedDateTime startTime, @Param("endTime") ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 统计指定时间范围内成功接通的通话数量
|
||||
*/
|
||||
@Query("SELECT COUNT(c) FROM FreeSwitchCdrEntity c WHERE c.startStamp BETWEEN :startTime AND :endTime AND c.answerStamp IS NOT NULL")
|
||||
long countAnsweredCallsInTimeRange(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||
long countAnsweredCallsInTimeRange(@Param("startTime") ZonedDateTime startTime, @Param("endTime") ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 计算指定时间范围内的总通话时长
|
||||
*/
|
||||
@Query("SELECT COALESCE(SUM(c.billsec), 0) FROM FreeSwitchCdrEntity c WHERE c.startStamp BETWEEN :startTime AND :endTime AND c.answerStamp IS NOT NULL")
|
||||
long sumBillSecInTimeRange(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
|
||||
long sumBillSecInTimeRange(@Param("startTime") ZonedDateTime startTime, @Param("endTime") ZonedDateTime endTime);
|
||||
|
||||
/**
|
||||
* 查找最近的通话记录
|
||||
@@ -133,5 +133,5 @@ public interface FreeSwitchCdrRepository extends JpaRepository<FreeSwitchCdrEnti
|
||||
/**
|
||||
* 删除指定日期之前的CDR记录
|
||||
*/
|
||||
void deleteByStartStampBefore(LocalDateTime cutoffDate);
|
||||
void deleteByStartStampBefore(ZonedDateTime cutoffDate);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* FreeSwitch通话详单请求实体
|
||||
@@ -72,11 +72,11 @@ public class FreeSwitchCdrRequest extends BaseRequest {
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
private LocalDateTime startDate;
|
||||
private ZonedDateTime startDate;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
private LocalDateTime endDate;
|
||||
private ZonedDateTime endDate;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* FreeSwitch通话详单响应实体
|
||||
@@ -92,17 +92,17 @@ public class FreeSwitchCdrResponse extends BaseResponse {
|
||||
/**
|
||||
* 开始时间戳
|
||||
*/
|
||||
private LocalDateTime startStamp;
|
||||
private ZonedDateTime startStamp;
|
||||
|
||||
/**
|
||||
* 接听时间戳
|
||||
*/
|
||||
private LocalDateTime answerStamp;
|
||||
private ZonedDateTime answerStamp;
|
||||
|
||||
/**
|
||||
* 结束时间戳
|
||||
*/
|
||||
private LocalDateTime endStamp;
|
||||
private ZonedDateTime endStamp;
|
||||
|
||||
/**
|
||||
* 主叫IP地址
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.cdr;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class FreeSwitchCdrService {
|
||||
/**
|
||||
* 根据时间范围查找CDR记录
|
||||
*/
|
||||
public List<FreeSwitchCdrEntity> findByTimeRange(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
public List<FreeSwitchCdrEntity> findByTimeRange(ZonedDateTime startTime, ZonedDateTime endTime) {
|
||||
return cdrRepository.findByStartStampBetween(startTime, endTime);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class FreeSwitchCdrService {
|
||||
/**
|
||||
* 获取通话统计信息
|
||||
*/
|
||||
public CallStatistics getCallStatistics(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
public CallStatistics getCallStatistics(ZonedDateTime startTime, ZonedDateTime endTime) {
|
||||
long totalCalls = cdrRepository.countCallsInTimeRange(startTime, endTime);
|
||||
long answeredCalls = cdrRepository.countAnsweredCallsInTimeRange(startTime, endTime);
|
||||
long totalDuration = cdrRepository.sumBillSecInTimeRange(startTime, endTime);
|
||||
@@ -168,7 +168,7 @@ public class FreeSwitchCdrService {
|
||||
*/
|
||||
@Transactional
|
||||
public void cleanupOldCdrs(int daysToKeep) {
|
||||
LocalDateTime cutoffDate = LocalDateTime.now().minusDays(daysToKeep);
|
||||
ZonedDateTime cutoffDate = ZonedDateTime.now().minusDays(daysToKeep);
|
||||
cdrRepository.deleteByStartStampBefore(cutoffDate);
|
||||
log.info("清理了{}天前的CDR记录", daysToKeep);
|
||||
}
|
||||
@@ -178,8 +178,8 @@ public class FreeSwitchCdrService {
|
||||
*/
|
||||
@Transactional
|
||||
public void processCdrEvent(String uuid, String callerNumber, String destinationNumber,
|
||||
String context, LocalDateTime startStamp, LocalDateTime answerStamp,
|
||||
LocalDateTime endStamp, Integer duration, Integer billsec,
|
||||
String context, ZonedDateTime startStamp, ZonedDateTime answerStamp,
|
||||
ZonedDateTime endStamp, Integer duration, Integer billsec,
|
||||
String hangupCause, String direction) {
|
||||
|
||||
Optional<FreeSwitchCdrEntity> existingCdr = cdrRepository.findByUid(uuid);
|
||||
@@ -214,7 +214,7 @@ public class FreeSwitchCdrService {
|
||||
* 更新CDR应答时间
|
||||
*/
|
||||
@Transactional
|
||||
public void updateCdrAnswerTime(String uuid, LocalDateTime answerTime) {
|
||||
public void updateCdrAnswerTime(String uuid, ZonedDateTime answerTime) {
|
||||
Optional<FreeSwitchCdrEntity> optionalCdr = cdrRepository.findByUid(uuid);
|
||||
if (optionalCdr.isPresent()) {
|
||||
FreeSwitchCdrEntity cdr = optionalCdr.get();
|
||||
@@ -230,7 +230,7 @@ public class FreeSwitchCdrService {
|
||||
* 更新CDR结束时间和挂断原因
|
||||
*/
|
||||
@Transactional
|
||||
public void updateCdrEndTime(String uuid, LocalDateTime endTime, String hangupCause) {
|
||||
public void updateCdrEndTime(String uuid, ZonedDateTime endTime, String hangupCause) {
|
||||
Optional<FreeSwitchCdrEntity> optionalCdr = cdrRepository.findByUid(uuid);
|
||||
if (optionalCdr.isPresent()) {
|
||||
FreeSwitchCdrEntity cdr = optionalCdr.get();
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.conference;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -63,11 +63,11 @@ public class FreeSwitchConferenceExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.freeswitch.config;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import org.freeswitch.esl.client.IEslEventListener;
|
||||
import org.freeswitch.esl.client.transport.event.EslEvent;
|
||||
@@ -91,7 +91,7 @@ public class FreeSwitchEventListener implements IEslEventListener {
|
||||
cdr.setUid(uuid);
|
||||
cdr.setCallerIdNumber(callerId);
|
||||
cdr.setDestinationNumber(destination);
|
||||
cdr.setStartStamp(LocalDateTime.now());
|
||||
cdr.setStartStamp(ZonedDateTime.now());
|
||||
cdr.setDirection("outbound"); // 默认为outbound,可根据实际情况调整
|
||||
cdr.setHangupCause(""); // 初始为空
|
||||
|
||||
@@ -119,7 +119,7 @@ public class FreeSwitchEventListener implements IEslEventListener {
|
||||
|
||||
// 更新CDR记录 - 设置应答时间
|
||||
try {
|
||||
cdrService.updateCdrAnswerTime(uuid, LocalDateTime.now());
|
||||
cdrService.updateCdrAnswerTime(uuid, ZonedDateTime.now());
|
||||
log.debug("已更新CDR应答时间: UUID {}", uuid);
|
||||
} catch (Exception e) {
|
||||
log.error("更新CDR应答时间失败: UUID {} - {}", uuid, e.getMessage(), e);
|
||||
@@ -140,7 +140,7 @@ public class FreeSwitchEventListener implements IEslEventListener {
|
||||
|
||||
// 更新CDR记录 - 设置结束时间和挂断原因
|
||||
try {
|
||||
cdrService.updateCdrEndTime(uuid, LocalDateTime.now(), hangupCause);
|
||||
cdrService.updateCdrEndTime(uuid, ZonedDateTime.now(), hangupCause);
|
||||
log.debug("已更新CDR结束时间: UUID {} 原因 {}", uuid, hangupCause);
|
||||
} catch (Exception e) {
|
||||
log.error("更新CDR结束时间失败: UUID {} - {}", uuid, e.getMessage(), e);
|
||||
@@ -185,7 +185,7 @@ public class FreeSwitchEventListener implements IEslEventListener {
|
||||
// Optional<FreeSwitchNumberEntity> userOptional = userService.findByUsername(username);
|
||||
// if (userOptional.isPresent()) {
|
||||
// if (online) {
|
||||
// userService.updateLastRegistration(username, LocalDateTime.now());
|
||||
// userService.updateLastRegistration(username, ZonedDateTime.now());
|
||||
// }
|
||||
// log.debug("已更新用户在线状态: {} -> {}", username, online);
|
||||
// }
|
||||
|
||||
@@ -15,7 +15,7 @@ package com.bytedesk.freeswitch.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
@@ -95,7 +95,7 @@ public class FreeSwitchHealthIndicator implements HealthIndicator {
|
||||
* 获取当前时间字符串
|
||||
*/
|
||||
private String getCurrentTime() {
|
||||
return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* FreeSwitch网关Excel导出实体
|
||||
@@ -84,12 +84,12 @@ public class FreeSwitchGatewayExcel {
|
||||
@ExcelProperty("创建时间")
|
||||
@ColumnWidth(20)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@ExcelProperty("更新时间")
|
||||
@ColumnWidth(20)
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
/**
|
||||
* 从实体转换为Excel对象
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.number;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.bytedesk.core.base.BaseEntity;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class FreeSwitchNumberEntity extends BaseEntity {
|
||||
/**
|
||||
* 最后注册时间
|
||||
*/
|
||||
private LocalDateTime lastRegister;
|
||||
private ZonedDateTime lastRegister;
|
||||
|
||||
/**
|
||||
* 注册IP地址
|
||||
@@ -114,6 +114,6 @@ public class FreeSwitchNumberEntity extends BaseEntity {
|
||||
*/
|
||||
public boolean isOnline() {
|
||||
return enabled && lastRegister != null &&
|
||||
lastRegister.isAfter(LocalDateTime.now().minusMinutes(5));
|
||||
lastRegister.isAfter(ZonedDateTime.now().minusMinutes(5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.number;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -59,16 +59,16 @@ public class FreeSwitchNumberExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "最后注册时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime lastRegister;
|
||||
private ZonedDateTime lastRegister;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.number;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -85,7 +85,7 @@ public interface FreeSwitchNumberRepository extends JpaRepository<FreeSwitchNumb
|
||||
/**
|
||||
* 查找在线用户(最近指定时间内有注册记录)
|
||||
*/
|
||||
List<FreeSwitchNumberEntity> findByEnabledTrueAndLastRegisterAfter(LocalDateTime cutoffTime);
|
||||
List<FreeSwitchNumberEntity> findByEnabledTrueAndLastRegisterAfter(ZonedDateTime cutoffTime);
|
||||
|
||||
/**
|
||||
* 统计域名下的用户数量
|
||||
@@ -95,13 +95,13 @@ public interface FreeSwitchNumberRepository extends JpaRepository<FreeSwitchNumb
|
||||
/**
|
||||
* 统计在线用户数量
|
||||
*/
|
||||
long countByEnabledTrueAndLastRegisterAfter(LocalDateTime cutoffTime);
|
||||
long countByEnabledTrueAndLastRegisterAfter(ZonedDateTime cutoffTime);
|
||||
|
||||
/**
|
||||
* 查找在线用户(最近5分钟内有注册记录)
|
||||
*/
|
||||
@Query("SELECT u FROM FreeSwitchNumberEntity u WHERE u.enabled = true AND u.lastRegister > :cutoffTime")
|
||||
List<FreeSwitchNumberEntity> findOnlineNumbers(@Param("cutoffTime") LocalDateTime cutoffTime);
|
||||
List<FreeSwitchNumberEntity> findOnlineNumbers(@Param("cutoffTime") ZonedDateTime cutoffTime);
|
||||
|
||||
/**
|
||||
* 根据用户名模糊搜索
|
||||
@@ -122,7 +122,7 @@ public interface FreeSwitchNumberRepository extends JpaRepository<FreeSwitchNumb
|
||||
* 统计在线用户数量
|
||||
*/
|
||||
@Query("SELECT COUNT(u) FROM FreeSwitchNumberEntity u WHERE u.enabled = true AND u.lastRegister > :cutoffTime")
|
||||
long countOnlineNumbers(@Param("cutoffTime") LocalDateTime cutoffTime);
|
||||
long countOnlineNumbers(@Param("cutoffTime") ZonedDateTime cutoffTime);
|
||||
|
||||
/**
|
||||
* 更新用户最后注册时间和IP
|
||||
@@ -130,6 +130,6 @@ public interface FreeSwitchNumberRepository extends JpaRepository<FreeSwitchNumb
|
||||
@Query("UPDATE FreeSwitchNumberEntity u SET u.lastRegister = :registerTime, u.registerIp = :registerIp WHERE u.username = :username AND u.domain = :domain")
|
||||
int updateLastRegister(@Param("username") String username,
|
||||
@Param("domain") String domain,
|
||||
@Param("registerTime") LocalDateTime registerTime,
|
||||
@Param("registerTime") ZonedDateTime registerTime,
|
||||
@Param("registerIp") String registerIp);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
/**
|
||||
* FreeSwitch用户响应实体
|
||||
@@ -67,7 +67,7 @@ public class FreeSwitchNumberResponse extends BaseResponse {
|
||||
/**
|
||||
* 最后注册时间
|
||||
*/
|
||||
private LocalDateTime lastRegister;
|
||||
private ZonedDateTime lastRegister;
|
||||
|
||||
/**
|
||||
* 注册IP地址
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -160,7 +160,7 @@ public class FreeSwitchNumberService {
|
||||
Optional<FreeSwitchNumberEntity> userOpt = userRepository.findByUsernameAndDomain(username, domain);
|
||||
if (userOpt.isPresent()) {
|
||||
FreeSwitchNumberEntity user = userOpt.get();
|
||||
user.setLastRegister(LocalDateTime.now());
|
||||
user.setLastRegister(ZonedDateTime.now());
|
||||
user.setRegisterIp(registerIp);
|
||||
user.setUserAgent(userAgent);
|
||||
userRepository.save(user);
|
||||
@@ -186,7 +186,7 @@ public class FreeSwitchNumberService {
|
||||
* 获取在线用户列表
|
||||
*/
|
||||
public List<FreeSwitchNumberEntity> findOnlineNumbers() {
|
||||
LocalDateTime cutoffTime = LocalDateTime.now().minusMinutes(5);
|
||||
ZonedDateTime cutoffTime = ZonedDateTime.now().minusMinutes(5);
|
||||
return userRepository.findByEnabledTrueAndLastRegisterAfter(cutoffTime);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class FreeSwitchNumberService {
|
||||
* 获取在线的用户数量
|
||||
*/
|
||||
public long countOnline() {
|
||||
LocalDateTime cutoffTime = LocalDateTime.now().minusMinutes(5);
|
||||
ZonedDateTime cutoffTime = ZonedDateTime.now().minusMinutes(5);
|
||||
return userRepository.countByEnabledTrueAndLastRegisterAfter(cutoffTime);
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class FreeSwitchNumberService {
|
||||
* 更新用户最后注册时间
|
||||
*/
|
||||
@Transactional
|
||||
public void updateLastRegistration(String username, LocalDateTime lastRegistration) {
|
||||
public void updateLastRegistration(String username, ZonedDateTime lastRegistration) {
|
||||
Optional<FreeSwitchNumberEntity> userOpt = userRepository.findByUsername(username);
|
||||
if (userOpt.isPresent()) {
|
||||
FreeSwitchNumberEntity user = userOpt.get();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bytedesk.freeswitch.queue;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -33,8 +33,8 @@ public class FreeSwitchQueueService {
|
||||
}
|
||||
|
||||
queue.setStatus(FreeSwitchQueueEntity.QueueStatus.ACTIVE);
|
||||
queue.setCreatedAt(LocalDateTime.now());
|
||||
queue.setUpdatedAt(LocalDateTime.now());
|
||||
queue.setCreatedAt(ZonedDateTime.now());
|
||||
queue.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return queueRepository.save(queue);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class FreeSwitchQueueService {
|
||||
existingQueue.setMaxLength(queue.getMaxLength());
|
||||
existingQueue.setWeight(queue.getWeight());
|
||||
existingQueue.setNotes(queue.getNotes());
|
||||
existingQueue.setUpdatedAt(LocalDateTime.now());
|
||||
existingQueue.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return queueRepository.save(existingQueue);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class FreeSwitchQueueService {
|
||||
.orElseThrow(() -> new RuntimeException("队列不存在: " + queueName));
|
||||
|
||||
queue.setStatus(status);
|
||||
queue.setUpdatedAt(LocalDateTime.now());
|
||||
queue.setUpdatedAt(ZonedDateTime.now());
|
||||
|
||||
return queueRepository.save(queue);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class FreeSwitchQueueService {
|
||||
|
||||
// call.setCurrentQueue(queueName);
|
||||
call.setStatus(CallStatus.QUEUED);
|
||||
// call.setQueueTime(LocalDateTime.now());
|
||||
// call.setQueueTime(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
package com.bytedesk.freeswitch.webrtc;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.format.DateTimeFormat;
|
||||
@@ -42,11 +42,11 @@ public class FreeSwitchWebRTCExcel {
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "创建时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime createdAt;
|
||||
private ZonedDateTime createdAt;
|
||||
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
@ExcelProperty(value = "修改时间")
|
||||
@ColumnWidth(25)
|
||||
private LocalDateTime updatedAt;
|
||||
private ZonedDateTime updatedAt;
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ AgentStatusEntity status = AgentStatusEntity.builder()
|
||||
.agent(agent)
|
||||
.status("ONLINE")
|
||||
.reason("Ready to take calls")
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.build();
|
||||
|
||||
// Example: Assigning skills to agent
|
||||
|
||||
@@ -67,7 +67,7 @@ AgentStatusEntity status = AgentStatusEntity.builder()
|
||||
.agent(agent)
|
||||
.status("ONLINE")
|
||||
.reason("准备接听电话")
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.build();
|
||||
|
||||
// 示例:分配坐席技能
|
||||
|
||||
@@ -67,7 +67,7 @@ AgentStatusEntity status = AgentStatusEntity.builder()
|
||||
.agent(agent)
|
||||
.status("ONLINE")
|
||||
.reason("準備接聽電話")
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.build();
|
||||
|
||||
// 示例:分配坐席技能
|
||||
|
||||
@@ -49,7 +49,7 @@ FreeSwitchCallEntity call = FreeSwitchCallEntity.builder()
|
||||
.callerNumber("1234567890")
|
||||
.calleeNumber("0987654321")
|
||||
.status(CallStatus.QUEUED)
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.queueId(1L)
|
||||
.agentId(1L)
|
||||
.skills("{\"language\":\"en\",\"department\":\"support\"}")
|
||||
|
||||
@@ -49,7 +49,7 @@ FreeSwitchCallEntity call = FreeSwitchCallEntity.builder()
|
||||
.callerNumber("1234567890")
|
||||
.calleeNumber("0987654321")
|
||||
.status(CallStatus.QUEUED)
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.queueId(1L)
|
||||
.agentId(1L)
|
||||
.skills("{\"language\":\"zh\",\"department\":\"support\"}")
|
||||
|
||||
@@ -49,7 +49,7 @@ FreeSwitchCallEntity call = FreeSwitchCallEntity.builder()
|
||||
.callerNumber("1234567890")
|
||||
.calleeNumber("0987654321")
|
||||
.status(CallStatus.QUEUED)
|
||||
.startTime(LocalDateTime.now())
|
||||
.startTime(ZonedDateTime.now())
|
||||
.queueId(1L)
|
||||
.agentId(1L)
|
||||
.skills("{\"language\":\"zh_TW\",\"department\":\"support\"}")
|
||||
|
||||
@@ -45,7 +45,7 @@ FreeSwitchCdrEntity cdr = FreeSwitchCdrEntity.builder()
|
||||
.callerIdName("John Doe")
|
||||
.callerIdNumber("1234567890")
|
||||
.destinationNumber("0987654321")
|
||||
.startStamp(LocalDateTime.now())
|
||||
.startStamp(ZonedDateTime.now())
|
||||
.duration(300)
|
||||
.billsec(280)
|
||||
.hangupCause("NORMAL_CLEARING")
|
||||
|
||||
@@ -45,7 +45,7 @@ FreeSwitchCdrEntity cdr = FreeSwitchCdrEntity.builder()
|
||||
.callerIdName("张三")
|
||||
.callerIdNumber("1234567890")
|
||||
.destinationNumber("0987654321")
|
||||
.startStamp(LocalDateTime.now())
|
||||
.startStamp(ZonedDateTime.now())
|
||||
.duration(300)
|
||||
.billsec(280)
|
||||
.hangupCause("NORMAL_CLEARING")
|
||||
|
||||
@@ -45,7 +45,7 @@ FreeSwitchCdrEntity cdr = FreeSwitchCdrEntity.builder()
|
||||
.callerIdName("張三")
|
||||
.callerIdNumber("1234567890")
|
||||
.destinationNumber("0987654321")
|
||||
.startStamp(LocalDateTime.now())
|
||||
.startStamp(ZonedDateTime.now())
|
||||
.duration(300)
|
||||
.billsec(280)
|
||||
.hangupCause("NORMAL_CLEARING")
|
||||
|
||||
Reference in New Issue
Block a user