コード例 #1
0
  @RequestMapping(value = "/getComboxs")
  @ResponseBody
  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
  public JSONArray getFuncMenuTops(@RequestParam("codetablename") String codetablename) {
    //		System.out.println("-----------" + voName);
    //		System.out.println("-----------" + code);
    //		System.out.println("-----------" + name);

    List<OptionObject> cacheList = CacheService.getCachelist(codetablename);
    // System.out.println("=================" + cache.get(voName));
    // System.out.println("=================" +
    // cache.get(voName).getObjectValue());

    JSONArray arrays = new JSONArray();
    if (cacheList != null && cacheList.size() > 0) {
      for (int i = 0; i < cacheList.size(); i++) {
        OptionObject optionObject = cacheList.get(i);
        ComboBox bo = new ComboBox();
        bo.setKey(optionObject.getKey());
        bo.setValue(optionObject.getValue());
        bo.setKeyvalue(optionObject.getKeyvalue());
        arrays.add(bo);
      }
    }
    // String jsonString = JSONValue.toJSONString(l1);
    // System.out.println("-----------" + arrays);
    return arrays;
  }
コード例 #2
0
  /**
   * 获取税种的下拉框,目前支持三种税,土地使用税,10,12,20,直接获取税种、税目一次性把数据取出来
   *
   * @param taxcode为空,取所有的税种,多个税种以,号隔开
   * @return
   */
  @RequestMapping(value = "/gettaxcomboxs")
  @ResponseBody
  @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
  public JSONObject getTaxCodeVales(
      @RequestParam("taxcode") String taxcode, @RequestParam("gettaxcode") boolean gettaxcode) {

    JSONObject result = new JSONObject();

    List<OptionObject> cacheList = CacheService.getCachelist(COD_TAXCODE);
    List<OptionObject> cacheList2 = CacheService.getCachelist(COD_TAXORGCODE);

    HashMap<OptionObject, JSONArray> map = new LinkedHashMap<OptionObject, JSONArray>();

    HashMap<String, OptionObject> taxMap = new HashMap<String, OptionObject>();

    for (int i = 0; i < cacheList.size(); i++) {
      OptionObject oo = cacheList.get(i);
      String value = oo.getKey();
      if (!StringUtils.notEmpty(value)) {
        continue;
      }
      String code = value.substring(0, 2);
      if (value.equals(code)) { // 税种
        if (!taxMap.containsKey(code)) {
          map.put(oo, new JSONArray());
          taxMap.put(code, oo);
        }
      } else { // 税目
        if (gettaxcode) {
          if (!taxMap.containsKey(code)) {
            map.put(oo, new JSONArray());
            taxMap.put(code, oo);
          }
          OptionObject optObj = taxMap.get(code);
          JSONArray array = map.get(optObj);
          array.add(oo);
        }
      }
    }
    List<String> taxcodeList = new ArrayList<String>();
    if (StringUtils.notEmpty(taxcode)) {
      String[] taxcodes = taxcode.split(",");
      for (String tc : taxcodes) {
        taxcodeList.add(tc);
      }
    }
    JSONArray keyArray = new JSONArray();
    JSONArray valueArray = new JSONArray();

    if (taxcodeList.size() > 0) {
      for (int i = 0; i < taxcodeList.size(); i++) {
        String key = taxcodeList.get(i);
        OptionObject partKey = taxMap.get(key);
        if (partKey != null) {
          keyArray.add(partKey);
          valueArray.add(map.get(partKey));
        }
      }
    } else {
      for (OptionObject key : map.keySet()) {
        keyArray.add(key);
        valueArray.add(map.get(key));
      }
    }
    result.put("key", keyArray);
    result.put("value", valueArray);
    return result;
  }