From dda268997ca8f8a364f7c19b45d7a43a50a98efe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期二, 25 十月 2022 18:00:11 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java | 1300 ++++++++++++++++++++++++++--------------------------------
1 files changed, 590 insertions(+), 710 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java
index 3a816b4..922431b 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java
@@ -1,711 +1,591 @@
-//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> {
-//
-// @Autowired
-// PoleStreetlightLightemitService poleStreetlightLightemitService;
-// LightemitUtils lightemitUtils;
-// @Autowired
-// 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);
-// }
-//
-// /*@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);
+package com.sandu.ximon.admin.service;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.google.gson.Gson;
+import com.sandu.common.execption.BusinessException;
+import com.sandu.common.file.FileUploadDto;
+import com.sandu.common.service.impl.BaseServiceImpl;
+import com.sandu.common.util.SpringContextHolder;
+import com.sandu.ximon.admin.config.RealtimeServerBean;
+import com.sandu.ximon.admin.entity.*;
+import com.sandu.ximon.admin.param.PoleBindingParam;
+import com.sandu.ximon.admin.redis.DeviceRedisKey;
+import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.*;
+import com.sandu.ximon.admin.vo.EquipmentInfomation;
+import com.sandu.ximon.admin.vo.RedisDeviceStatus;
+import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.domain.PoleLightemitEntity;
+import com.sandu.ximon.dao.enums.OrderByEnums;
+import com.sandu.ximon.dao.enums.PoleBindingEnums;
+import com.sandu.ximon.dao.mapper.PoleLightemitEntityMapper;
+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
+ private PoleBindingService poleBindingService;
+
+ LightemitUtils lightemitUtils;
+ @Autowired
+ private RealtimeServerBean realtimeServerBean;
+ @Value("${server.port}")
+ private String port;
+ @Autowired
+ ApplicationContext applicationContext;
+
+ @Autowired
+ PoleLightemitEntityMapper poleLightemitDao;
+
+ @Autowired
+ LedSFileService xiXunFileService;
+
+ @Autowired
+ RedisUtils redisUtils;
+
+ @PostConstruct
+ public void init() {
+ //閲嶆柊鑾峰彇鍗曚緥
+ lightemitUtils = applicationContext.getBean(LightemitUtils.class);
+ }
+
+ /**
+ * 鐔欒list
+ *
+ * @param keyword
+ * @param isOnLine
+ * @return
+ */
+ public List<PoleLightemitEntity> listLed(String keyword, Integer order, Integer seq, boolean isOnLine) {
+ List<PoleLightemitEntity> poleLightemitEntityList;
+ //鎺掑簭瀛楁
+ String orderByResult = "id";
+ //姝e簭銆佸�掑彊
+ String orderBySeq = OrderByEnums.ASC.getCode();
+ if (order != null) {
+ switch (order) {
+ case 1:
+ orderByResult = OrderByEnums.LED_S_CODE.getCode();
+ break;
+ case 2:
+ orderByResult = OrderByEnums.LED_S_NAME.getCode();
+ break;
+ case 3:
+ orderByResult = OrderByEnums.LED_S_POLE_NAME.getCode();
+ break;
+ case 4:
+ orderByResult = OrderByEnums.LED_S_CREATE_TIME.getCode();
+ break;
+ default:
+ }
+ }
+ if (seq != null) {
+ switch (seq) {
+ case 1:
+ orderBySeq = " ASC";
+ break;
+ case 2:
+ orderBySeq = " DESC";
+ break;
+ default:
+ break;
+ }
+ }
+ //鎺掑簭鏂瑰紡
+ String orderBy = orderByResult + " " + orderBySeq;
+
+ //瓒呯
+ if (SecurityUtils.getClientId() == null) {
+ poleLightemitEntityList = poleLightemitDao.listLed(keyword, null, orderBy);
+ } else {
+ poleLightemitEntityList = poleLightemitDao.listLed(keyword, SecurityUtils.getUserId(), orderBy);
+ }
+
+ List<PoleLightemitEntity> temp = new ArrayList<>();
+ for (PoleLightemitEntity poleLightemitEntity : poleLightemitEntityList) {
+ //鏌ヨ璁惧鍦ㄧ嚎鐘舵��
+ boolean onLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode());
+ //鏌ヨ灞忓箷鐨勫紑鍚姸鎬�
+ String isOpen = lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode());
+ poleLightemitEntity.setIsOpen(String.valueOf(isOpen));
+ poleLightemitEntity.setOnLine(onLine);
+ if (!isOnLine || onLine) {
+ temp.add(poleLightemitEntity);
+ }
+ }
+ return temp;
+ }
+
+ /**
+ * 鐔欒璁惧鍒楄〃锛堢敤浜庨椤垫暟鎹粺璁★級
+ *
+ * @return
+ */
+ public List<PoleLightemitEntity> listLedOnHome() {
+ List<PoleLightemitEntity> poleLightemitEntityList;
+ //瓒呯
+ if (SecurityUtils.getClientId() == null) {
+ poleLightemitEntityList = poleLightemitDao.listLed(null, null, null);
+ } else {
+ poleLightemitEntityList = poleLightemitDao.listLed(null, SecurityUtils.getUserId(), null);
+ }
+
+ return poleLightemitEntityList;
+ }
+
+
+ /**
+ * 缁戝畾浣跨敤
+ *
+ * @param keyword
+ * @return
+ */
+ public List<PoleLightemitEntity> listLedOnBinding(String keyword) {
+ List<PoleLightemitEntity> poleLightemitEntityList;
+
+
+ //瓒呯
+ if (SecurityUtils.getClientId() == null) {
+ poleLightemitEntityList = poleLightemitDao.listLedOnBinding(keyword, null);
+ } else {
+ poleLightemitEntityList = poleLightemitDao.listLedOnBinding(keyword, SecurityUtils.getUserId());
+ }
+
+ for (PoleLightemitEntity poleLightemitEntity : poleLightemitEntityList) {
+ //鏌ヨ璁惧鍦ㄧ嚎鐘舵��
+ boolean onLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode());
+ //鏌ヨ灞忓箷鐨勫紑鍚姸鎬�
+ String isOpen = lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode());
+ poleLightemitEntity.setIsOpen(String.valueOf(isOpen));
+ poleLightemitEntity.setOnLine(onLine);
+ }
+ return poleLightemitEntityList;
+ }
+
+ /**
+ * 鍙栧嚭鍦ㄧ嚎鐨勭啓璁�
+ *
+ * @param list
+ * @return
+ */
+ public List<PoleLightemitEntity> ledOnline(List<PoleLightemitEntity> list) {
+ List<PoleLightemitEntity> onLineList = new ArrayList<>();
+ for (PoleLightemitEntity poleLightemitEntity : list) {
+// if(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true")){
+// poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true"));
// }
-//
-// }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) {
-// this.save(poleLightemit);
-// poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
-// }*/
-//
-//
-// /* public void updatePoleLightemit(PoleLightemitEntity poleLightemit) {
-// this.updateById(poleLightemit);
-// poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
-// }*/
-//
-// /**
-// * 鏌ヨ鏉冮檺鑼冨洿鍐呯殑鎵�鏈塴ed灞忎俊鎭�
-// * @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鐨刪tml
-// 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閮藉彲鐢║UID闅忔満鐢熸垚
-// source.setId(filename);//璇锋眰澶存嫾鎺ヨID涓鸿璧勬簮鐨勫畬鏁翠笅杞藉湴鍧�
-// source.set_type("Video"); //璁剧疆璧勬簮绫诲瀷锛屽叾浠栬祫婧愮被鍨嬭鍙傝�儀ixunplayer鑺傜洰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);//濡傛灉涓簍rue锛屽垯璇ヨ妭鐩潵鑷涓夋柟鎺ュ彛锛屼笉鏄潵鑷垜浠嚜宸辩殑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鍥炶皟鍦板潃锛岄渶瑕佷慨鏀笽P鍦板潃
-// 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);
-// 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>";
-//
-// //鑾峰彇鎵�鏈塴ed鏁版嵁
-// 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鍦板潃
-// //鑾峰彇鎵�鏈塴ed鏁版嵁
-// 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鍦板潃
-// //鑾峰彇鎵�鏈塴ed鏁版嵁
-// 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閮藉彲鐢║UID闅忔満鐢熸垚
-//// source.setId(filename);//璇锋眰澶存嫾鎺ヨID涓鸿璧勬簮鐨勫畬鏁翠笅杞藉湴鍧�
-//// source.set_type("Video"); //璁剧疆璧勬簮绫诲瀷锛屽叾浠栬祫婧愮被鍨嬭鍙傝�儀ixunplayer鑺傜洰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);//濡傛灉涓簍rue锛屽垯璇ヨ妭鐩潵鑷涓夋柟鎺ュ彛锛屼笉鏄潵鑷垜浠嚜宸辩殑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鍥炶皟鍦板潃锛岄渶瑕佷慨鏀笽P鍦板潃
-//// 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);
-// }
-//}
\ No newline at end of file
+ poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()));
+ boolean ledOnLine = lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode());
+ if (ledOnLine) {
+ poleLightemitEntity.setOnLine(true);
+ onLineList.add(poleLightemitEntity);
+ } else {
+ poleLightemitEntity.setOnLine(false);
+ }
+ }
+ return onLineList;
+ }
+
+
+ /**
+ * 璁剧疆鍦ㄧ嚎鐘舵��
+ *
+ * @param list
+ */
+ public void ledOnlineCheck(List<PoleLightemitEntity> list) {
+ for (PoleLightemitEntity poleLightemitEntity : list) {
+ poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()));
+ poleLightemitEntity.setOnLine(lightemitUtils.getLedOnLine(poleLightemitEntity.getLightemitControlCode()));
+ }
+ }
+
+
+ /**
+ * 鏌ヨ鍗曚釜LED
+ *
+ * @param lightControlCode
+ * @return
+ */
+ public PoleLightemitEntity getLedByLightControlCode(String lightControlCode) {
+ PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode));
+ Pole getpole = poleLightemitDao.getpole(lightControlCode);
+ if (xiXun == null) {
+ return null;
+ }
+ boolean isScreenOpen = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode());
+
+ xiXun.setIsOpen(lightemitUtils.getIsScreenOpen(lightControlCode));
+ xiXun.setOnLine(isScreenOpen);
+ xiXun.setStreetlightName(getpole.getPoleName());
+ xiXun.setStreetlightId(getpole.getId());
+
+ return xiXun;
+ }
+
+ /**
+ * 棣栭〉鐏潌缁戝畾淇℃伅
+ */
+ public EquipmentInfomation getLedByLightControlCodeInfo(String lightControlCode) {
+ EquipmentInfomation equipmentInfo = new EquipmentInfomation();
+ equipmentInfo.setEquipmentType("SLED");
+ if (lightControlCode == null || lightControlCode.trim().length() == 0) {
+ return equipmentInfo;
+ }
+
+ PoleLightemitEntity xiXun = getOne(Wrappers.lambdaQuery(PoleLightemitEntity.class).eq(PoleLightemitEntity::getLightemitControlCode, lightControlCode));
+ boolean isScreenOpen = false;
+ if (xiXun != null) {
+ equipmentInfo.setEquipmentCreateTime(xiXun.getCreateTime());
+ equipmentInfo.setEquipmentMac(xiXun.getLightemitControlCode());
+ equipmentInfo.setEquipmentName(xiXun.getLightemitName());
+ isScreenOpen = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode());
+ }
+ if (isScreenOpen) {
+ equipmentInfo.setEquipmentState("鍦ㄧ嚎");
+ } else {
+ equipmentInfo.setEquipmentState("绂荤嚎");
+ }
+
+ return equipmentInfo;
+ }
+
+
+ public void savePoleLightemit(PoleLightemitEntity poleLightemit) {
+ boolean save = this.save(poleLightemit);
+ // 缁戝畾鐏潌
+
+ if (save && poleLightemit.getStreetlightId() != null) {
+ PoleBindingParam poleBindingParam = new PoleBindingParam();
+ poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode());
+ poleBindingParam.setDeviceType(1);
+ poleBindingParam.setDeviceName(poleLightemit.getLightemitName());
+ poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam);
+ }
+
+ /**
+ * 鐔欐睕led鏂板鏃ュ織璁板綍寮�濮�
+ */
+ List<String> listCode = new ArrayList<>();
+ listCode.add(poleLightemit.getLightemitControlCode());
+ String content = "{灞忓箷id锛�" + poleLightemit.getLightemitId() + "锛� 灞忓箷鍚嶇О锛�" + poleLightemit.getLightemitName() + "锛� 灞忓箷缂栫爜锛�" + poleLightemit.getLightemitControlCode() + " }";
+ StoreOperationRecordsUtils.storeOperationData(listCode, null, "鐔欐睕LED鏂板", content);
+ /**
+ * 鐔欐睕led鏂板鏃ュ織璁板綍缁撴潫
+ */
+ // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
+ }
+
+
+ public void updatePoleLightemit(Long ledId, PoleLightemitEntity poleLightemit) {
+ PoleLightemitEntity byId = getById(ledId);
+ if (byId == null) {
+ throw new BusinessException("鏈壘鍒癓ED灞�");
+ }
+
+ if (SecurityUtils.getClientId() != null) {
+ boolean belong = SpringContextHolder.getBean(PoleBindingService.class).isBelong(byId.getLightemitControlCode(), PoleBindingEnums.XIXUN);
+ if (!belong) {
+ throw new BusinessException("璇ヨ澶囦笉灞炰簬鎮�,涓嶈兘淇敼璁惧淇℃伅");
+ }
+ }
+ poleLightemit.setLightemitId(ledId);
+ boolean b = this.updateById(poleLightemit);
+ // 缁戝畾鐏潌
+
+ if (b && poleLightemit.getStreetlightId() != null) {
+ //鍏堝垹闄ょ粦瀹氬叧绯�
+ poleBindingService.unBindPole(null, poleLightemit.getLightemitControlCode());
+ //鍐嶇粦瀹�
+ PoleBindingParam poleBindingParam = new PoleBindingParam();
+ poleBindingParam.setDeviceCode(poleLightemit.getLightemitControlCode());
+ poleBindingParam.setDeviceType(10);
+ poleBindingParam.setDeviceName(poleLightemit.getLightemitName());
+ poleBindingService.bindPole(poleLightemit.getStreetlightId(), poleBindingParam);
+ }
+
+ /**
+ * 鐔欐睕led缂栬緫鏃ュ織璁板綍寮�濮�
+ */
+ List<String> listCode = new ArrayList<>();
+ listCode.add(byId.getLightemitControlCode());
+ String content = "{灞忓箷id锛�" + byId.getLightemitId() + "锛� 灞忓箷鍘熷悕锛�" + byId.getLightemitName() + "锛� 灞忓箷鍚嶇О锛�" + poleLightemit.getLightemitName() + "锛� 灞忓箷缂栫爜锛�" + byId.getLightemitControlCode() + " }";
+ StoreOperationRecordsUtils.storeOperationData(listCode, null, "鐔欐睕LED缂栬緫", content);
+ /**
+ * 鐔欐睕led缂栬緫鏃ュ織璁板綍缁撴潫
+ */
+ // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
+ }
+
+ public boolean deletePoleLightemit(List<Long> ledIds) {
+
+ List<PoleLightemitEntity> poleLightemitEntities = listByIds(ledIds);
+ if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) {
+ throw new BusinessException("璁惧涓嶅瓨鍦�");
+ }
+
+ List<String> listCode = new ArrayList<>();
+ // 鍒犻櫎璁惧缁戝畾
+ if (poleLightemitEntities != null && poleLightemitEntities.size() != 0) {
+ for (PoleLightemitEntity poleLightemitEntitie : poleLightemitEntities) {
+ if (poleLightemitEntitie.getLightemitControlCode() != null) {
+ //鍒犻櫎缁戝畾鍏崇郴//鍏堝垹闄ょ粦瀹氬叧绯�
+ listCode.add(poleLightemitEntitie.getLightemitControlCode());
+ poleBindingService.unBindPole(poleLightemitEntitie.getLightemitControlCode());
+ }
+ }
+ }
+ //鍒犻櫎璁惧
+ boolean b = removeByIds(ledIds);
+
+ /**
+ * 鐔欐睕led鍒犻櫎鏃ュ織璁板綍寮�濮�
+ */
+ List<String> nameList = new ArrayList<>();
+ for (PoleLightemitEntity poleLightemitEntitie : poleLightemitEntities) {
+ nameList.add(poleLightemitEntitie.getLightemitName());
+ }
+
+ String content = "{鍒犻櫎鐔欐睕LED鐨勮澶囦俊鎭細" + nameList.toString() + " }";
+ StoreOperationRecordsUtils.storeOperationData(listCode, null, "鐔欐睕LED鍒犻櫎", content);
+ /**
+ * 鐔欐睕led鍒犻櫎鏃ュ織璁板綍缁撴潫
+ */
+ return b;
+ // poleStreetlightLightemitService.saveStreetlightLightemit(poleLightemit.getLightemitId(),poleLightemit.getStreetlightId());
+ }
+
+ /**
+ * led涓婁紶鍥剧墖
+ *
+ * @param lightemitControlCode
+ * @param path
+ * @param filenameList
+ * @param userName
+ * @throws IOException
+ */
+ @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鐨刪tml
+ 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涓婁紶瑙嗛
+ *
+ * @param lightemitControlCode
+ */
+ @Async("taskExecutor")
+ public String videoUpload(String lightemitControlCode, FileUploadDto fileUploadDto, Integer type) {
+ //鑾峰彇灞忓箷瀹�
+ String screenWidth = lightemitUtils.getScreenWidth(lightemitControlCode);
+ String screenHeight = lightemitUtils.getScreenHeight(lightemitControlCode);
+
+ //鍙戦�佽棰戣嚦寮�鍙戞澘骞舵挱鏀�
+ String fileUrl = fileUploadDto.getFileUrl();
+ String[] split = fileUrl.split("/");
+ String id = split[split.length - 1];
+ String result = this.videoXixunPlayer(lightemitControlCode, id, fileUploadDto.getFileSize(), fileUploadDto.getMd5(), type, fileUploadDto.getFileType(), 999999);
+
+ LogUtils.error("涓婁紶鎾斁缁撴灉:" + result);
+ return result;
+ }
+
+
+ @Async("taskExecutor")
+ public String videoXixunPlayer(String lightemitControlCode, String filename, Long filesize, String md5, Integer type, String fileType, 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();
+ //鎵�鏈塤id閮藉彲鐢║UID闅忔満鐢熸垚
+ source.set_id(UUID.randomUUID().toString());
+ //璇锋眰澶存嫾鎺ヨID涓鸿璧勬簮鐨勫畬鏁翠笅杞藉湴鍧�
+ source.setId(filename);
+ if (type == 1) {
+ //璁剧疆璧勬簮绫诲瀷锛屽叾浠栬祫婧愮被鍨嬭鍙傝�儀ixunplayer鑺傜洰json璇存槑鏂囨。
+ source.set_type("Video");
+ source.setMime("video/mp4");
+ } else {
+ source.set_type("Image");
+ source.setMime("image/jpeg");
+ }
+ //璧勬簮鍚庣紑鍚�
+ source.setFileExt(fileType);
+ //璧勬簮楂樺害
+ source.setHeight(screenHeight);
+ //璧勬簮瀹藉害
+ source.setWidth(screenWidth);
+ //璺濆乏
+ source.setLeft(0);
+ source.setMd5(md5);
+ 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("鏂囦欢涓婁紶鎾斁"); //鑺傜洰鍚嶇О
+ pro.setOthers(true);//濡傛灉涓簍rue锛屽垯璇ヨ妭鐩潵鑷涓夋柟鎺ュ彛锛屼笉鏄潵鑷垜浠嚜宸辩殑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鍥炶皟鍦板潃锛岄渶瑕佷慨鏀笽P鍦板潃
+ command.setNotificationURL("");
+ //璧勬簮涓嬭浇閾炬帴鐨勮姹傚ご
+ command.setPreDownloadURL("https://ximonsmart.oss-cn-shanghai.aliyuncs.com/");
+ command.setTask(task);
+ xixun.set_id(UUID.randomUUID().toString());
+ xixun.setCommand(command);
+ xixun.setType("commandXixunPlayer"); //鍛戒护鍥哄畾绫诲瀷锛屼笉鍙洿鏀�
+ String jsondata = new Gson().toJson(xixun);
+ String clearResult = lightemitUtils.clear(lightemitControlCode);
+ if (clearResult.contains("does not exist")) {
+ return "鎺ㄩ�佸け璐�";
+ } else {
+ poleLightemitDao.updateRequestBody(lightemitControlCode, jsondata);
+ String post = lightemitUtils.post(realtimeServerBean.getCommand() + lightemitControlCode, jsondata);
+ LogUtils.error("缁撴灉:" + post);
+ //{"_type":"success","_id":"ce8dc3ff-dc88-43b7-8f55-60abd8700f1a","timestamp":1653555160535}
+ if (post.startsWith("{") && post.endsWith("}") && post.contains("_type\":\"success")) {
+ return "鎺ㄩ�佹垚鍔�";
+ } else {
+ return "鎺ㄩ�佸け璐�";
+ }
+
+ }
+ }
+
+ /**
+ * 鏇存柊璇锋眰鏁版嵁
+ *
+ * @param ledCode
+ * @param postBody
+ */
+ public void updateRequestBody(String ledCode, String postBody) {
+ baseMapper.updateRequestBody(ledCode, postBody);
+ }
+
+
+ /**
+ * 鏍规嵁led灞忕紪鐮佽缃煶閲�
+ *
+ * @param lightemitControlCode
+ * @param volume
+ */
+ @Async("taskExecutor")
+ public void setVolume(String lightemitControlCode, Integer volume) {
+ lightemitUtils.setVoiume(lightemitControlCode, volume);
+ }
+
+ /**
+ * 鏍规嵁led灞忕紪鐮佽缃寒搴�
+ *
+ * @param lightemitControlCode
+ * @param brightness
+ */
+ @Async("taskExecutor")
+ public void setBrightness(String lightemitControlCode, Integer brightness) {
+ lightemitUtils.setBrightness(lightemitControlCode, brightness);
+ }
+
+ public Object getProgram(Long lightemitId) {
+ PoleLightemitEntity xiXun = getById(lightemitId);
+
+ String requestBody = xiXun.getRequestBody();
+ if (requestBody == null || requestBody.isEmpty()) {
+ throw new BusinessException("鏈壘鍒拌妭鐩�");
+ }
+
+ Map map = JSON.parseObject(requestBody, Map.class);
+ return map;
+ }
+
+
+ /**
+ * 鍚慠edis涓瓨鍏ヨ澶囩姸鎬�
+ */
+ public void setCacheData() {
+ list().forEach(
+ xiXun -> {
+ RedisDeviceStatus deviceStatus = new RedisDeviceStatus();
+ deviceStatus.setDeviceId(xiXun.getLightemitControlCode());
+ boolean ledOnLine = lightemitUtils.getLedOnLine(xiXun.getLightemitControlCode());
+ if (ledOnLine) {
+ deviceStatus.setStatus(0);
+ } else {
+ deviceStatus.setStatus(1);
+ }
+ redisUtils.set(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode(), JSON.toJSONString(deviceStatus));
+// redisUtils.delete(DeviceRedisKey.XIXUN + xiXun.getLightemitControlCode());
+ }
+ );
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.3