From 228d1be133e0fd2f1f46a29af8bc9cbda3d18d74 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期一, 14 三月 2022 17:11:31 +0800
Subject: [PATCH] 熙讯接口新增

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java |   25 ++++++-
 dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java             |   17 +++--
 ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java |   69 +++++++++++++++-------
 ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java       |   44 ++++++++------
 4 files changed, 101 insertions(+), 54 deletions(-)

diff --git a/dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java b/dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java
index b39d7af..5e29e8f 100644
--- a/dao/src/main/java/com/sandu/ximon/dao/domain/LedScheduleEntity.java
+++ b/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;
 
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
index 7fadc51..99d01af 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java
+++ b/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);
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
index 6acaf6d..e090934 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedScheduleService.java
+++ b/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);
+    }
+
 }
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
index b01c089..460f387 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/LightemitUtils.java
+++ b/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浼犺緭鑷砽ed灞�, 閫氳繃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);
     }
 
     /**
      * 瑙嗛浼犺緭鑷砽ed灞�
+     *
      * @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";
         }
     }

--
Gitblit v1.9.3