From 7a7dfbbdf34cfe5765f8167313bd29661500cd49 Mon Sep 17 00:00:00 2001
From: liuhaonan <konodioda2333@vip.qq.com>
Date: 星期二, 01 三月 2022 15:09:36 +0800
Subject: [PATCH] 功能完善
---
/dev/null | 97 ----------------
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/XiXunController.java | 184 ++++++++++++++++++------------
ximon-admin/src/main/java/com/sandu/ximon/admin/param/SetScreenOpenParam.java | 17 ++
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleLightemitService.java | 26 +++-
4 files changed, 145 insertions(+), 179 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 adf0fc1..90324d1 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
@@ -1,17 +1,18 @@
package com.sandu.ximon.admin.controller;
import cn.hutool.core.util.StrUtil;
-import cn.hutool.system.UserInfo;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
+import com.sandu.common.domain.CommonPage;
import com.sandu.common.domain.ResponseVO;
import com.sandu.common.execption.BusinessException;
import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.util.ResponseUtil;
import com.sandu.ximon.admin.entity.ProgramPro;
import com.sandu.ximon.admin.param.LEDScheduleParam_xixun;
+import com.sandu.ximon.admin.param.SetScreenOpenParam;
import com.sandu.ximon.admin.param.SetVolumeParam;
import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.service.ClientService;
@@ -19,7 +20,6 @@
import com.sandu.ximon.admin.service.PoleLightemitService;
import com.sandu.ximon.admin.service.XiXunPlayerService;
import com.sandu.ximon.admin.utils.LightemitUtils;
-import com.sandu.ximon.admin.utils.ListPageUtil;
import com.sandu.ximon.dao.domain.PoleLightemitEntity;
import com.sandu.ximon.dao.domain.PoleXixunPlayerEntity;
import com.sandu.ximon.dao.enums.AdministratorEnums;
@@ -27,8 +27,6 @@
import org.springframework.web.bind.annotation.*;
import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* @Author liuhaonan
@@ -45,59 +43,64 @@
private final PoleLightemitService poleLightemitService;
private final LightemitUtils lightemitUtils;
private final LedScheduleService scheduleService;
- // private final ListPageUtil listPageUtil;
+ // private final ListPageUtil listPageUtil;
/**
* 鏂板鑺傜洰
+ *
* @param programPro
* @return
*/
@PostMapping("/addProgram")
- public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro){
- return ResponseUtil.success(xiXunPlayerService.insert(programPro));
+ public ResponseVO<Object> addProgram(@RequestBody ProgramPro programPro) {
+ return ResponseUtil.success(xiXunPlayerService.insert(programPro));
}
/**
* 淇敼
*/
@PostMapping("/updateProgram")
- // @RequiresPermissions("pole:polexixunplayer:update")
- public ResponseVO<Object> update(@RequestBody ProgramPro programPro){
+ // @RequiresPermissions("pole:polexixunplayer:update")
+ public ResponseVO<Object> update(@RequestBody ProgramPro programPro) {
PoleXixunPlayerEntity byId = xiXunPlayerService.getById(programPro.getProgramId());
- if(byId==null){
- throw new BusinessException("鍙傛暟閿欒");
+ if (byId == null) {
+ throw new BusinessException("鍙傛暟閿欒");
}
// QueryWrapper<PoleXixunPlayerEntity> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("program_code", programPro.get_id());
- boolean insert=false;
- if(xiXunPlayerService.removeById(programPro.getProgramId())){
- insert = xiXunPlayerService.insert(programPro);
- };
- return ResponseUtil.success(insert);
+ boolean insert = false;
+ if (xiXunPlayerService.removeById(programPro.getProgramId())) {
+ insert = xiXunPlayerService.insert(programPro);
+ }
+ ;
+ return ResponseUtil.success(insert);
}
/**
* 鍒犻櫎鑺傜洰
+ *
* @param pid
* @return
*/
@PostMapping("/deleteProgram/{pid}")
- public ResponseVO<Object> deleteProgram(@PathVariable Long pid){
+ public ResponseVO<Object> deleteProgram(@PathVariable Long pid) {
return ResponseUtil.success(xiXunPlayerService.deleteProgram(pid));
}
/**
* 鑾峰彇鑺傜洰璇︽儏
+ *
* @param pid
* @return
*/
@GetMapping("/getByPid/{pid}")
- public ResponseVO<Object> getByPid(@PathVariable Long pid){
+ public ResponseVO<Object> getByPid(@PathVariable Long pid) {
return ResponseUtil.success(xiXunPlayerService.getByPid(pid));
}
/**
* 鑺傜洰鍒楄〃
+ *
* @param baseConditionVO
* @param keyword
* @return
@@ -123,10 +126,10 @@
// );
// }
// return ResponseUtil.success(poleLightemitService.list(wrapper));
- if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
+ if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
return ResponseUtil.success(xiXunPlayerService.list(wrapper)); // todo
- }else {
+ } else {
return ResponseUtil.success(xiXunPlayerService.list(wrapper));
}
}
@@ -134,26 +137,28 @@
/**
* 鑺傜洰鎺ㄩ��
+ *
* @param pid
* @param lightemitIds
* @return
*/
@GetMapping("/pushToXixun/{pid}")
- public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds ){
- xiXunPlayerService.videoXixunPlayer(pid,lightemitIds);
+ public ResponseVO<Object> getByPid(@PathVariable Long pid, @RequestBody List<Long> lightemitIds) {
+ xiXunPlayerService.videoXixunPlayer(pid, lightemitIds);
return ResponseUtil.success("鎺ㄩ�佹垚鍔�");
}
/**
* LED灞忓箷鏂板
+ *
* @param poleLightemit
* @return
*/
@PostMapping("/saveLed")
- public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit){
+ public ResponseVO<Object> save(@RequestBody PoleLightemitEntity poleLightemit) {
int count = poleLightemitService.count(new QueryWrapper<PoleLightemitEntity>().eq("lightemit_control_code", poleLightemit.getLightemitControlCode()));
- if(count != 0){
- throw new BusinessException("LED鎺у埗鍗$紪鍙蜂笉鑳介噸澶�");
+ if (count != 0) {
+ throw new BusinessException("LED鎺у埗鍗$紪鍙蜂笉鑳介噸澶�");
}
poleLightemit.setCreateUserId(SecurityUtils.getClientId());
@@ -166,78 +171,109 @@
/**
* LED灞忓箷淇敼
+ *
* @param ledId
* @param poleLightemit
* @return
*/
@PostMapping("/updateLed/{ledId}")
- public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId,@RequestBody PoleLightemitEntity poleLightemit){
- poleLightemitService.updatePoleLightemit(ledId,poleLightemit);
+ public ResponseVO<Object> updatePoleLightemit(@PathVariable Long ledId, @RequestBody PoleLightemitEntity poleLightemit) {
+ poleLightemitService.updatePoleLightemit(ledId, poleLightemit);
return ResponseUtil.success("淇敼鎴愬姛");
}
/**
* LED灞忓箷鍒犻櫎
+ *
* @param ledIds
* @return
*/
@PostMapping("/deleteLed")
- public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds){
+ public ResponseVO<Object> deleteLed(@RequestBody List<Long> ledIds) {
boolean b = poleLightemitService.deletePoleLightemit(ledIds);
- if(b){
+ if (b) {
return ResponseUtil.success("鍒犻櫎鎴愬姛");
- }else {
+ } else {
return ResponseUtil.success("鍒犻櫎澶辫触");
}
}
/**
* LED灞忓箷鍒楄〃
+ *
* @param baseConditionVO
* @param keyword
* @return
*/
@GetMapping("/listLed")
- public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
+ public ResponseVO<Object> listLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
+ @RequestParam(value = "isOnLine", required = false) boolean isOnLine) {
PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
LambdaQueryWrapper<PoleLightemitEntity> wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class);
- if(AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())){
+ if (AdministratorEnums.CUSTOMER.getCode().equals(SecurityUtils.getAdministratorIdentity())) {
boolean clientId = clientService.findClientId();
- if(clientId){
- wrapper= wrapper.eq(PoleLightemitEntity::getUserId,SecurityUtils.getUserId());
+ if (clientId) {
+ wrapper = wrapper.eq(PoleLightemitEntity::getUserId, SecurityUtils.getUserId());
}
- wrapper= wrapper.eq(PoleLightemitEntity::getClientId,clientService.getClientId());
+ wrapper = wrapper.eq(PoleLightemitEntity::getClientId, clientService.getClientId());
}
- wrapper=Wrappers.lambdaQuery(PoleLightemitEntity.class);
- if(StrUtil.isNotBlank(keyword)){
- wrapper.like(PoleLightemitEntity::getLightemitName,keyword).or(
+ wrapper = Wrappers.lambdaQuery(PoleLightemitEntity.class);
+ if (StrUtil.isNotBlank(keyword)) {
+ wrapper.like(PoleLightemitEntity::getLightemitName, keyword).or(
lambdaQueryWrapper -> {
lambdaQueryWrapper.like(PoleLightemitEntity::getLightemitControlCode, keyword);
}
);
}
- return ResponseUtil.success(poleLightemitService.list(wrapper));
+ List<PoleLightemitEntity> list = poleLightemitService.list(wrapper);
+ if(isOnLine){
+ List<PoleLightemitEntity> results = poleLightemitService.ledOnline(list);
+ CommonPage commonPage = CommonPage.restPage(results);
+ int size = results.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);
+ }else {
+ poleLightemitService.ledOnlineCheck(list);
+ return ResponseUtil.success(list);
+ }
+// return ResponseUtil.success(poleLightemitService.list(wrapper));
}
- @GetMapping("/onLineLed")
- public ResponseVO<Object> onlineLed(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) {
- // PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
- List<PoleLightemitEntity> list = poleLightemitService.ledList();
- if(list!=null&&!keyword.isEmpty()){
- List results = new ArrayList();
- //妯$硦鏌ヨ 浣跨敤锛圥attern銆丮atcher锛�
- Pattern pattern = Pattern.compile("寮�");
- for(int i=0; i < list.size(); i++){
- Matcher matcher = pattern.matcher((list.get(i)).getLightemitName());
- Matcher matcher1 = pattern.matcher((list.get(i)).getLightemitControlCode());
- if(matcher.find()||matcher1.find()){ //matcher.find()-涓烘ā绯婃煡璇� matcher.matches()-涓虹簿纭煡璇�
- results.add(list.get(i));
- }
- }
- return ResponseUtil.success(results);
- }
+ /*
+ 璁剧疆灞忓箷寮�鍏�
+ */
- return ResponseUtil.success(list);
+ @PostMapping("/setScreenOpen")
+ public ResponseVO<Object> setScreenOpen(@RequestBody SetScreenOpenParam setScreenOpenEntity){
+ if(setScreenOpenEntity.getIds() == null || setScreenOpenEntity.getIds().length == 0 || setScreenOpenEntity.getBool() == null){
+ throw new BusinessException("鏈�夋嫨LED灞�");
+ }
+ Collection poleLightemitControllers = poleLightemitService.listByIds(Arrays.asList(setScreenOpenEntity.getIds()));
+ if (!poleLightemitControllers.isEmpty()) {
+
+ Map<Long, Object> map = new HashMap<>();
+
+ Iterator iterator = poleLightemitControllers.iterator();
+ while (iterator.hasNext()) {
+ PoleLightemitEntity poleLightemitEntity = (PoleLightemitEntity) iterator.next();
+ //缁撴灉鏌ヨ
+ String result = lightemitUtils.setScreenOpen(poleLightemitEntity.getLightemitControlCode(), setScreenOpenEntity.getBool());
+
+ System.out.println("result:---------------------"+result);
+ if(result.isEmpty() || !"true".equals(result)){
+
+ }
+
+ map.put(poleLightemitEntity.getLightemitId(), result);
+ }
+ return ResponseUtil.success(map);
+ }else {
+ throw new BusinessException("鏈纭�夋嫨LED灞�");
+ }
}
@@ -245,15 +281,15 @@
鑾峰彇led瀹炴椂鐢婚潰
*/
@GetMapping("/getPicture/{id}")
- public ResponseVO<Object> getPicture(@PathVariable Long id){
- if(id == null){
- throw new BusinessException("鏈�夋嫨LED灞�");
+ public ResponseVO<Object> getPicture(@PathVariable Long id) {
+ if (id == null) {
+ throw new BusinessException("鏈�夋嫨LED灞�");
}
PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id);
- if(poleLightemitEntity != null){
+ if (poleLightemitEntity != null) {
String result = lightemitUtils.getPicture(poleLightemitEntity.getLightemitControlCode());
return ResponseUtil.success(result);
- }else {
+ } else {
throw new BusinessException("鏈�夋嫨LED灞�");
}
}
@@ -262,15 +298,15 @@
鑾峰彇闊抽噺
*/
@PostMapping("/getVolume/{id}")
- public ResponseVO<Object> getVolume(@PathVariable Long id){
- if(id == null){
+ public ResponseVO<Object> getVolume(@PathVariable Long id) {
+ if (id == null) {
throw new BusinessException("鏈�夋嫨LED灞�");
}
PoleLightemitEntity poleLightemitEntity = poleLightemitService.getById(id);
- if(poleLightemitEntity != null){
+ if (poleLightemitEntity != null) {
String result = lightemitUtils.getVoiume(poleLightemitEntity.getLightemitControlCode());
return ResponseUtil.success(result);
- }else {
+ } else {
throw new BusinessException("鏈�夋嫨LED灞�");
}
}
@@ -280,9 +316,9 @@
璁剧疆闊抽噺
*/
@PostMapping("/setVolume")
- public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity){
+ public ResponseVO<Object> setVolume(@RequestBody SetVolumeParam setVolumeEntity) {
- if(setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15){
+ if (setVolumeEntity == null || setVolumeEntity.getIds() == null || setVolumeEntity.getVolume() > 15) {
throw new BusinessException("鍙傛暟閿欒");
}
@@ -294,29 +330,29 @@
poleLightemitService.setVolume(poleLightemitEntity.getLightemitControlCode(), setVolumeEntity.getVolume());
}
return ResponseUtil.success("璁剧疆闊抽噺鎴愬姛");
- }else {
+ } else {
throw new BusinessException("鏈�夋嫨LED灞�");
}
}
@PostMapping("/addSchedule")
- public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity){
+ public ResponseVO<Object> addSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
return ResponseUtil.success(scheduleService.insert(ledEntity));
}
@PostMapping("/updateSchedule")
- public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity){
+ public ResponseVO<Object> updateSchedule(@RequestBody LEDScheduleParam_xixun ledEntity) {
return ResponseUtil.success(scheduleService.updateSchedule(ledEntity));
}
@GetMapping("/getSchedule/{id}")
- public ResponseVO<Object> getSchedule(@PathVariable Integer id){
+ public ResponseVO<Object> getSchedule(@PathVariable Integer id) {
return ResponseUtil.success(scheduleService.getSchedule(id));
}
@PostMapping("/pushSchedule/{id}")
- public ResponseVO<Object> pushSchedule(@PathVariable Integer id,@RequestBody Long[] lightemitIds){
- scheduleService.ledschedulepush(id,lightemitIds);
+ public ResponseVO<Object> pushSchedule(@PathVariable Integer id, @RequestBody Long[] lightemitIds) {
+ scheduleService.ledschedulepush(id, lightemitIds);
return ResponseUtil.success("璁剧疆鎴愬姛");
}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/param/SetScreenOpenParam.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/param/SetScreenOpenParam.java
new file mode 100644
index 0000000..5e21cfa
--- /dev/null
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/param/SetScreenOpenParam.java
@@ -0,0 +1,17 @@
+package com.sandu.ximon.admin.param;
+
+import lombok.Data;
+
+/**
+ * @program: machine-fast
+ * @description: led寮�鍏虫帴鍙楃被
+ * @author: YSS
+ * @create: 2019-05-30 17:56
+ **/
+@Data
+public class SetScreenOpenParam {
+
+ private Long[] ids;
+
+ private Boolean bool;
+}
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 e283140..caca185 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
@@ -182,19 +182,29 @@
}
*/
- public List<PoleLightemitEntity> ledList(){
-// Wrappers.lambdaQuery()
- List<PoleLightemitEntity> list = list();
- return ledOnlineCheck(list);
+ /**
+ * 鏄惁鍦ㄧ嚎
+ * @param list
+ * @return
+ */
+
+ public void ledOnlineCheck(List<PoleLightemitEntity> list) {
+ // List<PoleLightemitEntity> onLineList=new ArrayList<>();
+ for(PoleLightemitEntity poleLightemitEntity : list){
+ poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true"));
+ }
}
-
-
- public List<PoleLightemitEntity> ledOnlineCheck(List<PoleLightemitEntity> list) {
+ /**
+ * 浠呭湪绾�
+ * @param list
+ * @return
+ */
+ public List<PoleLightemitEntity> ledOnline(List<PoleLightemitEntity> list) {
List<PoleLightemitEntity> onLineList=new ArrayList<>();
for(PoleLightemitEntity poleLightemitEntity : list){
poleLightemitEntity.setIsOpen(lightemitUtils.getIsScreenOpen(poleLightemitEntity.getLightemitControlCode()).contains("true"));
- if(!poleLightemitEntity.getIsOpen()){
+ if(poleLightemitEntity.getIsOpen()){
onLineList.add(poleLightemitEntity);
}
}
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/ListPageUtil.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/ListPageUtil.java
deleted file mode 100644
index 365eadc..0000000
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/utils/ListPageUtil.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.sandu.ximon.admin.utils;
-
-import java.util.Collections;
-import java.util.List;
-public class ListPageUtil<T> {
- private List<T> data;
-
- /** 涓婁竴椤� */
- private int lastPage;
-
- /** 褰撳墠椤� */
- private int currentPage;
-
- /** 涓嬩竴椤� */
- private int nextPage;
- //
- /** 姣忛〉鏉℃暟 */
- private int pageSize;
-
- /** 鎬婚〉鏁� */
- private int totalPage;
-
- /** 鎬绘暟鎹潯鏁� */
- private int totalCount;
-
- public ListPageUtil(List<T> data,int currentPage,int pageSize) {
- if (data == null || data.isEmpty()) {
- throw new IllegalArgumentException("data must be not empty!");
- }
-
- this.data = data;
- this.pageSize = pageSize;
- this.currentPage = currentPage;
- this.totalCount = data.size();
- this.totalPage = (totalCount + pageSize - 1) / pageSize;
- this.lastPage = currentPage-1>1? currentPage-1:1;
- this.nextPage = currentPage>=totalPage? totalPage: currentPage + 1;
-
- }
-
- /**
- * 寰楀埌鍒嗛〉鍚庣殑鏁版嵁
- * @return 鍒嗛〉鍚庣粨鏋�
- */
- // public List<T> getPagedLst() {
- // int fromIndex = (nowPage - 1) * pageSize;
-// if (fromIndex >= data.size()) {
- // return Collections.emptyList();//绌烘暟缁�
- // }
- // if(fromIndex<0){
- // return Collections.emptyList();//绌烘暟缁�
- // }
-// int toIndex = nowPage * pageSize;
-// if (toIndex >= data.size()) {
-// toIndex = data.size();
- // }
- // return data.subList(fromIndex, toIndex);
- // }
-
- public int getPageSize() {
- return pageSize;
- }
-
- public List<T> getData() {
- int fromIndex = (currentPage - 1) * pageSize;
- if (fromIndex >= data.size()) {
- return Collections.emptyList();//绌烘暟缁�
- }
- if(fromIndex<0){
- return Collections.emptyList();//绌烘暟缁�
- }
- int toIndex = currentPage * pageSize;
- if (toIndex >= data.size()) {
- toIndex = data.size();
- }
- return data.subList(fromIndex, toIndex);
- }
- public int getLastPage() {
- return lastPage;
- }
-
- public int getCurrentPage() {
- return currentPage;
- }
-
- public int getNextPage() {
- return nextPage;
- }
-
- public int getTotalPage() {
- return totalPage;
- }
-
- public int getTotalCount() {
- return totalCount;
- }
- }
\ No newline at end of file
--
Gitblit v1.9.3