From 0350b21561519f5cab9a29645fac67dd906470fd Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期五, 01 四月 2022 17:51:05 +0800
Subject: [PATCH] c3上报具体处理

---
 ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 47 insertions(+), 12 deletions(-)

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 257dff5..9f946e2 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
@@ -17,11 +17,13 @@
 import com.sandu.ximon.admin.security.SecurityUtils;
 import com.sandu.ximon.admin.service.*;
 import com.sandu.ximon.admin.utils.LightemitUtils;
+import com.sandu.ximon.dao.domain.Pole;
 import com.sandu.ximon.dao.domain.PoleBinding;
 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.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.*;
@@ -42,6 +44,7 @@
     private final LightemitUtils lightemitUtils;
     private final LedScheduleService scheduleService;
     private final PoleBindingService bindingService;
+    private final PoleService poleService;
     // private final ListPageUtil listPageUtil;
 
     /**
@@ -60,10 +63,10 @@
      */
     @PostMapping("/updateProgram")
     // @RequiresPermissions("pole:polexixunplayer:update")
-    public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
+    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());
@@ -141,8 +144,8 @@
      * @param lightemitIds
      * @return
      */
-    @GetMapping("/pushToXixun/{pid}")
-    public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
+    @PostMapping("/pushToXixun/{pid}")
+    public ResponseVO<Object> pushByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
         xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
         return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
     }
@@ -229,11 +232,13 @@
         if (isOnLine) {
             List<PoleLightemitEntity> results = poleLightemitService.ledOnline(list);
             results.forEach(
-                    led->{
+                    led -> {
                         bindings.forEach(
-                                bind->{
-                                    if(bind.getDeviceCode()!=null&&led.getLightemitControlCode()==bind.getDeviceCode()){
+                                bind -> {
+                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode() == bind.getDeviceCode()) {
                                         led.setStreetlightId(bind.getPoleId());
+                                        System.out.println("鏈夋病鏈夎繍琛屽埌杩欓噷?---------------" + bind.getPoleId());
+                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                     }
                                 }
                         );
@@ -250,17 +255,27 @@
         } else {
             poleLightemitService.ledOnlineCheck(list);
             list.forEach(
-                    led->{
+                    led -> {
                         bindings.forEach(
-                                bind->{
-                                    if(bind.getDeviceCode()!=null&&led.getLightemitControlCode().equals(bind.getDeviceCode())){
+                                bind -> {
+                                    if (bind.getDeviceCode() != null && led.getLightemitControlCode().equals(bind.getDeviceCode())) {
                                         led.setStreetlightId(bind.getPoleId());
+                                        System.out.println("鏈夋病鏈夎繍琛屽埌杩欓噷?---------------" + bind.getPoleId());
+                                        led.setStreetlightName(poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, bind.getPoleId())).getPoleName());
                                     }
                                 }
                         );
                     }
             );
-            return ResponseUtil.success(list);
+            CommonPage commonPage = CommonPage.restPage(list);
+            int size = list.size();
+            commonPage.setTotal((long) size);
+            commonPage.setTotalPage(size / baseConditionVO.getPageSize() + 1);
+            if (size % baseConditionVO.getPageSize() == 0) {
+                commonPage.setTotalPage(size / baseConditionVO.getPageSize());
+            }
+            return ResponseUtil.success(commonPage);
+            // return ResponseUtil.success(list);
         }
 //        return ResponseUtil.success(poleLightemitService.list(wrapper));
     }
@@ -341,7 +356,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()));
@@ -367,11 +382,31 @@
         return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
     }
 
+    @PostMapping("/deleteSchedule")
+    public ResponseVO<Object> deleteSchedule(@RequestBody List<Integer> ids) {
+        return ResponseUtil.success(scheduleService.removeByIds(ids));
+    }
+
     @GetMapping("/getSchedule/{id}")
     public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
         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);

--
Gitblit v1.9.3