48 lines
1.6 KiB
Java
48 lines
1.6 KiB
Java
|
|
package com.zhgd.xmgl.call;
|
|||
|
|
|
|||
|
|
import cn.hutool.core.codec.Base64;
|
|||
|
|
import cn.hutool.core.io.FileUtil;
|
|||
|
|
import cn.hutool.http.HttpRequest;
|
|||
|
|
import com.alibaba.fastjson.JSONObject;
|
|||
|
|
import com.zhgd.xmgl.call.api.BroadcastManufacturer;
|
|||
|
|
import com.zhgd.xmgl.modules.broadcast.entity.SmartBroadcastConfig;
|
|||
|
|
import lombok.extern.slf4j.Slf4j;
|
|||
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||
|
|
import org.springframework.context.annotation.Scope;
|
|||
|
|
import org.springframework.stereotype.Component;
|
|||
|
|
|
|||
|
|
import java.util.List;
|
|||
|
|
|
|||
|
|
@Slf4j
|
|||
|
|
@Component
|
|||
|
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|||
|
|
public class ShiZiWangBroadcastCall implements BroadcastManufacturer {
|
|||
|
|
private SmartBroadcastConfig config;
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public SmartBroadcastConfig getConfig() {
|
|||
|
|
return config;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void setConfig(SmartBroadcastConfig config) {
|
|||
|
|
this.config = config;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public void playVoiceFile(List<String> devSns, String fileName, String filePath) {
|
|||
|
|
JSONObject jsonObject = new JSONObject();
|
|||
|
|
jsonObject.put("SerialNums", devSns);
|
|||
|
|
jsonObject.put("PlayText", fileName);
|
|||
|
|
jsonObject.put("PlayFileContent", Base64.encode(FileUtil.readBytes(filePath)));
|
|||
|
|
String body = jsonObject.toJSONString();
|
|||
|
|
String url = "https://norsos.lionking110.com/sos/v1/mntn/adap/business/external/group/play";
|
|||
|
|
log.info("狮子王播放语音文件url:{},body:{}", url, body);
|
|||
|
|
String result = HttpRequest.post(url)
|
|||
|
|
.body(body)
|
|||
|
|
.timeout(20000)
|
|||
|
|
.execute().body();
|
|||
|
|
log.info("狮子王播放语音文件结果:{}", result);
|
|||
|
|
}
|
|||
|
|
}
|