|
@@ -1,17 +1,20 @@
|
|
|
package com.welampiot.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.welampiot.common.BaseResult;
|
|
|
import com.welampiot.common.InterfaceResultEnum;
|
|
|
+import com.welampiot.configuration.BroadcastConfig;
|
|
|
+import com.welampiot.dao.BroadcastProListDao;
|
|
|
import com.welampiot.dto.*;
|
|
|
-import com.welampiot.service.BroadcastItemService;
|
|
|
-import com.welampiot.service.BroadcastPolicyInfoService;
|
|
|
-import com.welampiot.service.BroadcastService;
|
|
|
-import com.welampiot.service.UserService;
|
|
|
+import com.welampiot.service.*;
|
|
|
+import com.welampiot.utils.BroadcastUtil;
|
|
|
import com.welampiot.utils.ToolUtils;
|
|
|
import com.welampiot.vo.BroadcastDetailsVO;
|
|
|
import com.welampiot.vo.BroadcastItemVO;
|
|
|
import com.welampiot.vo.BroadcastProListVO;
|
|
|
import com.welampiot.vo.BroadcastVO;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
@@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -53,6 +57,9 @@ public class BroadcastController {
|
|
|
@Autowired
|
|
|
private BroadcastPolicyInfoService broadcastPolicyInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BroadcastProListService broadcastProListService;
|
|
|
+
|
|
|
/**
|
|
|
* 获取音柱列表
|
|
|
* @param request
|
|
@@ -270,4 +277,315 @@ public class BroadcastController {
|
|
|
broadcastItemVO1.setTotal(total);
|
|
|
return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,broadcastItemVO1);
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 调节设备音量
|
|
|
+ * @param request
|
|
|
+ * @return 调节设备音量
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/setVol", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> setVol(HttpServletRequest request){
|
|
|
+ Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
|
|
|
+ Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
|
|
|
+ Integer vol = request.getParameter("vol") == null ? 0 : Integer.parseInt(request.getParameter("vol"));
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ BroadcastDTO broadcastById = broadcastService.getBroadcastById(id);
|
|
|
+ if (broadcastById.getType() == 0){ // 小播鼠
|
|
|
+ String s = "{\"mode\":1009,\"snlist\":[\""+broadcastById.getAddress()+"\"],\"vol\":"+vol+",\"vols\":"+vol+"}";
|
|
|
+ s = s.length()+"\n"+s;
|
|
|
+ BroadcastUtil.sendBroadcastXiaoBoshu(s, 10);
|
|
|
+ BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ broadcastDTO.setVol(vol);
|
|
|
+ broadcastDTO.setId(id);
|
|
|
+ broadcastService.updateBroadcastById(broadcastDTO);
|
|
|
+ } else if (broadcastById.getType() == 1) { // 世邦
|
|
|
+ String url = BroadcastConfig.shiBangHost+"/php/setterminal.php";
|
|
|
+ int i = vol / 63 * 15;
|
|
|
+ HashMap<String, Object> stringStringHashMap = new HashMap<>();
|
|
|
+ stringStringHashMap.put("jsondata[tname]",broadcastById.getName());
|
|
|
+ stringStringHashMap.put("jsondata[tid]",broadcastById.getDevId());
|
|
|
+ stringStringHashMap.put("jsondata[tbcoutv]",i);
|
|
|
+ BroadcastUtil.sendBroadcastShiBang(url, stringStringHashMap, 5000);
|
|
|
+ BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ broadcastDTO.setVol(vol);
|
|
|
+ broadcastDTO.setId(id);
|
|
|
+ broadcastService.updateBroadcastById(broadcastDTO);
|
|
|
+ } else if (broadcastById.getType() == 3){ // 威西尔
|
|
|
+
|
|
|
+ } else if (broadcastById.getType() == 4){ // 迪士普
|
|
|
+
|
|
|
+ }else{ // 先科
|
|
|
+
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 播放停止节目
|
|
|
+ * @param request
|
|
|
+ * @return 播放停止节目
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/itemPlay", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> itemPlay(HttpServletRequest request){
|
|
|
+ Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
|
|
|
+ Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
|
|
|
+ Integer status = request.getParameter("status") == null ? 0 : Integer.parseInt(request.getParameter("status"));
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ BroadcastItemDTO broadcastItemDTOById = broadcastItemService.getBroadcastItemDTOById(id);
|
|
|
+ if (broadcastItemDTOById.getProType() == 1){
|
|
|
+ String[] broadcastId = broadcastItemDTOById.getBroadcastId().split(",");
|
|
|
+ if (status == 1){
|
|
|
+ for (String s:broadcastId) {
|
|
|
+ BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ broadcastDTO.setId(Integer.valueOf(s));
|
|
|
+ broadcastDTO.setPolicyId(id);
|
|
|
+ broadcastDTO.setItemId(id);
|
|
|
+ broadcastService.updateBroadcastById(broadcastDTO);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ for (String s:broadcastId) {
|
|
|
+ BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ broadcastDTO.setId(Integer.valueOf(s));
|
|
|
+ broadcastDTO.setPolicyId(0);
|
|
|
+ broadcastDTO.setItemId(0);
|
|
|
+ broadcastService.updateBroadcastById(broadcastDTO);
|
|
|
+ }
|
|
|
+ if (!broadcastItemDTOById.getGuid().isEmpty() || !broadcastItemDTOById.getNumber().isEmpty()){
|
|
|
+ String url = BroadcastConfig.shiBangHost+"/php/exeRealPlayFile.php";
|
|
|
+ HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
+ stringObjectHashMap.put("jsondata[rtype]","stopbct");
|
|
|
+ stringObjectHashMap.put("jsondata[param1]",broadcastItemDTOById.getNumber());
|
|
|
+ stringObjectHashMap.put("jsondata[param2]",broadcastItemDTOById.getGuid());
|
|
|
+ BroadcastUtil.sendBroadcastShiBang(url,stringObjectHashMap,50);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
|
|
|
+ broadcastItemDTO.setId(id);
|
|
|
+ broadcastItemDTO.setStatus(status);
|
|
|
+ broadcastItemService.updateCommonProgramData(broadcastItemDTO);
|
|
|
+
|
|
|
+ // 世邦
|
|
|
+ if (!broadcastItemDTOById.getTaskId().isEmpty()){
|
|
|
+ String[] split = broadcastItemDTOById.getTaskId().split(",");
|
|
|
+ for (String s:split) {
|
|
|
+ HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
+ if (status == 1){
|
|
|
+ stringObjectHashMap.put("jsondata[isDisable]",0);
|
|
|
+ }else {
|
|
|
+ String url = BroadcastConfig.shiBangHost+"/php/exetaskcmd.php";
|
|
|
+ stringObjectHashMap.put("jsondata[taskCommand]","stoptaskinfo");
|
|
|
+ stringObjectHashMap.put("jsondata[taskId]",s);
|
|
|
+ BroadcastUtil.sendBroadcastShiBang(url,stringObjectHashMap,50);
|
|
|
+
|
|
|
+ stringObjectHashMap = new HashMap<>();
|
|
|
+ stringObjectHashMap.put("jsondata[isDisable]",1);
|
|
|
+ }
|
|
|
+ String url = BroadcastConfig.shiBangHost+"/php/exceptionable.php";
|
|
|
+ stringObjectHashMap.put("jsondata[taskId]",s);
|
|
|
+ String s1 = BroadcastUtil.sendBroadcastShiBang(url, stringObjectHashMap, 5000);
|
|
|
+ if (s1.isEmpty()) return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 威西尔
|
|
|
+ if (!broadcastItemDTOById.getWeiErXiId().isEmpty()){
|
|
|
+
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject seedCode = new JSONObject();
|
|
|
+ JSONArray proList = new JSONArray();
|
|
|
+ JSONArray proList2 = new JSONArray();
|
|
|
+ if (status == 0){
|
|
|
+ if (broadcastItemDTOById.getProId1() != null && broadcastItemDTOById.getProId1() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId1(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId1(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId2() != null && broadcastItemDTOById.getProId2() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId2(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId2(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId3() != null && broadcastItemDTOById.getProId3() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId3(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId3(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId4() != null && broadcastItemDTOById.getProId4() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId4(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId4(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId5() != null && broadcastItemDTOById.getProId5() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId5(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId5(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId6() != null && broadcastItemDTOById.getProId6() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId6(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId6(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId7() != null && broadcastItemDTOById.getProId7() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId7(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId7(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId8() != null && broadcastItemDTOById.getProId8() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId8(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId8(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId9() != null && broadcastItemDTOById.getProId9() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId9(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId9(),1));
|
|
|
+ }
|
|
|
+ if (broadcastItemDTOById.getProId10() != null && broadcastItemDTOById.getProId10() != 0){
|
|
|
+ proList.add(this.getProInfo(broadcastItemDTOById.getProId10(),0));
|
|
|
+ proList2.add(this.getProInfo(broadcastItemDTOById.getProId10(),1));
|
|
|
+ }
|
|
|
+ seedCode.put("type","cmd");
|
|
|
+ }else {
|
|
|
+ seedCode.put("type","stop");
|
|
|
+ }
|
|
|
+ List<BroadcastDTO> listByIds = broadcastService.getListByIds(broadcastItemDTOById.getBroadcastId());
|
|
|
+ JSONArray devList = new JSONArray();
|
|
|
+ ArrayList yuAddress = new ArrayList();
|
|
|
+ for (BroadcastDTO dto : listByIds) {
|
|
|
+ if (dto.getOnline() == 0) continue;
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ if (dto.getType() == 0){
|
|
|
+// jsonObject.put("address",dto.getAddress());
|
|
|
+// jsonObject.put("proList",proList);
|
|
|
+// jsonObject.put("playType",broadcastItemDTOById.getPlayType());
|
|
|
+// jsonObject.put("vol",dto.getVol());
|
|
|
+// devList.add(jsonObject);
|
|
|
+ yuAddress.add(dto.getAddress());
|
|
|
+ } else if (dto.getType() == 2) {
|
|
|
+ jsonObject.put("address",dto.getDevId());
|
|
|
+ jsonObject.put("name",dto.getAddress());
|
|
|
+ jsonObject.put("proList",proList2);
|
|
|
+ jsonObject.put("playType",broadcastItemDTOById.getPlayType());
|
|
|
+ jsonObject.put("devType",2);
|
|
|
+ jsonObject.put("vol",dto.getVol());
|
|
|
+ devList.add(jsonObject);
|
|
|
+ } else if (dto.getType() == 4) {
|
|
|
+ jsonObject.put("address",dto.getAddress());
|
|
|
+ jsonObject.put("proList",proList);
|
|
|
+ jsonObject.put("playType",broadcastItemDTOById.getPlayType());
|
|
|
+ jsonObject.put("devType",4);
|
|
|
+ jsonObject.put("vol",dto.getVol());
|
|
|
+ devList.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!yuAddress.isEmpty()){
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("address", StringUtils.join(yuAddress,","));
|
|
|
+ jsonObject.put("proList",proList);
|
|
|
+ jsonObject.put("playType",broadcastItemDTOById.getPlayType());
|
|
|
+ devList.add(jsonObject);
|
|
|
+ }
|
|
|
+ seedCode.put("devList",devList);
|
|
|
+ String string = seedCode.toJSONString();
|
|
|
+ BroadcastUtil.sendBroadcastByTcp(string,2000);
|
|
|
+ // 世邦
|
|
|
+ if (!broadcastItemDTOById.getTaskId().isEmpty()){
|
|
|
+ HashMap data2 = new HashMap<>();
|
|
|
+ String url;
|
|
|
+ if (broadcastItemDTOById.getProType() == 1){
|
|
|
+ url = BroadcastConfig.shiBangHost+"/php/exetaskenable.php";
|
|
|
+ if (status == 0){
|
|
|
+ String url2 = BroadcastConfig.shiBangHost+"/php/exetaskcmd.php";
|
|
|
+ data2.put("jsondata[taskCommand]","stoptaskinfo");
|
|
|
+ data2.put("jsondata[taskId]",broadcastItemDTOById.getTaskId());
|
|
|
+ BroadcastUtil.sendBroadcastShiBang(url2, data2, 5000);
|
|
|
+ data2 = new HashMap<>();
|
|
|
+ data2.put("jsondata[isDisable]",0);
|
|
|
+ data2.put("jsondata[taskId]",broadcastItemDTOById.getTaskId());
|
|
|
+ }else {
|
|
|
+ data2 = new HashMap<>();
|
|
|
+ data2.put("jsondata[isDisable]",1);
|
|
|
+ data2.put("jsondata[taskId]",broadcastItemDTOById.getTaskId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ url = BroadcastConfig.shiBangHost+"/php/exetaskcmd.php";
|
|
|
+ if (status == 0){
|
|
|
+ data2 = new HashMap<>();
|
|
|
+ data2.put("jsondata[taskCommand]","runtaskinfo");
|
|
|
+ data2.put("jsondata[taskId]",broadcastItemDTOById.getTaskId());
|
|
|
+ }else {
|
|
|
+ data2.put("jsondata[taskCommand]","stoptaskinfo");
|
|
|
+ data2.put("jsondata[taskId]",broadcastItemDTOById.getTaskId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String s1 = BroadcastUtil.sendBroadcastShiBang(url, data2, 5000);
|
|
|
+ if (s1.isEmpty()) return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 威西尔
|
|
|
+ if (!broadcastItemDTOById.getWeiErXiId().isEmpty()){
|
|
|
+
|
|
|
+ }
|
|
|
+ String[] split = broadcastItemDTOById.getBroadcastId().split(",");
|
|
|
+ for (String s:split) {
|
|
|
+ BroadcastDTO broadcastDTO = new BroadcastDTO();
|
|
|
+ broadcastDTO.setItemId(id);
|
|
|
+ broadcastDTO.setId(Integer.valueOf(s));
|
|
|
+ broadcastService.updateBroadcastById(broadcastDTO);
|
|
|
+ }
|
|
|
+ BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
|
|
|
+ broadcastItemDTO.setId(id);
|
|
|
+ broadcastItemDTO.setStatus(status);
|
|
|
+ broadcastItemService.updateCommonProgramData(broadcastItemDTO);
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject getProInfo(Integer proId,int type){
|
|
|
+ BroadcastProListDTO oneById = broadcastProListService.getOneById(proId);
|
|
|
+ JSONObject pro = new JSONObject();
|
|
|
+ String s = oneById.getXianKeName().substring(0, oneById.getXianKeName().length() - 6) + oneById.getXianKeName().substring(oneById.getXianKeName().length() - 4);
|
|
|
+ if (type == 0){
|
|
|
+ pro.put("url",oneById.getUrl());
|
|
|
+ pro.put("time",oneById.getTime()+4);
|
|
|
+ }else {
|
|
|
+ pro.put("url",s);
|
|
|
+ pro.put("time",oneById.getTime());
|
|
|
+ }
|
|
|
+ pro.put("xianke_name",s);
|
|
|
+ pro.put("xianke_id",oneById.getXianKeId());
|
|
|
+ pro.put("disipu_id",oneById.getDiSiPuId());
|
|
|
+ pro.put("id",proId);
|
|
|
+ return pro;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 停止播放设备
|
|
|
+ * @param request
|
|
|
+ * @return 停止播放设备
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/devStop", method = RequestMethod.POST)
|
|
|
+ public BaseResult<?> devStop(HttpServletRequest request){
|
|
|
+ Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
|
|
|
+ Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
|
|
|
+ if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
|
|
|
+
|
|
|
+ BroadcastDTO broadcastById = broadcastService.getBroadcastById(id);
|
|
|
+ if (broadcastById.getType() == 0){
|
|
|
+ String cmd = "{\"type\":\"stop\",\"devList\":[{\"address\":\""+broadcastById.getAddress()+"\"}]}";
|
|
|
+ BroadcastUtil.sendBroadcastByTcp(cmd,0);
|
|
|
+ } else if (broadcastById.getType() == 1) {
|
|
|
+ String url = BroadcastConfig.shiBangHost+"/php/exesdkcommand.php";
|
|
|
+ HashMap<String, Object> stringObjectHashMap = new HashMap<>();
|
|
|
+ stringObjectHashMap.put("jsondata[target]",broadcastById.getDevId());
|
|
|
+ stringObjectHashMap.put("jsondata[source]",broadcastById.getDevId());
|
|
|
+ stringObjectHashMap.put("jsondata[commandtype]",3);
|
|
|
+ stringObjectHashMap.put("jsondata[commandtype]",1);
|
|
|
+ stringObjectHashMap.put("jsondata[commandtype]",0);
|
|
|
+ String s = BroadcastUtil.sendBroadcastShiBang(url, stringObjectHashMap, 10000);
|
|
|
+ if (s == null || s.length() == 0) return toolUtils.response(InterfaceResultEnum.SEND_CMD_TIME_OUT,version);
|
|
|
+ } else if (broadcastById.getType() == 3) {
|
|
|
+
|
|
|
+ } else if (broadcastById.getType() == 4) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
|
|
|
+ }
|
|
|
}
|