2021与蓝度共同重构项目,服务端
zhanzhiqin
2022-05-26 4e91adbb41c89688fe5b0ef03807cfe748a7d59d
ximon-admin/src/main/java/com/sandu/ximon/admin/service/XiXunPlayerService.java
@@ -69,6 +69,20 @@
    }
    public boolean insert(ProgramPro programPro) {
        programPro.getLayers().forEach(
                layerPro -> {
                    layerPro.getSources().forEach(
                            sourcePro -> {
                                long fileId = Long.parseLong(sourcePro.getId());
                                LedSFile file = xiXunFileService.getById(fileId);
                                String fileUrl = file.getFileUrl();
                                String[] split = fileUrl.split("/");
                                sourcePro.setId(split[split.length - 1]);
                                sourcePro.setMd5(file.getMd5());
                            }
                    );
                }
        );
        String json = JsonUtil.jsonObj2Sting(programPro);
        PoleXixunPlayerEntity poleXixunPlayer = new PoleXixunPlayerEntity();
        poleXixunPlayer.setProgramCode(programPro.get_id());
@@ -148,43 +162,15 @@
    }
//    public Object getProgram(String json) {
////        PoleXixunPlayerEntity byId = getById(pid);
//        List<Long> fileIds = new ArrayList<>();
//        List<LedSFile> file = new ArrayList<>();
//        if (json == null) {
//            throw new BusinessException("未找到该节目");
//        }
//        ProgramPro programPro = new ProgramPro();
//        try {
//            programPro = JsonUtil.convertJsonStringToObject(json, ProgramPro.class);
//            programPro.setProgramId(pid);
//            programPro.setScreenShot(byId.getScreenShot());
//            programPro.getLayers().forEach(
//                    layerPro -> {
//                        layerPro.getSources().forEach(
//                                sourcePro -> {
//                                    long fileId = Long.parseLong(sourcePro.getId());
//                                    file.add(xiXunFileService.getById(fileId));
//                                }
//                        );
//                    }
//            );
//            programPro.setFileList(file);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return programPro;
//    }
    /**
     * 推送节目
     *
     * @param programId
     * @param lightemitIds
     */
    public void videoXixunPlayer(long programId, List<Long> lightemitIds) {
    public List<Map> videoXixunPlayer(long programId, List<Long> lightemitIds) {
        //记录操作结果
        List<Map> mapList = new ArrayList<>();
        ProgramPro pro = new ProgramPro();
        ItemPro items = new ItemPro();
@@ -214,10 +200,10 @@
        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");
//        //这里是下方的post回调地址,需要修改IP地址
        command.setNotificationURL("");
        //资源下载链接的请求头
        command.setPreDownloadURL("http://" + config.getIp() + ":" + config.getPort() + "/machine-fast/serv/download/downliadFileById/");
        command.setPreDownloadURL("https://ximonsmart.oss-cn-shanghai.aliyuncs.com/");
        command.setTask(taskPro);
        xixun.set_id(UUID.randomUUID().toString());
        xixun.setCommand(command);
@@ -231,11 +217,29 @@
        Collection<PoleLightemitEntity> poleLightemitEntities = poleLightemitService.listByIds(lightemitIds);
        if (poleLightemitEntities != null) {
            Map map;
            for (PoleLightemitEntity entity : poleLightemitEntities) {
                lightemitUtils.clear(entity.getLightemitControlCode());
                poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata);
                String post = lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata);
                LogUtils.error("结果:" + post);
                map = new LinkedHashMap();
                String clearResult = lightemitUtils.clear(entity.getLightemitControlCode());
                if (clearResult.contains("does not exist")) {
                    map.put("LightemitId", entity.getLightemitId());
                    map.put("Result", "失败");
                    mapList.add(map);
                } else {
                    poleLightemitService.updateRequestBody(entity.getLightemitControlCode(), jsondata);
                    String post = lightemitUtils.post(realtimeServerBean.getCommand() + entity.getLightemitControlCode(), jsondata);
                    //{"_type":"success","_id":"ce8dc3ff-dc88-43b7-8f55-60abd8700f1a","timestamp":1653555160535}
                    if (post.startsWith("{") && post.endsWith("}") && post.contains("_type\":\"success")) {
                        map.put("LightemitId", entity.getLightemitId());
                        map.put("Result", "成功");
                        mapList.add(map);
                    } else {
                        map.put("LightemitId", entity.getLightemitId());
                        map.put("Result", "失败");
                        mapList.add(map);
                    }
                    LogUtils.error("结果:" + post);
                }
            }
        }
@@ -255,6 +259,8 @@
        /**
         * 熙汛节目推送日志记录结束
         */
        return mapList;
    }
@@ -314,7 +320,7 @@
                    /**
                     * 熙汛大气数据推送日志记录开始
//                     */
                     //                     */
//                    String content = "{设备code:" + lightemitControlCode
//                            + ", 推送内容:" + body
//                            + " }";