package com.sandu.ximon.admin.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.util.StringUtil; import com.sandu.common.domain.ResponseVO; import com.sandu.common.util.ResponseUtil; import com.sandu.common.util.SpringContextHolder; import com.sandu.ximon.admin.security.SecurityUtils; import com.sandu.ximon.admin.service.*; import com.sandu.ximon.dao.bo.BroadcastTerminalV2EntityBo; import com.sandu.ximon.dao.bo.LightBo; import com.sandu.ximon.dao.bo.MonitorBo; import com.sandu.ximon.dao.domain.*; import com.sandu.ximon.dao.mapper.LightMapper; import com.sandu.ximon.dao.mapper.MonitorMapper; import com.sandu.ximon.dao.mapper.PoleMapper; import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; /** * 绑定设备时获取硬件列表的controller * * @author ZZQ * @date 2022/5/27 9:41 */ @RestController @AllArgsConstructor @RequestMapping("/v1/getListOnBinding") public class GetListOnBindingController { /** * 客户列表 */ @GetMapping("/getClientList") public ResponseVO getClientList(@RequestParam(required = false, value = "keyword") String keyword) { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Client.class); //非超管只能看到自己下属的客户信息 if (SecurityUtils.getClientId() != null) { wrapper.eq(Client::getSuperiorId, SecurityUtils.getUserId()); } if (!StringUtil.isEmpty(keyword)) { wrapper.like(Client::getId, keyword).or(w -> { w.like(Client::getClientName, keyword); }); } List list = SpringContextHolder.getBean(ClientService.class).list(wrapper); List mapList = new ArrayList<>(); Map map; for (Client bean : list) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("clientName", bean.getClientName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * 灯杆列表 */ private final PoleMapper poleMapper; @GetMapping("/getPoleList") public ResponseVO getPoleList(@RequestParam(required = false, value = "keyword") String keyword) { List poleList; if (SecurityUtils.getClientId() == null) { poleList = poleMapper.getPoleListOnBinding(null, keyword); } else { poleList = poleMapper.getPoleListOnBinding(SecurityUtils.getUserId(), keyword); } List mapList = new ArrayList<>(); Map map; for (Pole bean : poleList) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("poleName", bean.getPoleName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * 路灯列表 */ private final LightMapper lightMapper; @GetMapping("/getLightList") public ResponseVO getLightList(@RequestParam(required = false, value = "keyword") String keyword) { List listLight = lightMapper.listLightOnBinding(SecurityUtils.getClientId(), keyword); List mapList = new ArrayList<>(); Map map; for (LightBo bean : listLight) { map = new LinkedHashMap(); map.put("id", bean.getLightId()); map.put("deviceCode", bean.getDeviceCode()); map.put("poleId", bean.getPoleId()); map.put("poleName", bean.getPoleName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * NLED列表(诺瓦设备) */ @GetMapping("/getLedPlayerEntityList") public ResponseVO getLedPlayerEntityList(@RequestParam(required = false, value = "keyword") String keyword) { List list = SpringContextHolder.getBean(LedPlayerEntityService.class). ledPlayerEntityListOnBinding(keyword); List mapList = new ArrayList<>(); Map map; for (LedPlayerEntity bean : list) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("name", bean.getName()); map.put("playerName", bean.getPlayerName()); map.put("sn", bean.getSn()); map.put("poleId", bean.getPoleId()); map.put("poleName", bean.getPoleName()); map.put("onlineStatus", bean.getOnlineStatus()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * NLED文件列表 */ @GetMapping("/getLedFilesList") public ResponseVO getLedFilesList() { LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(LEDProgramFile.class); if (SecurityUtils.getClientId() != null) { wrapper.eq(LEDProgramFile::getClientId, SecurityUtils.getUserId()).or(w -> { w.eq(LEDProgramFile::getUserId, SecurityUtils.getUserId()); }); } List list = SpringContextHolder.getBean(LEDProgramFileService.class).list(wrapper); List mapList = new ArrayList<>(); Map map; for (LEDProgramFile bean : list) { map = new LinkedHashMap(); map.put("fileId", bean.getId()); map.put("fileType", bean.getFileType()); map.put("fileUrl", bean.getFileUrl()); map.put("fileSize", bean.getSize()); if ("mp4".equals(bean.getFileType())) { map.put("screenShot", bean.getScreenShot()); } else { map.put("screenShot", bean.getFileUrl()); } mapList.add(map); } return ResponseUtil.success(mapList); } /** * NLED节目列表 * * @return */ private final LEDProgramService ledProgramService; @GetMapping("/getNledProgeamList") public ResponseVO getNledProgeamList(@RequestParam(required = false, value = "keyword") String keyword) { List ledPrograms = ledProgramService.listProgramOnBinding(keyword); List mapList = new ArrayList<>(); Map map; for (LEDProgram bean : ledPrograms) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("name", bean.getName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * SLED列表 * * @return */ private final PoleLightemitService sLedService; @GetMapping("/getSledList") public ResponseVO getSledList(@RequestParam(required = false, value = "keyword") String keyword) { List poleLightemitEntities = sLedService.listLedOnBinding(keyword); List mapList = new ArrayList<>(); Map map; for (PoleLightemitEntity bean : poleLightemitEntities) { map = new LinkedHashMap(); map.put("lightemitId", bean.getLightemitId()); map.put("lightemitName", bean.getLightemitName()); map.put("lightemitControlCode", bean.getLightemitControlCode()); map.put("isOnLine", bean.isOnLine()); map.put("streetlightId", bean.getStreetlightId()); map.put("streetlightName", bean.getStreetlightName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * 摄像头列表 * * @return */ private final MonitorMapper monitorMapper; @GetMapping("/getMonitorList") public ResponseVO getMonitorList(@RequestParam(required = false, value = "keyword") String keyword) { List monitorBos; //超管 if (SecurityUtils.getClientId() == null) { monitorBos = monitorMapper.newListMonitorOnBind(null, keyword); } else { monitorBos = monitorMapper.newListMonitorOnBind(SecurityUtils.getUserId(), keyword); } List mapList = new ArrayList<>(); Map map; for (MonitorBo bean : monitorBos) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("deviceSerial", bean.getDeviceSerial()); map.put("poleId", bean.getPoleId()); map.put("poleName", bean.getPoleName()); map.put("note", bean.getNote()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * 音柱列表 */ private final IpVolumeService ipVolumeService; @GetMapping("/getIpVolumeList") public ResponseVO getIpVolumeList(@RequestParam(required = false, value = "keyword") String keyword) { List broadcastTerminalList = ipVolumeService.newIpTerminalList(keyword); List mapList = new ArrayList<>(); Map map; for (BroadcastTerminalV2EntityBo bean : broadcastTerminalList) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("terminalName", bean.getTerminalName()); map.put("status", bean.getStatus()); map.put("poleId", bean.getPoleId()); map.put("PoleName", bean.getPoleName()); mapList.add(map); } return ResponseUtil.success(mapList); } /** * 音柱广播素材列表 */ private final IpVolumeFileService ipVolumeFileService; @GetMapping("/getIpFileList") public ResponseVO getIpFileList(@RequestParam(required = false, value = "keyword") String keyword) { List ipVolumeFiles = ipVolumeFileService.listFiles(keyword); List mapList = new ArrayList<>(); Map map; for (IpVolumeFile bean : ipVolumeFiles) { map = new LinkedHashMap(); map.put("id", bean.getId()); map.put("fileName", bean.getFileName()); mapList.add(map); } return ResponseUtil.success(mapList); } }