private void updateTotalVA() {
   tv.setText(
       ""
           + (NumberUtils.toInt(batteryVoltage.getText().toString())
               * NumberUtils.toInt(batteryAmpHour.getText().toString())
               * NumberUtils.toInt(batteryCount.getText().toString())));
 }
Example #2
1
  public void createImage(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    response.setContentType("image/jpg");

    /** 取得高度和宽度 */
    String width = request.getParameter("width");
    String height = request.getParameter("height");

    if (StringUtils.isNumeric(width) && StringUtils.isNumeric(height)) {

      w = NumberUtils.toInt(width);
      h = NumberUtils.toInt(height);
    }
    /** */
    BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    createBackground(g);
    /** */
    String s = createCharacter(g);
    request.getSession().setAttribute(VALIDATE_CODE, s);
    g.dispose();
    OutputStream out = response.getOutputStream();
    ImageIO.write(image, "JPEG", out);
    out.close();
  }
  /** {@inheritDoc} */
  public String doExport(final String descriptorGroup, final String fileName, final boolean async) {

    final AsyncContext ctx = getAsyncContext();

    final String imgVault = systemService.getImageRepositoryDirectory();

    // Max char of report to UI since it will get huge and simply will crash the UI, not to mention
    // traffic cost.
    final int logSize =
        NumberUtils.toInt(
            nodeService.getConfiguration().get(AttributeNamesKeys.System.IMPORT_JOB_LOG_SIZE), 100);
    // Timeout - just in case runnable crashes and we need to unlock through timeout.
    final int timeout =
        NumberUtils.toInt(
            nodeService.getConfiguration().get(AttributeNamesKeys.System.IMPORT_JOB_TIMEOUT_MS),
            100);

    final String rootPath = resolveExportDirectory();
    final String absFile = resolveExportFile(fileName);

    return doJob(
        new JobContextImpl(
            async,
            new JobStatusListenerImpl(logSize, timeout),
            new HashMap<String, Object>() {
              {
                put(JobContextKeys.EXPORT_DESCRIPTOR_GROUP, descriptorGroup);
                put(JobContextKeys.EXPORT_FILE, absFile);
                put(JobContextKeys.IMAGE_VAULT_PATH, imgVault);
                put(JobContextKeys.EXPORT_DIRECTORY_ROOT, rootPath);
                putAll(ctx.getAttributes());
              }
            }));
  }
Example #4
0
  /**
   * Aggregate all income receipt for given period The result format is:
   * Map<accountId,'accountName|amount'>
   *
   * @param from
   * @param to
   * @return
   */
  public Map<Integer, Object[]> aggregateIncomeReceiptItem(Date from, Date to) {
    String squery =
        "select ir.account.id, ir.account.name, sum(ir.amount) from IncomeReceiptItem  as ir "
            + " left join ir.receipt as  r  "
            + "where r.receiptDate >= :from and r.receiptDate <= :to "
            + " group by ir.account.name";

    Query query = sessionFactory.getCurrentSession().createQuery(squery);
    query.setParameter("from", from);
    query.setParameter("to", to);
    List result = query.list();
    Map<Integer, Object[]> mapResult = new HashMap<Integer, Object[]>();
    String accountName;
    BigDecimal amount;
    Integer accountId;
    String tmp;
    if (result != null && result.size() > 0) {
      for (Object o : result) {
        Object[] obj = (Object[]) o;
        accountId = NumberUtils.toInt(obj[0].toString());
        mapResult.put(accountId, obj);
      }
    }
    return mapResult;
  }
 @Override
 @Nonnull
 public HstQueryBuilder sizeParam(final String parameterName) {
   String value = SiteUtils.getAnyParameter(parameterName, request, component);
   size = NumberUtils.toInt(value, SiteUtils.DEFAULT_PAGE_SIZE);
   return this;
 }
Example #6
0
  protected MemcachedImpl(boolean isTTStore) throws Exception {
    Properties configuration = new Properties();
    configuration.load(MemcachedImpl.class.getResourceAsStream("/config.properties"));

    List<InetSocketAddress> addrList = new ArrayList<InetSocketAddress>();
    int nb = 1;
    String prefix = isTTStore ? "ttcached." : "memcached.";
    while (configuration.containsKey(prefix + nb + ".host")) {
      String hostandport = configuration.getProperty(prefix + nb + ".host");
      String host = StringUtils.substringBefore(hostandport, ":");
      String portStr = StringUtils.substringAfter(hostandport, ":");
      int port = NumberUtils.toInt(portStr, 11211);
      System.out.println(
          "memcached init [host:" + host + ",port:" + port + ",portStr:" + portStr + "]");
      addrList.add(new InetSocketAddress(host, port));
      nb++;
    }

    if (addrList.size() == 0) {
      throw new Exception("Bad configuration for memcached or tt store");
    }

    MemcachedClientBuilder builder = new XMemcachedClientBuilder(addrList);
    try {
      builder.setConnectionPoolSize(5);
      this.client = builder.build();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
Example #7
0
  public void decreaseIndent() {
    if (currentEditor.getValue().getMediaType().equals(MediaType.XHTML)) {
      XHTMLCodeEditor xhtmlCodeEditor = (XHTMLCodeEditor) currentEditor.getValue();
      XMLTagPair pair =
          xhtmlCodeEditor.findSurroundingTags(new XHTMLCodeEditor.BlockTagInspector());
      if (pair != null) {
        logger.info("found xml block tag " + pair.getTagName());
        String tagAtttributes =
            xhtmlCodeEditor.getRange(pair.getOpenTagEnd(), pair.getTagAttributesEnd());

        Matcher regexMatcher = indentRegex.matcher(tagAtttributes);
        if (regexMatcher.find()) {
          String currentIndentStr = regexMatcher.group(2);
          int currentIndent = NumberUtils.toInt(currentIndentStr, 0);
          String currentUnit = regexMatcher.group(3);
          switch (currentUnit) {
            case "%":
            case "rem":
            case "em":
              currentIndent--;
              break;
            case "px":
              currentIndent = currentIndent - 10;
              break;
          }
          insertStyle("text-indent", currentIndent + currentUnit);
        } else {
          insertStyle("text-indent", "-1em");
        }
      }
    }
  }
Example #8
0
  @RequestMapping("/apply")
  public String getApplyBrandsByPage(HttpServletRequest request) {
    // 处理分页信息
    PageInfo pageInfo = null;

    if (request.getParameter("query") != null) { // 查询
      pageInfo = PageUtils.registerPageInfo(request);

    } else if (request.getParameter("pageNo") != null) { // 分页
      int pageNo = NumberUtils.toInt(request.getParameter("pageNo"), 1);

      pageInfo = PageUtils.getPageInfo(request);
      pageInfo.setPageNo(pageNo);
    } else {
      pageInfo = PageUtils.getPageInfo(request);

      if (pageInfo == null) {
        pageInfo = PageUtils.registerPageInfo(request);
        pageInfo.getConditions().put("status", SystemConstants.DB_STATUS_VALID); // 默认有效
        pageInfo.getConditions().put("createDate", "DESC"); // 默认降序
      }
    }

    request.setAttribute("pageInfo", pageInfo);

    // 查询
    Map<String, Object> map = Maps.newHashMap();

    if (StringUtils.isNotBlank(pageInfo.getConditions().get("brandName"))) {
      map.put("brandName", pageInfo.getConditions().get("brandName"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("coName"))) {
      map.put("coName", pageInfo.getConditions().get("coName").toLowerCase());
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("startDt"))) {
      map.put(
          "startDt", DateUtils.parseDate(pageInfo.getConditions().get("startDt"), "yyyy-MM-dd"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("endDt"))) {
      Date endDt = DateUtils.parseDate(pageInfo.getConditions().get("endDt"), "yyyy-MM-dd");

      endDt = DateUtils.addDay(endDt, 1);

      map.put("endDt", endDt);
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("status"))) {
      map.put("status", pageInfo.getConditions().get("status"));
    }
    if (StringUtils.isNotBlank(pageInfo.getConditions().get("loginName"))) {
      map.put("loginName", pageInfo.getConditions().get("loginName"));
    }

    Page<SellerBrand> sellerBrands =
        this.sellerBrandService.queryWaitAuditApplyByPage(map, pageInfo.getPageNo());

    request.setAttribute("sellerBrands", sellerBrands);

    return "brand/applyList";
  }
Example #9
0
  public static void main(String[] args) {
    String hostandport = "192.168.10.11:11218";
    String host = StringUtils.substringBefore(hostandport, ":");
    Integer port = NumberUtils.toInt(StringUtils.substringAfter(hostandport, ":"), 11211);

    System.out.println(host);
    System.out.println(port);
  }
Example #10
0
 public static int toInt(final Object o) {
   if (o instanceof BigDecimal) {
     return NumberUtil.toInt((BigDecimal) o);
   } else if (o instanceof Number) {
     return new BigDecimal(String.valueOf(o)).intValue();
   } else {
     return NumberUtils.toInt(String.valueOf(o));
   }
 }
  /** 客户端异常查询 */
  @RequestMapping("/exception")
  public ModelAndView doException(
      HttpServletRequest request, HttpServletResponse response, Model model) {
    // 1.1 应用信息
    Long appId = NumberUtils.toLong(request.getParameter("appId"));
    if (appId <= 0) {
      return new ModelAndView("");
    }
    AppDesc appDesc = appService.getByAppId(appId);
    model.addAttribute("appDesc", appDesc);

    // 1.2 异常类型
    int type = NumberUtil.toInt(request.getParameter("type"));
    model.addAttribute("type", type);

    // 1.3 客户端ip
    String clientIp = request.getParameter("clientIp");
    model.addAttribute("clientIp", clientIp);

    // 1.4 日期格式转换
    TimeBetween timeBetween = new TimeBetween();
    try {
      timeBetween = fillWithClientExceptionTime(request, model);
    } catch (ParseException e) {
      logger.error(e.getMessage(), e);
    }

    // 2. 分页查询异常
    int totalCount =
        clientReportExceptionService.getAppExceptionCount(
            appId, timeBetween.getStartTime(), timeBetween.getEndTime(), type, clientIp);
    int pageNo = NumberUtils.toInt(request.getParameter("pageNo"), 1);
    int pageSize = NumberUtils.toInt(request.getParameter("pageSize"), 10);
    Page page = new Page(pageNo, pageSize, totalCount);
    model.addAttribute("page", page);

    List<AppClientExceptionStat> appClientExceptionList =
        clientReportExceptionService.getAppExceptionList(
            appId, timeBetween.getStartTime(), timeBetween.getEndTime(), type, clientIp, page);
    model.addAttribute("appClientExceptionList", appClientExceptionList);

    return new ModelAndView("client/clientException");
  }
Example #12
0
  @Override
  public PageObject queryForMPageList(String sql, Object[] args, Map req) {
    int totalCount = 1;
    int start = NumberUtils.toInt(ObjectUtils.toString(req.get("start"), "1"));
    int limit =
        NumberUtils.toInt(
            ObjectUtils.toString(req.get("limit"), GlobalConstant.Global_PAGESIZE + ""));
    int startIndex = limit * (start - 1);
    String sort = ObjectUtils.toString(req.get("sort"));
    String dir = ObjectUtils.toString(req.get("dir"));

    StringBuffer buildsql = new StringBuffer();
    buildsql.append("select * from ( ");
    if (StringUtils.isNotBlank(sort)) {
      String pa = "order by (,|\\.|\\w|\\d| )+( asc| desc)?( Nulls last)?( Nulls first)?\\s?$";
      String re = " order by " + sort + " " + dir;
      Matcher matcher = Pattern.compile(pa, Pattern.CASE_INSENSITIVE).matcher(sql);
      if (matcher.find()) {
        buildsql.append(matcher.replaceFirst(re));
      }
    } else {
      buildsql.append(sql);
    }
    buildsql.append("	) temp LIMIT " + String.valueOf(startIndex) + "," + String.valueOf(limit));

    systemLog.debugLog(
        getClass(), buildsql.toString() + " : args is " + StringUtils.join(args, ","));
    PageObject page = new PageObject();
    try {
      List list = super.getJdbcTemplate().queryForList(buildsql.toString(), args);
      String countsql = "SELECT COUNT(*) FROM (" + sql + ") TEMP";
      totalCount = super.getJdbcTemplate().queryForInt(countsql, args);
      page.setDatasource(list);
      page.setTotalCount(totalCount);
      int _absolutePage = (int) Math.ceil(totalCount * 1.0 / limit);
      page.setAbsolutePage(_absolutePage);
      int _currentPage = start / limit + 1;
      page.setCurrentPage(_currentPage);
    } catch (Exception e) {
      systemLog.errorLog(getClass(), "--", "--", "--", "--", "--", e);
    }
    return page;
  }
  public void createShare(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    request = wrapRequest(request);
    Player player = playerService.getPlayer(request, response);

    User user = securityService.getCurrentUser(request);
    if (!user.isShareRole()) {
      error(
          request,
          response,
          ErrorCode.NOT_AUTHORIZED,
          user.getUsername() + " is not authorized to share media.");
      return;
    }

    XMLBuilder builder = createXMLBuilder(request, response, true);

    try {

      List<MediaFile> files = new ArrayList<MediaFile>();
      for (String id : ServletRequestUtils.getRequiredStringParameters(request, "id")) {
        MediaFile file = mediaFileService.getMediaFile(NumberUtils.toInt(id));
        files.add(file);
      }

      // TODO: Update api.jsp

      Share share = shareService.createShare(request, files);
      share.setDescription(request.getParameter("description"));
      long expires = ServletRequestUtils.getLongParameter(request, "expires", 0L);
      if (expires != 0) {
        share.setExpires(new Date(expires));
      }
      shareService.updateShare(share);

      builder.add("shares", false);
      builder.add("share", createAttributesForShare(share), false);

      for (MediaFile mediaFile : shareService.getSharedFiles(share.getId())) {
        File coverArt = mediaFileService.getCoverArt(mediaFile);
        AttributeSet attributes =
            restBrowseController.createAttributesForMediaFile(player, coverArt, mediaFile);
        builder.add("entry", attributes, true);
      }

      builder.endAll();
      response.getWriter().print(builder);

    } catch (ServletRequestBindingException x) {
      error(request, response, ErrorCode.MISSING_PARAMETER, getErrorMessage(x));
    } catch (Exception x) {
      LOG.warn("Error in REST API.", x);
      error(request, response, ErrorCode.GENERIC, getErrorMessage(x));
    }
  }
 public Integer checkDynamicCode(String validCode) {
   if (!redisEao.isKeyExist(Constants.REDIS_KEY_PER_LOGIN_DYNAMIC_CODE_PREFIX + validCode)) {
     return 0; // Code在Redis中已过期
   } else {
     Integer id =
         NumberUtils.toInt(
             redisEao.readFromString(
                 Constants.REDIS_KEY_PER_LOGIN_DYNAMIC_CODE_PREFIX + validCode));
     return id;
   }
 }
 public Integer checkSMSValidationCode(String validCode) {
   if (!redisEao.isKeyExist(Constants.REDIS_KEY_PER_SMS_VALIDATION_PREFIX + validCode)) {
     return 0; // Code在Redis中已过期
   } else {
     Integer id =
         NumberUtils.toInt(
             redisEao.readFromString(Constants.REDIS_KEY_PER_SMS_VALIDATION_PREFIX + validCode));
     // 这里需要考虑是否要将这个redis key直接移除掉?还是等它自己的生存周期过期?
     return id;
   }
 }
 public M2ReleaseVersionInfo(final String version, final String nextDevelopmentVersionMode)
     throws VersionParseException {
   super(version);
   // custom field (set next version mode index, acceptable are 1,2 and 3)
   // if latest is coming, we keep there DefaultVersionInfo behavior
   if (StringUtils.startsWith(nextDevelopmentVersionMode, INDEX_PREFIX)) {
     final String indexStr =
         StringUtils.substring(nextDevelopmentVersionMode, INDEX_PREFIX.length());
     nextVersionModeIndex = NumberUtils.toInt(indexStr) - 1;
   }
 }
Example #17
0
  public static int[] toIntArray(final Collection<? extends Object> collection) {
    if (collection == null) {
      return new int[0];
    }
    final int[] numeros = new int[collection.size()];

    int i = 0;
    for (final Object o : collection) {
      numeros[i++] = NumberUtils.toInt(o.toString().trim());
    }
    return numeros;
  }
Example #18
0
  public void fillComInterviewMixInfo(ComInterview comInterview) {
    if (comInterview != null && StringUtils.isBlank(comInterview.getMixInfo())) {
      Integer perId = comInterview.getPerUserId();

      try {
        Map<String, String> map = updateResumeMixInfo(perId, " com_interview ");
        if (NumberUtils.toInt(map.get("resumeId"), 0) > 0
            && map.get("userName") != null
            && StringUtils.isNotBlank(ObjectUtils.toString(map.get("userName")))) {
          comInterview.setResumeId(NumberUtils.toInt(map.get("resumeId"), 0));
          comInterview.setUserName(map.get("userName"));
          comInterview.setGender(NumberUtils.toInt(map.get("gender"), 0));
          comInterview.setAge(NumberUtils.toInt(map.get("age"), 0));
          comInterview.setDegree(NumberUtils.toInt(map.get("degree"), 0));
          comInterview.setMixInfo(map.get("mixInfo"));
          comInterview.setSchoolName(map.get("schoolName"));
          comInterview.setSpeciality(map.get("speciality"));
          comInterview.setSchoolName(map.get("schoolName"));
          comInterview.setJobyearType(NumberUtils.toInt(map.get("jobyearType"), 0));
        } else {
          getJdbcTemplateAction()
              .update(
                  "UPDATE com_blacklist SET mix_info = ? WHERE id=?", "{}", comInterview.getId());
          comInterview.setMixInfo("{}");
        }
      } catch (Exception ex) {
        // 不处理
      }
    }
  }
Example #19
0
  /**
   * Compares <code>version</code> to <code>value</code> version and value are strings like w.x.y.z
   * Returns <code>0</code> if either <code>version</code> or <code>value</code> is null.
   *
   * @param version String like w.x.y.z
   * @param value String like w.x.y.z
   * @return the value <code>0</code> if <code>version</code> is equal to the argument <code>value
   *     </code>; a value less than <code>0</code> if <code>version</code> is numerically less than
   *     the argument <code>value</code>; and a value greater than <code>0</code> if <code>version
   *     </code> is numerically greater than the argument <code>value</code>
   * @should correctly comparing two version numbers
   * @should treat SNAPSHOT as earliest version
   */
  public static int compareVersion(String version, String value) {
    try {
      if (version == null || value == null) return 0;

      List<String> versions = new Vector<String>();
      List<String> values = new Vector<String>();

      // treat "-SNAPSHOT" as the lowest possible version
      // e.g. 1.8.4-SNAPSHOT is really 1.8.4.0
      version = version.replace("-SNAPSHOT", ".0");
      value = value.replace("-SNAPSHOT", ".0");

      Collections.addAll(versions, version.split("\\."));
      Collections.addAll(values, value.split("\\."));

      // match the sizes of the lists
      while (versions.size() < values.size()) {
        versions.add("0");
      }
      while (values.size() < versions.size()) {
        values.add("0");
      }

      for (int x = 0; x < versions.size(); x++) {
        String verNum = versions.get(x).trim();
        String valNum = values.get(x).trim();
        Integer ver = NumberUtils.toInt(verNum, 0);
        Integer val = NumberUtils.toInt(valNum, 0);

        int ret = ver.compareTo(val);
        if (ret != 0) return ret;
      }
    } catch (NumberFormatException e) {
      log.error(
          "Error while converting a version/value to an integer: " + version + "/" + value, e);
    }

    // default return value if an error occurs or elements are equal
    return 0;
  }
 public void setAsText(String text) throws IllegalArgumentException {
   JASService jasService = (JASService) Context.getService(JASService.class);
   if (text != null && text.trim().length() > 0) {
     try {
       setValue(jasService.getItemUnitById(NumberUtils.toInt(text)));
     } catch (Exception ex) {
       log.error("Error setting text: " + text, ex);
       throw new IllegalArgumentException("ItemUnit not found: " + ex.getMessage());
     }
   } else {
     setValue(null);
   }
 }
  private long determineExpiryInMs() {

    final String av =
        systemService.getAttributeValue(AttributeNamesKeys.System.CART_ABANDONED_TIMEOUT_SECONDS);

    if (av != null && StringUtils.isNotBlank(av)) {
      long expiry = NumberUtils.toInt(av) * 1000L;
      if (expiry > 0) {
        return expiry;
      }
    }
    return this.abandonedTimeoutMs;
  }
 /**
  * 读取产品列表
  *
  * @param productQuery
  * @return
  */
 @RequestMapping(value = "/product/list")
 public void productList(ProductQuery productQuery, HttpServletResponse response)
     throws IOException {
   List<Product> productList = new ArrayList<Product>();
   int total = 0;
   if (productQuery.isProductId()) { // 如果有ID筛选
     Product product = productService.getProductById(NumberUtils.toInt(productQuery.getSearch()));
     if (product != null) {
       productList.add(product);
       total = 1;
     }
   } else if (productQuery.getSearch().length() > 0) { // 模糊查询
     Page<Product> page;
     page =
         productService.queryProductByFuzzyPage(
             productQuery.getSearch(), productQuery.getPageNo(), productQuery.getLimit());
     productList = page.getResult();
     total = page.getTotalCount();
   } else {
     Page<Product> page;
     if (productQuery.getCategoryId() > 0) {
       page =
           productService.queryProductsByCategoryIdByPage(
               productQuery.getCategoryId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getCustomerId() > 0) {
       page =
           productService.queryProductsByCustomerIdByPage(
               productQuery.getCustomerId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getBrandId() > 0) {
       page =
           productService.queryProductsByBrandIdByPage(
               productQuery.getBrandId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getStoreId() > 0) {
       page =
           productService.queryProductsByStoreIdByPage(
               productQuery.getStoreId(), productQuery.getPageNo(), productQuery.getLimit());
     } else {
       page =
           productService.queryAllProductsByPage(
               productQuery.getPageNo(), productQuery.getLimit());
     }
     productList = page.getResult();
     total = page.getTotalCount();
   }
   List<ProductModel> productGrid = createProductGrid(productList);
   new JsonResult(true)
       .addData("totalCount", total)
       .addData("result", productGrid)
       .toJson(response);
 }
Example #23
0
 @Override
 public void modify(Object element, String property, Object value) {
   if (!(element != null && COLUMN_QUANTITY.equals(property))) {
     return;
   }
   if (!(element instanceof TableItem)) {
     return;
   }
   if (((TableItem) element).getData() instanceof OrderEntry) {
     OrderEntry entry = (OrderEntry) ((TableItem) element).getData();
     entry.setQuantity(NumberUtils.toInt("" + value));
     this.orderEditor.tableViewer.refresh();
   }
 }
Example #24
0
 public String getCheckInfoAndAsset() throws IOException, DocumentException {
   String id = request.getParameter("id");
   int startIndex = NumberUtils.toInt(getRequestParameter("jtStartIndex"), 0);
   int pageSize = NumberUtils.toInt(getRequestParameter("jtPageSize"), 10);
   List<Object[]> list =
       ServiceProvider.getService(AssetTaskService.class)
           .findCheckInfoAndAssetByTaskId(id, startIndex, pageSize);
   List<Map<String, String>> result = new ArrayList<Map<String, String>>();
   for (Object[] obj : list) {
     Map map = new HashMap();
     map.put("assetNo", obj[0]);
     map.put("assetName", obj[1]);
     map.put("line", obj[2]);
     map.put("station", obj[3]);
     map.put("beginUseDate", obj[4]);
     map.put("checkInfo", obj[5]);
     map.put("checkDate", obj[6]);
     map.put("checkPerson", obj[7]);
     result.add(map);
   }
   renderJson(result, list.size());
   return Action.NONE;
 }
Example #25
0
  /**
   * 显示list页面,普通权限,无法新增任务
   *
   * @throws Exception
   */
  public void inquery() throws Exception {

    request.setAttribute("today", sdfToDate.format(new Date()));

    String pageNo = request.getParameter("pageNo");
    if (StringUtils.isEmpty(pageNo)) {
      pageNo = "0";
    }

    Map<String, String> mapFilter = createFilterMap();

    String start1 = getRequestParameter("start1");
    String start2 = getRequestParameter("start2");

    int startIndex = NumberUtils.toInt(getRequestParameter("jtStartIndex"), 0);
    int pageSize = NumberUtils.toInt(getRequestParameter("jtPageSize"), 10);
    Map<String, String> sort = createSortMap();
    Pagination<AssetTask> page =
        ServiceProvider.getService(AssetTaskService.class)
            .findBy(mapFilter, sort, startIndex, pageSize);

    JsonConfig jsonConfig = basicJsonCfg.copy();
    renderJson(page.getResult(), page.getTotalCount(), jsonConfig);
  }
 /*
  * (non-Javadoc)
  *
  * @see de.hybris.platform.b2bacceleratorfacades.company.CompanyB2BCommerceFacade#validateUserCount()
  */
 @SuppressWarnings("unchecked")
 @Override
 public boolean validateUserCount(final EnergizerB2BUnitModel energizerModel) {
   boolean validateFlag = false;
   if (null != energizerModel.getMaxUserLimit()) {
     final int b2bUnitLimit = NumberUtils.toInt(energizerModel.getMaxUserLimit());
     LOG.info("B2B Unit Count is " + b2bUnitLimit);
     final int totalCustomers = defaultB2BUnitService.getB2BCustomers(energizerModel).size();
     LOG.info("B2B Unit Size is " + totalCustomers);
     final int totalCustomer = defaultB2BUnitService.getB2BCustomers(energizerModel).size() - 1;
     LOG.info("B2B Unit size after is " + totalCustomer);
     validateFlag = (totalCustomers >= b2bUnitLimit) ? true : false;
   }
   return validateFlag;
 }
  @BeforeClass
  public static void startServer() throws Exception {

    String externalServerPort = System.getProperty("external.jetty.server.port");
    if (StringUtils.isNotBlank(externalServerPort)) {
      int port = NumberUtils.toInt(externalServerPort);
      serverUri =
          URI.create("http://localhost:" + port + "/services/advertise/UniqueIDService/v1/");
      return;
    }

    jetty = new SimpleJettyServer();
    jetty.start();
    serverUri = jetty.getServerURI();
    //		serverUri = new URI("/services/advertise/UniqueIDService/v1/");
  }
  private void createResponseBuilderInResourceMethodReturnType(
      final Action action,
      final JDefinedClass responseClass,
      final Entry<String, Response> statusCodeAndResponse)
      throws Exception {
    final int statusCode = NumberUtils.toInt(statusCodeAndResponse.getKey());
    final Response response = statusCodeAndResponse.getValue();

    if (response.getBody() == null || response.getBody().isEmpty()) {
      createResponseBuilderInResourceMethodReturnType(responseClass, statusCode, response, null);
    } else {
      for (final MimeType mimeType : response.getBody().values()) {
        createResponseBuilderInResourceMethodReturnType(
            responseClass, statusCode, response, mimeType);
      }
    }
  }
  private int getLimitSizeConfig(
      final long categoryId,
      final long shopId,
      final String limitAttribute,
      final int defaultLimit) {

    if (categoryId > 0L && shopService.getShopContentIds(shopId).contains(categoryId)) {

      final String size =
          contentService.getContentAttributeRecursive(null, categoryId, limitAttribute, null);
      if (size != null) {
        return NumberUtils.toInt(size, defaultLimit);
      }
    }

    return defaultLimit;
  }
  public String getHtComplication() {

    try {
      // 患者ID取得
      int patientId =
          NumberUtils.toInt(ActionContext.getContext().getSession().get("PatientID").toString());

      // 患者ID要从session里取得
      List<PatientNowComplicationsChecked> result = readMapper.selectByPatientId(patientId);

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

      // 疾病勾选
      for (PatientNowComplicationsChecked record : result) {
        codemap.put(record.getDiseaseidvalue(), record.getDiseaseidvalue());
      }

      ModelMap modelMap = new ModelMap();
      modelMap.setResult(codemap);

      // 将java对象转成json对象
      HttpServletResponse response = ServletActionContext.getResponse();
      // 以下代码从JSON.java中拷过来的
      response.setContentType("text/html");
      PrintWriter out;
      out = response.getWriter();
      modelMap.setResult(codemap);
      // 将java对象转成json对象
      JSONObject jsonObject = JSONObject.fromObject(modelMap); // 转换为json

      out.print(jsonObject);
      out.flush();
      out.close();

    } catch (Exception e) {
      return null;
    }

    return SUCCESS;
  }