Ejemplo n.º 1
0
  @ResponseBody
  @RequestMapping(value = "chooseJobs", method = RequestMethod.POST, produces = MediaTypes.JSON)
  public Map<String, Object> chooseJobs(@RequestParam("id") Integer id) {
    /**
     * 根节点下不会直接挂载作业,其他节点下可以挂载子节点和作业
     *
     * <p>如果传入的id是0,代表根节点,此时获取根节点下所有子节点 当点击一个子节点后,判断此节点是否为智能节点,如果是智能节点,则查找smart_group_query表
     * 如果是非智能节点,则获取此节点下的子节点和作业 GROUP_TYPE_ID=9 代表智能节点; GROUP_TYPE_ID=4代表非智能节点
     */
    List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
    if (id == 0) {
      List<GroupBean> firstLevelJobGroupList = groupService.findFirstLevelJobGroup();
      groupBeanList.addAll(firstLevelJobGroupList);
    } else {
      List<GroupBean> childJobGroup = groupService.findChildJobGroup(id);
      groupBeanList.addAll(childJobGroup);

      BLGroup groupNode = groupService.findByGroupId(id);
      if (groupNode.getGROUP_TYPE_ID() == 4) {
        List<GroupBean> staticJobList = groupService.findStaticJob(groupNode);
        groupBeanList.addAll(staticJobList);
      } else {
        List<GroupBean> smartJobList = groupService.findSmartJob(groupNode);
        groupBeanList.addAll(smartJobList);
      }
    }

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("data", groupBeanList);
    return resultMap;
  }
Ejemplo n.º 2
0
  @ResponseBody
  @RequestMapping(
      value = "chooseDeviceBYBBSA",
      method = RequestMethod.POST,
      produces = MediaTypes.JSON)
  public Map<String, Object> chooseDeviceBYBBSA(
      @RequestParam("id") Integer id, HttpServletRequest request) throws SQLException {
    List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
    if (id == 0) {
      List<GroupBean> firstLevelDeviceList = groupService.findFirstLevelDeviceGroup();
      groupBeanList.addAll(firstLevelDeviceList);
    } else {
      List<GroupBean> childDeviceGroup = groupService.findDeviceGroupWithId(id);
      groupBeanList.addAll(childDeviceGroup);

      BLGroup groupNode = groupService.findByGroupId(id);
      if (groupNode.getGROUP_TYPE_ID() == 1) {
        List<GroupBean> staticDeviceList = groupService.findStaticDeviceNode(id);
        groupBeanList.addAll(staticDeviceList);
      } else {
        List<GroupBean> smartDeviceList = groupService.findSmartDeviceNode(id);
        groupBeanList.addAll(smartDeviceList);
      }
    }

    Map<String, Object> resultMap = new HashMap<String, Object>();
    resultMap.put("data", groupBeanList);
    // resultMap.put("data",deviceFilter.deviceFilterRole(groupBeanList,UserNameUtil.getUserNameByRequest(request)) );
    return resultMap;
  }
Ejemplo n.º 3
0
 @ResponseBody
 @RequestMapping(value = "findJobGroup/{id}", method = RequestMethod.GET)
 public Map<String, String> findJobGroup(@PathVariable("id") Integer id) {
   BLGroup blGroup = groupService.getGroupNodeWithChildNode(id);
   Map<String, String> map = new LinkedHashMap<String, String>();
   map.put(blGroup.getGROUP_ID().toString(), blGroup.getNAME());
   while (blGroup.getPARENT_GROUP_ID() != 0 && !"Jobs".equals(blGroup.getNAME())) {
     blGroup = groupService.getGroupNodeWithChildNode(blGroup.getPARENT_GROUP_ID());
     map.put(blGroup.getGROUP_ID().toString(), blGroup.getNAME());
   }
   return map;
 }
Ejemplo n.º 4
0
  @ResponseBody
  @RequestMapping(
      value = "getIpAddressAllByGroupIdBYBBSA",
      method = RequestMethod.POST,
      produces = MediaTypes.JSON)
  public Set<String> getIpAddressAllByGroupIdBYBBSA(
      @RequestParam("id") Integer id, HttpServletRequest request) throws SQLException {
    Set<String> ipAddressList = new HashSet<String>();

    List<GroupBean> groupBeanList = new ArrayList<GroupBean>();
    // 选中的组
    BLGroup groupNode = groupService.findByGroupId(id);
    // 子组
    List<BLGroup> groupList = groupService.getAllChildrenGroup(id, new ArrayList<BLGroup>());
    groupList.add(groupNode);
    List<Integer> ordinaryGroupList = new ArrayList<Integer>();
    List<Integer> smartGroups = new ArrayList<Integer>();

    for (BLGroup blGroup : groupList) {
      if (blGroup.getGROUP_TYPE_ID() == 1) {
        if (blGroup.getGROUP_TYPE_ID() instanceof Integer)
          ordinaryGroupList.add(blGroup.getGROUP_ID());
      } else {
        smartGroups.add(blGroup.getGROUP_ID());
      }
    }
    String ordinaryGroups = "";
    for (Integer g : ordinaryGroupList) ordinaryGroups += "," + g;
    if (ordinaryGroupList.size() > 0) {
      String groupIDwhere = ordinaryGroups.substring(1, ordinaryGroups.length());
      if (",".equals(groupIDwhere.substring(groupIDwhere.length() - 1, groupIDwhere.length()))) {
        groupIDwhere = groupIDwhere.substring(0, groupIDwhere.length() - 1);
      }
      SessionImplementor sessionImplementor = (SessionImplementor) entityManager.getDelegate();
      Connection connection = sessionImplementor.connection();
      Statement statement = connection.createStatement();
      String sql =
          "select blgroup_device.device_id,blgroup_device.group_id,server.name IP_ADDRESS "
              + "from blgroup_device,device server,blgroup where server.agent_state_id=100 and server.device_state_id=50 "
              + "and blgroup_device.device_id=server.device_id and blgroup_device.group_id=blgroup.group_id "
              + "and blgroup.group_id in ("
              + groupIDwhere
              + ")";
      System.out.println("SQL: " + sql);
      ResultSet resultSet = statement.executeQuery(sql);
      if (resultSet.next()) {
        ipAddressList.add(resultSet.getString("IP_ADDRESS"));
      }
    }
    if (smartGroups.size() > 0) {
      SessionImplementor sessionImplementor = (SessionImplementor) entityManager.getDelegate();
      Connection connection = sessionImplementor.connection();
      Statement statement = connection.createStatement();
      for (Integer groupid : smartGroups) {
        SmartGroup smartGroup = smartGroupService.findWithGroupId(groupid);
        if (null != smartGroup) {
          String sql =
              smartGroup.getQUERY_STRING().substring(0, smartGroup.getQUERY_STRING().length() - 1);
          ResultSet resultSet = statement.executeQuery(sql);
          while (resultSet.next()) {
            ipAddressList.add(resultSet.getString("IP_ADDRESS"));
          }
        }
      }
    }

    return ipAddressList; // deviceFilter.deviceFilterRole(ipAddressList,UserNameUtil.getUserNameByRequest(request));
  }