|
|
@@ -1,6 +1,5 @@
|
|
|
package com.zd.alg.speaker.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.zd.alg.speaker.domain.RemoteAddress;
|
|
|
import com.zd.alg.speaker.service.ISpeakerService;
|
|
|
@@ -10,9 +9,6 @@ import com.zd.algorithm.api.speaker.entity.PlayVo;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
import com.zd.common.core.redis.RedisService;
|
|
|
import com.zd.common.core.utils.StringUtils;
|
|
|
-import com.zd.laboratory.api.feign.RemoteLaboratoryService;
|
|
|
-import com.zd.model.domain.AjaxResult;
|
|
|
-import com.zd.model.domain.R;
|
|
|
import com.zd.model.entity.UrlVo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -52,9 +48,6 @@ public class SpeakerServiceImpl implements ISpeakerService {
|
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RemoteLaboratoryService remoteLaboratoryService;
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public String getToken() {
|
|
|
@@ -209,67 +202,6 @@ public class SpeakerServiceImpl implements ISpeakerService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AjaxResult openSpeakBySubId(Long subId, String musicUrl) {
|
|
|
- if(subId == null || StringUtils.isBlank(musicUrl)){
|
|
|
- return AjaxResult.error("实验室id或音乐地址为空!");
|
|
|
- }
|
|
|
- R r=remoteLaboratoryService.getSpeakerBySubId(subId);
|
|
|
- if(r.getCode()!=200){
|
|
|
- return AjaxResult.error("获取设备列表失败!");
|
|
|
- }
|
|
|
- List<Map<String,Object>> mapList= (List<Map<String, Object>>) r.getData();
|
|
|
- String responseStr = getDeviceList(1, 1000);
|
|
|
- if(StringUtils.isEmpty(responseStr)){
|
|
|
- return AjaxResult.error("获取设备列表失败!");
|
|
|
- }
|
|
|
- JSONObject jsonObject=JSONObject.parseObject(responseStr);
|
|
|
- JSONArray jsonArray=JSONArray.parseArray(jsonObject.getString("rows"));
|
|
|
- for(Map<String,Object> map: mapList){
|
|
|
- for(int i=0;i<jsonArray.size();i++){
|
|
|
- JSONObject extra=jsonArray.getJSONObject(i).getJSONObject("extra");
|
|
|
- JSONObject obj = extra.getJSONObject("config");
|
|
|
- if(obj.getString("mac").equals(map.getOrDefault("hardwareNum","").toString())){
|
|
|
- map.put("deviceSn",obj.getString("sn"));
|
|
|
- map.put("deviceIp",extra.getString("ip"));
|
|
|
- map.put("operate",extra.getString("online"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return AjaxResult.success(mapList);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public AjaxResult openSpeakByFloorId(Long floorId, String musicUrl) {
|
|
|
- if(floorId == null || StringUtils.isBlank(musicUrl)){
|
|
|
- return AjaxResult.error("楼层id或音乐地址为空!");
|
|
|
- }
|
|
|
- R r=remoteLaboratoryService.getSpeakerByFloor(floorId);
|
|
|
- if(r.getCode()!=200){
|
|
|
- return AjaxResult.error("获取设备列表失败!");
|
|
|
- }
|
|
|
- List<Map<String,Object>> mapList= (List<Map<String, Object>>) r.getData();
|
|
|
- String responseStr = getDeviceList(1, 1000);
|
|
|
- if(StringUtils.isEmpty(responseStr)){
|
|
|
- return AjaxResult.error("获取设备列表失败!");
|
|
|
- }
|
|
|
- JSONObject jsonObject=JSONObject.parseObject(responseStr);
|
|
|
- JSONArray jsonArray=JSONArray.parseArray(jsonObject.getString("rows"));
|
|
|
- for(Map<String,Object> map: mapList){
|
|
|
- for(int i=0;i<jsonArray.size();i++){
|
|
|
- JSONObject extra=jsonArray.getJSONObject(i).getJSONObject("extra");
|
|
|
- JSONObject obj = extra.getJSONObject("config");
|
|
|
- if(obj.getString("mac").equals(map.getOrDefault("hardwareNum","").toString())){
|
|
|
- map.put("deviceSn",obj.getString("sn"));
|
|
|
- map.put("deviceIp",extra.getString("ip"));
|
|
|
- map.put("operate",extra.getString("online"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return AjaxResult.success(mapList);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public boolean stopPlayMusic(String sn, String ip) {
|
|
|
logger.info("********************" + sn + "********************");
|
|
|
String remoteUrlIp = remoteAddress.getProtocol() + "://" + remoteAddress.getTtsIp() + ":" + remoteAddress.getRemotePort() + "/api/sendtodevice";
|