| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | 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.service.AirEquipmentService; |
| | | import com.sandu.ximon.admin.service.MonitorService; |
| | | import com.sandu.ximon.admin.service.PoleService; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 灯杆模块以及设置分组到对应灯杆 |
| | |
| | | public class PoleController { |
| | | |
| | | private final PoleService poleService; |
| | | private MonitorService monitorService; |
| | | private AirEquipmentService airEquipmentService; |
| | | |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) { |
| | |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public ResponseVO<Object> listPole(@RequestParam String keyword) { |
| | | LambdaQueryWrapper<Pole> wrapper = Wrappers.lambdaQuery(Pole.class); |
| | | public ResponseVO<Object> listPole(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | LambdaQueryWrapper<Pole> wrapper = Wrappers.lambdaQuery(Pole.class).orderByDesc(Pole::getId); |
| | | if (StrUtil.isNotBlank(keyword)) { |
| | | wrapper.like(Pole::getPoleCode, keyword) |
| | | .or(lampPostLambdaQueryWrapper -> { |
| | |
| | | }); |
| | | } |
| | | List<Pole> list = poleService.list(wrapper); |
| | | return ResponseUtil.success(list); |
| | | return ResponseUtil.successPage(list); |
| | | } |
| | | |
| | | @GetMapping("listPoleAndState") |
| | | public ResponseVO<Object> listPoleAndState() { |
| | | @GetMapping("/listPoleAndState") |
| | | public ResponseVO<Object> listPoleAndState(BaseConditionVO baseConditionVO, @RequestParam(value = "keyword", required = false) String keyword) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | |
| | | return ResponseUtil.success(poleService.queryStatesAndList()); |
| | | List<Pole> poles = poleService.queryStatesAndList(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | return ResponseUtil.successPage(poles); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置三元码 |
| | | */ |
| | | @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 设备的绑定解绑都要单独重新处理 |
| | | /** |
| | | * 灯杆绑定设备 |
| | | */ |
| | |
| | | public ResponseVO<Object> bindPole(@PathVariable Long poleId, @RequestBody @Validated PoleBindingParam param) { |
| | | boolean result = poleService.bindPole(poleId, param); |
| | | if (result) { |
| | | //设备类型,0路灯,1led屏幕,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助 |
| | | switch (param.getDeviceType()) { |
| | | case 0: |
| | | break; |
| | | case 1: |
| | | break; |
| | | case 2: |
| | | break; |
| | | case 3: |
| | | break; |
| | | case 4: |
| | | break; |
| | | case 5: |
| | | break; |
| | | case 6: |
| | | break; |
| | | case 7: |
| | | monitorService.updateBingdingState(true, param.getDeviceCode()); |
| | | break; |
| | | case 8: |
| | | break; |
| | | case 9: |
| | | 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(param.getDeviceCode()); |
| | | if (result) { |
| | | //设备类型,0路灯,1led屏幕,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助 |
| | | switch (param.getDeviceType()) { |
| | | case 0: |
| | | break; |
| | | case 1: |
| | | break; |
| | | case 2: |
| | | break; |
| | | case 3: |
| | | break; |
| | | case 4: |
| | | break; |
| | | case 5: |
| | | break; |
| | | case 6: |
| | | break; |
| | | case 7: |
| | | monitorService.updateBingdingState(false, param.getDeviceCode()); |
| | | break; |
| | | case 8: |
| | | break; |
| | | case 9: |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | return ResponseUtil.success("解绑成功"); |
| | | } else { |
| | | return ResponseUtil.fail("解绑失败"); |
| | | } |
| | | } |
| | | |
| | | @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()));////////////// |
| | | } |
| | | |
| | | |
| | | } |