Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
fe5309b5
Commit
fe5309b5
authored
Sep 06, 2021
by
kongfm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新tzs119
parent
f8449fec
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
52 deletions
+195
-52
IVoiceRecordFileService.java
.../boot/module/tzs/api/service/IVoiceRecordFileService.java
+4
-0
VoiceRecordFileController.java
.../module/tzs/biz/controller/VoiceRecordFileController.java
+6
-49
TaskExecutorPoolConfig.java
...oot/module/tzs/biz/core/async/TaskExecutorPoolConfig.java
+23
-0
AmosThreadPool.java
...s/boot/module/tzs/biz/core/threadpool/AmosThreadPool.java
+59
-0
CtiServiceImpl.java
...amos/boot/module/tzs/biz/service/impl/CtiServiceImpl.java
+1
-0
VoiceRecordFileServiceImpl.java
...dule/tzs/biz/service/impl/VoiceRecordFileServiceImpl.java
+102
-3
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/service/IVoiceRecordFileService.java
View file @
fe5309b5
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
api
.
service
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.VoiceRecordFileDto
;
/**
* 通话记录附件接口类
*
...
...
@@ -9,4 +11,6 @@ package com.yeejoin.amos.boot.module.tzs.api.service;
*/
public
interface
IVoiceRecordFileService
{
void
publishRecord
(
VoiceRecordFileDto
model
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/VoiceRecordFileController.java
View file @
fe5309b5
...
...
@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -54,9 +55,6 @@ public class VoiceRecordFileController extends BaseController {
@Autowired
AlertCalledServiceImpl
iAlertCalledService
;
@Autowired
ICtiService
ctiService
;
/**
* 新增通话记录附件
*
...
...
@@ -123,56 +121,15 @@ public class VoiceRecordFileController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@PostMapping
(
value
=
"/saveRecord"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增通话记录附件"
,
notes
=
"新增通话记录附件"
)
public
ResponseModel
<
VoiceRecordFileDto
>
saveRecord
(
@RequestBody
VoiceRecordFileDto
model
)
{
public
ResponseModel
<
Boolean
>
saveRecord
(
@RequestBody
VoiceRecordFileDto
model
)
{
if
(
ValidationUtil
.
isEmpty
(
model
.
getAlertId
())
||
ValidationUtil
.
isEmpty
(
model
.
getConnectId
())){
throw
new
BadRequest
(
"参数校验失败."
);
}
// 获取通话人信息
JSONArray
recordInfos
=
ctiService
.
getCallInfo
(
model
.
getConnectId
());
if
(
recordInfos
==
null
||
recordInfos
.
size
()
==
0
)
{
throw
new
BadRequest
(
"未找到通话详单信息"
);
}
JSONObject
recordInfo
=
recordInfos
.
getJSONObject
(
0
);
model
.
setTel
(
recordInfo
.
getString
(
"telephone"
));
voiceRecordFileServiceImpl
.
publishRecord
(
model
);
return
ResponseHelper
.
buildResponse
(
true
);
}
Date
telStartTime
=
null
;
Date
telEndTime
=
null
;
try
{
telStartTime
=
DateUtils
.
longStr2Date
(
recordInfo
.
getString
(
"connectTime"
));
telEndTime
=
DateUtils
.
longStr2Date
(
recordInfo
.
getString
(
"hangupTime"
));
}
catch
(
Exception
e
)
{
throw
new
BadRequest
(
"日期转换错误"
);
}
model
.
setTelStartTime
(
telStartTime
);
model
.
setTelEndTime
(
telEndTime
);
if
(
1
==
recordInfo
.
getInteger
(
"callType"
))
{
model
.
setFileType
(
"客户呼入"
);
}
else
if
(
2
==
recordInfo
.
getInteger
(
"callType"
))
{
model
.
setFileType
(
"坐席呼出"
);
}
// 获取附件 需要延时5S
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
String
>
downloadFile
=
ctiService
.
downLoadRecordFile
(
recordInfo
.
getString
(
"connectionid"
));
if
(
downloadFile
.
isEmpty
())
{
throw
new
BadRequest
(
"未找到附件文件"
);
}
for
(
Map
.
Entry
<
String
,
String
>
file
:
downloadFile
.
entrySet
())
{
model
.
setFilePath
(
file
.
getKey
());
}
AlertCalledFormDto
alertDto
=
iAlertCalledService
.
selectAlertCalledByIdNoCache
(
model
.
getAlertId
());
if
(
alertDto
==
null
||
alertDto
.
getAlertCalledDto
()
==
null
)
{
throw
new
BadRequest
(
"未找到相关警情"
);
}
model
.
setAlertStage
(
alertDto
.
getAlertCalledDto
().
getAlertStage
());
model
.
setAlertStageCode
(
alertDto
.
getAlertCalledDto
().
getAlertStageCode
());
model
.
setSourceId
(-
1
l
);
model
=
voiceRecordFileServiceImpl
.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/core/async/TaskExecutorPoolConfig.java
0 → 100644
View file @
fe5309b5
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
core
.
async
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
@Configuration
public
class
TaskExecutorPoolConfig
{
@Bean
(
"asyncTaskExecutor"
)
public
Executor
taskExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
10
);
//线程池维护线程的最少数量
executor
.
setMaxPoolSize
(
100
);
//线程池维护线程的最大数量
executor
.
setQueueCapacity
(
100
);
executor
.
setKeepAliveSeconds
(
30
);
//线程池维护线程所允许的空闲时间,TimeUnit.SECONDS
executor
.
setThreadNamePrefix
(
"asyncTaskExecutor-"
);
// 线程池对拒绝任务的处理策略: CallerRunsPolicy策略,当线程池没有处理能力的时候,该策略会直接在 execute 方法的调用线程中运行被拒绝的任务;如果执行程序已关闭,则会丢弃该任务
// executor.setRejectedExecutionHandler(ThreadPoolExecutor.CallerRunsPolicy());
return
executor
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/core/threadpool/AmosThreadPool.java
0 → 100644
View file @
fe5309b5
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
core
.
threadpool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* 线程池
*/
public
class
AmosThreadPool
{
/**
* 日志记录器
*/
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
AmosThreadPool
.
class
);
/**
* 单例
*/
private
static
AmosThreadPool
instance
;
/**
* 执行服务
*/
private
static
ExecutorService
executorService
;
/**
* 获取单例
*
* @return
*/
public
static
AmosThreadPool
getInstance
()
{
if
(
instance
==
null
)
{
synchronized
(
AmosThreadPool
.
class
)
{
if
(
instance
==
null
)
{
instance
=
new
AmosThreadPool
();
}
}
}
return
instance
;
}
static
{
executorService
=
Executors
.
newFixedThreadPool
(
20
);
}
/**
* 执行线程
*
* @param task
*/
public
void
execute
(
Runnable
task
)
{
executorService
.
execute
(
task
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/CtiServiceImpl.java
View file @
fe5309b5
...
...
@@ -121,6 +121,7 @@ public class CtiServiceImpl implements ICtiService {
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
"accessToken"
,
token
);
String
responseStr
=
HttpUtils
.
doPostWithHeader
(
url
,
params
.
toJSONString
(),
header
);
JSONObject
response
=
null
;
try
{
response
=
JSONObject
.
parseObject
(
responseStr
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/service/impl/VoiceRecordFileServiceImpl.java
View file @
fe5309b5
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.biz.common.feign.AmosFeignService
;
import
com.yeejoin.amos.boot.biz.common.utils.DateUtils
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.AlertCalledFormDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.VoiceRecordFileDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.VoiceRecordFile
;
import
com.yeejoin.amos.boot.module.tzs.api.mapper.VoiceRecordFileMapper
;
import
com.yeejoin.amos.boot.module.tzs.api.service.ICtiService
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IVoiceRecordFileService
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.VoiceRecordFileDto
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 通话记录附件服务实现类
...
...
@@ -17,6 +31,25 @@ import java.util.List;
*/
@Service
public
class
VoiceRecordFileServiceImpl
extends
BaseService
<
VoiceRecordFileDto
,
VoiceRecordFile
,
VoiceRecordFileMapper
>
implements
IVoiceRecordFileService
{
@Autowired
private
VoiceRecordFileServiceImpl
voiceRecordFileServiceImpl
;
private
final
Logger
logger
=
LogManager
.
getLogger
(
AmosFeignService
.
class
);
@Autowired
AlertCalledServiceImpl
iAlertCalledService
;
@Autowired
ICtiService
ctiService
;
private
volatile
JSONArray
ctiInfos
;
@Autowired
EmqKeeper
emqKeeper
;
private
String
ctiMessage
=
"/cti/callphone"
;
/**
* 分页查询
*/
...
...
@@ -30,4 +63,69 @@ public class VoiceRecordFileServiceImpl extends BaseService<VoiceRecordFileDto,V
public
List
<
VoiceRecordFileDto
>
queryForVoiceRecordFileList
()
{
return
this
.
queryForList
(
""
,
false
);
}
@Override
public
void
publishRecord
(
final
VoiceRecordFileDto
model
)
{
Long
now
=
System
.
currentTimeMillis
();
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
Long
end
=
System
.
currentTimeMillis
();
// 获取通话人信息
ctiInfos
=
ctiService
.
getCallInfo
(
model
.
getConnectId
());
if
(
ctiInfos
==
null
||
ctiInfos
.
size
()
==
0
)
{
logger
.
error
(
"未找到通话详单信息"
+
(
end
-
now
));
}
JSONObject
recordInfo
=
ctiInfos
.
getJSONObject
(
0
);
model
.
setTel
(
recordInfo
.
getString
(
"telephone"
));
Date
telStartTime
=
null
;
Date
telEndTime
=
null
;
try
{
telStartTime
=
DateUtils
.
longStr2Date
(
recordInfo
.
getString
(
"connectTime"
));
telEndTime
=
DateUtils
.
longStr2Date
(
recordInfo
.
getString
(
"hangupTime"
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"日期转换错误"
);
}
model
.
setTelStartTime
(
telStartTime
);
model
.
setTelEndTime
(
telEndTime
);
if
(
1
==
recordInfo
.
getInteger
(
"callType"
))
{
model
.
setFileType
(
"客户呼入"
);
}
else
if
(
2
==
recordInfo
.
getInteger
(
"callType"
))
{
model
.
setFileType
(
"坐席呼出"
);
}
Map
<
String
,
String
>
downloadFile
=
ctiService
.
downLoadRecordFile
(
recordInfo
.
getString
(
"connectionid"
));
if
(
downloadFile
.
isEmpty
())
{
logger
.
error
(
"未找到附件文件"
);
}
for
(
Map
.
Entry
<
String
,
String
>
file
:
downloadFile
.
entrySet
())
{
model
.
setFilePath
(
file
.
getKey
());
}
AlertCalledFormDto
alertDto
=
iAlertCalledService
.
selectAlertCalledByIdNoCache
(
model
.
getAlertId
());
if
(
alertDto
==
null
||
alertDto
.
getAlertCalledDto
()
==
null
)
{
logger
.
error
(
"未找到相关警情"
);
}
model
.
setAlertStage
(
alertDto
.
getAlertCalledDto
().
getAlertStage
());
model
.
setAlertStageCode
(
alertDto
.
getAlertCalledDto
().
getAlertStageCode
());
model
.
setSourceId
(-
1
l
);
voiceRecordFileServiceImpl
.
createWithModel
(
model
);
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"code"
,
"1001"
);
json
.
put
(
"type"
,
"addRecord"
);
try
{
emqKeeper
.
getMqttClient
().
publish
(
ctiMessage
,
json
.
toJSONString
().
getBytes
(),
2
,
false
);
}
catch
(
MqttException
e
)
{
logger
.
error
(
"推送失败"
);
}
}
}
\ No newline at end of file
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