| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.constant.BladeConstant; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.catalog.entitly.catalog; |
| | | import org.springblade.modules.catalog.service.catalogService; |
| | | import org.springblade.modules.deploy.service.IDeployService; |
| | | import org.springblade.modules.equipment.vo.EquipmentVOS; |
| | |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<List<EquipmentVO>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) { |
| | | public R<List<Equipment>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | | List<EquipmentVO> pages; |
| | | |
| | | //清空全局参数 |
| | | childMenu = new ArrayList(); |
| | | |
| | | //根据查询条件得到所有设备 |
| | | List<Equipment> pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | |
| | | List<Equipment> datas = new ArrayList<>(); |
| | | |
| | | if (pid == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | datas = pages; |
| | | } else { |
| | | String s = catalogService.selectCatalogEqNUmber(pid); |
| | | if (s == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | } else { |
| | | String[] split = s.split(","); |
| | | String strArrays = ""; |
| | | for (int i = 0; i < split.length; i++) { |
| | | strArrays += "'" + split[i] + "',"; |
| | | List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(pid); |
| | | //根据传入的id递归出该节点下所有的设备 |
| | | List<Map<String, Object>> childList = treeMenuList(treedatas, Integer.parseInt(pid)); |
| | | //将得到的设备与查询所得设备进行匹配 |
| | | for (int i = 0; i < childList.size(); i++) { |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | if (childList.get(i).get("eqid") != null) { |
| | | if (childList.get(i).get("eqid").equals(pages.get(j).getDeviceNumber())) { |
| | | datas.add(pages.get(j)); |
| | | } |
| | | String substring = strArrays.substring(0, strArrays.length() - 1); |
| | | equipment.setDeviceName(substring); |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.data(datas); |
| | | } |
| | | |
| | | //子节点 |
| | | private static List childMenu = new ArrayList(); |
| | | |
| | | public static List treeMenuList(List<Map<String, Object>> menuList, int pid) { |
| | | for (int i = 0; i < menuList.size(); i++) { |
| | | //遍历出父id等于参数的id,add进子节点集合 |
| | | |
| | | if (pid != 0) { |
| | | if (menuList.get(i).get("pId").equals(pid)) { |
| | | //递归遍历下一级 |
| | | treeMenuList(menuList, Integer.valueOf((Integer) menuList.get(i).get("id"))); |
| | | childMenu.add(menuList.get(i)); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | return R.data(pages); |
| | | return childMenu; |
| | | } |
| | | |
| | | /** |