| | |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | | |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 控制器 |
| | |
| | | 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<EquipmentVO> pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | |
| | | List<EquipmentVO> datas = new ArrayList<>(); |
| | | |
| | | if (pid == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | 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); |
| | | } |
| | | |
| | | |
| | | if (childList.get(i).get("eqid") != null) { |
| | | if (childList.get(i).get("eqid").equals(pages.get(j).getDeviceNumber())) { |
| | | datas.add(pages.get(j)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else { |
| | | String s = catalogService.selectCatalogEqNUmber(pid); |
| | | if (s == null) { |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | } |
| | | } |
| | | } else { |
| | | String[] split = s.split(","); |
| | | String strArrays = ""; |
| | | for (int i = 0; i < split.length; i++) { |
| | | strArrays += "'" + split[i] + "',"; |
| | | } |
| | | String substring = strArrays.substring(0, strArrays.length() - 1); |
| | | equipment.setDeviceName(substring); |
| | | pages = equipmentService.selectEquipmentPage(equipment.getDeviceName(), equipment.getAddvcd(), equipment.getDtype(), equipment.getDevicestate()); |
| | | for(int i=0;i<pages.size();i++){ |
| | | String expireTime = pages.get(i).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(i).setType(1); |
| | | } |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | List<EquipmentVOS> list = equipmentService.selectList(deviceType); |
| | | return R.data(list); |
| | | } |
| | | |
| | | |
| | | } |