From 58a72f5b844bc77490431fc66bad0be45ce90bd2 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期一, 09 五月 2022 09:56:44 +0800
Subject: [PATCH] Changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 200 insertions(+), 19 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
index 9d41d53..4db242a 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/controller/PoleController.java
@@ -1,14 +1,26 @@
package com.sandu.ximon.admin.controller;
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ArrayUtil;
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.object.BaseConditionVO;
+import com.sandu.common.security.annotation.AnonymousAccess;
import com.sandu.common.util.ResponseUtil;
+import com.sandu.ximon.admin.dto.DeviceStatus;
+import com.sandu.ximon.admin.param.PoleBindParam;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.param.PoleParam;
+import com.sandu.ximon.admin.param.PoleStatesParam;
+import com.sandu.ximon.admin.security.PermissionConfig;
+import com.sandu.ximon.admin.service.AirEquipmentService;
+import com.sandu.ximon.admin.service.IpVolumeService;
+import com.sandu.ximon.admin.service.MonitorService;
import com.sandu.ximon.admin.service.PoleService;
import com.sandu.ximon.dao.domain.Pole;
+import com.sandu.ximon.dao.enums.MenuEnum;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -26,6 +38,10 @@
public class PoleController {
private final PoleService poleService;
+ private MonitorService monitorService;
+ private IpVolumeService broadcastTerminalV2Service;
+ private AirEquipmentService airEquipmentService;
+ private final PermissionConfig permissionConfig;
@PostMapping("/add")
public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) {
@@ -42,42 +58,61 @@
return ResponseUtil.success(poleService.deletePole(poleId));
}
- @GetMapping("/list")
- public ResponseVO<Object> listPole(@RequestParam String keyword) {
- LambdaQueryWrapper<Pole> wrapper = Wrappers.lambdaQuery(Pole.class);
- if (StrUtil.isNotBlank(keyword)) {
- wrapper.like(Pole::getPoleCode, keyword)
- .or(lampPostLambdaQueryWrapper -> {
- lampPostLambdaQueryWrapper.like(Pole::getPoleName, keyword);
- });
+ @PostMapping("/list")
+ public ResponseVO<Object> listPole(BaseConditionVO baseConditionVO, @RequestBody PoleStatesParam param) {
+ if (!permissionConfig.check(MenuEnum.POLE_LIST.getCode())) {
+ return ResponseUtil.fail("缂哄皯瀵瑰簲鐢ㄦ埛鏉冮檺");
}
- List<Pole> list = poleService.list(wrapper);
- return ResponseUtil.success(list);
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ List<Pole> results = poleService.queryAllStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), param);
+ 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);
+ // return ResponseUtil.success(poles);
}
- @GetMapping("listPoleAndState")
- public ResponseVO<Object> listPoleAndState() {
+ @GetMapping("/listPoleAndState")
+ public ResponseVO<Object> listPoleAndState(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword,
+ @RequestParam(value = "groupid", required = false) Long groupid) {
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ List<Pole> poles = poleService.queryStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), keyword, groupid);
+ return ResponseUtil.successPage(poles);
+ }
- return ResponseUtil.success(poleService.queryStatesAndList());
+ /**
+ * 鍦ㄧ嚎鏁伴噺
+ */
+ @AnonymousAccess
+ @GetMapping("/online")
+ public ResponseVO<Object> online() {
+ return ResponseUtil.success(poleService.poleCount());
}
/**
* 璁剧疆涓夊厓鐮�
*/
- @PostMapping("/setMac")
- public ResponseVO<Object> setMac(@PathVariable Long poleId) {
- return ResponseUtil.success(poleService.setMac(poleId));
+ @PostMapping("/setMac/{baseMac}")
+ public ResponseVO<Object> setMac(@PathVariable String baseMac) {
+ //public ResponseVO<Object> setMac() {
+ return ResponseUtil.success(poleService.setMac(baseMac));
+ // return ResponseUtil.success(poleService.setMac());
}
/**
* 鎭㈠鐏潌鍑哄巶璁剧疆
*/
- @PostMapping("/poleReset")
+ @PostMapping("/poleReset/{poleId}")
public ResponseVO<Object> poleReset(@PathVariable Long poleId) {
return ResponseUtil.success(poleService.poleReset(poleId));
}
+//TODO 璁惧鐨勭粦瀹氳В缁戦兘瑕佸崟鐙噸鏂板鐞�
/**
* 鐏潌缁戝畾璁惧
@@ -86,11 +121,157 @@
public ResponseVO<Object> bindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
boolean result = poleService.bindPole(poleId, param);
if (result) {
+ //璁惧绫诲瀷锛�0璺伅锛�1nove锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒, 11鍐滆��
+ switch (param.getDeviceType()) {
+ case 0:
+ Pole pole = poleService.getById(poleId);
+ if (pole != null) {
+ pole.setPoleName(param.getDeviceName());
+ pole.setDeviceCode(param.getDeviceCode());
+ poleService.updateById(pole);
+ }
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ case 5:
+ broadcastTerminalV2Service.updateBingdingState(true, Integer.valueOf(param.getDeviceCode()).intValue());
+ break;
+ case 6:
+ break;
+ case 7:
+ monitorService.updateBingdingState(true, param.getDeviceCode());
+ break;
+ case 8:
+ break;
+ case 9:
+ break;
+ case 10:
+ break;
+ case 11:
+ break;
+ default:
+ break;
+ }
+
return ResponseUtil.success("缁戝畾鎴愬姛");
} else {
return ResponseUtil.fail("缁戝畾澶辫触");
}
}
+ /**
+ * 鐏潌缁戝畾璁惧
+ */
+ @PostMapping("/unBind/{poleId}")
+ public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) {
+ boolean result = poleService.unBindPole(poleId, param.getDeviceCode());
+ if (result) {
+ //璁惧绫诲瀷锛�0璺伅锛�1led灞忓箷锛�2鍏呯數妗╋紝3澶ф皵鐩戞祴锛�4姘磋川鐩戞祴锛�5ip闊虫煴锛�6lcd骞垮憡鏈猴紝7鎽勫儚澶达紝8鏉嗕綋鍊炬祴锛�9涓�閿晳鍔�, 10鐔欒, 11鍐滆��
+ switch (param.getDeviceType()) {
+ case 0:
+ //鍒犻櫎鐏潌鐨刣evicescode
+ Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getId, poleId));
+ if (pole != null) {
+ poleService.updateDeviceCode(pole.getId());
+ }
+ break;
+ case 1:
+ break;
+ case 2:
+ break;
+ case 3:
+ break;
+ case 4:
+ break;
+ case 5:
+ broadcastTerminalV2Service.updateBingdingState(false, Integer.valueOf(param.getDeviceCode()).intValue());
+ break;
+ case 6:
+ break;
+ case 7:
+ monitorService.updateBingdingState(false, param.getDeviceCode());
+ break;
+ case 8:
+ break;
+ case 9:
+ break;
+ case 10:
+ break;
+ case 11:
+ break;
+ default:
+ break;
+ }
+
+ return ResponseUtil.success("瑙g粦鎴愬姛");
+ } else {
+ return ResponseUtil.fail("瑙g粦澶辫触");
+ }
+ }
+
+ @PostMapping("/listStatusByDeviceCode")
+ public ResponseVO<Object> getStatusById(@RequestBody String[] deviceCodeList) {
+ for (String s : deviceCodeList) {
+ if (s == null) {
+ return ResponseUtil.fail("鍙傛暟涓嶈兘涓虹┖");
+ }
+
+ }
+ if (ArrayUtil.isEmpty(deviceCodeList)) {
+ return ResponseUtil.fail("鍙傛暟涓嶈兘涓虹┖");
+ }
+ List<DeviceStatus> statusList = poleService.listStatusByDeviceCode(CollectionUtil.toList(deviceCodeList));
+ return ResponseUtil.success(statusList);
+ }
+
+ @PostMapping("/ClientBindingPole")
+ public ResponseVO<Object> ClientBindingPole(@RequestBody PoleBindParam param) {
+ return ResponseUtil.success(poleService.ClientBindingPole(param.getClientId(), param.getPoleIds()));//////////////
+ }
+
+
+ /**
+ * 鏌ユ壘鑷繁鎷ユ湁鐨勭伅鏉�
+ */
+ @PostMapping("/getOwnerPole/{cilentId}")
+ public ResponseVO<Object> getOwnerPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword
+ , @PathVariable Long cilentId) {
+ List<Pole> results = poleService.getOwnerPole(baseConditionVO, keyword, cilentId);
+ return ResponseUtil.success(results);
+ }
+
+ /**
+ * 鏌ョ湅鐏潌缁戝畾鐨勮澶�
+ */
+ @AnonymousAccess
+ @PostMapping("/getPoleBindDevice/{poleId}")
+ public ResponseVO<Object> getPoleBindDevice(@PathVariable Long poleId) {
+ return ResponseUtil.success(poleService.getBindByPoleId(poleId));
+ }
+
+
+ /**
+ * 鎺ㄩ�佸ぇ姘旇澶囧埌璇虹摝
+ */
+ @AnonymousAccess
+ @GetMapping("/pushAidDataToNova/{poleId}")
+ public ResponseVO<Object> pushAirDataToNova(@PathVariable Long poleId) {
+ return ResponseUtil.success(poleService.pushAirDataToNova(poleId));
+ }
+
+ /**
+ * 鎺ㄩ�佸ぇ姘旇澶囧埌鐔欒
+ */
+ @AnonymousAccess
+ @GetMapping("/pushAirDataToXiXun/{poleId}")
+ public ResponseVO<Object> pushAirDataToXiXun(@PathVariable Long poleId) {
+ return ResponseUtil.success(poleService.pushAirDataToXiXun(poleId));
+ }
}
--
Gitblit v1.9.3