| | |
| | | @GetMapping("/page") |
| | | @ApiOperationSupport(order = 3) |
| | | @ApiOperation(value = "分页", notes = "传入equipment") |
| | | public R<List<EquipmentVO>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) throws ParseException { |
| | | public R<IPage<EquipmentVO>> page(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) throws ParseException { |
| | | response.setHeader("Access-Control-Allow-Origin", "*"); |
| | | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); |
| | | response.setHeader("Access-Control-Allow-Credentials", "true"); |
| | |
| | | childMenu = new ArrayList(); |
| | | |
| | | //根据查询条件得到所有设备 |
| | | List<EquipmentVO> pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | IPage<EquipmentVO> pages = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment); |
| | | |
| | | List<EquipmentVO> datas = new ArrayList<>(); |
| | | //IPage<EquipmentVO> datas = new IPage<EquipmentVO> |
| | | |
| | | if (pid == null || pid.equals("")) { |
| | | for (int j = 0; j < pages.size(); j++) { |
| | | String expireTime = pages.get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | long st = sim.parse(expireTime).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | //计算天数 |
| | | int day = (int) ((st - en) / 86400000); |
| | | if (day <= 30) { |
| | | pages.get(j).setType(1); |
| | | } else { |
| | | pages.get(j).setType(0); |
| | | } |
| | | } |
| | | datas = pages; |
| | | } else { |
| | | 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++) { |
| | | String expireTime = pages.get(j).getExpireTime(); |
| | | //1.获取当前时间 |
| | | Date dd = new Date(); |
| | | SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String end = sim.format(dd); |
| | | //把string类型转换为long类型的 |
| | | long st = sim.parse(expireTime).getTime(); |
| | | long en = sim.parse(end).getTime(); |
| | | //计算天数 |
| | | int day = (int) ((st - en) / 86400000); |
| | | if (day <= 30) { |
| | | pages.get(j).setType(1); |
| | | } else { |
| | | pages.get(j).setType(0); |
| | | } |
| | | |
| | | if (childList.get(i).get("eqid") != null) { |
| | | if (childList.get(i).get("eqid").equals(pages.get(j).getDeviceNumber())) { |
| | | datas.add(pages.get(j)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return R.data(datas); |
| | | // if (pid == null || pid.equals("")) { |
| | | // for (int j = 0; j < pages.size(); j++) { |
| | | // String expireTime = pages.get(j).getExpireTime(); |
| | | // //1.获取当前时间 |
| | | // Date dd = new Date(); |
| | | // SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String end = sim.format(dd); |
| | | // //把string类型转换为long类型的 |
| | | // long st = sim.parse(expireTime).getTime(); |
| | | // long en = sim.parse(end).getTime(); |
| | | // //计算天数 |
| | | // int day = (int) ((st - en) / 86400000); |
| | | // if (day <= 30) { |
| | | // pages.get(j).setType(1); |
| | | // } else { |
| | | // pages.get(j).setType(0); |
| | | // } |
| | | // } |
| | | // datas = pages; |
| | | // } else { |
| | | // 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++) { |
| | | // String expireTime = pages.get(j).getExpireTime(); |
| | | // //1.获取当前时间 |
| | | // Date dd = new Date(); |
| | | // SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // String end = sim.format(dd); |
| | | // //把string类型转换为long类型的 |
| | | // long st = sim.parse(expireTime).getTime(); |
| | | // long en = sim.parse(end).getTime(); |
| | | // //计算天数 |
| | | // int day = (int) ((st - en) / 86400000); |
| | | // if (day <= 30) { |
| | | // pages.get(j).setType(1); |
| | | // } else { |
| | | // pages.get(j).setType(0); |
| | | // } |
| | | // |
| | | // if (childList.get(i).get("eqid") != null) { |
| | | // if (childList.get(i).get("eqid").equals(pages.get(j).getDeviceNumber())) { |
| | | // datas.add(pages.get(j)); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | return R.data(pages); |
| | | } |
| | | |
| | | //子节点 |