2021与蓝度共同重构项目,服务端
liuhaonan
2022-03-14 228d1be133e0fd2f1f46a29af8bc9cbda3d18d74
熙讯接口新增
已修改4个文件
155 ■■■■■ 文件已修改
dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java
@@ -4,32 +4,33 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * led熙讯任务表
 *
 * @TableName led_schedule_xixun
 */
@TableName(value ="led_schedule_xixun")
@TableName(value = "led_schedule_xixun")
@Data
public class LedScheduleEntity implements Serializable {
    /**
     *
     *
     */
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     *
     *
     */
    private Long userId;
    /**
     *
     *
     */
    private Long clientId;
@@ -70,7 +71,7 @@
    private String schedule;
    /**
     *
     *
     */
    private String week;
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
@@ -65,7 +65,7 @@
    public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
        PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId());
        if (byId == null) {
            throw new BusinessException("参数错误");
            throw new BusinessException("未选择LED屏");
        }
//        QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("program_code", programPro.get_id());
@@ -236,7 +236,7 @@
                                bind -> {
                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode() == bind.getDeviceCode()) {
                                        led.setStreetlightId(bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------"+bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------" + bind.getPoleId());
                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                    }
                                }
@@ -259,7 +259,7 @@
                                bind -> {
                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode().equals(bind.getDeviceCode())) {
                                        led.setStreetlightId(bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------"+bind.getPoleId());
                                        System.out.println("有没有运行到这里?---------------" + bind.getPoleId());
                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                    }
                                }
@@ -274,7 +274,7 @@
                commonPage.setTotalPage(size / baseConditionVO.getPageSize());
            }
            return ResponseUtil.success(commonPage);
           // return ResponseUtil.success(list);
            // return ResponseUtil.success(list);
        }
//        return ResponseUtil.success(poleLightemitService.list(wrapper));
    }
@@ -355,7 +355,7 @@
    public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
        if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
            throw new BusinessException("参数错误");
            throw new BusinessException("音量范围为0---15");
        }
        Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setVolumeEntity.getIds()));
@@ -386,6 +386,21 @@
        return ResponseUtil.success(scheduleService.getSchedule(id));
    }
    @GetMapping("/listSchedule")
    public ResponseVO<Object> listSchedule(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        return ResponseUtil.success(scheduleService.listSchedule(baseConditionVO, keyword));
    }
    /**
     * 设置定时
     *
     * @param id
     * @param lightemitIds
     * @return
     */
    @PostMapping("/pushSchedule/{id}")
    public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
        scheduleService.ledschedulepush(id, lightemitIds);
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
@@ -3,7 +3,11 @@
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
import com.sandu.ximon.admin.config.RealtimeServerBean;
import com.sandu.ximon.admin.param.LEDScheduleParam_xixun;
@@ -38,32 +42,32 @@
    public boolean insert(LEDScheduleParam_xixun ledEntity) {
        LedScheduleEntity ledScheduleEntity = new LedScheduleEntity();
        BeanUtil.copyProperties(ledEntity,ledScheduleEntity);
        BeanUtil.copyProperties(ledEntity, ledScheduleEntity);
        ledScheduleEntity.setUserId(SecurityUtils.getClientId());
        Schedules schedules = new Schedules();
        Task task = new Task();
        TaskSchedules taskSchedules = new TaskSchedules();
        if(ledEntity.getStartTime() =="" || ledEntity.getEndTime() == "" || ledEntity.getStartTime() == null || ledEntity.getEndTime() ==null ){
        if (ledEntity.getStartTime() == "" || ledEntity.getEndTime() == "" || ledEntity.getStartTime() == null || ledEntity.getEndTime() == null) {
            schedules.setTimeType("All");
        }else {
        } else {
            schedules.setTimeType("Range");
            schedules.setStartTime(ledEntity.getStartTime());
            schedules.setEndTime(ledEntity.getEndTime());
        }
        if(ledEntity.getStartDate() =="" || ledEntity.getEndDate() == "" || ledEntity.getStartDate() == null || ledEntity.getEndDate() ==null ){
        if (ledEntity.getStartDate() == "" || ledEntity.getEndDate() == "" || ledEntity.getStartDate() == null || ledEntity.getEndDate() == null) {
            schedules.setDateType("All");
        }else {
        } else {
            schedules.setDateType("Range");
            schedules.setStartDate(ledEntity.getStartDate());
            schedules.setEndDate(ledEntity.getEndDate());
        }
        if(ledEntity.getWeek().length != 0){
        if (ledEntity.getWeek().length != 0) {
            schedules.setFilterType("Week");
            schedules.setWeekFilter(ledEntity.getWeek());
        }else {
        } else {
            schedules.setFilterType("None");
        }
        List list =new ArrayList();
        List list = new ArrayList();
        list.add(schedules);
        task.setSchedules(list);
        task.setCreateDate(ledEntity.getCreateDate());
@@ -79,12 +83,13 @@
        String json = JSON.toJSONString(taskSchedules, SerializerFeature.WriteMapNullValue);
//         String json = new Gson().toJson(taskSchedules);
        ledScheduleEntity.setSchedule(json);
       return this.save(ledScheduleEntity);
        return this.save(ledScheduleEntity);
    }
    /**
     * 定时推送
     *
     * @param scheduleId
     * @param lightemitIds
     */
@@ -96,38 +101,56 @@
//        String json = new Gson().toJson(sendCommand);
        Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(Arrays.asList(lightemitIds));
        if(poleLightemitEntities != null){
            for (PoleLightemitEntity entity: poleLightemitEntities) {
        if (poleLightemitEntities != null) {
            for (PoleLightemitEntity entity : poleLightemitEntities) {
                lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), ledScheduleEntity.getSchedule());
            }
        }
    }
    public boolean updateSchedule(LEDScheduleParam_xixun paramXixun){
        if(paramXixun.getId()==null){
    public boolean updateSchedule(LEDScheduleParam_xixun paramXixun) {
        if (paramXixun.getId() == null) {
            throw new BusinessException("参数错误");
        }
        LedScheduleEntity byId = getById(paramXixun.getId());
        if(byId==null){
        if (byId == null) {
            throw new BusinessException("未找到该定时数据");
        }
        boolean result=false;
       if( removeById(paramXixun.getId())){
           result =  insert(paramXixun);
       }
       return result;
        boolean result = false;
        if (removeById(paramXixun.getId())) {
            result = insert(paramXixun);
        }
        return result;
    }
    public LedScheduleEntity getSchedule(Integer id){
        if(id==null){
    public LedScheduleEntity getSchedule(Integer id) {
        if (id == null) {
            throw new BusinessException("参数错误");
        }
        LedScheduleEntity byId = getById(id);
        if(byId==null){
        if (byId == null) {
            throw new BusinessException("未找到该定时数据");
        }
       //List<Map> schedule = JSON.parseArray(byId.getSchedule(), List.class);
        //List<Map> schedule = JSON.parseArray(byId.getSchedule(), List.class);
        return byId;
    }
    public List listSchedule(BaseConditionVO baseConditionVO, String keyword) {
        LambdaQueryWrapper<LedScheduleEntity> eq = new LambdaQueryWrapper<>();
        PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
        if (SecurityUtils.getClientId() != null && clientService.findClientId()) {
            eq = Wrappers.lambdaQuery(LedScheduleEntity.class).eq(LedScheduleEntity::getUserId, SecurityUtils.getUserId());
        } else if (SecurityUtils.getClientId() != null && !clientService.findClientId()) {
            eq = Wrappers.lambdaQuery(LedScheduleEntity.class).eq(LedScheduleEntity::getClientId, SecurityUtils.getUserId());
        } else {
            eq = Wrappers.lambdaQuery(LedScheduleEntity.class);
        }
        if (!keyword.isEmpty()) {
            eq = eq.like(LedScheduleEntity::getName, keyword);
        }
        return list(eq);
    }
}
ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
@@ -15,6 +15,10 @@
import java.io.IOException;
/**
 * 熙讯屏幕控制
 */
@Component
public class LightemitUtils {
    @Autowired
@@ -32,7 +36,7 @@
    private OkHttpClient client = new OkHttpClient();
    public void init(){
    public void init() {
        //重新获取单例
        poleLightemitService = applicationContext.getBean(PoleLightemitService.class);
    }
@@ -117,7 +121,7 @@
        //请求
//        poleLightemitService.updateRequestBody(ledCode, "");
        String result = post(url, postBody);
        LogUtils.error("清屏结果:"+result);
        LogUtils.error("清屏结果:" + result);
    }
    /**
@@ -138,12 +142,14 @@
        //请求
        String result = post(url, postBody);
    }
    /**
     * html传输至led屏, 通过url获取html
     *
     * @param ledCode
     * @param username
     */
    public void postHtmlUseNginx(String ledCode, String username){
    public void postHtmlUseNginx(String ledCode, String username) {
        PostHtml postHtml = new PostHtml(nginxConfigBean.getUrl() + username + "_" + ledCode + ".html");
        String postBody = new Gson().toJson(postHtml);
@@ -153,11 +159,12 @@
        //保存led数据
        poleLightemitService.updateRequestBody(ledCode, postBody);
        //请求
        String result =  post(url,postBody);
        String result = post(url, postBody);
    }
    /**
     * 视频传输至led屏
     *
     * @param screenWidth
     * @param screenHeight
     * @param filename
@@ -175,12 +182,12 @@
        //led开发板视频列表请求body
        SetPlayList setPlayList = new SetPlayList();
        setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/"+filename;
        setPlayList.list[0] = "/data/data/com.xixun.xy.conn/files/local/abc/" + filename;
//        setPlayList.pathList[0] = "";
        try{
        try {
            setPlayList.width = Integer.valueOf(screenWidth);
            setPlayList.height = Integer.valueOf(screenHeight);
        }catch (Exception e){
        } catch (Exception e) {
            return;
        }
        String postBody = new Gson().toJson(setPlayList);
@@ -192,12 +199,13 @@
    /**
     * led屏字幕设置
     *
     * @param subTitleSet
     * @param ledCode
     */
    public void subTitleSet(SubTitleSet subTitleSet, String ledCode, Boolean isSave){
        String postBody =  new Gson().toJson(subTitleSet);
        if(isSave == true){
    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);
@@ -334,24 +342,24 @@
        //请求
        String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
        LogUtils.error("设置结果:-------------------"+result);
        LogUtils.error("设置结果:-------------------" + result);
    }
//    获取led音量
    public String getVoiume(String ledCode){
    //    获取led音量
    public String getVoiume(String ledCode) {
        GetVolume getVolume = new GetVolume();
        String postBody = new Gson().toJson(getVolume);
        //请求
        String result =  post(realtimeServerBean.getCommand() + ledCode,postBody);
        String result = post(realtimeServerBean.getCommand() + ledCode, postBody);
        //请求
        if(StringUtils.isNotBlank(result)){
            try{
        if (StringUtils.isNotBlank(result)) {
            try {
                return JSONObject.parseObject(result).get("result").toString();
            }catch (Exception e){
            } catch (Exception e) {
                return "0";
            }
        }else{
        } else {
            return "0";
        }
    }