Пример #1
0
  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = new JSONArray().toString();
    String mode = this.getMode();
    try {

      if (ALEipConstants.MODE_INSERT.equals(mode)) {
        //
        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doInsert(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }

      } else if (ALEipConstants.MODE_UPDATE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if (ALEipConstants.MODE_DELETE.equals(mode)) {

        ToDoFormData formData = new ToDoFormData();
        formData.initField();
        formData.loadCategoryList(rundata);
        if (formData.doDelete(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_delete".equals(mode)) {

        ToDoMultiDelete delete = new ToDoMultiDelete();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else if ("multi_complete".equals(mode)) {

        ToDoMultiStateUpdate delete = new ToDoMultiStateUpdate();
        if (delete.doMultiAction(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      }
    } catch (Exception e) {
      logger.error("[ToDoFormJSONScreen]", e);
    }

    return result;
  }
Пример #2
0
  @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
  public ModelAndView main(
      Product product, PageParameter page, ModelMap model, HttpSession httpSession) {
    User user =
        httpSession.getAttribute("user") != null ? (User) httpSession.getAttribute("user") : null;

    //		if(httpSession.getAttribute("resTopList")==null){
    JSONArray toplist = JSONArray.fromObject(mainService.getResource(user, "top"));
    JSONArray leftlist = JSONArray.fromObject(mainService.getResource(user, "left"));
    httpSession.setAttribute("resTopList", toplist);
    httpSession.setAttribute("resList", leftlist);
    //		}
    Notice notice = new Notice();

    try {
      model.addAttribute("notices", noticeService.getNotices(notice, page));
    } catch (DaoException e) {
      logger.error("", e);
    }
    User us = new User();
    us.setUserId(user.getUserId());
    User u = (User) userDao.getUser(us);
    model.addAttribute("userbean", u);

    return new ModelAndView("main.jsp");
  }
Пример #3
0
  @SuppressWarnings("rawtypes")
  public List<Code> GetCodeCache() {
    List<Code> list = new ArrayList<Code>();

    if (MemCached.used()) {
      Object obj = MemCached.getInstance().get("Code");
      if (obj != null && !obj.equals("")) {
        String json = MemCached.getInstance().get("Code").toString();

        JSONArray array = JSONArray.fromObject(json);
        for (Iterator iter = array.iterator(); iter.hasNext(); ) {
          JSONObject jsonObject = (JSONObject) iter.next();
          list.add((Code) JSONObject.toBean(jsonObject, Code.class));
        }
      } else {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("status", "Y");
        list = this.findForUnPage(params);

        JSONArray jsonObject = JSONArray.fromObject(list);

        MemCached.getInstance().set("Code", jsonObject);
      }
    }

    return list;
  }
  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = new JSONArray().toString();
    String mode = this.getMode();
    try {

      if (ALEipConstants.MODE_UPDATE_PASSWD.equals(mode)) {
        AccountPasswdFormData formData = new AccountPasswdFormData();
        formData.initField();
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      } else {
        AccountEditFormData formData = new AccountEditFormData();
        formData.initField();
        if (formData.doUpdate(this, rundata, context)) {
        } else {
          JSONArray json = JSONArray.fromObject(context.get(ALEipConstants.ERROR_MESSAGE_LIST));
          result = json.toString();
        }
      }
    } catch (Exception e) {
      logger.error("AccountPersonFormJSONScreen.getJSONString", e);
    }

    return result;
  }
  @Override
  public Object processArrayValue(Object value, JsonConfig jsonConfig) {
    PropertyDescriptor pd = null;
    Method method = null;
    StringBuffer json = new StringBuffer("{");
    try {
      for (int i = 0; i < properties.length; i++) {
        pd = new PropertyDescriptor(properties[i], clazz);
        method = pd.getReadMethod();
        Object obj = method.invoke(value);
        String v = String.valueOf(method.invoke(value));
        // System.out.println(v + "  one
        // ......................................."+obj.getClass()+".............................................");

        if (obj instanceof ArticleType) {
          v = ((ArticleType) obj).getName();
        }
        // 该方法有错,不能处理set类型的tagstype
        if (obj instanceof org.hibernate.collection.internal.PersistentSet) {
          Set<TagsType> tagsTypes = (Set<TagsType>) obj;
          List<String> tagsNameList = new ArrayList<String>();
          Iterator<TagsType> iterator = tagsTypes.iterator();
          while (iterator.hasNext()) {
            tagsNameList.add(iterator.next().getName());
          }
          String tagsNameJSONModel = JSONArray.fromObject(tagsNameList).toString();

          json.append("'" + properties[i] + "':'" + tagsNameJSONModel + "'");
          json.append(i != properties.length - 1 ? "," : "");
          continue;
        }
        if (obj instanceof HashSet) {
          Set<TagsType> tagsTypes = (Set<TagsType>) obj;
          List<String> tagsNameList = new ArrayList<String>();
          Iterator<TagsType> iterator = tagsTypes.iterator();
          while (iterator.hasNext()) {
            tagsNameList.add(iterator.next().getName());
          }
          String tagsNameJSONModel = JSONArray.fromObject(tagsNameList).toString();

          json.append("'" + properties[i] + "':'" + tagsNameJSONModel + "'");
          json.append(i != properties.length - 1 ? "," : "");
          continue;
        }
        if (obj instanceof User) {
          v = ((User) obj).getName();
        }
        json.append("'" + properties[i] + "':'" + v + "'");
        json.append(i != properties.length - 1 ? "," : "");
      }
      json.append("}");
    } catch (Exception e) {
      e.printStackTrace();
    }
    return JSONObject.fromObject(json.toString());
  }
Пример #6
0
 private void retrieveTasks(UpdateInfo updateInfo, long since, boolean update)
     throws RateLimitReachedException, Exception {
   String key = getKey(updateInfo);
   String urlString = TOODLEDO_TASKS_GET + "?key=" + key + "&after=" + since;
   String tasksJson = restHelper.makeRestCall(connector(), updateInfo.getGuestId(), 1, urlString);
   JSONArray tasksArray = JSONArray.fromObject(tasksJson);
   JSONObject arrayInfo = tasksArray.getJSONObject(0);
   for (int i = 0; i < arrayInfo.getInt("total"); i++) {
     JSONObject task = tasksArray.getJSONObject(i + 1);
     if (task.has("total")) continue;
     long toodledo_id = task.getLong("id");
     if (update) {
       ToodledoTaskFacet oldTask =
           jpaDaoService.findOne(
               "toodledo.task.byToodledoId",
               ToodledoTaskFacet.class,
               updateInfo.getGuestId(),
               toodledo_id);
       if (oldTask != null) jpaDaoService.remove(oldTask.getClass(), oldTask.getId());
     }
     ToodledoTaskFacet taskFacet = new ToodledoTaskFacet();
     taskFacet.guestId = updateInfo.getGuestId();
     taskFacet.toodledo_id = toodledo_id;
     if (task.has("goal")) taskFacet.goal = task.getLong("goal");
     taskFacet.modified = task.getLong("modified");
     taskFacet.completed = task.getLong("completed");
     if (taskFacet.completed != 0) {
       taskFacet.start = taskFacet.modified * 1000;
       taskFacet.end = taskFacet.modified * 1000;
     }
     taskFacet.title = task.getString("title");
     taskFacet.api = connector().value();
     taskFacet.objectType = 1;
     jpaDaoService.persist(taskFacet);
   }
   if (update) {
     urlString = TOODLEDO_TASKS_GET_DELETED + "?key=" + key + "&after=" + since;
     String tasksToDeleteJson =
         restHelper.makeRestCall(connector(), updateInfo.getGuestId(), 1, urlString);
     JSONArray tasksToDeleteArray = JSONArray.fromObject(tasksToDeleteJson);
     arrayInfo = tasksToDeleteArray.getJSONObject(0);
     for (int i = 0; i < arrayInfo.getInt("num"); i++) {
       JSONObject task = tasksToDeleteArray.getJSONObject(i + 1);
       long toodledo_id = task.getLong("id");
       ToodledoTaskFacet taskToDelete =
           jpaDaoService.findOne(
               "toodledo.task.byToodledoId",
               ToodledoTaskFacet.class,
               updateInfo.getGuestId(),
               toodledo_id);
       if (taskToDelete != null)
         jpaDaoService.remove(taskToDelete.getClass(), taskToDelete.getId());
     }
   }
 }
  @RequestMapping(value = "/generateHistoryFile", method = RequestMethod.POST)
  @ResponseBody
  public void generateHistoryFile(HttpServletRequest request, HttpServletResponse response) {
    String foldername = request.getParameter("foldername");
    String reqstate = request.getParameter("reqstate");
    if (reqstate.equalsIgnoreCase("success")) {
      JSONArray ja = JSONArray.fromObject(request.getParameter("testresultitemcollectionjson"));
      for (int i = 0; i < ja.length(); i++) {
        TestResultItem tri = new TestResultItem();
        try {
          JSONObject itemobj = ja.getJSONObject(i);
          String result = itemobj.getString("result");
          tri.setResult(result);
          if (!result.equals(TestStatus.exception)) {
            Set<CheckPointItem> cps = new HashSet<CheckPointItem>();

            tri.setTime(itemobj.getString("time"));
            tri.setRequestInfo(itemobj.getString("requestInfo"));
            tri.setResponseInfo(itemobj.getString("responseInfo"));
            tri.setDuration(itemobj.getString("duration"));

            Object[] callbackarr = JSONArray.fromObject(itemobj.get("callback")).toArray();
            tri.setCallback(new HashSet(Arrays.asList(callbackarr)));
            JSONArray jsonarr = JSONArray.fromObject(itemobj.get("checkPoint"));
            for (int j = 0; j < jsonarr.length(); j++) {
              CheckPointItem item =
                  (CheckPointItem)
                      JSONObject.toBean(jsonarr.getJSONObject(j), CheckPointItem.class);
              cps.add(item);
            }
            tri.setCheckPoint(cps);
          } else tri.setComment(itemobj.getString("comment"));
        } catch (Exception e) {
          tri.setDuration("");
          tri.setResult(TestStatus.exception);
          tri.setComment(e.getClass().toString() + ": " + e.getMessage());
        } finally {
          testExecuteService.generateHistoryFile(foldername, tri);
        }
      }
    } else {
      TestResultItem tri = new TestResultItem();
      tri.setDuration("");
      tri.setResult(TestStatus.exception);
      String comment = "";
      String json = request.getParameter("obj");
      if (json.startsWith("{") && json.endsWith("}"))
        comment = JSONObject.fromObject(json).get("comment").toString();
      else if (json.startsWith("[") && json.endsWith("]"))
        comment = JSONArray.fromObject(json).getJSONObject(0).get("comment").toString();
      tri.setComment(comment);
      testExecuteService.generateHistoryFile(foldername, tri);
    }
  }
Пример #8
0
  @RequestMapping("/m2")
  public ModelAndView main2(
      Product product, PageParameter page, ModelMap model, HttpSession httpSession) {
    User user =
        httpSession.getAttribute("user") != null ? (User) httpSession.getAttribute("user") : null;
    //		if(httpSession.getAttribute("resTopList")==null){
    JSONArray toplist = JSONArray.fromObject(mainService.getResource(user, "top"));
    JSONArray leftlist = JSONArray.fromObject(mainService.getResource(user, "left"));
    httpSession.setAttribute("resTopList", toplist);
    httpSession.setAttribute("resList", leftlist);
    //		}

    return new ModelAndView("main2.jsp");
  }
Пример #9
0
 public UsersManager() {
   vip = false;
   String context = new Run().ReadFile("C:\\Users\\hp\\IdeaProjects\\Pos\\index.json");
   user = JSONArray.fromObject(context);
   setIntegral();
   setVip();
 }
Пример #10
0
  @org.junit.Test
  public void testGetTankerList() {
    for (int i = 10; i < 34; i++) {
      Map<String, Object> fieldMap2 = new HashMap<String, Object>();
      fieldMap2.put("stationCode", i + "");
      dao.deleteEntityByFiled(com.hcwins.vehicle.fleet.entity.mongo.device.Tanker.class, fieldMap2);
      com.hcwins.vehicle.fleet.entity.mongo.device.Tanker tanker =
          new com.hcwins.vehicle.fleet.entity.mongo.device.Tanker();
      tanker.setStationCode(i + "");
      tanker.setStationName("test_tanker_" + i);
      tankerDao.addEntity(tanker);
    }

    String fullUrl = baseUrl + "device/tanker/getTankerList?stationName=test_tan&pageSize=2000";
    WebResource.Builder builder = getBuilder(fullUrl);
    GetTankerPageResponse response = builder.get(GetTankerPageResponse.class);
    List<Tanker> cardList = response.getData().getTankerList();
    Assert.assertEquals(response.getCode(), "0000");
    Assert.assertEquals(cardList.size(), 24);

    fullUrl = baseUrl + "device/tanker/getTankerList?pageSize=2000";
    builder = getBuilder(fullUrl);
    response = builder.get(GetTankerPageResponse.class);
    cardList = response.getData().getTankerList();
    logger.info(JSONArray.fromObject(cardList).toString());
    Assert.assertEquals(response.getCode(), "0000");
    logger.info("cardList.size : " + cardList.size());
  }
Пример #11
0
  /** 首页管理:插入或更新 */
  public void commit() {
    // Object[] arr = super.toJavaArr(info, FpageEvent.class);
    // FpageEvent[] events = castToFpageEvent(arr);

    JSONArray jsonArray = new JSONArray();
    jsonArray = jsonArray.fromObject(info);
    FpageEvent[] events = new FpageEvent[jsonArray.size()];
    if (jsonArray.size() > 0) {
      for (int i = 0; i < jsonArray.size(); i++) {
        events[i] = new FpageEvent();
        JSONObject jsonObject = jsonArray.getJSONObject(i);
        events[i].setId(Long.parseLong(jsonObject.getString("id")));
        events[i].setWeight(jsonObject.getInt("weight"));
        events[i].setTitle(jsonObject.getString("title"));
        events[i].setDescription(jsonObject.getString("description"));
        events[i].setPublicationId(jsonObject.getLong("publicationId"));
        events[i].setIssueId(jsonObject.getLong("issueId"));
        events[i].setPageNo(jsonObject.getInt("pageNo"));
        events[i].setEndPageNo(jsonObject.getInt("endPageNo"));
        events[i].setImgFile(jsonObject.getString("imgFile"));
        events[i].setWidth(Float.parseFloat(jsonObject.getString("width")));
        events[i].setHeight(Float.parseFloat(jsonObject.getString("height")));
        events[i].setStatus(jsonObject.getInt("status"));
        events[i].setIsPubCover(jsonObject.getInt("isPubCover"));
        events[i].setIsRecommend(jsonObject.getInt("isRecommend"));
        events[i].setIsSuitMobile(jsonObject.getInt("isSuitMobile"));
      }
      this.fpageEventService.commit(events);
    }
  }
Пример #12
0
  @Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
  @Override
  public String getUserMenu(User user) {
    String loginName = user.getLoginName(); // 获得登录用户的logiName
    StringBuilder resultStr = new StringBuilder(); // 定义最终返回的 json 格式的字符串

    // 根据登录的用户名loginName,获取该用户对应的顶级菜单
    String topMenuSql =
        "select a.id,a.name,a.icon,a.url from wxw_sys_menu a where a.id in " //
            + " (select md.menuId from wxw_menu_dept md where md.deptId in " //
            + " (select u.departmentId from wxw_user u where loginName=:loginName))" //
            + " order by orderNum asc";
    logger.debug("topMenuSql:" + topMenuSql);

    Query sqlQuery =
        getSession()
            .createSQLQuery(topMenuSql) //
            .setParameter("loginName", loginName) //
            .setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP);

    List resultList = sqlQuery.list();

    if (!(resultList == null || resultList.size() == 0)) {
      for (int i = 0; i < resultList.size(); i++) {
        // 这里返回的 resultList 本身就类似于 Map,所以强转不会粗问题~~
        Map resultMap = (Map) resultList.get(i);
        // logger.debug("menu_icon:"+resultMap.get("menu_icon"));
        if (0 == i) {
          resultStr.append("{'menus':[");
        }
        resultStr.append("{'id':'" + resultMap.get("id") + "',");
        resultStr.append("'icon':'" + resultMap.get("icon") + "',");
        resultStr.append("'name':'" + resultMap.get("name") + "',");
        resultStr.append("'menus':");
        String subMenuSql =
            "select a.id,a.name,a.icon,a.url from wxw_sys_menu a " //
                + " where a.level = :level and a.parentId = :pId";
        List resultSubMenuList =
            getSession()
                .createSQLQuery(subMenuSql) //
                .setParameter("level", 2) //
                .setParameter("pId", resultMap.get("id")) //
                .setResultTransformer(CriteriaSpecification.ALIAS_TO_ENTITY_MAP) //
                .list();
        resultStr.append(JSONArray.fromObject(resultSubMenuList));

        if (i != (resultList.size() - 1)) {
          resultStr.append("},");
        }

        if (i == (resultList.size() - 1)) {
          resultStr.append("}]}");
        }
      }
    }

    logger.debug("jsonMenus:" + resultStr);

    return resultStr.toString();
  }
Пример #13
0
  public String getNotCompleteCashOrder() {
    int notCompleteOrder = 0;
    try {
      BetPlanOrderServiceInterf orderServer =
          ApplicationContextUtils.getService(
              "lotteryBetOrderService", BetPlanOrderServiceInterf.class);
      List<Integer> winStatus = new ArrayList<Integer>();
      List<Integer> orderStatus = new ArrayList<Integer>();
      orderStatus.add(0);
      orderStatus.add(1);
      orderStatus.add(2);
      orderStatus.add(3);

      notCompleteOrder =
          orderServer.queryOrderNumByStatus(
              Integer.parseInt(this.getP_lotteryId()),
              this.getP_termNo_begin(),
              orderStatus,
              winStatus); // 查是否还有需要确认出票处理的订单
    } catch (Exception e) {
      e.printStackTrace();
    }
    this.jsonString = JSONArray.fromObject(notCompleteOrder).toString();
    return "ajaxjson";
  }
Пример #14
0
  public String query() throws IOException {
    List<Song> songs = songService.findSongs();

    JsonConfig jc = new JsonConfig();
    jc.setExcludes(
        new String[] {
          "recorder",
          "copyright",
          "size",
          "initiateName",
          "keyword",
          "date",
          "description",
          "singer"
        });

    JSONArray jsonArray = JSONArray.fromObject(songs, jc);

    String json = jsonArray.toString();

    System.out.print(json);
    ServletActionContext.getResponse().setContentType("text/json;charset=UTF-8");
    System.out.println(json);
    ServletActionContext.getResponse().getWriter().print(json);

    return NONE;
  }
Пример #15
0
 /**
  * 请求报表权限页面
  *
  * @param roleId
  * @param model
  * @return
  */
 @RequestMapping(value = "/authReport{userId}")
 public String authReport(@PathVariable int userId, Model model) {
   List<ReportDesign> reportList = reportService.listAllReport();
   User user = userService.getUserById(userId);
   // 获得用户的角色权限
   if (user != null) {
     int roleId = user.getRoleId();
     Role role = roleService.getRoleById(roleId);
     String roleRights = role.getReportRights();
     String reportRights = user.getReportRights();
     if (reportList != null && reportList.size() > 0 && Tools.notEmpty(reportRights)) {
       reportChecked(reportList, reportRights);
       // 角色权限
       // roleReportChecked(reportList, roleRights);
     }
   }
   // if (Tools.notEmpty(reportRights)) {
   // reportChecked(reportList, reportRights);
   // }
   JSONArray arr = JSONArray.fromObject(reportList);
   String json = arr.toString();
   json =
       json.replaceAll("reportId", "id")
           .replaceAll("reportName", "name")
           .replaceAll("subReport", "nodes")
           .replaceAll("hasReport", "checked");
   model.addAttribute("zTreeNodes", json);
   model.addAttribute("userId", userId);
   return "user/authorizationReport";
 }
Пример #16
0
 /**
  * 请求用户授权页面
  *
  * @param userId
  * @param model
  * @return
  */
 @RequestMapping(value = "/auth{userId}")
 public String auth(@PathVariable int userId, Model model) {
   List<Menu> menuList = menuService.listAllMenu();
   User user = userService.getUserById(userId);
   String userRights = "";
   if (user != null) {
     userRights = user.getRights();
   }
   if (Tools.notEmpty(userRights) && menuList != null && menuList.size() > 0) {
     for (Menu menu : menuList) {
       menu.setHasMenu(RightsHelper.testRights(userRights, menu.getMenuId()));
       if (menu.isHasMenu()) {
         List<Menu> subRightsList = menu.getSubMenu();
         for (Menu sub : subRightsList) {
           sub.setHasMenu(RightsHelper.testRights(userRights, sub.getMenuId()));
         }
       }
     }
   }
   JSONArray arr = JSONArray.fromObject(menuList);
   String json = arr.toString();
   json =
       json.replaceAll("menuId", "id")
           .replaceAll("menuName", "name")
           .replaceAll("subMenu", "nodes")
           .replaceAll("hasMenu", "checked");
   model.addAttribute("zTreeNodes", json);
   model.addAttribute("userId", userId);
   return "user/authorization";
 }
Пример #17
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response) {

    try {
      request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e1) {
      e1.printStackTrace();
    }

    String kind = request.getParameter("kind");
    ModifyRole mu = new ModifyRole();
    String result = "wrong";

    if (kind.equals("role")) {
      String user = request.getParameter("user");
      String role = request.getParameter("role");

      List roles = mu.getAllRole(user, role);
      JSONArray jsonList = JSONArray.fromObject(roles);
      result = jsonList.toString();
    }

    response.setContentType("text/html;charset=UTF-8");
    PrintWriter pout = null;
    try {
      pout = response.getWriter();
    } catch (IOException e) {
      e.printStackTrace();
    }
    pout.print(result);
  }
 // 根据编号获得团购
 @Action(
     value = "searchGroupon",
     interceptorRefs = {@InterceptorRef(value = "userActionStack")},
     results = {@Result(name = SUCCESS, type = "json")})
 public String searchGroupon() {
   User sessionUser = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
   // 获得这个学校所有的团购项目
   if (groupon.getName() != null) {
     //            name = CommonUtil.getSortString(name.trim());
     name = "%" + groupon.getName() + "%";
   }
   List<Groupon> groupons =
       grouponService.effectiveGroupons(sessionUser.getSchool().getId(), page, name);
   List<GrouponBean> grouponBeanList = new ArrayList<>();
   for (int i = 0; i < groupons.size(); i++) {
     GrouponBean bean = new GrouponBean();
     bean.setId(groupons.get(i).getId());
     bean.setName(groupons.get(i).getName());
     bean.setClassNo(groupons.get(i).getClassNo());
     bean.setTel(groupons.get(i).getTel());
     bean.setEndTime(CommonUtil.dateToString(groupons.get(i).getEndTime()));
     grouponBeanList.add(bean);
   }
   String json = JSONArray.fromObject(grouponBeanList).toString();
   PrintWriter writer = CommonUtil.getJsonPrintWriter(ServletActionContext.getResponse());
   writer.write(json);
   writer.flush();
   writer.close();
   return SUCCESS;
 }
Пример #19
0
  @RequestMapping(value = "/BoothRentFeeList", produces = "application/json")
  @ResponseBody
  public Map<String, Object> boothInfoList(HttpServletRequest request) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();

    HashMap<String, String> param = new HashMap<String, String>();
    List<BoothRentFeeDto> list = null;

    String groupId = request.getParameter("groupId");
    String boothId = request.getParameter("boothId");
    String rentYear = request.getParameter("rentYear");
    String rentMonth = request.getParameter("rentMonth");
    String rentFeeType = request.getParameter("rentFeeType");
    String payOnsite = request.getParameter("payOnsite");

    if (StringUtils.isNotBlank(groupId)) param.put("groupId", groupId);
    if (StringUtils.isNotBlank(boothId)) param.put("boothId", boothId);
    if (StringUtils.isNotBlank(rentYear)) param.put("rentYear", rentYear);
    if (StringUtils.isNotBlank(rentMonth)) param.put("rentMonth", rentMonth);
    if (StringUtils.isNotBlank(rentFeeType)) param.put("rentFeeType", rentFeeType);
    if (StringUtils.isNotBlank(payOnsite)) param.put("payOnsite", payOnsite);

    list = boothRentFee.getRentFeeList(param);

    JSONArray jsonList = new JSONArray();
    jsonList = JSONArray.fromObject(JSONSerializer.toJSON(list));

    model.put("jsonList", jsonList);

    return model;
  }
Пример #20
0
 public List<List> getHaoYou(String yhbh, String key) {
   web = new HttpWebs();
   web.init();
   list = new ArrayList<List>();
   GetUrl getUrl = new GetUrl();
   String url = getUrl.getUrl("findFriend_url");
   Map<String, String> parmMap = new HashMap<String, String>();
   parmMap.put("uid", yhbh);
   parmMap.put("key", key);
   String sb = web.callByGet(url, parmMap);
   JSONArray array = JSONArray.fromObject("[" + Base64Util.decrypt(sb) + "]");
   JSONObject jsonObject = array.getJSONObject(0);
   String msgCode = jsonObject.get("msgCode").toString();
   try {
     if ("1".equals(msgCode)) {
       String uids = jsonObject.get("uids").toString();
       String[] uidlist = uids.split(",");
       for (int i = 0; i < uidlist.length; i++) {
         String uid = uidlist[i];
         printHtml(uid);
       }
     }
     return list;
   } catch (SQLException e) {
     e.printStackTrace();
     return list;
   }
 }
Пример #21
0
  public String sddata() {
    try {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("staffno", staffno);
      if (!statusid.equals("")) {
        String statusWhere =
            " CHARINDEX(','+CAST(A.StatusId AS VARCHAR(4))+',','," + statusid + ",') > 0 ";
        params.put("statusWhere", statusWhere);
      }
      params.put("starttime", startDate);
      params.put("endtime", endDate);

      List<StatusDetail> lists = statusDetailService.retrieveForMod(params);
      for (StatusDetail entity : lists) {
        entity.setStatusName(HelperUtils.getLanguageValue("zh", entity.getStatusName()));
      }
      JsonConfig jsonConfig = new JsonConfig();
      jsonConfig.registerJsonValueProcessor(
          Date.class, new JsonDateValueProcessor("yyyy-MM-dd HH:mm:ss"));
      JSONArray json = JSONArray.fromObject(lists, jsonConfig);
      String s = json.toString();
      postJSON("{\"rows\":" + s + "}");
    } catch (Exception ex) {
      throw ex;
    }
    return null;
  }
Пример #22
0
  public String getUserAuthorization() {

    User user = userService.findUserById(userid);

    if (user == null) {
      ret.put("retCode", "1001");
      ret.put("retMSG", "该用户不存在");
      return "success";
    }

    Integer userauth = user.getAuthorization();

    List<Permission> pers = permissionService.findAllPermissions();

    List<Permission> auth = new ArrayList<Permission>();

    // magic here, don't touch
    for (int i = 0; i < pers.size(); i++) {
      Double d = Math.pow(2, pers.get(i).getValue());
      if ((userauth & d.intValue()) != 0) {
        auth.add(pers.get(i));
      }
    }
    JSONArray ja = JSONArray.fromObject(auth);
    ret.put("auth", ja);
    ret.put("retCode", "1000");
    ret.put("retMSG", "操作成功");
    return "success";
  }
Пример #23
0
  // 查看开票、支付明细信息
  @SuppressWarnings("unchecked")
  public String viewPayDetail() {
    Map pm = getRequestParams();
    List paymentDetail = erpService.findByList(pager, "shcb_erp_sql.getPaymentDetail", pm);

    return ajaxJson(JSONArray.fromObject(paymentDetail).toString());
  }
Пример #24
0
	public String refreshToken(String refresh_token){
		
		String response = null;
		
		String Client_id = AppConfig.APP_ID;
		String Client_secret = AppConfig.APP_SECRET;
		String Url = "https://graph.renren.com/oauth/token?"+
		    "grant_type=refresh_token&"+
		    "refresh_token="+refresh_token+"&"+
		    "client_id="+Client_id+"&"+
		    "client_secret="+Client_secret;
		HttpClient client = new HttpClient();
		PostMethod method = new PostMethod (Url);
		
		try{
			client.executeMethod(method);
			if(method.getStatusCode()== HttpStatus.SC_OK){
				response = method.getResponseBodyAsString();
			}
		}catch (IOException e) {
			// TODO: handle exception
			System.out.println("Exception happend when processing Http Post:"+Url+"\n"+e);
		}finally{
			method.releaseConnection();
		}
		System.out.println("[FeedStub : run]"+response);
		
		net.sf.json.JSONArray jsonarray = net.sf.json.JSONArray.fromObject(response);
		net.sf.json.JSONObject jsonobject = jsonarray.getJSONObject(0);
		
		return (String) jsonobject.get("access_token");
	}
	public String items(){
		List<Object[]> itemsAll = bidItemsDao.getAllBidItemsByEntpId(getUser().getProjectId(),getUser().getEntpId());
			
		try {
			List<Items> dd = new java.util.ArrayList<Items>();
			
			for(Object item : itemsAll){
				
				Object[] imo = ((Object[])item);
				if(imo[1].toString().indexOf("\\")!= -1){
					imo[1]=imo[1].toString().replace("\\", "/");
				}
				
				Items i = new Items(imo[0].toString(), imo[2].toString(), imo[1].toString());
				dd.add(i);
			}
			JSONArray jsonArray = JSONArray.fromObject(dd);
			
			itemsAllString = jsonArray.toString();
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "items";
	}
  @Override
  protected String getJSONString(RunData rundata, Context context) throws Exception {
    String result = "";
    JSONArray json;

    try {

      String mode = rundata.getParameters().getString("mode");
      if ("group".equals(mode)) {
        String groupname = rundata.getParameters().getString("groupname");

        json =
            JSONArray.fromObject(
                AddressBookUserUtils.getAddressBookUserLiteBeansFromGroup(
                    groupname, ALEipUtils.getUserId(rundata)));
      } else {
        json = new JSONArray();
      }
      result = json.toString();
    } catch (Exception e) {
      logger.error("AddressBookUserLiteJSONScreen.getJSONString", e);
    }

    return result;
  }
Пример #27
0
  /**
   * Saves the form to the configuration and disk.
   *
   * @param req StaplerRequest
   * @param rsp StaplerResponse
   * @throws ServletException if something unfortunate happens.
   * @throws IOException if something unfortunate happens.
   * @throws InterruptedException if something unfortunate happens.
   */
  public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp)
      throws ServletException, IOException, InterruptedException {
    getProject().checkPermission(AbstractProject.BUILD);
    if (isRebuildAvailable()) {
      if (!req.getMethod().equals("POST")) {
        // show the parameter entry form.
        req.getView(this, "index.jelly").forward(req, rsp);
        return;
      }
      build = req.findAncestorObject(AbstractBuild.class);
      ParametersDefinitionProperty paramDefProp =
          build.getProject().getProperty(ParametersDefinitionProperty.class);
      List<ParameterValue> values = new ArrayList<ParameterValue>();
      ParametersAction paramAction = build.getAction(ParametersAction.class);
      JSONObject formData = req.getSubmittedForm();
      if (!formData.isEmpty()) {
        JSONArray a = JSONArray.fromObject(formData.get("parameter"));
        for (Object o : a) {
          JSONObject jo = (JSONObject) o;
          String name = jo.getString("name");
          ParameterValue parameterValue =
              getParameterValue(paramDefProp, name, paramAction, req, jo);
          if (parameterValue != null) {
            values.add(parameterValue);
          }
        }
      }

      CauseAction cause = new CauseAction(new RebuildCause(build));
      Hudson.getInstance()
          .getQueue()
          .schedule(build.getProject(), 0, new ParametersAction(values), cause);
      rsp.sendRedirect("../../");
    }
  }
 // 到货操作
 @RequestMapping(value = "/addArr.json", method = RequestMethod.POST)
 @ResponseBody
 private Object addArr(String purchaseArr, String data) {
   JSONObject purchase = JSONObject.fromObject(purchaseArr);
   PurchaseArrival arr = (PurchaseArrival) JSONObject.toBean(purchase, PurchaseArrival.class);
   JSONArray array = JSONArray.fromObject(data);
   List<PurchaseOrderDetail> list = new ArrayList<PurchaseOrderDetail>();
   for (int i = 0; i < array.toArray().length; i++) { // 遍历循环,去除最后一项统计栏的信息
     JSONObject json = JSONObject.fromObject(array.toArray()[i]);
     PurchaseOrderDetail resourceBean =
         (PurchaseOrderDetail) JSONObject.toBean(json, PurchaseOrderDetail.class);
     if (resourceBean.getGoodsCode().equals("<b>统计:</b>")) {
       continue;
     }
     if (arr.getNotPayAmo() == null) {
       arr.setNotPayAmo(new BigDecimal(0));
     }
     if (arr.getAlrInvAmo() == null) {
       arr.setAlrInvAmo(new BigDecimal(0));
     }
     if (arr.getNotReturnAmo() == null) {
       arr.setNotReturnAmo(new BigDecimal(0));
     }
     arr.setNotPayAmo(arr.getNotPayAmo().add(resourceBean.getMoney())); // 未付款金额
     arr.setAlrInvAmo(arr.getAlrInvAmo().add(resourceBean.getMoney())); // 已开票金额
     arr.setNotReturnAmo(arr.getNotReturnAmo().add(resourceBean.getMoney())); // 未退货金额
     list.add(resourceBean);
   }
   return purchaseOrderService.addPurchaseArr(arr, list);
 }
  /** Web method to handle the approval action submitted by the user. */
  public void doApprove(
      StaplerRequest req,
      StaplerResponse rsp,
      @AncestorInPath PromotionProcess promotionProcess,
      @AncestorInPath AbstractBuild<?, ?> build)
      throws IOException, ServletException {

    JSONObject formData = req.getSubmittedForm();

    if (canApprove(promotionProcess, build)) {
      List<ParameterValue> paramValues = new ArrayList<ParameterValue>();

      if (parameterDefinitions != null && !parameterDefinitions.isEmpty()) {
        JSONArray a = JSONArray.fromObject(formData.get("parameter"));

        for (Object o : a) {
          JSONObject jo = (JSONObject) o;
          String name = jo.getString("name");

          ParameterDefinition d = getParameterDefinition(name);
          if (d == null)
            throw new IllegalArgumentException("No such parameter definition: " + name);

          paramValues.add(d.createValue(req, jo));
        }
      }
      approve(build, promotionProcess, paramValues);
    }

    rsp.sendRedirect2("../../../..");
  }
Пример #30
0
  public String execute() throws Exception {

    response.setCharacterEncoding("UTF-8"); // 编码
    int count = memberFriendService.findMemberCountByInsertDate(insertDate); // 统计数量
    List list =
        memberFriendService.findMemerFriendListByTime(page, rows, insertDate); // 根据投票选项编号,查找详情列表
    PrintWriter out = response.getWriter();
    try {
      JsonConfig cfg = new JsonConfig();
      cfg.registerJsonValueProcessor(
          java.util.Date.class, new DateJsonValueProcessor("yyyy-MM-dd"));
      JSONArray arr = JSONArray.fromObject(list, cfg);
      JSONObject jsonObj = new JSONObject();
      jsonObj.put("rows", arr);
      jsonObj.put("total", count);
      out.write(jsonObj.toString());
      out.flush();
      out.close();

    } catch (Exception e) {

      e.printStackTrace();
    }
    return null;
  }