| | |
| | | package com.battery.business.web; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.constant.HttpStatus; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.page.PageDomain; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.page.TableSupport; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.battery.business.domain.TCollector; |
| | | import com.battery.business.domain.vo.DiscoveredCollectorVo; |
| | | import com.battery.business.service.ICollectorDiscoveryService; |
| | | import com.battery.business.service.ITCollectorService; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ITCollectorService collectorService; |
| | | |
| | | @Autowired |
| | | private ICollectorDiscoveryService collectorDiscoveryService; |
| | | |
| | | /** 分页查询采集器列表。 */ |
| | | @PreAuthorize("@ss.hasPermi('system:collector:list')") |
| | | @GetMapping("/list") |
| | |
| | | startPage(); |
| | | List<TCollector> list = collectorService.selectCollectorList(collector); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 查询当前可发现的采集器列表。 |
| | | * |
| | | * @return 可发现采集器分页数据 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:collector:list')") |
| | | @GetMapping("/discovered/list") |
| | | public TableDataInfo discoveredList() |
| | | { |
| | | List<DiscoveredCollectorVo> devices = collectorDiscoveryService.selectDiscoveredCollectorList(); |
| | | PageDomain pageDomain = TableSupport.buildPageRequest(); |
| | | int pageNum = pageDomain.getPageNum() == null || pageDomain.getPageNum() < 1 ? 1 : pageDomain.getPageNum(); |
| | | int pageSize = pageDomain.getPageSize() == null || pageDomain.getPageSize() < 1 ? 10 : pageDomain.getPageSize(); |
| | | long offset = (long) (pageNum - 1) * pageSize; |
| | | int fromIndex = (int) Math.min(offset, devices.size()); |
| | | int toIndex = (int) Math.min((long) fromIndex + pageSize, devices.size()); |
| | | List<DiscoveredCollectorVo> rows = fromIndex == toIndex |
| | | ? Collections.emptyList() |
| | | : devices.subList(fromIndex, toIndex); |
| | | TableDataInfo result = new TableDataInfo(rows, devices.size()); |
| | | result.setCode(HttpStatus.SUCCESS); |
| | | result.setMsg("查询成功"); |
| | | return result; |
| | | } |
| | | |
| | | /** 查询采集器详情。 */ |