示例#1
0
  /**
   * 异常数据datagrid
   *
   * @return
   * @throws Exception
   */
  public String ajaxExceptionDataGrid() throws Exception {

    ActionTemplate.executeAjaxPage(
        this,
        null,
        new ActionAjaxFieldPageCallback() {

          @Override
          public int initTotal() throws Exception {
            return 0;
          }

          @SuppressWarnings("unchecked")
          @Override
          public List<?> initRows() throws Exception {

            List<BatchExceptionData> batchList = null;

            Object obj = request.getSession().getAttribute(BATCH_EXCEPTION_DATA);
            if (obj != null) {

              batchList = (List<BatchExceptionData>) obj;
            }

            return batchList;
          }
        },
        "projectName",
        "projectId",
        "jobNumber",
        "realName",
        "exceptionData");

    return null;
  }
示例#2
0
  public String searchArticleAjax() {
    if (cond == null) {
      cond = new ArticleCond();
    }
    setCondOrderSortByRequest(cond);
    cond.setDevFlag(EnumDevFlag.GUANGZHOU.toString()); // 广州标示

    // 只查看全部公告或者指定的该公司公告
    List<Integer> companyIds = new ArrayList<Integer>();
    companyIds.add(0);
    companyIds.addAll(PermissionUtils.getUserCompanyIdList());
    cond.setSearchCompanyIds(companyIds);

    ActionTemplate.executeAjaxPage(
        this,
        cond,
        new ActionAjaxPageCallback() {

          @Override
          public int initTotal() throws Exception {
            // 分页的做法 DEMO
            return articleServices.findArticleCount(cond);
          }

          // 获取table中要显示的json
          @Override
          public List<Map<String, String>> initRows() throws Exception {

            List<Map<String, String>> retList = new ArrayList<Map<String, String>>();

            List<Article> list = articleServices.findArticlePage(cond);

            if (!CommonUtils.isCollectionEmpty(list)) {

              Map<String, String> map = null;

              // 与jsp中table的表头(th field)定义一致
              for (Article obj : list) {

                map = new HashMap<String, String>();

                map.put("id", String.valueOf(obj.getId()));
                map.put("companyName", DescUtils.getCompanyRealName(obj.getCompanyId()));
                map.put("title", obj.getTitle());
                map.put("summary", obj.getSummary());
                map.put("articleType", obj.getDescArticleType());
                map.put("userRealName", DescUtils.getUserRealName(obj.getCreatedId()));
                map.put("createdTime", DateTimeUtils.toStr(obj.getCreatedTime()));

                retList.add(map);
              }
            }
            return retList;
          }
        });
    return null;
  }
示例#3
0
  /**
   * 批量修改项目
   *
   * @return
   * @throws Exception
   */
  public String batchModifyProject() throws Exception {

    // 先移除之前session中的异常数据

    request.getSession().removeAttribute(BATCH_EXCEPTION_DATA);

    ActionTemplate.executeAjaxMethod(
        this,
        new ActionAjaxMethodModifyNoThrowsExceptionCallback() {

          @Override
          public void modifyMethod() throws Exception {

            String ignoreFirstRowStr = request.getParameter("ignoreFirstRow"); // 是否忽略第一行
            boolean ignoreFirstRow = false;
            if (!CommonUtils.isStrEmpty(ignoreFirstRowStr)) {
              ignoreFirstRow = true;
            }

            List<Cell[]> cellList = ReadXlsUtils.readXls(batchFile, 5, ignoreFirstRow);

            if (CommonUtils.isCollectionEmpty(cellList)) {

              return;
            }

            int companyId = Integer.parseInt(request.getParameter("companyId"));
            CompanyProjectCond proCond = new CompanyProjectCond();
            proCond.setCompanyId(companyId);

            List<CompanyProject> proList = companyProjectServices.findCompanyProjectByCond(proCond);

            List<BatchExceptionData> pojoList = new ArrayList<BatchExceptionData>();
            BatchExceptionData pojo = null;

            for (Cell[] cell : cellList) {

              pojo = modifyUserAccountProject(cell, proList, companyId); // 返回null表示修改成功

              if (pojo != null) {

                pojoList.add(pojo);
              }
            }

            if (!CommonUtils.isCollectionEmpty(pojoList)) {
              // 表示有异常数据
              request.getSession().setAttribute(BATCH_EXCEPTION_DATA, pojoList);
            }
          }
        });

    return null;
  }
示例#4
0
  /**
   * 判断是否有异常数据
   *
   * @return
   * @throws Exception
   */
  public String ajaxExceptionData() throws Exception {

    ActionTemplate.executeAjaxMethod(
        this,
        new ActionAjaxMethodModifyNoThrowsExceptionCallback() {

          @Override
          public void modifyMethod() throws Exception {

            Object obj = request.getSession().getAttribute(BATCH_EXCEPTION_DATA);
            if (obj == null) {
              // 表示没有异常数据
              throw new Exception();
            }
          }
        });

    return null;
  }
示例#5
0
  /**
   * 返回数据
   *
   * @return
   * @throws Exception
   */
  public String xsgjqkReportAjax() throws Exception {
    ActionTemplate.executeAjaxPage(
        this,
        cond,
        new ActionAjaxPageCallback() {

          @Override
          public int initTotal() throws Exception {
            return value;
          }

          @Override
          public List<Map<String, String>> initRows() throws Exception {
            List<Map<String, String>> retList = new ArrayList<Map<String, String>>();
            List<Map> list = null;
            if (!"".equals(cond.getFollowUserId()))
              list = customerFollowServices.findCustomerListByCustomerFollowUser(cond);
            else if (!"".equals(cond.getCompanyId()))
              list = customerFollowServices.findCustomerListByCustomer(cond);
            else if (!"".equals(cond.getProjectId()))
              list = customerFollowServices.findCustomerListByProject(cond);
            if (!CommonUtils.isCollectionEmpty(list)) {
              for (Map obj : list) {
                Map<String, String> map = new HashMap<String, String>();

                map.put("name", obj.get("customerName").toString());
                if (PermissionUtils.hasPermission(
                    EnumPrivCode.PRECUSTOMER_RETRIEVE_TEL, EnumDevFlag.GUANGZHOU)) {
                  map.put("phone1", obj.get("homePhone").toString());
                  map.put("phone2", obj.get("phone").toString());
                } else {
                  map.put("phone1", "********");
                  map.put("phone2", "********");
                }
                map.put("area", obj.get("areaNum").toString());
                map.put("price", obj.get("priceNum").toString());
                map.put("pro", obj.get("projectName").toString());
                map.put("followUserName", obj.get("userId").toString());
                map.put(
                    "createdTime",
                    obj.get("createdTime")
                        .toString()
                        .substring(0, obj.get("createdTime").toString().length() - 2));
                retList.add(map);
              }
            }
            return retList;
          }
        });
    cond.pageSize = 0;
    List<Map<String, String>> downList = new ArrayList<Map<String, String>>();
    List<Map> list = null;
    if (!"".equals(cond.getFollowUserId()))
      list = customerFollowServices.findCustomerListByCustomerFollowUser(cond);
    else if (!"".equals(cond.getCompanyId()))
      list = customerFollowServices.findCustomerListByCustomer(cond);
    else if (!"".equals(cond.getProjectId()))
      list = customerFollowServices.findCustomerListByProject(cond);
    if (!CommonUtils.isCollectionEmpty(list)) {
      for (Map obj : list) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("name", obj.get("customerName").toString());
        map.put("phone1", obj.get("phone").toString());
        map.put("phone2", obj.get("homePhone").toString());
        map.put("area", obj.get("areaNum").toString());
        map.put("price", obj.get("priceNum").toString());
        map.put("pro", obj.get("projectName").toString());
        map.put("followUserName", obj.get("userId").toString());
        map.put(
            "createdTime",
            obj.get("createdTime")
                .toString()
                .substring(0, obj.get("createdTime").toString().length() - 2));
        downList.add(map);
      }
    }
    setDownloadData(downList);

    return null;
  }
示例#6
0
  /**
   * 提交批量新建用户
   *
   * @return
   */
  public String submitBatUser() {
    ActionTemplate.executeAjaxMethod(
        true,
        this,
        new ActionAjaxMethodModifyCallback() {

          @Override
          public void modifyMethodException(Exception e) {
            setUpEasyuiAjaxForFail(e.getMessage());
          }

          @Override
          public void modifyMethod() throws Exception {
            if (SessionUser.getUserId() != ContUserId.ADMIN) {
              throw new Exception("目前仅供系统管理员使用");
            }

            if (selProjectId <= 0) {
              throw new Exception("必须选择项目");
            }

            if (selRoleId <= 0) {
              throw new Exception("必须选择角色");
            }

            Date thisDate = new Date();
            CompanyProject project = companyProjectServices.findCompanyProjectById(selProjectId);

            if (userAccountList == null) {
              userAccountList = new ArrayList<UserAccount>();
            }

            // 每行格式校验
            String strLine[] = userStr.split("\r\n");

            for (int i = 0; i < strLine.length; i++) {
              if (strLine[i].endsWith(",")) {
                strLine[i] = strLine[i] + " ";
              }
              String strUserInfo[] = strLine[i].split(",");

              if (strUserInfo.length != 5) {
                throw new Exception("第" + (i + 1) + "行格式不对");
              }

              UserAccount userAccount = new UserAccount();
              userAccount.setUserName(strUserInfo[0]);
              userAccount.setRealName(strUserInfo[1]);
              userAccount.setRemark(strUserInfo[2]);
              userAccount.setMobilePhone(strUserInfo[3]);
              userAccount.setJobNumber(strUserInfo[4]);

              userAccount.setUserPwd(ContUserId.INIT_PASSWORD);
              userAccount.setAccountType("1");
              userAccount.setCompanyId(project.getCompanyId());
              userAccount.setProjectId(project.getId());
              userAccount.setCreatedId(SessionUser.getUserId());
              userAccount.setCreatedTime(thisDate);
              userAccount.setModId(SessionUser.getUserId());
              userAccount.setModTime(thisDate);
              userAccount.setIsDeleted("0");

              userAccountList.add(userAccount);
            }

            // 用户校验(用户名是否已经存在)
            for (int i = 0; i < userAccountList.size(); i++) {
              if (userAccountServices.findUserAccountByName(userAccountList.get(i).getUserName())
                  > 0) {
                throw new Exception(
                    "用户账号已经存在,无法添加(" + userAccountList.get(i).getUserName() + ")全部账号都不会创建!");
              }
            }

            // 执行保存
            for (int i = 0; i < userAccountList.size(); i++) {
              userAccountServices.saveUserAccount(userAccountList.get(i));

              addRole(userAccountList.get(i), selRoleId);
            }
          }
        });

    return null;
  }