/**
  * 终端信息列表页面跳转
  *
  * @return
  */
 @RequestMapping(params = "addorupdate")
 public ModelAndView addorupdate(TerminalInfoEntity terminalInfo, HttpServletRequest req) {
   if (StringUtil.isNotEmpty(terminalInfo.getId())) {
     try {
       terminalInfo =
           terminalInfoService.getEntity(TerminalInfoEntity.class, terminalInfo.getId());
       TerminalInfoPage page = new TerminalInfoPage();
       MyBeanUtils.copyBeanNotNull2Bean(terminalInfo, page);
       TSTerritory self = systemService.get(TSTerritory.class, page.getGroupid());
       String territoryName = "";
       List<TSTerritory> ts = new ArrayList<TSTerritory>();
       TSTerritory parent = self.getTSTerritory();
       ts.add(self);
       String pid = parent.getId();
       // 当父组织机构不为根机构时,查找父机构
       while (!"1".equals(pid)) {
         parent = systemService.get(TSTerritory.class, pid);
         ts.add(parent);
         parent = parent.getTSTerritory();
         pid = parent.getId();
       }
       // 按照添加顺序逆序
       Collections.reverse(ts);
       for (TSTerritory te : ts) {
         territoryName += "-" + te.getTerritoryName();
       }
       page.setGroupname(territoryName.substring(1));
       req.setAttribute("terminalInfoPage", page);
     } catch (Exception e) {
       logger.error("获取终端信息错误");
       e.printStackTrace();
     }
   }
   return new ModelAndView("vod/terminalinfo/terminalInfo");
 }
  /**
   * easyui AJAX请求数据
   *
   * @param request
   * @param response
   * @param dataGrid
   * @param user
   * @throws Exception
   */
  @SuppressWarnings("unchecked")
  @RequestMapping(params = "datagrid")
  public void datagrid(
      TerminalInfoEntity terminalInfo,
      HttpServletRequest request,
      HttpServletResponse response,
      DataGrid dataGrid,
      String groupname)
      throws Exception {
    CriteriaQuery cq = new CriteriaQuery(TerminalInfoEntity.class, dataGrid);
    // 查询条件组装器,fuzzy search
    String name = terminalInfo.getName();
    if (StringUtil.isNotEmpty(name)) {
      terminalInfo.setName("*" + name + "*");
    }
    org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(
        cq, terminalInfo, request.getParameterMap());
    this.terminalInfoService.getDataGridReturn(cq, true);

    List<TerminalInfoEntity> terminals = dataGrid.getResults();
    List<TerminalInfoPage> results = new ArrayList<TerminalInfoPage>();
    // 添加地理位置
    for (TerminalInfoEntity t : terminals) {
      if (StringUtil.isNotEmpty(t.getGroupid())) {
        TerminalInfoPage page = new TerminalInfoPage();
        MyBeanUtils.copyBeanNotNull2Bean(t, page);
        TSTerritory self = systemService.get(TSTerritory.class, t.getGroupid());
        String territoryName = "";
        List<TSTerritory> ts = new ArrayList<TSTerritory>();
        TSTerritory parent = self.getTSTerritory();
        ts.add(self);
        String pid = parent.getId();
        // 当父组织机构不为根机构时,查找父机构
        while (!"1".equals(pid)) {
          parent = systemService.get(TSTerritory.class, pid);
          ts.add(parent);
          parent = parent.getTSTerritory();
          pid = parent.getId();
        }
        // 按照添加顺序逆序
        Collections.reverse(ts);
        for (TSTerritory te : ts) {
          territoryName += "-" + te.getTerritoryName();
        }
        page.setGroupname(territoryName.substring(1));
        results.add(page);
      }
    }
    dataGrid.setResults(results);
    TagUtil.datagrid(response, dataGrid);
  }