Bläddra i källkod

修改了部分的broadcastcontroller部分接口

weclouds 1 år sedan
förälder
incheckning
1d0a2fea89

+ 6 - 1
src/main/java/com/welampiot/common/InterfaceResultEnum.java

@@ -228,7 +228,12 @@ public enum InterfaceResultEnum {
     LACK_PLC_MACADDRESS__ERROR("0503","请添加灯地址","Please add a light address","Пожалуйста, добавьте адрес лампы."),
     FILL_LAMP_ADDRESS__ERROR("0504","请填写正确的灯地址","Please fill in the correct lamp address","Укажите правильный адрес лампы"),
     PLC_SERIAL_NUMBER_SAME__ERROR("0505","设置双灯时,灯序号要一致","When setting up dual lights, the light numbers should be consistent","При установке двойного света номера ламп должны совпадать."),
-
+    LACK_PROGRESS_NAME_ERROR("0506","节目名称不能为空","Program name cannot be empty","название программы не может быть пустым"),
+    LACK_MUSIC_ERROR("0507","请选择音乐","Please select music","Выберите музыку"),
+    LACK_DEVICE_ERROR("0508","请选择设备","Please select device","Выберите устройство"),
+    REPEAT_TIME_ERROR("0509","策略开始时间不能重复","Policy start time cannot be repeated","время начала стратегии не может быть повторено"),
+    POLICY_CONTENT_ERROR("0510","策略内容不能为空","Policy content can not be empty","содержимое стратегии не может быть пустым"),
+    PROGRAM_NAME_EXIST_ERROR("0511","节目名称已经存在","The program name already exists","название программы уже существует"),
 
 
     //分组 0600-0699 分组名称必须在1-255数字范围内

+ 801 - 88
src/main/java/com/welampiot/controller/BroadcastController.java

@@ -23,10 +23,11 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -59,7 +60,15 @@ public class BroadcastController {
 
     @Autowired
     private BroadcastProListService broadcastProListService;
+    @Autowired
+    private LampPoleService lampPoleService;
 
+    final private Integer shibangOpen = 1;
+    //世邦音柱接口地址
+    final private String xinchang_shibang_url = "http://218.75.118.162:1181";
+    final private String shibang_url = "http://112.74.87.184";
+    // 先科音柱接口地址
+    final private String xianke_url = "http://120.24.31.58:8888";
     /**
      * 获取音柱列表
      * @param request
@@ -67,13 +76,40 @@ public class BroadcastController {
      */
     @RequestMapping(value = "/devList", method = RequestMethod.POST)
     public BaseResult<BroadcastDTO> devList(HttpServletRequest request){
-        Integer online = request.getParameter("online") == null || request.getParameter("online").length() == 0 ? null : Integer.parseInt(request.getParameter("online"));
+        Integer version = request.getParameter("version") == null ? 0 : Integer.parseInt(request.getParameter("version"));
+        String online = request.getParameter("online");
+        Integer areaId = request.getParameter("areaId") == null ? 0 : Integer.parseInt(request.getParameter("areaId"));
+        Integer sectionId = request.getParameter("sectionId") == null ? 0 : Integer.parseInt(request.getParameter("sectionId"));
+
         BroadcastDTO dto = new BroadcastDTO();
-        if (online != null) dto.setOnlineState(online);
-        dto.setSectionList(toolUtils.getSectionList(request));
+        dto.setAreaId(areaId);
+        dto.setSectionId(sectionId);
+        if (sectionId == 0){
+            List sectionList = toolUtils.getSectionList(request);
+            dto.setSectionList(sectionList);
+        }
+        if (online != null){
+            dto.setOnlineState(Integer.parseInt(online));
+        }
 
-        BroadcastVO vo = broadcastService.getDevListByBroadcastDTO(dto);
-        return BaseResult.success(vo);
+        List<BroadcastDTO> list = broadcastService.getDevListByBroadcastDTO(dto);
+        for (BroadcastDTO broadcastDTO:list) {
+            if (broadcastDTO.getType() == 0){
+                broadcastDTO.setProName((broadcastDTO.getProName() == null || broadcastDTO.getIsPlay() == null) ? "" : broadcastDTO.getProName() );
+            }else {
+                broadcastDTO.setProName((broadcastDTO.getItemName() == null || broadcastDTO.getIsPlay() == null) ? "" : broadcastDTO.getItemName() );
+            }
+        }
+        //设备在线数
+        dto.setOnlineState(1);
+        Integer onlineTotal = broadcastService.getCount(dto);
+        dto.setOnlineState(null);
+        Integer total = broadcastService.getCount(dto);
+        BroadcastVO broadcastVO = new BroadcastVO();
+        broadcastVO.setList(list);
+        broadcastVO.setTotal(total);
+        broadcastVO.setOnlineCount(onlineTotal);
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,broadcastVO);
     }
 
     /**
@@ -95,103 +131,780 @@ public class BroadcastController {
      */
     @RequestMapping(value = "/itemList", method = RequestMethod.POST)
     public BaseResult<BroadcastItemDTO> itemList(HttpServletRequest request){
-        String username = request.getParameter("username") == null ? "" : request.getParameter("username");
+        Integer version = request.getParameter("version") == null ? 0 : Integer.valueOf(request.getParameter("version"));
         Integer devId = request.getParameter("devId") == null ? 0 : Integer.parseInt(request.getParameter("devId"));
-        BroadcastItemVO vo = broadcastService.getItemListByDTO(username, devId);
-        return BaseResult.success(vo);
+        UserDTO user = toolUtils.getUser(request);
+        BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
+        if (user.getRole() != ToolUtils.SYSTEM_ADMIN) broadcastItemDTO.setUserId(user.getId());
+        List<BroadcastItemDTO> list = broadcastItemService.getList(broadcastItemDTO);
+        BroadcastItemVO vo = new BroadcastItemVO();
+
+        if (list != null && list.size() > 0){
+            String allItemId = "";
+            for (BroadcastItemDTO dto:list) {
+                String broadcastId = dto.getBroadcastId();
+                if (allItemId.equals("")){
+                    allItemId = broadcastId;
+                }else {
+                    allItemId = allItemId + ","+broadcastId;
+                }
+            }
+            List<String> idArr = null;
+            if (allItemId.equals("")){
+                String[] split = allItemId.split(",");
+                Set<String> uniqueItemIds = new HashSet<>(Arrays.asList(split));
+                // 将Set转换回数组
+               String[] arr = uniqueItemIds.toArray(new String[0]);
+                idArr = Arrays.asList(arr);
+
+            }else {
+                String[] arr = new String[]{"0"};
+                idArr = Arrays.asList(arr);
+            }
+            BroadcastDTO broadcastDTO = new BroadcastDTO();
+            broadcastDTO.setIdList(idArr);
+            List<BroadcastDTO> broadList = broadcastService.getList(broadcastDTO);
+            HashMap<Integer, BroadcastDTO> temp = new HashMap<>();
+            for (BroadcastDTO dto:broadList) {
+                temp.put(dto.getId(),dto);
+            }
+            HashSet<Integer> temp2 = new HashSet<>();
+            for (BroadcastItemDTO dto:list) {
+                temp2.add(dto.getProId10());
+                temp2.add(dto.getProId2());
+                temp2.add(dto.getProId3());
+                temp2.add(dto.getProId4());
+                temp2.add(dto.getProId5());
+                temp2.add(dto.getProId6());
+                temp2.add(dto.getProId7());
+                temp2.add(dto.getProId8());
+            }
+            ArrayList<Integer> proIds = new ArrayList<>(temp2);
+            BroadcastProListDTO broadcastProListDTO = new BroadcastProListDTO();
+            broadcastProListDTO.setIdList(proIds);
+            List<BroadcastProListDTO> proList = broadcastProListService.getList(broadcastProListDTO);
+            HashMap<Integer, BroadcastProListDTO> pro_t = new HashMap<>();
+            for (BroadcastProListDTO dto:proList) {
+               pro_t.put(dto.getId(),dto);
+            }
+
+            Iterator itr = list.iterator();
+            while(itr.hasNext()) {
+                BroadcastItemDTO next = (BroadcastItemDTO)itr.next();
+                String[] split = next.getBroadcastId().split(",");
+                List<String> ids = Arrays.asList(split);
+                if (!ids.contains(String.valueOf(devId))){
+                    itr.remove();
+                }
+                ArrayList<String> broadName = new ArrayList<>();
+                for (String id:ids) {
+                    if (temp.get(id) != null){
+                        broadName.add(temp.get(id).getName());
+                    }
+                }
+                next.setBroadcastStr(broadName.size() == 0 ? "":String.join(",",broadName));
+                ArrayList<String> p_name = new ArrayList<>();
+                Class<? extends BroadcastItemDTO> clazz = next.getClass();
+                for (int i = 1; i <= 10; i ++){
+                    try {
+                        // 动态创建字段名
+                        String index = String.valueOf(i);
+                        String fieldName = "proId" + index;
+                        // 获取字段
+                        Field field = clazz.getDeclaredField(fieldName);
+                        // 设置字段可访问,忽略访问权限
+                        field.setAccessible(true);
+                        if (field.get(next) != null && pro_t.get(field.get(next)) != null){
+                            p_name.add(pro_t.get(field.get(next)).getName());
+                        }
+                    } catch (NoSuchFieldException | IllegalAccessException e) {
+                        e.printStackTrace();
+                    }
+                }
+                next.setProStr(String.join(",",p_name));
+            }
+            vo.setList(list);
+
+        }else {
+            vo.setList(new ArrayList<>());
+        }
+        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
     }
 
+
+    private Object getArrayParam(HttpServletRequest request) {
+        Map<String, String[]> fileList = request.getParameterMap();
+        int i = 0; //每三个值都设置一次就会重设置
+        //set排序,从下标0开始
+        Set<String> setCollection = fileList.keySet();
+        Set<String> sortSet = new TreeSet<String>((o1, o2) -> o1.compareTo(o2));
+        sortSet.addAll(setCollection);
+        //查找相应的值 - 这里是二维数组
+        int inner = 0; //proTimeList的下标
+        int innerParam = 0; //proTimeList每个对象总数
+        boolean lackParam = true; //是否缺少参数
+        ArrayList<BroadcastItemVO> proList = new ArrayList<>();
+        BroadcastItemVO vo = new BroadcastItemVO();
+        BroadcastItemDTO item = new BroadcastItemDTO();
+        List<BroadcastItemDTO> proTimeList = new ArrayList<>();
+        int lack = 0;
+        for (String key : sortSet) {//返回set类型,无序的
+            if (key.contains("proList")) {
+                String[] values = fileList.get(key);
+                if (key.contains("beginDate")){
+                    //多个情况下
+                    if (Integer.parseInt(key.substring(8, 9)) != i){
+                        i++;
+                        inner = 0;
+                        innerParam = 0;
+                        lack = 0;
+                        vo.setProTimeList(proTimeList);
+                        proList.add(vo);
+                        //清除数组的所有数据
+                        proTimeList =new ArrayList<>();
+                        vo = new BroadcastItemVO();
+                    }
+                    lack ++;
+                    vo.setBeginDate(values[0]);
+                }
+
+                if (key.contains("proTimeList")){
+
+                    if (key.contains("beginTime") && inner == Integer.parseInt(key.substring(24,25))){
+                        lack ++;
+                        innerParam ++;
+                        item.setBeginTime(values[0]);
+                    }
+                    if (key.contains("time") && inner == Integer.parseInt(key.substring(24,25))){
+                        lack ++;
+                        innerParam ++;
+                        item.setTime(values[0]);
+                    }
+                    if (key.contains("vol") && inner == Integer.parseInt(key.substring(24,25))){
+                        lack ++;
+                        innerParam ++;
+                        item.setVol(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("playType") && inner == Integer.parseInt(key.substring(24,25))){
+                        lack ++;
+                        innerParam ++;
+                        item.setPlayType(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId1") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId1(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId2") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId2(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId3") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId3(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId4") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId4(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId5") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId5(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId6") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId6(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId7") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId7(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId8") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId8(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId9") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId9(Integer.valueOf(values[0]));
+                    }
+                    if (key.contains("proId10") && inner == Integer.parseInt(key.substring(24,25))){
+                        innerParam ++;
+                        item.setProId10(Integer.valueOf(values[0]));
+                    }
+                    if (item.getProId1() == null) {
+                        item.setProId1(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId2() == null) {
+                        item.setProId2(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId3() == null){
+                        item.setProId3(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId4() == null) {
+                        item.setProId4(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId5() == null){
+                        item.setProId5(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId6() == null) {
+                        item.setProId6(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId7() == null) {
+                        item.setProId7(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId8() == null) {
+                        item.setProId8(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId9() == null) {
+                        item.setProId9(0);
+                        innerParam ++;
+                    }
+                    if (item.getProId10() == null) {
+                        item.setProId10(0);
+                        innerParam ++;
+                    }
+
+                    if (innerParam == 13){
+                        if (lack < 4){
+                            lackParam = false;
+                            break;
+                        }
+                        innerParam = 0;
+                        inner ++;
+                        proTimeList.add(item);
+                        item = new BroadcastItemDTO();
+                    }
+                    if (inner != Integer.parseInt(key.substring(24,25))){
+                        if (lack < 4){
+                            lackParam = false;
+                            break;
+                        }
+                    }
+                }
+                if (lack == 0){
+                    lackParam = false;
+                    break;
+                }
+            }
+        }
+
+        if (lackParam == false){
+            //System.out.println("缺少参数");
+        }
+        if (i >= 0 && lackParam == true){
+            //只有一组或多组
+            vo.setProTimeList(proTimeList);
+            proList.add(vo);
+        }
+        return lackParam == false ? "缺少参数" : proList;
+    }
     /**
-     * 添加编辑节目
+     * 添加编辑节目 TODO
      * @param vo 节目表属性
      * @return 添加编辑节目
      */
     @RequestMapping(value = "/itemSave", method = RequestMethod.POST)
-    public BaseResult<?> itemSave(BroadcastDetailsVO vo) {
-        BroadcastDetailsVO detailsVO = BroadcastDetailsVO.getBroadcastDetailsVO(vo);
-        Integer version = detailsVO.getVersion();
-        String username = detailsVO.getUsername();
-        Integer proType = detailsVO.getProType();
-        String name = detailsVO.getName();
-        Integer playType = detailsVO.getPlayType();
-        String broadcastId = detailsVO.getBroadcastId();
-        if (username.length() == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
-        UserDTO userDTO = userService.queryUserIdByUsername(username);
-        if (userDTO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
-        detailsVO.setUserId(userDTO.getId());
-        if (proType == null || name.length() == 0 || broadcastId.length() == 0 || playType == null)
-            return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
-        BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
-        BeanUtils.copyProperties(detailsVO,broadcastItemDTO);
-        Integer id = detailsVO.getId();
-        if (proType == 0) { // 普通节目
-            if (id == 0) {
-                long l = System.currentTimeMillis();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                String format = simpleDateFormat.format(l);
-                broadcastItemDTO.setCreateTime(format);
-                broadcastItemService.addCommonProgramData(broadcastItemDTO);
-            } else {
-                broadcastItemService.updateCommonProgramData(broadcastItemDTO);
+    public BaseResult<?> itemSave(HttpServletRequest request) throws IOException, ParseException {
+
+        Integer version = request.getParameter("version") == null ? 0 : Integer.valueOf(request.getParameter("version"));
+        Integer id = request.getParameter("id") == null ? 0 : Integer.parseInt(request.getParameter("id"));
+        String name = request.getParameter("name");
+        Integer proType = request.getParameter("proType") == null ? 0 : Integer.parseInt(request.getParameter("proType"));
+        Integer proId1 = request.getParameter("proId1") == null ? 0 : Integer.parseInt(request.getParameter("proId1"));
+        Integer proId2 = request.getParameter("proId2") == null ? 0 : Integer.parseInt(request.getParameter("proId2"));
+        Integer proId3 = request.getParameter("proId3") == null ? 0 : Integer.parseInt(request.getParameter("proId3"));
+        Integer proId4 = request.getParameter("proId4") == null ? 0 : Integer.parseInt(request.getParameter("proId4"));
+        Integer proId5 = request.getParameter("proId5") == null ? 0 : Integer.parseInt(request.getParameter("proId5"));
+        Integer proId6 = request.getParameter("proId6") == null ? 0 : Integer.parseInt(request.getParameter("proId6"));
+        Integer proId7 = request.getParameter("proId7") == null ? 0 : Integer.parseInt(request.getParameter("proId7"));
+        Integer proId8 = request.getParameter("proId8") == null ? 0 : Integer.parseInt(request.getParameter("proId8"));
+        Integer proId9 = request.getParameter("proId9") == null ? 0 : Integer.parseInt(request.getParameter("proId9"));
+        Integer proId10 = request.getParameter("proId10") == null ? 0 : Integer.parseInt(request.getParameter("proId10"));
+        String broadcastId = request.getParameter("broadcastId");
+        Integer playType = request.getParameter("playType") == null ? 0 : Integer.parseInt(request.getParameter("playType"));
+        Integer type = request.getParameter("type") == null ? 0 : Integer.parseInt(request.getParameter("type"));;
+
+        ArrayList<BroadcastItemVO> prist = null;
+        if (proType != 0){
+            Object arrayParam = this.getArrayParam(request);
+            if (arrayParam instanceof String){
+                return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
+            }else {
+                prist =  (ArrayList<BroadcastItemVO>)arrayParam;
             }
-        } else { // 策略节目
-            Integer policyType = broadcastItemDTO.getPolicyType();
-            List<BroadcastContentDTO> proList = detailsVO.getProList();
-            if (policyType == null || proList.size() == 0)
-                return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
-            List<BroadcastPolicyInfoDTO> contentList = new ArrayList<>();
-            for (BroadcastContentDTO b : proList) {
-                BroadcastPolicyInfoDTO policyInfoDTO = new BroadcastPolicyInfoDTO();
-                String startDate = b.getBeginDate();
-                policyInfoDTO.setBeginDate(startDate);
-                List<BroadcastPolicyInfoDTO> proTimeList = b.getProTimeList();
-                if (proTimeList == null || proTimeList.size() == 0)
-                    return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
-                for (BroadcastPolicyInfoDTO dto : proTimeList) {
-                    String beginTime = dto.getBeginTime();
-                    Integer time = dto.getTime();
-                    Integer vol = dto.getVol();
-                    Integer type = dto.getPlayType();
-                    if (beginTime == null || beginTime.length() == 0)
-                        return toolUtils.response(InterfaceResultEnum.LACK_START_TIME_ERROR,version);
-                    if (time == null || time == 0)
-                        return toolUtils.response(InterfaceResultEnum.LACK_PROGRAM_TIME_ERROR,version);
-                    if (vol == null || vol == 0)
-                        return toolUtils.response(InterfaceResultEnum.LACK_VOL_ERROR,version);
-                    if (type == null)
-                        return toolUtils.response(InterfaceResultEnum.LACK_PLAY_TYPE_ERROR,version);
-                    BeanUtils.copyProperties(dto,policyInfoDTO);
-                    contentList.add(policyInfoDTO);
-                }
+        }
+
+        if (broadcastId == null || broadcastId.equals("")) return toolUtils.response(InterfaceResultEnum.LACK_DEVICE_ERROR,version);
+        if (name == null || name.equals("")) return toolUtils.response(InterfaceResultEnum.LACK_PROGRESS_NAME_ERROR,version);
+        if (proType == 0 &&  proId1 == 0 && proId2 == 0 && proId3 == 0 && proId4 == 0 && proId5 == 0 && proId6 == 0 && proId7 == 0
+                && proId8 == 0 && proId9 == 0 && proId10 == 0
+        )return toolUtils.response(InterfaceResultEnum.LACK_MUSIC_ERROR,version);
+
+        Integer[] pros = {proId1,proId2,proId3,proId4,proId5,proId6,proId7,proId8,proId9,proId10};
+        List<Integer> proL = Arrays.asList(pros);
+
+        // 世邦设备
+        List<Integer> dev1 = new ArrayList<>();
+
+        // 先科设备
+        List<BroadcastDTO> dev2 = new ArrayList<>();
+
+        // 威尔西
+        List<BroadcastDTO> dev3 = new ArrayList<>();
+
+        // sip
+        List<BroadcastDTO> dev5 = new ArrayList<>();
+
+        BroadcastDTO dto = new BroadcastDTO();
+        String[] split = broadcastId.split(",");
+        List<String> broadcastIdList = Arrays.asList(split);
+        dto.setIdList(broadcastIdList);
+        List<BroadcastDTO> devList = broadcastService.getList(dto);
+        int lampPoleId = 0;
+        for (BroadcastDTO item:devList) {
+            if (item.getType() == 1){
+                dev1.add(item.getDevId());
+                lampPoleId = item.getLampPoleId();
+            } else if (item.getType() == 2) {
+                dev2.add(item);
+            } else if (item.getType() == 3) {
+                dev3.add(item);
+            } else if (item.getType() == 5) {
+                dev5.add(item);
+            }
+        }
+        BroadcastProListDTO proListDTO = new BroadcastProListDTO();
+        proListDTO.setIdList(proL);
+        List<BroadcastProListDTO> proList = broadcastProListService.getList(proListDTO);
+        HashMap<Integer, BroadcastProListDTO> temp = new HashMap<>();
+        HashMap<Integer, String> weierxiFileList = new HashMap<>();
+        for (BroadcastProListDTO item : proList) {
+            String xiankeName = item.getXianKeName();
+            String prefix = xiankeName.substring(0, xiankeName.length() - 6);
+            String suffix = xiankeName.substring(xiankeName.length() - 4);
+            String result = prefix + suffix;
+            item.setXianKeName(result);
+            temp.put(item.getId(),item);
+            weierxiFileList.put(item.getId(),item.getWeierxiId());
+        }
+        ArrayList<String> temp2 = new ArrayList<>();
+        for (Integer item : proL) {
+            if (item != 0 && temp.get(item) != null && temp.get(item).getShiBangName() != null){
+                temp2.add(temp.get(item).getShiBangName());
+            }
+        }
+        int proTime = 0;
+        if (playType == 1){
+            proTime = 999999;
+        }
+
+        String task = "3*"+proTime+"*0*0*"+String.join("<",temp2)+"*"+String.join((CharSequence) "<", (CharSequence) dev1)+"*0*1*0*0*";
+        toolUtils.setLog("item_save.txt",task);
+        if (playType == 2){
+            task = task + "1";
+        }else {
+            task = task + "0";
+        }
+        long l = System.currentTimeMillis();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long time = simpleDateFormat.parse("2015-1-1 00:00:00").getTime();
+        long xiankeId = (l - time) / 1000;
+        JSONObject xiankeProData = new JSONObject();
+        if (dev2.size() > 0){
+            ArrayList<String> addressList = new ArrayList<>();
+            ArrayList<Integer> idList = new ArrayList<>();
+            ArrayList<String> nameList = new ArrayList<>();
+            for (BroadcastDTO item : dev2) {
+                addressList.add(item.getAddress());
+                idList.add(item.getDevId());
+            }
+            for (BroadcastProListDTO item : proList) {
+                nameList.add(item.getXianKeName());
+            }
+            String deviceName = String.join(";",addressList) + ";";
+            String deviceId = String.join(" ", (CharSequence) idList) + " ";
+            String musicName = String.join(":",nameList) + ":";
+            int playMode = 5;
+            if (playType == 0){
+                playMode = 1;
+            }else if(playType == 1){
+                playMode = 4;
             }
-            if (id == 0) {
-                long l = System.currentTimeMillis();
-                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                String format = simpleDateFormat.format(l);
-                broadcastItemDTO.setCreateTime(format);
+            JSONArray objects = new JSONArray();
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("StartTime",l / 1000);
+            jsonObject.put("UserName","admin");
+            jsonObject.put("ID",xiankeId);
+            jsonObject.put("UserID","10000000");
+            jsonObject.put("Oparetion_name",String.valueOf(l / 1000) + "admin");
+            jsonObject.put("Result","下发");
+            jsonObject.put("Device_name",deviceName);
+            jsonObject.put("SelectId",deviceId);
+            jsonObject.put("VolValues",200);
+            jsonObject.put("Priority","16");
+            jsonObject.put("MusicID","0");
+            jsonObject.put("MusicName",musicName);
+            jsonObject.put("PlayMode",playMode);
+            jsonObject.put("Config",2);
+            objects.add(jsonObject);
+            //objects.add(null);
+
+
+            xiankeProData.put("UserID",10000000);
+            xiankeProData.put("PlanState",0);
+            xiankeProData.put("MediaPlanID",xiankeId);
+            xiankeProData.put("DeviceName",deviceName);
+            xiankeProData.put("DeviceID",deviceId);
+            xiankeProData.put("MusicName",musicName);
+            xiankeProData.put("MusicID",0);
+            xiankeProData.put("VolValue","200");
+            xiankeProData.put("PlayMode",playMode);
+            xiankeProData.put("PlayType",16);
+            xiankeProData.put("PlayRoad",1);
+            xiankeProData.put("PlayJsonData",objects);
+        }
+        UserDTO user = toolUtils.getUser(request);
+        if (id == 0){
+            BroadcastItemVO broadcastItemVO = new BroadcastItemVO();
+            broadcastItemVO.setUserId(user.getId());
+            broadcastItemVO.setName(name);
+            Integer total = broadcastItemService.getBroadcastItemTotalByItemVO(broadcastItemVO);
+            if (total != null && total > 0) toolUtils.response(InterfaceResultEnum.PROGRAM_NAME_EXIST_ERROR,version);
+            if (proType == 0){// 普通节目
+                BroadcastItemDTO broadcastItemDTO = new BroadcastItemDTO();
+                broadcastItemDTO.setName(name);
+                broadcastItemDTO.setProType(proType);
+                broadcastItemDTO.setProId1(proId1);
+                broadcastItemDTO.setProId2(proId2);
+                broadcastItemDTO.setProId3(proId3);
+                broadcastItemDTO.setProId4(proId4);
+                broadcastItemDTO.setProId5(proId5);
+                broadcastItemDTO.setProId6(proId6);
+                broadcastItemDTO.setProId7(proId7);
+                broadcastItemDTO.setProId8(proId8);
+                broadcastItemDTO.setProId9(proId9);
+                broadcastItemDTO.setProId10(proId10);
+                broadcastItemDTO.setBroadcastId(broadcastId);
+                broadcastItemDTO.setUserId(user.getId());
+                broadcastItemDTO.setPlayType(playType);
+                broadcastItemDTO.setCreateTime(simpleDateFormat.format(new Date()));
                 broadcastItemService.addCommonProgramData(broadcastItemDTO);
-                Integer broadcastItemId = broadcastItemDTO.getId();
-                contentList.forEach(dto -> dto.setBroadcastPolicyId(broadcastItemId));
-                for (BroadcastPolicyInfoDTO b : contentList) {
-                    broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
+                if (dev1.size() > 0 && this.shibangOpen == 1){
+                    LampPoleDTO lampPoleDTO = new LampPoleDTO();
+                    lampPoleDTO.setId(lampPoleId);
+                    LampPoleDTO simpleOne = lampPoleService.getSimpleOne(lampPoleDTO);
+                    if(simpleOne.getSectionId().equals(1292)){
+                        String sendUrl = this.xinchang_shibang_url + "/php/exesdkcommand.php";
+                        String data = "jsondata[taskname]="+broadcastItemDTO.getId()+"&jsondata[isdisable]=0"+"&jsondata[level]=10&jsondata[triggers]=''"+"&jsondata[commands]="+task;
+                        String res = toolUtils.sendHttp("post", sendUrl, data, 10, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
+                        if (res != null && !res.equals("")){
+                            toolUtils.setLog("item_save.txt",res);
+                            //TODO
+                        }
+                    }else {
+                        String sendUrl = this.shibang_url + "/php/exesdkcommand.php";
+                        String data = "jsondata[taskname]="+broadcastItemDTO.getId()+"&jsondata[isdisable]=0"+"&jsondata[level]=10&jsondata[triggers]=''"+"&jsondata[commands]="+task;
+                        String res = toolUtils.sendHttp("post", sendUrl, data, 10, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
+                        if (res != null && !res.equals("")){
+                            toolUtils.setLog("item_save.txt",res);
+                            System.out.println(res);
+                            //TODO - 更新BroadcastItem
+                        }
+                    }
+                }
+
+                if (dev2.size() > 0){
+                    String url = this.shibang_url + "/php/addtaskinfo.php";
+                    String sendData = "UserID="+xiankeProData.get("UserID")+"&PlanState="+xiankeProData.get("PlanState")+"&MediaPlanID="+xiankeProData.get("MediaPlanID")+"&DeviceName="+xiankeProData.get("DeviceName")+
+                            "&DeviceID="+xiankeProData.get("DeviceID")+"&MusicName="+xiankeProData.get("MusicName")+"&MusicID="+xiankeProData.get("MusicID")+"&VolValue="+xiankeProData.get("VolValue")+
+                            "&PlayMode="+xiankeProData.get("PlayMode")+"&PlayType="+xiankeProData.get("PlayType")+"&PlayRoad="+xiankeProData.get("PlayRoad")+"&PlayJsonData="+xiankeProData.get("PlayJsonData").toString();
+                    String res = toolUtils.sendHttp("post", url, sendData, 10, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
+                    //TODO - 更新BroadcastItem
+                    System.out.println(res);
+                }
+                if (dev3.size() > 0){
+                    ArrayList<String> fileList = new ArrayList<>();
+                    ArrayList<String> weiDevList = new ArrayList<>();
+                    for (BroadcastDTO broadcastDTO:dev3) {
+                        weiDevList.add(broadcastDTO.getAddress());
+                    }
+                    Class<? extends BroadcastItemDTO> clazz = broadcastItemDTO.getClass();
+                    for (int i = 0; i <= 10; i++){
+                        try {
+                            // 动态创建字段名
+                            String index = String.valueOf(i);
+                            String fieldName = "proId" + index;
+                            // 获取字段
+                            Field field = clazz.getDeclaredField(fieldName);
+                            // 设置字段可访问,忽略访问权限
+                            field.setAccessible(true);
+                            if (field.get(broadcastItemDTO) != null){
+                                Integer in = (Integer)field.get(broadcastItemDTO);
+                                if (in != null && weierxiFileList.get(in) != null){
+                                    fileList.add(weierxiFileList.get(in));
+                                }
+                            }
+                        } catch (NoSuchFieldException | IllegalAccessException e) {
+                            e.printStackTrace();
+                        }
+                    }
+                    //TODO - 这个方法还没有完善测试的
+                    String proId = this.saveWeierxiPro(fileList, weiDevList, playType, null);
+                    if (!proId.equals("")){
+                        BroadcastItemDTO item = new BroadcastItemDTO();
+                        item.setId(broadcastItemDTO.getId());
+                        broadcastItemService.updateCommonProgramData(item);
+                    }
                 }
-            } else {
-                broadcastItemService.updateCommonProgramData(broadcastItemDTO);
-                contentList.forEach(dto -> dto.setBroadcastPolicyId(id));
-                broadcastPolicyInfoService.deleteBroadcastPolicyInfoData(id);
-                for (BroadcastPolicyInfoDTO b : contentList) {
-                    broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
+                if (dev5.size() > 0){
+                    String uid = UUID.randomUUID().toString();
+                    String url = "http://120.24.241.39/control/20210909/validateListNameRepeat.json";
+                    JSONObject data2 = new JSONObject();
+                    data2.put("list_name",uid);
+                    data2.put("id","");
+                    String res = toolUtils.sendHttp("post", url, data2.toString(), "weclouds:weclouds@1234", null, 10, "base64", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+                    String agentright = "";
+                    int i = 0;
+                    for (BroadcastProListDTO pro : proList) {
+                        List<String> urlList = Arrays.asList(pro.getUrl().split("/"));
+                        String fileName = urlList.get(urlList.size()-1);
+                        String name1 = Arrays.asList(fileName.split(".")).get(0);
+                        agentright += name1 + "--" + pro.getSipId() + "--" + String.valueOf(i) + "1,";
+                    }
+                    url = "http://120.24.241.39/control/AddMusicServlet";
+                    String data = "list_name="+uid+"&descr=''"+"&dept_id=0"+"&agentright="+agentright;
+                    String s = toolUtils.sendHttp("post", url, data, 10, ToolUtils.ContentTypeEnum.CONTENT_TYPE_FORM, null);
+
+                    url = "http://120.24.241.39/control/20180628/infs/getPlayList.json";
+                    JSONObject object = new JSONObject();
+                    String respone = toolUtils.sendHttp("get", url, object.toString(), "weclouds:weclouds@1234", null, 10, "base64", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+                    int sipId = 0;
+                    if (respone != null){
+                        JSONObject jsonObject = JSONObject.parseObject(respone);
+                        JSONArray arr = jsonObject.getJSONArray("data");
+                        for (Object o : arr) {
+                            JSONObject value = (JSONObject) o;
+                            if (value.get("play_name").equals(uid)){
+                                sipId = value.getInteger("id");
+                            }
+                        }
+                    }
+                    String valuedId = String.valueOf(broadcastItemDTO.getId());
+                    name = "pro" + valuedId;
+                    if (sipId > 0){
+                        int playingMode = 0;
+                        if (playType == 0){
+                            playingMode = 1;
+                        } else if (playType == 2) {
+                            playingMode = 2;
+                        }else {
+                            playingMode = 3;
+                        }
+
+                        List<String> partIdList = new ArrayList<>();
+                        for (BroadcastDTO item : dev5) {
+                            partIdList.add(item.getAddress());
+                        }
+                        String partId = String.join(",", partIdList);
+                        JSONObject dataJson = new JSONObject();
+                        dataJson.put("access_num","");
+                        dataJson.put("access_num_pw","");
+                        dataJson.put("prompt_tone","1");
+                        dataJson.put("play_list_id",sipId);
+                        dataJson.put("priority","4");
+                        dataJson.put("capture_dev","");
+                        dataJson.put("volume","0");
+                        dataJson.put("play_times","1");
+                        dataJson.put("text_content","");
+                        dataJson.put("text_file","");
+                        dataJson.put("play_type","0");
+                        dataJson.put("name",name);
+                        dataJson.put("type","2");
+                        dataJson.put("timetype","0");
+                        dataJson.put("playing_mode",playingMode);
+                        dataJson.put("status","0");
+                        dataJson.put("playing_time","2018/7/5 14:27:33");
+                        dataJson.put("lasting_time","0");
+                        dataJson.put("part_type","2");
+                        dataJson.put("part_id",partId);
+                        dataJson.put("sys_user_id","weclouds");
+                        dataJson.put("broadcast_time",new ArrayList<Object>());
+                        url = "http://120.24.241.39/control/20180628/infs/addBroadTask.json";
+                        String resp = toolUtils.sendHttp("post", url, dataJson.toString(), "weclouds:weclouds@1234", null, 10, "base64", ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+                        sipId = 0;
+                        if (resp != null){
+                            // TODO - 这里要设备测试
+                            JSONObject jsonObject = JSONObject.parseObject(resp);
+                            Object statuscode = jsonObject.get("statuscode");
+                            Integer id1 = jsonObject.getInteger("id");
+                            String statuscode1 = jsonObject.getString("statuscode");
+                            if (statuscode != null && id1 != null && statuscode1.equals("000000")){
+                                sipId = id1;
+                            }
+                            BroadcastItemDTO itemDTO = new BroadcastItemDTO();
+                            itemDTO.setId(broadcastItemDTO.getId());
+                            itemDTO.setSipId(sipId);
+                            broadcastItemService.updateCommonProgramData(itemDTO);
+                        }
+                    }
                 }
+            }else { //策略节目
+                BroadcastItemDTO itemDTO = new BroadcastItemDTO();
+                itemDTO.setName(name);
+                itemDTO.setProType(proType);
+                itemDTO.setUserId(user.getId());
+                itemDTO.setBroadcastId(broadcastId);
+                itemDTO.setPolicyType(type);
+                itemDTO.setCreateTime(simpleDateFormat.format(new Date()));
+                broadcastItemService.addCommonProgramData(itemDTO);
+                //TODO
             }
+        }else {
+            //编辑
+
         }
-        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
+return null;
+
+
+        //long xianke_id =  time() - strtotime('2015-1-1 00:00:00');
+
+//        if (proType == 0) { // 普通节目
+//            if (id == 0) {
+//                long l = System.currentTimeMillis();
+//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//                String format = simpleDateFormat.format(l);
+//                broadcastItemDTO.setCreateTime(format);
+//                broadcastItemService.addCommonProgramData(broadcastItemDTO);
+//            } else {
+//                broadcastItemService.updateCommonProgramData(broadcastItemDTO);
+//            }
+//        } else { // 策略节目
+//            Integer policyType = broadcastItemDTO.getPolicyType();
+//            List<BroadcastContentDTO> proList = detailsVO.getProList();
+//            if (policyType == null || proList.size() == 0)
+//                return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
+//            List<BroadcastPolicyInfoDTO> contentList = new ArrayList<>();
+//            for (BroadcastContentDTO b : proList) {
+//                BroadcastPolicyInfoDTO policyInfoDTO = new BroadcastPolicyInfoDTO();
+//                String startDate = b.getBeginDate();
+//                policyInfoDTO.setBeginDate(startDate);
+//                List<BroadcastPolicyInfoDTO> proTimeList = b.getProTimeList();
+//                if (proTimeList == null || proTimeList.size() == 0)
+//                    return toolUtils.response(InterfaceResultEnum.LACK_NEED_PARAM,version);
+//                for (BroadcastPolicyInfoDTO dto : proTimeList) {
+//                    String beginTime = dto.getBeginTime();
+//                    Integer time = dto.getTime();
+//                    Integer vol = dto.getVol();
+//                    Integer type = dto.getPlayType();
+//                    if (beginTime == null || beginTime.length() == 0)
+//                        return toolUtils.response(InterfaceResultEnum.LACK_START_TIME_ERROR,version);
+//                    if (time == null || time == 0)
+//                        return toolUtils.response(InterfaceResultEnum.LACK_PROGRAM_TIME_ERROR,version);
+//                    if (vol == null || vol == 0)
+//                        return toolUtils.response(InterfaceResultEnum.LACK_VOL_ERROR,version);
+//                    if (type == null)
+//                        return toolUtils.response(InterfaceResultEnum.LACK_PLAY_TYPE_ERROR,version);
+//                    BeanUtils.copyProperties(dto,policyInfoDTO);
+//                    contentList.add(policyInfoDTO);
+//                }
+//            }
+//            if (id == 0) {
+//                long l = System.currentTimeMillis();
+//                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//                String format = simpleDateFormat.format(l);
+//                broadcastItemDTO.setCreateTime(format);
+//                broadcastItemService.addCommonProgramData(broadcastItemDTO);
+//                Integer broadcastItemId = broadcastItemDTO.getId();
+//                contentList.forEach(dto -> dto.setBroadcastPolicyId(broadcastItemId));
+//                for (BroadcastPolicyInfoDTO b : contentList) {
+//                    broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
+//                }
+//            } else {
+//                broadcastItemService.updateCommonProgramData(broadcastItemDTO);
+//                contentList.forEach(dto -> dto.setBroadcastPolicyId(id));
+//                broadcastPolicyInfoService.deleteBroadcastPolicyInfoData(id);
+//                for (BroadcastPolicyInfoDTO b : contentList) {
+//                    broadcastPolicyInfoService.addBroadcastPolicyInfoData(b);
+//                }
+//            }
+//        }
+//        return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version);
     }
+    // 即时节目
+    private String saveWeierxiPro(List<String> srcsInfo,List<String> dstsUsrGuids,Integer playType,Integer proId) throws IOException {
+        if (proId == null) {
+            String proName = UUID.randomUUID().toString();
+            String url = "http://120.24.31.58:23412/api/login";
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("usrPwd","admin");
+            jsonObject.put("usrName","admin");
+            String token = toolUtils.sendHttp("post", url, jsonObject.toString(), 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+            int flagRandom = 1; // 随机播放
+            if (playType == 0){ //顺序播放
+                flagRandom = 0;
+            }else if(playType == 1){ //循环播放
+                flagRandom = 3;
+            }
+            String sendUrl = "http://120.24.31.58:23412/api/addManualTsk";
+            JSONObject sendData = new JSONObject();
+            sendData.put("token",token);
+           JSONObject tskInfo =  new JSONObject();
+            tskInfo.put("tskName",proName);
+            tskInfo.put("srcType",1);
+            tskInfo.put("flagRandom",flagRandom);
+            tskInfo.put("playVolumn",-1);
+            tskInfo.put("dstsUsrGuids",dstsUsrGuids);
+            tskInfo.put("srcsInfo",srcsInfo);
+            sendData.put("tskInfo",tskInfo);
 
-    /**
-     * 删除节目
-     * @param vo id
-     * @return 删除节目
-     */
+            String res = toolUtils.sendHttp("post", sendUrl, sendData.toString(), 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+            // TODO - 获取tskGuid的值
+            System.out.println(res);
+            return "";
+        }else {
+            String url = "http://120.24.31.58:23412/api/login";
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("usrPwd","admin");
+            jsonObject.put("usrName","admin");
+            String token = toolUtils.sendHttp("post", url, jsonObject.toString(), 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+            int flagRandom = 1; // 随机播放
+            if (playType == 0){ //顺序播放
+                flagRandom = 0;
+            }else if(playType == 1){ //循环播放
+                flagRandom = 3;
+            }
+            url = "http://120.24.31.58:23412/api/editManualTsk";
+            JSONObject data = new JSONObject();
+            data.put("toke",token);
+            data.put("tskGuid",proId);
+            JSONObject tskInfo =  new JSONObject();
+            tskInfo.put("srcType",1);
+            tskInfo.put("flagRandom",flagRandom);
+            tskInfo.put("dstsUsrGuids",dstsUsrGuids);
+            tskInfo.put("srcsInfo",srcsInfo);
+            data.put("tskInfo",tskInfo);
+            String res = toolUtils.sendHttp("post", url, data.toString(), 5, ToolUtils.ContentTypeEnum.CONTENT_TYPE_JSON, null);
+            if (res != null){
+                JSONObject jsonObject1 = JSONObject.parseObject(res);
+                if (jsonObject1.getInteger("Code") == 1){
+                    return String.valueOf(proId);
+                }
+            }
+            return "";
+        }
+    }
+            /**
+             * 删除节目
+             * @param vo id
+             * @return 删除节目
+             */
     @RequestMapping(value = "/itemDel", method = RequestMethod.POST)
     public BaseResult<?> itemDel(BroadcastDetailsVO vo) {
         BroadcastDetailsVO detailsVO = BroadcastDetailsVO.getBroadcastDetailsVO(vo);

+ 1 - 5
src/main/java/com/welampiot/controller/LampController.java

@@ -137,11 +137,7 @@ public class LampController {
         LampInfoDTO detailsById = lampService.getDetailsById(lampId,version);
         return BaseResult.success(detailsById);
     }
-    @RequestMapping(value = "/getkk", method = RequestMethod.POST)
-    public Integer kk(HttpServletRequest request) {
-        toolUtils.addOpertaionLog(request,null,null,null,null,null,null,null,null,null,null,null,null,null);
-        return 0;
-    }
+
     /**
      * 添加编辑灯控
      * @param request

+ 2 - 0
src/main/java/com/welampiot/dao/BroadcastDao.java

@@ -44,4 +44,6 @@ public interface BroadcastDao {
     List<BroadcastDTO> getListByIds(@Param("ids")String ids);
     BroadcastDTO getOneDataByLampPoleId(Integer lampPoleId);
     BroadcastDTO getData(Integer lampPoleId);
+    Integer getCount(BroadcastDTO dto);
+    List<BroadcastDTO> getList(BroadcastDTO dto);
 }

+ 1 - 0
src/main/java/com/welampiot/dao/BroadcastItemDao.java

@@ -28,4 +28,5 @@ public interface BroadcastItemDao {
 
     Integer getBroadcastItemTotalByItemVO(BroadcastItemVO vo);
     BroadcastItemDTO getOneDataById(Integer id);
+    List<BroadcastItemDTO> getList(BroadcastItemDTO dto);
 }

+ 3 - 0
src/main/java/com/welampiot/dao/BroadcastProListDao.java

@@ -3,8 +3,11 @@ package com.welampiot.dao;
 import com.welampiot.dto.BroadcastProListDTO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 public interface BroadcastProListDao {
     BroadcastProListDTO getOneById(@Param("id")int id);
     void addBroadcastMusic(BroadcastProListDTO dto);
     void deleteBroadcastProListDate(@Param("id") Integer id);
+    List<BroadcastProListDTO> getList(BroadcastProListDTO dto);
 }

+ 2 - 0
src/main/java/com/welampiot/dto/BroadcastDTO.java

@@ -82,4 +82,6 @@ public class BroadcastDTO implements Serializable {
 
     private static final long serialVersionUID = 1L;
     private String itemName;
+    private Integer areaId;
+    private List<?> idList;
 }

+ 5 - 0
src/main/java/com/welampiot/dto/BroadcastItemDTO.java

@@ -100,4 +100,9 @@ public class BroadcastItemDTO implements Serializable {
     private String broadcastStr;
 
     private static final long serialVersionUID = 1L;
+    private String proStr;
+    private Integer sipId;
+    private String beginTime;
+    private String time;
+    private Integer vol;
 }

+ 5 - 1
src/main/java/com/welampiot/dto/BroadcastProListDTO.java

@@ -3,6 +3,7 @@ package com.welampiot.dto;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.List;
 
 /**
  * ClassName: BroadcastProListDTO
@@ -45,7 +46,10 @@ public class BroadcastProListDTO implements Serializable {
     private String xinChangShiBangUrl;
 
     /** 威尔西设备素材id **/
-    private Integer weiErXiId;
+    //private Integer weiErXiId;
+    private String weierxiId;
 
     private static final long serialVersionUID = 1L;
+    private List<?> idList;
+    private Integer sipId;
 }

+ 1 - 0
src/main/java/com/welampiot/service/BroadcastItemService.java

@@ -28,4 +28,5 @@ public interface BroadcastItemService {
 
     Integer getBroadcastItemTotalByItemVO(BroadcastItemVO vo);
     BroadcastItemDTO getOneDataById(Integer id);
+    List<BroadcastItemDTO> getList(BroadcastItemDTO dto);
 }

+ 3 - 0
src/main/java/com/welampiot/service/BroadcastProListService.java

@@ -2,8 +2,11 @@ package com.welampiot.service;
 
 import com.welampiot.dto.BroadcastProListDTO;
 
+import java.util.List;
+
 public interface BroadcastProListService {
     BroadcastProListDTO getOneById(int id);
     void addBroadcastMusic(BroadcastProListDTO dto);
     void deleteBroadcastProListDate(Integer id);
+    List<BroadcastProListDTO> getList(BroadcastProListDTO dto);
 }

+ 3 - 2
src/main/java/com/welampiot/service/BroadcastService.java

@@ -3,7 +3,6 @@ package com.welampiot.service;
 import com.welampiot.dto.BroadcastDTO;
 import com.welampiot.vo.BroadcastItemVO;
 import com.welampiot.vo.BroadcastProListVO;
-import com.welampiot.vo.BroadcastVO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -18,7 +17,7 @@ import java.util.List;
  * @Version: v1.0
  */
 public interface BroadcastService {
-    BroadcastVO getDevListByBroadcastDTO(BroadcastDTO dto);
+    List<BroadcastDTO>  getDevListByBroadcastDTO(BroadcastDTO dto);
 
     BroadcastProListVO getProListByDTO(String username);
 
@@ -40,4 +39,6 @@ public interface BroadcastService {
     Integer getTotalBySectionList(BroadcastDTO dto);
     BroadcastDTO getOneDataByLampPoleId(Integer lampPoleId);
     BroadcastDTO getData(Integer lampPoleId);
+    Integer getCount(BroadcastDTO dto);
+    List<BroadcastDTO> getList(BroadcastDTO dto);
 }

+ 4 - 0
src/main/java/com/welampiot/service/impl/BroadcastItemServiceImpl.java

@@ -56,4 +56,8 @@ public class BroadcastItemServiceImpl implements BroadcastItemService {
     public BroadcastItemDTO getOneDataById(Integer id){
         return broadcastItemDao.getOneDataById(id);
     }
+    @Override
+    public List<BroadcastItemDTO> getList(BroadcastItemDTO dto){
+        return broadcastItemDao.getList(dto);
+    }
 }

+ 6 - 0
src/main/java/com/welampiot/service/impl/BroadcastProListServiceImpl.java

@@ -6,6 +6,8 @@ import com.welampiot.service.BroadcastProListService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class BroadcastProListServiceImpl implements BroadcastProListService {
     @Autowired
@@ -25,4 +27,8 @@ public class BroadcastProListServiceImpl implements BroadcastProListService {
     public void deleteBroadcastProListDate(Integer id) {
         broadcastProListDao.deleteBroadcastProListDate(id);
     }
+    @Override
+    public List<BroadcastProListDTO> getList(BroadcastProListDTO dto){
+        return broadcastProListDao.getList(dto);
+    }
 }

+ 60 - 52
src/main/java/com/welampiot/service/impl/BroadcastServiceImpl.java

@@ -7,7 +7,6 @@ import com.welampiot.dto.BroadcastProListDTO;
 import com.welampiot.service.BroadcastService;
 import com.welampiot.vo.BroadcastItemVO;
 import com.welampiot.vo.BroadcastProListVO;
-import com.welampiot.vo.BroadcastVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -31,57 +30,58 @@ public class BroadcastServiceImpl implements BroadcastService {
     private BroadcastDao broadcastDao;
 
     @Override
-    public BroadcastVO getDevListByBroadcastDTO(BroadcastDTO dto) {
-        BroadcastVO vo = new BroadcastVO();
-        vo.setTotal(broadcastDao.getTotalBySectionList(dto));
-        vo.setOnlineTotal(broadcastDao.getOnlineTotalBySectionList(dto));
-        List<BroadcastDTO> devList = broadcastDao.getDevListByBroadcastDTO(dto);
-        List<BroadcastDTO> list = new ArrayList<>();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        devList.forEach(broadcastDTO ->{
-            if (broadcastDTO.getOnline() != null && broadcastDTO.getOnline() == 1){
-                broadcastDTO.setOnline(1);
-            }else {
-                broadcastDTO.setOnline(0);
-            }
-            if (broadcastDTO.getProName() == null){
-                broadcastDTO.setProName("");
-            }
-            if (broadcastDTO.getLampPoleName() == null){
-                broadcastDTO.setLampPoleName("");
-            }
-            if (broadcastDTO.getType() != null && broadcastDTO.getType() == 1){
-                broadcastDTO.setType(1);
-            }else {
-                broadcastDTO.setType(0);
-            }
-            if (broadcastDTO.getIsPlay() != null && broadcastDTO.getIsPlay() == 1){
-                broadcastDTO.setIsPlay(1);
-            }else {
-                broadcastDTO.setIsPlay(0);
-            }
-            if (broadcastDTO.getInstallDate() != null && !broadcastDTO.getInstallDate().equals("")){
-                try {
-                    broadcastDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getInstallDate())));
-                } catch (ParseException e) {
-                    throw new RuntimeException(e);
-                }
-            }else {
-                broadcastDTO.setInstallDate("");
-            }
-            if (broadcastDTO.getExpirationDate() != null && !broadcastDTO.getExpirationDate().equals("")){
-                try {
-                    broadcastDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getExpirationDate())));
-                } catch (ParseException e) {
-                    throw new RuntimeException(e);
-                }
-            }else {
-                broadcastDTO.setExpirationDate("");
-            }
-            list.add(broadcastDTO);
-        });
-        vo.setList(list);
-        return vo;
+    public List<BroadcastDTO> getDevListByBroadcastDTO(BroadcastDTO dto) {
+        return broadcastDao.getDevListByBroadcastDTO(dto);
+//        BroadcastVO vo = new BroadcastVO();
+//        vo.setTotal(broadcastDao.getTotalBySectionList(dto));
+//        vo.setOnlineTotal(broadcastDao.getOnlineTotalBySectionList(dto));
+//        List<BroadcastDTO> devList = broadcastDao.getDevListByBroadcastDTO(dto);
+//        List<BroadcastDTO> list = new ArrayList<>();
+//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+//        devList.forEach(broadcastDTO ->{
+//            if (broadcastDTO.getOnline() != null && broadcastDTO.getOnline() == 1){
+//                broadcastDTO.setOnline(1);
+//            }else {
+//                broadcastDTO.setOnline(0);
+//            }
+//            if (broadcastDTO.getProName() == null){
+//                broadcastDTO.setProName("");
+//            }
+//            if (broadcastDTO.getLampPoleName() == null){
+//                broadcastDTO.setLampPoleName("");
+//            }
+//            if (broadcastDTO.getType() != null && broadcastDTO.getType() == 1){
+//                broadcastDTO.setType(1);
+//            }else {
+//                broadcastDTO.setType(0);
+//            }
+//            if (broadcastDTO.getIsPlay() != null && broadcastDTO.getIsPlay() == 1){
+//                broadcastDTO.setIsPlay(1);
+//            }else {
+//                broadcastDTO.setIsPlay(0);
+//            }
+//            if (broadcastDTO.getInstallDate() != null && !broadcastDTO.getInstallDate().equals("")){
+//                try {
+//                    broadcastDTO.setInstallDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getInstallDate())));
+//                } catch (ParseException e) {
+//                    throw new RuntimeException(e);
+//                }
+//            }else {
+//                broadcastDTO.setInstallDate("");
+//            }
+//            if (broadcastDTO.getExpirationDate() != null && !broadcastDTO.getExpirationDate().equals("")){
+//                try {
+//                    broadcastDTO.setExpirationDate(simpleDateFormat.format(simpleDateFormat.parse(broadcastDTO.getExpirationDate())));
+//                } catch (ParseException e) {
+//                    throw new RuntimeException(e);
+//                }
+//            }else {
+//                broadcastDTO.setExpirationDate("");
+//            }
+//            list.add(broadcastDTO);
+//        });
+//        vo.setList(list);
+//        return vo;
     }
 
     @Override
@@ -181,4 +181,12 @@ public class BroadcastServiceImpl implements BroadcastService {
     public BroadcastDTO getData(Integer lampPoleId){
         return broadcastDao.getData(lampPoleId);
     }
+    @Override
+    public Integer getCount(BroadcastDTO dto){
+        return broadcastDao.getCount(dto);
+    }
+    @Override
+    public List<BroadcastDTO> getList(BroadcastDTO dto){
+        return broadcastDao.getList(dto);
+    }
 }

+ 5 - 2
src/main/java/com/welampiot/utils/ToolUtils.java

@@ -1162,7 +1162,7 @@ System.out.println(res);
      *  @param token:令牌
      *  @param sessionId:会话id
      *  @param timeOut:超时
-     *  @param mark:标记Authorization是传哪种方式
+     *  @param mark:标记Authorization是传哪种方式,想要时,可以修改增加
      * @param typeEnum: 编码类型
      * @return 返回类型字符串
      */
@@ -1194,7 +1194,10 @@ System.out.println(res);
             connection.setRequestProperty("Authorization","Bearer "+token);
         }else if(mark != null && mark.equals("api-key")) {
             connection.setRequestProperty("api-key"," "+token);
-        }else {
+        } else if (mark != null && mark.equals("base64")) {
+            connection.setRequestProperty("Content-Length: ",String.valueOf(param.length()));
+            connection.setRequestProperty("Authorization",Base64.getEncoder().encodeToString(token.getBytes()));
+        } else {
             connection.setRequestProperty("Authorization",token);
         }
         if (cookie != null){

+ 4 - 0
src/main/java/com/welampiot/vo/BroadcastItemVO.java

@@ -36,6 +36,10 @@ public class BroadcastItemVO implements Serializable {
     private List<BroadcastItemDTO> list;
 
     private static final long serialVersionUID = 1L;
+    private String name;
+    private String beginDate;
+    private List<BroadcastItemDTO> proTimeList;
+
 
     @NotNull
     @Contract("_ -> param1")

+ 1 - 0
src/main/java/com/welampiot/vo/BroadcastVO.java

@@ -20,6 +20,7 @@ public class BroadcastVO implements Serializable {
     private Integer total;
 
     private Integer onlineTotal;
+    private Integer onlineCount;
 
     private List<BroadcastDTO> list;
 

+ 31 - 3
src/main/resources/mapper/BroadcastItemMapper.xml

@@ -39,7 +39,9 @@
         <if test="policyType != null and policyType != 0">
             policyType,
         </if>
-        playType,
+        <if test="playType != null">
+            playType,
+        </if>
         proType,
         createTime)
         VALUES (#{broadcastId},
@@ -78,7 +80,9 @@
         <if test="policyType != null and policyType != 0">
             #{policyType},
         </if>
-        #{playType},
+        <if test="playType != null">
+            #{playType},
+        </if>
         #{proType},
         #{createTime})
     </insert>
@@ -134,6 +138,12 @@
         </if>
         <if test="status != null">
             b.status = #{status},
+        </if>
+        <if test="weierxiId != null">
+            b.weierxiId = #{weierxiId},
+        </if>
+        <if test="sipId != null">
+            b.sip_id = #{sipId}
         </if>
             b.id = #{id}
         where
@@ -176,10 +186,28 @@
         select
             count(*)
         from broadcast_item b
-        where b.userId = #{userId}
+        <trim prefix="where" suffixOverrides="and|or">
+            <if test="userId != null">
+                b.userId = #{userId} and
+            </if>
+            <if test="name != null">
+                b.name = #{name} and
+            </if>
+        </trim>
+
     </select>
 
     <select id="getOneDataById" resultType="BroadcastItemDTO" parameterType="integer">
         select name from broadcast_item where id = #{id} order by id desc
     </select>
+
+    <select id="getList" parameterType="BroadcastItemDTO" resultType="BroadcastItemDTO">
+        select B.id,B.name,B.proType,B.createTime,B.broadcastId,B.status,B.proId1,B.proId2,B.proId3,B.proId4,B.proId5,B.proId6,B.proId7,B.proId8,B.proId9,B.proId10
+        from broadcast_item B
+        <trim prefix="where" prefixOverrides="and|or">
+            <if test="userId != null">
+                B.userId = #{userId}
+            </if>
+        </trim>
+    </select>
 </mapper>

+ 52 - 2
src/main/resources/mapper/BroadcastMapper.xml

@@ -4,10 +4,18 @@
 
     <select id="getDevListByBroadcastDTO" resultType="BroadcastDTO">
         select b.id,b.name,b.dev_id devId,b.address,b.online,b.vol,bi.name as proName,b.isPlay,
-               lp.name as lampPoleName,b.type,b.install_date installDate,b.expiration_date expirationDate
-        from broadcast b left join broadcast_item bi on bi.broadcastId = b.id
+               lp.name as lampPoleName,lp.id as lampPoleId,b.type,b.install_date installDate,b.expiration_date expirationDate
+        from broadcast b
+            left join broadcast_item bi on  bi.id = b.itemId
             left join lamp_pole lp on b.lamp_pole_id = lp.id
+            left join broadcast_pro_list as BP on b.proId = BP.id
         where b.lamp_pole_id != 0
+          <if test="areaId != 0">
+              and lp.areaid = #{areaId}
+          </if>
+          <if test="sectionId != 0">
+              and lp.sectionid = #{sectionId}
+          </if>
         <if test="sectionList != null and !sectionList.isEmpty()">
             and lp.sectionid in
             <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
@@ -168,4 +176,46 @@
             left join broadcast_pro_list c on a.proId = c.id
         where a.lamp_pole_id = #{lampPoleId}
     </select>
+
+    <select id="getCount" resultType="integer" parameterType="BroadcastDTO">
+        select count(*) as total from broadcast b
+        left join broadcast_item bi on  bi.id = b.itemId
+        left join lamp_pole lp on b.lamp_pole_id = lp.id
+        left join broadcast_pro_list as BP on b.proId = BP.id
+        where b.lamp_pole_id != 0
+        <if test="areaId != 0">
+            and lp.areaid = #{areaId}
+        </if>
+        <if test="sectionId != 0">
+            and lp.sectionid = #{sectionId}
+        </if>
+        <if test="sectionList != null and !sectionList.isEmpty()">
+            and lp.sectionid in
+            <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
+                #{dto}
+            </foreach>
+        </if>
+        <choose>
+            <when test="onlineState == 0">
+                and b.online = 0
+            </when>
+            <when test="onlineState == 1">
+                and b.online = 1
+            </when>
+        </choose>
+        order by convert(lp.number using gbk) asc,
+        convert(b.name using gbk) asc,b.id desc
+    </select>
+
+    <select id="getList" parameterType="BroadcastDTO" resultType="BroadcastDTO">
+        select id,name,dev_id as devId,name,vol,address,lamp_pole_id as lampPoleId from broadcast
+        <trim prefix="where" prefixOverrides="and|or">
+            <if test="idList != null and id">
+                id in
+                <foreach collection="idList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+        </trim>
+    </select>
 </mapper>

+ 11 - 0
src/main/resources/mapper/BroadcastProListMapper.xml

@@ -18,4 +18,15 @@
         where id = #{id};
     </delete>
 
+    <select id="getList" resultType="BroadcastProListDTO">
+        select id,name,shibang_name as shibangName,xianke_name as xiankeName,weierxi_id as weierxiId,url,sip_id as sipId from broadcast_pro_list
+        <trim prefix="where" prefixOverrides="and|or">
+            <if test="idList != null and idList.size() > 0">
+                id in
+                <foreach collection="idList" separator="," item="item" open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </trim>
+    </select>
 </mapper>