2021与蓝度共同重构项目,服务端
liuhaonan
2022-02-24 a98ab7f009865d113b75708a69ef1a0a8e3d8d3b
功能完善
已修改8个文件
已添加5个文件
2566 ■■■■■ 文件已修改
dao/src/main/java/com/sandu/ximon/dao/domain/PoleLightemitEntity.java 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/mapper/PoleLightemitEntityMapper.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/resources/mapper/PoleLightemitEntityMapper.xml 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/entity/Schedule.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/entity/TaskItem.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/security/test.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeDataService.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java 1304 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/XiXunPlayerService.java 227 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java 744 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/PoleLightemitEntity.java
@@ -1,89 +1,95 @@
package com.sandu.ximon.dao.domain;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
/**
 * led广告屏主表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-04-20 13:34:54
 * @TableName pole_lightemit
 */
@TableName(value ="pole_lightemit")
@Data
@TableName("pole_lightemit")
public class PoleLightemitEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * LED ID
     */
    @TableId
    @TableId(type = IdType.AUTO)
    private Long lightemitId;
    /**
     * LED名称
     */
    private String lightemitName;
    /**
     * LED控制卡编号
     * led屏控制卡编号
     */
    private String lightemitControlCode;
    /**
     * æ‰€æ˜¾ç¤ºå›¾ç‰‡åœ°å€
     */
    private String url;
    /**
     * æ˜¾ç¤ºæ—¶é—´
     */
    private Integer playTime;
    /**
     * åŠ å…¥æ—¶é—´ï¼ˆå­˜å‚¨å•ç¯æ•°æ®æ›´æ–°æ—¶é—´ï¼‰
     * åŠ å…¥æ—¶é—´
     */
    private DateTime addTime;
    /*
    è¯·æ±‚数据
    private LocalDateTime addTime;
    /**
     * è¯·æ±‚body,节目主体的容器
     */
    private String requestBody;
    /**
     * æ’­æ”¾è®¾ç½® 0:使用播放接口; 1:使用xixunplayer播放接口
     */
    private Integer playerSetting;
    /**
     * çŠ¶æ€  0:禁用   1:正常
     */
    private Integer status;
    /**
     * çŠ¶æ€  0:禁用   1:正常
     * å¤‡æ³¨
     */
    private String remark;
    /**
     * åˆ›å»ºè€…ID
     */
    private Long createUserId;
    /**
     * åˆ›å»ºæ—¶é—´
     * å®¢æˆ·id
     */
    private DateTime createTime;
    private Long clientId;
    private Long userId;
    /**
     * ç»‘定灯杆ID
     */
    @TableField(exist = false)
    private Long streetlightId;
    /**
     * ç¯æ†åç§°
     */
    @TableField(exist = false)
    private String streetlightName;
    private Long poleId;
    /**
     * led屏幕开关
     *
     */
    @TableField(exist = false)
    private Boolean isOpen;
    private LocalDateTime createTime;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;
}
dao/src/main/java/com/sandu/ximon/dao/mapper/PoleLightemitEntityMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.sandu.ximon.dao.mapper;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * @Entity com.sandu.ximon.dao.domain.PoleLightemitEntity
 */
@Mapper
public interface PoleLightemitEntityMapper extends BaseMapper<PoleLightemitEntity> {
    void updateRequestBody(@Param("ledCode")String ledCode, @Param("postBody")String postBody);
}
dao/src/main/resources/mapper/PoleLightemitEntityMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sandu.ximon.dao.mapper.PoleLightemitEntityMapper">
    <resultMap id="BaseResultMap" type="com.sandu.ximon.dao.domain.PoleLightemitEntity">
            <id property="lightemitId" column="lightemit_id" jdbcType="BIGINT"/>
            <result property="lightemitName" column="lightemit_name" jdbcType="VARCHAR"/>
            <result property="lightemitControlCode" column="lightemit_control_code" jdbcType="VARCHAR"/>
            <result property="url" column="url" jdbcType="VARCHAR"/>
            <result property="playTime" column="play_time" jdbcType="INTEGER"/>
            <result property="addTime" column="add_time" jdbcType="TIMESTAMP"/>
            <result property="requestBody" column="request_body" jdbcType="VARCHAR"/>
            <result property="playerSetting" column="player_setting" jdbcType="TINYINT"/>
            <result property="status" column="status" jdbcType="TINYINT"/>
            <result property="remark" column="remark" jdbcType="VARCHAR"/>
            <result property="createUserId" column="create_user_id" jdbcType="BIGINT"/>
            <result property="clientId" column="client_id" jdbcType="BIGINT"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
    </resultMap>
    <sql id="Base_Column_List">
        lightemit_id,lightemit_name,lightemit_control_code,
        url,play_time,add_time,
        request_body,player_setting,status,
        remark,create_user_id,create_time
    </sql>
    <update id="updateRequestBody">
        UPDATE pole_lightemit
        SET request_body = #{postBody}
        WHERE lightemit_control_code = #{ledCode}
    </update>
</mapper>
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/VnnoxController.java
@@ -130,6 +130,5 @@
            wrapper.like(LedPlayerEntity::getPlayerName,keyword);
            return ResponseUtil.success(ledPlayerEntityService.list(wrapper));
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,91 @@
package com.sandu.ximon.admin.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageHelper;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.entity.ProgramPro;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.ClientService;
import com.sandu.ximon.admin.service.PoleLightemitService;
import com.sandu.ximon.admin.service.XiXunPlayerService;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
import com.sandu.ximon.dao.enums.AdministratorEnums;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
 * @Author liuhaonan
 * @Date 2022/2/22 13:55
 * @Version 1.0
 */
@RestController
@AllArgsConstructor
@RequestMapping("/v1/xixun")
public class XiXunController {
    private final XiXunPlayerService xiXunPlayerService;
    private final ClientService clientService;
    private final PoleLightemitService poleLightemitService;
    @PostMapping("/addProgram")
    public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro){
       return ResponseUtil.success(xiXunPlayerService.insert(programPro));
    }
    @PostMapping("/deleteProgram/{pid}")
    public ResponseVO<Object> deleteProgram(@PathVariable Long pid){
        return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
    }
    @GetMapping("/getByPid/{pid}")
    public ResponseVO<Object> getByPid(@PathVariable Long pid){
        return ResponseUtil.success(xiXunPlayerService.getByPid(pid));
    }
    @GetMapping("/list")
    public ResponseVO<Object> list(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        LambdaQueryWrapper<PoleXixunPlayerEntity> wrapper = Wrappers.lambdaQuery(PoleXixunPlayerEntity.class).like(PoleXixunPlayerEntity::getProgramName, keyword);
        if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
//            clientService.findClientId()
//            wrapper.eq(PoleXixunPlayerEntity::getCreateUserId,)
            //wrapper.eq(LedPlayerEntity::get)
            return ResponseUtil.success(xiXunPlayerService.list(wrapper)); //  todo
        }else {
            return ResponseUtil.success(xiXunPlayerService.list(wrapper));
        }
    }
    @GetMapping("/pushToXixun/{pid}")
    public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds ){
        xiXunPlayerService.videoXixunPlayer(pid,lightemitIds);
        return ResponseUtil.success("推送成功");
    }
    @PostMapping("/saveLed")
    public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit){
        int count = poleLightemitService.count(new QueryWrapper<PoleLightemitEntity>().eq("lightemit_control_code", poleLightemit.getLightemitControlCode()));
        if(count != 0){
          throw  new BusinessException("LED控制卡编号不能重复");
        }
        poleLightemit.setCreateUserId(SecurityUtils.getClientId());
        poleLightemitService.savePoleLightemit(poleLightemit);
        return ResponseUtil.success("");
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/entity/Schedule.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.sandu.ximon.admin.entity;
import lombok.Data;
/**
 * @Author liuhaonan
 * @Date 2022/2/21 15:27
 * @Version 1.0
 */
@Data
public class Schedule {
}
ximon-admin/src/main/java/com/sandu/ximon/admin/entity/TaskItem.java
@@ -3,6 +3,7 @@
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class TaskItem implements Serializable {
@@ -11,5 +12,5 @@
    private String _id;                    //UUID
    private Program _program;            //将包装好的节目赋值给他
    private int repeatTimes;                //重复次数
   // private List<Schedule> schedules=null;    //可以为一个program添加多个定时段
    private List<Schedule> schedules=null;    //可以为一个program添加多个定时段
}
ximon-admin/src/main/java/com/sandu/ximon/admin/security/test.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.sandu.ximon.admin.security;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
/**
 * @Author liuhaonan
 * @Date 2022/2/24 10:15
 * @Version 1.0
 */
public class test {
    public static void main(String[] args) {
        String s="e10adc3949ba59abbe56e057f20f883e";
        PasswordEncoder pw= new BCryptPasswordEncoder();
        //加密
        String encode=pw.encode(s);
        System.out.println(encode);
        //比较密码
        boolean matches=pw.matches(s,encode);
        System.out.println("==============================");
        System.out.println(matches);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/IpVolumeDataService.java
@@ -2,12 +2,19 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.Constant;
import com.sandu.ximon.dao.domain.IpVolumeData;
import com.sandu.ximon.dao.mapper.IpVolumeDataMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
 * @Author liuhaonan
@@ -26,6 +33,36 @@
        } else {
            return  Wrappers.lambdaQuery(IpVolumeData.class);
        }
    }
//    public List<IpVolumeData> getOnlineList(Long userId) {
//        PageInfo terminalList = getTerminalList(userId, 1, 9999, "");
//        List<IpVolumeData> list = terminalList.getList();
//        List<IpVolumeData> result = new ArrayList<>();
//        for(IpVolumeData t:list){
//            if(t.getOnLineStatus() != 0) {
//                result.add(t);
//            }
//        }
//        return result;
//    }
//    public PageInfo getTerminalList(Long userId, Integer page, Integer limit, String key) {
//
//        List<TerminalEntity> list = null;
//        if(roleId == Constant.SUPER_ADMIN) {
//            PageHelper.startPage(page,limit);
//            list = getTerminalList(key);
//        }else if(roleId == Constant.ADMIN) {
//            PageHelper.startPage(page,limit);
//            list = getTerminalListByCompanyId(companyId,key);
//        }else {
//            PageHelper.startPage(page,limit);
//            list = getTerminalListByUserId(userId,key);
//        }
//        PageInfo pageInfo = new PageInfo(list);
//
//        pageInfo.setList(setTerminalStatus(list));
//
//        return pageInfo;
//    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java
@@ -1,343 +1,660 @@
//package com.sandu.ximon.admin.service;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.google.gson.Gson;
//import com.sandu.common.service.impl.BaseServiceImpl;
//import com.sandu.ximon.admin.config.NginxConfigBean;
//import com.sandu.ximon.admin.config.RealtimeServerBean;
//import com.sandu.ximon.admin.entity.*;
//import com.sandu.ximon.admin.utils.Constant;
//import com.sandu.ximon.admin.utils.FileUtil;
//import com.sandu.ximon.admin.utils.HtmlTemplateUtils;
//import com.sandu.ximon.admin.utils.LightemitUtils;
//import com.sandu.ximon.admin.utils.request.SubTitleSet;
//import com.sandu.ximon.dao.domain.PoleLightemitEntity;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.cache.annotation.EnableCaching;
//import org.springframework.context.ApplicationContext;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.PostConstruct;
//import java.io.File;
//import java.io.IOException;
//import java.util.*;
//
//
//@Service
//@EnableCaching
//public class PoleLightemitService extends BaseServiceImpl<PoleLightemitDao, PoleLightemitEntity> {
//
package com.sandu.ximon.admin.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.Gson;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.config.NginxConfigBean;
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.entity.*;
import com.sandu.ximon.admin.utils.Constant;
import com.sandu.ximon.admin.utils.FileUtil;
import com.sandu.ximon.admin.utils.HtmlTemplateUtils;
import com.sandu.ximon.admin.utils.LightemitUtils;
import com.sandu.ximon.admin.utils.request.SubTitleSet;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.mapper.PoleLightemitEntityMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.IOException;
import java.util.*;
@Service
@EnableCaching
public class PoleLightemitService extends BaseServiceImpl<PoleLightemitEntityMapper, PoleLightemitEntity> {
//    @Autowired
//    PoleStreetlightLightemitService poleStreetlightLightemitService;
//    LightemitUtils lightemitUtils;
//    @Autowired
//    RealtimeServerBean realtimeServerBean;
//    @Value("${server.port}")
//    private String port;
//    @Autowired
//    ApplicationContext applicationContext;
    LightemitUtils lightemitUtils;
    @Autowired
    private RealtimeServerBean realtimeServerBean;
    @Value("${server.port}")
    private String port;
    @Autowired
    ApplicationContext applicationContext;
//    @Autowired
//    FfmpegUtils ffmpegUtils;
//    @Autowired
//    FileUploadPathBean fileUploadPathBean;
//    @Autowired
//    NginxConfigBean nginxConfigBean;
//    @Autowired
//    PoleLightemitDao poleLightemitDao;
//
//    @PostConstruct
//    public  void init(){
//        //重新获取单例
//        lightemitUtils = applicationContext.getBean(LightemitUtils.class);
    @Autowired
    NginxConfigBean nginxConfigBean;
    @Autowired
    PoleLightemitEntityMapper poleLightemitDao;
    @PostConstruct
    public void init() {
        //重新获取单例
        lightemitUtils = applicationContext.getBean(LightemitUtils.class);
    }
    /*@Override
    public PageUtils queryPage(Map<String, Object> params, Long userId) {
        String key = (String)params.get("key");
        Long groupId = StringUtils.isNotBlank((String)params.get("group"))? Long.valueOf((String)params.get("group")): null;
        String order = (String)params.get("order");
        String column = (String)params.get("sortby");
        IPage<PoleLightemitEntity> page = new Page<>();
        //获取角色列表
        Long roleId = (sysUserRoleService.queryRoleId(userId));
        if(roleId == null || roleId == 0){
            return null;
        }
        if(roleId.longValue() == Constant.SUPER_ADMIN){
//            page = this.page(
//                    new Query<PoleLightemitEntity>().getPage(params),
//                    new QueryWrapper<PoleLightemitEntity>().like(StringUtils.isNotBlank(key),"lightemit_name", key));
            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params),key,groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params),key,groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else {
                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params), key, groupId,order,column);
            }
        }else if(roleId.longValue() == Constant.ADMIN){
            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else {
                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
            }
        }else if(roleId.longValue() == Constant.USER){
            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
                Map<String, Object> map = new HashMap<>();
                Integer pg = 1;
                Integer size = 200;
                map.put("page",pg);
                params.put("limit",size);
                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
                ledOnlineCheck(page.getRecords());
                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
                return new PageUtils(page);
            }else {
                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
            }
        }
        ledOnlineCheck(page.getRecords());
        return new PageUtils(page);
    }
*//*
    @Override
    public List<PoleLightemitEntity> getAll(Long userId) {
        //获取角色列表
        Long roleId = (sysUserRoleService.queryRoleId(userId));
        if(roleId == null || roleId == 0){
            return null;
        }
        List<PoleLightemitEntity> list = null;
        if(roleId.longValue() == Constant.SUPER_ADMIN){
            list = poleLightemitDao.selectAll();
        }else if(roleId.longValue() == Constant.ADMIN){
            list = poleLightemitDao.selectAllByCompany(userId);
        }else if(roleId.longValue() == Constant.USER){
            list = poleLightemitDao.selectAllByUser(userId);
        }
        return list;
    }
*/
/*    public void ledOnlineCheck(List<PoleLightemitEntity> list) {
        for(PoleLightemitEntity poleLightemitEntity : list){
            poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true"));
        }
    }*/
    public void savePoleLightemit(PoleLightemitEntity poleLightemit) {
        boolean save = this.save(poleLightemit);
        // ç»‘定灯杆
        if(save&&poleLightemit.getPoleId()!=null){
        }
      //  poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
    }
  /*  public void updatePoleLightemit(PoleLightemitEntity poleLightemit) {
        this.updateById(poleLightemit);
        poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
    }*/
    /**
     * æŸ¥è¯¢æƒé™èŒƒå›´å†…的所有led屏信息
     *
     * @param
     * @return
     */
   /* public List<PoleLightemitEntity> selectLightemitByUserId(Long userId) {
        List<PoleLightemitEntity> list = new ArrayList<>();
        Long roleId = sysUserRoleService.queryRoleId(userId);
        if(roleId == null || roleId == 0){
            return new ArrayList<>();
        }
        if(roleId.longValue() == Constant.SUPER_ADMIN){
            list = this.list();
        }else if(roleId.longValue() == Constant.ADMIN){
            list = baseMapper.selectCompanyLightemitByUserId(userId);
        }else if(roleId.longValue() == Constant.USER){
            list = baseMapper.selectLightemitByUserId(userId);
        }
        return list;
    }
*/
    /*
    é€šè¿‡å±å¹•编码查询
     */
    public PoleLightemitEntity selectByLightemitControlCode(String lightemitControlCode) {
        QueryWrapper<PoleLightemitEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("lightemit_control_code", lightemitControlCode);
        return this.getOne(queryWrapper);
    }
    /*
    led上传图片
     */
    @Async("taskExecutor")
    public void photoUpload(String lightemitControlCode, String path, List<String> filenameList, String userName) throws IOException {
        //获取屏幕宽
        String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode);
        String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode);
        //html地址
        String filenameTemp = path + userName + "_" + lightemitControlCode + ".html";
        File htmlFile = new File(filenameTemp);
        if (!htmlFile.exists() || htmlFile.delete()) {
            htmlFile.createNewFile();
        }
        //获取body的html
        Map<String, Object> params = new HashMap<>();
        params.put("imgList", filenameList);
        params.put("screenWidth", screenWidth);
        params.put("screenHeight", screenHeight);
        String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/photoTemplates.html", params);
        boolean flag = new FileUtil().writeToFile(body, filenameTemp);
        if (flag) {
            //清屏操作
            lightemitUtils.clear(lightemitControlCode);
            //清除播放列表
            lightemitUtils.clearVideoPlay(lightemitControlCode);
            //清除节目列表
            lightemitUtils.clearPlayerTask(lightemitControlCode);
            //推送图片
            lightemitUtils.postHtml(lightemitControlCode, userName);
        }
    }
    /*
    led上传视频
     */
    @Async("taskExecutor")
    public void videoUpload(String lightemitControlCode, String filename, String path, String userName) throws IOException {
        //获取屏幕宽
        String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode);
        String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode);
        //发送视频至开发板并播放
        lightemitUtils.postVideo(screenWidth, screenHeight, filename, lightemitControlCode);
        //清屏
        lightemitUtils.clear(lightemitControlCode);
    }
    /**
     * LED上传单行字幕
     */
    @Async("taskExecutor")
    public Boolean subTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) {
        if (subTitleSetEntity == null) {
            return false;
        }
        if (subTitleSetEntity.getDirection().equals(Constant.LEFT) || subTitleSetEntity.getDirection().equals(Constant.RIGHT)) {
            //字幕横向滚动
            this.BuildHorizonSingSubTitleText(subTitleSetEntity);
        } else if (subTitleSetEntity.getDirection().equals(Constant.UP) || subTitleSetEntity.getDirection().equals(Constant.DOWN)) {
            //字幕纵向滚动
            try {
                this.BuildVerticalSingSubTitleText(subTitleSetEntity, path, userName);
            } catch (IOException e) {
                return false;
            }
        }
        return true;
    }
    /**
     * LED上传多行字幕
     */
    @Async("taskExecutor")
    public Boolean subMultiTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) {
        try {
            this.BuildVerticalMultiSubTitleText(subTitleSetEntity, path, userName);
            return true;
        } catch (IOException e) {
            return false;
        }
    }
    /*
    åˆ é™¤
     */
   /* public void deleteByIds(List<Long> lightemitIds) {
        this.removeByIds(lightemitIds);
        //删除关系表中的数据
        poleStreetlightLightemitService.remove(
                new UpdateWrapper<PoleStreetlightLightemitEntity>().in("lightemit_id", lightemitIds.toArray()));
    }*/
    /*
    ç†™è®¯è§†é¢‘设置
     */
    @Async("taskExecutor")
    public void videoXixunPlayer(String lightemitControlCode, String ip, String filename, Long filesize, Integer videoTime) {
        //获取屏幕宽
        Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
        Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
        Source source = new Source();
        Layer layer = new Layer();
        Program pro = new Program();
        TaskItem items = new TaskItem();
        ProgramsTask task = new ProgramsTask();
        Command command = new Command();
        XixunPlayer xixun = new XixunPlayer();
        source.set_id(UUID.randomUUID().toString());//所有_id都可用UUID随机生成
        source.setId(filename);//请求头拼接该ID为该资源的完整下载地址
        source.set_type("Video");    //设置资源类型,其他资源类型请参考xixunplayer节目json说明文档
        source.setFileExt(".mp4");    //资源后缀名
        source.setHeight(screenHeight);        //资源高度
        source.setWidth(screenWidth);        //资源宽度
        source.setLeft(0);            //距左
        source.setMd5("dd135d5d2d44d619a542db773ab529a4");
        source.setMime("video/mp4");
        source.setName(filename);
        source.setPlayTime(0);    //播放起始时间
        source.setSize(filesize);    //资源字节数,要精准
        source.setTimeSpan(videoTime);        //该资源播放时长
        source.setTop(0);            //距顶
        List<Source> list = new ArrayList<Source>();
        list.add(source);
        layer.setSources(list);
        pro.set_id(UUID.randomUUID().toString());
        pro.setHeight(screenHeight);        //节目高度
        List<Layer> list1 = new ArrayList<Layer>();
        list1.add(layer);
        pro.setLayers(list1);
        pro.setName("demo");    //节目名称
        pro.setOthers(true);//如果为true,则该节目来自第三方接口,不是来自我们自己的web,二次开发请务必赋值为true
        pro.setTotalSize(filesize);    //所有资源总字节数
        pro.setVersion(0);            //高级节目=0,简易节目=2
        pro.setWidth(screenWidth);        //节目宽度
        items.set_id(UUID.randomUUID().toString());
        items.set_program(pro);
        items.setRepeatTimes(1);
        items.setSchedules(null);//定时段,不做定时可为null
        task.set_id(UUID.randomUUID().toString());
        task.setName("这是一个示例");
        List<TaskItem> list2 = new ArrayList<TaskItem>();
        list2.add(items);
        task.setItems(list2);
        command.setId(UUID.randomUUID().toString());
        //这里是下方的post回调地址,需要修改IP地址
        command.setNotificationURL("http://" + ip + ":" + port + "/machine-fast/serv/download/getJSON");
        //资源下载链接的请求头
        command.setPreDownloadURL("http://" + ip + ":" + port + "/machine-fast/serv/download/downloadFile/");
        command.setTask(task);
        xixun.set_id(UUID.randomUUID().toString());
        xixun.setCommand(command);
        xixun.setType("commandXixunPlayer");    //命令固定类型,不可更改
        String jsondata = new Gson().toJson(xixun);
        lightemitUtils.clear(lightemitControlCode);
        poleLightemitDao.updateRequestBody(lightemitControlCode, jsondata);
        lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode, jsondata);
    }
    /*
    æŽ¨é€å¤©æ°”数据
     */
    //@Async("taskExecutor")
   /* public Boolean pushWeather(String lightemitControlCode, PoleSensorEntity sensorEntity, PoleStreetlightEntity streetlightEntity) {
        if(StringUtils.isBlank(lightemitControlCode)){
            return Boolean.valueOf(false);
        }
        Integer screenHeight = Integer.parseInt(lightemitUtils.getScreenHeight(lightemitControlCode));
        String size = String.valueOf(screenHeight/18);
        //字幕主体拼接
        String body =
                "<head><style type=\"text/css\">body{background-color:#000;}</style></head>" +
                        "<p style=\"font-size:" + size + "px;line-height:17px;color:#fff\">" +
                        (streetlightEntity == null || streetlightEntity.getCity() == null? "": streetlightEntity.getCity().replace("市", "")) + "<br/>" +
                        "温度:" + (sensorEntity == null || sensorEntity.getTemperature() == null? "-": sensorEntity.getTemperature()) + "℃<br/>" +
                        "湿度:" + (sensorEntity == null || sensorEntity.getHumidity() == null? "-": sensorEntity.getHumidity()) + "%RH<br/>" +
                        "亮度:" + (sensorEntity == null || sensorEntity.getBrightness() == null? "-": sensorEntity.getBrightness()) + "lux<br/>" +
                        "风速:" + (sensorEntity == null || sensorEntity.getWindSpeed() == null? "-": sensorEntity.getWindSpeed()) + "m/s<br/>" +
                        "CO2:" + (sensorEntity == null || sensorEntity.getEco2() == null? "-": sensorEntity.getEco2()) + "ppm<br/>" +
                        "甲醛:" + (sensorEntity == null || sensorEntity.getEch2o() == null? "-": sensorEntity.getEch2o()) + "mg/m³<br/>" +
                        "TVOC:" + (sensorEntity == null || sensorEntity.getTvoc() == null? "-": sensorEntity.getTvoc()) + "mg/m³<br/>" +
                        "PM25:" + (sensorEntity == null || sensorEntity.getPm25() == null? "-": sensorEntity.getPm25()) + "mg/m³<br/>" +
                        "PM10:" + (sensorEntity == null || sensorEntity.getPm10() == null? "-": sensorEntity.getPm10()) + "mg/m³<br/>";
        //组装请求参数
        SubTitleSet subTitleSet = new SubTitleSet();
        subTitleSet.html = body;
        subTitleSet.num = 1;
        //清屏操作
        lightemitUtils.clear(lightemitControlCode);
        //清除播放列表
        lightemitUtils.clearVideoPlay(lightemitControlCode);
        //清除节目列表
        lightemitUtils.clearPlayerTask(lightemitControlCode);
        try{
            lightemitUtils.subTitleSet(subTitleSet, lightemitControlCode, false);
            return true;
        }catch (Exception e){
            return false;
        }finally {
            //一分钟后清除屏幕
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    lightemitUtils.clear(lightemitControlCode);
                    //清除播放列表
                    lightemitUtils.clearVideoPlay(lightemitControlCode);
                    //清除节目列表
                    lightemitUtils.clearPlayerTask(lightemitControlCode);
                    //推送最后命令
                    lightemitUtils.sendLastCommand(lightemitControlCode);
                }
            }, 60*1000);
        }
    }*/
    /*
    æ›´æ–°è¯·æ±‚数据
     */
    public void updateRequestBody(String ledCode, String postBody) {
        baseMapper.updateRequestBody(ledCode, postBody);
    }
    /*
    æ ¹æ®led屏编码获取灯杆所有信息
     */
//    public PoleStreetlightEntity getStreetlightByLedCode(String ledCode) {
//        return baseMapper.getStreetlightByLedCode(ledCode);
//    }
//
//    /*@Override
//    public PageUtils queryPage(Map<String, Object> params, Long userId) {
//
//        String key = (String)params.get("key");
//
//        Long groupId = StringUtils.isNotBlank((String)params.get("group"))? Long.valueOf((String)params.get("group")): null;
//
//        String order = (String)params.get("order");
//
//        String column = (String)params.get("sortby");
//
//        IPage<PoleLightemitEntity> page = new Page<>();
//        //获取角色列表
//        Long roleId = (sysUserRoleService.queryRoleId(userId));
//
//        if(roleId == null || roleId == 0){
//            return null;
    /*
    æ ¹æ®led屏编码设置音量
     */
    @Async("taskExecutor")
    public void setVolume(String lightemitControlCode, Integer volume) {
        lightemitUtils.setVoiume(lightemitControlCode, volume);
    }
//    public List<PoleLightemitEntity> listOfStreetlight(String streetlightId) {
//        return baseMapper.listOfStreetlight(streetlightId);
//        }
//
//        if(roleId.longValue() == Constant.SUPER_ADMIN){
////            page = this.page(
////                    new Query<PoleLightemitEntity>().getPage(params),
////                    new QueryWrapper<PoleLightemitEntity>().like(StringUtils.isNotBlank(key),"lightemit_name", key));
//            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params),key,groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params),key,groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else {
//                page = baseMapper.superAdminSelectPageVo(PageTransform.transformPage(params), key, groupId,order,column);
//    public List<PoleLightemitEntity> selectLedByStreetlightId(String streetlightId) {
//        return baseMapper.getLedByStreetlightId(streetlightId);
//            }
//
//        }else if(roleId.longValue() == Constant.ADMIN){
//            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else {
//                page = baseMapper.adminSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//            }
//
//        }else if(roleId.longValue() == Constant.USER){
//            if (order != null && order.equals("ASC") && column.equals("isOpen")) {
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(true)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else if (order != null && order.equals("DESC") && column.equals("isOpen")){
//                Map<String, Object> map = new HashMap<>();
//                Integer pg = 1;
//                Integer size = 200;
//                map.put("page",pg);
//                params.put("limit",size);
//                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//                ledOnlineCheck(page.getRecords());
//                page.setRecords(page.getRecords().stream().filter(h-> h.getIsOpen().equals(false)).collect(Collectors.toList()));
//                return new PageUtils(page);
//            }else {
//                page = baseMapper.userSelectPageVo(PageTransform.transformPage(params), userId, key, groupId,order,column);
//            }
//
//        }
//        ledOnlineCheck(page.getRecords());
//        return new PageUtils(page);
//    }
//*//*
    /*
        ä¸Šä¼ æ°´å¹³æ»šåŠ¨å•è¡Œå­—å¹•
         */
    private void BuildHorizonSingSubTitleText(SubTitleSetEntity subTitleSetEntity) {
        //拼装LED屏幕设置请求body
        SubTitleSet subTitleSet = new SubTitleSet();
        subTitleSet.num = subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : subTitleSet.num;
        subTitleSet.interval = subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : subTitleSet.interval;
        subTitleSet.step = subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : subTitleSet.step;
        subTitleSet.direction = subTitleSetEntity.getDirection() != null ? subTitleSetEntity.getDirection() : subTitleSet.direction;
        subTitleSet.align = subTitleSetEntity.getAlign() != null ? subTitleSetEntity.getAlign() : subTitleSet.align;
        //拼接html èƒŒæ™¯é»˜è®¤æ˜¾è‰²ä¸ºç™½è‰²
        subTitleSet.html = "<head><style type=\"text/css\">body{background-color:" +
                (subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000") +
                "}</style></head><i style=\"color:" +
                (subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff")
                + "; font-size: " +
                (subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1")
                + "em\">" + subTitleSetEntity.getContent() + "</i>";
        //获取所有led数据
        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
        if (!poleLightemitControllers.isEmpty()) {
            Iterator iterator = poleLightemitControllers.iterator();
            while (iterator.hasNext()) {
                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
                //清屏操作
                lightemitUtils.clear(poleLightemitEntity.getLightemitControlCode());
                //清除播放列表
                lightemitUtils.clearVideoPlay(poleLightemitEntity.getLightemitControlCode());
                //清除节目列表
                lightemitUtils.clearPlayerTask(poleLightemitEntity.getLightemitControlCode());
                //发送字幕设置请求
                lightemitUtils.subTitleSet(subTitleSet, poleLightemitEntity.getLightemitControlCode(), true);
            }
        }
    }
    /*
    ä¸Šä¼ åž‚直滚动单行字幕
     */
    private void BuildVerticalSingSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException {
        //html地址
        //获取所有led数据
        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
        if (!poleLightemitControllers.isEmpty()) {
            Iterator iterator = poleLightemitControllers.iterator();
            while (iterator.hasNext()) {
                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
                String lightemitControlCode = poleLightemitEntity.getLightemitControlCode();
                //获取屏幕宽
                Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
                Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
                String filenameTemp = path + userName + "_" + lightemitControlCode + ".html";
                File htmlFile = new File(filenameTemp);
                if (!htmlFile.exists() || htmlFile.delete()) {
                    htmlFile.createNewFile();
                }
                //若向下滚动,文字顺序相反
                if (Constant.DOWN.equals(subTitleSetEntity.getDirection())) {
                    subTitleSetEntity.setContent(StringUtils.reverse(subTitleSetEntity.getContent()));
                }
                Map<String, Object> params = new HashMap<>();
                params.put("direction", subTitleSetEntity.getDirection());
                params.put("screenWidth", screenWidth);
                params.put("screenHeight", screenHeight);
                params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1");
                params.put("align", subTitleSetEntity.getAlign());
                params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff");
                params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000");
                params.put("interval", subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : 50);
                params.put("step", subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : 1);
                params.put("num", subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : -1);
                params.put("contentArray", subTitleSetEntity.getContent().toCharArray());
                String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params);
                boolean flag = new FileUtil().writeToFile(body, filenameTemp);
                if (flag) {
                    //清屏操作
                    lightemitUtils.clear(lightemitControlCode);
                    //清除播放列表
                    lightemitUtils.clearVideoPlay(lightemitControlCode);
                    //清除节目列表
                    lightemitUtils.clearPlayerTask(lightemitControlCode);
                    //推送
                    lightemitUtils.postHtmlUseNginx(lightemitControlCode, userName);
                }
            }
        }
    }
    /*
    ä¸Šä¼ åž‚直滚动多行字幕
     */
    private void BuildVerticalMultiSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException {
        //html地址
        //获取所有led数据
        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
        if (!poleLightemitControllers.isEmpty()) {
            Iterator iterator = poleLightemitControllers.iterator();
            while (iterator.hasNext()) {
                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
                String lightemitControlCode = poleLightemitEntity.getLightemitControlCode();
                //获取屏幕宽
                Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
                Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
                String filenameTemp = path + userName + "_" + lightemitControlCode + ".html";
                File htmlFile = new File(filenameTemp);
                if (!htmlFile.exists() || htmlFile.delete()) {
                    htmlFile.createNewFile();
                }
                Map<String, Object> params = new HashMap<>();
                params.put("direction", subTitleSetEntity.getDirection());
                params.put("screenWidth", screenWidth);
                params.put("screenHeight", screenHeight);
                params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize()) ? subTitleSetEntity.getFontSize() : "1");
                params.put("align", subTitleSetEntity.getAlign());
                params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor()) ? subTitleSetEntity.getFontColor() : "#ffffff");
                params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor()) ? subTitleSetEntity.getColor() : "#000000");
                params.put("interval", subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval() : 50);
                params.put("step", subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep() : 1);
                params.put("num", subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum() : -1);
                params.put("contentArray", subTitleSetEntity.getContent().split("\n"));
                String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params);
                boolean flag = new FileUtil().writeToFile(body, filenameTemp);
                if (flag) {
                    //清屏操作
                    lightemitUtils.clear(lightemitControlCode);
                    //清除播放列表
                    lightemitUtils.clearVideoPlay(lightemitControlCode);
                    //清除节目列表
                    lightemitUtils.clearPlayerTask(lightemitControlCode);
                    //推送
                    lightemitUtils.postHtmlUseNginx(lightemitControlCode, userName);
                }
            }
        }
    }
//    @Override
//    public List<PoleLightemitEntity> getAll(Long userId) {
//        //获取角色列表
//        Long roleId = (sysUserRoleService.queryRoleId(userId));
//
//        if(roleId == null || roleId == 0){
//            return null;
//        }
//        List<PoleLightemitEntity> list = null;
//        if(roleId.longValue() == Constant.SUPER_ADMIN){
//            list = poleLightemitDao.selectAll();
//        }else if(roleId.longValue() == Constant.ADMIN){
//            list = poleLightemitDao.selectAllByCompany(userId);
//        }else if(roleId.longValue() == Constant.USER){
//            list = poleLightemitDao.selectAllByUser(userId);
//        }
//        return list;
//    }
//*/
//
///*    public void ledOnlineCheck(List<PoleLightemitEntity> list) {
//
//        for(PoleLightemitEntity poleLightemitEntity : list){
//            poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true"));
//        }
//    }*/
//
//
//   /* public void savePoleLightemit(PoleLightemitEntity poleLightemit) {
//        this.save(poleLightemit);
//        poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
//    }*/
//
//
//  /*  public void updatePoleLightemit(PoleLightemitEntity poleLightemit) {
//        this.updateById(poleLightemit);
//        poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
//    }*/
//
//    /**
//     * æŸ¥è¯¢æƒé™èŒƒå›´å†…的所有led屏信息
//     * @param
//     * @return
//     */
//   /* public List<PoleLightemitEntity> selectLightemitByUserId(Long userId) {
//        List<PoleLightemitEntity> list = new ArrayList<>();
//
//        Long roleId = sysUserRoleService.queryRoleId(userId);
//
//        if(roleId == null || roleId == 0){
//            return new ArrayList<>();
//        }
//        if(roleId.longValue() == Constant.SUPER_ADMIN){
//            list = this.list();
//        }else if(roleId.longValue() == Constant.ADMIN){
//            list = baseMapper.selectCompanyLightemitByUserId(userId);
//        }else if(roleId.longValue() == Constant.USER){
//            list = baseMapper.selectLightemitByUserId(userId);
//        }
//        return list;
//    }
//*/
//    /*
//    é€šè¿‡å±å¹•编码查询
//     */
//
//    public PoleLightemitEntity selectByLightemitControlCode(String lightemitControlCode) {
//        QueryWrapper<PoleLightemitEntity> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("lightemit_control_code", lightemitControlCode);
//        return this.getOne(queryWrapper);
//    }
//
//    /*
//    led上传图片
//     */
//    @Async("taskExecutor")
//    public void photoUpload(String lightemitControlCode, String path, List<String> filenameList, String userName) throws IOException {
//        //获取屏幕宽
//        String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode);
//        String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode);
//
//        //html地址
//        String filenameTemp = path + userName + "_"+lightemitControlCode + ".html";
//        File htmlFile = new File(filenameTemp);
//        if (!htmlFile.exists() || htmlFile.delete()) {
//            htmlFile.createNewFile();
//        }
//
//        //获取body的html
//        Map<String, Object> params = new HashMap<>();
//        params.put("imgList",filenameList);
//        params.put("screenWidth",screenWidth);
//        params.put("screenHeight",screenHeight);
//
//        String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/photoTemplates.html", params);
//
//        boolean flag = new FileUtil().writeToFile(body, filenameTemp);
//
//        if(flag){
//            //清屏操作
//            lightemitUtils.clear(lightemitControlCode);
//            //清除播放列表
//            lightemitUtils.clearVideoPlay(lightemitControlCode);
//            //清除节目列表
//            lightemitUtils.clearPlayerTask(lightemitControlCode);
//            //推送图片
//            lightemitUtils.postHtml(lightemitControlCode,userName);
//        }
//    }
//
//    /*
//    led上传视频
//     */
//
//    @Async("taskExecutor")
//    public void videoUpload(String lightemitControlCode, String filename, String path, String userName) throws IOException {
//        //获取屏幕宽
//        String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode);
//        String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode);
//
//        //发送视频至开发板并播放
//        lightemitUtils.postVideo(screenWidth, screenHeight, filename, lightemitControlCode);
//
//        //清屏
//        lightemitUtils.clear(lightemitControlCode);
//
//    }
//
//    /**
//     * LED上传单行字幕
//     */
//    @Async("taskExecutor")
//    public Boolean subTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) {
//        if(subTitleSetEntity == null){
//            return false;
//        }
//        if(subTitleSetEntity.getDirection().equals(Constant.LEFT) || subTitleSetEntity.getDirection().equals(Constant.RIGHT)){
//            //字幕横向滚动
//            this.BuildHorizonSingSubTitleText(subTitleSetEntity);
//        }else if (subTitleSetEntity.getDirection().equals(Constant.UP) || subTitleSetEntity.getDirection().equals(Constant.DOWN)){
//            //字幕纵向滚动
//            try {
//                this.BuildVerticalSingSubTitleText(subTitleSetEntity, path, userName);
//            }catch (IOException e){
//                return false;
//            }
//        }
//        return true;
//    }
//
//    /**
//     * LED上传多行字幕
//     */
//    @Async("taskExecutor")
//    public Boolean subMultiTitleSet(SubTitleSetEntity subTitleSetEntity, String path, String userName) {
//        try{
//            this.BuildVerticalMultiSubTitleText(subTitleSetEntity, path, userName);
//            return true;
//        }catch (IOException e){
//            return false;
//        }
//    }
//
//    /*
//    åˆ é™¤
//     */
//
//   /* public void deleteByIds(List<Long> lightemitIds) {
//        this.removeByIds(lightemitIds);
//        //删除关系表中的数据
//        poleStreetlightLightemitService.remove(
//                new UpdateWrapper<PoleStreetlightLightemitEntity>().in("lightemit_id", lightemitIds.toArray()));
//    }*/
//
//    /*
//    ç†™è®¯è§†é¢‘设置
//     */
//
//    @Async("taskExecutor")
//    public void videoXixunPlayer(String lightemitControlCode, String ip, String filename, Long filesize, Integer videoTime) {
//        //获取屏幕宽
    public void xixunplaySetting(String lightemitControlCode) {
        //获取屏幕宽
//        Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
//        Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
//        Source source = new Source();
@@ -345,7 +662,7 @@
//        Program pro = new Program();
//        TaskItem items = new TaskItem();
//        ProgramsTask task = new ProgramsTask();
//        Command command = new Command();
//        Command payload = new Command();
//        XixunPlayer xixun = new XixunPlayer();
//        source.set_id(UUID.randomUUID().toString());//所有_id都可用UUID随机生成
//        source.setId(filename);//请求头拼接该ID为该资源的完整下载地址
@@ -383,329 +700,18 @@
//        List<TaskItem> list2=new ArrayList<TaskItem>();
//        list2.add(items);
//        task.setItems(list2);
//        command.setId(UUID.randomUUID().toString());
//        payload.setId(UUID.randomUUID().toString());
//        //这里是下方的post回调地址,需要修改IP地址
//        command.setNotificationURL("http://" + ip + ":" + port + "/machine-fast/serv/download/getJSON");
//        payload.setNotificationURL("http://" + ip + ":" + port + "/machine-fast/serv/download/getJSON");
//        //资源下载链接的请求头
//        command.setPreDownloadURL("http://" + ip + ":" + port + "/machine-fast/serv/download/downloadFile/");
//        command.setTask(task);
//        payload.setPreDownloadURL("http://" + ip + ":" + port + "/machine-fast/serv/download/downloadFile/");
//        payload.setTask(task);
//        xixun.set_id(UUID.randomUUID().toString());
//        xixun.setCommand(command);
//        xixun.setCommand(payload);
//        xixun.setType("commandXixunPlayer");    //命令固定类型,不可更改
//        String jsondata = new Gson().toJson(xixun);
//        lightemitUtils.clear(lightemitControlCode);
//        this.updateRequestBody(lightemitControlCode,jsondata);
//        lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode,jsondata);
//    }
//
//    /*
//    æŽ¨é€å¤©æ°”数据
//     */
//
//    //@Async("taskExecutor")
//   /* public Boolean pushWeather(String lightemitControlCode, PoleSensorEntity sensorEntity, PoleStreetlightEntity streetlightEntity) {
//        if(StringUtils.isBlank(lightemitControlCode)){
//            return Boolean.valueOf(false);
//        }
//        Integer screenHeight = Integer.parseInt(lightemitUtils.getScreenHeight(lightemitControlCode));
//        String size = String.valueOf(screenHeight/18);
//        //字幕主体拼接
//        String body =
//                "<head><style type=\"text/css\">body{background-color:#000;}</style></head>" +
//                        "<p style=\"font-size:" + size + "px;line-height:17px;color:#fff\">" +
//                        (streetlightEntity == null || streetlightEntity.getCity() == null? "": streetlightEntity.getCity().replace("市", "")) + "<br/>" +
//                        "温度:" + (sensorEntity == null || sensorEntity.getTemperature() == null? "-": sensorEntity.getTemperature()) + "℃<br/>" +
//                        "湿度:" + (sensorEntity == null || sensorEntity.getHumidity() == null? "-": sensorEntity.getHumidity()) + "%RH<br/>" +
//                        "亮度:" + (sensorEntity == null || sensorEntity.getBrightness() == null? "-": sensorEntity.getBrightness()) + "lux<br/>" +
//                        "风速:" + (sensorEntity == null || sensorEntity.getWindSpeed() == null? "-": sensorEntity.getWindSpeed()) + "m/s<br/>" +
//                        "CO2:" + (sensorEntity == null || sensorEntity.getEco2() == null? "-": sensorEntity.getEco2()) + "ppm<br/>" +
//                        "甲醛:" + (sensorEntity == null || sensorEntity.getEch2o() == null? "-": sensorEntity.getEch2o()) + "mg/m³<br/>" +
//                        "TVOC:" + (sensorEntity == null || sensorEntity.getTvoc() == null? "-": sensorEntity.getTvoc()) + "mg/m³<br/>" +
//                        "PM25:" + (sensorEntity == null || sensorEntity.getPm25() == null? "-": sensorEntity.getPm25()) + "mg/m³<br/>" +
//                        "PM10:" + (sensorEntity == null || sensorEntity.getPm10() == null? "-": sensorEntity.getPm10()) + "mg/m³<br/>";
//
//        //组装请求参数
//        SubTitleSet subTitleSet = new SubTitleSet();
//        subTitleSet.html = body;
//        subTitleSet.num = 1;
//
//        //清屏操作
//        lightemitUtils.clear(lightemitControlCode);
//        //清除播放列表
//        lightemitUtils.clearVideoPlay(lightemitControlCode);
//        //清除节目列表
//        lightemitUtils.clearPlayerTask(lightemitControlCode);
//        try{
//            lightemitUtils.subTitleSet(subTitleSet, lightemitControlCode, false);
//            return true;
//        }catch (Exception e){
//            return false;
//        }finally {
//            //一分钟后清除屏幕
//            new Timer().schedule(new TimerTask() {
//                @Override
//                public void run() {
//                    lightemitUtils.clear(lightemitControlCode);
//                    //清除播放列表
//                    lightemitUtils.clearVideoPlay(lightemitControlCode);
//                    //清除节目列表
//                    lightemitUtils.clearPlayerTask(lightemitControlCode);
//                    //推送最后命令
//                    lightemitUtils.sendLastCommand(lightemitControlCode);
//                }
//            }, 60*1000);
//        }
//    }*/
//
//    /*
//    æ›´æ–°è¯·æ±‚数据
//     */
//
//    public void updateRequestBody(String ledCode, String postBody) {
//        baseMapper.updateRequestBody(ledCode, postBody);
//    }
//
//    /*
//    æ ¹æ®led屏编码获取灯杆所有信息
//     */
//
//    public PoleStreetlightEntity getStreetlightByLedCode(String ledCode) {
//        return baseMapper.getStreetlightByLedCode(ledCode);
//    }
//
//    /*
//    æ ¹æ®led屏编码设置音量
//     */
//
//    @Async("taskExecutor")
//    public void setVolume(String lightemitControlCode, Integer volume) {
//        lightemitUtils.setVoiume(lightemitControlCode, volume);
//    }
//
//
//    public List<PoleLightemitEntity> listOfStreetlight(String streetlightId) {
//        return baseMapper.listOfStreetlight(streetlightId);
//    }
//
//
//    public List<PoleLightemitEntity> selectLedByStreetlightId(String streetlightId) {
//        return baseMapper.getLedByStreetlightId(streetlightId);
//    }
//
//    /*
//        ä¸Šä¼ æ°´å¹³æ»šåŠ¨å•è¡Œå­—å¹•
//         */
//    private void BuildHorizonSingSubTitleText(SubTitleSetEntity subTitleSetEntity){
//        //拼装LED屏幕设置请求body
//        SubTitleSet subTitleSet = new SubTitleSet();
//        subTitleSet.num = subTitleSetEntity.getNum() != null ? subTitleSetEntity.getNum(): subTitleSet.num;
//        subTitleSet.interval = subTitleSetEntity.getInterval() != null ? subTitleSetEntity.getInterval(): subTitleSet.interval;
//        subTitleSet.step = subTitleSetEntity.getStep() != null ? subTitleSetEntity.getStep(): subTitleSet.step;
//        subTitleSet.direction = subTitleSetEntity.getDirection() != null ? subTitleSetEntity.getDirection(): subTitleSet.direction;
//        subTitleSet.align = subTitleSetEntity.getAlign() != null ? subTitleSetEntity.getAlign(): subTitleSet.align;
//        //拼接html èƒŒæ™¯é»˜è®¤æ˜¾è‰²ä¸ºç™½è‰²
//        subTitleSet.html = "<head><style type=\"text/css\">body{background-color:" +
//                (subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor())? subTitleSetEntity.getColor(): "#000000") +
//                "}</style></head><i style=\"color:" +
//                (subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor())? subTitleSetEntity.getFontColor(): "#ffffff")
//                + "; font-size: " +
//                (subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize())? subTitleSetEntity.getFontSize(): "1")
//                + "em\">" + subTitleSetEntity.getContent() + "</i>";
//
//        //获取所有led数据
//        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
//        if (!poleLightemitControllers.isEmpty()) {
//            Iterator iterator = poleLightemitControllers.iterator();
//            while (iterator.hasNext()){
//                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
//                //清屏操作
//                lightemitUtils.clear(poleLightemitEntity.getLightemitControlCode());
//                //清除播放列表
//                lightemitUtils.clearVideoPlay(poleLightemitEntity.getLightemitControlCode());
//                //清除节目列表
//                lightemitUtils.clearPlayerTask(poleLightemitEntity.getLightemitControlCode());
//                //发送字幕设置请求
//                lightemitUtils.subTitleSet(subTitleSet, poleLightemitEntity.getLightemitControlCode(),true);
//            }
//        }
//    }
//
//    /*
//    ä¸Šä¼ åž‚直滚动单行字幕
//     */
//    private void BuildVerticalSingSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException {
//        //html地址
//        //获取所有led数据
//        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
//        if (!poleLightemitControllers.isEmpty()) {
//            Iterator iterator = poleLightemitControllers.iterator();
//            while (iterator.hasNext()) {
//                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
//
//                String lightemitControlCode = poleLightemitEntity.getLightemitControlCode();
//
//                //获取屏幕宽
//                Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
//                Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
//
//                String filenameTemp = path + userName + "_"+ lightemitControlCode + ".html";
//                File htmlFile = new File(filenameTemp);
//                if (!htmlFile.exists() || htmlFile.delete()) {
//                    htmlFile.createNewFile();
//                }
//
//                //若向下滚动,文字顺序相反
//                if(Constant.DOWN.equals(subTitleSetEntity.getDirection())){
//                    subTitleSetEntity.setContent(StringUtils.reverse(subTitleSetEntity.getContent()));
//                }
//
//                Map<String, Object> params = new HashMap<>();
//                params.put("direction", subTitleSetEntity.getDirection());
//                params.put("screenWidth", screenWidth);
//                params.put("screenHeight", screenHeight);
//                params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize())? subTitleSetEntity.getFontSize(): "1");
//                params.put("align", subTitleSetEntity.getAlign());
//                params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor())? subTitleSetEntity.getFontColor(): "#ffffff");
//                params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor())? subTitleSetEntity.getColor(): "#000000");
//                params.put("interval", subTitleSetEntity.getInterval() != null? subTitleSetEntity.getInterval(): 50);
//                params.put("step", subTitleSetEntity.getStep() != null? subTitleSetEntity.getStep(): 1);
//                params.put("num", subTitleSetEntity.getNum() != null? subTitleSetEntity.getNum(): -1);
//                params.put("contentArray", subTitleSetEntity.getContent().toCharArray());
//
//                String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params);
//
//                boolean flag = new FileUtil().writeToFile(body, filenameTemp);
//
//                if(flag){
//                    //清屏操作
//                    lightemitUtils.clear(lightemitControlCode);
//                    //清除播放列表
//                    lightemitUtils.clearVideoPlay(lightemitControlCode);
//                    //清除节目列表
//                    lightemitUtils.clearPlayerTask(lightemitControlCode);
//                    //推送
//                    lightemitUtils.postHtmlUseNginx(lightemitControlCode,userName);
//                }
//            }
//        }
//    }
//
//
//    /*
//    ä¸Šä¼ åž‚直滚动多行字幕
//     */
//    private void BuildVerticalMultiSubTitleText(SubTitleSetEntity subTitleSetEntity, String path, String userName) throws IOException {
//        //html地址
//        //获取所有led数据
//        Collection poleLightemitControllers = this.listByIds(Arrays.asList(subTitleSetEntity.getId()));
//        if (!poleLightemitControllers.isEmpty()) {
//            Iterator iterator = poleLightemitControllers.iterator();
//            while (iterator.hasNext()) {
//                PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
//
//                String lightemitControlCode = poleLightemitEntity.getLightemitControlCode();
//
//                //获取屏幕宽
//                Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
//                Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
//
//                String filenameTemp = path + userName + "_" + lightemitControlCode + ".html";
//                File htmlFile = new File(filenameTemp);
//                if (!htmlFile.exists() || htmlFile.delete()) {
//                    htmlFile.createNewFile();
//                }
//
//                Map<String, Object> params = new HashMap<>();
//                params.put("direction", subTitleSetEntity.getDirection());
//                params.put("screenWidth", screenWidth);
//                params.put("screenHeight", screenHeight);
//                params.put("fontSize", subTitleSetEntity.getFontSize() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontSize())? subTitleSetEntity.getFontSize(): "1");
//                params.put("align", subTitleSetEntity.getAlign());
//                params.put("fontColor", subTitleSetEntity.getFontColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getFontColor())? subTitleSetEntity.getFontColor(): "#ffffff");
//                params.put("backgroundColor", subTitleSetEntity.getColor() != null && StringUtils.isNotBlank(subTitleSetEntity.getColor())? subTitleSetEntity.getColor(): "#000000");
//                params.put("interval", subTitleSetEntity.getInterval() != null? subTitleSetEntity.getInterval(): 50);
//                params.put("step", subTitleSetEntity.getStep() != null? subTitleSetEntity.getStep(): 1);
//                params.put("num", subTitleSetEntity.getNum() != null? subTitleSetEntity.getNum(): -1);
//                params.put("contentArray", subTitleSetEntity.getContent().split("\n"));
//
//                String body = new HtmlTemplateUtils().renderPath("classpath:templates/lightemitTemplates/buildVerticalSingSubTitleTemplates.html", params);
//
//                boolean flag = new FileUtil().writeToFile(body, filenameTemp);
//
//                if (flag) {
//                    //清屏操作
//                    lightemitUtils.clear(lightemitControlCode);
//                    //清除播放列表
//                    lightemitUtils.clearVideoPlay(lightemitControlCode);
//                    //清除节目列表
//                    lightemitUtils.clearPlayerTask(lightemitControlCode);
//                    //推送
//                    lightemitUtils.postHtmlUseNginx(lightemitControlCode, userName);
//                }
//            }
//        }
//    }
//
//    @Override
//    public void xixunplaySetting(String lightemitControlCode) {
//        //获取屏幕宽
////        Integer screenWidth = Integer.valueOf(lightemitUtils.getScreenWidth(lightemitControlCode));
////        Integer screenHeight = Integer.valueOf(lightemitUtils.getScreenHeight(lightemitControlCode));
////        Source source = new Source();
////        Layer layer = new Layer();
////        Program pro = new Program();
////        TaskItem items = new TaskItem();
////        ProgramsTask task = new ProgramsTask();
////        Command payload = new Command();
////        XixunPlayer xixun = new XixunPlayer();
////        source.set_id(UUID.randomUUID().toString());//所有_id都可用UUID随机生成
////        source.setId(filename);//请求头拼接该ID为该资源的完整下载地址
////        source.set_type("Video");    //设置资源类型,其他资源类型请参考xixunplayer节目json说明文档
////        source.setFileExt(".mp4");    //资源后缀名
////        source.setHeight(screenHeight);        //资源高度
////        source.setWidth(screenWidth);        //资源宽度
////        source.setLeft(0);            //距左
////        source.setMd5("dd135d5d2d44d619a542db773ab529a4");
////        source.setMime("video/mp4");
////        source.setName(filename);
////        source.setPlayTime(0);    //播放起始时间
////        source.setSize(filesize);    //资源字节数,要精准
////        source.setTimeSpan(videoTime);        //该资源播放时长
////        source.setTop(0);            //距顶
////        List<Source> list = new ArrayList<Source>();
////        list.add(source);
////        layer.setSources(list);
////        pro.set_id(UUID.randomUUID().toString());
////        pro.setHeight(screenHeight);        //节目高度
////        List<Layer> list1=new ArrayList<Layer>();
////        list1.add(layer);
////        pro.setLayers(list1);
////        pro.setName("demo");    //节目名称
////        pro.setOthers(true);//如果为true,则该节目来自第三方接口,不是来自我们自己的web,二次开发请务必赋值为true
////        pro.setTotalSize(filesize);    //所有资源总字节数
////        pro.setVersion(0);            //高级节目=0,简易节目=2
////        pro.setWidth(screenWidth);        //节目宽度
////        items.set_id(UUID.randomUUID().toString());
////        items.set_program(pro);
////        items.setRepeatTimes(1);
////        items.setSchedules(null);//定时段,不做定时可为null
////        task.set_id(UUID.randomUUID().toString());
////        task.setName("这是一个示例");
////        List<TaskItem> list2=new ArrayList<TaskItem>();
////        list2.add(items);
////        task.setItems(list2);
////        payload.setId(UUID.randomUUID().toString());
////        //这里是下方的post回调地址,需要修改IP地址
////        payload.setNotificationURL("http://" + ip + ":" + port + "/machine-fast/serv/download/getJSON");
////        //资源下载链接的请求头
////        payload.setPreDownloadURL("http://" + ip + ":" + port + "/machine-fast/serv/download/downloadFile/");
////        payload.setTask(task);
////        xixun.set_id(UUID.randomUUID().toString());
////        xixun.setCommand(payload);
////        xixun.setType("commandXixunPlayer");    //命令固定类型,不可更改
////        String jsondata = new Gson().toJson(xixun);
////        lightemitUtils.clear(lightemitControlCode);
////        this.updateRequestBody(lightemitControlCode,jsondata);
////        lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode,jsondata);
//    }
//}
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/service/RoleService.java
@@ -81,6 +81,9 @@
    @Transactional(rollbackFor = Exception.class)
    public boolean addRole(RoleParam param) {
        if(param.getMenuIdList().isEmpty()){
            throw new BusinessException("权限参数异常");
        }
        Role role = new Role();
        role.setName(param.getName());
        role.setRemark(param.getRemark());
ximon-admin/src/main/java/com/sandu/ximon/admin/service/XiXunPlayerService.java
@@ -1,107 +1,132 @@
//package com.sandu.ximon.admin.service;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.google.gson.Gson;
//import com.google.gson.GsonBuilder;
//import com.sandu.common.service.impl.BaseServiceImpl;
//import com.sandu.ximon.admin.config.RealtimeServerBean;
//import com.sandu.ximon.admin.config.XiXunConfig;
//import com.sandu.ximon.admin.entity.*;
//import com.sandu.ximon.admin.security.SecurityUtils;
//import com.sandu.ximon.admin.utils.JsonUtil;
//import com.sandu.ximon.admin.utils.LightemitUtils;
//import com.sandu.ximon.dao.domain.PoleLightemitEntity;
//import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
//import com.sandu.ximon.dao.mapper.PoleXixunPlayerEntityMapper;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.text.SimpleDateFormat;
//import java.util.*;
//
//@Service
//@AllArgsConstructor
//public class XiXunPlayerService extends BaseServiceImpl<PoleXixunPlayerEntityMapper, PoleXixunPlayerEntity> {
//
//    private final PoleXixunPlayerEntityMapper poleXixunPlayerEntityMapper;
//    private final XiXunConfig config;
//    private final LightemitUtils lightemitUtils;
//    private final RealtimeServerBean realtimeServerBean;
//
//
//    public void insert(ProgramPro programPro, Long userId) {
package com.sandu.ximon.admin.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.config.XiXunConfig;
import com.sandu.ximon.admin.entity.*;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.JsonUtil;
import com.sandu.ximon.admin.utils.LightemitUtils;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
import com.sandu.ximon.dao.mapper.PoleXixunPlayerEntityMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@AllArgsConstructor
public class XiXunPlayerService extends BaseServiceImpl<PoleXixunPlayerEntityMapper, PoleXixunPlayerEntity> {
    private final PoleXixunPlayerEntityMapper poleXixunPlayerEntityMapper;
    private final XiXunConfig config;
    private final LightemitUtils lightemitUtils;
    private final RealtimeServerBean realtimeServerBean;
    private final PoleLightemitService poleLightemitService;
    public boolean insert(ProgramPro programPro) {
//        SimpleDateFormat sdf=new SimpleDateFormat("yy-MM-dd HH:mm:ss");
//        Date date = new Date();
////        Program program = new Program();
////        try {
////            program = JsonUtil.convertJsonStringToObject(json,Program.class);
////        } catch (Exception e) {
////            e.printStackTrace();
////        }
//        String json = JsonUtil.jsonObj2Sting(programPro);
//        PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity();
//        poleXixunPlayer.setProgramCode(programPro.get_id());
//        poleXixunPlayer.setProgramName(programPro.getName());
//        poleXixunPlayer.setHeight(programPro.getHeight());
//        poleXixunPlayer.setWidth(programPro.getWidth());
//        poleXixunPlayer.setTotalSize((float) programPro.getTotalSize()/1000000+"MB");
//        poleXixunPlayer.setRequestBody(json);
//        poleXixunPlayer.setCreatTime(sdf.format(date));
//        poleXixunPlayer.setCreateUserId(SecurityUtils.getClientId());
//
//        this.save(poleXixunPlayer);
//    }
//
//    public void videoXixunPlayer(long programId,Long[] lightemitIds) {
//
//        ProgramPro pro = new ProgramPro();
//        ItemPro items = new ItemPro();
//        TaskPro taskPro = new TaskPro();
//        CommandPro command = new CommandPro();
//        XixunPlayerPro xixun = new XixunPlayerPro();
//        PoleXixunPlayerEntity poleXixunPlayerEntity = new PoleXixunPlayerEntity();
//        items.set_id(UUID.randomUUID().toString());
//        QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("program_id",programId);
//        poleXixunPlayerEntity = this.getOne(queryWrapper);
//        String json = poleXixunPlayerEntity.getRequestBody();
//        Program program = new Program();
//        try {
//            pro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class);
//            program = JsonUtil.convertJsonStringToObject(json,Program.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        items.set_program(pro);
//        items.setRepeatTimes(1);
//        items.setSchedulePros(null);//定时段,不做定时可为null
//        taskPro.set_id(UUID.randomUUID().toString());
//        taskPro.setName(poleXixunPlayerEntity.getProgramName());
//        List<ItemPro> list2=new ArrayList<ItemPro>();
//        list2.add(items);
//        taskPro.setItems(list2);
//        command.setId(UUID.randomUUID().toString());
//        //这里是下方的post回调地址,需要修改IP地址
//        command.setNotificationURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/getJSON");
//        //资源下载链接的请求头
//        command.setPreDownloadURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/downliadFileById/");
//        command.setTask(taskPro);
//        xixun.set_id(UUID.randomUUID().toString());
//        xixun.setCommand(command);
//        xixun.setType("commandXixunPlayer");    //命令固定类型,不可更改
//
//
//        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
////        String jsondata = JSON.toJSONString(xixun);
//        String jsondata = gson.toJson(xixun);
//
////        Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds));
////
////        if(poleLightemitEntities != null){
////            for (PoleLightemitEntity entity: poleLightemitEntities) {
////                lightemitUtils.clear(entity.getLightemitControlCode());
////                poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata);
////                lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata);
////            }
////        }
//    }
//
//}
        String json = JsonUtil.jsonObj2Sting(programPro);
        PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity();
        poleXixunPlayer.setProgramCode(programPro.get_id());
        poleXixunPlayer.setProgramName(programPro.getName());
        poleXixunPlayer.setHeight(programPro.getHeight());
        poleXixunPlayer.setWidth(programPro.getWidth());
        poleXixunPlayer.setTotalSize((float) programPro.getTotalSize() / 1000000 + "MB");
        poleXixunPlayer.setRequestBody(json);
        //  poleXixunPlayer.setCreatTime(sdf.format(date));
        poleXixunPlayer.setCreateUserId(SecurityUtils.getClientId());
        return this.save(poleXixunPlayer);
    }
    public boolean deleteProgram(Long pid) {
        PoleXixunPlayerEntity byId = getById(pid);
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
        return removeById(pid);
    }
    public Object getByPid(Long pid) {
        PoleXixunPlayerEntity byId = getById(pid);
        if (byId == null) {
            throw new BusinessException("未找到该节目");
        }
        String json = byId.getRequestBody();
        ProgramPro programPro = new ProgramPro();
        try {
            programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return  programPro;
    }
    public void videoXixunPlayer(long programId, List<Long> lightemitIds) {
        ProgramPro pro = new ProgramPro();
        ItemPro items = new ItemPro();
        TaskPro taskPro = new TaskPro();
        CommandPro command = new CommandPro();
        XixunPlayerPro xixun = new XixunPlayerPro();
        PoleXixunPlayerEntity poleXixunPlayerEntity = new PoleXixunPlayerEntity();
        items.set_id(UUID.randomUUID().toString());
        QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("program_id", programId);
        poleXixunPlayerEntity = this.getOne(queryWrapper);
        String json = poleXixunPlayerEntity.getRequestBody();
        try {
            pro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
        items.set_program(pro);
        items.setRepeatTimes(1);
        items.setSchedulePros(null);//定时段,不做定时可为null
        taskPro.set_id(UUID.randomUUID().toString());
        taskPro.setName(poleXixunPlayerEntity.getProgramName());
        List<ItemPro> list2 = new ArrayList<>();
        list2.add(items);
        taskPro.setItems(list2);
        command.setId(UUID.randomUUID().toString());
        //这里是下方的post回调地址,需要修改IP地址
        command.setNotificationURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/getJSON");
        //资源下载链接的请求头
        command.setPreDownloadURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/downliadFileById/");
        command.setTask(taskPro);
        xixun.set_id(UUID.randomUUID().toString());
        xixun.setCommand(command);
        xixun.setType("commandXixunPlayer");    //命令固定类型,不可更改
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
//        String jsondata = JSON.toJSONString(xixun);
        String jsondata = gson.toJson(xixun);
        Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(lightemitIds);
        if(poleLightemitEntities != null){
            for (PoleLightemitEntity entity: poleLightemitEntities) {
                lightemitUtils.clear(entity.getLightemitControlCode());
                poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata);
                lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata);
            }
        }
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
@@ -1,308 +1,318 @@
//package com.sandu.ximon.admin.utils;
//
//import com.alibaba.fastjson.JSONObject;
//import com.google.gson.Gson;
//import com.sandu.ximon.admin.config.NginxConfigBean;
//import com.sandu.ximon.admin.config.RealtimeServerBean;
//import com.sandu.ximon.admin.service.PoleLightemitService;
//import com.sandu.ximon.admin.utils.request.*;
//import com.sandu.ximon.dao.domain.PoleLightemitEntity;
//import com.squareup.okhttp.*;
//import org.apache.commons.lang.StringEscapeUtils;
//import org.apache.commons.lang.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.ApplicationContext;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//
//@Component
//public class LightemitUtils {
//    @Autowired
//    RealtimeServerBean realtimeServerBean;
//
//    PoleLightemitService poleLightemitService;
//    @Autowired
//    ApplicationContext applicationContext;
//    @Autowired
//    NginxConfigBean nginxConfigBean;
//    //body封装编码
//    private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
//
//    private OkHttpClient client = new OkHttpClient();
//
//
package com.sandu.ximon.admin.utils;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.sandu.ximon.admin.config.NginxConfigBean;
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.service.PoleLightemitService;
import com.sandu.ximon.admin.utils.request.*;
import com.squareup.okhttp.*;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.io.IOException;
@Component
public class LightemitUtils {
    @Autowired
    RealtimeServerBean realtimeServerBean;
    @Autowired
    PoleLightemitService poleLightemitService;
    @Autowired
    ApplicationContext applicationContext;
    @Autowired
    NginxConfigBean nginxConfigBean;
    //body封装编码
    private final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
    private OkHttpClient client = new OkHttpClient();
//    public void init(){
//        //重新获取单例
//        poleLightemitService = applicationContext.getBean(PoleLightemitService.class);
//    }
//    /**
//     * post请求封装方法
//     * @param url url
//     * @param json body
//     * @return
//     */
//    public String post(String url, String json){
//        RequestBody body = RequestBody.create(JSON, json);
//        Request request = new Request.Builder()
//                .url(url)
//                .post(body)
//                .build();
//        try {
//            Response response = client.newCall(request).execute();
//            return response.body().string();
//        } catch (IOException e) {
//            LogUtils.error(e.getMessage());
//            return "";
//        }
//    }
//
//    /**
//     * èŽ·å–led屏宽度
//     * @param ledCode led屏编号
//     * @return
//     */
//    public String getScreenWidth(String ledCode){
//        String postBody = new Gson().toJson(new GetScreenWidth());
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //请求
//        String result =  post(url,postBody);
//        if(StringUtils.isNotBlank(result)){
//            try{
//                return JSONObject.parseObject(result).get("result").toString();
//            }catch (Exception e){
//                return "64";
//            }
//        }else{
//            return "64";
//        }
//    }
//
//    /**
//     * èŽ·å–led屏高度
//     * @param ledCode led屏编号
//     * @return
//     */
//    public String getScreenHeight(String ledCode){
//        String postBody = new Gson().toJson(new GetScreenHeight());
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //请求
//        String result =  post(url,postBody);
//        if(StringUtils.isNotBlank(result)){
//            try{
//                return JSONObject.parseObject(result).get("result").toString();
//            }catch (Exception e){
//                return "64";
//            }
//        }else{
//            return "64";
//        }
//    }
//
//    /**
//     * æ¸…屏操作
//     * @param ledCode
//     */
//    public void clear(String ledCode){
//        String postBody = new Gson().toJson(new Clear());
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //请求
////        poleLightemitService.updateRequestBody(ledCode, "");
//        String result =  post(url,postBody);
//    }
//
//    /**
//     * html传输至led屏
//     * @param ledCode
//     * @param username
//     */
//    public void postHtml(String ledCode, String username){
//
//        PostHtml postHtml = new PostHtml(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
//        String postBody = new Gson().toJson(postHtml);
//
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //保存led数据
//        poleLightemitService.updateRequestBody(ledCode, postBody);
//        //请求
//        String result =  post(url,postBody);
//    }
//    /**
//     * html传输至led屏, é€šè¿‡url获取html
//     * @param ledCode
//     * @param username
//     */
//    public void postHtmlUseNginx(String ledCode, String username){
//
//        PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
//        String postBody = new Gson().toJson(postHtml);
//
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //保存led数据
//        poleLightemitService.updateRequestBody(ledCode, postBody);
//        //请求
//        String result =  post(url,postBody);
//    }
//
//    /**
//     * è§†é¢‘传输至led屏
//     * @param screenWidth
//     * @param screenHeight
//     * @param filename
//     * @param ledCode
//     */
//    public void postVideo(String screenWidth, String screenHeight, String filename, String ledCode) {
//
//        //led开发板下载视频请求body
//        DownloadFileToLocal downloadFileToLocal = new DownloadFileToLocal();
//        downloadFileToLocal.url = realtimeServerBean.getUrl() + filename;
//        downloadFileToLocal.path += filename;
//
//        //led开发板下载视频请求
//        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(downloadFileToLocal));
//
//        //led开发板视频列表请求body
//        SetPlayList setPlayList = new SetPlayList();
//        setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/"+filename;
////        setPlayList.pathList[0] = "";
//        try{
//            setPlayList.width = Integer.valueOf(screenWidth);
//            setPlayList.height = Integer.valueOf(screenHeight);
//        }catch (Exception e){
//            return;
//        }
//        String postBody = new Gson().toJson(setPlayList);
//        //保存led数据
//        poleLightemitService.updateRequestBody(ledCode, postBody);
//        //led开发板视频列表请求
//        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
//    }
//
//    /**
//     * led屏字幕设置
//     * @param subTitleSet
//     * @param ledCode
//     */
//    public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
//        String postBody =  new Gson().toJson(subTitleSet);
//        if(isSave == true){
//            poleLightemitService.updateRequestBody(ledCode, postBody);
//        }
//        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
//    }
//
//    /**
//     * æ¸…除播放列表
//     * @param ledCode
//     */
//    public void clearVideoPlay(String ledCode) {
////        poleLightemitService.updateRequestBody(ledCode, "");
//        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearVideoPlay()));
//    }
//
//    /**
//     * æ¸…除节目列表
//     * @param ledCode
//     */
//    public void clearPlayerTask(String ledCode) {
////        poleLightemitService.updateRequestBody(ledCode, "");
//        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearPlayerTask()));
//    }
//
//    /**
//     * èŽ·å–led屏画面
//     * @param ledCode
//     */
//    public String getPicture(String ledCode) {
//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetPicture()));
//        //获取base64图片数据
//        if(StringUtils.isBlank(result)){
//            return "";
//        }
//        String re;
//
//        try{
//            re = JSONObject.parseObject(result).get("result").toString();
//        }catch (Exception e){
//            re = "0";
//        }
//
//        if(StringUtils.isBlank(re)){
//            return "";
//        }
//        //去除换行符
//        re.replaceAll("\r|\n*","");
//        return re;
//    }
//
//    /**
//     * åˆ¤æ–­led屏是否开启
//     * @param ledCode
//     * @return
//     */
//    public String getIsScreenOpen(String ledCode){
//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
//        //获取base64图片数据
//        if(StringUtils.isNotBlank(result)){
//            String re;
//            try{
//                re = JSONObject.parseObject(result).get("result").toString();
//            }catch (Exception e){
//                re = "false";
//            }
//            return re;
//        }else{
//            return "";
//        }
//    }
//
//    /*
//    å¯åЍxwalk
//     */
//    /*public void startActivity(String ledCode){
//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new StartActivity()));
//    }*/
//
//    /*
//    ä½¿ç”¨xwalk加载网页
//     */
//    /*public void callXwalkFn(String ledCode,String username){
//
//        CallXwalkFn callXwalkFn = new CallXwalkFn();
//
//        callXwalkFn.setArgUrl(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
//        String postBody = new Gson().toJson(callXwalkFn);
//
//        //请求地址
//        String url = realtimeServerBean.getCommand() + ledCode;
//        //请求
//        String result =  post(url,postBody);
//    }*/
//
//    /*
//   æŽ§åˆ¶å±å¹•开关
//    */
//    public String setScreenOpen(String ledCode, Boolean bool) {
//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new setScreenOpen(bool)));
//        //获取base64图片数据
//        if(StringUtils.isNotBlank(result)){
//            String re = "";
//            try{
//                re = JSONObject.parseObject(result).get("result").toString();
//            }catch (Exception e){
//                re = "false";
//            }
//            return re;
//        }else{
//            return "";
//        }
//    }
//
    /**
     * post请求封装方法
     *
     * @param url  url
     * @param json body
     * @return
     */
    public String post(String url, String json) {
        RequestBody body = RequestBody.create(JSON, json);
        Request request = new Request.Builder()
                .url(url)
                .post(body)
                .build();
        try {
            Response response = client.newCall(request).execute();
            return response.body().string();
        } catch (IOException e) {
            LogUtils.error(e.getMessage());
            return "";
        }
    }
    /**
     * èŽ·å–led屏宽度
     *
     * @param ledCode led屏编号
     * @return
     */
    public String getScreenWidth(String ledCode) {
        String postBody = new Gson().toJson(new GetScreenWidth());
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //请求
        String result = post(url, postBody);
        if (StringUtils.isNotBlank(result)) {
            try {
                return JSONObject.parseObject(result).get("result").toString();
            } catch (Exception e) {
                return "64";
            }
        } else {
            return "64";
        }
    }
    /**
     * èŽ·å–led屏高度
     *
     * @param ledCode led屏编号
     * @return
     */
    public String getScreenHeight(String ledCode) {
        String postBody = new Gson().toJson(new GetScreenHeight());
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //请求
        String result = post(url, postBody);
        if (StringUtils.isNotBlank(result)) {
            try {
                return JSONObject.parseObject(result).get("result").toString();
            } catch (Exception e) {
                return "64";
            }
        } else {
            return "64";
        }
    }
    /**
     * æ¸…屏操作
     *
     * @param ledCode
     */
    public void clear(String ledCode) {
        String postBody = new Gson().toJson(new Clear());
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //请求
//        poleLightemitService.updateRequestBody(ledCode, "");
        String result = post(url, postBody);
    }
    /**
     * html传输至led屏
     *
     * @param ledCode
     * @param username
     */
    public void postHtml(String ledCode, String username) {
        PostHtml postHtml = new PostHtml(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
        String postBody = new Gson().toJson(postHtml);
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //保存led数据
        poleLightemitService.updateRequestBody(ledCode, postBody);
        //请求
        String result = post(url, postBody);
    }
    /**
     * html传输至led屏, é€šè¿‡url获取html
     * @param ledCode
     * @param username
     */
    public void postHtmlUseNginx(String ledCode, String username){
        PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
        String postBody = new Gson().toJson(postHtml);
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //保存led数据
        poleLightemitService.updateRequestBody(ledCode, postBody);
        //请求
        String result =  post(url,postBody);
    }
    /**
     * è§†é¢‘传输至led屏
     * @param screenWidth
     * @param screenHeight
     * @param filename
     * @param ledCode
     */
    public void postVideo(String screenWidth, String screenHeight, String filename, String ledCode) {
        //led开发板下载视频请求body
        DownloadFileToLocal downloadFileToLocal = new DownloadFileToLocal();
        downloadFileToLocal.url = realtimeServerBean.getUrl() + filename;
        downloadFileToLocal.path += filename;
        //led开发板下载视频请求
        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(downloadFileToLocal));
        //led开发板视频列表请求body
        SetPlayList setPlayList = new SetPlayList();
        setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/"+filename;
//        setPlayList.pathList[0] = "";
        try{
            setPlayList.width = Integer.valueOf(screenWidth);
            setPlayList.height = Integer.valueOf(screenHeight);
        }catch (Exception e){
            return;
        }
        String postBody = new Gson().toJson(setPlayList);
        //保存led数据
        poleLightemitService.updateRequestBody(ledCode, postBody);
        //led开发板视频列表请求
        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
    }
    /**
     * led屏字幕设置
     * @param subTitleSet
     * @param ledCode
     */
    public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
        String postBody =  new Gson().toJson(subTitleSet);
        if(isSave == true){
            poleLightemitService.updateRequestBody(ledCode, postBody);
        }
        this.post(realtimeServerBean.getCommand() + ledCode, postBody);
    }
    /**
     * æ¸…除播放列表
     *
     * @param ledCode
     */
    public void clearVideoPlay(String ledCode) {
//        poleLightemitService.updateRequestBody(ledCode, "");
        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearVideoPlay()));
    }
    /**
     * æ¸…除节目列表
     *
     * @param ledCode
     */
    public void clearPlayerTask(String ledCode) {
//        poleLightemitService.updateRequestBody(ledCode, "");
        this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new ClearPlayerTask()));
    }
    /**
     * èŽ·å–led屏画面
     *
     * @param ledCode
     */
    public String getPicture(String ledCode) {
        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetPicture()));
        //获取base64图片数据
        if (StringUtils.isBlank(result)) {
            return "";
        }
        String re;
        try {
            re = JSONObject.parseObject(result).get("result").toString();
        } catch (Exception e) {
            re = "0";
        }
        if (StringUtils.isBlank(re)) {
            return "";
        }
        //去除换行符
        re.replaceAll("\r|\n*", "");
        return re;
    }
    /**
     * åˆ¤æ–­led屏是否开启
     *
     * @param ledCode
     * @return
     */
    public String getIsScreenOpen(String ledCode) {
        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new IsScreenOpen()));
        //获取base64图片数据
        if (StringUtils.isNotBlank(result)) {
            String re;
            try {
                re = JSONObject.parseObject(result).get("result").toString();
            } catch (Exception e) {
                re = "false";
            }
            return re;
        } else {
            return "";
        }
    }
    /*
    å¯åЍxwalk
     */
    /*public void startActivity(String ledCode){
        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new StartActivity()));
    }*/
    /*
    ä½¿ç”¨xwalk加载网页
     */
    /*public void callXwalkFn(String ledCode,String username){
        CallXwalkFn callXwalkFn = new CallXwalkFn();
        callXwalkFn.setArgUrl(realtimeServerBean.getUrl() + username + "_" + ledCode + ".html");
        String postBody = new Gson().toJson(callXwalkFn);
        //请求地址
        String url = realtimeServerBean.getCommand() + ledCode;
        //请求
        String result =  post(url,postBody);
    }*/
    /*
   æŽ§åˆ¶å±å¹•开关
    */
    public String setScreenOpen(String ledCode, Boolean bool) {
        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new setScreenOpen(bool)));
        //获取base64图片数据
        if (StringUtils.isNotBlank(result)) {
            String re = "";
            try {
                re = JSONObject.parseObject(result).get("result").toString();
            } catch (Exception e) {
                re = "false";
            }
            return re;
        } else {
            return "";
        }
    }
//    //发送最新的数据
//    public void sendLastCommand(String lightemitControlCode) {
//        PoleLightemitEntity poleLightemitEntity = poleLightemitService.selectByLightemitControlCode(lightemitControlCode);
@@ -311,68 +321,70 @@
//        }
//        this.post(realtimeServerBean.getCommand() + lightemitControlCode, poleLightemitEntity.getRequestBody());
//    }
//
//    /*
//    è®¾ç½®led音量
//     */
//    public void setVoiume(String ledCode,Integer volume){
//
//        SetVolume setVolume = new SetVolume();
//        setVolume.arg1 = volume;
//        String postBody = new Gson().toJson(setVolume);
//
//        //请求
//        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
//    }
//
//    /*
//    èŽ·å–led音量
//     */
//    /*public String getVoiume(String ledCode){
//        GetVolume getVolume = new GetVolume();
//        String postBody = new Gson().toJson(getVolume);
//
//        //请求
//        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
//        //请求
//        if(StringUtils.isNotBlank(result)){
//            try{
//                return JSONObject.parseObject(result).get("result").toString();
//            }catch (Exception e){
//                return "0";
//            }
//        }else{
//            return "0";
//        }
//    }
//*/
//    /**
//     * æŸ¥è¯¢å®šæ—¶
//     * @param ledCode
//     * @return
//     */
//    public String getTimeSchedule(String ledCode) {
//        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetTimeSchedule()));
//        //获取定时json数据
////        Map map = new Gson().fromJson(result,Map.class);
////        Gson gson = new Gson();
////        Task task =gson.fromJson((String)gson.fromJson(result,Map.class).get("task"),Task.class);
////        Schedules schedules =gson.fromJson((String)gson.fromJson(result,Map.class).get("schedule"),Schedules.class);
//        if(StringUtils.isBlank(result)){
//            return "";
//        }
//        String re;
//
//        //去除字符串中的\
//        re = StringEscapeUtils.unescapeJavaScript(result);
//        //去除字符串中的}"
//        re = re.replace("}\"","}");
//        //去除字符串中"{
//        re = re.replace("\"{","{");
//        re = re.replace("\"null\"","{}");
//        if(StringUtils.isBlank(re)){
//            return "";
//        }
//        return re;
//    }
//}
    /*
    è®¾ç½®led音量
     */
    public void setVoiume(String ledCode, Integer volume) {
        SetVolume setVolume = new SetVolume();
        setVolume.arg1 = volume;
        String postBody = new Gson().toJson(setVolume);
        //请求
        String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
    }
    /*
    èŽ·å–led音量
     */
    /*public String getVoiume(String ledCode){
        GetVolume getVolume = new GetVolume();
        String postBody = new Gson().toJson(getVolume);
        //请求
        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
        //请求
        if(StringUtils.isNotBlank(result)){
            try{
                return JSONObject.parseObject(result).get("result").toString();
            }catch (Exception e){
                return "0";
            }
        }else{
            return "0";
        }
    }
*/
    /**
     * æŸ¥è¯¢å®šæ—¶
     *
     * @param ledCode
     * @return
     */
    public String getTimeSchedule(String ledCode) {
        String result = this.post(realtimeServerBean.getCommand() + ledCode, new Gson().toJson(new GetTimeSchedule()));
        //获取定时json数据
//        Map map = new Gson().fromJson(result,Map.class);
//        Gson gson = new Gson();
//        Task task =gson.fromJson((String)gson.fromJson(result,Map.class).get("task"),Task.class);
//        Schedules schedules =gson.fromJson((String)gson.fromJson(result,Map.class).get("schedule"),Schedules.class);
        if (StringUtils.isBlank(result)) {
            return "";
        }
        String re;
        //去除字符串中的\
        re = StringEscapeUtils.unescapeJavaScript(result);
        //去除字符串中的}"
        re = re.replace("}\"", "}");
        //去除字符串中"{
        re = re.replace("\"{", "{");
        re = re.replace("\"null\"", "{}");
        if (StringUtils.isBlank(re)) {
            return "";
        }
        return re;
    }
}