| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | 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.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.param.GroupParam; |
| | | import com.sandu.ximon.admin.param.LampPostParam; |
| | | import com.sandu.ximon.admin.param.ReceiveParam; |
| | | import com.sandu.ximon.admin.service.LampPostService; |
| | | import com.sandu.ximon.dao.domain.LampPost; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | 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.*; |
| | | |
| | | import java.sql.Wrapper; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 灯杆模块以及设置分组到对应灯杆 |
| | | * |
| | | * @author chenjiantian |
| | | */ |
| | | @RestController |
| | |
| | | @RequestMapping("/v1/pole") |
| | | public class PoleController { |
| | | |
| | | private final LampPostService poleService; |
| | | private final PoleService poleService; |
| | | private MonitorService monitorService; |
| | | private IpVolumeService broadcastTerminalV2Service; |
| | | private AirEquipmentService airEquipmentService; |
| | | private final PermissionConfig permissionConfig; |
| | | |
| | | @GetMapping("/add") |
| | | public ResponseVO<Object> addLampPost(@RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( poleService.addLamp(lampPostParam)); |
| | | @PostMapping("/add") |
| | | public ResponseVO<Object> addPole(@RequestBody @Validated PoleParam param) { |
| | | return ResponseUtil.success(poleService.addPole(param)); |
| | | } |
| | | |
| | | @GetMapping("/update/{id}") |
| | | public ResponseVO<Object> updateLampPost(@PathVariable Long id, @RequestBody LampPostParam lampPostParam){ |
| | | return ResponseUtil.success( poleService.updateLamp(id,lampPostParam)); |
| | | @PostMapping("/update/{poleId}") |
| | | public ResponseVO<Object> updatePole(@PathVariable Long poleId, @RequestBody @Validated PoleParam param) { |
| | | return ResponseUtil.success(poleService.updatePole(poleId, param)); |
| | | } |
| | | |
| | | @GetMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteLampPost(@PathVariable Long id){ |
| | | return ResponseUtil.success(poleService.deleteLampPost(id)); |
| | | @PostMapping("/delete/{poleId}") |
| | | public ResponseVO<Object> deletePole(@PathVariable Long poleId) { |
| | | return ResponseUtil.success(poleService.deletePole(poleId)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/setGroup") |
| | | public ResponseVO<Object> setGroup(@RequestBody GroupParam groupParam){ |
| | | poleService.setGroup(groupParam.getGroup(), groupParam.getId()); |
| | | return ResponseUtil.success("分组设置成功"); |
| | | } |
| | | |
| | | // @AnonymousAccess |
| | | //@PostMapping("/list") |
| | | /* public ResponseVO<Object> listLamp(){ |
| | | //List<LampPost> list = lampPostService.list(); |
| | | return ResponseUtil.success(lampPostService.list()); |
| | | //return ResponseUtil.success(lampPostService.listLamp()); |
| | | }*/ |
| | | |
| | | /** |
| | | * 查询灯杆列表并携带在线状态 |
| | | * @return |
| | | */ |
| | | @PostMapping("/list") |
| | | public ResponseVO<Object> listLamp(){ |
| | | return ResponseUtil.success(poleService.queryStates()); |
| | | public ResponseVO<Object> listPole(BaseConditionVO baseConditionVO, @RequestBody PoleStatesParam param) { |
| | | if (!permissionConfig.check(MenuEnum.POLE_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | 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(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); |
| | | } |
| | | |
| | | /** |
| | | * 恢复出厂设置 |
| | | * @param id |
| | | * @return |
| | | * 在线数量 |
| | | */ |
| | | @GetMapping("/lightReset/{id}") |
| | | public ResponseVO<Object> LightReset(@PathVariable Long id){ |
| | | return ResponseUtil.success(poleService.LightReset(id)); |
| | | @GetMapping("/online") |
| | | public ResponseVO<Object> online() { |
| | | return ResponseUtil.success(poleService.poleCount()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置三元码 |
| | | */ |
| | | @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()); |
| | | } |
| | | |
| | | @GetMapping("/lsitLike") |
| | | public ResponseVO<Object> list( @RequestBody ReceiveParam receiveParam){ |
| | | LambdaQueryWrapper<LampPost> wrapper = Wrappers.lambdaQuery(LampPost.class); |
| | | if(receiveParam.getKeyWord()!=null){ |
| | | wrapper.like(LampPost::getLampId,receiveParam.getKeyWord()) |
| | | .or(lampPostLambdaQueryWrapper -> { |
| | | lampPostLambdaQueryWrapper.like(LampPost::getName,receiveParam.getKeyWord()); |
| | | }); |
| | | /** |
| | | * 恢复灯杆出厂设置 |
| | | */ |
| | | @PostMapping("/poleReset/{poleId}") |
| | | public ResponseVO<Object> poleReset(@PathVariable Long poleId) { |
| | | return ResponseUtil.success(poleService.poleReset(poleId)); |
| | | } |
| | | |
| | | //TODO 设备的绑定解绑都要单独重新处理 |
| | | |
| | | /** |
| | | * 灯杆绑定设备 |
| | | */ |
| | | @PostMapping("/bind/{poleId}") |
| | | 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熙讯 |
| | | 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; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | return ResponseUtil.success("绑定成功"); |
| | | } else { |
| | | return ResponseUtil.fail("绑定失败"); |
| | | } |
| | | List<LampPost> lsit= poleService.list(wrapper); |
| | | return ResponseUtil.success(lsit); |
| | | } |
| | | |
| | | /** |
| | | * 灯杆绑定设备 |
| | | */ |
| | | @PostMapping("/unBind/{poleId}") |
| | | public ResponseVO<Object> unBindPole(@PathVariable Long poleId, @RequestBody PoleBindingParam param) { |
| | | boolean result = poleService.unBindPole(poleId, param.getDeviceCode()); |
| | | if (result) { |
| | | //设备类型,0路灯,1led屏幕,2充电桩,3大气监测,4水质监测,5ip音柱,6lcd广告机,7摄像头,8杆体倾测,9一键救助, 10熙讯 |
| | | switch (param.getDeviceType()) { |
| | | case 0: |
| | | //删除灯杆的devicescode |
| | | 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; |
| | | 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()));////////////// |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查找自己拥有的灯杆 |
| | | */ |
| | | @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); |
| | | // 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(results); |
| | | } |
| | | |
| | | /** |
| | | * 查看灯杆绑定的设备 |
| | | */ |
| | | @PostMapping("/getPoleBindDevice/{poleId}") |
| | | public ResponseVO<Object> getPoleBindDevice(@PathVariable Long poleId) { |
| | | return ResponseUtil.success(poleService.getBindByPoleId(poleId)); |
| | | } |
| | | |
| | | |
| | | } |