Commit c32f2a9e by tongpuxin

增加录音下载解冻

parent a41631ba
...@@ -45,10 +45,11 @@ public class ExGridLoad { ...@@ -45,10 +45,11 @@ public class ExGridLoad {
* @param page 分页对象 * @param page 分页对象
*/ */
public static ExGridLoad wrapExGridLoad(Collection<?> list, Paging page) { public static ExGridLoad wrapExGridLoad(Collection<?> list, Paging page) {
Long totalCount = page.getTotalCount(); if(page.getTotalCount() == null || page.getTotalCount() <= 0) {
if(totalCount == null || totalCount <= 0)totalCount = new Long(list.size()); page.setTotalCount(new Long(list.size()));
}
ExGridLoad exGridLoad = new ExGridLoad(); ExGridLoad exGridLoad = new ExGridLoad();
exGridLoad.setTotalCount(totalCount); exGridLoad.setTotalCount(page.getTotalCount());
exGridLoad.setTotalPage(page.getTotalPage()); exGridLoad.setTotalPage(page.getTotalPage());
exGridLoad.setResult(list); exGridLoad.setResult(list);
return exGridLoad; return exGridLoad;
......
package com.app.ydl.ydl.controller;
import cn.hutool.core.collection.ListUtil;
import com.app.framework.core.support.controller.CrudBaseControllerSupport;
import com.app.framework.core.support.view.form.AjaxResult;
import com.app.framework.core.support.view.grid.Paging;
import com.app.ydl.ydl.service.CallRecordService;
import com.app.ydl.ydl.view.CallRecordView;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 录音文件下载、解冻
*/
@Slf4j
@Controller
@RequestMapping("/call/call_record")
public class CallRecordController extends CrudBaseControllerSupport<CallRecordView> {
@Resource
CallRecordService callRecordService;
private boolean isStandardOrder(String id) {
if (id.startsWith("97") || id.startsWith("99")) {
return true;
}
return false;
}
/**
* 查询列表的具体实现
* 请求:list
*
* @param request HttpServletRequest
* @param view 查询条件
* @param paging 分页条件
* @return 查询结果
*/
@Override
public List<CallRecordView> list(HttpServletRequest request, CallRecordView view, Paging paging) {
List<CallRecordView> list = null;
if (StringUtils.isNotBlank(view.getOrderId())) {
if (this.isStandardOrder(view.getOrderId())) {
return callRecordService.getByStandardOrderId(Long.parseLong(view.getOrderId()));
} else {
list = callRecordService.getByRelationId(view.getOrderId());
}
} else if (StringUtils.isNotBlank(view.getRelationId())) {
if (this.isStandardOrder(view.getRelationId())) {
return callRecordService.getByStandardOrderServiceId(Long.parseLong(view.getRelationId()));
} else {
list = callRecordService.getByRelationId(view.getRelationId());
}
} else if (view.getId() != null) {
CallRecordView byId = callRecordService.getById(view.getId());
if (this.isStandardOrder(byId.getRelationId())) {
return callRecordService.getByStandardOrderAndCallRecordId(view.getId());
} else {
list = ListUtil.toList(byId);
}
}
if (list == null) {
list = new ArrayList<>();
}
for (CallRecordView callRecordView : list) {
callRecordView.setOrderId(callRecordView.getRelationId());
}
return list;
}
/**
* 保存记录的具体实现
* 请求:saveEntity
*
* @param request HttpServletRequest
* @param entity 实体
* @return 影响结果数
*/
@Override
public AjaxResult saveEntity(HttpServletRequest request, CallRecordView entity) {
return AjaxResult.wrap(false);
}
/**
* 删除记录,根据Id 具体实现
* 请求:deleteById 参数oid
* 请求:batchDelete 参数oid数组
*
* @param request HttpServletRequest
* @param oids 实体
* @return 影响结果数
*/
@Override
public AjaxResult batchDelete(HttpServletRequest request, Long oids[]) {
return AjaxResult.wrap(false);
}
@RequestMapping(value = "/golist")
public ModelAndView info(HttpServletRequest request) {
Map<String, Object> result = new HashMap<>();
return new ModelAndView("admin/business/call_record/list.html", result);
}
@RequestMapping(value = "/thaw")
@ResponseBody
public AjaxResult thaw(String recordUrl) {
log.info("call_record.thaw:{}", recordUrl);
return AjaxResult.wrap(true);
}
}
package com.app.ydl.ydl.dao;
import com.app.ydl.ydl.view.CallRecordView;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@DS("ydl")
public interface CallRecordDao {
@Select("SELECT r.id, r.relation_id, r.record_url FROM ydl.call_record r WHERE r.id = #{id}")
CallRecordView getById(Long id);
@Select("SELECT r.id, r.relation_id, r.record_url FROM ydl.call_record r " +
"WHERE r.record_url != '' AND r.record_url != 'no' " +
"AND r.relation_id = #{relationId}")
List<CallRecordView> getByRelationId(String relationId);
@Select("SELECT sos.standard_order_id AS order_id, sos.id AS relation_id, r.record_url, r.id FROM ydl.call_record r " +
"LEFT JOIN ydl.standard_order_service sos ON sos.id = r.relation_id " +
"WHERE r.record_url != '' AND r.record_url != 'no' " +
"AND sos.id = #{orderServiceId} ;")
List<CallRecordView> getByStandardOrderServiceId(Long orderServiceId);
@Select("SELECT sos.standard_order_id AS order_id, sos.id AS relation_id, r.record_url, r.id FROM ydl.call_record r " +
"LEFT JOIN ydl.standard_order_service sos ON sos.id = r.relation_id " +
"WHERE r.record_url != '' AND r.record_url != 'no' " +
"AND sos.standard_order_id = #{orderId} ;")
List<CallRecordView> getByStandardOrderId(Long orderId);
@Select("SELECT sos.standard_order_id AS order_id, sos.id AS relation_id, r.record_url, r.id FROM ydl.call_record r " +
"LEFT JOIN ydl.standard_order_service sos ON sos.id = r.relation_id " +
"WHERE r.record_url != '' AND r.record_url != 'no' " +
"AND r.id = #{callRecordId} ;")
List<CallRecordView> getByStandardOrderAndCallRecordId(Long callRecordId);
}
\ No newline at end of file
package com.app.ydl.ydl.service;
import com.app.ydl.ydl.dao.CallRecordDao;
import com.app.ydl.ydl.view.CallRecordView;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class CallRecordService {
@Resource
private CallRecordDao callRecordDao;
public CallRecordView getById(Long id) {
return callRecordDao.getById(id);
}
public List<CallRecordView> getByRelationId(String relationId) {
return callRecordDao.getByRelationId(relationId);
}
public List<CallRecordView> getByStandardOrderId(Long orderId) {
return callRecordDao.getByStandardOrderId(orderId);
}
public List<CallRecordView> getByStandardOrderServiceId(Long orderServiceId) {
return callRecordDao.getByStandardOrderServiceId(orderServiceId);
}
public List<CallRecordView> getByStandardOrderAndCallRecordId(Long callRecordId) {
return callRecordDao.getByStandardOrderAndCallRecordId(callRecordId);
}
}
\ No newline at end of file
package com.app.ydl.ydl.view;
import lombok.Data;
import java.io.Serializable;
@Data
public class CallRecordView implements Serializable {
private Long id;
private String relationId;
private String recordUrl;
private String orderId;
}
...@@ -20,7 +20,7 @@ spring: ...@@ -20,7 +20,7 @@ spring:
# 主库数据源 # 主库数据源
master: master:
driverClassName: org.sqlite.JDBC driverClassName: org.sqlite.JDBC
url: jdbc:sqlite::resource:ydl_admin.db?date_string_format=yyyy-MM-dd HH:mm:ss url: jdbc:sqlite:/Users/tongpuxin/Documents/workspace/ydl/yunjiao-admin/src/main/resources/ydl_admin.db?date_string_format=yyyy-MM-dd HH:mm:ss
username: root username: root
password: root password: root
# 营销数据源 # 营销数据源
...@@ -30,9 +30,15 @@ spring: ...@@ -30,9 +30,15 @@ spring:
username: ydl username: ydl
password: tt12345 password: tt12345
# 医疗数据源 # 医疗数据源
ydl_yiliao: # ydl_yiliao:
# driverClassName: com.mysql.jdbc.Driver
# url: jdbc:mysql://120.26.213.52:3306/ydl_yiliao?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
# username: ydl
# password: tt12345
# ydl数据源
ydl:
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://120.26.213.52:3306/ydl_yiliao?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai url: jdbc:mysql://120.26.213.52:3306/ydl?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: ydl username: ydl
password: tt12345 password: tt12345
druid: druid:
......
...@@ -35,6 +35,12 @@ spring: ...@@ -35,6 +35,12 @@ spring:
# url: jdbc:mysql://rm-bp1z1072kug2190fy.mysql.rds.aliyuncs.com:3306/ydl_yiliao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai # url: jdbc:mysql://rm-bp1z1072kug2190fy.mysql.rds.aliyuncs.com:3306/ydl_yiliao?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
# username: ydl_yiliao_read # username: ydl_yiliao_read
# password: Yl$2304823jjY5699 # password: Yl$2304823jjY5699
# ydl数据源
ydl:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://rm-bp14n58nzawa6ykny.mysql.rds.aliyuncs.com:3306/ydl?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: ydl_yiliao
password: CD1V*DSV7w4!fDaAzs@&
druid: druid:
initial-size: 5 initial-size: 5
max-active: 100 max-active: 100
......
/**
* 录音文件查询
*/
$(function(){
AppCallRecord = {
Events : {'click .btn': function (e, value, row, index) {
var event = $(e.target).data('event');
if(event == 'download'){
AppCallRecord.download(row);
}else if(event == 'thaw'){
AppCallRecord.thaw(row);
}
}},
download : function(row){
var recordUrl = row['recordUrl'];
if(!recordUrl) {
App.MsgBox.msg("文件URL为空");
return;
}
window.open(recordUrl);
},
thaw: function(row){
App.MsgBox.confirm('确定要解冻吗', function(){
var recordUrl = row['recordUrl'];
if(!recordUrl) {
App.MsgBox.msg("文件URL为空");
return;
}
App.Ajax.request({
url : Config.ROOT + '/call/call_record/thaw',
params : {
'recordUrl': recordUrl
},
success: function(resp){
}
});
});
},
search: function () {
$table.search({
'page' : 1
});
}
};
//初始化表格
var $table = new App.Table({
url: Config.ROOT + '/call/call_record/list',
search: false,
searchParamName: '',
searchPlaceholder: '',
columns :[
{field:'id', title:'操作', width: 120, toolbar: 'tableRowToolbar', events: AppCallRecord.Events},
{field:'', title:'通话记录ID', formatter: function (value, row, index) {
return row['id'];
}},
{field:'relationId', title:'订单', formatter: function (value, row, index) {
return row['orderId'] + '_' + value;
}},
{field:'recordUrl', title:'音频'}
],
getQueryParam: function () {
var search_orderId = $('#search_orderId').val() || '';
var search_relationId = $('#search_relationId').val() || '';
var search_callRecordId = $('#search_callRecordId').val() || '';
var postData = {
'orderId' : search_orderId,
'relationId' : search_relationId,
'id' : search_callRecordId
};
return postData;
}
});
});
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh">
<head>
<@meta/>
<title>录音文件查询</title>
<#include "admin/common/include_hplus.ftl">
<#include "admin/common/include_form.ftl">
<#include "admin/common/include_table.ftl">
<script src="<@contextPath/>/templates/admin/business/call_record/js/list.js" type="text/javascript"></script>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox ">
<div class="ibox-content">
<h3>${module.name}</h3>
<script type="text/html" id="tableRowToolbar">
<a class="btn btn-xs btn-primary" data-event="download">下载</a></br></br>
<a class="btn btn-xs btn-success" data-event="thaw">解冻</a></br></br>
</script>
<form role="form" class="form-inline" onsubmit="return false">
<div class="form-group">
<input type="text" placeholder="orderId" id="search_orderId" class="form-control">
</div>
<div class="form-group">
<input type="text" placeholder="relationId" id="search_relationId" class="form-control">
</div>
<div class="form-group">
<input type="text" placeholder="callRecordId" id="search_callRecordId" class="form-control">
</div>
<button class="btn btn-primary" type="button" onclick="AppCallRecord.search()">搜索</button>
</form>
<div class="btn-group" id="tableEventsToolbar" role="group">
</div>
<table id="tableEvents" data-mobile-responsive="true">
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment